17560fa60SDavid Brownell #ifndef __LINUX_GPIO_H 27560fa60SDavid Brownell #define __LINUX_GPIO_H 37560fa60SDavid Brownell 47560fa60SDavid Brownell /* see Documentation/gpio.txt */ 57560fa60SDavid Brownell 67560fa60SDavid Brownell #ifdef CONFIG_GENERIC_GPIO 77560fa60SDavid Brownell #include <asm/gpio.h> 87560fa60SDavid Brownell 97560fa60SDavid Brownell #else 107560fa60SDavid Brownell 113d599d1cSUwe Kleine-König #include <linux/kernel.h> 126ea0205bSDavid Brownell #include <linux/types.h> 136ea0205bSDavid Brownell #include <linux/errno.h> 146ea0205bSDavid Brownell 15a4177ee7SJani Nikula struct device; 164e4438b8SAnton Vorontsov struct gpio_chip; 17a4177ee7SJani Nikula 187560fa60SDavid Brownell /* 197560fa60SDavid Brownell * Some platforms don't support the GPIO programming interface. 207560fa60SDavid Brownell * 217560fa60SDavid Brownell * In case some driver uses it anyway (it should normally have 227560fa60SDavid Brownell * depended on GENERIC_GPIO), these routines help the compiler 237560fa60SDavid Brownell * optimize out much GPIO-related code ... or trigger a runtime 247560fa60SDavid Brownell * warning when something is wrongly called. 257560fa60SDavid Brownell */ 267560fa60SDavid Brownell 277560fa60SDavid Brownell static inline int gpio_is_valid(int number) 287560fa60SDavid Brownell { 297560fa60SDavid Brownell return 0; 307560fa60SDavid Brownell } 317560fa60SDavid Brownell 320fdae42dSWolfram Sang static inline int __must_check gpio_request(unsigned gpio, const char *label) 337560fa60SDavid Brownell { 347560fa60SDavid Brownell return -ENOSYS; 357560fa60SDavid Brownell } 367560fa60SDavid Brownell 377560fa60SDavid Brownell static inline void gpio_free(unsigned gpio) 387560fa60SDavid Brownell { 393d599d1cSUwe Kleine-König might_sleep(); 403d599d1cSUwe Kleine-König 417560fa60SDavid Brownell /* GPIO can never have been requested */ 427560fa60SDavid Brownell WARN_ON(1); 437560fa60SDavid Brownell } 447560fa60SDavid Brownell 450fdae42dSWolfram Sang static inline int __must_check gpio_direction_input(unsigned gpio) 467560fa60SDavid Brownell { 477560fa60SDavid Brownell return -ENOSYS; 487560fa60SDavid Brownell } 497560fa60SDavid Brownell 500fdae42dSWolfram Sang static inline int __must_check gpio_direction_output(unsigned gpio, int value) 517560fa60SDavid Brownell { 527560fa60SDavid Brownell return -ENOSYS; 537560fa60SDavid Brownell } 547560fa60SDavid Brownell 55c4b5be98SFelipe Balbi static inline int gpio_set_debounce(unsigned gpio, unsigned debounce) 56c4b5be98SFelipe Balbi { 57c4b5be98SFelipe Balbi return -ENOSYS; 58c4b5be98SFelipe Balbi } 59c4b5be98SFelipe Balbi 607560fa60SDavid Brownell static inline int gpio_get_value(unsigned gpio) 617560fa60SDavid Brownell { 627560fa60SDavid Brownell /* GPIO can never have been requested or set as {in,out}put */ 637560fa60SDavid Brownell WARN_ON(1); 647560fa60SDavid Brownell return 0; 657560fa60SDavid Brownell } 667560fa60SDavid Brownell 677560fa60SDavid Brownell static inline void gpio_set_value(unsigned gpio, int value) 687560fa60SDavid Brownell { 697560fa60SDavid Brownell /* GPIO can never have been requested or set as output */ 707560fa60SDavid Brownell WARN_ON(1); 717560fa60SDavid Brownell } 727560fa60SDavid Brownell 737560fa60SDavid Brownell static inline int gpio_cansleep(unsigned gpio) 747560fa60SDavid Brownell { 757560fa60SDavid Brownell /* GPIO can never have been requested or set as {in,out}put */ 767560fa60SDavid Brownell WARN_ON(1); 777560fa60SDavid Brownell return 0; 787560fa60SDavid Brownell } 797560fa60SDavid Brownell 807560fa60SDavid Brownell static inline int gpio_get_value_cansleep(unsigned gpio) 817560fa60SDavid Brownell { 827560fa60SDavid Brownell /* GPIO can never have been requested or set as {in,out}put */ 837560fa60SDavid Brownell WARN_ON(1); 847560fa60SDavid Brownell return 0; 857560fa60SDavid Brownell } 867560fa60SDavid Brownell 877560fa60SDavid Brownell static inline void gpio_set_value_cansleep(unsigned gpio, int value) 887560fa60SDavid Brownell { 897560fa60SDavid Brownell /* GPIO can never have been requested or set as output */ 907560fa60SDavid Brownell WARN_ON(1); 917560fa60SDavid Brownell } 927560fa60SDavid Brownell 93d8f388d8SDavid Brownell static inline int gpio_export(unsigned gpio, bool direction_may_change) 94d8f388d8SDavid Brownell { 95d8f388d8SDavid Brownell /* GPIO can never have been requested or set as {in,out}put */ 96d8f388d8SDavid Brownell WARN_ON(1); 97d8f388d8SDavid Brownell return -EINVAL; 98d8f388d8SDavid Brownell } 99d8f388d8SDavid Brownell 100a4177ee7SJani Nikula static inline int gpio_export_link(struct device *dev, const char *name, 101a4177ee7SJani Nikula unsigned gpio) 102a4177ee7SJani Nikula { 103a4177ee7SJani Nikula /* GPIO can never have been exported */ 104a4177ee7SJani Nikula WARN_ON(1); 105a4177ee7SJani Nikula return -EINVAL; 106a4177ee7SJani Nikula } 107a4177ee7SJani Nikula 10807697461SJani Nikula static inline int gpio_sysfs_set_active_low(unsigned gpio, int value) 10907697461SJani Nikula { 11007697461SJani Nikula /* GPIO can never have been requested */ 11107697461SJani Nikula WARN_ON(1); 11207697461SJani Nikula return -EINVAL; 11307697461SJani Nikula } 114a4177ee7SJani Nikula 115d8f388d8SDavid Brownell static inline void gpio_unexport(unsigned gpio) 116d8f388d8SDavid Brownell { 117d8f388d8SDavid Brownell /* GPIO can never have been exported */ 118d8f388d8SDavid Brownell WARN_ON(1); 119d8f388d8SDavid Brownell } 120d8f388d8SDavid Brownell 1217560fa60SDavid Brownell static inline int gpio_to_irq(unsigned gpio) 1227560fa60SDavid Brownell { 1237560fa60SDavid Brownell /* GPIO can never have been requested or set as input */ 1247560fa60SDavid Brownell WARN_ON(1); 1257560fa60SDavid Brownell return -EINVAL; 1267560fa60SDavid Brownell } 1277560fa60SDavid Brownell 1287560fa60SDavid Brownell static inline int irq_to_gpio(unsigned irq) 1297560fa60SDavid Brownell { 1307560fa60SDavid Brownell /* irq can never have been returned from gpio_to_irq() */ 1317560fa60SDavid Brownell WARN_ON(1); 1327560fa60SDavid Brownell return -EINVAL; 1337560fa60SDavid Brownell } 1347560fa60SDavid Brownell 1357560fa60SDavid Brownell #endif 1367560fa60SDavid Brownell 1377560fa60SDavid Brownell #endif /* __LINUX_GPIO_H */ 138