Skip to contentSkip to conversation

usb: host: ehci-vf: Remove hardcoded USB host client configuration

PATCH New Sanchayan Maity 4 participants 36 messages Oct 26, 2015 – Jan 8, 2016

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/3 usb: host: ehci-vf: Remove hardcoded USB host client configuration

The current ehci-vf USB driver for Vybrid hardcodes the USB host and client functionality. Remove this.

---
 drivers/usb/host/ehci-vf.c | 5 -----
 1 file changed, 5 deletions(-)
drivers/usb/host/ehci-vf.c +0 -5
index 98e0fc6..351e0fb 100644
@@ -134,11 +134,6 @@ int ehci_hcd_init(int index, enum usb_init_type init,
 	if (index >= ARRAY_SIZE(nc_reg_bases))
 		return -EINVAL;
 
-	if (init == USB_INIT_DEVICE && index == 1)
-		return -ENODEV;
-	if (init == USB_INIT_HOST && index == 0)
-		return -ENODEV;
-
 	ehci = (struct usb_ehci *)nc_reg_bases[index];
 
 	/* Do board specific initialisation */
Signature · 1 line
2.6.2
#1 lore raw

PATCH 1/3 usb: host: ehci-vf: Remove hardcoded USB host client configuration

Hello Stefano / Marek,

Can you pick this up?

- Sanchayan.

Quoted 28 lines · Sanchayan Maity

The current ehci-vf USB driver for Vybrid hardcodes the USB host and client functionality. Remove this.

---
 drivers/usb/host/ehci-vf.c | 5 -----
 1 file changed, 5 deletions(-)
drivers/usb/host/ehci-vf.c +0 -5
index 98e0fc6..351e0fb 100644
@@ -134,11 +134,6 @@ int ehci_hcd_init(int index, enum usb_init_type init,
 	if (index >= ARRAY_SIZE(nc_reg_bases))
 		return -EINVAL;
 
-	if (init == USB_INIT_DEVICE && index == 1)
-		return -ENODEV;
-	if (init == USB_INIT_HOST && index == 0)
-		return -ENODEV;
-
 	ehci = (struct usb_ehci *)nc_reg_bases[index];
 
 	/* Do board specific initialisation */
Signature · 1 line
2.6.2
#2 lore raw

PATCH 1/3 usb: host: ehci-vf: Remove hardcoded USB host client configuration

Quoted 3 lines · maitysanchayan at gmail.com

Hello Stefano / Marek,

Can you pick this up?

I can, but only for next. Is that fine ?

Quoted 30 lines

- Sanchayan.

Quoted 27 lines · Sanchayan Maity

The current ehci-vf USB driver for Vybrid hardcodes the USB host and client functionality. Remove this.

---

 drivers/usb/host/ehci-vf.c | 5 -----
 1 file changed, 5 deletions(-)
drivers/usb/host/ehci-vf.c +0 -5
index 98e0fc6..351e0fb 100644
@@ -134,11 +134,6 @@ int ehci_hcd_init(int index, enum usb_init_type
 init,
 
 	if (index >= ARRAY_SIZE(nc_reg_bases))
 
 		return -EINVAL;
 
-	if (init == USB_INIT_DEVICE && index == 1)
-		return -ENODEV;
-	if (init == USB_INIT_HOST && index == 0)
-		return -ENODEV;
-
Quoted 3 lines

drivers/usb/host/ehci-vf.c int ehci_hcd_init(int index, enum usb_init_type init, · line 139

Quoted 3 lines
drivers/usb/host/ehci-vf.c +0 -0
 	ehci = (struct usb_ehci *)nc_reg_bases[index];
 
 	/* Do board specific initialisation */

Best regards,
Marek Vasut

#3 lore raw

PATCH 1/3 usb: host: ehci-vf: Remove hardcoded USB host client configuration

Hello Marek,

Quoted 6 lines · Marek Vasut
Quoted 3 lines · maitysanchayan at gmail.com

Hello Stefano / Marek,

Can you pick this up?

I can, but only for next. Is that fine ?

Yes it's fine. Thank you.

- Sanchayan.

Quoted 35 lines
Quoted 29 lines · Sanchayan Maity
Quoted 27 lines

The current ehci-vf USB driver for Vybrid hardcodes the USB host and client functionality. Remove this.

---

 drivers/usb/host/ehci-vf.c | 5 -----
 1 file changed, 5 deletions(-)
drivers/usb/host/ehci-vf.c +0 -5
index 98e0fc6..351e0fb 100644
@@ -134,11 +134,6 @@ int ehci_hcd_init(int index, enum usb_init_type
 init,
 
 	if (index >= ARRAY_SIZE(nc_reg_bases))
 
 		return -EINVAL;
 
-	if (init == USB_INIT_DEVICE && index == 1)
-		return -ENODEV;
-	if (init == USB_INIT_HOST && index == 0)
-		return -ENODEV;
-
Quoted 3 lines

drivers/usb/host/ehci-vf.c int ehci_hcd_init(int index, enum usb_init_type init, · line 139

Quoted 3 lines
drivers/usb/host/ehci-vf.c +0 -0
 	ehci = (struct usb_ehci *)nc_reg_bases[index];
 
 	/* Do board specific initialisation */

Best regards,
Marek Vasut

Applied
#4 lore raw

PATCH 1/3 usb: host: ehci-vf: Remove hardcoded USB host client configuration

In reply to maitysanchayan at gmail.com
Quoted 4 lines · maitysanchayan at gmail.com

Hello Stefano / Marek,

Can you pick this up?

Applied, will be in next MW.

Best regards,
Marek Vasut

#5 lore raw

PATCH 2/3 usb: host: ehci-vf: Implement board_usb_phy_mode weak function

In reply to Sanchayan Maity

Add board_usb_phy_mode weak function on similar lines to ehci-mx6. However since Vybrid USB does not have a true OTG, make this weak functon just return 0. The function is supposed to be implemented by the individual boards using a GPIO for providing the OTG pin functionality.

---
There seems to be a problem here. As per DFU's help note, the first argument to dfu is the USB controller.

So if dfu 1 nand 2 is run, I would expect the ehci_hcd_init function's first index argument to recieve 1. However this does not seem to be the case. Not sure if I am understanding something wrongly here. Is this expected?

Currently because of this even though I did like dfu 1 nand 2 to bail out, it does not. I tried tracing the code from do_dfu but I have yet to get from where ehci_hcd_init is getting called in the call chain.

All seems to be well when using usb start.

---
 drivers/usb/host/ehci-vf.c | 10 ++++++++++
 1 file changed, 10 insertions(+)
drivers/usb/host/ehci-vf.c +10 -0
index 351e0fb..335e303 100644
@@ -121,6 +121,11 @@ static void usb_oc_config(int index)
 	setbits_le32(ctrl, UCTRL_OVER_CUR_DIS);
 }
 
+int __weak board_usb_phy_mode(int port)
+{
+	return 0;
+}
+
 int __weak board_ehci_hcd_init(int port)
 {
 	return 0;
@@ -130,6 +135,7 @@ int ehci_hcd_init(int index, enum usb_init_type init,
 		struct ehci_hccr **hccr, struct ehci_hcor **hcor)
 {
 	struct usb_ehci *ehci;
+	enum usb_init_type type;
 
 	if (index >= ARRAY_SIZE(nc_reg_bases))
 		return -EINVAL;
@@ -148,6 +154,10 @@ int ehci_hcd_init(int index, enum usb_init_type init,
 	*hcor = (struct ehci_hcor *)((uint32_t)*hccr +
 			HC_LENGTH(ehci_readl(&(*hccr)->cr_capbase)));
 
+	type = board_usb_phy_mode(index);
+	if (type != init)
+		return -ENODEV;
+
 	if (init == USB_INIT_DEVICE) {
 		setbits_le32(&ehci->usbmode, CM_DEVICE);
 		writel((PORT_PTS_UTMI | PORT_PTS_PTW), &ehci->portsc);
Signature · 1 line
2.6.2
#6 lore raw

PATCH 2/3 usb: host: ehci-vf: Implement board_usb_phy_mode weak function

Hello Stefano / Marek,

Can you pick this up?

- Sanchayan.

Quoted 65 lines · Sanchayan Maity

Add board_usb_phy_mode weak function on similar lines to ehci-mx6. However since Vybrid USB does not have a true OTG, make this weak functon just return 0. The function is supposed to be implemented by the individual boards using a GPIO for providing the OTG pin functionality.

---
There seems to be a problem here. As per DFU's help note, the first argument to dfu is the USB controller.

So if dfu 1 nand 2 is run, I would expect the ehci_hcd_init function's first index argument to recieve 1. However this does not seem to be the case. Not sure if I am understanding something wrongly here. Is this expected?

Currently because of this even though I did like dfu 1 nand 2 to bail out, it does not. I tried tracing the code from do_dfu but I have yet to get from where ehci_hcd_init is getting called in the call chain.

All seems to be well when using usb start.

---
 drivers/usb/host/ehci-vf.c | 10 ++++++++++
 1 file changed, 10 insertions(+)
drivers/usb/host/ehci-vf.c +10 -0
index 351e0fb..335e303 100644
@@ -121,6 +121,11 @@ static void usb_oc_config(int index)
 	setbits_le32(ctrl, UCTRL_OVER_CUR_DIS);
 }
 
+int __weak board_usb_phy_mode(int port)
+{
+	return 0;
+}
+
 int __weak board_ehci_hcd_init(int port)
 {
 	return 0;
@@ -130,6 +135,7 @@ int ehci_hcd_init(int index, enum usb_init_type init,
 		struct ehci_hccr **hccr, struct ehci_hcor **hcor)
 {
 	struct usb_ehci *ehci;
+	enum usb_init_type type;
 
 	if (index >= ARRAY_SIZE(nc_reg_bases))
 		return -EINVAL;
@@ -148,6 +154,10 @@ int ehci_hcd_init(int index, enum usb_init_type init,
 	*hcor = (struct ehci_hcor *)((uint32_t)*hccr +
 			HC_LENGTH(ehci_readl(&(*hccr)->cr_capbase)));
 
+	type = board_usb_phy_mode(index);
+	if (type != init)
+		return -ENODEV;
+
 	if (init == USB_INIT_DEVICE) {
 		setbits_le32(&ehci->usbmode, CM_DEVICE);
 		writel((PORT_PTS_UTMI | PORT_PTS_PTW), &ehci->portsc);
Signature · 1 line
2.6.2
Applied
#7 lore raw

PATCH 2/3 usb: host: ehci-vf: Implement board_usb_phy_mode weak function

Quoted 6 lines · maitysanchayan at gmail.com

Hello Stefano / Marek,

Can you pick this up?

- Sanchayan.

Applied.

Best regards,
Marek Vasut

#9 lore raw

PATCH 1/3 usb: host: ehci-vf: Remove hardcoded USB host client configuration

Hello,

Quoted 8 lines · Marek Vasut
Quoted 5 lines · Sanchayan Maity

The current ehci-vf USB driver for Vybrid hardcodes the USB host and client functionality. Remove this.

Is this a V2 or why did I receive this patchset twice ?

Yes sorry about that. I specified the uboot mailing list address wrong in my first patchset mail. Had to resend but then missed adding RESEND.

- Sanchayan.

Quoted 5 lines

Looks OK though.

Best regards,
Marek Vasut

#10 lore raw

PATCH 3/3 colibri_vf: Add board_usb_phy_mode function

In reply to Sanchayan Maity

Add board_usb_phy_mode function for detecting whether a port is being used as host or client using a GPIO. On Colibri Vybrid we provide the GPIO 102 for the very same purpose.

---
 board/toradex/colibri_vf/colibri_vf.c | 19 ++++++++++++++++++-
 1 file changed, 18 insertions(+), 1 deletion(-)
board/toradex/colibri_vf/colibri_vf.c +18 -1
index a6d1c5b..fd90ef2 100644
@@ -34,6 +34,7 @@ DECLARE_GLOBAL_DATA_PTR;
 			PAD_CTL_DSE_50ohm | PAD_CTL_OBE_IBE_ENABLE)
 
 #define USB_PEN_GPIO           83
+#define USB_CDET_GPIO			102
 
 static struct ddrmc_cr_setting colibri_vf_cr_settings[] = {
 	/* levelling */
@@ -92,6 +93,7 @@ static struct ddrmc_cr_setting colibri_vf_cr_settings[] = {
 
 static const iomux_v3_cfg_t usb_pads[] = {
 	VF610_PAD_PTD4__GPIO_83,
+	VF610_PAD_PTC29__GPIO_102,
 };
 
 int dram_init(void)
@@ -280,7 +282,6 @@ static void setup_iomux_gpio(void)
 		VF610_PAD_PTB23__GPIO_93,
 		VF610_PAD_PTB26__GPIO_96,
 		VF610_PAD_PTB28__GPIO_98,
-		VF610_PAD_PTC29__GPIO_102,
 		VF610_PAD_PTC30__GPIO_103,
 		VF610_PAD_PTA7__GPIO_134,
 	};
@@ -554,4 +555,20 @@ int board_ehci_hcd_init(int port)
 	}
 	return 0;
 }
+
+int board_usb_phy_mode(int port)
+{
+	switch (port) {
+	case 0:
+		gpio_request(USB_CDET_GPIO, "usb-cdet-gpio");
+		return gpio_get_value(USB_CDET_GPIO);
+		break;
+	case 1:
+		return 0;
+		break;
+	default:
+		return 0;
+		break;
+	}
+}
 #endif
Signature · 1 line
2.6.2
#11 lore raw

PATCH 3/3 colibri_vf: Add board_usb_phy_mode function

Quoted 39 lines · Sanchayan Maity

Add board_usb_phy_mode function for detecting whether a port is being used as host or client using a GPIO. On Colibri Vybrid we provide the GPIO 102 for the very same purpose.

---
 board/toradex/colibri_vf/colibri_vf.c | 19 ++++++++++++++++++-
 1 file changed, 18 insertions(+), 1 deletion(-)
(quoted diff) +0 -0

b/board/toradex/colibri_vf/colibri_vf.c index a6d1c5b..fd90ef2 100644

board/toradex/colibri_vf/colibri_vf.c +2 -0
@@ -34,6 +34,7 @@ DECLARE_GLOBAL_DATA_PTR;
 			PAD_CTL_DSE_50ohm | PAD_CTL_OBE_IBE_ENABLE)
 
 #define USB_PEN_GPIO           83
+#define USB_CDET_GPIO			102
 
 static struct ddrmc_cr_setting colibri_vf_cr_settings[] = {
 	/* levelling */
@@ -92,6 +93,7 @@ static struct ddrmc_cr_setting colibri_vf_cr_settings[] =
 {
 
 static const iomux_v3_cfg_t usb_pads[] = {
 	VF610_PAD_PTD4__GPIO_83,
+	VF610_PAD_PTC29__GPIO_102,
 };
 

int dram_init(void)

board/toradex/colibri_vf/colibri_vf.c +0 -1
@@ -280,7 +282,6 @@ static void setup_iomux_gpio(void)
 		VF610_PAD_PTB23__GPIO_93,
 		VF610_PAD_PTB26__GPIO_96,
 		VF610_PAD_PTB28__GPIO_98,
-		VF610_PAD_PTC29__GPIO_102,
 		VF610_PAD_PTC30__GPIO_103,
 		VF610_PAD_PTA7__GPIO_134,
 	};

board/toradex/colibri_vf/colibri_vf.c int board_ehci_hcd_init(int port) · line 563

Quoted 9 lines
board/toradex/colibri_vf/colibri_vf.c +6 -0
@@ -554,4 +555,20 @@ int board_ehci_hcd_init(int port)
 	}
 	return 0;
 }
+
+int board_usb_phy_mode(int port)
+{
+	switch (port) {
+	case 0:
+		gpio_request(USB_CDET_GPIO, "usb-cdet-gpio");

The gpio_request() here will fail the second time you do "usb reset" on the command line I think. You might want to request this elsewhere.

board/toradex/colibri_vf/colibri_vf.c int board_ehci_hcd_init(int port) · line 574

Quoted 11 lines
board/toradex/colibri_vf/colibri_vf.c +10 -0
+		return gpio_get_value(USB_CDET_GPIO);
+		break;
+	case 1:
+		return 0;
+		break;
+	default:
+		return 0;
+		break;
+	}
+}
 #endif

Best regards,
Marek Vasut

#12 lore raw

PATCH 3/3 colibri_vf: Add board_usb_phy_mode function

Quoted 44 lines · Marek Vasut
Quoted 43 lines · Sanchayan Maity

Add board_usb_phy_mode function for detecting whether a port is being used as host or client using a GPIO. On Colibri Vybrid we provide the GPIO 102 for the very same purpose.

---
 board/toradex/colibri_vf/colibri_vf.c | 19 ++++++++++++++++++-
 1 file changed, 18 insertions(+), 1 deletion(-)
(quoted diff) +0 -0

b/board/toradex/colibri_vf/colibri_vf.c index a6d1c5b..fd90ef2 100644

board/toradex/colibri_vf/colibri_vf.c +2 -0
@@ -34,6 +34,7 @@ DECLARE_GLOBAL_DATA_PTR;
 			PAD_CTL_DSE_50ohm | PAD_CTL_OBE_IBE_ENABLE)
 
 #define USB_PEN_GPIO           83
+#define USB_CDET_GPIO			102
 
 static struct ddrmc_cr_setting colibri_vf_cr_settings[] = {
 	/* levelling */
@@ -92,6 +93,7 @@ static struct ddrmc_cr_setting colibri_vf_cr_settings[] =
 {
 
 static const iomux_v3_cfg_t usb_pads[] = {
 	VF610_PAD_PTD4__GPIO_83,
+	VF610_PAD_PTC29__GPIO_102,
 };
 

int dram_init(void)

board/toradex/colibri_vf/colibri_vf.c +1 -1
@@ -280,7 +282,6 @@ static void setup_iomux_gpio(void)
 		VF610_PAD_PTB23__GPIO_93,
 		VF610_PAD_PTB26__GPIO_96,
 		VF610_PAD_PTB28__GPIO_98,
-		VF610_PAD_PTC29__GPIO_102,
 		VF610_PAD_PTC30__GPIO_103,
 		VF610_PAD_PTA7__GPIO_134,
 	};
@@ -554,4 +555,20 @@ int board_ehci_hcd_init(int port)
 	}
 	return 0;
 }
+
Quoted 8 lines

board/toradex/colibri_vf/colibri_vf.c int board_ehci_hcd_init(int port) · line 563

Quoted 5 lines
board/toradex/colibri_vf/colibri_vf.c +5 -0
+int board_usb_phy_mode(int port)
+{
+	switch (port) {
+	case 0:
+		gpio_request(USB_CDET_GPIO, "usb-cdet-gpio");

The gpio_request() here will fail the second time you do "usb reset" on the command line I think. You might want to request this elsewhere.

Hmmm makes sense. I did not try usb reset. Only usb start stop and dfu cmds. Will check and revert back accordingly.

Thanks.

- Sanchayan.

Quoted 15 lines

board/toradex/colibri_vf/colibri_vf.c int board_ehci_hcd_init(int port) · line 574

Quoted 12 lines
board/toradex/colibri_vf/colibri_vf.c +10 -0
+		return gpio_get_value(USB_CDET_GPIO);
+		break;
+	case 1:
+		return 0;
+		break;
+	default:
+		return 0;
+		break;
+	}
+}
 #endif

Best regards,
Marek Vasut

#13 lore raw

PATCH v2 1/1 colibri_vf: Add board_usb_phy_mode function

In reply to Sanchayan Maity

Add board_usb_phy_mode function for detecting whether a port is being used as host or client using a GPIO. On Colibri Vybrid we provide the GPIO 102 for this very same purpose.

---
Changes since v1:

Move the GPIO request call to the board_init function as all further calls to board_usb_phy_mode will actually result in the gpio_request failing.

---
 board/toradex/colibri_vf/colibri_vf.c | 22 +++++++++++++++++++++-
 1 file changed, 21 insertions(+), 1 deletion(-)
board/toradex/colibri_vf/colibri_vf.c +21 -1
index a6d1c5b..69274e5 100644
@@ -34,6 +34,7 @@ DECLARE_GLOBAL_DATA_PTR;
 			PAD_CTL_DSE_50ohm | PAD_CTL_OBE_IBE_ENABLE)
 
 #define USB_PEN_GPIO           83
+#define USB_CDET_GPIO			102
 
 static struct ddrmc_cr_setting colibri_vf_cr_settings[] = {
 	/* levelling */
@@ -92,6 +93,7 @@ static struct ddrmc_cr_setting colibri_vf_cr_settings[] = {
 
 static const iomux_v3_cfg_t usb_pads[] = {
 	VF610_PAD_PTD4__GPIO_83,
+	VF610_PAD_PTC29__GPIO_102,
 };
 
 int dram_init(void)
@@ -280,7 +282,6 @@ static void setup_iomux_gpio(void)
 		VF610_PAD_PTB23__GPIO_93,
 		VF610_PAD_PTB26__GPIO_96,
 		VF610_PAD_PTB28__GPIO_98,
-		VF610_PAD_PTC29__GPIO_102,
 		VF610_PAD_PTC30__GPIO_103,
 		VF610_PAD_PTA7__GPIO_134,
 	};
@@ -509,6 +510,10 @@ int board_init(void)
 
 	setbits_le32(&scsc->sosc_ctr, SCSC_SOSC_CTR_SOSC_EN);
 
+#ifdef CONFIG_USB_EHCI_VF
+	gpio_request(USB_CDET_GPIO, "usb-cdet-gpio");
+#endif
+
 	return 0;
 }
 
@@ -554,4 +559,19 @@ int board_ehci_hcd_init(int port)
 	}
 	return 0;
 }
+
+int board_usb_phy_mode(int port)
+{
+	switch (port) {
+	case 0:
+		return gpio_get_value(USB_CDET_GPIO);
+		break;
+	case 1:
+		return 0;
+		break;
+	default:
+		return 0;
+		break;
+	}
+}
 #endif
Signature · 1 line
2.6.2
#14 lore raw

PATCH v2 1/1 colibri_vf: Add board_usb_phy_mode function

Quoted 5 lines · Sanchayan Maity

Add board_usb_phy_mode function for detecting whether a port is being used as host or client using a GPIO. On Colibri Vybrid we provide the GPIO 102 for this very same purpose.

Hi!

[...]

board/toradex/colibri_vf/colibri_vf.c int board_ehci_hcd_init(int port) · line 570

Quoted 13 lines
board/toradex/colibri_vf/colibri_vf.c +9 -0
@@ -554,4 +559,19 @@ int board_ehci_hcd_init(int port)
 	}
 	return 0;
 }
+
+int board_usb_phy_mode(int port)
+{
+	switch (port) {
+	case 0:
+		return gpio_get_value(USB_CDET_GPIO);
+		break;
+	case 1:
+		return 0;

This should return USB_INIT_DEVICE or USB_INIT_HOST .

board/toradex/colibri_vf/colibri_vf.c int board_ehci_hcd_init(int port) · line 577

Quoted 7 lines
board/toradex/colibri_vf/colibri_vf.c +6 -0
+		break;
+	default:
+		return 0;
+		break;
+	}
+}
 #endif

Best regards,
Marek Vasut

#15 lore raw

PATCH v3 1/1 colibri_vf: Add board_usb_phy_mode function

In reply to Sanchayan Maity

Add board_usb_phy_mode function for detecting whether a port is being used as host or client using a GPIO. On Colibri Vybrid we provide the GPIO 102 for this very same purpose.

---
Changes since v1:

Move the GPIO request call to the board_init function as all further calls to board_usb_phy_mode will actually result in the gpio_request failing.

Changes since v2:

Instead of returning 0 from board_usb_phy_mode return it as USB_INIT_HOST.

---
 board/toradex/colibri_vf/colibri_vf.c | 23 ++++++++++++++++++++++-
 1 file changed, 22 insertions(+), 1 deletion(-)
board/toradex/colibri_vf/colibri_vf.c +22 -1
index a6d1c5b..9878671 100644
@@ -21,6 +21,7 @@
 #include <i2c.h>
 #include <g_dnl.h>
 #include <asm/gpio.h>
+#include <usb.h>
 
 DECLARE_GLOBAL_DATA_PTR;
 
@@ -34,6 +35,7 @@ DECLARE_GLOBAL_DATA_PTR;
 			PAD_CTL_DSE_50ohm | PAD_CTL_OBE_IBE_ENABLE)
 
 #define USB_PEN_GPIO           83
+#define USB_CDET_GPIO			102
 
 static struct ddrmc_cr_setting colibri_vf_cr_settings[] = {
 	/* levelling */
@@ -92,6 +94,7 @@ static struct ddrmc_cr_setting colibri_vf_cr_settings[] = {
 
 static const iomux_v3_cfg_t usb_pads[] = {
 	VF610_PAD_PTD4__GPIO_83,
+	VF610_PAD_PTC29__GPIO_102,
 };
 
 int dram_init(void)
@@ -280,7 +283,6 @@ static void setup_iomux_gpio(void)
 		VF610_PAD_PTB23__GPIO_93,
 		VF610_PAD_PTB26__GPIO_96,
 		VF610_PAD_PTB28__GPIO_98,
-		VF610_PAD_PTC29__GPIO_102,
 		VF610_PAD_PTC30__GPIO_103,
 		VF610_PAD_PTA7__GPIO_134,
 	};
@@ -509,6 +511,10 @@ int board_init(void)
 
 	setbits_le32(&scsc->sosc_ctr, SCSC_SOSC_CTR_SOSC_EN);
 
+#ifdef CONFIG_USB_EHCI_VF
+	gpio_request(USB_CDET_GPIO, "usb-cdet-gpio");
+#endif
+
 	return 0;
 }
 
@@ -554,4 +560,19 @@ int board_ehci_hcd_init(int port)
 	}
 	return 0;
 }
+
+int board_usb_phy_mode(int port)
+{
+	switch (port) {
+	case 0:
+		return gpio_get_value(USB_CDET_GPIO);
+		break;
+	case 1:
+		return USB_INIT_HOST;
+		break;
+	default:
+		return USB_INIT_HOST;
+		break;
+	}
+}
 #endif
Signature · 1 line
2.6.2
#16 lore raw

PATCH v3 1/1 colibri_vf: Add board_usb_phy_mode function

Quoted 69 lines · Sanchayan Maity

Add board_usb_phy_mode function for detecting whether a port is being used as host or client using a GPIO. On Colibri Vybrid we provide the GPIO 102 for this very same purpose.

---
Changes since v1:

Move the GPIO request call to the board_init function as all further calls to board_usb_phy_mode will actually result in the gpio_request failing.

Changes since v2:

Instead of returning 0 from board_usb_phy_mode return it as USB_INIT_HOST.

---
 board/toradex/colibri_vf/colibri_vf.c | 23 ++++++++++++++++++++++-
 1 file changed, 22 insertions(+), 1 deletion(-)
(quoted diff) +0 -0

b/board/toradex/colibri_vf/colibri_vf.c index a6d1c5b..9878671 100644

board/toradex/colibri_vf/colibri_vf.c +3 -0
@@ -21,6 +21,7 @@
 #include <i2c.h>
 #include <g_dnl.h>
 #include <asm/gpio.h>
+#include <usb.h>
 
 DECLARE_GLOBAL_DATA_PTR;
 
@@ -34,6 +35,7 @@ DECLARE_GLOBAL_DATA_PTR;
 			PAD_CTL_DSE_50ohm | PAD_CTL_OBE_IBE_ENABLE)
 
 #define USB_PEN_GPIO           83
+#define USB_CDET_GPIO			102
 
 static struct ddrmc_cr_setting colibri_vf_cr_settings[] = {
 	/* levelling */
@@ -92,6 +94,7 @@ static struct ddrmc_cr_setting colibri_vf_cr_settings[] =
 {
 
 static const iomux_v3_cfg_t usb_pads[] = {
 	VF610_PAD_PTD4__GPIO_83,
+	VF610_PAD_PTC29__GPIO_102,
 };
 

int dram_init(void)

board/toradex/colibri_vf/colibri_vf.c +4 -1
@@ -280,7 +283,6 @@ static void setup_iomux_gpio(void)
 		VF610_PAD_PTB23__GPIO_93,
 		VF610_PAD_PTB26__GPIO_96,
 		VF610_PAD_PTB28__GPIO_98,
-		VF610_PAD_PTC29__GPIO_102,
 		VF610_PAD_PTC30__GPIO_103,
 		VF610_PAD_PTA7__GPIO_134,
 	};
@@ -509,6 +511,10 @@ int board_init(void)
 
 	setbits_le32(&scsc->sosc_ctr, SCSC_SOSC_CTR_SOSC_EN);
 
+#ifdef CONFIG_USB_EHCI_VF
+	gpio_request(USB_CDET_GPIO, "usb-cdet-gpio");
+#endif
+
 	return 0;
 }
 

board/toradex/colibri_vf/colibri_vf.c int board_ehci_hcd_init(int port) · line 568

Quoted 9 lines
board/toradex/colibri_vf/colibri_vf.c +6 -0
@@ -554,4 +560,19 @@ int board_ehci_hcd_init(int port)
 	}
 	return 0;
 }
+
+int board_usb_phy_mode(int port)
+{
+	switch (port) {
+	case 0:
+		return gpio_get_value(USB_CDET_GPIO);

So what would happen to this code in case we re-number the USB_INIT_HOST and USB_INIT_DEVICE or in case the GPIO API starts returning something else but 0 or 1 here ?

Quoted 10 lines
board/toradex/colibri_vf/colibri_vf.c +9 -0
+		break;
+	case 1:
+		return USB_INIT_HOST;
+		break;
+	default:
+		return USB_INIT_HOST;
+		break;
+	}
+}
 #endif
#17 lore raw

PATCH v3 1/1 colibri_vf: Add board_usb_phy_mode function

Quoted 69 lines · Marek Vasut
Quoted 68 lines · Sanchayan Maity

Add board_usb_phy_mode function for detecting whether a port is being used as host or client using a GPIO. On Colibri Vybrid we provide the GPIO 102 for this very same purpose.

---
Changes since v1:

Move the GPIO request call to the board_init function as all further calls to board_usb_phy_mode will actually result in the gpio_request failing.

Changes since v2:

Instead of returning 0 from board_usb_phy_mode return it as USB_INIT_HOST.

---
 board/toradex/colibri_vf/colibri_vf.c | 23 ++++++++++++++++++++++-
 1 file changed, 22 insertions(+), 1 deletion(-)
(quoted diff) +0 -0

b/board/toradex/colibri_vf/colibri_vf.c index a6d1c5b..9878671 100644

board/toradex/colibri_vf/colibri_vf.c +3 -0
@@ -21,6 +21,7 @@
 #include <i2c.h>
 #include <g_dnl.h>
 #include <asm/gpio.h>
+#include <usb.h>
 
 DECLARE_GLOBAL_DATA_PTR;
 
@@ -34,6 +35,7 @@ DECLARE_GLOBAL_DATA_PTR;
 			PAD_CTL_DSE_50ohm | PAD_CTL_OBE_IBE_ENABLE)
 
 #define USB_PEN_GPIO           83
+#define USB_CDET_GPIO			102
 
 static struct ddrmc_cr_setting colibri_vf_cr_settings[] = {
 	/* levelling */
@@ -92,6 +94,7 @@ static struct ddrmc_cr_setting colibri_vf_cr_settings[] =
 {
 
 static const iomux_v3_cfg_t usb_pads[] = {
 	VF610_PAD_PTD4__GPIO_83,
+	VF610_PAD_PTC29__GPIO_102,
 };
 

int dram_init(void)

board/toradex/colibri_vf/colibri_vf.c +4 -1
@@ -280,7 +283,6 @@ static void setup_iomux_gpio(void)
 		VF610_PAD_PTB23__GPIO_93,
 		VF610_PAD_PTB26__GPIO_96,
 		VF610_PAD_PTB28__GPIO_98,
-		VF610_PAD_PTC29__GPIO_102,
 		VF610_PAD_PTC30__GPIO_103,
 		VF610_PAD_PTA7__GPIO_134,
 	};
@@ -509,6 +511,10 @@ int board_init(void)
 
 	setbits_le32(&scsc->sosc_ctr, SCSC_SOSC_CTR_SOSC_EN);
 
+#ifdef CONFIG_USB_EHCI_VF
+	gpio_request(USB_CDET_GPIO, "usb-cdet-gpio");
+#endif
+
 	return 0;
 }
 
Quoted 14 lines

board/toradex/colibri_vf/colibri_vf.c int board_ehci_hcd_init(int port) · line 568

Quoted 10 lines
board/toradex/colibri_vf/colibri_vf.c +6 -0
@@ -554,4 +560,19 @@ int board_ehci_hcd_init(int port)
 	}
 	return 0;
 }
+
+int board_usb_phy_mode(int port)
+{
+	switch (port) {
+	case 0:
+		return gpio_get_value(USB_CDET_GPIO);

So what would happen to this code in case we re-number the USB_INIT_HOST and USB_INIT_DEVICE or in case the GPIO API starts returning something else but 0 or 1 here ?

Sorry for the delay in reply. Had got tied up elsewhere.

Currently USB_INIT_HOST and USB_INIT_DEVICE are defined with an enum. If we were to switch this would not work as I intended. I guess this would be more appropriate then

if (gpio_get_value(USB_CDET_GPIO))

	return USB_INIT_DEVICE;
else
	return USB_INIT_HOST;

For the GPIO, isn't gpio_get_value always suppose to return the actual state of GPIO? Would we ever change the GPIO API to report otherwise?

Concerning the other thread from Stefan's query I will add the comments.

Thanks.

- Sanchayan.

Quoted 11 lines
Quoted 11 lines
board/toradex/colibri_vf/colibri_vf.c +9 -0
+		break;
+	case 1:
+		return USB_INIT_HOST;
+		break;
+	default:
+		return USB_INIT_HOST;
+		break;
+	}
+}
 #endif
#18 lore raw

PATCH v3 1/1 colibri_vf: Add board_usb_phy_mode function

Quoted 106 lines · maitysanchayan at gmail.com
Quoted 94 lines · Marek Vasut
Quoted 93 lines · Sanchayan Maity

Add board_usb_phy_mode function for detecting whether a port is being used as host or client using a GPIO. On Colibri Vybrid we provide the GPIO 102 for this very same purpose.

---
Changes since v1:

Move the GPIO request call to the board_init function as all further calls to board_usb_phy_mode will actually result in the gpio_request failing.

Changes since v2:

Instead of returning 0 from board_usb_phy_mode return it as USB_INIT_HOST.
---

 board/toradex/colibri_vf/colibri_vf.c | 23 ++++++++++++++++++++++-
 1 file changed, 22 insertions(+), 1 deletion(-)
(quoted diff) +0 -0

b/board/toradex/colibri_vf/colibri_vf.c index a6d1c5b..9878671 100644

board/toradex/colibri_vf/colibri_vf.c +1 -0
@@ -21,6 +21,7 @@
 
 #include <i2c.h>
 #include <g_dnl.h>
 #include <asm/gpio.h>
 
+#include <usb.h>
 

DECLARE_GLOBAL_DATA_PTR;

board/toradex/colibri_vf/colibri_vf.c +1 -0
@@ -34,6 +35,7 @@ DECLARE_GLOBAL_DATA_PTR;
 
 			PAD_CTL_DSE_50ohm | PAD_CTL_OBE_IBE_ENABLE)
 
 #define USB_PEN_GPIO           83
 
+#define USB_CDET_GPIO			102
 

static struct ddrmc_cr_setting colibri_vf_cr_settings[] = {

board/toradex/colibri_vf/colibri_vf.c +1 -0
 	/* levelling */
@@ -92,6 +94,7 @@ static struct ddrmc_cr_setting
 colibri_vf_cr_settings[] = {
 
 static const iomux_v3_cfg_t usb_pads[] = {
 
 	VF610_PAD_PTD4__GPIO_83,
 
+	VF610_PAD_PTC29__GPIO_102,

};

int dram_init(void)

board/toradex/colibri_vf/colibri_vf.c +0 -1
@@ -280,7 +283,6 @@ static void setup_iomux_gpio(void)
 
 		VF610_PAD_PTB23__GPIO_93,
 		VF610_PAD_PTB26__GPIO_96,
 		VF610_PAD_PTB28__GPIO_98,
 
-		VF610_PAD_PTC29__GPIO_102,
 
board/toradex/colibri_vf/colibri_vf.c +4 -0
 		VF610_PAD_PTC30__GPIO_103,
 		VF610_PAD_PTA7__GPIO_134,
 
 	};
@@ -509,6 +511,10 @@ int board_init(void)
 
 	setbits_le32(&scsc->sosc_ctr, SCSC_SOSC_CTR_SOSC_EN);
 
+#ifdef CONFIG_USB_EHCI_VF
+	gpio_request(USB_CDET_GPIO, "usb-cdet-gpio");
+#endif
+
 
 	return 0;
 

}

board/toradex/colibri_vf/colibri_vf.c +0 -0
@@ -554,4 +560,19 @@ int board_ehci_hcd_init(int port)
 
 	}
 	return 0;
 
 }
Quoted 10 lines

board/toradex/colibri_vf/colibri_vf.c int board_ehci_hcd_init(int port) · line 568

Quoted 6 lines
board/toradex/colibri_vf/colibri_vf.c +6 -0
+
+int board_usb_phy_mode(int port)
+{
+	switch (port) {
+	case 0:
+		return gpio_get_value(USB_CDET_GPIO);

So what would happen to this code in case we re-number the USB_INIT_HOST and USB_INIT_DEVICE or in case the GPIO API starts returning something else but 0 or 1 here ?

Quoted 1 line

Sorry for the delay in reply. Had got tied up elsewhere.

Yeah, no problem, I can relate to that.

Quoted 8 lines

Currently USB_INIT_HOST and USB_INIT_DEVICE are defined with an enum. If we were to switch this would not work as I intended. I guess this would be more appropriate then

if (gpio_get_value(USB_CDET_GPIO))

	return USB_INIT_DEVICE;
else
	return USB_INIT_HOST;

Yeah.

Quoted 2 lines

For the GPIO, isn't gpio_get_value always suppose to return the actual state of GPIO? Would we ever change the GPIO API to report otherwise?

It will report 0 for GPIO inactive and non-zero for GPIO active, that's the behavior of it.

Quoted 1 line

Concerning the other thread from Stefan's query I will add the comments.

Thanks!

#19 lore raw

PATCH v3 1/1 colibri_vf: Add board_usb_phy_mode function

In reply to Sanchayan Maity

Hi All,

board/toradex/colibri_vf/colibri_vf.c int board_ehci_hcd_init(int port) · line 575

Quoted 13 lines · Sanchayan Maity
board/toradex/colibri_vf/colibri_vf.c +13 -0
+
+int board_usb_phy_mode(int port)
+{
+	switch (port) {
+	case 0:
+		return gpio_get_value(USB_CDET_GPIO);
+		break;
+	case 1:
+		return USB_INIT_HOST;
+		break;
+	default:
+		return USB_INIT_HOST;
+		break;

One thing I would like to note in this whole discussion is that the old setup is kind of the "default" role of each dual-role controller: The boot ROM uses USB1 as client, the tower board uses this configuration too... So maybe we could/should keep that default role at least in here?

--
Stefan

#20 lore raw

PATCH v3 1/1 colibri_vf: Add board_usb_phy_mode function

Quoted 1 line · Stefan Agner

Hi All,

Hi!

Quoted 11 lines · Sanchayan Maity
Quoted 10 lines
board/toradex/colibri_vf/colibri_vf.c +10 -0
+
+int board_usb_phy_mode(int port)
+{
+	switch (port) {
+	case 0:
+		return gpio_get_value(USB_CDET_GPIO);
+		break;
+	case 1:
+		return USB_INIT_HOST;
+		break;
Quoted 8 lines

board/toradex/colibri_vf/colibri_vf.c int board_ehci_hcd_init(int port) · line 575

Quoted 3 lines
board/toradex/colibri_vf/colibri_vf.c +3 -0
+	default:
+		return USB_INIT_HOST;
+		break;

One thing I would like to note in this whole discussion is that the old setup is kind of the "default" role of each dual-role controller: The boot ROM uses USB1 as client, the tower board uses this configuration too... So maybe we could/should keep that default role at least in here?

Well we cannot, since this is a custom board, right ?

Best regards,
Marek Vasut

#21 lore raw

PATCH v3 1/1 colibri_vf: Add board_usb_phy_mode function

Quoted 25 lines · Marek Vasut
Quoted 1 line · Stefan Agner

Hi All,

Hi!

Quoted 11 lines · Sanchayan Maity
Quoted 10 lines
board/toradex/colibri_vf/colibri_vf.c +10 -0
+
+int board_usb_phy_mode(int port)
+{
+	switch (port) {
+	case 0:
+		return gpio_get_value(USB_CDET_GPIO);
+		break;
+	case 1:
+		return USB_INIT_HOST;
+		break;
Quoted 8 lines

board/toradex/colibri_vf/colibri_vf.c int board_ehci_hcd_init(int port) · line 575

Quoted 3 lines
board/toradex/colibri_vf/colibri_vf.c +3 -0
+	default:
+		return USB_INIT_HOST;
+		break;

One thing I would like to note in this whole discussion is that the old setup is kind of the "default" role of each dual-role controller: The boot ROM uses USB1 as client, the tower board uses this configuration too... So maybe we could/should keep that default role at least in here?

Quoted 1 line

Well we cannot, since this is a custom board, right ?

Ah sorry, the switch statement is enumerating the port numbers, hence this default refers to ports > 2. Somehow read that the wrong way around.

Sorry for the noise.

--
Stefan

#22 lore raw

PATCH v3 1/1 colibri_vf: Add board_usb_phy_mode function

Quoted 26 lines · Stefan Agner
Quoted 25 lines · Marek Vasut
Quoted 1 line · Stefan Agner

Hi All,

Hi!

Quoted 19 lines · Sanchayan Maity

board/toradex/colibri_vf/colibri_vf.c int board_ehci_hcd_init(int port) · line 575

Quoted 13 lines
board/toradex/colibri_vf/colibri_vf.c +13 -0
+
+int board_usb_phy_mode(int port)
+{
+	switch (port) {
+	case 0:
+		return gpio_get_value(USB_CDET_GPIO);
+		break;
+	case 1:
+		return USB_INIT_HOST;
+		break;
+	default:
+		return USB_INIT_HOST;
+		break;

One thing I would like to note in this whole discussion is that the old setup is kind of the "default" role of each dual-role controller: The boot ROM uses USB1 as client, the tower board uses this configuration too... So maybe we could/should keep that default role at least in here?

Quoted 5 lines
Quoted 1 line

Well we cannot, since this is a custom board, right ?

Ah sorry, the switch statement is enumerating the port numbers, hence this default refers to ports > 2. Somehow read that the wrong way around.

Well, if it is not obvious to you, comment in the code is a good idea. Sanchayan, please add one.

Best regards,
Marek Vasut

#23 lore raw

PATCH v4 1/1 colibri_vf: Add board_usb_phy_mode function

In reply to Sanchayan Maity

Add board_usb_phy_mode function for detecting whether a port is being used as host or client using a GPIO. On Colibri Vybrid we provide GPIO 102 for this very same purpose.

---
Changes since v3:
Return USB_INIT_DEVICE or USB_INIT_HOST after checking for the GPIO state to account for the fact that the previous logic breaks in case if the enum for USB mode were to ever be changed.

Add comments based on Stefan's feedback.

Changes since v2:

Instead of returning 0 from board_usb_phy_mode return it as USB_INIT_HOST.

Changes since v1:

Move the GPIO request call to the board_init function as all further calls to board_usb_phy_mode will actually result in the gpio_request failing.

---
 board/toradex/colibri_vf/colibri_vf.c | 36 ++++++++++++++++++++++++++++++++++-
 1 file changed, 35 insertions(+), 1 deletion(-)
board/toradex/colibri_vf/colibri_vf.c +35 -1
index a6d1c5b..b1a3375 100644
@@ -21,6 +21,7 @@
 #include <i2c.h>
 #include <g_dnl.h>
 #include <asm/gpio.h>
+#include <usb.h>
 
 DECLARE_GLOBAL_DATA_PTR;
 
@@ -34,6 +35,7 @@ DECLARE_GLOBAL_DATA_PTR;
 			PAD_CTL_DSE_50ohm | PAD_CTL_OBE_IBE_ENABLE)
 
 #define USB_PEN_GPIO           83
+#define USB_CDET_GPIO		102
 
 static struct ddrmc_cr_setting colibri_vf_cr_settings[] = {
 	/* levelling */
@@ -92,6 +94,7 @@ static struct ddrmc_cr_setting colibri_vf_cr_settings[] = {
 
 static const iomux_v3_cfg_t usb_pads[] = {
 	VF610_PAD_PTD4__GPIO_83,
+	VF610_PAD_PTC29__GPIO_102,
 };
 
 int dram_init(void)
@@ -280,7 +283,6 @@ static void setup_iomux_gpio(void)
 		VF610_PAD_PTB23__GPIO_93,
 		VF610_PAD_PTB26__GPIO_96,
 		VF610_PAD_PTB28__GPIO_98,
-		VF610_PAD_PTC29__GPIO_102,
 		VF610_PAD_PTC30__GPIO_103,
 		VF610_PAD_PTA7__GPIO_134,
 	};
@@ -509,6 +511,10 @@ int board_init(void)
 
 	setbits_le32(&scsc->sosc_ctr, SCSC_SOSC_CTR_SOSC_EN);
 
+#ifdef CONFIG_USB_EHCI_VF
+	gpio_request(USB_CDET_GPIO, "usb-cdet-gpio");
+#endif
+
 	return 0;
 }
 
@@ -554,4 +560,32 @@ int board_ehci_hcd_init(int port)
 	}
 	return 0;
 }
+
+int board_usb_phy_mode(int port)
+{
+	switch (port) {
+	case 0:
+		/*
+		 * Port 0 is used only in client mode on Colibri Vybrid modules
+		 * Check for state of USB client gpio pin and accordingly return
+		 * USB_INIT_DEVICE or USB_INIT_HOST.
+		 */
+		if (gpio_get_value(USB_CDET_GPIO))
+			return USB_INIT_DEVICE;
+		else
+			return USB_INIT_HOST;
+		break;
+	case 1:
+		/* Port 1 is used only in host mode on Colibri Vybrid modules */
+		return USB_INIT_HOST;
+		break;
+	default:
+		/*
+		 * There are only two USB controllers on Vybrid. Ideally we will
+		 * not reach here. However return USB_INIT_HOST if we do.
+		 */
+		return USB_INIT_HOST;
+		break;
+	}
+}
 #endif
Signature · 1 line
2.6.2
#24 lore raw

PATCH v4 1/1 colibri_vf: Add board_usb_phy_mode function

Quoted 86 lines · Sanchayan Maity

Add board_usb_phy_mode function for detecting whether a port is being used as host or client using a GPIO. On Colibri Vybrid we provide GPIO 102 for this very same purpose.

---
Changes since v3:
Return USB_INIT_DEVICE or USB_INIT_HOST after checking for the GPIO state to account for the fact that the previous logic breaks in case if the enum for USB mode were to ever be changed.

Add comments based on Stefan's feedback.

Changes since v2:

Instead of returning 0 from board_usb_phy_mode return it as USB_INIT_HOST.

Changes since v1:

Move the GPIO request call to the board_init function as all further calls to board_usb_phy_mode will actually result in the gpio_request failing.

---
 board/toradex/colibri_vf/colibri_vf.c | 36

++++++++++++++++++++++++++++++++++- 1 file changed, 35 insertions(+), 1 deletion(-)

(quoted diff) +0 -0

b/board/toradex/colibri_vf/colibri_vf.c index a6d1c5b..b1a3375 100644

board/toradex/colibri_vf/colibri_vf.c +3 -0
@@ -21,6 +21,7 @@
 #include <i2c.h>
 #include <g_dnl.h>
 #include <asm/gpio.h>
+#include <usb.h>
 
 DECLARE_GLOBAL_DATA_PTR;
 
@@ -34,6 +35,7 @@ DECLARE_GLOBAL_DATA_PTR;
 			PAD_CTL_DSE_50ohm | PAD_CTL_OBE_IBE_ENABLE)
 
 #define USB_PEN_GPIO           83
+#define USB_CDET_GPIO		102
 
 static struct ddrmc_cr_setting colibri_vf_cr_settings[] = {
 	/* levelling */
@@ -92,6 +94,7 @@ static struct ddrmc_cr_setting colibri_vf_cr_settings[] =
 {
 
 static const iomux_v3_cfg_t usb_pads[] = {
 	VF610_PAD_PTD4__GPIO_83,
+	VF610_PAD_PTC29__GPIO_102,
 };
 

int dram_init(void)

board/toradex/colibri_vf/colibri_vf.c +9 -1
@@ -280,7 +283,6 @@ static void setup_iomux_gpio(void)
 		VF610_PAD_PTB23__GPIO_93,
 		VF610_PAD_PTB26__GPIO_96,
 		VF610_PAD_PTB28__GPIO_98,
-		VF610_PAD_PTC29__GPIO_102,
 		VF610_PAD_PTC30__GPIO_103,
 		VF610_PAD_PTA7__GPIO_134,
 	};
@@ -509,6 +511,10 @@ int board_init(void)
 
 	setbits_le32(&scsc->sosc_ctr, SCSC_SOSC_CTR_SOSC_EN);
 
+#ifdef CONFIG_USB_EHCI_VF
+	gpio_request(USB_CDET_GPIO, "usb-cdet-gpio");
+#endif
+
 	return 0;
 }
 
@@ -554,4 +560,32 @@ int board_ehci_hcd_init(int port)
 	}
 	return 0;
 }
+
+int board_usb_phy_mode(int port)
+{
+	switch (port) {
+	case 0:

board/toradex/colibri_vf/colibri_vf.c int board_ehci_hcd_init(int port) · line 577

Quoted 10 lines
board/toradex/colibri_vf/colibri_vf.c +10 -0
+		/*
+		 * Port 0 is used only in client mode on Colibri Vybrid modules
+		 * Check for state of USB client gpio pin and accordingly return
+		 * USB_INIT_DEVICE or USB_INIT_HOST.
+		 */
+		if (gpio_get_value(USB_CDET_GPIO))
+			return USB_INIT_DEVICE;
+		else
+			return USB_INIT_HOST;
+		break;

You don't have to break after return.

board/toradex/colibri_vf/colibri_vf.c int board_ehci_hcd_init(int port) · line 581

Quoted 4 lines
board/toradex/colibri_vf/colibri_vf.c +4 -0
+	case 1:
+		/* Port 1 is used only in host mode on Colibri Vybrid modules */
+		return USB_INIT_HOST;
+		break;

DTTO

board/toradex/colibri_vf/colibri_vf.c int board_ehci_hcd_init(int port) · line 588

Quoted 7 lines
board/toradex/colibri_vf/colibri_vf.c +7 -0
+	default:
+		/*
+		 * There are only two USB controllers on Vybrid. Ideally we will
+		 * not reach here. However return USB_INIT_HOST if we do.
+		 */
+		return USB_INIT_HOST;
+		break;

DTTO.

Quoted 3 lines
board/toradex/colibri_vf/colibri_vf.c +2 -0
+	}
+}
 #endif
#25 lore raw

PATCH v5 1/1 colibri_vf: Add board_usb_phy_mode function

In reply to Sanchayan Maity

Add board_usb_phy_mode function for detecting whether a port is being used as host or client using a GPIO. On Colibri Vybrid we provide GPIO 102 for this very same purpose.

---
Changes since v4:
No need to break after return.

Changes since v3:
Return USB_INIT_DEVICE or USB_INIT_HOST after checking for the GPIO state to account for the fact that the previous logic breaks in case if the enum for USB mode were to ever be changed.

Add comments based on Stefan's feedback.

Changes since v2:

Instead of returning 0 from board_usb_phy_mode return it as USB_INIT_HOST.

Changes since v1:

Move the GPIO request call to the board_init function as all further calls to board_usb_phy_mode will actually result in the gpio_request failing.

---
 board/toradex/colibri_vf/colibri_vf.c | 33 ++++++++++++++++++++++++++++++++-
 1 file changed, 32 insertions(+), 1 deletion(-)
board/toradex/colibri_vf/colibri_vf.c +32 -1
index a6d1c5b..c65ccb3 100644
@@ -21,6 +21,7 @@
 #include <i2c.h>
 #include <g_dnl.h>
 #include <asm/gpio.h>
+#include <usb.h>
 
 DECLARE_GLOBAL_DATA_PTR;
 
@@ -34,6 +35,7 @@ DECLARE_GLOBAL_DATA_PTR;
 			PAD_CTL_DSE_50ohm | PAD_CTL_OBE_IBE_ENABLE)
 
 #define USB_PEN_GPIO           83
+#define USB_CDET_GPIO		102
 
 static struct ddrmc_cr_setting colibri_vf_cr_settings[] = {
 	/* levelling */
@@ -92,6 +94,7 @@ static struct ddrmc_cr_setting colibri_vf_cr_settings[] = {
 
 static const iomux_v3_cfg_t usb_pads[] = {
 	VF610_PAD_PTD4__GPIO_83,
+	VF610_PAD_PTC29__GPIO_102,
 };
 
 int dram_init(void)
@@ -280,7 +283,6 @@ static void setup_iomux_gpio(void)
 		VF610_PAD_PTB23__GPIO_93,
 		VF610_PAD_PTB26__GPIO_96,
 		VF610_PAD_PTB28__GPIO_98,
-		VF610_PAD_PTC29__GPIO_102,
 		VF610_PAD_PTC30__GPIO_103,
 		VF610_PAD_PTA7__GPIO_134,
 	};
@@ -509,6 +511,10 @@ int board_init(void)
 
 	setbits_le32(&scsc->sosc_ctr, SCSC_SOSC_CTR_SOSC_EN);
 
+#ifdef CONFIG_USB_EHCI_VF
+	gpio_request(USB_CDET_GPIO, "usb-cdet-gpio");
+#endif
+
 	return 0;
 }
 
@@ -554,4 +560,29 @@ int board_ehci_hcd_init(int port)
 	}
 	return 0;
 }
+
+int board_usb_phy_mode(int port)
+{
+	switch (port) {
+	case 0:
+		/*
+		 * Port 0 is used only in client mode on Colibri Vybrid modules
+		 * Check for state of USB client gpio pin and accordingly return
+		 * USB_INIT_DEVICE or USB_INIT_HOST.
+		 */
+		if (gpio_get_value(USB_CDET_GPIO))
+			return USB_INIT_DEVICE;
+		else
+			return USB_INIT_HOST;
+	case 1:
+		/* Port 1 is used only in host mode on Colibri Vybrid modules */
+		return USB_INIT_HOST;
+	default:
+		/*
+		 * There are only two USB controllers on Vybrid. Ideally we will
+		 * not reach here. However return USB_INIT_HOST if we do.
+		 */
+		return USB_INIT_HOST;
+	}
+}
 #endif
Signature · 1 line
2.6.2
#26 lore raw

PATCH v5 1/1 colibri_vf: Add board_usb_phy_mode function

Hello,

Ping?

Any further feedback? Is the patchset good to get accepted?

Thanks.

Regards,
Sanchayan.

Quoted 111 lines · Sanchayan Maity

Add board_usb_phy_mode function for detecting whether a port is being used as host or client using a GPIO. On Colibri Vybrid we provide GPIO 102 for this very same purpose.

---
Changes since v4:
No need to break after return.

Changes since v3:
Return USB_INIT_DEVICE or USB_INIT_HOST after checking for the GPIO state to account for the fact that the previous logic breaks in case if the enum for USB mode were to ever be changed.

Add comments based on Stefan's feedback.

Changes since v2:

Instead of returning 0 from board_usb_phy_mode return it as USB_INIT_HOST.

Changes since v1:

Move the GPIO request call to the board_init function as all further calls to board_usb_phy_mode will actually result in the gpio_request failing.

---
 board/toradex/colibri_vf/colibri_vf.c | 33 ++++++++++++++++++++++++++++++++-
 1 file changed, 32 insertions(+), 1 deletion(-)
board/toradex/colibri_vf/colibri_vf.c +32 -1
index a6d1c5b..c65ccb3 100644
@@ -21,6 +21,7 @@
 #include <i2c.h>
 #include <g_dnl.h>
 #include <asm/gpio.h>
+#include <usb.h>
 
 DECLARE_GLOBAL_DATA_PTR;
 
@@ -34,6 +35,7 @@ DECLARE_GLOBAL_DATA_PTR;
 			PAD_CTL_DSE_50ohm | PAD_CTL_OBE_IBE_ENABLE)
 
 #define USB_PEN_GPIO           83
+#define USB_CDET_GPIO		102
 
 static struct ddrmc_cr_setting colibri_vf_cr_settings[] = {
 	/* levelling */
@@ -92,6 +94,7 @@ static struct ddrmc_cr_setting colibri_vf_cr_settings[] = {
 
 static const iomux_v3_cfg_t usb_pads[] = {
 	VF610_PAD_PTD4__GPIO_83,
+	VF610_PAD_PTC29__GPIO_102,
 };
 
 int dram_init(void)
@@ -280,7 +283,6 @@ static void setup_iomux_gpio(void)
 		VF610_PAD_PTB23__GPIO_93,
 		VF610_PAD_PTB26__GPIO_96,
 		VF610_PAD_PTB28__GPIO_98,
-		VF610_PAD_PTC29__GPIO_102,
 		VF610_PAD_PTC30__GPIO_103,
 		VF610_PAD_PTA7__GPIO_134,
 	};
@@ -509,6 +511,10 @@ int board_init(void)
 
 	setbits_le32(&scsc->sosc_ctr, SCSC_SOSC_CTR_SOSC_EN);
 
+#ifdef CONFIG_USB_EHCI_VF
+	gpio_request(USB_CDET_GPIO, "usb-cdet-gpio");
+#endif
+
 	return 0;
 }
 
@@ -554,4 +560,29 @@ int board_ehci_hcd_init(int port)
 	}
 	return 0;
 }
+
+int board_usb_phy_mode(int port)
+{
+	switch (port) {
+	case 0:
+		/*
+		 * Port 0 is used only in client mode on Colibri Vybrid modules
+		 * Check for state of USB client gpio pin and accordingly return
+		 * USB_INIT_DEVICE or USB_INIT_HOST.
+		 */
+		if (gpio_get_value(USB_CDET_GPIO))
+			return USB_INIT_DEVICE;
+		else
+			return USB_INIT_HOST;
+	case 1:
+		/* Port 1 is used only in host mode on Colibri Vybrid modules */
+		return USB_INIT_HOST;
+	default:
+		/*
+		 * There are only two USB controllers on Vybrid. Ideally we will
+		 * not reach here. However return USB_INIT_HOST if we do.
+		 */
+		return USB_INIT_HOST;
+	}
+}
 #endif
Signature · 1 line
2.6.2
#27 lore raw

PATCH v5 1/1 colibri_vf: Add board_usb_phy_mode function

Quoted 5 lines · maitysanchayan at gmail.com

Hello,

Ping?

Any further feedback? Is the patchset good to get accepted?

Not from me. Stefano, this is borad-level stuff, so pick it up please.

Best regards,
Marek Vasut

#28 lore raw

PATCH v5 1/1 colibri_vf: Add board_usb_phy_mode function

In reply to maitysanchayan at gmail.com
Quoted 5 lines · maitysanchayan at gmail.com

Hello,

Ping?

Any further feedback? Is the patchset good to get accepted?

I'll pick it up

Best regards,
Stefano Babic

Quoted 118 lines

Thanks.

Regards,
Sanchayan.

Quoted 111 lines · Sanchayan Maity

Add board_usb_phy_mode function for detecting whether a port is being used as host or client using a GPIO. On Colibri Vybrid we provide GPIO 102 for this very same purpose.

---
Changes since v4:
No need to break after return.

Changes since v3:
Return USB_INIT_DEVICE or USB_INIT_HOST after checking for the GPIO state to account for the fact that the previous logic breaks in case if the enum for USB mode were to ever be changed.

Add comments based on Stefan's feedback.

Changes since v2:

Instead of returning 0 from board_usb_phy_mode return it as USB_INIT_HOST.

Changes since v1:

Move the GPIO request call to the board_init function as all further calls to board_usb_phy_mode will actually result in the gpio_request failing.

---
 board/toradex/colibri_vf/colibri_vf.c | 33 ++++++++++++++++++++++++++++++++-
 1 file changed, 32 insertions(+), 1 deletion(-)
board/toradex/colibri_vf/colibri_vf.c +32 -1
index a6d1c5b..c65ccb3 100644
@@ -21,6 +21,7 @@
 #include <i2c.h>
 #include <g_dnl.h>
 #include <asm/gpio.h>
+#include <usb.h>
 
 DECLARE_GLOBAL_DATA_PTR;
 
@@ -34,6 +35,7 @@ DECLARE_GLOBAL_DATA_PTR;
 			PAD_CTL_DSE_50ohm | PAD_CTL_OBE_IBE_ENABLE)
 
 #define USB_PEN_GPIO           83
+#define USB_CDET_GPIO		102
 
 static struct ddrmc_cr_setting colibri_vf_cr_settings[] = {
 	/* levelling */
@@ -92,6 +94,7 @@ static struct ddrmc_cr_setting colibri_vf_cr_settings[] = {
 
 static const iomux_v3_cfg_t usb_pads[] = {
 	VF610_PAD_PTD4__GPIO_83,
+	VF610_PAD_PTC29__GPIO_102,
 };
 
 int dram_init(void)
@@ -280,7 +283,6 @@ static void setup_iomux_gpio(void)
 		VF610_PAD_PTB23__GPIO_93,
 		VF610_PAD_PTB26__GPIO_96,
 		VF610_PAD_PTB28__GPIO_98,
-		VF610_PAD_PTC29__GPIO_102,
 		VF610_PAD_PTC30__GPIO_103,
 		VF610_PAD_PTA7__GPIO_134,
 	};
@@ -509,6 +511,10 @@ int board_init(void)
 
 	setbits_le32(&scsc->sosc_ctr, SCSC_SOSC_CTR_SOSC_EN);
 
+#ifdef CONFIG_USB_EHCI_VF
+	gpio_request(USB_CDET_GPIO, "usb-cdet-gpio");
+#endif
+
 	return 0;
 }
 
@@ -554,4 +560,29 @@ int board_ehci_hcd_init(int port)
 	}
 	return 0;
 }
+
+int board_usb_phy_mode(int port)
+{
+	switch (port) {
+	case 0:
+		/*
+		 * Port 0 is used only in client mode on Colibri Vybrid modules
+		 * Check for state of USB client gpio pin and accordingly return
+		 * USB_INIT_DEVICE or USB_INIT_HOST.
+		 */
+		if (gpio_get_value(USB_CDET_GPIO))
+			return USB_INIT_DEVICE;
+		else
+			return USB_INIT_HOST;
+	case 1:
+		/* Port 1 is used only in host mode on Colibri Vybrid modules */
+		return USB_INIT_HOST;
+	default:
+		/*
+		 * There are only two USB controllers on Vybrid. Ideally we will
+		 * not reach here. However return USB_INIT_HOST if we do.
+		 */
+		return USB_INIT_HOST;
+	}
+}
 #endif
Signature · 1 line
2.6.2
Signature · 5 lines
=====================================================================
DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-53 Fax: +49-8142-66989-80 Email: sbabic at denx.de
=====================================================================
#29 lore raw

PATCH v5 1/1 colibri_vf: Add board_usb_phy_mode function

Quoted 8 lines · Stefano Babic
Quoted 5 lines · maitysanchayan at gmail.com

Hello,

Ping?

Any further feedback? Is the patchset good to get accepted?

I'll pick it up

Thanks.

- Sanchayan.

#30 lore raw

PATCH v5 1/1 colibri_vf: Add board_usb_phy_mode function

In reply to Stefano Babic

Hello Stefano,

Ping?

I just checked the master branch and this has not been picked up yet.

- Sanchayan.

Quoted 138 lines · Stefano Babic
Quoted 5 lines · maitysanchayan at gmail.com

Hello,

Ping?

Any further feedback? Is the patchset good to get accepted?

I'll pick it up

Best regards,
Stefano Babic

Quoted 118 lines

Thanks.

Regards,
Sanchayan.

Quoted 111 lines · Sanchayan Maity

Add board_usb_phy_mode function for detecting whether a port is being used as host or client using a GPIO. On Colibri Vybrid we provide GPIO 102 for this very same purpose.

---
Changes since v4:
No need to break after return.

Changes since v3:
Return USB_INIT_DEVICE or USB_INIT_HOST after checking for the GPIO state to account for the fact that the previous logic breaks in case if the enum for USB mode were to ever be changed.

Add comments based on Stefan's feedback.

Changes since v2:

Instead of returning 0 from board_usb_phy_mode return it as USB_INIT_HOST.

Changes since v1:

Move the GPIO request call to the board_init function as all further calls to board_usb_phy_mode will actually result in the gpio_request failing.

---
 board/toradex/colibri_vf/colibri_vf.c | 33 ++++++++++++++++++++++++++++++++-
 1 file changed, 32 insertions(+), 1 deletion(-)
board/toradex/colibri_vf/colibri_vf.c +32 -1
index a6d1c5b..c65ccb3 100644
@@ -21,6 +21,7 @@
 #include <i2c.h>
 #include <g_dnl.h>
 #include <asm/gpio.h>
+#include <usb.h>
 
 DECLARE_GLOBAL_DATA_PTR;
 
@@ -34,6 +35,7 @@ DECLARE_GLOBAL_DATA_PTR;
 			PAD_CTL_DSE_50ohm | PAD_CTL_OBE_IBE_ENABLE)
 
 #define USB_PEN_GPIO           83
+#define USB_CDET_GPIO		102
 
 static struct ddrmc_cr_setting colibri_vf_cr_settings[] = {
 	/* levelling */
@@ -92,6 +94,7 @@ static struct ddrmc_cr_setting colibri_vf_cr_settings[] = {
 
 static const iomux_v3_cfg_t usb_pads[] = {
 	VF610_PAD_PTD4__GPIO_83,
+	VF610_PAD_PTC29__GPIO_102,
 };
 
 int dram_init(void)
@@ -280,7 +283,6 @@ static void setup_iomux_gpio(void)
 		VF610_PAD_PTB23__GPIO_93,
 		VF610_PAD_PTB26__GPIO_96,
 		VF610_PAD_PTB28__GPIO_98,
-		VF610_PAD_PTC29__GPIO_102,
 		VF610_PAD_PTC30__GPIO_103,
 		VF610_PAD_PTA7__GPIO_134,
 	};
@@ -509,6 +511,10 @@ int board_init(void)
 
 	setbits_le32(&scsc->sosc_ctr, SCSC_SOSC_CTR_SOSC_EN);
 
+#ifdef CONFIG_USB_EHCI_VF
+	gpio_request(USB_CDET_GPIO, "usb-cdet-gpio");
+#endif
+
 	return 0;
 }
 
@@ -554,4 +560,29 @@ int board_ehci_hcd_init(int port)
 	}
 	return 0;
 }
+
+int board_usb_phy_mode(int port)
+{
+	switch (port) {
+	case 0:
+		/*
+		 * Port 0 is used only in client mode on Colibri Vybrid modules
+		 * Check for state of USB client gpio pin and accordingly return
+		 * USB_INIT_DEVICE or USB_INIT_HOST.
+		 */
+		if (gpio_get_value(USB_CDET_GPIO))
+			return USB_INIT_DEVICE;
+		else
+			return USB_INIT_HOST;
+	case 1:
+		/* Port 1 is used only in host mode on Colibri Vybrid modules */
+		return USB_INIT_HOST;
+	default:
+		/*
+		 * There are only two USB controllers on Vybrid. Ideally we will
+		 * not reach here. However return USB_INIT_HOST if we do.
+		 */
+		return USB_INIT_HOST;
+	}
+}
 #endif
Signature · 1 line
2.6.2
Signature · 5 lines
=====================================================================
DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-53 Fax: +49-8142-66989-80 Email: sbabic at denx.de
=====================================================================
#31 lore raw

PATCH v5 1/1 colibri_vf: Add board_usb_phy_mode function

Hi,

Quoted 6 lines · maitysanchayan at gmail.com

Hello Stefano,

Ping?

I just checked the master branch and this has not been picked up yet.

Can you check ? I see:

commit 01a8cf91513981d05bf89840d768e9c060ee998b

Author: Sanchayan Maity <[email protected]>
Date:   Thu Nov 12 11:47:35 2015 +0530

colibri_vf: Add board_usb_phy_mode function

Regards,
Stefano

Quoted 141 lines

- Sanchayan.

Quoted 138 lines · Stefano Babic
Quoted 5 lines · maitysanchayan at gmail.com

Hello,

Ping?

Any further feedback? Is the patchset good to get accepted?

I'll pick it up

Best regards,
Stefano Babic

Quoted 118 lines

Thanks.

Regards,
Sanchayan.

Quoted 111 lines · Sanchayan Maity

Add board_usb_phy_mode function for detecting whether a port is being used as host or client using a GPIO. On Colibri Vybrid we provide GPIO 102 for this very same purpose.

---
Changes since v4:
No need to break after return.

Changes since v3:
Return USB_INIT_DEVICE or USB_INIT_HOST after checking for the GPIO state to account for the fact that the previous logic breaks in case if the enum for USB mode were to ever be changed.

Add comments based on Stefan's feedback.

Changes since v2:

Instead of returning 0 from board_usb_phy_mode return it as USB_INIT_HOST.

Changes since v1:

Move the GPIO request call to the board_init function as all further calls to board_usb_phy_mode will actually result in the gpio_request failing.

---
 board/toradex/colibri_vf/colibri_vf.c | 33 ++++++++++++++++++++++++++++++++-
 1 file changed, 32 insertions(+), 1 deletion(-)
board/toradex/colibri_vf/colibri_vf.c +32 -1
index a6d1c5b..c65ccb3 100644
@@ -21,6 +21,7 @@
 #include <i2c.h>
 #include <g_dnl.h>
 #include <asm/gpio.h>
+#include <usb.h>
 
 DECLARE_GLOBAL_DATA_PTR;
 
@@ -34,6 +35,7 @@ DECLARE_GLOBAL_DATA_PTR;
 			PAD_CTL_DSE_50ohm | PAD_CTL_OBE_IBE_ENABLE)
 
 #define USB_PEN_GPIO           83
+#define USB_CDET_GPIO		102
 
 static struct ddrmc_cr_setting colibri_vf_cr_settings[] = {
 	/* levelling */
@@ -92,6 +94,7 @@ static struct ddrmc_cr_setting colibri_vf_cr_settings[] = {
 
 static const iomux_v3_cfg_t usb_pads[] = {
 	VF610_PAD_PTD4__GPIO_83,
+	VF610_PAD_PTC29__GPIO_102,
 };
 
 int dram_init(void)
@@ -280,7 +283,6 @@ static void setup_iomux_gpio(void)
 		VF610_PAD_PTB23__GPIO_93,
 		VF610_PAD_PTB26__GPIO_96,
 		VF610_PAD_PTB28__GPIO_98,
-		VF610_PAD_PTC29__GPIO_102,
 		VF610_PAD_PTC30__GPIO_103,
 		VF610_PAD_PTA7__GPIO_134,
 	};
@@ -509,6 +511,10 @@ int board_init(void)
 
 	setbits_le32(&scsc->sosc_ctr, SCSC_SOSC_CTR_SOSC_EN);
 
+#ifdef CONFIG_USB_EHCI_VF
+	gpio_request(USB_CDET_GPIO, "usb-cdet-gpio");
+#endif
+
 	return 0;
 }
 
@@ -554,4 +560,29 @@ int board_ehci_hcd_init(int port)
 	}
 	return 0;
 }
+
+int board_usb_phy_mode(int port)
+{
+	switch (port) {
+	case 0:
+		/*
+		 * Port 0 is used only in client mode on Colibri Vybrid modules
+		 * Check for state of USB client gpio pin and accordingly return
+		 * USB_INIT_DEVICE or USB_INIT_HOST.
+		 */
+		if (gpio_get_value(USB_CDET_GPIO))
+			return USB_INIT_DEVICE;
+		else
+			return USB_INIT_HOST;
+	case 1:
+		/* Port 1 is used only in host mode on Colibri Vybrid modules */
+		return USB_INIT_HOST;
+	default:
+		/*
+		 * There are only two USB controllers on Vybrid. Ideally we will
+		 * not reach here. However return USB_INIT_HOST if we do.
+		 */
+		return USB_INIT_HOST;
+	}
+}
 #endif
Signature · 1 line
2.6.2
Signature · 5 lines
=====================================================================
DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-53 Fax: +49-8142-66989-80 Email: sbabic at denx.de
=====================================================================
Signature · 5 lines
=====================================================================
DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-53 Fax: +49-8142-66989-80 Email: sbabic at denx.de
=====================================================================
#32 lore raw

PATCH v5 1/1 colibri_vf: Add board_usb_phy_mode function

Hello,

Quoted 10 lines · Stefano Babic

Hi,

Quoted 6 lines · maitysanchayan at gmail.com

Hello Stefano,

Ping?

I just checked the master branch and this has not been picked up yet.

Quoted 7 lines

Can you check ? I see:

commit 01a8cf91513981d05bf89840d768e9c060ee998b

Author: Sanchayan Maity <[email protected]>
Date:   Thu Nov 12 11:47:35 2015 +0530

colibri_vf: Add board_usb_phy_mode function

Yes, this seems to be present but the first and second patch in the series which make changes to the ehci-vf driver are not present.

- Sanchayan.

Quoted 152 lines

Regards,
Stefano

Quoted 141 lines

- Sanchayan.

Quoted 138 lines · Stefano Babic
Quoted 5 lines · maitysanchayan at gmail.com

Hello,

Ping?

Any further feedback? Is the patchset good to get accepted?

I'll pick it up

Best regards,
Stefano Babic

Quoted 118 lines

Thanks.

Regards,
Sanchayan.

Quoted 111 lines · Sanchayan Maity

Add board_usb_phy_mode function for detecting whether a port is being used as host or client using a GPIO. On Colibri Vybrid we provide GPIO 102 for this very same purpose.

---
Changes since v4:
No need to break after return.

Changes since v3:
Return USB_INIT_DEVICE or USB_INIT_HOST after checking for the GPIO state to account for the fact that the previous logic breaks in case if the enum for USB mode were to ever be changed.

Add comments based on Stefan's feedback.

Changes since v2:

Instead of returning 0 from board_usb_phy_mode return it as USB_INIT_HOST.

Changes since v1:

Move the GPIO request call to the board_init function as all further calls to board_usb_phy_mode will actually result in the gpio_request failing.

---
 board/toradex/colibri_vf/colibri_vf.c | 33 ++++++++++++++++++++++++++++++++-
 1 file changed, 32 insertions(+), 1 deletion(-)
board/toradex/colibri_vf/colibri_vf.c +32 -1
index a6d1c5b..c65ccb3 100644
@@ -21,6 +21,7 @@
 #include <i2c.h>
 #include <g_dnl.h>
 #include <asm/gpio.h>
+#include <usb.h>
 
 DECLARE_GLOBAL_DATA_PTR;
 
@@ -34,6 +35,7 @@ DECLARE_GLOBAL_DATA_PTR;
 			PAD_CTL_DSE_50ohm | PAD_CTL_OBE_IBE_ENABLE)
 
 #define USB_PEN_GPIO           83
+#define USB_CDET_GPIO		102
 
 static struct ddrmc_cr_setting colibri_vf_cr_settings[] = {
 	/* levelling */
@@ -92,6 +94,7 @@ static struct ddrmc_cr_setting colibri_vf_cr_settings[] = {
 
 static const iomux_v3_cfg_t usb_pads[] = {
 	VF610_PAD_PTD4__GPIO_83,
+	VF610_PAD_PTC29__GPIO_102,
 };
 
 int dram_init(void)
@@ -280,7 +283,6 @@ static void setup_iomux_gpio(void)
 		VF610_PAD_PTB23__GPIO_93,
 		VF610_PAD_PTB26__GPIO_96,
 		VF610_PAD_PTB28__GPIO_98,
-		VF610_PAD_PTC29__GPIO_102,
 		VF610_PAD_PTC30__GPIO_103,
 		VF610_PAD_PTA7__GPIO_134,
 	};
@@ -509,6 +511,10 @@ int board_init(void)
 
 	setbits_le32(&scsc->sosc_ctr, SCSC_SOSC_CTR_SOSC_EN);
 
+#ifdef CONFIG_USB_EHCI_VF
+	gpio_request(USB_CDET_GPIO, "usb-cdet-gpio");
+#endif
+
 	return 0;
 }
 
@@ -554,4 +560,29 @@ int board_ehci_hcd_init(int port)
 	}
 	return 0;
 }
+
+int board_usb_phy_mode(int port)
+{
+	switch (port) {
+	case 0:
+		/*
+		 * Port 0 is used only in client mode on Colibri Vybrid modules
+		 * Check for state of USB client gpio pin and accordingly return
+		 * USB_INIT_DEVICE or USB_INIT_HOST.
+		 */
+		if (gpio_get_value(USB_CDET_GPIO))
+			return USB_INIT_DEVICE;
+		else
+			return USB_INIT_HOST;
+	case 1:
+		/* Port 1 is used only in host mode on Colibri Vybrid modules */
+		return USB_INIT_HOST;
+	default:
+		/*
+		 * There are only two USB controllers on Vybrid. Ideally we will
+		 * not reach here. However return USB_INIT_HOST if we do.
+		 */
+		return USB_INIT_HOST;
+	}
+}
 #endif
Signature · 1 line
2.6.2
Signature · 5 lines
=====================================================================
DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-53 Fax: +49-8142-66989-80 Email: sbabic at denx.de
=====================================================================
Signature · 5 lines
=====================================================================
DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-53 Fax: +49-8142-66989-80 Email: sbabic at denx.de
=====================================================================
#33 lore raw

PATCH v5 1/1 colibri_vf: Add board_usb_phy_mode function

Quoted 14 lines · maitysanchayan at gmail.com

Hello,

Quoted 11 lines · Stefano Babic

Hi,

Quoted 5 lines · maitysanchayan at gmail.com

Hello Stefano,

Ping?

I just checked the master branch and this has not been picked up yet.

Can you check ? I see:

Quoted 8 lines
Quoted 5 lines

commit 01a8cf91513981d05bf89840d768e9c060ee998b

Author: Sanchayan Maity <[email protected]>
Date:   Thu Nov 12 11:47:35 2015 +0530

colibri_vf: Add board_usb_phy_mode function

Yes, this seems to be present but the first and second patch in the series which make changes to the ehci-vf driver are not present.

But this is only a single patch here , even the subject indicates so ... ?

Best regards,
Marek Vasut

#34 lore raw

PATCH v5 1/1 colibri_vf: Add board_usb_phy_mode function

Quoted 19 lines · Marek Vasut
Quoted 18 lines · maitysanchayan at gmail.com

Hello,

Quoted 15 lines · Stefano Babic

Hi,

Quoted 5 lines · maitysanchayan at gmail.com

Hello Stefano,

Ping?

I just checked the master branch and this has not been picked up yet.

Can you check ? I see:

commit 01a8cf91513981d05bf89840d768e9c060ee998b

Author: Sanchayan Maity <[email protected]>
Date:   Thu Nov 12 11:47:35 2015 +0530
Quoted 6 lines
Quoted 4 lines
Quoted 1 line

colibri_vf: Add board_usb_phy_mode function

Yes, this seems to be present but the first and second patch in the series which make changes to the ehci-vf driver are not present.

But this is only a single patch here , even the subject indicates so ... ?

Hmm I guess I get it. This patch I had send as a reply to the 3rd patch in a thread of a 3 patch series

http://thread.gmane.org/gmane.comp.boot-loaders.u-boot/238549

My bad. Sorry about the confusion. I will ping on the respective individual 1st and 2nd patch.

- Sanchayan.

#35 lore raw

PATCH v5 1/1 colibri_vf: Add board_usb_phy_mode function

Quoted 29 lines · maitysanchayan at gmail.com
Quoted 20 lines · Marek Vasut
Quoted 19 lines · maitysanchayan at gmail.com

Hello,

Quoted 16 lines · Stefano Babic

Hi,

Quoted 6 lines · maitysanchayan at gmail.com

Hello Stefano,

Ping?

I just checked the master branch and this has not been picked up yet.

Can you check ? I see:

commit 01a8cf91513981d05bf89840d768e9c060ee998b

Author: Sanchayan Maity <[email protected]>
Date:   Thu Nov 12 11:47:35 2015 +0530
Quoted 7 lines
Quoted 4 lines
Quoted 1 line

colibri_vf: Add board_usb_phy_mode function

Yes, this seems to be present but the first and second patch in the series which make changes to the ehci-vf driver are not present.

But this is only a single patch here , even the subject indicates so ... ?

Quoted 7 lines

Hmm I guess I get it. This patch I had send as a reply to the 3rd patch in a thread of a 3 patch series

http://thread.gmane.org/gmane.comp.boot-loaders.u-boot/238549

My bad. Sorry about the confusion. I will ping on the respective individual 1st and 2nd patch.

Thanks :) I suppose it's clear now to everyone involved.

Best regards,
Marek Vasut