From patchwork Fri Sep 7 11:14:59 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lee Jones X-Patchwork-Id: 11251 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 823C623F25 for ; Fri, 7 Sep 2012 11:15:44 +0000 (UTC) Received: from mail-iy0-f180.google.com (mail-iy0-f180.google.com [209.85.210.180]) by fiordland.canonical.com (Postfix) with ESMTP id 30A96A18DC1 for ; Fri, 7 Sep 2012 11:15:44 +0000 (UTC) Received: by mail-iy0-f180.google.com with SMTP id j25so2861152iaf.11 for ; Fri, 07 Sep 2012 04:15:44 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-forwarded-to:x-forwarded-for:delivered-to:received-spf:from:to:cc :subject:date:message-id:x-mailer:in-reply-to:references :x-gm-message-state; bh=8xYE6OhtBMaUh6omyIf1ENBFwoQOLfp2uH9FM+x4x9E=; b=QXBO5JeNdkyzNtG0XiWMOb4S5nsedm7xsz/FqzuSdlNGO5FKu0JyJq3p/uQNvhzcuV lk0hfeZV5K36fAro7tOz84jCmauYUFrgi79/8T3R0ZVvFQeim2daSGcM56DwCvzVfAZY de2jdv6C3pOODzveIfymCJkO+H2QSNrJrpYduQjHK/dv34+KYzjimeMLRRPO3jeHctFW kWci+1MpNmuZ/X1iZSl3/qMb87xhCkXiVh4/SbPcb/wMj4p7lRGzMPrqEETUvl23VNMh JlHC80ojN44hZDKZBqEsuHBH1vKV7JnA6xUij6Acg3H8GNpU5oJMW3gmHpG+y+isBAT3 Ln0Q== Received: by 10.42.109.194 with SMTP id m2mr6402534icp.48.1347016543975; Fri, 07 Sep 2012 04:15:43 -0700 (PDT) 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.50.184.232 with SMTP id ex8csp373472igc; Fri, 7 Sep 2012 04:15:43 -0700 (PDT) Received: by 10.180.105.6 with SMTP id gi6mr11578576wib.4.1347016542652; Fri, 07 Sep 2012 04:15:42 -0700 (PDT) Received: from mail-wg0-f50.google.com (mail-wg0-f50.google.com [74.125.82.50]) by mx.google.com with ESMTPS id fj1si12702359wib.21.2012.09.07.04.15.42 (version=TLSv1/SSLv3 cipher=OTHER); Fri, 07 Sep 2012 04:15:42 -0700 (PDT) Received-SPF: neutral (google.com: 74.125.82.50 is neither permitted nor denied by best guess record for domain of lee.jones@linaro.org) client-ip=74.125.82.50; Authentication-Results: mx.google.com; spf=neutral (google.com: 74.125.82.50 is neither permitted nor denied by best guess record for domain of lee.jones@linaro.org) smtp.mail=lee.jones@linaro.org Received: by mail-wg0-f50.google.com with SMTP id ds11so2271205wgb.31 for ; Fri, 07 Sep 2012 04:15:42 -0700 (PDT) Received: by 10.216.242.196 with SMTP id i46mr2541918wer.125.1347016542149; Fri, 07 Sep 2012 04:15:42 -0700 (PDT) Received: from localhost.localdomain (cpc1-aztw13-0-0-cust473.18-1.cable.virginmedia.com. [77.102.241.218]) by mx.google.com with ESMTPS id k20sm9151505wiv.11.2012.09.07.04.15.40 (version=TLSv1/SSLv3 cipher=OTHER); Fri, 07 Sep 2012 04:15:41 -0700 (PDT) From: Lee Jones To: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Cc: STEricsson_nomadik_linux@list.st.com, linus.walleij@stericsson.com, arnd@arndb.de, Lee Jones , Grant Likely Subject: [PATCH 19/19] gpio: Enable the tc3298x GPIO expander driver for Device Tree Date: Fri, 7 Sep 2012 12:14:59 +0100 Message-Id: <1347016499-29354-20-git-send-email-lee.jones@linaro.org> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1347016499-29354-1-git-send-email-lee.jones@linaro.org> References: <1347016499-29354-1-git-send-email-lee.jones@linaro.org> X-Gm-Message-State: ALoCoQm7ydZ4ULF0woGh/ENdxUqNWLUlwF2uTgGOUh5CIdu3VDHScKJhlkEOsJGT0mwEN7XPK+xS Here we provide a means to probe and extract vital information from Device Tree when booting with it enabled. Without this patch sub-devices wouldn't be able to reference the tc3589x-gpio expander from Device Tree. CC: Grant Likely Signed-off-by: Lee Jones --- drivers/gpio/gpio-tc3589x.c | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/drivers/gpio/gpio-tc3589x.c b/drivers/gpio/gpio-tc3589x.c index 6e89009..1e48317 100644 --- a/drivers/gpio/gpio-tc3589x.c +++ b/drivers/gpio/gpio-tc3589x.c @@ -11,6 +11,7 @@ #include #include #include +#include #include #include #include @@ -286,7 +287,8 @@ static struct irq_domain_ops tc3589x_irq_ops = { .xlate = irq_domain_xlate_twocell, }; -static int tc3589x_gpio_irq_init(struct tc3589x_gpio *tc3589x_gpio) +static int tc3589x_gpio_irq_init(struct tc3589x_gpio *tc3589x_gpio, + struct device_node *np) { int base = tc3589x_gpio->irq_base; @@ -297,7 +299,7 @@ static int tc3589x_gpio_irq_init(struct tc3589x_gpio *tc3589x_gpio) } else { tc3589x_gpio->domain = irq_domain_add_linear( - NULL, tc3589x_gpio->chip.ngpio, + np, tc3589x_gpio->chip.ngpio, &tc3589x_irq_ops, tc3589x_gpio); } @@ -313,13 +315,17 @@ static int __devinit tc3589x_gpio_probe(struct platform_device *pdev) { struct tc3589x *tc3589x = dev_get_drvdata(pdev->dev.parent); struct tc3589x_gpio_platform_data *pdata; + struct device_node *np = pdev->dev.of_node; struct tc3589x_gpio *tc3589x_gpio; int ret; int irq; pdata = tc3589x->pdata->gpio; - if (!pdata) - return -ENODEV; + + if (!(pdata || np)) { + dev_err(&pdev->dev, "No platform data or Device Tree found\n"); + return -EINVAL; + } irq = platform_get_irq(pdev, 0); if (irq < 0) @@ -337,9 +343,11 @@ static int __devinit tc3589x_gpio_probe(struct platform_device *pdev) tc3589x_gpio->chip = template_chip; tc3589x_gpio->chip.ngpio = tc3589x->num_gpio; tc3589x_gpio->chip.dev = &pdev->dev; - tc3589x_gpio->chip.base = pdata->gpio_base; + tc3589x_gpio->chip.base = (pdata) ? pdata->gpio_base : -1; - tc3589x_gpio->irq_base = tc3589x->irq_base + TC3589x_INT_GPIO(0); +#ifdef CONFIG_OF_GPIO + tc3589x_gpio->chip.of_node = np; +#endif tc3589x_gpio->irq_base = tc3589x->irq_base ? tc3589x->irq_base + TC3589x_INT_GPIO(0) : 0; @@ -350,7 +358,7 @@ static int __devinit tc3589x_gpio_probe(struct platform_device *pdev) if (ret < 0) goto out_free; - ret = tc3589x_gpio_irq_init(tc3589x_gpio); + ret = tc3589x_gpio_irq_init(tc3589x_gpio, np); if (ret) goto out_free; @@ -367,7 +375,7 @@ static int __devinit tc3589x_gpio_probe(struct platform_device *pdev) goto out_freeirq; } - if (pdata->setup) + if (pdata && pdata->setup) pdata->setup(tc3589x, tc3589x_gpio->chip.base); platform_set_drvdata(pdev, tc3589x_gpio); @@ -389,7 +397,7 @@ static int __devexit tc3589x_gpio_remove(struct platform_device *pdev) int irq = platform_get_irq(pdev, 0); int ret; - if (pdata->remove) + if (pdata && pdata->remove) pdata->remove(tc3589x, tc3589x_gpio->chip.base); ret = gpiochip_remove(&tc3589x_gpio->chip);