From patchwork Mon Jul 25 15:07:46 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shawn Guo X-Patchwork-Id: 1004802 Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) by demeter1.kernel.org (8.14.4/8.14.4) with ESMTP id p6PF1lg4019932 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Mon, 25 Jul 2011 15:02:07 GMT Received: from canuck.infradead.org ([2001:4978:20e::1]) by merlin.infradead.org with esmtps (Exim 4.76 #1 (Red Hat Linux)) id 1QlMet-0001fD-68; Mon, 25 Jul 2011 15:01:27 +0000 Received: from localhost ([127.0.0.1] helo=canuck.infradead.org) by canuck.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1QlMes-0000Xe-Ry; Mon, 25 Jul 2011 15:01:26 +0000 Received: from va3ehsobe006.messaging.microsoft.com ([216.32.180.16] helo=VA3EHSOBE009.bigfish.com) by canuck.infradead.org with esmtps (Exim 4.76 #1 (Red Hat Linux)) id 1QlMeK-0000SU-4R for linux-arm-kernel@lists.infradead.org; Mon, 25 Jul 2011 15:00:55 +0000 Received: from mail147-va3-R.bigfish.com (10.7.14.245) by VA3EHSOBE009.bigfish.com (10.7.40.29) with Microsoft SMTP Server id 14.1.225.22; Mon, 25 Jul 2011 15:00:50 +0000 Received: from mail147-va3 (localhost.localdomain [127.0.0.1]) by mail147-va3-R.bigfish.com (Postfix) with ESMTP id 904A1228171; Mon, 25 Jul 2011 15:00:50 +0000 (UTC) X-SpamScore: 0 X-BigFish: VS0(zzzz1202hzz8275dhz2dh87h2a8h668h839h61h) 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 mail147-va3 (localhost.localdomain [127.0.0.1]) by mail147-va3 (MessageSwitch) id 131160605022921_25757; Mon, 25 Jul 2011 15:00:50 +0000 (UTC) Received: from VA3EHSMHS026.bigfish.com (unknown [10.7.14.243]) by mail147-va3.bigfish.com (Postfix) with ESMTP id DD56BEB0050; Mon, 25 Jul 2011 15:00:49 +0000 (UTC) Received: from mail.freescale.net (70.37.183.190) by VA3EHSMHS026.bigfish.com (10.7.99.36) with Microsoft SMTP Server (TLS) id 14.1.225.22; Mon, 25 Jul 2011 15:00:37 +0000 Received: from az33smr01.freescale.net (10.64.34.199) by 039-SN1MMR1-003.039d.mgd.msft.net (10.84.1.16) with Microsoft SMTP Server id 14.1.289.8; Mon, 25 Jul 2011 10:00:36 -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 p6PF0VGh022379; Mon, 25 Jul 2011 10:00:34 -0500 (CDT) From: Shawn Guo To: Subject: [PATCH 1/2] arm/mx5: parse iomuxc pad configuratoin from device tree Date: Mon, 25 Jul 2011 23:07:46 +0800 Message-ID: <1311606467-28985-2-git-send-email-shawn.guo@linaro.org> X-Mailer: git-send-email 1.7.4.1 In-Reply-To: <1311606467-28985-1-git-send-email-shawn.guo@linaro.org> References: <1311606467-28985-1-git-send-email-shawn.guo@linaro.org> MIME-Version: 1.0 X-OriginatorOrg: sigmatel.com X-CRM114-Version: 20090807-BlameThorstenAndJenny ( TRE 0.7.6 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20110725_110052_429764_F6F2EBE1 X-CRM114-Status: GOOD ( 22.88 ) X-Spam-Score: -2.3 (--) X-Spam-Report: SpamAssassin version 3.3.1 on canuck.infradead.org summary: Content analysis details: (-2.3 points) pts rule name description ---- ---------------------- -------------------------------------------------- -2.3 RCVD_IN_DNSWL_MED RBL: Sender listed at http://www.dnswl.org/, medium trust [216.32.180.16 listed in list.dnswl.org] Cc: Grant Likely , devicetree-discuss@lists.ozlabs.org, Shawn Guo , Sascha Hauer , patches@linaro.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: linux-arm-kernel-bounces@lists.infradead.org Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter1.kernel.org [140.211.167.41]); Mon, 25 Jul 2011 15:02:08 +0000 (UTC) It adds function mxc_iomuxc_dt_init() to parse iomuxc pad configuration from device tree. Signed-off-by: Shawn Guo Cc: Grant Likely Cc: Sascha Hauer --- .../devicetree/bindings/arm/fsl/iomuxc.txt | 47 +++++++++++++ arch/arm/mach-mx5/Makefile | 2 + arch/arm/mach-mx5/iomuxc-dt.c | 72 ++++++++++++++++++++ arch/arm/plat-mxc/include/mach/common.h | 3 + 4 files changed, 124 insertions(+), 0 deletions(-) create mode 100644 Documentation/devicetree/bindings/arm/fsl/iomuxc.txt create mode 100644 arch/arm/mach-mx5/iomuxc-dt.c diff --git a/Documentation/devicetree/bindings/arm/fsl/iomuxc.txt b/Documentation/devicetree/bindings/arm/fsl/iomuxc.txt new file mode 100644 index 0000000..ae9292b --- /dev/null +++ b/Documentation/devicetree/bindings/arm/fsl/iomuxc.txt @@ -0,0 +1,47 @@ +* Freescale i.MX IOMUX Controller (IOMUXC) + +Required properties: +- compatible : "fsl,-iomuxc"; + +Sub-nodes present individual PAD configuration, and node name is the +PAD name given by hardware document. + +Required properties: +- reg : Should contain the offset of registers + IOMUXC_SW_MUX_CTL_PAD_ and IOMUXC_SW_PAD_CTL_PAD_. +- fsl,iomuxc-mux-mode : Should specify the MUX_MODE setting of register + IOMUXC_SW_MUX_CTL_PAD_. + +Optional properties: +- fsl,iomuxc-sion : Indicates that bit SION of register + IOMUXC_SW_MUX_CTL_PAD_ needs to be set for given MUX_MODE + setting of the PAD. +- fsl,iomuxc-select-input : Specify the offset of register + IOMUXC_<...>_SELECT_INPUT and the value of bit-field DAISY for given + MUX_MODE setting of the PAD. + +Examples: + +iomuxc@53fa8000 { + #address-cells = <2>; + #size-cells = <0>; + compatible = "fsl,imx53-iomuxc"; + reg = <0x53fa8000 0x4000>; + + /* + * I2C2 + */ + key-col3 { /* I2C2_SCL */ + reg = <0x3c 0x364>; + fsl,iomuxc-mux-mode = <4>; + fsl,iomuxc-sion; + fsl,iomuxc-select-input = <0x81c 0x0>; + }; + + key-row3 { /* I2C2_SDA */ + reg = <0x40 0x368>; + fsl,iomuxc-mux-mode = <4>; + fsl,iomuxc-sion; + fsl,iomuxc-select-input = <0x820 0x0>; + }; +}; diff --git a/arch/arm/mach-mx5/Makefile b/arch/arm/mach-mx5/Makefile index 383e7cd..71379f6 100644 --- a/arch/arm/mach-mx5/Makefile +++ b/arch/arm/mach-mx5/Makefile @@ -22,3 +22,5 @@ obj-$(CONFIG_MX51_EFIKA_COMMON) += mx51_efika.o obj-$(CONFIG_MACH_MX51_EFIKAMX) += board-mx51_efikamx.o obj-$(CONFIG_MACH_MX51_EFIKASB) += board-mx51_efikasb.o obj-$(CONFIG_MACH_MX50_RDP) += board-mx50_rdp.o + +obj-$(CONFIG_OF) += iomuxc-dt.o diff --git a/arch/arm/mach-mx5/iomuxc-dt.c b/arch/arm/mach-mx5/iomuxc-dt.c new file mode 100644 index 0000000..2cfe6e7 --- /dev/null +++ b/arch/arm/mach-mx5/iomuxc-dt.c @@ -0,0 +1,72 @@ +/* + * Copyright 2011 Freescale Semiconductor, Inc. All Rights Reserved. + * Copyright 2011 Linaro Ltd. + * + * The code contained herein is licensed under the GNU General Public + * License. You may obtain a copy of the GNU General Public License + * Version 2 or later at the following locations: + * + * http://www.opensource.org/licenses/gpl-license.html + * http://www.gnu.org/copyleft/gpl.html + */ + +#include +#include + +#define IOMUXC_CONFIG_SION (1 << 4) + +void mxc_iomuxc_dt_init(const struct of_device_id *match) +{ + struct device_node *node = of_find_matching_node(NULL, match); + struct device_node *child; + void __iomem *base; + u32 reg[2], select_input[2]; + u32 mux_mode, pad_ctl; + + if (!node) { + pr_warn("%s: no iomuxc node found\n", __func__); + return; + } + + if (of_property_read_u32_array(node, "reg", reg, ARRAY_SIZE(reg))) { + pr_warn("%s: property 'reg' not found\n", __func__); + goto out; + } + + base = ioremap(reg[0], reg[1]); + if (!base) { + pr_warn("%s: ioremap failed\n", __func__); + goto out; + } + + for_each_child_of_node(node, child) { + /* get regsister offset of mux_ctl and pad_ctl */ + if (of_property_read_u32_array(child, "reg", reg, + ARRAY_SIZE(reg))) + continue; + + /* set register mux_ctl */ + if (of_property_read_u32(child, "fsl,iomuxc-mux-mode", + &mux_mode)) + continue; + if (of_get_property(child, "fsl,iomuxc-sion", NULL)) + mux_mode |= IOMUXC_CONFIG_SION; + writel(mux_mode, base + reg[0]); + + /* set register pad_ctl */ + if (!of_property_read_u32(child, "fsl,iomuxc-pad-ctl", + &pad_ctl)) + writel(pad_ctl, base + reg[1]); + + /* get offset/value pair and set select_input register */ + if (!of_property_read_u32_array(child, + "fsl,iomuxc-select-input", select_input, + ARRAY_SIZE(select_input))) + writel(select_input[1], base + select_input[0]); + } + + iounmap(base); + +out: + of_node_put(node); +} diff --git a/arch/arm/plat-mxc/include/mach/common.h b/arch/arm/plat-mxc/include/mach/common.h index 4e3d978..12b7499 100644 --- a/arch/arm/plat-mxc/include/mach/common.h +++ b/arch/arm/plat-mxc/include/mach/common.h @@ -13,6 +13,7 @@ struct platform_device; struct clk; +struct of_device_id; extern void mx1_map_io(void); extern void mx21_map_io(void); @@ -72,4 +73,6 @@ extern void mxc_arch_reset_init(void __iomem *); extern void mx51_efikamx_reset(void); extern int mx53_revision(void); extern int mx53_display_revision(void); + +extern void mxc_iomuxc_dt_init(const struct of_device_id *match); #endif