linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] pinctrl: imx: Add exception hook for select input
@ 2013-07-30  2:54 Peter Chen
  2013-07-30  2:54 ` [PATCH 2/2] imx: pinctrl: change XXX_USB_OTG_ID configuration Peter Chen
  2013-07-30  7:50 ` [PATCH 1/2] pinctrl: imx: Add exception hook for select input Shawn Guo
  0 siblings, 2 replies; 7+ messages in thread
From: Peter Chen @ 2013-07-30  2:54 UTC (permalink / raw)
  To: linux-arm-kernel

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 <peter.chen@freescale.com>
---
 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[] = {
-- 
1.7.0.4

^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2013-08-07 18:29 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-07-30  2:54 [PATCH 1/2] pinctrl: imx: Add exception hook for select input Peter Chen
2013-07-30  2:54 ` [PATCH 2/2] imx: pinctrl: change XXX_USB_OTG_ID configuration Peter Chen
2013-07-30  7:50 ` [PATCH 1/2] pinctrl: imx: Add exception hook for select input Shawn Guo
2013-07-30  8:00   ` Peter Chen
2013-07-30  8:38     ` Shawn Guo
2013-07-31  5:20       ` Shawn Guo
2013-08-07 18:29         ` Linus Walleij

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).