From patchwork Mon Feb 25 03:49:39 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Haojian Zhuang X-Patchwork-Id: 15055 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 9C4D123E27 for ; Mon, 25 Feb 2013 03:51:47 +0000 (UTC) Received: from mail-vb0-f52.google.com (mail-vb0-f52.google.com [209.85.212.52]) by fiordland.canonical.com (Postfix) with ESMTP id 41451A18069 for ; Mon, 25 Feb 2013 03:51:47 +0000 (UTC) Received: by mail-vb0-f52.google.com with SMTP id fa15so1451829vbb.39 for ; Sun, 24 Feb 2013 19:51:46 -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=PQMaYluDSvRrEOhjXko5JCuXETB95dElQbgRSNheNbo=; b=CHEmrmDB1FvL5HUIcSlw4lsiLcTO3g5YpQO8CEGipJKLR7wVUBO1OI7rbZDAP86QSs HSSYP0Oyk5exc2rjthDtakf+G3QWHncHdXw9NmyUsMMjtFV1hVz9GrKihI1mFH7TOxXy wQEO8F6v97W7lZgLbELA0Rz1LBUHeowkQ63uiceu0012HT/cMruCYXciWqDLCoGnSThs jVJ0m4mrpVLbGlmCzEa0HfICkwvx1TrJOLqJ4kyUxYhGvHw9HRKqj7tKRrHoN2B02LH4 tx6dHnOjxBRMalDlLtXGCPxgxKIe2hqNcqEGfN4OwsqCZvKa0q0bulRijMJJ7nODyFMv 4cZQ== X-Received: by 10.58.188.48 with SMTP id fx16mr9564007vec.22.1361764306759; Sun, 24 Feb 2013 19:51:46 -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 st5csp39575veb; Sun, 24 Feb 2013 19:51:46 -0800 (PST) X-Received: by 10.66.182.226 with SMTP id eh2mr16558554pac.159.1361764305706; Sun, 24 Feb 2013 19:51:45 -0800 (PST) Received: from mail-pa0-f48.google.com (mail-pa0-f48.google.com [209.85.220.48]) by mx.google.com with ESMTPS id tv4si10385715pbc.305.2013.02.24.19.51.45 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Sun, 24 Feb 2013 19:51:45 -0800 (PST) Received-SPF: neutral (google.com: 209.85.220.48 is neither permitted nor denied by best guess record for domain of haojian.zhuang@linaro.org) client-ip=209.85.220.48; Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.220.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-pa0-f48.google.com with SMTP id hz10so1485343pad.7 for ; Sun, 24 Feb 2013 19:51:45 -0800 (PST) X-Received: by 10.66.122.74 with SMTP id lq10mr16718427pab.189.1361764305327; Sun, 24 Feb 2013 19:51:45 -0800 (PST) Received: from localhost.localdomain ([67.198.145.34]) by mx.google.com with ESMTPS id b9sm11188695pba.6.2013.02.24.19.51.40 (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Sun, 24 Feb 2013 19:51:44 -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 v5 10/12] gpio: pxa: move gpio properties into child node Date: Mon, 25 Feb 2013 11:49:39 +0800 Message-Id: <1361764181-26647-11-git-send-email-haojian.zhuang@linaro.org> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1361764181-26647-1-git-send-email-haojian.zhuang@linaro.org> References: <1361764181-26647-1-git-send-email-haojian.zhuang@linaro.org> X-Gm-Message-State: ALoCoQlvf9FEdwFKtxNK/0f8JpWrXpmyi0s7fKhqzFSXLS1KaxhM5I6HOPIAPH3Z9A6Bg47D9agK 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 | 41 ++++++++++++++++++----------------------- 1 file changed, 18 insertions(+), 23 deletions(-) diff --git a/drivers/gpio/gpio-pxa.c b/drivers/gpio/gpio-pxa.c index f5f78ea..91f4881 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); @@ -458,20 +468,6 @@ 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"); - return -EINVAL; - } - 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, pdata->nr_gpios, 0); if (irq_base < 0) { dev_err(&pdev->dev, "Failed to allocate IRQ numbers\n"); @@ -482,7 +478,6 @@ static int pxa_gpio_probe_dt(struct platform_device *pdev) pdev->dev.platform_data = pdata; domain = irq_domain_add_legacy(np, pdata->nr_gpios, irq_base, 0, &pxa_irq_domain_ops, NULL); - pxa_gpio_of_node = np; return 0; } #else