From patchwork Tue Jul 30 02:54:16 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Chen X-Patchwork-Id: 2835221 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 EFC24C0319 for ; Tue, 30 Jul 2013 02:55:01 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 2E12E201FC for ; Tue, 30 Jul 2013 02:54:57 +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 E5436201F9 for ; Tue, 30 Jul 2013 02:54:55 +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 1V405N-0006D6-Rs; Tue, 30 Jul 2013 02:54:54 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1V405L-0007Bd-GF; Tue, 30 Jul 2013 02:54:51 +0000 Received: from mail-db9lp0249.outbound.messaging.microsoft.com ([213.199.154.249] helo=db9outboundpool.messaging.microsoft.com) by merlin.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1V405H-0007Au-PR for linux-arm-kernel@lists.infradead.org; Tue, 30 Jul 2013 02:54:48 +0000 Received: from mail58-db9-R.bigfish.com (10.174.16.233) by DB9EHSOBE003.bigfish.com (10.174.14.66) with Microsoft SMTP Server id 14.1.225.22; Tue, 30 Jul 2013 02:54:25 +0000 Received: from mail58-db9 (localhost [127.0.0.1]) by mail58-db9-R.bigfish.com (Postfix) with ESMTP id 3AF3ADC011A; Tue, 30 Jul 2013 02:54:25 +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(zzzz1f42h208ch1ee6h1de0h1fdah2073h1202h1e76h1d1ah1d2ah1fc6hzz1de098h8275bh1de097hz2dh2a8h668h839hd24he5bhf0ah1288h12a5h12a9h12bdh12e5h1354h137ah139eh13b6h1441h1504h1537h162dh1631h1758h1898h18e1h1946h19b5h1ad9h1b0ah1d0ch1d2eh1d3fh1dc1h1dfeh1dffh1e23h1155h) Received: from mail58-db9 (localhost.localdomain [127.0.0.1]) by mail58-db9 (MessageSwitch) id 1375152862992075_24387; Tue, 30 Jul 2013 02:54:22 +0000 (UTC) Received: from DB9EHSMHS017.bigfish.com (unknown [10.174.16.246]) by mail58-db9.bigfish.com (Postfix) with ESMTP id E329DA0004D; Tue, 30 Jul 2013 02:54:22 +0000 (UTC) Received: from mail.freescale.net (70.37.183.190) by DB9EHSMHS017.bigfish.com (10.174.14.27) with Microsoft SMTP Server (TLS) id 14.16.227.3; Tue, 30 Jul 2013 02:54:22 +0000 Received: from az84smr01.freescale.net (10.64.34.197) by 039-SN1MMR1-001.039d.mgd.msft.net (10.84.1.13) with Microsoft SMTP Server (TLS) id 14.3.136.1; Tue, 30 Jul 2013 02:54:20 +0000 Received: from localhost.localdomain (nchen-desktop.ap.freescale.net [10.192.242.40]) by az84smr01.freescale.net (8.14.3/8.14.0) with ESMTP id r6U2sIJv029544; Mon, 29 Jul 2013 19:54:18 -0700 From: Peter Chen To: , Subject: [PATCH 1/2] pinctrl: imx: Add exception hook for select input Date: Tue, 30 Jul 2013 10:54:16 +0800 Message-ID: <1375152857-32177-1-git-send-email-peter.chen@freescale.com> X-Mailer: git-send-email 1.7.0.4 MIME-Version: 1.0 X-OriginatorOrg: freescale.com 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-20130729_225448_044366_580EF780 X-CRM114-Status: GOOD ( 16.72 ) X-Spam-Score: -1.9 (-) Cc: linus.walleij@linaro.org, linux-arm-kernel@lists.infradead.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+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 At some i.mx platforms the select input pin configuration may not be at common select input register region due to IC found the pin select pin configuration missing very late (Eg, ECO stage), so this pin's select input register is at other register space at pinctrl module. One typical example is USB OTG ID pin at i.mx6q is at IOMUXC_IOMUXC_GPR1. Signed-off-by: Peter Chen --- drivers/pinctrl/pinctrl-imx.c | 11 +++++++++-- drivers/pinctrl/pinctrl-imx.h | 8 ++++++-- drivers/pinctrl/pinctrl-imx6q.c | 14 ++++++++++++++ 3 files changed, 29 insertions(+), 4 deletions(-) diff --git a/drivers/pinctrl/pinctrl-imx.c b/drivers/pinctrl/pinctrl-imx.c index 57a4eb0..da75cd4 100644 --- a/drivers/pinctrl/pinctrl-imx.c +++ b/drivers/pinctrl/pinctrl-imx.c @@ -240,8 +240,15 @@ static int imx_pmx_enable(struct pinctrl_dev *pctldev, unsigned selector, pin_reg->mux_reg, mux[i]); /* some pins also need select input setting, set it if found */ - if (input_reg[i]) { - writel(input_val[i], ipctl->base + input_reg[i]); + if (input_reg) { + if ((input_reg[i] == IMX_SELECT_INPUT_EXCEPTION) && + info->imx_select_input_hook) + info->imx_select_input_hook(ipctl->base, + input_val[i]); + else + writel(input_val[i], ipctl->base + + input_reg[i]); + dev_dbg(ipctl->dev, "==>select_input: offset 0x%x val 0x%x\n", input_reg[i], input_val[i]); diff --git a/drivers/pinctrl/pinctrl-imx.h b/drivers/pinctrl/pinctrl-imx.h index bcedd99..15e71b9 100644 --- a/drivers/pinctrl/pinctrl-imx.h +++ b/drivers/pinctrl/pinctrl-imx.h @@ -26,8 +26,9 @@ struct platform_device; * elements in .pins so we can iterate over that array * @mux_mode: the mux mode for each pin in this group. The size of this * array is the same as pins. - * @input_reg: select input register offset for this mux if any - * 0 if no select input setting needed. + * @input_reg: select input register offset for this mux, + * 0 if no select input setting needed, 0xfff if select input setting + * is not at common select input register regiion. * @input_val: the select input value for each pin in this group. The size of * this array is the same as pins. * @configs: the config for each pin in this group. The size of this @@ -75,10 +76,13 @@ struct imx_pinctrl_soc_info { struct imx_pmx_func *functions; unsigned int nfunctions; unsigned int flags; + /* Handle the exception for select input choose */ + void (*imx_select_input_hook) (void __iomem *, int); }; #define ZERO_OFFSET_VALID 0x1 #define SHARE_MUX_CONF_REG 0x2 +#define IMX_SELECT_INPUT_EXCEPTION 0xfff #define NO_MUX 0x0 #define NO_PAD 0x0 diff --git a/drivers/pinctrl/pinctrl-imx6q.c b/drivers/pinctrl/pinctrl-imx6q.c index 76dd9c4..61efa97 100644 --- a/drivers/pinctrl/pinctrl-imx6q.c +++ b/drivers/pinctrl/pinctrl-imx6q.c @@ -461,9 +461,23 @@ static const struct pinctrl_pin_desc imx6q_pinctrl_pads[] = { IMX_PINCTRL_PIN(MX6Q_PAD_SD2_DAT3), }; +#define IOMUXC_IOMUXC_GPR1 0x4 +#define IOMUXC_GPR1_USB_OTG_ID_SEL_BIT 13 +static void imx6q_pinctrl_select_input_hook(void __iomem *base, int val) +{ + u32 value; + /* Add the exceptions one by one */ + + /* USB ID select input configuration */ + value = readl(base + IOMUXC_IOMUXC_GPR1); + writel(value | (val << IOMUXC_GPR1_USB_OTG_ID_SEL_BIT), + base + IOMUXC_IOMUXC_GPR1); +} + static struct imx_pinctrl_soc_info imx6q_pinctrl_info = { .pins = imx6q_pinctrl_pads, .npins = ARRAY_SIZE(imx6q_pinctrl_pads), + .imx_select_input_hook = imx6q_pinctrl_select_input_hook, }; static struct of_device_id imx6q_pinctrl_of_match[] = {