Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

gpio: Add bitmask to block requests to unavailable stmpe GPIOs

GPIOs on these controller are multi-functional. If you decided to use
some of them e.g. as input channels for the ADC, you surely don't want
those pins to be reassigned as simple GPIOs (which may be triggered even
from userspace via 'export'). Same for the touchscreen controller pins.
Since knowledge about the hardware is needed to decide which GPIOs to
reserve, let this bitmask be inside platform_data and provide some
defines to assist potential users.

Signed-off-by: Wolfram Sang <w.sang@pengutronix.de>
Acked-by: Rabin Vincent <rabin.vincent@stericsson.com>
Cc: Linus Walleij <linus.walleij@stericsson.com>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>

authored by

Wolfram Sang and committed by
Samuel Ortiz
b8e9cf0b 8c96aefb

+11
+5
drivers/gpio/stmpe-gpio.c
··· 30 30 struct mutex irq_lock; 31 31 32 32 int irq_base; 33 + unsigned norequest_mask; 33 34 34 35 /* Caches of interrupt control registers for bus_lock */ 35 36 u8 regs[CACHE_NR_REGS][CACHE_NR_BANKS]; ··· 103 102 { 104 103 struct stmpe_gpio *stmpe_gpio = to_stmpe_gpio(chip); 105 104 struct stmpe *stmpe = stmpe_gpio->stmpe; 105 + 106 + if (stmpe_gpio->norequest_mask & (1 << offset)) 107 + return -EINVAL; 106 108 107 109 return stmpe_set_altfunc(stmpe, 1 << offset, STMPE_BLOCK_GPIO); 108 110 } ··· 306 302 307 303 stmpe_gpio->dev = &pdev->dev; 308 304 stmpe_gpio->stmpe = stmpe; 305 + stmpe_gpio->norequest_mask = pdata ? pdata->norequest_mask : 0; 309 306 310 307 stmpe_gpio->chip = template_chip; 311 308 stmpe_gpio->chip.ngpio = stmpe->num_gpios;
+6
include/linux/mfd/stmpe.h
··· 112 112 bool no_autorepeat; 113 113 }; 114 114 115 + #define STMPE_GPIO_NOREQ_811_TOUCH (0xf0) 116 + 115 117 /** 116 118 * struct stmpe_gpio_platform_data - STMPE GPIO platform data 117 119 * @gpio_base: first gpio number assigned. A maximum of 118 120 * %STMPE_NR_GPIOS GPIOs will be allocated. 121 + * @norequest_mask: bitmask specifying which GPIOs should _not_ be 122 + * requestable due to different usage (e.g. touch, keypad) 123 + * STMPE_GPIO_NOREQ_* macros can be used here. 119 124 */ 120 125 struct stmpe_gpio_platform_data { 121 126 int gpio_base; 127 + unsigned norequest_mask; 122 128 void (*setup)(struct stmpe *stmpe, unsigned gpio_base); 123 129 void (*remove)(struct stmpe *stmpe, unsigned gpio_base); 124 130 };