From patchwork Thu Feb 13 12:59:02 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shawn Guo X-Patchwork-Id: 24594 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-qa0-f69.google.com (mail-qa0-f69.google.com [209.85.216.69]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id EA7A2202E2 for ; Thu, 13 Feb 2014 12:58:34 +0000 (UTC) Received: by mail-qa0-f69.google.com with SMTP id w8sf20649466qac.0 for ; Thu, 13 Feb 2014 04:58:34 -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=Y2dTceTakxh4ogebiXzekaj1lBLkOGZmQn/vk8gxl2A=; b=EmEn2uqHiMnXuZymeiH00PaLYHAH0d7zRxVxp6d4LSADYkDY0jlGkJ3S0/36aU+T4p +4sxR9LNOH/jjfx18O+adryH7v7Vppp/x6ASOeyuykimiUKmbk6AORDvY92fKkHYLa+8 ic1nBlDJOCiBDzVdCawXFnf4qoVvqAA9ktNQmfE2yFMqP8n5JMzsBXbUg9Jia6d1yZwi JMdA7mGfdeUxvIIaZqoSruPDePtWH2hMXVK36gbeRhQbDPMZfuVDNNUWFtneB5TbMWi6 qC87o/KUV1NpI9u/rbSEq2VeI1kdAgQkoEh9NRk3dQAN01TNvDCfF4eyK+zoVT/T/9jb dgrA== X-Gm-Message-State: ALoCoQk2AriucXlzfvTzGOwjb2EXlnxcHa9IDYSVwjyKFDVYcau6IWzoGgqtMkn7bjXNDypX+tjo X-Received: by 10.58.23.170 with SMTP id n10mr425012vef.25.1392296314088; Thu, 13 Feb 2014 04:58:34 -0800 (PST) X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.27.117 with SMTP id 108ls3551853qgw.77.gmail; Thu, 13 Feb 2014 04:58:33 -0800 (PST) X-Received: by 10.58.4.138 with SMTP id k10mr918110vek.8.1392296313963; Thu, 13 Feb 2014 04:58:33 -0800 (PST) Received: from mail-vb0-f51.google.com (mail-vb0-f51.google.com [209.85.212.51]) by mx.google.com with ESMTPS id rl1si622218vcb.74.2014.02.13.04.58.33 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 13 Feb 2014 04:58:33 -0800 (PST) Received-SPF: neutral (google.com: 209.85.212.51 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.51; Received: by mail-vb0-f51.google.com with SMTP id j16so2425480vbh.10 for ; Thu, 13 Feb 2014 04:58:33 -0800 (PST) X-Received: by 10.58.90.202 with SMTP id by10mr894937veb.6.1392296313853; Thu, 13 Feb 2014 04:58:33 -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 u4csp23610vcz; Thu, 13 Feb 2014 04:58:33 -0800 (PST) X-Received: by 10.68.236.9 with SMTP id uq9mr1710915pbc.10.1392296312923; Thu, 13 Feb 2014 04:58:32 -0800 (PST) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id yy4si2014701pbc.159.2014.02.13.04.58.32; Thu, 13 Feb 2014 04:58:32 -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 S1753455AbaBMM6b (ORCPT + 9 others); Thu, 13 Feb 2014 07:58:31 -0500 Received: from va3ehsobe005.messaging.microsoft.com ([216.32.180.31]:34588 "EHLO va3outboundpool.messaging.microsoft.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753257AbaBMM6a (ORCPT ); Thu, 13 Feb 2014 07:58:30 -0500 Received: from mail190-va3-R.bigfish.com (10.7.14.233) by VA3EHSOBE009.bigfish.com (10.7.40.29) with Microsoft SMTP Server id 14.1.225.22; Thu, 13 Feb 2014 12:58:29 +0000 Received: from mail190-va3 (localhost [127.0.0.1]) by mail190-va3-R.bigfish.com (Postfix) with ESMTP id BD2273401B9; Thu, 13 Feb 2014 12:58:29 +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 mail190-va3 (localhost.localdomain [127.0.0.1]) by mail190-va3 (MessageSwitch) id 1392296307963790_499; Thu, 13 Feb 2014 12:58:27 +0000 (UTC) Received: from VA3EHSMHS028.bigfish.com (unknown [10.7.14.246]) by mail190-va3.bigfish.com (Postfix) with ESMTP id E4BCF48007B; Thu, 13 Feb 2014 12:58:27 +0000 (UTC) Received: from mail.freescale.net (70.37.183.190) by VA3EHSMHS028.bigfish.com (10.7.99.38) with Microsoft SMTP Server (TLS) id 14.16.227.3; Thu, 13 Feb 2014 12:58:24 +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; Thu, 13 Feb 2014 12:58:23 +0000 Received: from S2101-09.ap.freescale.net ([10.192.185.141]) by tx30smr01.am.freescale.net (8.14.3/8.14.0) with ESMTP id s1DCwJOQ006191; Thu, 13 Feb 2014 05:58:20 -0700 From: Shawn Guo To: CC: Philippe De Muyter , Huang Shijie , , , Shawn Guo Subject: [PATCH v2] bus: imx-weim: support CS GPR config for imx6q-weim Date: Thu, 13 Feb 2014 20:59:02 +0800 Message-ID: <1392296342-21115-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.212.51 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 v1: - Drop device tree property fsl,weim-cs-gpr - Use octal value for IOMUXC_GPR1[11:0] bit field - Use of_property_for_each_u32() to build gprval incrementally drivers/bus/imx-weim.c | 59 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) diff --git a/drivers/bus/imx-weim.c b/drivers/bus/imx-weim.c index 3ef58c8..a120c93 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,59 @@ 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) */ + 0111, /* CS0(64M) CS1(32M) CS2(32M) CS3(0M) */ + }; + u32 gprval = 0; + u32 val; + int len; + 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; + } + + prop = of_find_property(np, "ranges", &len); + if (prop == NULL) + return -ENOENT; + if (len % (sizeof(u32) * 4)) + return -EINVAL; + + of_property_for_each_u32(np, "ranges", prop, p, val) { + if (i % 4 == 0) { + cs = val; + } else if (i % 4 == 3 && val) { + val /= SZ_64M; + val = (val << 1) | 1; + gprval |= val << cs * 3; + } + i++; + } + + 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; + } + } + + 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 +148,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;