From patchwork Tue Feb 11 02:50:11 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shawn Guo X-Patchwork-Id: 24433 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ig0-f200.google.com (mail-ig0-f200.google.com [209.85.213.200]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 2C98120967 for ; Tue, 11 Feb 2014 02:50:36 +0000 (UTC) Received: by mail-ig0-f200.google.com with SMTP id k19sf17532543igc.3 for ; Mon, 10 Feb 2014 18:50:35 -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:subject:date:message-id :mime-version:cc:precedence:list-id:list-unsubscribe:list-archive :list-post:list-help:list-subscribe:sender:errors-to :x-original-sender:x-original-authentication-results:mailing-list :content-type:content-transfer-encoding; bh=ZCTRDlokeb2Oa/20knJ/6q1qZ2dgQLUsEcNCQaNEQCo=; b=DC85eKyVoYHQd0sURlsG9Bjfmt+RcpfUgMP0Ba9w4qKzjUgEA7xTL6fWeOozdSOwUx yhnEmsvBy6gvyZTYjFa8ZS9pMDxH8bSjyHdkzndMgN876weCQHMc3VCCAPXeLzkGwG6Q rMt74Cc+G7mw/SrR3vmYVSya/eG1LViicSkfFa0vPn5uN1Hb9SSZuwbEcwT/n5iu+Lit 7wKYAXuTx0pupbBPxX2+H/ylKxSomtutYGA83C2BmApaO3w+yHZfJbRtLxR/K7YBTVcc UjW3yKCVxzXgFAvNKGoKM+jFxXylgz1a6k2wpK+L5e5/bUomJtzslmVPmxPlHiW7x+Rk c73g== X-Gm-Message-State: ALoCoQnMU8ug25LFheMJRU23Tvabx0Ip81TEfVvVQzsqqrPzmIPawJyammxiraOKIL06bd/agU89 X-Received: by 10.182.216.200 with SMTP id os8mr13571686obc.0.1392087035108; Mon, 10 Feb 2014 18:50:35 -0800 (PST) X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.91.110 with SMTP id y101ls2426827qgd.0.gmail; Mon, 10 Feb 2014 18:50:35 -0800 (PST) X-Received: by 10.220.139.136 with SMTP id e8mr37722vcu.34.1392087035006; Mon, 10 Feb 2014 18:50:35 -0800 (PST) Received: from mail-vb0-f53.google.com (mail-vb0-f53.google.com [209.85.212.53]) by mx.google.com with ESMTPS id cz20si5415503veb.53.2014.02.10.18.50.34 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 10 Feb 2014 18:50:34 -0800 (PST) Received-SPF: neutral (google.com: 209.85.212.53 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.212.53; Received: by mail-vb0-f53.google.com with SMTP id p17so5331496vbe.40 for ; Mon, 10 Feb 2014 18:50:34 -0800 (PST) X-Received: by 10.220.139.136 with SMTP id e8mr37719vcu.34.1392087034907; Mon, 10 Feb 2014 18:50:34 -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 u4cs240433vcz; Mon, 10 Feb 2014 18:50:34 -0800 (PST) X-Received: by 10.180.189.169 with SMTP id gj9mr12895617wic.17.1392087033770; Mon, 10 Feb 2014 18:50:33 -0800 (PST) Received: from casper.infradead.org (casper.infradead.org. [2001:770:15f::2]) by mx.google.com with ESMTPS id b5si7782940wiy.76.2014.02.10.18.50.33 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 10 Feb 2014 18:50:33 -0800 (PST) Received-SPF: pass (google.com: domain of linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org designates 2001:770:15f::2 as permitted sender) client-ip=2001:770:15f::2; Received: from merlin.infradead.org ([2001:4978:20e::2]) by casper.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1WD3QP-0001LK-Tm; Tue, 11 Feb 2014 02:50:18 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1WD3QN-00056G-Lf; Tue, 11 Feb 2014 02:50:15 +0000 Received: from co1ehsobe002.messaging.microsoft.com ([216.32.180.185] helo=co1outboundpool.messaging.microsoft.com) by merlin.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1WD3QK-00055s-Gl for linux-arm-kernel@lists.infradead.org; Tue, 11 Feb 2014 02:50:13 +0000 Received: from mail156-co1-R.bigfish.com (10.243.78.246) by CO1EHSOBE020.bigfish.com (10.243.66.83) with Microsoft SMTP Server id 14.1.225.22; Tue, 11 Feb 2014 02:49:49 +0000 Received: from mail156-co1 (localhost [127.0.0.1]) by mail156-co1-R.bigfish.com (Postfix) with ESMTP id 884367A0ACF; Tue, 11 Feb 2014 02:49:49 +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(zcb8kzzz1f42h2148h208ch1ee6h1de0h1fdah2073h2146h1202h1e76h2189h1d1ah1d2ah21bch1fc6hzz1de098h8275dh1de097hz2dh87h2a8h839hd24he5bhf0ah1288h12a5h12a9h12bdh12e5h137ah139eh13b6h1441h1504h1537h162dh1631h1758h1898h18e1h1946h19b5h1ad9h1b0ah1b2fh2222h224fh1fb3h1d0ch1d2eh1d3fh1dc1h1dfeh1dffh1e23h1fe8h1ff5h2218h2216h226dh22d0h24afh2327h2336h2438h2461h2487h24d7h2516h2545h255eh1151h1155h) X-FB-DOMAIN-IP-MATCH: fail Received: from mail156-co1 (localhost.localdomain [127.0.0.1]) by mail156-co1 (MessageSwitch) id 1392086988370645_3565; Tue, 11 Feb 2014 02:49:48 +0000 (UTC) Received: from CO1EHSMHS029.bigfish.com (unknown [10.243.78.246]) by mail156-co1.bigfish.com (Postfix) with ESMTP id A8570AC0054; Tue, 11 Feb 2014 02:49:46 +0000 (UTC) Received: from mail.freescale.net (70.37.183.190) by CO1EHSMHS029.bigfish.com (10.243.66.39) with Microsoft SMTP Server (TLS) id 14.16.227.3; Tue, 11 Feb 2014 02:49:41 +0000 Received: from tx30smr01.am.freescale.net (10.81.153.31) by 039-SN1MMR1-004.039d.mgd.msft.net (10.84.1.14) with Microsoft SMTP Server (TLS) id 14.3.158.2; Tue, 11 Feb 2014 02:49:38 +0000 Received: from S2101-09.ap.freescale.net ([10.192.185.43]) by tx30smr01.am.freescale.net (8.14.3/8.14.0) with ESMTP id s1B2nXVo002115; Mon, 10 Feb 2014 19:49:33 -0700 From: Shawn Guo To: Subject: [PATCH] bus: imx-weim: support weim-cs-gpr for imx6q-weim Date: Tue, 11 Feb 2014 10:50:11 +0800 Message-ID: <1392087011-31629-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% X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20140210_215012_699605_16F790E3 X-CRM114-Status: GOOD ( 18.89 ) X-Spam-Score: -0.7 (/) X-Spam-Report: SpamAssassin version 3.3.2 on merlin.infradead.org summary: Content analysis details: (-0.7 points) pts rule name description ---- ---------------------- -------------------------------------------------- 1.3 UNRESOLVED_TEMPLATE Headers contain an unresolved template -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low trust [216.32.180.185 listed in list.dnswl.org] 0.7 SPF_SOFTFAIL SPF: sender does not match SPF record (softfail) -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] Cc: Huang Shijie , Philippe De Muyter , Shawn Guo , kernel@pengutronix.de, devicetree@vger.kernel.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: , List-Help: , List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.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.212.53 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 For imx6q-weim type of device, 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 0x5, 0x1b, 0x4b or 0x249 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 table in the driver for above configurations, and detects which one is being used for the booting system by looking at 'ranges' property of WEIM node. Thus the WEIM CS GPR can be set up automatically at boot time. Signed-off-by: Shawn Guo --- Documentation/devicetree/bindings/bus/imx-weim.txt | 6 ++ drivers/bus/imx-weim.c | 83 ++++++++++++++++++++ 2 files changed, 89 insertions(+) diff --git a/Documentation/devicetree/bindings/bus/imx-weim.txt b/Documentation/devicetree/bindings/bus/imx-weim.txt index 0fd76c4..d114460f 100644 --- a/Documentation/devicetree/bindings/bus/imx-weim.txt +++ b/Documentation/devicetree/bindings/bus/imx-weim.txt @@ -19,6 +19,12 @@ Required properties: 0 +Optional properties: + + - fsl,weim-cs-gpr: Should be the phandle to the General Purpose Register + controller that contains WEIM CS GPR register, e.g. + IOMUXC_GPR1 on i.MX6Q. + 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..9c8a522 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,83 @@ static const struct of_device_id weim_id_table[] = { }; MODULE_DEVICE_TABLE(of, weim_id_table); +struct imx6q_weim_gpr { + u32 cssize[4]; + u32 gprval; +}; + +static const struct imx6q_weim_gpr imx6q_weim_gpr_data[] __initconst = { + { + /* CS0(128M) CS1(0M) CS2(0M) CS3(0M) */ + .cssize = { 128, 0, 0, 0 }, + .gprval = 0x5, + }, { + /* CS0(64M) CS1(64M) CS2(0M) CS3(0M) */ + .cssize = { 64, 64, 0, 0 }, + .gprval = 0x1b, + }, { + /* CS0(64M) CS1(32M) CS2(32M) CS3(0M) */ + .cssize = { 64, 32, 32, 0 }, + .gprval = 0x4b, + }, { + /* CS0(64M) CS1(32M) CS2(32M) CS3(0M) */ + .cssize = { 32, 32, 32, 32 }, + .gprval = 0x249, + }, +}; + +static int __init imx6q_weim_gpr_setup(struct platform_device *pdev) +{ + struct device_node *np = pdev->dev.of_node; + const struct property *prop; + struct regmap *gpr; + u32 cssize[4] = { 0, 0, 0, 0 }; + int len; + int ret; + int i; + + gpr = syscon_regmap_lookup_by_phandle(np, "fsl,weim-cs-gpr"); + if (IS_ERR(gpr)) { + dev_dbg(&pdev->dev, "No weim-cs-gpr to set up\n"); + return 0; + } + + prop = of_find_property(np, "ranges", &len); + if (prop == NULL) + return -ENOENT; + if (len % (sizeof(u32) * 4)) + return -EINVAL; + + for (i = 0; i < len / (sizeof(u32) * 4); i++) { + int cs; + /* read cs index */ + ret = of_property_read_u32_index(np, "ranges", i * 4, &cs); + if (ret) + return ret; + /* read cs size */ + ret = of_property_read_u32_index(np, "ranges", i * 4 + 3, + &cssize[cs]); + if (ret) + return ret; + /* turn to MB */ + cssize[cs] >>= 20; + } + + for (i = 0; i < ARRAY_SIZE(imx6q_weim_gpr_data); i++) { + ret = memcmp(cssize, imx6q_weim_gpr_data[i].cssize, + sizeof(cssize)); + if (ret == 0) { + /* Find it. Set up IOMUXC_GPR1[11:0] with the gprval. */ + regmap_update_bits(gpr, IOMUXC_GPR1, 0xfff, + imx6q_weim_gpr_data[i].gprval); + return 0; + } + } + + 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 +172,9 @@ static int __init weim_parse_dt(struct platform_device *pdev, struct device_node *child; int ret; + if (of_device_is_compatible(pdev->dev.of_node, "fsl,imx6q-weim")) + imx6q_weim_gpr_setup(pdev); + for_each_child_of_node(pdev->dev.of_node, child) { if (!child->name) continue;