From patchwork Tue Feb 19 16:22:23 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Haojian Zhuang X-Patchwork-Id: 14994 Return-Path: X-Original-To: patchwork@peony.canonical.com Delivered-To: patchwork@peony.canonical.com Received: from fiordland.canonical.com (fiordland.canonical.com [91.189.94.145]) by peony.canonical.com (Postfix) with ESMTP id 5F0BA23E24 for ; Tue, 19 Feb 2013 16:23:16 +0000 (UTC) Received: from mail-ve0-f180.google.com (mail-ve0-f180.google.com [209.85.128.180]) by fiordland.canonical.com (Postfix) with ESMTP id 0714BA187A2 for ; Tue, 19 Feb 2013 16:23:15 +0000 (UTC) Received: by mail-ve0-f180.google.com with SMTP id jx10so5861041veb.25 for ; Tue, 19 Feb 2013 08:23:15 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-received:x-forwarded-to:x-forwarded-for:delivered-to:x-received :received-spf:x-received:from:to:cc:subject:date:message-id:x-mailer :in-reply-to:references:x-gm-message-state; bh=Er4X+CjVLYcBXBL+HCbt461050gdendH2urxudDRVh4=; b=by+x82dmLTdLdXAqkciAWAG8fVzVVuS2Pngy0t4F3/ElZ2MOJmnJaA5nMIlq5fFxXQ LcbyWM8zh/w77P4xn/eGKnOEQN2bUl2Oom71HDshBBGVpohnSz3C7yIJwQ25Z2BbcGxg 4zrMEtiaL7p0hegI3fh+o4xXnsI/xCrfl2u9PGYLOif0t6n/tbHPHoxJdO8UQoXPW5eW b8p4gDrn0MAJGJCI+9mlAmMs/YmLJ5i9hlVEkyWSPbc583nTCc8o/3fAYqSGiMQmOppi 3HVttMCB1p6znK72mJSrmc6aVBHk3n3uNLW2E3B87JPe0xgxWo3vo+2/1EgAFkCzmw4R gZ3w== X-Received: by 10.221.0.79 with SMTP id nl15mr21359183vcb.41.1361290995095; Tue, 19 Feb 2013 08:23:15 -0800 (PST) X-Forwarded-To: linaro-patchwork@canonical.com X-Forwarded-For: patch@linaro.org linaro-patchwork@canonical.com Delivered-To: patches@linaro.org Received: by 10.58.145.101 with SMTP id st5csp150703veb; Tue, 19 Feb 2013 08:23:14 -0800 (PST) X-Received: by 10.68.217.164 with SMTP id oz4mr41266385pbc.73.1361290993967; Tue, 19 Feb 2013 08:23:13 -0800 (PST) Received: from mail-da0-f46.google.com (mail-da0-f46.google.com [209.85.210.46]) by mx.google.com with ESMTPS id l7si24341073paz.36.2013.02.19.08.23.13 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 19 Feb 2013 08:23:13 -0800 (PST) Received-SPF: neutral (google.com: 209.85.210.46 is neither permitted nor denied by best guess record for domain of haojian.zhuang@linaro.org) client-ip=209.85.210.46; Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.210.46 is neither permitted nor denied by best guess record for domain of haojian.zhuang@linaro.org) smtp.mail=haojian.zhuang@linaro.org Received: by mail-da0-f46.google.com with SMTP id p5so3065412dak.33 for ; Tue, 19 Feb 2013 08:23:13 -0800 (PST) X-Received: by 10.68.135.3 with SMTP id po3mr42029249pbb.33.1361290993535; Tue, 19 Feb 2013 08:23:13 -0800 (PST) Received: from localhost.localdomain ([27.115.121.39]) by mx.google.com with ESMTPS id rn14sm18472714pbb.33.2013.02.19.08.23.08 (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 19 Feb 2013 08:23:12 -0800 (PST) From: Haojian Zhuang To: grinberg@compulab.co.il, linus.walleij@linaro.org, linux@arm.linux.org.uk, marek.vasut@gmail.com, robert.jarzmik@free.fr, daniel@caiaq.de, linux-arm-kernel@lists.infradead.org, grant.likely@secretlab.ca, cxie4@marvell.com Cc: patches@linaro.org, Haojian Zhuang Subject: [PATCH v4 06/11] gpio: pxa: add irq base in platform data Date: Wed, 20 Feb 2013 00:22:23 +0800 Message-Id: <1361290948-16669-7-git-send-email-haojian.zhuang@linaro.org> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1361290948-16669-1-git-send-email-haojian.zhuang@linaro.org> References: <1361290948-16669-1-git-send-email-haojian.zhuang@linaro.org> X-Gm-Message-State: ALoCoQmpAheBJQlJHesq/QqBY0iEofYSUG/ZjbbMgtNllgItW5eEulg8wnVrPeGrEGc/Q8eMpRnZ Macro PXA_GPIO_TO_IRQ() & MMP_GPIO_TO_IRQ() is used in machine driver without DT. So move them into machine driver. Signed-off-by: Haojian Zhuang Tested-by: Igor Grinberg --- 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 | 22 +++++++++------------- include/linux/gpio-pxa.h | 1 + 13 files changed, 21 insertions(+), 13 deletions(-) diff --git a/arch/arm/mach-mmp/aspenite.c b/arch/arm/mach-mmp/aspenite.c index a3e42dc..5785931 100644 --- a/arch/arm/mach-mmp/aspenite.c +++ b/arch/arm/mach-mmp/aspenite.c @@ -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 = MMP_GPIO_TO_IRQ(0), .ed_mask = true, }; diff --git a/arch/arm/mach-mmp/avengers_lite.c b/arch/arm/mach-mmp/avengers_lite.c index 1ea6502..074fbbe 100644 --- a/arch/arm/mach-mmp/avengers_lite.c +++ b/arch/arm/mach-mmp/avengers_lite.c @@ -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 = MMP_GPIO_TO_IRQ(0), .ed_mask = true, }; diff --git a/arch/arm/mach-mmp/brownstone.c b/arch/arm/mach-mmp/brownstone.c index a32156f..3b4224c 100644 --- a/arch/arm/mach-mmp/brownstone.c +++ b/arch/arm/mach-mmp/brownstone.c @@ -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 = MMP_GPIO_TO_IRQ(0), .ed_mask = true, }; diff --git a/arch/arm/mach-mmp/flint.c b/arch/arm/mach-mmp/flint.c index 3f301b5..00cdf62 100644 --- a/arch/arm/mach-mmp/flint.c +++ b/arch/arm/mach-mmp/flint.c @@ -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 = MMP_GPIO_TO_IRQ(0), .ed_mask = true, }; diff --git a/arch/arm/mach-mmp/gplugd.c b/arch/arm/mach-mmp/gplugd.c index 019b178..78acca4 100644 --- a/arch/arm/mach-mmp/gplugd.c +++ b/arch/arm/mach-mmp/gplugd.c @@ -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 = MMP_GPIO_TO_IRQ(0), .ed_mask = true, }; diff --git a/arch/arm/mach-mmp/tavorevb.c b/arch/arm/mach-mmp/tavorevb.c index 6e8cf80..86ed017 100644 --- a/arch/arm/mach-mmp/tavorevb.c +++ b/arch/arm/mach-mmp/tavorevb.c @@ -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 = MMP_GPIO_TO_IRQ(0), .ed_mask = true, }; diff --git a/arch/arm/mach-mmp/teton_bga.c b/arch/arm/mach-mmp/teton_bga.c index b5146bb..db65631 100644 --- a/arch/arm/mach-mmp/teton_bga.c +++ b/arch/arm/mach-mmp/teton_bga.c @@ -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 = MMP_GPIO_TO_IRQ(0), .ed_mask = true, }; diff --git a/arch/arm/mach-mmp/ttc_dkb.c b/arch/arm/mach-mmp/ttc_dkb.c index 387e3f8..0e0ea87 100644 --- a/arch/arm/mach-mmp/ttc_dkb.c +++ b/arch/arm/mach-mmp/ttc_dkb.c @@ -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 = MMP_GPIO_TO_IRQ(0), .ed_mask = true, }; diff --git a/arch/arm/mach-pxa/pxa25x.c b/arch/arm/mach-pxa/pxa25x.c index 52f94f3..2195e1a 100644 --- a/arch/arm/mach-pxa/pxa25x.c +++ b/arch/arm/mach-pxa/pxa25x.c @@ -346,6 +346,7 @@ static struct pxa_gpio_platform_data pxa25x_gpio_info __initdata = { #else .nr_gpios = 85, #endif + .irq_base = PXA_GPIO_TO_IRQ(0), .gafr = true, .gpio_set_wake = gpio_set_wake, }; diff --git a/arch/arm/mach-pxa/pxa27x.c b/arch/arm/mach-pxa/pxa27x.c index 619b2f2..cb3f443 100644 --- a/arch/arm/mach-pxa/pxa27x.c +++ b/arch/arm/mach-pxa/pxa27x.c @@ -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_TO_IRQ(0), .gpio_set_wake = gpio_set_wake, }; diff --git a/arch/arm/mach-pxa/pxa3xx.c b/arch/arm/mach-pxa/pxa3xx.c index f6bff16..ef0634b 100644 --- a/arch/arm/mach-pxa/pxa3xx.c +++ b/arch/arm/mach-pxa/pxa3xx.c @@ -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_TO_IRQ(0), }; static struct platform_device *devices[] __initdata = { diff --git a/drivers/gpio/gpio-pxa.c b/drivers/gpio/gpio-pxa.c index 472c006..5879f76 100644 --- a/drivers/gpio/gpio-pxa.c +++ b/drivers/gpio/gpio-pxa.c @@ -459,8 +459,6 @@ static int pxa_gpio_probe_dt(struct platform_device *pdev) dev_err(&pdev->dev, "nr-gpios isn't specified\n"); return -ENOTSUPP; } - /* set the platform data */ - pdev->dev.platform_data = pdata; next = of_get_next_child(np, NULL); prev = next; @@ -482,6 +480,9 @@ static int pxa_gpio_probe_dt(struct platform_device *pdev) dev_err(&pdev->dev, "Failed to allocate IRQ numbers\n"); goto err; } + pdata->irq_base = irq_base; + /* set the platform data */ + pdev->dev.platform_data = pdata; domain = irq_domain_add_legacy(np, nr_gpios, irq_base, 0, &pxa_irq_domain_ops, NULL); pxa_gpio_of_node = np; @@ -501,16 +502,13 @@ static int pxa_gpio_probe(struct platform_device *pdev) int irq0 = 0, irq1 = 0, irq_mux, gpio_offset = 0; ret = pxa_gpio_probe_dt(pdev); - if (ret < 0) { -#ifdef CONFIG_ARCH_PXA - irq_base = PXA_GPIO_TO_IRQ(0); -#elif defined(CONFIG_ARCH_MMP) - irq_base = MMP_GPIO_TO_IRQ(0); -#else -#error "gpio-pxa driver can't be used for your architecture" -#endif + if (ret < 0) use_of = 0; - } + info = dev_get_platdata(&pdev->dev); + pxa_last_gpio = info->nr_gpios - 1; + irq_base = info->irq_base; + if (pxa_last_gpio <=0 || irq_base <= 0) + return -EINVAL; irq0 = platform_get_irq_byname(pdev, "gpio0"); irq1 = platform_get_irq_byname(pdev, "gpio1"); @@ -543,8 +541,6 @@ static int pxa_gpio_probe(struct platform_device *pdev) } /* Initialize GPIO chips */ - info = dev_get_platdata(&pdev->dev); - pxa_last_gpio = info->nr_gpios - 1; pxa_init_gpio_chip(pdev, pxa_last_gpio); /* clear all GPIO edge detects */ diff --git a/include/linux/gpio-pxa.h b/include/linux/gpio-pxa.h index d2fa8e0..82c3e73 100644 --- a/include/linux/gpio-pxa.h +++ b/include/linux/gpio-pxa.h @@ -18,6 +18,7 @@ struct pxa_gpio_platform_data { bool inverted; /* only valid for PXA26x */ bool gafr; /* only valid for PXA25x/PXA26x/PXA27x */ unsigned int nr_gpios; + unsigned int irq_base; int (*gpio_set_wake)(unsigned int gpio, unsigned int on); };