From patchwork Wed Jun 13 12:34:18 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Zhao X-Patchwork-Id: 164652 Return-Path: X-Original-To: incoming-imx@patchwork.ozlabs.org Delivered-To: patchwork-incoming-imx@bilbo.ozlabs.org Received: from merlin.infradead.org (merlin.infradead.org [IPv6:2001:4978:20e::2]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 7D2C1B700D for ; Wed, 13 Jun 2012 22:41:41 +1000 (EST) Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1Semor-0006TZ-F0; Wed, 13 Jun 2012 12:37:05 +0000 Received: from va3ehsobe005.messaging.microsoft.com ([216.32.180.31] helo=va3outboundpool.messaging.microsoft.com) by merlin.infradead.org with esmtps (Exim 4.76 #1 (Red Hat Linux)) id 1SemnA-0005WP-A3 for linux-arm-kernel@lists.infradead.org; Wed, 13 Jun 2012 12:35:21 +0000 Received: from mail236-va3-R.bigfish.com (10.7.14.248) by VA3EHSOBE007.bigfish.com (10.7.40.11) with Microsoft SMTP Server id 14.1.225.23; Wed, 13 Jun 2012 12:34:15 +0000 Received: from mail236-va3 (localhost [127.0.0.1]) by mail236-va3-R.bigfish.com (Postfix) with ESMTP id 326429001A4; Wed, 13 Jun 2012 12:34:15 +0000 (UTC) X-Forefront-Antispam-Report: CIP:70.37.183.190; KIP:(null); UIP:(null); IPV:NLI; H:mail.freescale.net; RD:none; EFVD:NLI X-SpamScore: 3 X-BigFish: VS3(zcb8kzzz1202hzz8275bh8275dhz2dh2a8h668h839hd24he5bhf0ah) Received: from mail236-va3 (localhost.localdomain [127.0.0.1]) by mail236-va3 (MessageSwitch) id 133959085457883_24296; Wed, 13 Jun 2012 12:34:14 +0000 (UTC) Received: from VA3EHSMHS024.bigfish.com (unknown [10.7.14.254]) by mail236-va3.bigfish.com (Postfix) with ESMTP id 0A4A1600048; Wed, 13 Jun 2012 12:34:14 +0000 (UTC) Received: from mail.freescale.net (70.37.183.190) by VA3EHSMHS024.bigfish.com (10.7.99.34) with Microsoft SMTP Server (TLS) id 14.1.225.23; Wed, 13 Jun 2012 12:34:13 +0000 Received: from az84smr01.freescale.net (10.64.34.197) by 039-SN1MMR1-002.039d.mgd.msft.net (10.84.1.15) with Microsoft SMTP Server (TLS) id 14.2.298.5; Wed, 13 Jun 2012 07:35:16 -0500 Received: from b20223-02.ap.freescale.net (b20223-02.ap.freescale.net [10.192.242.124]) by az84smr01.freescale.net (8.14.3/8.14.0) with ESMTP id q5DCYPjX007626; Wed, 13 Jun 2012 05:35:09 -0700 From: Richard Zhao To: , , Subject: [Patch v5 08/13] ARM: imx6q: add config-on-boot gpios Date: Wed, 13 Jun 2012 20:34:18 +0800 Message-ID: <1339590863-10564-9-git-send-email-richard.zhao@freescale.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1339590863-10564-1-git-send-email-richard.zhao@freescale.com> References: <1339590863-10564-1-git-send-email-richard.zhao@freescale.com> MIME-Version: 1.0 X-OriginatorOrg: freescale.com X-Spam-Note: CRM114 invocation failed X-Spam-Score: -2.6 (--) X-Spam-Report: SpamAssassin version 3.3.2 on merlin.infradead.org summary: Content analysis details: (-2.6 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low trust [216.32.180.31 listed in list.dnswl.org] -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] Cc: marex@denx.de, B20596@freescale.com, dong.aisheng@linaro.org, fabio.estevam@freescale.com, alexander.shishkin@linux.intel.com, B29397@freescale.com, balbi@ti.com, Grant Likely , stern@rowland.harvard.edu, Rob Herring , kernel@pengutronix.de, gregkh@linuxfoundation.org, richard.zhao@freescale.com, shawn.guo@linaro.org, linuxzsc@gmail.com X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.14 Precedence: list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: linux-arm-kernel-bounces@lists.infradead.org Errors-To: linux-arm-kernel-bounces+incoming-imx=patchwork.ozlabs.org@lists.infradead.org List-Id: linux-imx-kernel.lists.patchwork.ozlabs.org Sometimes, boards have gpios that don't own by any driver or owner by a generic driver that don't like hacks. Such gpios is normally output and need setup once on boot. So I introduce the config-on-boot gpios. Signed-off-by: Richard Zhao Cc: Shawn Guo Cc: Rob Herring Cc: Grant Likely --- .../devicetree/bindings/arm/config-on-boot.txt | 12 +++++++ arch/arm/boot/dts/imx6q-sabrelite.dts | 7 ++++ arch/arm/mach-imx/mach-imx6q.c | 35 ++++++++++++++++++++ 3 files changed, 54 insertions(+) create mode 100644 Documentation/devicetree/bindings/arm/config-on-boot.txt diff --git a/Documentation/devicetree/bindings/arm/config-on-boot.txt b/Documentation/devicetree/bindings/arm/config-on-boot.txt new file mode 100644 index 0000000..f98ed74 --- /dev/null +++ b/Documentation/devicetree/bindings/arm/config-on-boot.txt @@ -0,0 +1,12 @@ +* Configure on Boot + +Node name: config-on-boot + It must be in root node. config-on-boot means to describe settings that needs + to be set one time on boot but aren't owned by any driver, or the owned driver + is too generic to handle such settings. For example, usb hub uses generic + driver in usb core code, a on-board usb may need deassert reset pin. + +Optional properties: +- output-gpios: Output gpio array that needs to set. +- output-gpio-values: This property is required if output-gpios is set. + The value is a array of 0 or 1. Total count eaquals the number of gpios. diff --git a/arch/arm/boot/dts/imx6q-sabrelite.dts b/arch/arm/boot/dts/imx6q-sabrelite.dts index e0ec929..1dd2261 100644 --- a/arch/arm/boot/dts/imx6q-sabrelite.dts +++ b/arch/arm/boot/dts/imx6q-sabrelite.dts @@ -17,6 +17,13 @@ model = "Freescale i.MX6 Quad SABRE Lite Board"; compatible = "fsl,imx6q-sabrelite", "fsl,imx6q"; + config-on-boot { + output-gpios = < + &gpio3 22 0>; /* vbus reset */ + output-gpio-values = < + 1>; /* vbus reset */ + }; + memory { reg = <0x10000000 0x40000000>; }; diff --git a/arch/arm/mach-imx/mach-imx6q.c b/arch/arm/mach-imx/mach-imx6q.c index b47e98b..577cf19 100644 --- a/arch/arm/mach-imx/mach-imx6q.c +++ b/arch/arm/mach-imx/mach-imx6q.c @@ -19,6 +19,7 @@ #include #include #include +#include #include #include #include @@ -113,6 +114,38 @@ static void __init imx6q_sabrelite_init(void) imx6q_sabrelite_cko1_setup(); } +static void __init imx6q_config_on_boot(void) +{ + struct device_node *np; + struct property *pp; + int cnt, len, i; + int gpio; + + np = of_find_node_by_path("/config-on-boot"); + if (!np) + return; + cnt = of_gpio_named_count(np, "output-gpios"); + pp = of_find_property(np, "output-gpio-values", &len); + if (!pp || cnt != len / sizeof(u32)) { + pr_err("Invalid config-on-boot gpios!\n"); + of_node_put(np); + return; + } + for (i = 0; i < cnt; i++) { + gpio = of_get_named_gpio(np, "output-gpios", i); + if (gpio_is_valid(gpio)) + gpio_request_one(gpio, GPIOF_OUT_INIT_HIGH, + "config-on-boot"); + } + + of_node_put(np); +} + +static void __init imx6q_post_populate(void) +{ + imx6q_config_on_boot(); +} + static void __init imx6q_init_machine(void) { /* @@ -126,6 +159,8 @@ static void __init imx6q_init_machine(void) of_platform_populate(NULL, of_default_bus_match_table, NULL, NULL); + imx6q_post_populate(); + imx6q_pm_init(); }