blob: d875bc3dba3cd044181e29be75084f328234d129 [file] [log] [blame]
Mathias Nymane29482e2012-11-30 12:37:36 +01001#ifndef _LINUX_ACPI_GPIO_H_
2#define _LINUX_ACPI_GPIO_H_
3
Mika Westerberg12028d22013-04-03 13:56:54 +03004#include <linux/device.h>
Mika Westerberg936e15d2013-10-10 11:01:08 +03005#include <linux/err.h>
Mathias Nymane29482e2012-11-30 12:37:36 +01006#include <linux/errno.h>
Mathias Nyman0d1c28a2013-01-28 16:23:10 +02007#include <linux/gpio.h>
Mika Westerberg936e15d2013-10-10 11:01:08 +03008#include <linux/gpio/consumer.h>
Mathias Nymane29482e2012-11-30 12:37:36 +01009
Mika Westerberg12028d22013-04-03 13:56:54 +030010/**
11 * struct acpi_gpio_info - ACPI GPIO specific information
12 * @gpioint: if %true this GPIO is of type GpioInt otherwise type is GpioIo
Mika Westerberge01f4402013-10-10 11:01:10 +030013 * @active_low: in case of @gpioint, the pin is active low
Mika Westerberg12028d22013-04-03 13:56:54 +030014 */
15struct acpi_gpio_info {
16 bool gpioint;
Mika Westerberge01f4402013-10-10 11:01:10 +030017 bool active_low;
Mika Westerberg12028d22013-04-03 13:56:54 +030018};
19
Mathias Nymane29482e2012-11-30 12:37:36 +010020#ifdef CONFIG_GPIO_ACPI
21
Mika Westerberg936e15d2013-10-10 11:01:08 +030022struct gpio_desc *acpi_get_gpiod_by_index(struct device *dev, int index,
23 struct acpi_gpio_info *info);
Mathias Nyman0d1c28a2013-01-28 16:23:10 +020024void acpi_gpiochip_request_interrupts(struct gpio_chip *chip);
Rafael J. Wysocki7fc7acb2013-04-09 15:57:25 +020025void acpi_gpiochip_free_interrupts(struct gpio_chip *chip);
Mathias Nymane29482e2012-11-30 12:37:36 +010026
27#else /* CONFIG_GPIO_ACPI */
28
Mika Westerberg936e15d2013-10-10 11:01:08 +030029static inline struct gpio_desc *
30acpi_get_gpiod_by_index(struct device *dev, int index,
31 struct acpi_gpio_info *info)
Mathias Nymane29482e2012-11-30 12:37:36 +010032{
Mika Westerberg936e15d2013-10-10 11:01:08 +030033 return ERR_PTR(-ENOSYS);
Mika Westerberg12028d22013-04-03 13:56:54 +030034}
35
Mathias Nyman0d1c28a2013-01-28 16:23:10 +020036static inline void acpi_gpiochip_request_interrupts(struct gpio_chip *chip) { }
Rafael J. Wysocki7fc7acb2013-04-09 15:57:25 +020037static inline void acpi_gpiochip_free_interrupts(struct gpio_chip *chip) { }
Mathias Nyman0d1c28a2013-01-28 16:23:10 +020038
Mathias Nymane29482e2012-11-30 12:37:36 +010039#endif /* CONFIG_GPIO_ACPI */
40
Mika Westerberg936e15d2013-10-10 11:01:08 +030041static 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 Nymane29482e2012-11-30 12:37:36 +010051#endif /* _LINUX_ACPI_GPIO_H_ */