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

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

The XXX_USB_OTG_ID select input chosen is not at common select
input register region, we add exception for this pin configration.

Signed-off-by: Peter Chen <peter.chen@freescale.com>
---
 arch/arm/boot/dts/imx6q-pinfunc.h |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/arm/boot/dts/imx6q-pinfunc.h b/arch/arm/boot/dts/imx6q-pinfunc.h
index faea6e1..a40a5a6 100644
--- a/arch/arm/boot/dts/imx6q-pinfunc.h
+++ b/arch/arm/boot/dts/imx6q-pinfunc.h
@@ -532,7 +532,7 @@
 #define MX6Q_PAD_ENET_REF_CLK__ESAI_RX_FS         0x1d4 0x4e8 0x85c 0x2 0x0
 #define MX6Q_PAD_ENET_REF_CLK__GPIO1_IO23         0x1d4 0x4e8 0x000 0x5 0x0
 #define MX6Q_PAD_ENET_REF_CLK__SPDIF_SR_CLK       0x1d4 0x4e8 0x000 0x6 0x0
-#define MX6Q_PAD_ENET_RX_ER__USB_OTG_ID           0x1d8 0x4ec 0x000 0x0 0x0
+#define MX6Q_PAD_ENET_RX_ER__USB_OTG_ID           0x1d8 0x4ec 0xfff 0x0 0x0
 #define MX6Q_PAD_ENET_RX_ER__ENET_RX_ER           0x1d8 0x4ec 0x000 0x1 0x0
 #define MX6Q_PAD_ENET_RX_ER__ESAI_RX_HF_CLK       0x1d8 0x4ec 0x864 0x2 0x0
 #define MX6Q_PAD_ENET_RX_ER__SPDIF_IN             0x1d8 0x4ec 0x914 0x3 0x1
@@ -650,7 +650,7 @@
 #define MX6Q_PAD_GPIO_1__ESAI_RX_CLK              0x224 0x5f4 0x86c 0x0 0x1
 #define MX6Q_PAD_GPIO_1__WDOG2_B                  0x224 0x5f4 0x000 0x1 0x0
 #define MX6Q_PAD_GPIO_1__KEY_ROW5                 0x224 0x5f4 0x8f4 0x2 0x0
-#define MX6Q_PAD_GPIO_1__USB_OTG_ID               0x224 0x5f4 0x000 0x3 0x0
+#define MX6Q_PAD_GPIO_1__USB_OTG_ID               0x224 0x5f4 0xfff 0x3 0x1
 #define MX6Q_PAD_GPIO_1__PWM2_OUT                 0x224 0x5f4 0x000 0x4 0x0
 #define MX6Q_PAD_GPIO_1__GPIO1_IO01               0x224 0x5f4 0x000 0x5 0x0
 #define MX6Q_PAD_GPIO_1__SD1_CD_B                 0x224 0x5f4 0x000 0x6 0x0
-- 
1.7.0.4

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

* [PATCH 1/2] pinctrl: imx: Add exception hook for select input
  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 ` Shawn Guo
  2013-07-30  8:00   ` Peter Chen
  1 sibling, 1 reply; 7+ messages in thread
From: Shawn Guo @ 2013-07-30  7:50 UTC (permalink / raw)
  To: linux-arm-kernel

On Tue, Jul 30, 2013 at 10:54:16AM +0800, Peter Chen wrote:
> 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.

Do you know any other case except this USB OTG ID pin on imx6q?  If this
is the only case, I'm wondering if we could work it around in machine
code mach-imx6q.c to avoid the churn of pinctrl driver?

Shawn

> 
> 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	[flat|nested] 7+ messages in thread

* [PATCH 1/2] pinctrl: imx: Add exception hook for select input
  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
  0 siblings, 1 reply; 7+ messages in thread
From: Peter Chen @ 2013-07-30  8:00 UTC (permalink / raw)
  To: linux-arm-kernel

On Tue, Jul 30, 2013 at 03:50:21PM +0800, Shawn Guo wrote:
> On Tue, Jul 30, 2013 at 10:54:16AM +0800, Peter Chen wrote:
> > 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.
> 
> Do you know any other case except this USB OTG ID pin on imx6q?  If this
> is the only case, I'm wondering if we could work it around in machine
> code mach-imx6q.c to avoid the churn of pinctrl driver?
> 

I searched the RM, this is the only one. If you don't think we need
to consider if it will occur in the future, I am OK to move it at machine
code, but every mx6q board need it if it does not use default select input
value.

-- 

Best Regards,
Peter Chen

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

* [PATCH 1/2] pinctrl: imx: Add exception hook for select input
  2013-07-30  8:00   ` Peter Chen
@ 2013-07-30  8:38     ` Shawn Guo
  2013-07-31  5:20       ` Shawn Guo
  0 siblings, 1 reply; 7+ messages in thread
From: Shawn Guo @ 2013-07-30  8:38 UTC (permalink / raw)
  To: linux-arm-kernel

On Tue, Jul 30, 2013 at 04:00:29PM +0800, Peter Chen wrote:
> I searched the RM, this is the only one. If you don't think we need
> to consider if it will occur in the future, I am OK to move it at machine
> code, but every mx6q board need it if it does not use default select input
> value.

Yes, maybe you can put it into imx6q_usb_init() with
if (IS_ENABLED(CONFIG_USB_OTG)) protect.

Shawn

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

* [PATCH 1/2] pinctrl: imx: Add exception hook for select input
  2013-07-30  8:38     ` Shawn Guo
@ 2013-07-31  5:20       ` Shawn Guo
  2013-08-07 18:29         ` Linus Walleij
  0 siblings, 1 reply; 7+ messages in thread
From: Shawn Guo @ 2013-07-31  5:20 UTC (permalink / raw)
  To: linux-arm-kernel

On Tue, Jul 30, 2013 at 04:38:05PM +0800, Shawn Guo wrote:
> On Tue, Jul 30, 2013 at 04:00:29PM +0800, Peter Chen wrote:
> > I searched the RM, this is the only one. If you don't think we need
> > to consider if it will occur in the future, I am OK to move it at machine
> > code, but every mx6q board need it if it does not use default select input
> > value.
> 
> Yes, maybe you can put it into imx6q_usb_init() with
> if (IS_ENABLED(CONFIG_USB_OTG)) protect.

I misunderstood it.  As it varies from board to board, we can not nicely
handle it in mach-imx6q.c.  I have some other idea to solve the problem,
and will cook up a patch to demonstrate it.

Shawn

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

* [PATCH 1/2] pinctrl: imx: Add exception hook for select input
  2013-07-31  5:20       ` Shawn Guo
@ 2013-08-07 18:29         ` Linus Walleij
  0 siblings, 0 replies; 7+ messages in thread
From: Linus Walleij @ 2013-08-07 18:29 UTC (permalink / raw)
  To: linux-arm-kernel

On Wed, Jul 31, 2013 at 7:20 AM, Shawn Guo <shawn.guo@linaro.org> wrote:
> On Tue, Jul 30, 2013 at 04:38:05PM +0800, Shawn Guo wrote:
>> On Tue, Jul 30, 2013 at 04:00:29PM +0800, Peter Chen wrote:
>> > I searched the RM, this is the only one. If you don't think we need
>> > to consider if it will occur in the future, I am OK to move it at machine
>> > code, but every mx6q board need it if it does not use default select input
>> > value.
>>
>> Yes, maybe you can put it into imx6q_usb_init() with
>> if (IS_ENABLED(CONFIG_USB_OTG)) protect.
>
> I misunderstood it.  As it varies from board to board, we can not nicely
> handle it in mach-imx6q.c.  I have some other idea to solve the problem,
> and will cook up a patch to demonstrate it.

I'm putting this patch on hold until we've seen Shawn's proof of concept.

Yours,
Linus Walleij

^ permalink raw reply	[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).