From e2098526ff7b0fa5b9aa025d135527bd7357e669 Mon Sep 17 00:00:00 2001 From: Stephen Rothwell Date: Tue, 20 May 2014 18:00:11 +1000 Subject: [PATCH] Revert "mfd: stmpe: root out static GPIO and IRQ assignments" This reverts commit 3ba1d516d5feddba3e13d30d31a70da130a3ee0e. --- drivers/gpio/gpio-stmpe.c | 18 +++++++++++++----- drivers/mfd/stmpe.c | 3 ++- include/linux/mfd/stmpe.h | 14 ++++++++++++++ 3 files changed, 29 insertions(+), 6 deletions(-) diff --git a/drivers/gpio/gpio-stmpe.c b/drivers/gpio/gpio-stmpe.c index 628b58494294..2776a09bee58 100644 --- a/drivers/gpio/gpio-stmpe.c +++ b/drivers/gpio/gpio-stmpe.c @@ -23,8 +23,7 @@ enum { REG_RE, REG_FE, REG_IE }; #define CACHE_NR_REGS 3 -/* No variant has more than 24 GPIOs */ -#define CACHE_NR_BANKS (24 / 8) +#define CACHE_NR_BANKS (STMPE_NR_GPIOS / 8) struct stmpe_gpio { struct gpio_chip chip; @@ -32,6 +31,8 @@ struct stmpe_gpio { struct device *dev; struct mutex irq_lock; struct irq_domain *domain; + + int irq_base; unsigned norequest_mask; /* Caches of interrupt control registers for bus_lock */ @@ -310,8 +311,13 @@ static const struct irq_domain_ops stmpe_gpio_irq_simple_ops = { static int stmpe_gpio_irq_init(struct stmpe_gpio *stmpe_gpio, struct device_node *np) { + int base = 0; + + if (!np) + base = stmpe_gpio->irq_base; + stmpe_gpio->domain = irq_domain_add_simple(np, - stmpe_gpio->chip.ngpio, 0, + stmpe_gpio->chip.ngpio, base, &stmpe_gpio_irq_simple_ops, stmpe_gpio); if (!stmpe_gpio->domain) { dev_err(stmpe_gpio->dev, "failed to create irqdomain\n"); @@ -348,7 +354,7 @@ static int stmpe_gpio_probe(struct platform_device *pdev) #ifdef CONFIG_OF stmpe_gpio->chip.of_node = np; #endif - stmpe_gpio->chip.base = -1; + stmpe_gpio->chip.base = pdata ? pdata->gpio_base : -1; if (pdata) stmpe_gpio->norequest_mask = pdata->norequest_mask; @@ -356,7 +362,9 @@ static int stmpe_gpio_probe(struct platform_device *pdev) of_property_read_u32(np, "st,norequest-mask", &stmpe_gpio->norequest_mask); - if (irq < 0) + if (irq >= 0) + stmpe_gpio->irq_base = stmpe->irq_base + STMPE_INT_GPIO(0); + else dev_info(&pdev->dev, "device configured in no-irq mode; " "irqs are not available\n"); diff --git a/drivers/mfd/stmpe.c b/drivers/mfd/stmpe.c index acda60638b03..294731be1a15 100644 --- a/drivers/mfd/stmpe.c +++ b/drivers/mfd/stmpe.c @@ -1077,7 +1077,7 @@ static int stmpe_chip_init(struct stmpe *stmpe) static int stmpe_add_device(struct stmpe *stmpe, const struct mfd_cell *cell) { return mfd_add_devices(stmpe->dev, stmpe->pdata->id, cell, 1, - NULL, 0, stmpe->domain); + NULL, stmpe->irq_base, stmpe->domain); } static int stmpe_devices_init(struct stmpe *stmpe) @@ -1181,6 +1181,7 @@ int stmpe_probe(struct stmpe_client_info *ci, int partnum) stmpe->dev = ci->dev; stmpe->client = ci->client; stmpe->pdata = pdata; + stmpe->irq_base = pdata->irq_base; stmpe->ci = ci; stmpe->partnum = partnum; stmpe->variant = stmpe_variant_info[partnum]; diff --git a/include/linux/mfd/stmpe.h b/include/linux/mfd/stmpe.h index 575a86c7fcbd..980898620e57 100644 --- a/include/linux/mfd/stmpe.h +++ b/include/linux/mfd/stmpe.h @@ -76,6 +76,7 @@ struct stmpe_client_info; * @regs: list of addresses of registers which are at different addresses on * different variants. Indexed by one of STMPE_IDX_*. * @irq: irq number for stmpe + * @irq_base: starting IRQ number for internal IRQs * @num_gpios: number of gpios, differs for variants * @ier: cache of IER registers for bus_lock * @oldier: cache of IER registers for bus_lock @@ -95,6 +96,7 @@ struct stmpe { const u8 *regs; int irq; + int irq_base; int num_gpios; u8 ier[2]; u8 oldier[2]; @@ -135,6 +137,8 @@ struct stmpe_keypad_platform_data { /** * struct stmpe_gpio_platform_data - STMPE GPIO platform data + * @gpio_base: first gpio number assigned. A maximum of + * %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. @@ -142,6 +146,7 @@ struct stmpe_keypad_platform_data { * @remove: board specific remove callback */ struct stmpe_gpio_platform_data { + int gpio_base; unsigned norequest_mask; void (*setup)(struct stmpe *stmpe, unsigned gpio_base); void (*remove)(struct stmpe *stmpe, unsigned gpio_base); @@ -195,6 +200,8 @@ struct stmpe_ts_platform_data { * @irq_trigger: IRQ trigger to use for the interrupt to the host * @autosleep: bool to enable/disable stmpe autosleep * @autosleep_timeout: inactivity timeout in milliseconds for autosleep + * @irq_base: base IRQ number. %STMPE_NR_IRQS irqs will be used, or + * %STMPE_NR_INTERNAL_IRQS if the GPIO driver is not used. * @irq_over_gpio: true if gpio is used to get irq * @irq_gpio: gpio number over which irq will be requested (significant only if * irq_over_gpio is true) @@ -205,6 +212,7 @@ struct stmpe_ts_platform_data { struct stmpe_platform_data { int id; unsigned int blocks; + int irq_base; unsigned int irq_trigger; bool autosleep; bool irq_over_gpio; @@ -216,4 +224,10 @@ struct stmpe_platform_data { struct stmpe_ts_platform_data *ts; }; +#define STMPE_NR_INTERNAL_IRQS 9 +#define STMPE_INT_GPIO(x) (STMPE_NR_INTERNAL_IRQS + (x)) + +#define STMPE_NR_GPIOS 24 +#define STMPE_NR_IRQS STMPE_INT_GPIO(STMPE_NR_GPIOS) + #endif -- 2.39.5