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 116ea0205bSDavid Brownell #include <linux/types.h> 126ea0205bSDavid Brownell #include <linux/errno.h> 136ea0205bSDavid Brownell 147560fa60SDavid Brownell /* 157560fa60SDavid Brownell * Some platforms don't support the GPIO programming interface. 167560fa60SDavid Brownell * 177560fa60SDavid Brownell * In case some driver uses it anyway (it should normally have 187560fa60SDavid Brownell * depended on GENERIC_GPIO), these routines help the compiler 197560fa60SDavid Brownell * optimize out much GPIO-related code ... or trigger a runtime 207560fa60SDavid Brownell * warning when something is wrongly called. 217560fa60SDavid Brownell */ 227560fa60SDavid Brownell 237560fa60SDavid Brownell static inline int gpio_is_valid(int number) 247560fa60SDavid Brownell { 257560fa60SDavid Brownell return 0; 267560fa60SDavid Brownell } 277560fa60SDavid Brownell 287560fa60SDavid Brownell static inline int gpio_request(unsigned gpio, const char *label) 297560fa60SDavid Brownell { 307560fa60SDavid Brownell return -ENOSYS; 317560fa60SDavid Brownell } 327560fa60SDavid Brownell 337560fa60SDavid Brownell static inline void gpio_free(unsigned gpio) 347560fa60SDavid Brownell { 357560fa60SDavid Brownell /* GPIO can never have been requested */ 367560fa60SDavid Brownell WARN_ON(1); 377560fa60SDavid Brownell } 387560fa60SDavid Brownell 397560fa60SDavid Brownell static inline int gpio_direction_input(unsigned gpio) 407560fa60SDavid Brownell { 417560fa60SDavid Brownell return -ENOSYS; 427560fa60SDavid Brownell } 437560fa60SDavid Brownell 447560fa60SDavid Brownell static inline int gpio_direction_output(unsigned gpio, int value) 457560fa60SDavid Brownell { 467560fa60SDavid Brownell return -ENOSYS; 477560fa60SDavid Brownell } 487560fa60SDavid Brownell 497560fa60SDavid Brownell static inline int gpio_get_value(unsigned gpio) 507560fa60SDavid Brownell { 517560fa60SDavid Brownell /* GPIO can never have been requested or set as {in,out}put */ 527560fa60SDavid Brownell WARN_ON(1); 537560fa60SDavid Brownell return 0; 547560fa60SDavid Brownell } 557560fa60SDavid Brownell 567560fa60SDavid Brownell static inline void gpio_set_value(unsigned gpio, int value) 577560fa60SDavid Brownell { 587560fa60SDavid Brownell /* GPIO can never have been requested or set as output */ 597560fa60SDavid Brownell WARN_ON(1); 607560fa60SDavid Brownell } 617560fa60SDavid Brownell 627560fa60SDavid Brownell static inline int gpio_cansleep(unsigned gpio) 637560fa60SDavid Brownell { 647560fa60SDavid Brownell /* GPIO can never have been requested or set as {in,out}put */ 657560fa60SDavid Brownell WARN_ON(1); 667560fa60SDavid Brownell return 0; 677560fa60SDavid Brownell } 687560fa60SDavid Brownell 697560fa60SDavid Brownell static inline int gpio_get_value_cansleep(unsigned gpio) 707560fa60SDavid Brownell { 717560fa60SDavid Brownell /* GPIO can never have been requested or set as {in,out}put */ 727560fa60SDavid Brownell WARN_ON(1); 737560fa60SDavid Brownell return 0; 747560fa60SDavid Brownell } 757560fa60SDavid Brownell 767560fa60SDavid Brownell static inline void gpio_set_value_cansleep(unsigned gpio, int value) 777560fa60SDavid Brownell { 787560fa60SDavid Brownell /* GPIO can never have been requested or set as output */ 797560fa60SDavid Brownell WARN_ON(1); 807560fa60SDavid Brownell } 817560fa60SDavid Brownell 827560fa60SDavid Brownell static inline int gpio_to_irq(unsigned gpio) 837560fa60SDavid Brownell { 847560fa60SDavid Brownell /* GPIO can never have been requested or set as input */ 857560fa60SDavid Brownell WARN_ON(1); 867560fa60SDavid Brownell return -EINVAL; 877560fa60SDavid Brownell } 887560fa60SDavid Brownell 897560fa60SDavid Brownell static inline int irq_to_gpio(unsigned irq) 907560fa60SDavid Brownell { 917560fa60SDavid Brownell /* irq can never have been returned from gpio_to_irq() */ 927560fa60SDavid Brownell WARN_ON(1); 937560fa60SDavid Brownell return -EINVAL; 947560fa60SDavid Brownell } 957560fa60SDavid Brownell 967560fa60SDavid Brownell #endif 977560fa60SDavid Brownell 987560fa60SDavid Brownell #endif /* __LINUX_GPIO_H */ 99