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 157560fa60SDavid Brownell /* 167560fa60SDavid Brownell * Some platforms don't support the GPIO programming interface. 177560fa60SDavid Brownell * 187560fa60SDavid Brownell * In case some driver uses it anyway (it should normally have 197560fa60SDavid Brownell * depended on GENERIC_GPIO), these routines help the compiler 207560fa60SDavid Brownell * optimize out much GPIO-related code ... or trigger a runtime 217560fa60SDavid Brownell * warning when something is wrongly called. 227560fa60SDavid Brownell */ 237560fa60SDavid Brownell 247560fa60SDavid Brownell static inline int gpio_is_valid(int number) 257560fa60SDavid Brownell { 267560fa60SDavid Brownell return 0; 277560fa60SDavid Brownell } 287560fa60SDavid Brownell 297560fa60SDavid Brownell static inline int gpio_request(unsigned gpio, const char *label) 307560fa60SDavid Brownell { 317560fa60SDavid Brownell return -ENOSYS; 327560fa60SDavid Brownell } 337560fa60SDavid Brownell 347560fa60SDavid Brownell static inline void gpio_free(unsigned gpio) 357560fa60SDavid Brownell { 363d599d1cSUwe Kleine-König might_sleep(); 373d599d1cSUwe Kleine-König 387560fa60SDavid Brownell /* GPIO can never have been requested */ 397560fa60SDavid Brownell WARN_ON(1); 407560fa60SDavid Brownell } 417560fa60SDavid Brownell 427560fa60SDavid Brownell static inline int gpio_direction_input(unsigned gpio) 437560fa60SDavid Brownell { 447560fa60SDavid Brownell return -ENOSYS; 457560fa60SDavid Brownell } 467560fa60SDavid Brownell 477560fa60SDavid Brownell static inline int gpio_direction_output(unsigned gpio, int value) 487560fa60SDavid Brownell { 497560fa60SDavid Brownell return -ENOSYS; 507560fa60SDavid Brownell } 517560fa60SDavid Brownell 527560fa60SDavid Brownell static inline int gpio_get_value(unsigned gpio) 537560fa60SDavid Brownell { 547560fa60SDavid Brownell /* GPIO can never have been requested or set as {in,out}put */ 557560fa60SDavid Brownell WARN_ON(1); 567560fa60SDavid Brownell return 0; 577560fa60SDavid Brownell } 587560fa60SDavid Brownell 597560fa60SDavid Brownell static inline void gpio_set_value(unsigned gpio, int value) 607560fa60SDavid Brownell { 617560fa60SDavid Brownell /* GPIO can never have been requested or set as output */ 627560fa60SDavid Brownell WARN_ON(1); 637560fa60SDavid Brownell } 647560fa60SDavid Brownell 657560fa60SDavid Brownell static inline int gpio_cansleep(unsigned gpio) 667560fa60SDavid Brownell { 677560fa60SDavid Brownell /* GPIO can never have been requested or set as {in,out}put */ 687560fa60SDavid Brownell WARN_ON(1); 697560fa60SDavid Brownell return 0; 707560fa60SDavid Brownell } 717560fa60SDavid Brownell 727560fa60SDavid Brownell static inline int gpio_get_value_cansleep(unsigned gpio) 737560fa60SDavid Brownell { 747560fa60SDavid Brownell /* GPIO can never have been requested or set as {in,out}put */ 757560fa60SDavid Brownell WARN_ON(1); 767560fa60SDavid Brownell return 0; 777560fa60SDavid Brownell } 787560fa60SDavid Brownell 797560fa60SDavid Brownell static inline void gpio_set_value_cansleep(unsigned gpio, int value) 807560fa60SDavid Brownell { 817560fa60SDavid Brownell /* GPIO can never have been requested or set as output */ 827560fa60SDavid Brownell WARN_ON(1); 837560fa60SDavid Brownell } 847560fa60SDavid Brownell 85d8f388d8SDavid Brownell static inline int gpio_export(unsigned gpio, bool direction_may_change) 86d8f388d8SDavid Brownell { 87d8f388d8SDavid Brownell /* GPIO can never have been requested or set as {in,out}put */ 88d8f388d8SDavid Brownell WARN_ON(1); 89d8f388d8SDavid Brownell return -EINVAL; 90d8f388d8SDavid Brownell } 91d8f388d8SDavid Brownell 92d8f388d8SDavid Brownell static inline void gpio_unexport(unsigned gpio) 93d8f388d8SDavid Brownell { 94d8f388d8SDavid Brownell /* GPIO can never have been exported */ 95d8f388d8SDavid Brownell WARN_ON(1); 96d8f388d8SDavid Brownell } 97d8f388d8SDavid Brownell 987560fa60SDavid Brownell static inline int gpio_to_irq(unsigned gpio) 997560fa60SDavid Brownell { 1007560fa60SDavid Brownell /* GPIO can never have been requested or set as input */ 1017560fa60SDavid Brownell WARN_ON(1); 1027560fa60SDavid Brownell return -EINVAL; 1037560fa60SDavid Brownell } 1047560fa60SDavid Brownell 1057560fa60SDavid Brownell static inline int irq_to_gpio(unsigned irq) 1067560fa60SDavid Brownell { 1077560fa60SDavid Brownell /* irq can never have been returned from gpio_to_irq() */ 1087560fa60SDavid Brownell WARN_ON(1); 1097560fa60SDavid Brownell return -EINVAL; 1107560fa60SDavid Brownell } 1117560fa60SDavid Brownell 1127560fa60SDavid Brownell #endif 1137560fa60SDavid Brownell 1147560fa60SDavid Brownell #endif /* __LINUX_GPIO_H */ 115