From patchwork Sun Feb 16 08:38:44 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shawn Guo X-Patchwork-Id: 24713 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-qa0-f71.google.com (mail-qa0-f71.google.com [209.85.216.71]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id BFE31201EE for ; Sun, 16 Feb 2014 08:38:05 +0000 (UTC) Received: by mail-qa0-f71.google.com with SMTP id j5sf26705636qaq.6 for ; Sun, 16 Feb 2014 00:38:04 -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=19hHcOdTMqSIZ0pqiQjxyRsDpt/FaKdJaCg1oxrvOAs=; b=YHBwzf6rOWZBSi5QPbpmoPHGhrKl+yM6OQqsDMmJ9pSf6LnJCQVgDZu79xn67c2fsD 0vvlARYOw9FdWKlNneaNnfZy3csMF9HVSSGGObIANpe+XSW2HoaX8P6jQkV3Gw+i764u vQhBvL55cvnfUUvKU4khiOEL3PxU0FnmMg99B6Gn28HXK0n+2ZUJ/9RHt7Q3GZSVNVhz JzZfl0r2JBK85VoqA1yOTF+o/mrUdLPUCq1HR1kEixyRVVVUlf6KQgJz58qZXs4K43cd fTbUk+VofBjXN8hmEZNv7iNbGF621AYZeUeYoQbdfYgcF9Z1ndgKg4Y7PvU2grRmgn05 BUMw== X-Gm-Message-State: ALoCoQkEg7IT21P/Nw5mbLgEGwFBBISuRTiUNBmO2+4vumlAOVxtM7JYBxjDfk6NgI5Gdiv1UJSd X-Received: by 10.236.13.36 with SMTP id a24mr6965041yha.50.1392539884868; Sun, 16 Feb 2014 00:38:04 -0800 (PST) X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.26.195 with SMTP id 61ls513533qgv.19.gmail; Sun, 16 Feb 2014 00:38:04 -0800 (PST) X-Received: by 10.221.55.133 with SMTP id vy5mr12428760vcb.17.1392539884782; Sun, 16 Feb 2014 00:38:04 -0800 (PST) Received: from mail-ve0-f171.google.com (mail-ve0-f171.google.com [209.85.128.171]) by mx.google.com with ESMTPS id zp2si3602498vec.46.2014.02.16.00.38.04 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Sun, 16 Feb 2014 00:38:04 -0800 (PST) Received-SPF: neutral (google.com: 209.85.128.171 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.171; Received: by mail-ve0-f171.google.com with SMTP id pa12so10916833veb.2 for ; Sun, 16 Feb 2014 00:38:04 -0800 (PST) X-Received: by 10.220.175.198 with SMTP id bb6mr399773vcb.31.1392539884621; Sun, 16 Feb 2014 00:38:04 -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 u4csp61319vcz; Sun, 16 Feb 2014 00:38:04 -0800 (PST) X-Received: by 10.68.64.196 with SMTP id q4mr19577643pbs.100.1392539883707; Sun, 16 Feb 2014 00:38:03 -0800 (PST) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id vb2si11073206pbc.187.2014.02.16.00.38.03; Sun, 16 Feb 2014 00:38:03 -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 S1750947AbaBPIiC (ORCPT + 9 others); Sun, 16 Feb 2014 03:38:02 -0500 Received: from tx2ehsobe003.messaging.microsoft.com ([65.55.88.13]:41058 "EHLO tx2outboundpool.messaging.microsoft.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750859AbaBPIiB (ORCPT ); Sun, 16 Feb 2014 03:38:01 -0500 Received: from mail137-tx2-R.bigfish.com (10.9.14.246) by TX2EHSOBE012.bigfish.com (10.9.40.32) with Microsoft SMTP Server id 14.1.225.22; Sun, 16 Feb 2014 08:38:00 +0000 Received: from mail137-tx2 (localhost [127.0.0.1]) by mail137-tx2-R.bigfish.com (Postfix) with ESMTP id 474341002B7; Sun, 16 Feb 2014 08:38:00 +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 mail137-tx2 (localhost.localdomain [127.0.0.1]) by mail137-tx2 (MessageSwitch) id 1392539877755338_25437; Sun, 16 Feb 2014 08:37:57 +0000 (UTC) Received: from TX2EHSMHS024.bigfish.com (unknown [10.9.14.242]) by mail137-tx2.bigfish.com (Postfix) with ESMTP id 998E44E0051; Sun, 16 Feb 2014 08:37:57 +0000 (UTC) Received: from mail.freescale.net (70.37.183.190) by TX2EHSMHS024.bigfish.com (10.9.99.124) with Microsoft SMTP Server (TLS) id 14.16.227.3; Sun, 16 Feb 2014 08:37:50 +0000 Received: from tx30smr01.am.freescale.net (10.81.153.31) by 039-SN1MMR1-002.039d.mgd.msft.net (10.84.1.15) with Microsoft SMTP Server (TLS) id 14.3.158.2; Sun, 16 Feb 2014 08:37:48 +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 s1G8biWE009104; Sun, 16 Feb 2014 01:37:45 -0700 From: Shawn Guo To: CC: Philippe De Muyter , Huang Shijie , , , Shawn Guo Subject: [PATCH v3] bus: imx-weim: support CS GPR config for imx6q-weim Date: Sun, 16 Feb 2014 16:38:44 +0800 Message-ID: <1392539924-23583-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.171 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 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 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 imx6q-weim type of device, 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 v2: - Fix a typo of 01111 value - Minor code improvements per Philippe's suggestion drivers/bus/imx-weim.c | 55 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) diff --git a/drivers/bus/imx-weim.c b/drivers/bus/imx-weim.c index 3ef58c8..08b017a 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 imx6q_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_compatible("fsl,imx6q-iomuxc-gpr"); + if (IS_ERR(gpr)) { + dev_err(&pdev->dev, "failed to find fsl,imx6q-iomuxc-gpr\n"); + return -ENOENT; + } + + 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 (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;