Skip to contentSkip to conversation

dt-bindings: usb: ci-hdrc-usb2: add property power-active-high

PATCH Superseded Philipp Puschmann 5 participants 12 messages Jan 15, 2019 – Jan 22, 2019

Subsystems (4)

v1 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 dt-bindings: usb: ci-hdrc-usb2: add property power-active-high

---
 Documentation/devicetree/bindings/usb/ci-hdrc-usb2.txt | 1 +
 1 file changed, 1 insertion(+)
Documentation/devicetree/bindings/usb/ci-hdrc-usb2.txt +1 -0
index adae82385dd6..8696e3eff6e7 100644
@@ -93,6 +93,7 @@ i.mx specific properties
 - over-current-active-low: over current signal polarity is active low.
 - over-current-active-high: over current signal polarity is active high.
   It's recommended to specify the over current polarity.
+- power-active-high: power signal polarity is high active (only for imx6q/dl)
 - external-vbus-divider: enables off-chip resistor divider for Vbus
 
 Example:
Signature · 1 line
2.20.1
#1 lore raw

PATCH 2/2 usb: chipidea: imx: set power polarity

This patch adds support to set the power line polarity for i.MX6q/dl.

To let the USB controller control the power it may be necessary to configure the polarity of the power line. So far the polarity was configured by Bootloader or alternatively the power line was muxed as gpio and driven by a regulator.

---
 drivers/usb/chipidea/ci_hdrc_imx.c | 3 +++
 drivers/usb/chipidea/ci_hdrc_imx.h | 1 +
 drivers/usb/chipidea/usbmisc_imx.c | 4 ++++
 3 files changed, 8 insertions(+)
drivers/usb/chipidea/ci_hdrc_imx.c +3 -0
index e81de9ca8729..32dc120680fa 100644
@@ -152,6 +152,9 @@ static struct imx_usbmisc_data *usbmisc_get_init_data(struct device *dev)
 		dev_warn(dev, "No over current polarity defined\n");
 	}
 
+	if (of_find_property(np, "power-active-high", NULL))
+		data->pwr_pol = 1;
+
 	if (of_find_property(np, "external-vbus-divider", NULL))
 		data->evdo = 1;
 
drivers/usb/chipidea/ci_hdrc_imx.h +1 -0
index 7cc53e2ce564..c842e03f8767 100644
@@ -18,6 +18,7 @@ struct imx_usbmisc_data {
 	/* true if dt specifies polarity */
 	unsigned int oc_pol_configured:1;
 
+	unsigned int pwr_pol:1; /* power polarity */
 	unsigned int evdo:1; /* set external vbus divider option */
 	unsigned int ulpi:1; /* connected to an ULPI phy */
 	unsigned int hsic:1; /* HSIC controlller */
drivers/usb/chipidea/usbmisc_imx.c +4 -0
index 097ffbca0bd9..13e52632aece 100644
@@ -63,6 +63,7 @@
 #define MX6_BM_NON_BURST_SETTING	BIT(1)
 #define MX6_BM_OVER_CUR_DIS		BIT(7)
 #define MX6_BM_OVER_CUR_POLARITY	BIT(8)
+#define MX6_BM_PWR_POLARITY		BIT(9)
 #define MX6_BM_WAKEUP_ENABLE		BIT(10)
 #define MX6_BM_UTMI_ON_CLOCK		BIT(13)
 #define MX6_BM_ID_WAKEUP		BIT(16)
@@ -383,6 +384,9 @@ static int usbmisc_imx6q_init(struct imx_usbmisc_data *data)
 		else if (data->oc_pol_configured)
 			reg &= ~MX6_BM_OVER_CUR_POLARITY;
 	}
+	/* If the polarity is not set keep it as setup by the bootlader */
+	if (data->pwr_polarity == 1)
+		reg |= MX6_BM_PWR_POLARITY;
 	writel(reg, usbmisc->base + data->index * 4);
 
 	/* SoC non-burst setting */
Signature · 1 line
2.20.1
#2 lore raw

PATCH v2 1/2 dt-bindings: usb: ci-hdrc-usb2: add property power-active-high

In reply to Philipp Puschmann

---

V2: unchanged ...

---
 Documentation/devicetree/bindings/usb/ci-hdrc-usb2.txt | 1 +
 1 file changed, 1 insertion(+)
Documentation/devicetree/bindings/usb/ci-hdrc-usb2.txt +1 -0
index adae82385dd6..8696e3eff6e7 100644
@@ -93,6 +93,7 @@ i.mx specific properties
 - over-current-active-low: over current signal polarity is active low.
 - over-current-active-high: over current signal polarity is active high.
   It's recommended to specify the over current polarity.
+- power-active-high: power signal polarity is high active (only for imx6q/dl)
 - external-vbus-divider: enables off-chip resistor divider for Vbus
 
 Example:
Signature · 1 line
2.20.1
#3 lore raw

PATCH v2 2/2 usb: chipidea: imx: set power polarity

This patch adds support to set the power line polarity for i.MX6q/dl.

To let the USB controller control the power it may be necessary to configure the polarity of the power line. So far the polarity was configured by Bootloader or alternatively the power line was muxed as gpio and driven by a regulator.

---

V2: fixed wrong variable name ...

---
 drivers/usb/chipidea/ci_hdrc_imx.c | 3 +++
 drivers/usb/chipidea/ci_hdrc_imx.h | 1 +
 drivers/usb/chipidea/usbmisc_imx.c | 4 ++++
 3 files changed, 8 insertions(+)
drivers/usb/chipidea/ci_hdrc_imx.c +3 -0
index e81de9ca8729..32dc120680fa 100644
@@ -152,6 +152,9 @@ static struct imx_usbmisc_data *usbmisc_get_init_data(struct device *dev)
 		dev_warn(dev, "No over current polarity defined\n");
 	}
 
+	if (of_find_property(np, "power-active-high", NULL))
+		data->pwr_pol = 1;
+
 	if (of_find_property(np, "external-vbus-divider", NULL))
 		data->evdo = 1;
 
drivers/usb/chipidea/ci_hdrc_imx.h +1 -0
index 7cc53e2ce564..c842e03f8767 100644
@@ -18,6 +18,7 @@ struct imx_usbmisc_data {
 	/* true if dt specifies polarity */
 	unsigned int oc_pol_configured:1;
 
+	unsigned int pwr_pol:1; /* power polarity */
 	unsigned int evdo:1; /* set external vbus divider option */
 	unsigned int ulpi:1; /* connected to an ULPI phy */
 	unsigned int hsic:1; /* HSIC controlller */
drivers/usb/chipidea/usbmisc_imx.c +4 -0
index 097ffbca0bd9..64a7c7ff4b35 100644
@@ -63,6 +63,7 @@
 #define MX6_BM_NON_BURST_SETTING	BIT(1)
 #define MX6_BM_OVER_CUR_DIS		BIT(7)
 #define MX6_BM_OVER_CUR_POLARITY	BIT(8)
+#define MX6_BM_PWR_POLARITY		BIT(9)
 #define MX6_BM_WAKEUP_ENABLE		BIT(10)
 #define MX6_BM_UTMI_ON_CLOCK		BIT(13)
 #define MX6_BM_ID_WAKEUP		BIT(16)
@@ -383,6 +384,9 @@ static int usbmisc_imx6q_init(struct imx_usbmisc_data *data)
 		else if (data->oc_pol_configured)
 			reg &= ~MX6_BM_OVER_CUR_POLARITY;
 	}
+	/* If the polarity is not set keep it as setup by the bootlader */
+	if (data->pwr_pol == 1)
+		reg |= MX6_BM_PWR_POLARITY;
 	writel(reg, usbmisc->base + data->index * 4);
 
 	/* SoC non-burst setting */
Signature · 1 line
2.20.1
#4 lore raw

PATCH v3 1/2 dt-bindings: usb: ci-hdrc-usb2: add property power-active-high

The i.MX6q/dl USB controller may drive the usb power line directly, but the polarity depends on the board. Reset state of the polarity is low-active so add this property to allow it to be high-active.

---
Changes in v3: add description

---
 Documentation/devicetree/bindings/usb/ci-hdrc-usb2.txt | 1 +
 1 file changed, 1 insertion(+)
Documentation/devicetree/bindings/usb/ci-hdrc-usb2.txt +1 -0
index adae82385dd6..8696e3eff6e7 100644
@@ -93,6 +93,7 @@ i.mx specific properties
 - over-current-active-low: over current signal polarity is active low.
 - over-current-active-high: over current signal polarity is active high.
   It's recommended to specify the over current polarity.
+- power-active-high: power signal polarity is high active (only for imx6q/dl)
 - external-vbus-divider: enables off-chip resistor divider for Vbus
 
 Example:
Signature · 1 line
2.20.1
#5 lore raw

PATCH v3 2/2 usb: chipidea: imx: set power polarity

This patch adds support to set the power line polarity for i.MX6q/dl.

To let the USB controller control the power it may be necessary to configure the polarity of the power line. So far the polarity was configured by Bootloader or alternatively the power line was muxed as gpio and driven by a regulator.

---
Changes in v2: fixed usage of wrong variable name
Changes in v3: no changes

---
 drivers/usb/chipidea/ci_hdrc_imx.c | 3 +++
 drivers/usb/chipidea/ci_hdrc_imx.h | 1 +
 drivers/usb/chipidea/usbmisc_imx.c | 4 ++++
 3 files changed, 8 insertions(+)
drivers/usb/chipidea/ci_hdrc_imx.c +3 -0
index e81de9ca8729..32dc120680fa 100644
@@ -152,6 +152,9 @@ static struct imx_usbmisc_data *usbmisc_get_init_data(struct device *dev)
 		dev_warn(dev, "No over current polarity defined\n");
 	}
 
+	if (of_find_property(np, "power-active-high", NULL))
+		data->pwr_pol = 1;
+
 	if (of_find_property(np, "external-vbus-divider", NULL))
 		data->evdo = 1;
 
drivers/usb/chipidea/ci_hdrc_imx.h +1 -0
index 7cc53e2ce564..c842e03f8767 100644
@@ -18,6 +18,7 @@ struct imx_usbmisc_data {
 	/* true if dt specifies polarity */
 	unsigned int oc_pol_configured:1;
 
+	unsigned int pwr_pol:1; /* power polarity */
 	unsigned int evdo:1; /* set external vbus divider option */
 	unsigned int ulpi:1; /* connected to an ULPI phy */
 	unsigned int hsic:1; /* HSIC controlller */
drivers/usb/chipidea/usbmisc_imx.c +4 -0
index 097ffbca0bd9..64a7c7ff4b35 100644
@@ -63,6 +63,7 @@
 #define MX6_BM_NON_BURST_SETTING	BIT(1)
 #define MX6_BM_OVER_CUR_DIS		BIT(7)
 #define MX6_BM_OVER_CUR_POLARITY	BIT(8)
+#define MX6_BM_PWR_POLARITY		BIT(9)
 #define MX6_BM_WAKEUP_ENABLE		BIT(10)
 #define MX6_BM_UTMI_ON_CLOCK		BIT(13)
 #define MX6_BM_ID_WAKEUP		BIT(16)
@@ -383,6 +384,9 @@ static int usbmisc_imx6q_init(struct imx_usbmisc_data *data)
 		else if (data->oc_pol_configured)
 			reg &= ~MX6_BM_OVER_CUR_POLARITY;
 	}
+	/* If the polarity is not set keep it as setup by the bootlader */
+	if (data->pwr_pol == 1)
+		reg |= MX6_BM_PWR_POLARITY;
 	writel(reg, usbmisc->base + data->index * 4);
 
 	/* SoC non-burst setting */
Signature · 1 line
2.20.1
#10 lore raw

Re: [PATCH v2,2/2] usb: chipidea: imx: set power polarity

In reply to Philipp Puschmann

Hello!

Quoted 23 lines · Philipp Puschmann

This patch adds support to set the power line polarity for i.MX6q/dl.

To let the USB controller control the power it may be necessary to configure the polarity of the power line. So far the polarity was configured by Bootloader or alternatively the power line was muxed as gpio and driven by a regulator.

---

V2: fixed wrong variable name ...

---
 drivers/usb/chipidea/ci_hdrc_imx.c | 3 +++
 drivers/usb/chipidea/ci_hdrc_imx.h | 1 +
 drivers/usb/chipidea/usbmisc_imx.c | 4 ++++
 3 files changed, 8 insertions(+)
drivers/usb/chipidea/ci_hdrc_imx.c +0 -0
index e81de9ca8729..32dc120680fa 100644

drivers/usb/chipidea/ci_hdrc_imx.c static struct imx_usbmisc_data *usbmisc_get_init_data(struct device *dev) · line 155

Quoted 4 lines
drivers/usb/chipidea/ci_hdrc_imx.c +1 -0
@@ -152,6 +152,9 @@ static struct imx_usbmisc_data *usbmisc_get_init_data(struct device *dev)
 		dev_warn(dev, "No over current polarity defined\n");
 	}
 
+	if (of_find_property(np, "power-active-high", NULL))

How about of_property_read_bool()?

drivers/usb/chipidea/ci_hdrc_imx.c static struct imx_usbmisc_data *usbmisc_get_init_data(struct device *dev) · line 160

Quoted 5 lines
drivers/usb/chipidea/ci_hdrc_imx.c +2 -0
+		data->pwr_pol = 1;
+
 	if (of_find_property(np, "external-vbus-divider", NULL))
 		data->evdo = 1;
 

[...]

MBR, Sergei

maintainer Reviewed-by on v3 1/2
#6 lore raw
In reply to Philipp Puschmann
Quoted 11 lines · Philipp Puschmann

The i.MX6q/dl USB controller may drive the usb power line directly, but the polarity depends on the board. Reset state of the polarity is low-active so add this property to allow it to be high-active.

---
Changes in v3: add description

---
 Documentation/devicetree/bindings/usb/ci-hdrc-usb2.txt | 1 +
 1 file changed, 1 insertion(+)
#7 lore raw
In reply to Philipp Puschmann
Quoted 6 lines

The i.MX6q/dl USB controller may drive the usb power line directly, but the polarity depends on the board. Reset state of the polarity is low-active so add this property to allow it to be high-active.

As far as I know, most of i.mx USB controllers (except imx28/23, but they don't have non-core registers) work like this, and most of them are low active for PP default. Would you just use "i.mx" at both your code and your comment?

Peter

Quoted 23 lines

---
Changes in v3: add description

---
 Documentation/devicetree/bindings/usb/ci-hdrc-usb2.txt | 1 +
 1 file changed, 1 insertion(+)
Documentation/devicetree/bindings/usb/ci-hdrc-usb2.txt +2 -1
index adae82385dd6..8696e3eff6e7 100644
@@ -93,6 +93,7 @@ i.mx specific properties
 - over-current-active-low: over current signal polarity is active low.
 - over-current-active-high: over current signal polarity is active high.
   It's recommended to specify the over current polarity.
+- power-active-high: power signal polarity is high active (only for
+imx6q/dl)
 - external-vbus-divider: enables off-chip resistor divider for Vbus
 
 Example:
--

2.20.1

#11 lore raw

Re: [PATCH v2,2/2] usb: chipidea: imx: set power polarity

In reply to Sergei Shtylyov

Hi!

Am 16.01.19 um 17:32 schrieb Sergei Shtylyov:

Quoted 30 lines

Hello!

Quoted 26 lines · Philipp Puschmann

This patch adds support to set the power line polarity for i.MX6q/dl.

To let the USB controller control the power it may be necessary to configure the polarity of the power line. So far the polarity was configured by Bootloader or alternatively the power line was muxed as gpio and driven by a regulator.

---

V2: fixed wrong variable name ...

---
 drivers/usb/chipidea/ci_hdrc_imx.c | 3 +++
 drivers/usb/chipidea/ci_hdrc_imx.h | 1 +
 drivers/usb/chipidea/usbmisc_imx.c | 4 ++++
 3 files changed, 8 insertions(+)
drivers/usb/chipidea/ci_hdrc_imx.c +0 -0
index e81de9ca8729..32dc120680fa 100644
@@ -152,6 +152,9 @@ static struct imx_usbmisc_data *usbmisc_get_init_data(struct device *dev)
 		dev_warn(dev, "No over current polarity defined\n");
 	}
 
Quoted 3 lines

drivers/usb/chipidea/ci_hdrc_imx.c static struct imx_usbmisc_data *usbmisc_get_init_data(struct device *dev) · line 155

Quoted 1 line
drivers/usb/chipidea/ci_hdrc_imx.c +1 -0
+	if (of_find_property(np, "power-active-high", NULL))

How about of_property_read_bool()?

Good idea. I will send a patch v4 in next days.

Quoted 10 lines

drivers/usb/chipidea/ci_hdrc_imx.c static struct imx_usbmisc_data *usbmisc_get_init_data(struct device *dev) · line 160

Quoted 6 lines
drivers/usb/chipidea/ci_hdrc_imx.c +2 -0
+		data->pwr_pol = 1;
+
 	if (of_find_property(np, "external-vbus-divider", NULL))
 		data->evdo = 1;
 

[...]

MBR, Sergei

#8 lore raw
In reply to Peter Chen

Hi Peter,

Am 17.01.19 um 08:01 schrieb Peter Chen:

Quoted 10 lines
Quoted 6 lines

The i.MX6q/dl USB controller may drive the usb power line directly, but the polarity depends on the board. Reset state of the polarity is low-active so add this property to allow it to be high-active.

As far as I know, most of i.mx USB controllers (except imx28/23, but they don't have non-core registers) work like this, and most of them are low active for PP default. Would you just use "i.mx" at both your code and your comment?

Am i right that i have to add my code block to (nearly) all other version specific init functions then? Will do so in next days and then send a v4 of this patch.

Quoted 27 lines

Peter

Quoted 23 lines

---
Changes in v3: add description

---
 Documentation/devicetree/bindings/usb/ci-hdrc-usb2.txt | 1 +
 1 file changed, 1 insertion(+)
Documentation/devicetree/bindings/usb/ci-hdrc-usb2.txt +2 -1
index adae82385dd6..8696e3eff6e7 100644
@@ -93,6 +93,7 @@ i.mx specific properties
 - over-current-active-low: over current signal polarity is active low.
 - over-current-active-high: over current signal polarity is active high.
   It's recommended to specify the over current polarity.
+- power-active-high: power signal polarity is high active (only for
+imx6q/dl)
 - external-vbus-divider: enables off-chip resistor divider for Vbus
 
 Example:
--

2.20.1

#9 lore raw
Quoted 9 lines

Am 17.01.19 um 08:01 schrieb Peter Chen:

Quoted 7 lines
Quoted 6 lines

The i.MX6q/dl USB controller may drive the usb power line directly, but the polarity depends on the board. Reset state of the polarity is low-active so add this property to allow it to be high-active.

Quoted 7 lines
Quoted 3 lines

As far as I know, most of i.mx USB controllers (except imx28/23, but they don't have non-core registers) work like this, and most of them are low active for PP default. Would you just use "i.mx" at both your code and

your comment?

Am i right that i have to add my code block to (nearly) all other version specific init functions then?

Besides your current patch, only usbmisc_imx7d_init is needed to add the same content.

Peter

Quoted 28 lines

Will do so in next days and then send a v4 of this patch.

Quoted 27 lines

Peter

Quoted 23 lines

---
Changes in v3: add description

---
 Documentation/devicetree/bindings/usb/ci-hdrc-usb2.txt | 1 +
 1 file changed, 1 insertion(+)
Documentation/devicetree/bindings/usb/ci-hdrc-usb2.txt +2 -1
index adae82385dd6..8696e3eff6e7 100644
@@ -93,6 +93,7 @@ i.mx specific properties
 - over-current-active-low: over current signal polarity is active low.
 - over-current-active-high: over current signal polarity is active high.
   It's recommended to specify the over current polarity.
+- power-active-high: power signal polarity is high active (only for
+imx6q/dl)
 - external-vbus-divider: enables off-chip resistor divider for Vbus
 
 Example:
--

2.20.1