Mathias Nyman | e29482e | 2012-11-30 12:37:36 +0100 | [diff] [blame] | 1 | #ifndef _LINUX_ACPI_GPIO_H_ |
| 2 | #define _LINUX_ACPI_GPIO_H_ |
| 3 | |
Mika Westerberg | 12028d2 | 2013-04-03 13:56:54 +0300 | [diff] [blame] | 4 | #include <linux/device.h> |
Mika Westerberg | 936e15d | 2013-10-10 11:01:08 +0300 | [diff] [blame] | 5 | #include <linux/err.h> |
Mathias Nyman | e29482e | 2012-11-30 12:37:36 +0100 | [diff] [blame] | 6 | #include <linux/errno.h> |
Mathias Nyman | 0d1c28a | 2013-01-28 16:23:10 +0200 | [diff] [blame] | 7 | #include <linux/gpio.h> |
Mika Westerberg | 936e15d | 2013-10-10 11:01:08 +0300 | [diff] [blame] | 8 | #include <linux/gpio/consumer.h> |
Mathias Nyman | e29482e | 2012-11-30 12:37:36 +0100 | [diff] [blame] | 9 | |
Mika Westerberg | 12028d2 | 2013-04-03 13:56:54 +0300 | [diff] [blame] | 10 | /** |
| 11 | * struct acpi_gpio_info - ACPI GPIO specific information |
| 12 | * @gpioint: if %true this GPIO is of type GpioInt otherwise type is GpioIo |
Mika Westerberg | e01f440 | 2013-10-10 11:01:10 +0300 | [diff] [blame] | 13 | * @active_low: in case of @gpioint, the pin is active low |
Mika Westerberg | 12028d2 | 2013-04-03 13:56:54 +0300 | [diff] [blame] | 14 | */ |
| 15 | struct acpi_gpio_info { |
| 16 | bool gpioint; |
Mika Westerberg | e01f440 | 2013-10-10 11:01:10 +0300 | [diff] [blame] | 17 | bool active_low; |
Mika Westerberg | 12028d2 | 2013-04-03 13:56:54 +0300 | [diff] [blame] | 18 | }; |
| 19 | |
Mathias Nyman | e29482e | 2012-11-30 12:37:36 +0100 | [diff] [blame] | 20 | #ifdef CONFIG_GPIO_ACPI |
| 21 | |
Mika Westerberg | 936e15d | 2013-10-10 11:01:08 +0300 | [diff] [blame] | 22 | struct gpio_desc *acpi_get_gpiod_by_index(struct device *dev, int index, |
| 23 | struct acpi_gpio_info *info); |
Mathias Nyman | 0d1c28a | 2013-01-28 16:23:10 +0200 | [diff] [blame] | 24 | void acpi_gpiochip_request_interrupts(struct gpio_chip *chip); |
Rafael J. Wysocki | 7fc7acb | 2013-04-09 15:57:25 +0200 | [diff] [blame] | 25 | void acpi_gpiochip_free_interrupts(struct gpio_chip *chip); |
Mathias Nyman | e29482e | 2012-11-30 12:37:36 +0100 | [diff] [blame] | 26 | |
| 27 | #else /* CONFIG_GPIO_ACPI */ |
| 28 | |
Mika Westerberg | 936e15d | 2013-10-10 11:01:08 +0300 | [diff] [blame] | 29 | static inline struct gpio_desc * |
| 30 | acpi_get_gpiod_by_index(struct device *dev, int index, |
| 31 | struct acpi_gpio_info *info) |
Mathias Nyman | e29482e | 2012-11-30 12:37:36 +0100 | [diff] [blame] | 32 | { |
Mika Westerberg | 936e15d | 2013-10-10 11:01:08 +0300 | [diff] [blame] | 33 | return ERR_PTR(-ENOSYS); |
Mika Westerberg | 12028d2 | 2013-04-03 13:56:54 +0300 | [diff] [blame] | 34 | } |
| 35 | |
Mathias Nyman | 0d1c28a | 2013-01-28 16:23:10 +0200 | [diff] [blame] | 36 | static inline void acpi_gpiochip_request_interrupts(struct gpio_chip *chip) { } |
Rafael J. Wysocki | 7fc7acb | 2013-04-09 15:57:25 +0200 | [diff] [blame] | 37 | static inline void acpi_gpiochip_free_interrupts(struct gpio_chip *chip) { } |
Mathias Nyman | 0d1c28a | 2013-01-28 16:23:10 +0200 | [diff] [blame] | 38 | |
Mathias Nyman | e29482e | 2012-11-30 12:37:36 +0100 | [diff] [blame] | 39 | #endif /* CONFIG_GPIO_ACPI */ |
| 40 | |
Mika Westerberg | 936e15d | 2013-10-10 11:01:08 +0300 | [diff] [blame] | 41 | static inline int acpi_get_gpio_by_index(struct device *dev, int index, |
| 42 | struct acpi_gpio_info *info) |
| 43 | { |
| 44 | struct gpio_desc *desc = acpi_get_gpiod_by_index(dev, index, info); |
| 45 | |
| 46 | if (IS_ERR(desc)) |
| 47 | return PTR_ERR(desc); |
| 48 | return desc_to_gpio(desc); |
| 49 | } |
| 50 | |
Mathias Nyman | e29482e | 2012-11-30 12:37:36 +0100 | [diff] [blame] | 51 | #endif /* _LINUX_ACPI_GPIO_H_ */ |