From patchwork Tue Feb 19 16:22:26 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Haojian Zhuang X-Patchwork-Id: 14997 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 6962223E24 for ; Tue, 19 Feb 2013 16:23:36 +0000 (UTC) Received: from mail-ve0-f175.google.com (mail-ve0-f175.google.com [209.85.128.175]) by fiordland.canonical.com (Postfix) with ESMTP id 06D88A18F2B for ; Tue, 19 Feb 2013 16:23:35 +0000 (UTC) Received: by mail-ve0-f175.google.com with SMTP id cy12so5920264veb.20 for ; Tue, 19 Feb 2013 08:23:35 -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=WsWzUwmblRaSMvcixpcuV7s/Sqo9LpdcUmjqIgOq/5U=; b=TktXatlMnHuQVmVw/ikQR9bwhVqFRift6B5OaUhA7IEtCAoWGp4E1cR9hF94/mWzp8 tM331wqe0KQeZpS/Zl+iN+LJ3FLmm9MpYqOtRcMNegZw4K3MjY0qQLz/UVfZVbmxXe1F EfO1Y3a1XPuDp/5qWW+b/8n/w3rtWimHPy/nHc1Wrv+tMT9WxxpTLepp1ICtkdmXyexc Xb/pkIHm0r9h61RrFUpMbkfjOAh+8iUARw+yShMwI654mqxoB2TMM02L1yBZ0tEOFCSz Qbl12TywxniOQ54vzpxnvGmtc+vS8BEGDGC6CxoaS8YpEOaCa0eVaW39lxUwapMxglv2 I7+g== X-Received: by 10.220.39.69 with SMTP id f5mr21418722vce.45.1361291012090; Tue, 19 Feb 2013 08:23:32 -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 st5csp150714veb; Tue, 19 Feb 2013 08:23:31 -0800 (PST) X-Received: by 10.68.138.225 with SMTP id qt1mr6561237pbb.82.1361291010686; Tue, 19 Feb 2013 08:23:30 -0800 (PST) Received: from mail-da0-f49.google.com (mail-da0-f49.google.com [209.85.210.49]) by mx.google.com with ESMTPS id bu4si24428559pab.119.2013.02.19.08.23.30 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 19 Feb 2013 08:23:30 -0800 (PST) Received-SPF: neutral (google.com: 209.85.210.49 is neither permitted nor denied by best guess record for domain of haojian.zhuang@linaro.org) client-ip=209.85.210.49; Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.210.49 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-f49.google.com with SMTP id t11so3029273daj.22 for ; Tue, 19 Feb 2013 08:23:30 -0800 (PST) X-Received: by 10.66.73.165 with SMTP id m5mr46789916pav.78.1361291010243; Tue, 19 Feb 2013 08:23:30 -0800 (PST) Received: from localhost.localdomain ([27.115.121.39]) by mx.google.com with ESMTPS id rn14sm18472714pbb.33.2013.02.19.08.23.25 (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 19 Feb 2013 08:23:29 -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 09/11] gpio: pxa: move gpio properties into child node Date: Wed, 20 Feb 2013 00:22:26 +0800 Message-Id: <1361290948-16669-10-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: ALoCoQl989m3aENdRBZ0zw8diluUcPEh/n+YDvZCbBJsCqZTTvnw4wVIfhs7cJPw78yVqWE9r3LI Move gpio properties into child node. So pinctrl driver could binds to each gpio chip with gpio range. Signed-off-by: Haojian Zhuang Tested-by: Igor Grinberg --- drivers/gpio/gpio-pxa.c | 44 +++++++++++++++++++------------------------- 1 file changed, 19 insertions(+), 25 deletions(-) diff --git a/drivers/gpio/gpio-pxa.c b/drivers/gpio/gpio-pxa.c index 983758f..0f3a350 100644 --- a/drivers/gpio/gpio-pxa.c +++ b/drivers/gpio/gpio-pxa.c @@ -65,7 +65,6 @@ static int irq_base; #ifdef CONFIG_OF static struct irq_domain *domain; -static struct device_node *pxa_gpio_of_node; #endif struct pxa_gpio_chip { @@ -233,8 +232,9 @@ static int pxa_gpio_of_xlate(struct gpio_chip *gc, static int pxa_init_gpio_chip(struct platform_device *pdev, int gpio_end) { int i, gpio, nbanks = gpio_to_bank(gpio_end) + 1; - struct pxa_gpio_chip *chips; struct pxa_gpio_platform_data *pdata = dev_get_platdata(&pdev->dev); + struct pxa_gpio_chip *chips; + struct device_node *next = NULL, *np = NULL; chips = devm_kzalloc(&pdev->dev, nbanks * sizeof(*chips), GFP_KERNEL); if (!chips) { @@ -242,6 +242,11 @@ static int pxa_init_gpio_chip(struct platform_device *pdev, int gpio_end) return -ENOMEM; } + np = pdev->dev.of_node; +#ifdef CONFIG_OF + if (np) + next = of_get_next_child(np, NULL); +#endif for (i = 0, gpio = 0; i < nbanks; i++, gpio += 32) { struct gpio_chip *gc = &chips[i].gc; @@ -258,16 +263,21 @@ static int pxa_init_gpio_chip(struct platform_device *pdev, int gpio_end) gc->get = pxa_gpio_get; gc->set = pxa_gpio_set; gc->to_irq = pxa_gpio_to_irq; -#ifdef CONFIG_OF_GPIO - gc->of_node = pxa_gpio_of_node; - gc->of_xlate = pxa_gpio_of_xlate; - gc->of_gpio_n_cells = 2; +#ifdef CONFIG_OF + if (np) { + gc->of_node = next; + next = of_get_next_child(np, next); + + gc->of_xlate = pxa_gpio_of_xlate; + gc->of_gpio_n_cells = 2; + } #endif /* number of GPIOs on last bank may be less than 32 */ gc->ngpio = (gpio + 31 > gpio_end) ? (gpio_end - gpio + 1) : 32; gpiochip_add(gc); } + of_node_put(next); pxa_gpio_chips = chips; return 0; } @@ -436,9 +446,9 @@ const struct irq_domain_ops pxa_irq_domain_ops = { static int pxa_gpio_probe_dt(struct platform_device *pdev) { - int ret, nr_banks; + int ret; struct pxa_gpio_platform_data *pdata; - struct device_node *prev, *next, *np = pdev->dev.of_node; + struct device_node *np = pdev->dev.of_node; const struct of_device_id *of_id = of_match_device(pxa_gpio_dt_ids, &pdev->dev); @@ -460,32 +470,16 @@ static int pxa_gpio_probe_dt(struct platform_device *pdev) return -ENOTSUPP; } - next = of_get_next_child(np, NULL); - prev = next; - if (!next) { - dev_err(&pdev->dev, "Failed to find child gpio node\n"); - ret = -EINVAL; - goto err; - } - for (nr_banks = 1; ; nr_banks++) { - next = of_get_next_child(np, prev); - if (!next) - break; - prev = next; - } - of_node_put(prev); - irq_base = irq_alloc_descs(-1, 0, nr_gpios, 0); if (irq_base < 0) { dev_err(&pdev->dev, "Failed to allocate IRQ numbers\n"); - goto err; + return -EINVAL; } 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; return 0; } #else