4 * Copyright (c) 2012 - 2013 Samsung Electronics Co., Ltd.
6 * Licensed under the Apache License, Version 2.0 (the License);
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
19 #ifndef __GPIO_HANDLER_H__
20 #define __GPIO_HANDLER_H__
23 #include "core/common.h"
25 #define GPIO_DEVICE_CLOSED 0
26 #define GPIO_DEVICE_OPENED 1
28 enum gpio_device_check_type {
29 GPIO_DEVICE_UNKNOWN = -1,
30 GPIO_DEVICE_NOT_EXIST = 0,
31 GPIO_DEVICE_EXIST = 1,
33 enum gpio_device_type {
40 enum gpio_device_type type;
46 void register_gpio_device(const struct gpio_device *gpio);
47 void unregister_gpio_device(const struct gpio_device *gpio);
48 const struct gpio_device *find_gpio_device(const char *name);
49 int check_default_gpio_device(const struct gpio_device *dev);
51 #define NOT_SUPPORT_GPIO(gpio) \
52 ((check_default_gpio_device(gpio))? 1 : 0)
54 #define FIND_GPIO_INT(gpio, name) do { \
55 if (!gpio) gpio = find_gpio_device(name); if(check_default_gpio_device(gpio)) return -ENODEV; \
58 #define FIND_GPIO_VOID(gpio, name) do { \
59 if (!gpio) gpio = find_gpio_device(name); if(check_default_gpio_device(gpio)) return; \
63 #endif /* __GPIO_HANDLER_H__ */