From patchwork Thu Aug 1 04:22:03 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shawn Guo X-Patchwork-Id: 2836760 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 66EC7C0319 for ; Thu, 1 Aug 2013 06:15:03 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 5573B201D6 for ; Thu, 1 Aug 2013 06:15:02 +0000 (UTC) Received: from casper.infradead.org (casper.infradead.org [85.118.1.10]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 54EC920190 for ; Thu, 1 Aug 2013 06:15:01 +0000 (UTC) Received: from merlin.infradead.org ([2001:4978:20e::2]) by casper.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1V4m9g-0002Kh-Tg; Thu, 01 Aug 2013 06:14:33 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1V4m9T-0006zL-S4; Thu, 01 Aug 2013 06:14:19 +0000 Received: from co1ehsobe003.messaging.microsoft.com ([216.32.180.186] helo=co1outboundpool.messaging.microsoft.com) by merlin.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1V4m9K-0006xZ-Sk for linux-arm-kernel@lists.infradead.org; Thu, 01 Aug 2013 06:14:11 +0000 Received: from mail171-co1-R.bigfish.com (10.243.78.244) by CO1EHSOBE005.bigfish.com (10.243.66.68) with Microsoft SMTP Server id 14.1.225.22; Thu, 1 Aug 2013 06:13:49 +0000 Received: from mail171-co1 (localhost [127.0.0.1]) by mail171-co1-R.bigfish.com (Postfix) with ESMTP id 141B74C00B7; Thu, 1 Aug 2013 06:13: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: 0 X-BigFish: VS0(zzzz1f42h208ch1ee6h1de0h1fdah2073h1202h1e76h1d1ah1d2ah1fc6hzz1de098h8275dh1de097hz2dh2a8h668h839hd24he5bhf0ah107ah11b5h121eh1288h12a5h12a9h12bdh12e5h137ah139eh13b6h1441h14afh1504h1537h162dh1631h1758h1898h18e1h1946h19b5h1ad9h1b0ah1b2fh1fb3h1d0ch1d2eh1d3fh1dc1h1dfeh1dffh1e1dh1e23h1155h) Received: from mail171-co1 (localhost.localdomain [127.0.0.1]) by mail171-co1 (MessageSwitch) id 1375337626276806_25968; Thu, 1 Aug 2013 06:13:46 +0000 (UTC) Received: from CO1EHSMHS022.bigfish.com (unknown [10.243.78.245]) by mail171-co1.bigfish.com (Postfix) with ESMTP id 3EDEA54004A; Thu, 1 Aug 2013 06:13:46 +0000 (UTC) Received: from mail.freescale.net (70.37.183.190) by CO1EHSMHS022.bigfish.com (10.243.66.32) with Microsoft SMTP Server (TLS) id 14.16.227.3; Thu, 1 Aug 2013 06:13:45 +0000 Received: from az84smr01.freescale.net (10.64.34.197) by 039-SN1MMR1-004.039d.mgd.msft.net (10.84.1.14) with Microsoft SMTP Server (TLS) id 14.3.136.1; Thu, 1 Aug 2013 06:13:34 +0000 Received: from shlinux1.ap.freescale.net (shlinux1.ap.freescale.net [10.192.225.216]) by az84smr01.freescale.net (8.14.3/8.14.0) with ESMTP id r716DXFQ023293; Wed, 31 Jul 2013 23:13:34 -0700 Received: by shlinux1.ap.freescale.net (Postfix, from userid 1027) id 0CCE11AE0F9; Thu, 1 Aug 2013 12:22:06 +0800 (CST) From: Shawn Guo To: Subject: [PATCH 1/2] pinctrl: imx: work around select input quirk Date: Thu, 1 Aug 2013 12:22:03 +0800 Message-ID: <1375330924-27384-1-git-send-email-shawn.guo@linaro.org> X-Mailer: git-send-email 1.7.1 MIME-Version: 1.0 X-OriginatorOrg: freescale.net X-FOPE-CONNECTOR: Id%0$Dn%*$RO%0$TLS%0$FQDN%$TlsDn% X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20130801_021411_092470_C1530D89 X-CRM114-Status: GOOD ( 15.94 ) X-Spam-Score: -2.6 (--) Cc: Linus Walleij , Shawn Guo , Peter Chen , kernel@pengutronix.de 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+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-5.7 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The select input for some pin may not be implemented using the regular select input register but the general purpose register. A real example is that imx6q designers found the select input for USB OTG ID pin is missing at the very late stage, and can not add a new select input register but have to use a general purpose register bit to implement it. The patch adds a workaround for such select input quirk by interpreting the input_val cell of pin function ID in a different way, so that all the info that needed for setting up select input bits in general purpose register could be decoded from there. Signed-off-by: Shawn Guo --- drivers/pinctrl/pinctrl-imx.c | 25 ++++++++++++++++++++++++- 1 files changed, 24 insertions(+), 1 deletions(-) diff --git a/drivers/pinctrl/pinctrl-imx.c b/drivers/pinctrl/pinctrl-imx.c index 57a4eb0..6ebe2e9 100644 --- a/drivers/pinctrl/pinctrl-imx.c +++ b/drivers/pinctrl/pinctrl-imx.c @@ -241,7 +241,30 @@ static int imx_pmx_enable(struct pinctrl_dev *pctldev, unsigned selector, /* some pins also need select input setting, set it if found */ if (input_reg[i]) { - writel(input_val[i], ipctl->base + input_reg[i]); + u32 val = input_val[i]; + /* + * If the select input value begins with 0xff, the value + * will be interpreted as below. + * 31 23 15 7 0 + * | 0xff | shift | width | select | + * It's used to work around the problem that the select + * input for some pin is not implemented in the select + * input register but in some general purpose register. + * We encode the select input value, width and shift of + * the bit field into input_val cell of pin function ID + * in device tree, and then decode them here for setting + * up the select input bits in general purpose register. + */ + if (val >> 24 == 0xff) { + u8 select = val & 0xff; + u8 width = (val >> 8) & 0xff; + u8 shift = (val >> 16) & 0xff; + u32 mask = ((1 << width) - 1) << shift; + val = readl(ipctl->base + input_reg[i]); + val &= ~mask; + val |= select << shift; + } + writel(val, ipctl->base + input_reg[i]); dev_dbg(ipctl->dev, "==>select_input: offset 0x%x val 0x%x\n", input_reg[i], input_val[i]);