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