From patchwork Tue Jul 5 15:19:26 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shawn Guo X-Patchwork-Id: 2466 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 15F3523F55 for ; Tue, 5 Jul 2011 15:13:59 +0000 (UTC) Received: from mail-qy0-f173.google.com (mail-qy0-f173.google.com [209.85.216.173]) by fiordland.canonical.com (Postfix) with ESMTP id CEE95A186BB for ; Tue, 5 Jul 2011 15:13:58 +0000 (UTC) Received: by mail-qy0-f173.google.com with SMTP id 10so1827763qyk.11 for ; Tue, 05 Jul 2011 08:13:58 -0700 (PDT) Received: by 10.229.1.140 with SMTP id 12mr5595412qcf.118.1309878838572; Tue, 05 Jul 2011 08:13:58 -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.229.48.135 with SMTP id r7cs54043qcf; Tue, 5 Jul 2011 08:13:58 -0700 (PDT) Received: by 10.236.179.40 with SMTP id g28mr8697201yhm.105.1309878838009; Tue, 05 Jul 2011 08:13:58 -0700 (PDT) Received: from VA3EHSOBE002.bigfish.com (va3ehsobe002.messaging.microsoft.com [216.32.180.12]) by mx.google.com with ESMTPS id bm4si15140309icb.150.2011.07.05.08.13.57 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 05 Jul 2011 08:13:57 -0700 (PDT) Received-SPF: neutral (google.com: 216.32.180.12 is neither permitted nor denied by best guess record for domain of shawn.guo@linaro.org) client-ip=216.32.180.12; Authentication-Results: mx.google.com; spf=neutral (google.com: 216.32.180.12 is neither permitted nor denied by best guess record for domain of shawn.guo@linaro.org) smtp.mail=shawn.guo@linaro.org Received: from mail158-va3-R.bigfish.com (10.7.14.239) by VA3EHSOBE002.bigfish.com (10.7.40.22) with Microsoft SMTP Server id 14.1.225.22; Tue, 5 Jul 2011 15:13:57 +0000 Received: from mail158-va3 (localhost.localdomain [127.0.0.1]) by mail158-va3-R.bigfish.com (Postfix) with ESMTP id 054B119B8186; Tue, 5 Jul 2011 15:13:57 +0000 (UTC) X-SpamScore: -6 X-BigFish: VS-6(zzea8Nzz1202hzz8275dhz2dh87h2a8h668h839h61h) X-Spam-TCS-SCL: 0:0 X-Forefront-Antispam-Report: CIP:70.37.183.190; KIP:(null); UIP:(null); IPVD:NLI; H:mail.freescale.net; RD:none; EFVD:NLI X-FB-DOMAIN-IP-MATCH: fail Received: from mail158-va3 (localhost.localdomain [127.0.0.1]) by mail158-va3 (MessageSwitch) id 1309878802287587_19314; Tue, 5 Jul 2011 15:13:22 +0000 (UTC) Received: from VA3EHSMHS018.bigfish.com (unknown [10.7.14.239]) by mail158-va3.bigfish.com (Postfix) with ESMTP id 6D6111630063; Tue, 5 Jul 2011 15:13:18 +0000 (UTC) Received: from mail.freescale.net (70.37.183.190) by VA3EHSMHS018.bigfish.com (10.7.99.28) with Microsoft SMTP Server (TLS) id 14.1.225.22; Tue, 5 Jul 2011 15:13:10 +0000 Received: from az33smr01.freescale.net (10.64.34.199) by 039-SN1MMR1-001.039d.mgd.msft.net (10.84.1.13) with Microsoft SMTP Server id 14.1.289.8; Tue, 5 Jul 2011 10:13:09 -0500 Received: from S2100-06.ap.freescale.net (S2100-06.ap.freescale.net [10.192.242.125]) by az33smr01.freescale.net (8.13.1/8.13.0) with ESMTP id p65FD0QD011592; Tue, 5 Jul 2011 10:13:07 -0500 (CDT) From: Shawn Guo To: CC: , , Shawn Guo , Grant Likely Subject: [PATCH v2 3/3] gpio/mxc: add device tree probe support Date: Tue, 5 Jul 2011 23:19:26 +0800 Message-ID: <1309879166-25788-4-git-send-email-shawn.guo@linaro.org> X-Mailer: git-send-email 1.7.4.1 In-Reply-To: <1309879166-25788-1-git-send-email-shawn.guo@linaro.org> References: <1309879166-25788-1-git-send-email-shawn.guo@linaro.org> MIME-Version: 1.0 X-OriginatorOrg: sigmatel.com The patch adds device tree probe support for gpio-mxc driver. Signed-off-by: Shawn Guo Cc: Grant Likely Acked-by: Grant Likely --- .../devicetree/bindings/gpio/fsl-imx-gpio.txt | 22 ++++++++++++++++++++ drivers/gpio/gpio-mxc.c | 18 +++++++++++++++- 2 files changed, 39 insertions(+), 1 deletions(-) create mode 100644 Documentation/devicetree/bindings/gpio/fsl-imx-gpio.txt diff --git a/Documentation/devicetree/bindings/gpio/fsl-imx-gpio.txt b/Documentation/devicetree/bindings/gpio/fsl-imx-gpio.txt new file mode 100644 index 0000000..4363ae4 --- /dev/null +++ b/Documentation/devicetree/bindings/gpio/fsl-imx-gpio.txt @@ -0,0 +1,22 @@ +* Freescale i.MX/MXC GPIO controller + +Required properties: +- compatible : Should be "fsl,-gpio" +- reg : Address and length of the register set for the device +- interrupts : Should be the port interrupt shared by all 32 pins, if + one number. If two numbers, the first one is the interrupt shared + by low 16 pins and the second one is for high 16 pins. +- gpio-controller : Marks the device node as a gpio controller. +- #gpio-cells : Should be two. The first cell is the pin number and + the second cell is used to specify optional parameters (currently + unused). + +Example: + +gpio0: gpio@73f84000 { + compatible = "fsl,imx51-gpio", "fsl,imx31-gpio"; + reg = <0x73f84000 0x4000>; + interrupts = <50 51>; + gpio-controller; + #gpio-cells = <2>; +}; diff --git a/drivers/gpio/gpio-mxc.c b/drivers/gpio/gpio-mxc.c index 4875690..059d44a 100644 --- a/drivers/gpio/gpio-mxc.c +++ b/drivers/gpio/gpio-mxc.c @@ -27,6 +27,8 @@ #include #include #include +#include +#include #include enum mxc_gpio_hwtype { @@ -126,6 +128,13 @@ static struct platform_device_id mxc_gpio_devtype[] = { } }; +static const struct of_device_id mxc_gpio_dt_ids[] = { + { .compatible = "fsl,imx1-gpio", .data = &mxc_gpio_devtype[IMX1_GPIO], }, + { .compatible = "fsl,imx21-gpio", .data = &mxc_gpio_devtype[IMX2_GPIO], }, + { .compatible = "fsl,imx31-gpio", .data = &mxc_gpio_devtype[IMX_GPIO], }, + { /* sentinel */ } +}; + /* * MX2 has one interrupt *for all* gpio ports. The list is used * to save the references to all ports, so that mx2_gpio_irq_handler @@ -308,7 +317,13 @@ static void __init mxc_gpio_init_gc(struct mxc_gpio_port *port) static void __devinit mxc_gpio_get_hw(struct platform_device *pdev) { - enum mxc_gpio_hwtype hwtype = pdev->id_entry->driver_data; + const struct of_device_id *of_id = + of_match_device(mxc_gpio_dt_ids, &pdev->dev); + enum mxc_gpio_hwtype hwtype; + + if (of_id) + pdev->id_entry = of_id->data; + hwtype = pdev->id_entry->driver_data; if (mxc_gpio_hwtype) { /* @@ -426,6 +441,7 @@ static struct platform_driver mxc_gpio_driver = { .driver = { .name = "gpio-mxc", .owner = THIS_MODULE, + .of_match_table = mxc_gpio_dt_ids, }, .probe = mxc_gpio_probe, .id_table = mxc_gpio_devtype,