From patchwork Sun Feb 16 14:03:01 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shawn Guo X-Patchwork-Id: 24714 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-pa0-f70.google.com (mail-pa0-f70.google.com [209.85.220.70]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id CB669203BE for ; Sun, 16 Feb 2014 14:02:26 +0000 (UTC) Received: by mail-pa0-f70.google.com with SMTP id kq14sf34134394pab.1 for ; Sun, 16 Feb 2014 06:02:25 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:from:to:cc:subject:date:message-id :mime-version:sender:precedence:list-id:x-original-sender :x-original-authentication-results:mailing-list:list-post:list-help :list-archive:list-unsubscribe:content-type; bh=LsDKzIu52pbSsGu9t52n/5lgTRbEgJBjpbXkNO1gYDQ=; b=JHLM7J1D9aR7Y+zE200RS1L4h/1mTUzFe97Pfwi2WcKqVnivaXJlIdDTr0I86EnYpQ F3At750/uu6gKwuQjSlH/XDf9Kw67Jm68DFYK5Z+2VsGNa2ufV7eRKb29eiKyoaz7kg1 Ux+i3OwZWPRyuon9Ehvj5F62DZb8tKnCpCTIKGHiDxKXhp8GTy/T/LLVvQY6KVXq7LL4 gAzZD2bx1R/H1An/kO/uNt4vd63Oz3sCzwGTFrb9vSXuaUmHzRdSn18IAPejj4FTAc7N bqpK4jzWNm3vPrh7BciMUwxkt6wzlfQL6J6ld5ZR5dGl0kcnSzpAbIiaQOW1fJCD8z8i z3PA== X-Gm-Message-State: ALoCoQk3xhmUZKFAa+SHTjCje6LaBSJ3fQEoermfcf0R1laYnzalZpaSeB9WMSTFBMuH4id7gcRc X-Received: by 10.66.66.109 with SMTP id e13mr8000893pat.1.1392559345564; Sun, 16 Feb 2014 06:02:25 -0800 (PST) X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.51.130 with SMTP id u2ls655043qga.34.gmail; Sun, 16 Feb 2014 06:02:25 -0800 (PST) X-Received: by 10.52.179.198 with SMTP id di6mr11287000vdc.7.1392559345460; Sun, 16 Feb 2014 06:02:25 -0800 (PST) Received: from mail-ve0-f169.google.com (mail-ve0-f169.google.com [209.85.128.169]) by mx.google.com with ESMTPS id uo16si3747694veb.86.2014.02.16.06.02.25 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Sun, 16 Feb 2014 06:02:25 -0800 (PST) Received-SPF: neutral (google.com: 209.85.128.169 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.128.169; Received: by mail-ve0-f169.google.com with SMTP id oy12so11178051veb.14 for ; Sun, 16 Feb 2014 06:02:25 -0800 (PST) X-Received: by 10.52.89.230 with SMTP id br6mr11325910vdb.20.1392559345115; Sun, 16 Feb 2014 06:02:25 -0800 (PST) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.220.174.196 with SMTP id u4csp74328vcz; Sun, 16 Feb 2014 06:02:24 -0800 (PST) X-Received: by 10.68.89.162 with SMTP id bp2mr1971993pbb.151.1392559343969; Sun, 16 Feb 2014 06:02:23 -0800 (PST) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id x3si11736694pbk.203.2014.02.16.06.02.23; Sun, 16 Feb 2014 06:02:23 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of devicetree-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752146AbaBPOCW (ORCPT + 9 others); Sun, 16 Feb 2014 09:02:22 -0500 Received: from co1ehsobe005.messaging.microsoft.com ([216.32.180.188]:52681 "EHLO co1outboundpool.messaging.microsoft.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752138AbaBPOCV (ORCPT ); Sun, 16 Feb 2014 09:02:21 -0500 Received: from mail59-co1-R.bigfish.com (10.243.78.234) by CO1EHSOBE041.bigfish.com (10.243.66.106) with Microsoft SMTP Server id 14.1.225.22; Sun, 16 Feb 2014 14:02:21 +0000 Received: from mail59-co1 (localhost [127.0.0.1]) by mail59-co1-R.bigfish.com (Postfix) with ESMTP id E82E590031D; Sun, 16 Feb 2014 14:02:20 +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: 0 X-BigFish: VS0(zzzz1f42h2148h208ch1ee6h1de0h1fdah2073h2146h1202h1e76h2189h1d1ah1d2ah21bch1fc6hzz1de098h8275dh1de097hz2dh87h2a8h839hd24he5bhf0ah1288h12a5h12a9h12bdh12e5h137ah139eh13b6h1441h1504h1537h162dh1631h1758h1898h18e1h1946h19b5h1ad9h1b0ah1b2fh2222h224fh1fb3h1d0ch1d2eh1d3fh1dc1h1dfeh1dffh1e23h1fe8h1ff5h2218h2216h226dh22d0h24afh2327h2336h2438h2461h2487h24d7h2516h2545h255eh1151h1155h) X-FB-DOMAIN-IP-MATCH: fail Received: from mail59-co1 (localhost.localdomain [127.0.0.1]) by mail59-co1 (MessageSwitch) id 1392559338770698_32711; Sun, 16 Feb 2014 14:02:18 +0000 (UTC) Received: from CO1EHSMHS011.bigfish.com (unknown [10.243.78.235]) by mail59-co1.bigfish.com (Postfix) with ESMTP id B69D730004D; Sun, 16 Feb 2014 14:02:18 +0000 (UTC) Received: from mail.freescale.net (70.37.183.190) by CO1EHSMHS011.bigfish.com (10.243.66.21) with Microsoft SMTP Server (TLS) id 14.16.227.3; Sun, 16 Feb 2014 14:02:18 +0000 Received: from tx30smr01.am.freescale.net (10.81.153.31) by 039-SN1MMR1-003.039d.mgd.msft.net (10.84.1.16) with Microsoft SMTP Server (TLS) id 14.3.158.2; Sun, 16 Feb 2014 14:02:17 +0000 Received: from S2101-09.ap.freescale.net ([10.192.185.149]) by tx30smr01.am.freescale.net (8.14.3/8.14.0) with ESMTP id s1GE29Tm007676; Sun, 16 Feb 2014 07:02:10 -0700 From: Shawn Guo To: CC: Philippe De Muyter , Alexander Shiyan , Huang Shijie , , , Rob Herring , Mark Rutland , Shawn Guo Subject: [PATCH v4] bus: imx-weim: support CS GPR configuration Date: Sun, 16 Feb 2014 22:03:01 +0800 Message-ID: <1392559381-30842-1-git-send-email-shawn.guo@linaro.org> X-Mailer: git-send-email 1.7.9.5 MIME-Version: 1.0 X-OriginatorOrg: sigmatel.com X-FOPE-CONNECTOR: Id%0$Dn%*$RO%0$TLS%0$FQDN%$TlsDn% X-FOPE-CONNECTOR: Id%0$Dn%FREESCALE.MAIL.ONMICROSOFT.COM$RO%1$TLS%0$FQDN%$TlsDn% Sender: devicetree-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: devicetree@vger.kernel.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: shawn.guo@linaro.org X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.128.169 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , For imx50-weim and imx6q-weim type of devices, there might a WEIM CS space configuration register in General Purpose Register controller, e.g. IOMUXC_GPR1 on i.MX6Q. Depending on which configuration of the following 4 is chosen for given system, IOMUXC_GPR1[11:0] should be set up as 05, 033, 0113 or 01111 correspondingly. CS0(128M) CS1(0M) CS2(0M) CS3(0M) CS0(64M) CS1(64M) CS2(0M) CS3(0M) CS0(64M) CS1(32M) CS2(32M) CS3(0M) CS0(32M) CS1(32M) CS2(32M) CS3(32M) The patch creates a function for such type of devices, which scans 'ranges' property of WEIM node and build the GPR value incrementally. Thus the WEIM CS GPR can be set up automatically at boot time. Signed-off-by: Shawn Guo --- Changes since v3: - Add DT property fsl,weim-cs-gpr back, so that the support can work for more i.MX SoCs than just i.MX6Q. Documentation/devicetree/bindings/bus/imx-weim.txt | 27 +++++++++- drivers/bus/imx-weim.c | 55 ++++++++++++++++++++ 2 files changed, 81 insertions(+), 1 deletion(-) diff --git a/Documentation/devicetree/bindings/bus/imx-weim.txt b/Documentation/devicetree/bindings/bus/imx-weim.txt index 0fd76c4..363c970 100644 --- a/Documentation/devicetree/bindings/bus/imx-weim.txt +++ b/Documentation/devicetree/bindings/bus/imx-weim.txt @@ -8,7 +8,12 @@ The actual devices are instantiated from the child nodes of a WEIM node. Required properties: - - compatible: Should be set to "fsl,-weim" + - compatible: Should contain one of the following: + "fsl,imx1-weim" + "fsl,imx27-weim" + "fsl,imx51-weim" + "fsl,imx50-weim" + "fsl,imx6q-weim" - reg: A resource specifier for the register space (see the example below) - clocks: the clock, see the example below. @@ -19,6 +24,26 @@ Required properties: 0 +Optional properties: + + - fsl,weim-cs-gpr: For "fsl,imx50-weim" and "fsl,imx6q-weim" type of + devices, it should be the phandle to the system General + Purpose Register controller that contains WEIM CS GPR + register, e.g. IOMUXC_GPR1 on i.MX6Q. IOMUXC_GPR1[11:0] + should be set up as one of the following 4 possible + values depending on the CS space configuration. + + IOMUXC_GPR1[11:0] CS0 CS1 CS2 CS3 + --------------------------------------------- + 05 128M 0M 0M 0M + 033 64M 64M 0M 0M + 0113 64M 32M 32M 0M + 01111 32M 32M 32M 32M + + In case that the property is absent, the reset value or + what bootloader sets up in IOMUXC_GPR1[11:0] will be + used. + Timing property for child nodes. It is mandatory, not optional. - fsl,weim-cs-timing: The timing array, contains timing values for the diff --git a/drivers/bus/imx-weim.c b/drivers/bus/imx-weim.c index 3ef58c8..35e9529 100644 --- a/drivers/bus/imx-weim.c +++ b/drivers/bus/imx-weim.c @@ -11,6 +11,9 @@ #include #include #include +#include +#include +#include struct imx_weim_devtype { unsigned int cs_count; @@ -56,6 +59,55 @@ static const struct of_device_id weim_id_table[] = { }; MODULE_DEVICE_TABLE(of, weim_id_table); +static int __init imx_weim_gpr_setup(struct platform_device *pdev) +{ + struct device_node *np = pdev->dev.of_node; + struct property *prop; + const __be32 *p; + struct regmap *gpr; + u32 gprvals[4] = { + 05, /* CS0(128M) CS1(0M) CS2(0M) CS3(0M) */ + 033, /* CS0(64M) CS1(64M) CS2(0M) CS3(0M) */ + 0113, /* CS0(64M) CS1(32M) CS2(32M) CS3(0M) */ + 01111, /* CS0(64M) CS1(32M) CS2(32M) CS3(0M) */ + }; + u32 gprval = 0; + u32 val; + int cs = 0; + int i = 0; + + gpr = syscon_regmap_lookup_by_phandle(np, "fsl,weim-cs-gpr"); + if (IS_ERR(gpr)) { + dev_dbg(&pdev->dev, "failed to find weim-cs-gpr\n"); + return 0; + } + + of_property_for_each_u32(np, "ranges", prop, p, val) { + if (i % 4 == 0) { + cs = val; + } else if (i % 4 == 3 && val) { + val = (val / SZ_32M) | 1; + gprval |= val << cs * 3; + } + i++; + } + + if (i == 0 || i % 4) + goto err; + + for (i = 0; i < ARRAY_SIZE(gprvals); i++) { + if (gprval == gprvals[i]) { + /* Found it. Set up IOMUXC_GPR1[11:0] with it. */ + regmap_update_bits(gpr, IOMUXC_GPR1, 0xfff, gprval); + return 0; + } + } + +err: + dev_err(&pdev->dev, "Invalid 'ranges' configuration\n"); + return -EINVAL; +} + /* Parse and set the timing for this device. */ static int __init weim_timing_setup(struct device_node *np, void __iomem *base, const struct imx_weim_devtype *devtype) @@ -92,6 +144,9 @@ static int __init weim_parse_dt(struct platform_device *pdev, struct device_node *child; int ret; + if (devtype == &imx50_weim_devtype) + imx_weim_gpr_setup(pdev); + for_each_child_of_node(pdev->dev.of_node, child) { if (!child->name) continue;