From patchwork Mon Feb 18 05:12:30 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Haojian Zhuang X-Patchwork-Id: 14954 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 450E523E0D for ; Mon, 18 Feb 2013 05:13:31 +0000 (UTC) Received: from mail-ve0-f169.google.com (mail-ve0-f169.google.com [209.85.128.169]) by fiordland.canonical.com (Postfix) with ESMTP id DA2B7A1852D for ; Mon, 18 Feb 2013 05:13:30 +0000 (UTC) Received: by mail-ve0-f169.google.com with SMTP id 15so4509597vea.14 for ; Sun, 17 Feb 2013 21:13:30 -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=uFZ+BtOWhHgWfp3K8xgJpI2hyfgwhN+weIcx3qvALOs=; b=XPHTLKotAfq54OaxqSMX9X/Yv8Uhh5TlZUMg9ESbc70LuNeMxNJuU4DzFVRgqfmPYU ATgML/s7jfnudJTG5m56Q2VvIc8i2peBqA9g+AxHdeeSGrI5YpwhMRiNOB7mWCTkc0Qw i6II/pjjtH7Jbfp3t6emACVd6+BPQZM+ZumkEWVkXo4M7P887XLB8QXubkfT3iHF9Cay QLRvTTejqtYw5kh1AT0orldsdy5wmp5gKlgKF9Gips0GBPhLnNGC19RG4sJcLLdNvgaF E6PxiZrsW+at889UC+tXkWzw6RELTXPVYR+9N1qpUVNI/Ul3Dtmlsqr4rxsPaajHy/HR tmyg== X-Received: by 10.58.181.201 with SMTP id dy9mr14365380vec.34.1361164410392; Sun, 17 Feb 2013 21:13:30 -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 st5csp72432veb; Sun, 17 Feb 2013 21:13:29 -0800 (PST) X-Received: by 10.68.202.3 with SMTP id ke3mr2958282pbc.98.1361164409323; Sun, 17 Feb 2013 21:13:29 -0800 (PST) Received: from mail-pb0-f48.google.com (mail-pb0-f48.google.com [209.85.160.48]) by mx.google.com with ESMTPS id yh7si11619960pbc.64.2013.02.17.21.13.29 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Sun, 17 Feb 2013 21:13:29 -0800 (PST) Received-SPF: neutral (google.com: 209.85.160.48 is neither permitted nor denied by best guess record for domain of haojian.zhuang@linaro.org) client-ip=209.85.160.48; Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.160.48 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-pb0-f48.google.com with SMTP id wy12so1469429pbc.21 for ; Sun, 17 Feb 2013 21:13:29 -0800 (PST) X-Received: by 10.66.89.226 with SMTP id br2mr32685048pab.57.1361164408909; Sun, 17 Feb 2013 21:13:28 -0800 (PST) Received: from localhost.localdomain ([140.206.155.71]) by mx.google.com with ESMTPS id ni3sm13194880pbc.31.2013.02.17.21.13.21 (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Sun, 17 Feb 2013 21:13:28 -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 v3 04/12] gpio: pxa: remove gpio_type Date: Mon, 18 Feb 2013 13:12:30 +0800 Message-Id: <1361164358-5845-5-git-send-email-haojian.zhuang@linaro.org> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1361164358-5845-1-git-send-email-haojian.zhuang@linaro.org> References: <1361164358-5845-1-git-send-email-haojian.zhuang@linaro.org> X-Gm-Message-State: ALoCoQmSXt+JaB2xjfLAL4bxjJuCsC9Yw6CyaegNeZyhKp7tJoG8k/OUvEGRZw95/7Df5IUlpGb7 Since gpio_type is used to check whether gafr register is valid. So move it into platform data. Signed-off-by: Haojian Zhuang Acked-by: Linus Walleij --- arch/arm/mach-pxa/pxa25x.c | 1 + arch/arm/mach-pxa/pxa27x.c | 1 + drivers/gpio/gpio-pxa.c | 43 ++++++------------------------------------- include/linux/gpio-pxa.h | 1 + 4 files changed, 9 insertions(+), 37 deletions(-) diff --git a/arch/arm/mach-pxa/pxa25x.c b/arch/arm/mach-pxa/pxa25x.c index 66dafb7..3460de1 100644 --- a/arch/arm/mach-pxa/pxa25x.c +++ b/arch/arm/mach-pxa/pxa25x.c @@ -343,6 +343,7 @@ static struct pxa_gpio_platform_data pxa25x_gpio_info __initdata = { #ifdef CONFIG_CPU_PXA26x .inverted = true, #endif + .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 4a63b4e..c2c3120 100644 --- a/arch/arm/mach-pxa/pxa27x.c +++ b/arch/arm/mach-pxa/pxa27x.c @@ -431,6 +431,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, .gpio_set_wake = gpio_set_wake, }; diff --git a/drivers/gpio/gpio-pxa.c b/drivers/gpio/gpio-pxa.c index 1f8dfc8..6c6e21c 100644 --- a/drivers/gpio/gpio-pxa.c +++ b/drivers/gpio/gpio-pxa.c @@ -72,6 +72,7 @@ struct pxa_gpio_chip { void __iomem *regbase; unsigned int irq_base; bool inverted; + bool gafr; char label[10]; unsigned long irq_mask; @@ -87,18 +88,8 @@ struct pxa_gpio_chip { #endif }; -enum { - PXA25X_GPIO = 0, - PXA26X_GPIO, - PXA27X_GPIO, - PXA3XX_GPIO, - PXA93X_GPIO, - MMP_GPIO = 0x10, -}; - static DEFINE_SPINLOCK(gpio_lock); static struct pxa_gpio_chip *pxa_gpio_chips; -static int gpio_type; static void __iomem *gpio_reg_base; #define for_each_gpio_chip(i, c) \ @@ -114,16 +105,6 @@ static inline struct pxa_gpio_chip *gpio_to_pxachip(unsigned gpio) return &pxa_gpio_chips[gpio_to_bank(gpio)]; } -static inline int gpio_is_pxa_type(int type) -{ - return (type & MMP_GPIO) == 0; -} - -static inline int gpio_is_mmp_type(int type) -{ - return (type & MMP_GPIO) != 0; -} - /* GPIO86/87/88/89 on PXA26x have their direction bits in PXA_GPDR(2 inverted, * as well as their Alternate Function value being '1' for GPIO in GAFRx. */ @@ -149,10 +130,7 @@ static inline int __gpio_is_occupied(struct pxa_gpio_chip *chip, unsigned gpio) base = gpio_chip_base(&chip->chip); gpdr = readl_relaxed(base + GPDR_OFFSET); - switch (gpio_type) { - case PXA25X_GPIO: - case PXA26X_GPIO: - case PXA27X_GPIO: + if (chip->gafr) { gafr = readl_relaxed(base + GAFR_OFFSET); af = (gafr >> ((gpio & 0xf) * 2)) & 0x3; dir = gpdr & GPIO_bit(gpio); @@ -161,10 +139,8 @@ static inline int __gpio_is_occupied(struct pxa_gpio_chip *chip, unsigned gpio) ret = (af != 1) || (dir == 0); else ret = (af != 0) || (dir != 0); - break; - default: + } else { ret = gpdr & GPIO_bit(gpio); - break; } return ret; } @@ -412,30 +388,23 @@ static int pxa_gpio_nums(void) if (cpu_is_pxa25x()) { #ifdef CONFIG_CPU_PXA26x count = 89; - gpio_type = PXA26X_GPIO; #elif defined(CONFIG_PXA25x) count = 84; - gpio_type = PXA26X_GPIO; #endif /* CONFIG_CPU_PXA26x */ } else if (cpu_is_pxa27x()) { count = 120; - gpio_type = PXA27X_GPIO; } else if (cpu_is_pxa93x()) { count = 191; - gpio_type = PXA93X_GPIO; } else if (cpu_is_pxa3xx()) { count = 127; - gpio_type = PXA3XX_GPIO; } #endif /* CONFIG_ARCH_PXA */ #ifdef CONFIG_ARCH_MMP if (cpu_is_pxa168() || cpu_is_pxa910()) { count = 127; - gpio_type = MMP_GPIO; } else if (cpu_is_mmp2()) { count = 191; - gpio_type = MMP_GPIO; } #endif /* CONFIG_ARCH_MMP */ return count; @@ -458,7 +427,7 @@ static const struct irq_domain_ops pxa_irq_domain_ops = { #ifdef CONFIG_OF static struct of_device_id pxa_gpio_dt_ids[] = { { .compatible = "mrvl,pxa-gpio" }, - { .compatible = "mrvl,mmp-gpio", .data = (void *)MMP_GPIO }, + { .compatible = "mrvl,mmp-gpio" }, {} }; @@ -484,7 +453,6 @@ static int pxa_gpio_probe_dt(struct platform_device *pdev) pdata->inverted = true; /* set the platform data */ pdev->dev.platform_data = pdata; - gpio_type = (int)of_id->data; next = of_get_next_child(np, NULL); prev = next; @@ -624,8 +592,9 @@ static int pxa_gpio_probe(struct platform_device *pdev) /* unmask GPIO edge detect for AP side */ if (info->ed_mask) writel_relaxed(~0, c->regbase + ED_MASK_OFFSET); - /* update for gpio inverted */ + /* update for gpio inverted & gafr */ c->inverted = info->inverted; + c->gafr = info->gafr; } if (!use_of) { diff --git a/include/linux/gpio-pxa.h b/include/linux/gpio-pxa.h index 0c212a1..80e0322 100644 --- a/include/linux/gpio-pxa.h +++ b/include/linux/gpio-pxa.h @@ -18,6 +18,7 @@ extern int pxa_irq_to_gpio(struct irq_data *d); struct pxa_gpio_platform_data { bool ed_mask; /* true means that ed_mask reg is available */ bool inverted; /* only valid for PXA26x */ + bool gafr; /* only valid for PXA25x/PXA26x/PXA27x */ int (*gpio_set_wake)(unsigned int gpio, unsigned int on); };