@@ -113,6 +113,7 @@ static unsigned long common_pin_config[] __initdata = {
static struct pxa_gpio_platform_data pxa168_gpio_pdata = {
.nr_gpios = 128,
+ .irq_base = IRQ_GPIO_START,
.ed_mask = true,
};
@@ -35,6 +35,7 @@ static unsigned long avengers_lite_pin_config_V16F[] __initdata = {
static struct pxa_gpio_platform_data pxa168_gpio_pdata = {
.nr_gpios = 128,
+ .irq_base = IRQ_GPIO_START,
.ed_mask = true,
};
@@ -107,6 +107,7 @@ static unsigned long brownstone_pin_config[] __initdata = {
static struct pxa_gpio_platform_data mmp2_gpio_pdata = {
.nr_gpios = 192,
+ .irq_base = IRQ_GPIO_START,
.ed_mask = true,
};
@@ -80,6 +80,7 @@ static unsigned long flint_pin_config[] __initdata = {
static struct pxa_gpio_platform_data mmp2_gpio_pdata = {
.nr_gpios = 192,
+ .irq_base = IRQ_GPIO_START,
.ed_mask = true,
};
@@ -130,6 +130,7 @@ static unsigned long gplugd_pin_config[] __initdata = {
static struct pxa_gpio_platform_data pxa168_gpio_pdata = {
.nr_gpios = 128,
+ .irq_base = IRQ_GPIO_START,
.ed_mask = true,
};
@@ -63,6 +63,7 @@ static unsigned long tavorevb_pin_config[] __initdata = {
static struct pxa_gpio_platform_data ttc_dkb_gpio_pdata = {
.nr_gpios = 128,
+ .irq_base = IRQ_GPIO_START,
.ed_mask = true,
};
@@ -52,6 +52,7 @@ static unsigned long teton_bga_pin_config[] __initdata = {
static struct pxa_gpio_platform_data pxa168_gpio_pdata = {
.nr_gpios = 128,
+ .irq_base = IRQ_GPIO_START,
.ed_mask = true,
};
@@ -78,6 +78,7 @@ static unsigned long ttc_dkb_pin_config[] __initdata = {
static struct pxa_gpio_platform_data ttc_dkb_gpio_pdata = {
.nr_gpios = 128,
+ .irq_base = IRQ_GPIO_START,
.ed_mask = true,
};
@@ -346,6 +346,7 @@ static struct pxa_gpio_platform_data pxa25x_gpio_info __initdata = {
#else
.nr_gpios = 85,
#endif
+ .irq_base = PXA_GPIO_IRQ_BASE,
.gafr = true,
.gpio_set_wake = gpio_set_wake,
};
@@ -433,6 +433,7 @@ void __init pxa27x_set_i2c_power_info(struct i2c_pxa_platform_data *info)
static struct pxa_gpio_platform_data pxa27x_gpio_info __initdata = {
.gafr = true,
.nr_gpios = 121,
+ .irq_base = PXA_GPIO_IRQ_BASE,
.gpio_set_wake = gpio_set_wake,
};
@@ -438,6 +438,7 @@ void __init pxa3xx_set_i2c_power_info(struct i2c_pxa_platform_data *info)
static struct pxa_gpio_platform_data pxa3xx_gpio_info __initdata = {
.nr_gpios = 128,
+ .irq_base = PXA_GPIO_IRQ_BASE,
};
static struct platform_device *devices[] __initdata = {
@@ -451,9 +451,10 @@ static int pxa_gpio_probe_dt(struct platform_device *pdev)
#endif
static int pxa_init_gpio_chip(struct platform_device *pdev, int gpio_end,
- int (*set_wake)(unsigned int, unsigned int))
+ struct pxa_gpio_platform_data *pdata)
{
int i, gpio, nbanks = gpio_to_bank(gpio_end) + 1;
+ int irq_base;
struct pxa_gpio_chip *chips;
struct device_node *next = NULL, *np = NULL;
@@ -473,12 +474,17 @@ static int pxa_init_gpio_chip(struct platform_device *pdev, int gpio_end,
sprintf(chips[i].label, "gpio-%d", i);
chips[i].regbase = gpio_reg_base + BANK_OFF(i);
- chips[i].set_wake = set_wake;
+ if (pdata->gpio_set_wake)
+ chips[i].set_wake = pdata->gpio_set_wake;
/* number of GPIOs on last bank may be less than 32 */
gc->ngpio = (gpio + 31 > gpio_end) ? (gpio_end - gpio + 1) : 32;
- chips[i].irq_base = irq_alloc_descs(-1, 0, gc->ngpio, 0);
+ if (pdata->irq_base)
+ irq_base = pdata->irq_base + gpio;
+ else
+ irq_base = -1;
+ chips[i].irq_base = irq_alloc_descs(irq_base, 0, gc->ngpio, 0);
if (chips[i].irq_base < 0)
return -EINVAL;
if (!irq_domain_add_legacy(pdev->dev.of_node, gc->ngpio,
@@ -557,8 +563,7 @@ static int pxa_gpio_probe(struct platform_device *pdev)
/* Initialize GPIO chips */
pdata = dev_get_platdata(&pdev->dev);
pxa_last_gpio = pdata->nr_gpios - 1;
- ret = pxa_init_gpio_chip(pdev, pxa_last_gpio,
- pdata ? pdata->gpio_set_wake : NULL);
+ ret = pxa_init_gpio_chip(pdev, pxa_last_gpio, pdata);
if (ret < 0)
return ret;
@@ -20,6 +20,7 @@ struct pxa_gpio_platform_data {
bool inverted; /* only valid for PXA26x */
bool gafr; /* only valid for PXA25x/PXA26x/PXA27x */
unsigned nr_gpios;
+ int irq_base;
int (*gpio_set_wake)(unsigned int gpio, unsigned int on);
};
Macro PXA_GPIO_TO_IRQ() & MMP_GPIO_TO_IRQ() is used in machine driver without DT. Although we're allocating irq descriptions dynamically, it may break machine drivers without DT. Append pdata->irq_base. If irq_base is valid, allocate irq descriptions from irq_base. Signed-off-by: Haojian Zhuang <haojian.zhuang@linaro.org> --- arch/arm/mach-mmp/aspenite.c | 1 + arch/arm/mach-mmp/avengers_lite.c | 1 + arch/arm/mach-mmp/brownstone.c | 1 + arch/arm/mach-mmp/flint.c | 1 + arch/arm/mach-mmp/gplugd.c | 1 + arch/arm/mach-mmp/tavorevb.c | 1 + arch/arm/mach-mmp/teton_bga.c | 1 + arch/arm/mach-mmp/ttc_dkb.c | 1 + arch/arm/mach-pxa/pxa25x.c | 1 + arch/arm/mach-pxa/pxa27x.c | 1 + arch/arm/mach-pxa/pxa3xx.c | 1 + drivers/gpio/gpio-pxa.c | 15 ++++++++++----- include/linux/gpio-pxa.h | 1 + 13 files changed, 22 insertions(+), 5 deletions(-)