From patchwork Tue Feb 18 06:41:06 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shawn Guo X-Patchwork-Id: 24815 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ob0-f198.google.com (mail-ob0-f198.google.com [209.85.214.198]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id B16C5201EE for ; Tue, 18 Feb 2014 06:40:15 +0000 (UTC) Received: by mail-ob0-f198.google.com with SMTP id wp4sf62488270obc.5 for ; Mon, 17 Feb 2014 22:40:14 -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=NXIq//rYWsDDfq2gqp6YRKshQ4M/2+Y1B51Fyptsi1E=; b=GKc3ij0kgQ8zrxMLIrns/htUQu+5V4cEVeylGYF2dD+nAUJsLDMbTfCl+N0wHIJ612 3kHkSVoXgfahjHMqc0o/KjSSultzRnhNmLcs1h3T6wXzUOPv6+f1kC8gcWGpqnkOpgWq tWhAtSVcbAJUMicG060iJ1hWf73T2hJ85lXRBFJwG1cCPBqflocNmvian9MkhW6wyyXG PgbCaKe6VkWFuWXQiPiOrP9BccnWZkGeo/VZC3DM2nuuOQvMvxlWPMhxISa5vAVIL3Cg LAr0idg1HBgfRehgbWlUDQrjINeupTi1N3rtCfsyn3g7vrYqFjNRykDvLJcn5wVf5BbH IJSw== X-Gm-Message-State: ALoCoQmovMRAgAqcWANIIGciAUBHjTJvSA1iL2z6iaZ7jGHiApybxJdGz9tJH6XMhF3vJp+37Nzh X-Received: by 10.50.47.6 with SMTP id z6mr10412517igm.4.1392705614655; Mon, 17 Feb 2014 22:40:14 -0800 (PST) X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.25.33 with SMTP id 30ls1206073qgs.22.gmail; Mon, 17 Feb 2014 22:40:14 -0800 (PST) X-Received: by 10.52.30.230 with SMTP id v6mr16695200vdh.6.1392705614520; Mon, 17 Feb 2014 22:40:14 -0800 (PST) Received: from mail-ve0-f174.google.com (mail-ve0-f174.google.com [209.85.128.174]) by mx.google.com with ESMTPS id yv5si5239302veb.64.2014.02.17.22.40.14 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 17 Feb 2014 22:40:14 -0800 (PST) Received-SPF: neutral (google.com: 209.85.128.174 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.174; Received: by mail-ve0-f174.google.com with SMTP id pa12so12811009veb.5 for ; Mon, 17 Feb 2014 22:40:14 -0800 (PST) X-Received: by 10.220.58.202 with SMTP id i10mr15764099vch.23.1392705614299; Mon, 17 Feb 2014 22:40:14 -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 u4csp194198vcz; Mon, 17 Feb 2014 22:40:13 -0800 (PST) X-Received: by 10.68.211.1 with SMTP id my1mr31413645pbc.55.1392705613078; Mon, 17 Feb 2014 22:40:13 -0800 (PST) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id xk2si17172728pab.42.2014.02.17.22.40.12; Mon, 17 Feb 2014 22:40:12 -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 S1752346AbaBRGkL (ORCPT + 9 others); Tue, 18 Feb 2014 01:40:11 -0500 Received: from co1ehsobe003.messaging.microsoft.com ([216.32.180.186]:46091 "EHLO co1outboundpool.messaging.microsoft.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751239AbaBRGkK (ORCPT ); Tue, 18 Feb 2014 01:40:10 -0500 Received: from mail181-co1-R.bigfish.com (10.243.78.252) by CO1EHSOBE028.bigfish.com (10.243.66.91) with Microsoft SMTP Server id 14.1.225.22; Tue, 18 Feb 2014 06:40:10 +0000 Received: from mail181-co1 (localhost [127.0.0.1]) by mail181-co1-R.bigfish.com (Postfix) with ESMTP id E24052000EE; Tue, 18 Feb 2014 06:40:09 +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 mail181-co1 (localhost.localdomain [127.0.0.1]) by mail181-co1 (MessageSwitch) id 1392705607295012_9830; Tue, 18 Feb 2014 06:40:07 +0000 (UTC) Received: from CO1EHSMHS025.bigfish.com (unknown [10.243.78.225]) by mail181-co1.bigfish.com (Postfix) with ESMTP id 38CEDBC0049; Tue, 18 Feb 2014 06:40:07 +0000 (UTC) Received: from mail.freescale.net (70.37.183.190) by CO1EHSMHS025.bigfish.com (10.243.66.35) with Microsoft SMTP Server (TLS) id 14.16.227.3; Tue, 18 Feb 2014 06:40:06 +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; Tue, 18 Feb 2014 06:40:05 +0000 Received: from S2101-09.ap.freescale.net ([10.192.185.144]) by tx30smr01.am.freescale.net (8.14.3/8.14.0) with ESMTP id s1I6dsKT032688; Mon, 17 Feb 2014 23:39:55 -0700 From: Shawn Guo To: CC: Philippe De Muyter , Alexander Shiyan , Huang Shijie , , Rob Herring , Mark Rutland , , Shawn Guo Subject: [PATCH v5] bus: imx-weim: support CS GPR configuration Date: Tue, 18 Feb 2014 14:41:06 +0800 Message-ID: <1392705666-10995-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.174 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 v4: - Fix a typo in comment - Add fsl,weim-cs-gpr in the binding example - Check return of imx_weim_gpr_setup() Documentation/devicetree/bindings/bus/imx-weim.txt | 28 +++++++++- drivers/bus/imx-weim.c | 58 ++++++++++++++++++++ 2 files changed, 85 insertions(+), 1 deletion(-) diff --git a/Documentation/devicetree/bindings/bus/imx-weim.txt b/Documentation/devicetree/bindings/bus/imx-weim.txt index 0fd76c4..6630d84 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 @@ -43,6 +68,7 @@ Example for an imx6q-sabreauto board, the NOR flash connected to the WEIM: #address-cells = <2>; #size-cells = <1>; ranges = <0 0 0x08000000 0x08000000>; + fsl,weim-cs-gpr = <&gpr>; nor@0,0 { compatible = "cfi-flash"; diff --git a/drivers/bus/imx-weim.c b/drivers/bus/imx-weim.c index 3ef58c8..f8ee13c 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(32M) CS1(32M) CS2(32M) CS3(32M) */ + }; + 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,12 @@ static int __init weim_parse_dt(struct platform_device *pdev, struct device_node *child; int ret; + if (devtype == &imx50_weim_devtype) { + ret = imx_weim_gpr_setup(pdev); + if (ret) + return ret; + } + for_each_child_of_node(pdev->dev.of_node, child) { if (!child->name) continue;