Commit b8e9cf0b authored by Wolfram Sang's avatar Wolfram Sang Committed by Samuel Ortiz

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: default avatarWolfram Sang <w.sang@pengutronix.de>
Acked-by: default avatarRabin Vincent <rabin.vincent@stericsson.com>
Cc: Linus Walleij <linus.walleij@stericsson.com>
Signed-off-by: default avatarSamuel Ortiz <sameo@linux.intel.com>
parent 8c96aefb
...@@ -30,6 +30,7 @@ struct stmpe_gpio { ...@@ -30,6 +30,7 @@ struct stmpe_gpio {
struct mutex irq_lock; struct mutex irq_lock;
int irq_base; int irq_base;
unsigned norequest_mask;
/* Caches of interrupt control registers for bus_lock */ /* Caches of interrupt control registers for bus_lock */
u8 regs[CACHE_NR_REGS][CACHE_NR_BANKS]; u8 regs[CACHE_NR_REGS][CACHE_NR_BANKS];
...@@ -103,6 +104,9 @@ static int stmpe_gpio_request(struct gpio_chip *chip, unsigned offset) ...@@ -103,6 +104,9 @@ static int stmpe_gpio_request(struct gpio_chip *chip, unsigned offset)
struct stmpe_gpio *stmpe_gpio = to_stmpe_gpio(chip); struct stmpe_gpio *stmpe_gpio = to_stmpe_gpio(chip);
struct stmpe *stmpe = stmpe_gpio->stmpe; struct stmpe *stmpe = stmpe_gpio->stmpe;
if (stmpe_gpio->norequest_mask & (1 << offset))
return -EINVAL;
return stmpe_set_altfunc(stmpe, 1 << offset, STMPE_BLOCK_GPIO); return stmpe_set_altfunc(stmpe, 1 << offset, STMPE_BLOCK_GPIO);
} }
...@@ -302,6 +306,7 @@ static int __devinit stmpe_gpio_probe(struct platform_device *pdev) ...@@ -302,6 +306,7 @@ static int __devinit stmpe_gpio_probe(struct platform_device *pdev)
stmpe_gpio->dev = &pdev->dev; stmpe_gpio->dev = &pdev->dev;
stmpe_gpio->stmpe = stmpe; stmpe_gpio->stmpe = stmpe;
stmpe_gpio->norequest_mask = pdata ? pdata->norequest_mask : 0;
stmpe_gpio->chip = template_chip; stmpe_gpio->chip = template_chip;
stmpe_gpio->chip.ngpio = stmpe->num_gpios; stmpe_gpio->chip.ngpio = stmpe->num_gpios;
......
...@@ -112,13 +112,19 @@ struct stmpe_keypad_platform_data { ...@@ -112,13 +112,19 @@ struct stmpe_keypad_platform_data {
bool no_autorepeat; bool no_autorepeat;
}; };
#define STMPE_GPIO_NOREQ_811_TOUCH (0xf0)
/** /**
* struct stmpe_gpio_platform_data - STMPE GPIO platform data * struct stmpe_gpio_platform_data - STMPE GPIO platform data
* @gpio_base: first gpio number assigned. A maximum of * @gpio_base: first gpio number assigned. A maximum of
* %STMPE_NR_GPIOS GPIOs will be allocated. * %STMPE_NR_GPIOS GPIOs will be allocated.
* @norequest_mask: bitmask specifying which GPIOs should _not_ be
* requestable due to different usage (e.g. touch, keypad)
* STMPE_GPIO_NOREQ_* macros can be used here.
*/ */
struct stmpe_gpio_platform_data { struct stmpe_gpio_platform_data {
int gpio_base; int gpio_base;
unsigned norequest_mask;
void (*setup)(struct stmpe *stmpe, unsigned gpio_base); void (*setup)(struct stmpe *stmpe, unsigned gpio_base);
void (*remove)(struct stmpe *stmpe, unsigned gpio_base); void (*remove)(struct stmpe *stmpe, unsigned gpio_base);
}; };
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment