From patchwork Sat Nov 2 15:39:33 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Lad, Prabhakar" X-Patchwork-Id: 3130871 Return-Path: X-Original-To: patchwork-davinci@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 8BC7F9F43F for ; Sat, 2 Nov 2013 15:42:12 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 6AB53202A1 for ; Sat, 2 Nov 2013 15:42:11 +0000 (UTC) Received: from bear.ext.ti.com (bear.ext.ti.com [192.94.94.41]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 59B5020258 for ; Sat, 2 Nov 2013 15:42:10 +0000 (UTC) Received: from dflxv15.itg.ti.com ([128.247.5.124]) by bear.ext.ti.com (8.13.7/8.13.7) with ESMTP id rA2Ff4kO023042; Sat, 2 Nov 2013 10:41:04 -0500 Received: from DFLE73.ent.ti.com ([128.247.5.110]) by dflxv15.itg.ti.com (8.14.3/8.13.8) with ESMTP id rA2Ff4r0017292; Sat, 2 Nov 2013 10:41:04 -0500 Received: from dlep32.itg.ti.com (157.170.170.100) by DFLE73.ent.ti.com (128.247.5.110) with Microsoft SMTP Server id 14.2.342.3; Sat, 2 Nov 2013 10:41:04 -0500 Received: from linux.omap.com (dlelxs01.itg.ti.com [157.170.227.31]) by dlep32.itg.ti.com (8.14.3/8.13.8) with ESMTP id rA2Ff4ol016649; Sat, 2 Nov 2013 10:41:04 -0500 Received: from linux.omap.com (localhost [127.0.0.1]) by linux.omap.com (Postfix) with ESMTP id D1E588062D; Sat, 2 Nov 2013 09:41:03 -0600 (CST) X-Original-To: davinci-linux-open-source@linux.davincidsp.com Delivered-To: davinci-linux-open-source@linux.davincidsp.com Received: from dflp52.itg.ti.com (dflp52.itg.ti.com [128.247.22.96]) by linux.omap.com (Postfix) with ESMTP id EA78080627 for ; Sat, 2 Nov 2013 09:40:31 -0600 (CST) Received: from neches.ext.ti.com (neches.ext.ti.com [192.91.81.29]) by dflp52.itg.ti.com (8.13.7/8.13.8) with ESMTP id rA2FeV1q014864 for ; Sat, 2 Nov 2013 10:40:31 -0500 (CDT) Received: from mail6.bemta7.messagelabs.com (mail6.bemta7.messagelabs.com [216.82.255.55]) by neches.ext.ti.com (8.13.7/8.13.7) with ESMTP id rA2FeVCN026272 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Sat, 2 Nov 2013 10:40:31 -0500 Received: from [216.82.253.67:29915] by server-1.bemta-7.messagelabs.com id D2/D9-24188-FEC15725; Sat, 02 Nov 2013 15:40:31 +0000 X-Env-Sender: prabhakar.csengg@gmail.com X-Msg-Ref: server-13.tower-158.messagelabs.com!1383406829!3744931!1 X-Originating-IP: [209.85.160.46] X-SpamReason: No, hits=0.0 required=7.0 tests=ML_RADAR_SPEW_LINKS_14, spamassassin: X-StarScan-Received: X-StarScan-Version: 6.9.12; banners=-,-,- X-VirusChecked: Checked Received: (qmail 22370 invoked from network); 2 Nov 2013 15:40:30 -0000 Received: from mail-pb0-f46.google.com (HELO mail-pb0-f46.google.com) (209.85.160.46) by server-13.tower-158.messagelabs.com with RC4-SHA encrypted SMTP; 2 Nov 2013 15:40:30 -0000 Received: by mail-pb0-f46.google.com with SMTP id un15so492432pbc.19 for ; Sat, 02 Nov 2013 08:40:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=QMR2vb785pXkLRCRVgaO16I3pHV/5XJ0BqEsVVm7lgA=; b=aeUpnX5bXC2wj5pXu0W7wcBJghEJ0ycBFG8S6sRFdMTL+o7b5mRKvrWOcXVowOJELL YaNKHv+IQ9HtkEXjvgIaUqyxQ9mM3S1Z9s/Vj9LjMi/bdpvLA/JYToI4Z90mo8icBMLC ZqjCXkHHGlyYRLJiE1+vTQlcS0OxwB7Wn1BAIXLaMXIsAdEyqCVwX/VaKiALWPbdn3+b mZXs3ZKAoJW+qXOqLU51ACWPnhnbfyUNbtKN60+4zLe1Lqt44UGy2TWa205A8gnrG5TL GYtVJYJCf4xCFqG5GXqKPPuP5o/h7i/70HYtf+fZtNNjZg3FAFddMB219rwV8OJrBCcc CBOA== X-Received: by 10.66.139.8 with SMTP id qu8mr1279101pab.157.1383406829202; Sat, 02 Nov 2013 08:40:29 -0700 (PDT) Received: from localhost.localdomain ([49.200.27.40]) by mx.google.com with ESMTPSA id qp10sm20456849pab.13.2013.11.02.08.40.20 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Sat, 02 Nov 2013 08:40:28 -0700 (PDT) From: "Lad, Prabhakar" To: Sekhar Nori , Linus Walleij , Subject: [PATCH v4 4/6] gpio: davinci: add OF support Date: Sat, 2 Nov 2013 21:09:33 +0530 Message-ID: <1383406775-14902-5-git-send-email-prabhakar.csenng@gmail.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1383406775-14902-1-git-send-email-prabhakar.csenng@gmail.com> References: <1383406775-14902-1-git-send-email-prabhakar.csenng@gmail.com> CC: Mark Rutland , Alex Elder , , Russell King , Pawel Moll , Ian Campbell , Stephen Warren , , , Rob Herring , , Rob Landley , Grant Likely , X-BeenThere: davinci-linux-open-source@linux.davincidsp.com X-Mailman-Version: 2.1.12 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: Errors-To: davinci-linux-open-source-bounces@linux.davincidsp.com X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: KV Sujith This patch adds OF parser support for davinci gpio driver and also appropriate documentation in gpio-davinci.txt located at Documentation/devicetree/bindings/gpio/. Signed-off-by: KV Sujith Signed-off-by: Philip Avinash [prabhakar.csengg@gmail.com: simplified the OF code, removed unnecessary DT property and also simplified the commit message] Signed-off-by: Lad, Prabhakar --- .../devicetree/bindings/gpio/gpio-davinci.txt | 32 ++++++++++++ drivers/gpio/gpio-davinci.c | 54 ++++++++++++++++++-- 2 files changed, 83 insertions(+), 3 deletions(-) create mode 100644 Documentation/devicetree/bindings/gpio/gpio-davinci.txt diff --git a/Documentation/devicetree/bindings/gpio/gpio-davinci.txt b/Documentation/devicetree/bindings/gpio/gpio-davinci.txt new file mode 100644 index 0000000..55aae1c --- /dev/null +++ b/Documentation/devicetree/bindings/gpio/gpio-davinci.txt @@ -0,0 +1,32 @@ +Davinci GPIO controller bindings + +Required Properties: +- compatible: should be "ti,dm6441-gpio" + +- reg: Physical base address of the controller and the size of memory mapped + registers. + +- gpio-controller : Marks the device node as a gpio controller. + +- interrupts: Array of GPIO interrupt number. + +- ti,ngpio: The number of GPIO pins supported. + +- ti,davinci-gpio-unbanked: The number of GPIOs that have an individual interrupt + line to processor. + +Example: + +gpio: gpio@1e26000 { + compatible = "ti,dm6441-gpio"; + gpio-controller; + reg = <0x226000 0x1000>; + interrupts = <42 IRQ_TYPE_EDGE_BOTH 43 IRQ_TYPE_EDGE_BOTH + 44 IRQ_TYPE_EDGE_BOTH 45 IRQ_TYPE_EDGE_BOTH + 46 IRQ_TYPE_EDGE_BOTH 47 IRQ_TYPE_EDGE_BOTH + 48 IRQ_TYPE_EDGE_BOTH 49 IRQ_TYPE_EDGE_BOTH + 50 IRQ_TYPE_EDGE_BOTH>; + ti,ngpio = <144>; + ti,davinci-gpio-irq-base = <101>; + ti,davinci-gpio-unbanked = <0>; +}; diff --git a/drivers/gpio/gpio-davinci.c b/drivers/gpio/gpio-davinci.c index bcb6d8d..bb20a39 100644 --- a/drivers/gpio/gpio-davinci.c +++ b/drivers/gpio/gpio-davinci.c @@ -17,6 +17,9 @@ #include #include #include +#include +#include +#include #include #include @@ -134,6 +137,40 @@ davinci_gpio_set(struct gpio_chip *chip, unsigned offset, int value) __raw_writel((1 << offset), value ? &g->set_data : &g->clr_data); } +static struct davinci_gpio_platform_data * +davinci_gpio_get_pdata(struct platform_device *pdev) +{ + struct device_node *dn = pdev->dev.of_node; + struct davinci_gpio_platform_data *pdata; + int ret; + u32 val; + + if (!IS_ENABLED(CONFIG_OF) || !pdev->dev.of_node) + return pdev->dev.platform_data; + + pdata = devm_kzalloc(&pdev->dev, sizeof(*pdata), GFP_KERNEL); + if (!pdata) + return NULL; + + ret = of_property_read_u32(dn, "ti,ngpio", &val); + if (ret) + goto of_err; + + pdata->ngpio = val; + + ret = of_property_read_u32(dn, "ti,davinci-gpio-unbanked", &val); + if (ret) + goto of_err; + + pdata->gpio_unbanked = val; + + return pdata; + +of_err: + dev_err(&pdev->dev, "Populating pdata from DT failed: err %d\n", ret); + return NULL; +} + static int davinci_gpio_probe(struct platform_device *pdev) { int i, base; @@ -144,12 +181,14 @@ static int davinci_gpio_probe(struct platform_device *pdev) struct device *dev = &pdev->dev; struct resource *res; - pdata = dev->platform_data; + pdata = davinci_gpio_get_pdata(pdev); if (!pdata) { dev_err(dev, "No platform data found\n"); return -EINVAL; } + dev->platform_data = pdata; + /* * The gpio banks conceptually expose a segmented bitmap, * and "ngpio" is one more than the largest zero-based @@ -501,11 +540,20 @@ done: return 0; } +#if IS_ENABLED(CONFIG_OF) +static const struct of_device_id davinci_gpio_ids[] = { + { .compatible = "ti,dm6441-gpio", }, + { /* sentinel */ }, +}; +MODULE_DEVICE_TABLE(of, davinci_gpio_ids); +#endif + static struct platform_driver davinci_gpio_driver = { .probe = davinci_gpio_probe, .driver = { - .name = "davinci_gpio", - .owner = THIS_MODULE, + .name = "davinci_gpio", + .owner = THIS_MODULE, + .of_match_table = of_match_ptr(davinci_gpio_ids), }, };