From patchwork Wed Jan 23 08:25:50 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Haojian Zhuang X-Patchwork-Id: 14232 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 19C2623E1A for ; Wed, 23 Jan 2013 08:26:26 +0000 (UTC) Received: from mail-vb0-f46.google.com (mail-vb0-f46.google.com [209.85.212.46]) by fiordland.canonical.com (Postfix) with ESMTP id 9CA5FA18D32 for ; Wed, 23 Jan 2013 08:26:25 +0000 (UTC) Received: by mail-vb0-f46.google.com with SMTP id b13so7329100vby.19 for ; Wed, 23 Jan 2013 00:26:25 -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=yBAgEW8Yh9QaDi6gtK4HceAIss3ddJYGh5UiK09YOSE=; b=V33dmcvReeZfRP7BYzAcqwmoDdODtgS0qM+L22zxIEHH3k6AfGUoHbVYW5R9rNrnwd jvpsyOnv5xdWIZ6+WOQWP0GkFAip7zmg67CuqejNFG1NMCbrgaai6ih/snWgLw9hwszG 9stvTSLUj7Gnvsbnm/gYYnqI6zPnA6Ks+rTmXNnQ1gBRTx0XjulZ8sJmD8xuQqEcinzb x5BwOFhjjjvmzT0QGrHJTNdF9aVFYso1AlwF5d18vbDuZWsw9hJKosIqONMaVl88XDdn c0jQuDsdUilb4tMhv5Wq4NYwKP7WePJAsb+D1BXRcuWr/flK3ytg5T14b71PuCzgfm1h 28Fw== X-Received: by 10.52.18.147 with SMTP id w19mr365257vdd.94.1358929585137; Wed, 23 Jan 2013 00:26:25 -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 st5csp292079veb; Wed, 23 Jan 2013 00:26:24 -0800 (PST) X-Received: by 10.66.83.6 with SMTP id m6mr2469049pay.52.1358929583966; Wed, 23 Jan 2013 00:26:23 -0800 (PST) Received: from mail-pa0-f52.google.com (mail-pa0-f52.google.com [209.85.220.52]) by mx.google.com with ESMTPS id h8si20055386pay.221.2013.01.23.00.26.23 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 23 Jan 2013 00:26:23 -0800 (PST) Received-SPF: neutral (google.com: 209.85.220.52 is neither permitted nor denied by best guess record for domain of haojian.zhuang@linaro.org) client-ip=209.85.220.52; Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.220.52 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-pa0-f52.google.com with SMTP id fb1so4596819pad.25 for ; Wed, 23 Jan 2013 00:26:23 -0800 (PST) X-Received: by 10.66.90.72 with SMTP id bu8mr2383144pab.69.1358929583566; Wed, 23 Jan 2013 00:26:23 -0800 (PST) Received: from localhost.localdomain ([98.126.173.75]) by mx.google.com with ESMTPS id qf7sm12392126pbb.49.2013.01.23.00.26.20 (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 23 Jan 2013 00:26:22 -0800 (PST) From: Haojian Zhuang To: linux@arm.linux.org.uk, marek.vasut@gmail.com, robert.jarzmik@free.fr, daniel@caiaq.de, linux-arm-kernel@lists.infradead.org, linus.walleij@linaro.org, grant.likely@secretlab.ca, cxie4@marvell.com Cc: patches@linaro.org, Haojian Zhuang Subject: [PATCH 06/10] gpio: pxa: define nr gpios in platform data Date: Wed, 23 Jan 2013 16:25:50 +0800 Message-Id: <1358929554-32265-7-git-send-email-haojian.zhuang@linaro.org> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1358929554-32265-1-git-send-email-haojian.zhuang@linaro.org> References: <1358929554-32265-1-git-send-email-haojian.zhuang@linaro.org> X-Gm-Message-State: ALoCoQnTsvmx0GrtEpZk25q6Jg0kuX3YFOGD2PcbnVQg+R3DW1R/IRHeFD5CgMlmJaqVe5tg4KmU Avoid to define gpio numbers in gpio driver. Define it in platform data instead. Signed-off-by: Haojian Zhuang --- 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 | 3 +++ arch/arm/mach-pxa/pxa27x.c | 1 + arch/arm/mach-pxa/pxa3xx.c | 15 +++++++++++- drivers/gpio/gpio-pxa.c | 48 +++++++------------------------------ include/linux/gpio-pxa.h | 1 + 13 files changed, 35 insertions(+), 41 deletions(-) diff --git a/arch/arm/mach-mmp/aspenite.c b/arch/arm/mach-mmp/aspenite.c index ee1fb62..f5aea07 100644 --- a/arch/arm/mach-mmp/aspenite.c +++ b/arch/arm/mach-mmp/aspenite.c @@ -112,6 +112,7 @@ static unsigned long common_pin_config[] __initdata = { }; static struct pxa_gpio_platform_data pxa168_gpio_pdata = { + .nr_gpios = 128, .ed_mask = 1, }; diff --git a/arch/arm/mach-mmp/avengers_lite.c b/arch/arm/mach-mmp/avengers_lite.c index 8b4b1ae..2f93f8f 100644 --- a/arch/arm/mach-mmp/avengers_lite.c +++ b/arch/arm/mach-mmp/avengers_lite.c @@ -34,6 +34,7 @@ static unsigned long avengers_lite_pin_config_V16F[] __initdata = { }; static struct pxa_gpio_platform_data pxa168_gpio_pdata = { + .nr_gpios = 128, .ed_mask = 1, }; diff --git a/arch/arm/mach-mmp/brownstone.c b/arch/arm/mach-mmp/brownstone.c index 0454488..7f07cc5 100644 --- a/arch/arm/mach-mmp/brownstone.c +++ b/arch/arm/mach-mmp/brownstone.c @@ -106,6 +106,7 @@ static unsigned long brownstone_pin_config[] __initdata = { }; static struct pxa_gpio_platform_data mmp2_gpio_pdata = { + .nr_gpios = 192, .ed_mask = 1, }; diff --git a/arch/arm/mach-mmp/flint.c b/arch/arm/mach-mmp/flint.c index 7ec873c..bf37d97 100644 --- a/arch/arm/mach-mmp/flint.c +++ b/arch/arm/mach-mmp/flint.c @@ -79,6 +79,7 @@ static unsigned long flint_pin_config[] __initdata = { }; static struct pxa_gpio_platform_data mmp2_gpio_pdata = { + .nr_gpios = 192, .ed_mask = 1, }; diff --git a/arch/arm/mach-mmp/gplugd.c b/arch/arm/mach-mmp/gplugd.c index d592041..47808e1 100644 --- a/arch/arm/mach-mmp/gplugd.c +++ b/arch/arm/mach-mmp/gplugd.c @@ -129,6 +129,7 @@ static unsigned long gplugd_pin_config[] __initdata = { }; static struct pxa_gpio_platform_data pxa168_gpio_pdata = { + .nr_gpios = 128, .ed_mask = 1, }; diff --git a/arch/arm/mach-mmp/tavorevb.c b/arch/arm/mach-mmp/tavorevb.c index a855e69..dd4a22b 100644 --- a/arch/arm/mach-mmp/tavorevb.c +++ b/arch/arm/mach-mmp/tavorevb.c @@ -62,6 +62,7 @@ static unsigned long tavorevb_pin_config[] __initdata = { }; static struct pxa_gpio_platform_data ttc_dkb_gpio_pdata = { + .nr_gpios = 128, .ed_mask = 1, }; diff --git a/arch/arm/mach-mmp/teton_bga.c b/arch/arm/mach-mmp/teton_bga.c index 9f64f37..b3e7bf9 100644 --- a/arch/arm/mach-mmp/teton_bga.c +++ b/arch/arm/mach-mmp/teton_bga.c @@ -51,6 +51,7 @@ static unsigned long teton_bga_pin_config[] __initdata = { }; static struct pxa_gpio_platform_data pxa168_gpio_pdata = { + .nr_gpios = 128, .ed_mask = 1, }; diff --git a/arch/arm/mach-mmp/ttc_dkb.c b/arch/arm/mach-mmp/ttc_dkb.c index 74081cd..597268c 100644 --- a/arch/arm/mach-mmp/ttc_dkb.c +++ b/arch/arm/mach-mmp/ttc_dkb.c @@ -75,6 +75,7 @@ static unsigned long ttc_dkb_pin_config[] __initdata = { }; static struct pxa_gpio_platform_data ttc_dkb_gpio_pdata = { + .nr_gpios = 128, .ed_mask = 1, }; diff --git a/arch/arm/mach-pxa/pxa25x.c b/arch/arm/mach-pxa/pxa25x.c index 90415a6..eb82ece 100644 --- a/arch/arm/mach-pxa/pxa25x.c +++ b/arch/arm/mach-pxa/pxa25x.c @@ -342,6 +342,9 @@ void __init pxa25x_map_io(void) static struct pxa_gpio_platform_data pxa25x_gpio_info __initdata = { #ifdef CONFIG_CPU_PXA26x .inverted = 1, + .nr_gpios = 90, +#else + .nr_gpios = 85, #endif .gafr = 1, .gpio_set_wake = gpio_set_wake, diff --git a/arch/arm/mach-pxa/pxa27x.c b/arch/arm/mach-pxa/pxa27x.c index 91ac5d9..8e6b164 100644 --- a/arch/arm/mach-pxa/pxa27x.c +++ b/arch/arm/mach-pxa/pxa27x.c @@ -423,6 +423,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 = 1, + .nr_gpios = 121, .gpio_set_wake = gpio_set_wake, }; diff --git a/arch/arm/mach-pxa/pxa3xx.c b/arch/arm/mach-pxa/pxa3xx.c index 656a1bb..a0cc797 100644 --- a/arch/arm/mach-pxa/pxa3xx.c +++ b/arch/arm/mach-pxa/pxa3xx.c @@ -435,6 +435,10 @@ void __init pxa3xx_set_i2c_power_info(struct i2c_pxa_platform_data *info) pxa_register_device(&pxa3xx_device_i2c_power, info); } +static struct pxa_gpio_platform_data pxa3xx_gpio_info __initdata = { + .nr_gpios = 128, +}; + static struct platform_device *devices[] __initdata = { &pxa_device_gpio, &pxa27x_device_udc, @@ -482,8 +486,17 @@ static int __init pxa3xx_init(void) register_syscore_ops(&pxa3xx_mfp_syscore_ops); register_syscore_ops(&pxa3xx_clock_syscore_ops); - if (!of_have_populated_dt()) + if (!of_have_populated_dt()) { + if (cpu_is_pxa93x()) + pxa3xx_gpio_info.nr_gpios = 192; + ret = platform_device_add_data(&pxa_device_gpio, + &pxa3xx_gpio_info, + sizeof(struct pxa_gpio_platform_data); + if (ret < 0) + break; + ret = platform_add_devices(devices, ARRAY_SIZE(devices)); + } } return ret; diff --git a/drivers/gpio/gpio-pxa.c b/drivers/gpio/gpio-pxa.c index 8b3edc7..67be225 100644 --- a/drivers/gpio/gpio-pxa.c +++ b/drivers/gpio/gpio-pxa.c @@ -380,36 +380,6 @@ static struct irq_chip pxa_muxed_gpio_chip = { .irq_set_wake = pxa_gpio_set_wake, }; -static int pxa_gpio_nums(void) -{ - int count = 0; - -#ifdef CONFIG_ARCH_PXA - if (cpu_is_pxa25x()) { -#ifdef CONFIG_CPU_PXA26x - count = 89; -#elif defined(CONFIG_PXA25x) - count = 84; -#endif /* CONFIG_CPU_PXA26x */ - } else if (cpu_is_pxa27x()) { - count = 120; - } else if (cpu_is_pxa93x()) { - count = 191; - } else if (cpu_is_pxa3xx()) { - count = 127; - } -#endif /* CONFIG_ARCH_PXA */ - -#ifdef CONFIG_ARCH_MMP - if (cpu_is_pxa168() || cpu_is_pxa910()) { - count = 127; - } else if (cpu_is_mmp2()) { - count = 191; - } -#endif /* CONFIG_ARCH_MMP */ - return count; -} - #ifdef CONFIG_OF static struct of_device_id pxa_gpio_dt_ids[] = { { .compatible = "mrvl,pxa-gpio" }, @@ -433,7 +403,7 @@ static const struct irq_domain_ops pxa_irq_domain_ops = { static int pxa_gpio_probe_dt(struct platform_device *pdev) { - int ret, nr_banks, nr_gpios; + int ret, nr_banks; struct pxa_gpio_platform_data *pdata; struct device_node *prev, *next, *np = pdev->dev.of_node; const struct of_device_id *of_id = @@ -453,6 +423,11 @@ static int pxa_gpio_probe_dt(struct platform_device *pdev) ret = of_find_property(np, "marvell,gpio-inverted", NULL); if (ret) pdata->inverted = 1; + ret = of_property_read_u32(np, "marvell,nr-gpios", &pdata->nr_gpios); + if (ret < 0) { + dev_err(&pdev->dev, "nr-gpios isn't specified\n"); + return -ENOTSUPP; + } /* set the platform data */ pdev->dev.platform_data = pdata; @@ -470,8 +445,6 @@ static int pxa_gpio_probe_dt(struct platform_device *pdev) prev = next; } of_node_put(prev); - nr_gpios = nr_banks << 5; - pxa_last_gpio = nr_gpios - 1; return 0; err: @@ -542,14 +515,8 @@ 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) { - pxa_last_gpio = pxa_gpio_nums(); - } else { + if (!ret) use_of = 1; - } - - if (!pxa_last_gpio) - return -EINVAL; irq0 = platform_get_irq_byname(pdev, "gpio0"); irq1 = platform_get_irq_byname(pdev, "gpio1"); @@ -583,6 +550,7 @@ 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, info ? info->gpio_set_wake : NULL); diff --git a/include/linux/gpio-pxa.h b/include/linux/gpio-pxa.h index 5a9e003..cf17f4c 100644 --- a/include/linux/gpio-pxa.h +++ b/include/linux/gpio-pxa.h @@ -19,6 +19,7 @@ struct pxa_gpio_platform_data { unsigned ed_mask; /* not 0 means ed_mask reg is available */ unsigned gafr; /* only valid for PXA25x/PXA26x/PXA27x */ unsigned inverted; /* only valid for PXA26x */ + unsigned nr_gpios; int (*gpio_set_wake)(unsigned int gpio, unsigned int on); };