All of lore.kernel.org
 help / color / mirror / Atom feed
* [U-Boot] [PATCH 1/3] usb: host: ehci-vf: Remove hardcoded USB host client configuration
@ 2015-10-26 12:58 Sanchayan Maity
  2015-10-26 12:58 ` [U-Boot] [PATCH 2/3] usb: host: ehci-vf: Implement board_usb_phy_mode weak function Sanchayan Maity
                   ` (3 more replies)
  0 siblings, 4 replies; 36+ messages in thread
From: Sanchayan Maity @ 2015-10-26 12:58 UTC (permalink / raw)
  To: u-boot

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

Reported-by: Santhosh Kumar Janardhanam <santhosh.kj@hcl.com>
Signed-off-by: Sanchayan Maity <maitysanchayan@gmail.com>
---
 drivers/usb/host/ehci-vf.c | 5 -----
 1 file changed, 5 deletions(-)

diff --git a/drivers/usb/host/ehci-vf.c b/drivers/usb/host/ehci-vf.c
index 98e0fc6..351e0fb 100644
--- a/drivers/usb/host/ehci-vf.c
+++ b/drivers/usb/host/ehci-vf.c
@@ -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 */
-- 
2.6.2

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

* [U-Boot] [PATCH 2/3] usb: host: ehci-vf: Implement board_usb_phy_mode weak function
  2015-10-26 12:58 [U-Boot] [PATCH 1/3] usb: host: ehci-vf: Remove hardcoded USB host client configuration Sanchayan Maity
@ 2015-10-26 12:58 ` Sanchayan Maity
  2016-01-08 12:22   ` maitysanchayan at gmail.com
  2015-10-26 12:58 ` [U-Boot] [PATCH 3/3] colibri_vf: Add board_usb_phy_mode function Sanchayan Maity
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 36+ messages in thread
From: Sanchayan Maity @ 2015-10-26 12:58 UTC (permalink / raw)
  To: u-boot

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.

Signed-off-by: Sanchayan Maity <maitysanchayan@gmail.com>
---
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(+)

diff --git a/drivers/usb/host/ehci-vf.c b/drivers/usb/host/ehci-vf.c
index 351e0fb..335e303 100644
--- a/drivers/usb/host/ehci-vf.c
+++ b/drivers/usb/host/ehci-vf.c
@@ -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);
-- 
2.6.2

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

* [U-Boot] [PATCH 3/3] colibri_vf: Add board_usb_phy_mode function
  2015-10-26 12:58 [U-Boot] [PATCH 1/3] usb: host: ehci-vf: Remove hardcoded USB host client configuration Sanchayan Maity
  2015-10-26 12:58 ` [U-Boot] [PATCH 2/3] usb: host: ehci-vf: Implement board_usb_phy_mode weak function Sanchayan Maity
@ 2015-10-26 12:58 ` Sanchayan Maity
  2015-10-27  9:18   ` Marek Vasut
  2015-10-29 10:15   ` [U-Boot] [PATCH v2] " Sanchayan Maity
  2015-10-26 19:19 ` [U-Boot] [PATCH 1/3] usb: host: ehci-vf: Remove hardcoded USB host client configuration Marek Vasut
  2016-01-08 12:20 ` maitysanchayan at gmail.com
  3 siblings, 2 replies; 36+ messages in thread
From: Sanchayan Maity @ 2015-10-26 12:58 UTC (permalink / raw)
  To: u-boot

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.

Signed-off-by: Sanchayan Maity <maitysanchayan@gmail.com>
---
 board/toradex/colibri_vf/colibri_vf.c | 19 ++++++++++++++++++-
 1 file changed, 18 insertions(+), 1 deletion(-)

diff --git a/board/toradex/colibri_vf/colibri_vf.c b/board/toradex/colibri_vf/colibri_vf.c
index a6d1c5b..fd90ef2 100644
--- a/board/toradex/colibri_vf/colibri_vf.c
+++ b/board/toradex/colibri_vf/colibri_vf.c
@@ -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
-- 
2.6.2

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

* [U-Boot] [PATCH 1/3] usb: host: ehci-vf: Remove hardcoded USB host client configuration
  2015-10-26 12:58 [U-Boot] [PATCH 1/3] usb: host: ehci-vf: Remove hardcoded USB host client configuration Sanchayan Maity
  2015-10-26 12:58 ` [U-Boot] [PATCH 2/3] usb: host: ehci-vf: Implement board_usb_phy_mode weak function Sanchayan Maity
  2015-10-26 12:58 ` [U-Boot] [PATCH 3/3] colibri_vf: Add board_usb_phy_mode function Sanchayan Maity
@ 2015-10-26 19:19 ` Marek Vasut
  2015-10-27  3:28   ` maitysanchayan at gmail.com
  2016-01-08 12:20 ` maitysanchayan at gmail.com
  3 siblings, 1 reply; 36+ messages in thread
From: Marek Vasut @ 2015-10-26 19:19 UTC (permalink / raw)
  To: u-boot

On Monday, October 26, 2015 at 01:58:49 PM, Sanchayan Maity wrote:
> The current ehci-vf USB driver for Vybrid hardcodes the USB host
> and client functionality. Remove this.
> 
> Reported-by: Santhosh Kumar Janardhanam <santhosh.kj@hcl.com>
> Signed-off-by: Sanchayan Maity <maitysanchayan@gmail.com>

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

Looks OK though.

Best regards,
Marek Vasut

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

* [U-Boot] [PATCH 1/3] usb: host: ehci-vf: Remove hardcoded USB host client configuration
  2015-10-26 19:19 ` [U-Boot] [PATCH 1/3] usb: host: ehci-vf: Remove hardcoded USB host client configuration Marek Vasut
@ 2015-10-27  3:28   ` maitysanchayan at gmail.com
  0 siblings, 0 replies; 36+ messages in thread
From: maitysanchayan at gmail.com @ 2015-10-27  3:28 UTC (permalink / raw)
  To: u-boot

Hello,

On 15-10-26 20:19:42, Marek Vasut wrote:
> On Monday, October 26, 2015 at 01:58:49 PM, Sanchayan Maity wrote:
> > The current ehci-vf USB driver for Vybrid hardcodes the USB host
> > and client functionality. Remove this.
> > 
> > Reported-by: Santhosh Kumar Janardhanam <santhosh.kj@hcl.com>
> > Signed-off-by: Sanchayan Maity <maitysanchayan@gmail.com>
> 
> 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.

>
> Looks OK though.
> 
> Best regards,
> Marek Vasut

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

* [U-Boot] [PATCH 3/3] colibri_vf: Add board_usb_phy_mode function
  2015-10-26 12:58 ` [U-Boot] [PATCH 3/3] colibri_vf: Add board_usb_phy_mode function Sanchayan Maity
@ 2015-10-27  9:18   ` Marek Vasut
  2015-10-27 11:34     ` maitysanchayan at gmail.com
  2015-10-29 10:15   ` [U-Boot] [PATCH v2] " Sanchayan Maity
  1 sibling, 1 reply; 36+ messages in thread
From: Marek Vasut @ 2015-10-27  9:18 UTC (permalink / raw)
  To: u-boot

On Monday, October 26, 2015 at 01:58:51 PM, Sanchayan Maity wrote:
> 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.
> 
> Signed-off-by: Sanchayan Maity <maitysanchayan@gmail.com>
> ---
>  board/toradex/colibri_vf/colibri_vf.c | 19 ++++++++++++++++++-
>  1 file changed, 18 insertions(+), 1 deletion(-)
> 
> diff --git a/board/toradex/colibri_vf/colibri_vf.c
> b/board/toradex/colibri_vf/colibri_vf.c index a6d1c5b..fd90ef2 100644
> --- a/board/toradex/colibri_vf/colibri_vf.c
> +++ b/board/toradex/colibri_vf/colibri_vf.c
> @@ -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");

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.

> +		return gpio_get_value(USB_CDET_GPIO);
> +		break;
> +	case 1:
> +		return 0;
> +		break;
> +	default:
> +		return 0;
> +		break;
> +	}
> +}
>  #endif

Best regards,
Marek Vasut

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

* [U-Boot] [PATCH 3/3] colibri_vf: Add board_usb_phy_mode function
  2015-10-27  9:18   ` Marek Vasut
@ 2015-10-27 11:34     ` maitysanchayan at gmail.com
  0 siblings, 0 replies; 36+ messages in thread
From: maitysanchayan at gmail.com @ 2015-10-27 11:34 UTC (permalink / raw)
  To: u-boot

On 15-10-27 10:18:47, Marek Vasut wrote:
> On Monday, October 26, 2015 at 01:58:51 PM, Sanchayan Maity wrote:
> > 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.
> > 
> > Signed-off-by: Sanchayan Maity <maitysanchayan@gmail.com>
> > ---
> >  board/toradex/colibri_vf/colibri_vf.c | 19 ++++++++++++++++++-
> >  1 file changed, 18 insertions(+), 1 deletion(-)
> > 
> > diff --git a/board/toradex/colibri_vf/colibri_vf.c
> > b/board/toradex/colibri_vf/colibri_vf.c index a6d1c5b..fd90ef2 100644
> > --- a/board/toradex/colibri_vf/colibri_vf.c
> > +++ b/board/toradex/colibri_vf/colibri_vf.c
> > @@ -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");
> 
> 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.

>
> > +		return gpio_get_value(USB_CDET_GPIO);
> > +		break;
> > +	case 1:
> > +		return 0;
> > +		break;
> > +	default:
> > +		return 0;
> > +		break;
> > +	}
> > +}
> >  #endif
> 
> Best regards,
> Marek Vasut

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

* [U-Boot] [PATCH v2] colibri_vf: Add board_usb_phy_mode function
  2015-10-26 12:58 ` [U-Boot] [PATCH 3/3] colibri_vf: Add board_usb_phy_mode function Sanchayan Maity
  2015-10-27  9:18   ` Marek Vasut
@ 2015-10-29 10:15   ` Sanchayan Maity
  2015-10-29 17:25     ` Marek Vasut
  2015-10-30 12:26     ` [U-Boot] [PATCH v3] " Sanchayan Maity
  1 sibling, 2 replies; 36+ messages in thread
From: Sanchayan Maity @ 2015-10-29 10:15 UTC (permalink / raw)
  To: u-boot

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.

Signed-off-by: Sanchayan Maity <maitysanchayan@gmail.com>
---
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(-)

diff --git a/board/toradex/colibri_vf/colibri_vf.c b/board/toradex/colibri_vf/colibri_vf.c
index a6d1c5b..69274e5 100644
--- a/board/toradex/colibri_vf/colibri_vf.c
+++ b/board/toradex/colibri_vf/colibri_vf.c
@@ -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
-- 
2.6.2

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

* [U-Boot] [PATCH v2] colibri_vf: Add board_usb_phy_mode function
  2015-10-29 10:15   ` [U-Boot] [PATCH v2] " Sanchayan Maity
@ 2015-10-29 17:25     ` Marek Vasut
  2015-10-30 12:26     ` [U-Boot] [PATCH v3] " Sanchayan Maity
  1 sibling, 0 replies; 36+ messages in thread
From: Marek Vasut @ 2015-10-29 17:25 UTC (permalink / raw)
  To: u-boot

On Thursday, October 29, 2015 at 11:15:24 AM, Sanchayan Maity wrote:
> 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.
> 
> Signed-off-by: Sanchayan Maity <maitysanchayan@gmail.com>

Hi!

[...]

> @@ -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 .

> +		break;
> +	default:
> +		return 0;
> +		break;
> +	}
> +}
>  #endif

Best regards,
Marek Vasut

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

* [U-Boot] [PATCH v3] colibri_vf: Add board_usb_phy_mode function
  2015-10-29 10:15   ` [U-Boot] [PATCH v2] " Sanchayan Maity
  2015-10-29 17:25     ` Marek Vasut
@ 2015-10-30 12:26     ` Sanchayan Maity
  2015-10-30 13:20       ` Marek Vasut
                         ` (2 more replies)
  1 sibling, 3 replies; 36+ messages in thread
From: Sanchayan Maity @ 2015-10-30 12:26 UTC (permalink / raw)
  To: u-boot

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.

Signed-off-by: Sanchayan Maity <maitysanchayan@gmail.com>
---
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(-)

diff --git a/board/toradex/colibri_vf/colibri_vf.c b/board/toradex/colibri_vf/colibri_vf.c
index a6d1c5b..9878671 100644
--- a/board/toradex/colibri_vf/colibri_vf.c
+++ b/board/toradex/colibri_vf/colibri_vf.c
@@ -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
-- 
2.6.2

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

* [U-Boot] [PATCH v3] colibri_vf: Add board_usb_phy_mode function
  2015-10-30 12:26     ` [U-Boot] [PATCH v3] " Sanchayan Maity
@ 2015-10-30 13:20       ` Marek Vasut
  2015-11-06  7:00         ` maitysanchayan at gmail.com
  2015-10-30 16:12       ` Stefan Agner
  2015-11-09 14:59       ` [U-Boot] [PATCH v4] " Sanchayan Maity
  2 siblings, 1 reply; 36+ messages in thread
From: Marek Vasut @ 2015-10-30 13:20 UTC (permalink / raw)
  To: u-boot

On Friday, October 30, 2015 at 01:26:59 PM, Sanchayan Maity wrote:
> 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.
> 
> Signed-off-by: Sanchayan Maity <maitysanchayan@gmail.com>
> ---
> 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(-)
> 
> diff --git a/board/toradex/colibri_vf/colibri_vf.c
> b/board/toradex/colibri_vf/colibri_vf.c index a6d1c5b..9878671 100644
> --- a/board/toradex/colibri_vf/colibri_vf.c
> +++ b/board/toradex/colibri_vf/colibri_vf.c
> @@ -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);

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 ?

> +		break;
> +	case 1:
> +		return USB_INIT_HOST;
> +		break;
> +	default:
> +		return USB_INIT_HOST;
> +		break;
> +	}
> +}
>  #endif

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

* [U-Boot] [PATCH v3] colibri_vf: Add board_usb_phy_mode function
  2015-10-30 12:26     ` [U-Boot] [PATCH v3] " Sanchayan Maity
  2015-10-30 13:20       ` Marek Vasut
@ 2015-10-30 16:12       ` Stefan Agner
  2015-10-30 16:24         ` Marek Vasut
  2015-11-09 14:59       ` [U-Boot] [PATCH v4] " Sanchayan Maity
  2 siblings, 1 reply; 36+ messages in thread
From: Stefan Agner @ 2015-10-30 16:12 UTC (permalink / raw)
  To: u-boot

Hi All,

On 2015-10-30 05:26, Sanchayan Maity wrote:
> +
> +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

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

* [U-Boot] [PATCH v3] colibri_vf: Add board_usb_phy_mode function
  2015-10-30 16:12       ` Stefan Agner
@ 2015-10-30 16:24         ` Marek Vasut
  2015-10-30 16:26           ` Stefan Agner
  0 siblings, 1 reply; 36+ messages in thread
From: Marek Vasut @ 2015-10-30 16:24 UTC (permalink / raw)
  To: u-boot

On Friday, October 30, 2015 at 05:12:54 PM, Stefan Agner wrote:
> Hi All,

Hi!

> On 2015-10-30 05:26, Sanchayan Maity wrote:
> > +
> > +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?

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

Best regards,
Marek Vasut

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

* [U-Boot] [PATCH v3] colibri_vf: Add board_usb_phy_mode function
  2015-10-30 16:24         ` Marek Vasut
@ 2015-10-30 16:26           ` Stefan Agner
  2015-10-30 17:07             ` Marek Vasut
  0 siblings, 1 reply; 36+ messages in thread
From: Stefan Agner @ 2015-10-30 16:26 UTC (permalink / raw)
  To: u-boot

On 2015-10-30 09:24, Marek Vasut wrote:
> On Friday, October 30, 2015 at 05:12:54 PM, Stefan Agner wrote:
>> Hi All,
> 
> Hi!
> 
>> On 2015-10-30 05:26, Sanchayan Maity wrote:
>> > +
>> > +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?
> 
> 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

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

* [U-Boot] [PATCH v3] colibri_vf: Add board_usb_phy_mode function
  2015-10-30 16:26           ` Stefan Agner
@ 2015-10-30 17:07             ` Marek Vasut
  0 siblings, 0 replies; 36+ messages in thread
From: Marek Vasut @ 2015-10-30 17:07 UTC (permalink / raw)
  To: u-boot

On Friday, October 30, 2015 at 05:26:25 PM, Stefan Agner wrote:
> On 2015-10-30 09:24, Marek Vasut wrote:
> > On Friday, October 30, 2015 at 05:12:54 PM, Stefan Agner wrote:
> >> Hi All,
> > 
> > Hi!
> > 
> >> On 2015-10-30 05:26, Sanchayan Maity wrote:
> >> > +
> >> > +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?
> > 
> > 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

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

* [U-Boot] [PATCH v3] colibri_vf: Add board_usb_phy_mode function
  2015-10-30 13:20       ` Marek Vasut
@ 2015-11-06  7:00         ` maitysanchayan at gmail.com
  2015-11-06 15:00           ` Marek Vasut
  0 siblings, 1 reply; 36+ messages in thread
From: maitysanchayan at gmail.com @ 2015-11-06  7:00 UTC (permalink / raw)
  To: u-boot

On 15-10-30 14:20:29, Marek Vasut wrote:
> On Friday, October 30, 2015 at 01:26:59 PM, Sanchayan Maity wrote:
> > 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.
> > 
> > Signed-off-by: Sanchayan Maity <maitysanchayan@gmail.com>
> > ---
> > 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(-)
> > 
> > diff --git a/board/toradex/colibri_vf/colibri_vf.c
> > b/board/toradex/colibri_vf/colibri_vf.c index a6d1c5b..9878671 100644
> > --- a/board/toradex/colibri_vf/colibri_vf.c
> > +++ b/board/toradex/colibri_vf/colibri_vf.c
> > @@ -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);
> 
> 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.

> 
> > +		break;
> > +	case 1:
> > +		return USB_INIT_HOST;
> > +		break;
> > +	default:
> > +		return USB_INIT_HOST;
> > +		break;
> > +	}
> > +}
> >  #endif

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

* [U-Boot] [PATCH v3] colibri_vf: Add board_usb_phy_mode function
  2015-11-06  7:00         ` maitysanchayan at gmail.com
@ 2015-11-06 15:00           ` Marek Vasut
  0 siblings, 0 replies; 36+ messages in thread
From: Marek Vasut @ 2015-11-06 15:00 UTC (permalink / raw)
  To: u-boot

On Friday, November 06, 2015 at 08:00:01 AM, maitysanchayan at gmail.com wrote:
> On 15-10-30 14:20:29, Marek Vasut wrote:
> > On Friday, October 30, 2015 at 01:26:59 PM, Sanchayan Maity wrote:
> > > 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.
> > > 
> > > Signed-off-by: Sanchayan Maity <maitysanchayan@gmail.com>
> > > ---
> > > 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(-)
> > > 
> > > diff --git a/board/toradex/colibri_vf/colibri_vf.c
> > > b/board/toradex/colibri_vf/colibri_vf.c index a6d1c5b..9878671 100644
> > > --- a/board/toradex/colibri_vf/colibri_vf.c
> > > +++ b/board/toradex/colibri_vf/colibri_vf.c
> > > @@ -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);
> > 
> > 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.

Yeah, no problem, I can relate to that.

> 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.

> 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.

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

Thanks!

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

* [U-Boot] [PATCH v4] colibri_vf: Add board_usb_phy_mode function
  2015-10-30 12:26     ` [U-Boot] [PATCH v3] " Sanchayan Maity
  2015-10-30 13:20       ` Marek Vasut
  2015-10-30 16:12       ` Stefan Agner
@ 2015-11-09 14:59       ` Sanchayan Maity
  2015-11-09 15:22         ` Marek Vasut
  2015-11-12  6:17         ` [U-Boot] [PATCH v5] " Sanchayan Maity
  2 siblings, 2 replies; 36+ messages in thread
From: Sanchayan Maity @ 2015-11-09 14:59 UTC (permalink / raw)
  To: u-boot

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.

Signed-off-by: Sanchayan Maity <maitysanchayan@gmail.com>
---
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(-)

diff --git a/board/toradex/colibri_vf/colibri_vf.c b/board/toradex/colibri_vf/colibri_vf.c
index a6d1c5b..b1a3375 100644
--- a/board/toradex/colibri_vf/colibri_vf.c
+++ b/board/toradex/colibri_vf/colibri_vf.c
@@ -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
-- 
2.6.2

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

* [U-Boot] [PATCH v4] colibri_vf: Add board_usb_phy_mode function
  2015-11-09 14:59       ` [U-Boot] [PATCH v4] " Sanchayan Maity
@ 2015-11-09 15:22         ` Marek Vasut
  2015-11-12  6:17         ` [U-Boot] [PATCH v5] " Sanchayan Maity
  1 sibling, 0 replies; 36+ messages in thread
From: Marek Vasut @ 2015-11-09 15:22 UTC (permalink / raw)
  To: u-boot

On Monday, November 09, 2015 at 03:59:56 PM, Sanchayan Maity wrote:
> 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.
> 
> Signed-off-by: Sanchayan Maity <maitysanchayan@gmail.com>
> ---
> 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(-)
> 
> diff --git a/board/toradex/colibri_vf/colibri_vf.c
> b/board/toradex/colibri_vf/colibri_vf.c index a6d1c5b..b1a3375 100644
> --- a/board/toradex/colibri_vf/colibri_vf.c
> +++ b/board/toradex/colibri_vf/colibri_vf.c
> @@ -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;


You don't have to break after return.

> +	case 1:
> +		/* Port 1 is used only in host mode on Colibri Vybrid modules */
> +		return USB_INIT_HOST;
> +		break;

DTTO

> +	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.

> +	}
> +}
>  #endif

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

* [U-Boot] [PATCH v5] colibri_vf: Add board_usb_phy_mode function
  2015-11-09 14:59       ` [U-Boot] [PATCH v4] " Sanchayan Maity
  2015-11-09 15:22         ` Marek Vasut
@ 2015-11-12  6:17         ` Sanchayan Maity
  2015-11-24 10:23           ` maitysanchayan at gmail.com
  1 sibling, 1 reply; 36+ messages in thread
From: Sanchayan Maity @ 2015-11-12  6:17 UTC (permalink / raw)
  To: u-boot

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.

Signed-off-by: Sanchayan Maity <maitysanchayan@gmail.com>
---
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(-)

diff --git a/board/toradex/colibri_vf/colibri_vf.c b/board/toradex/colibri_vf/colibri_vf.c
index a6d1c5b..c65ccb3 100644
--- a/board/toradex/colibri_vf/colibri_vf.c
+++ b/board/toradex/colibri_vf/colibri_vf.c
@@ -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
-- 
2.6.2

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

* [U-Boot] [PATCH v5] colibri_vf: Add board_usb_phy_mode function
  2015-11-12  6:17         ` [U-Boot] [PATCH v5] " Sanchayan Maity
@ 2015-11-24 10:23           ` maitysanchayan at gmail.com
  2015-11-24 10:30             ` Marek Vasut
  2015-11-24 10:37             ` Stefano Babic
  0 siblings, 2 replies; 36+ messages in thread
From: maitysanchayan at gmail.com @ 2015-11-24 10:23 UTC (permalink / raw)
  To: u-boot

Hello,

Ping?

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

Thanks.

Regards,
Sanchayan.

On 15-11-12 11:47:35, Sanchayan Maity wrote:
> 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.
> 
> Signed-off-by: Sanchayan Maity <maitysanchayan@gmail.com>
> ---
> 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(-)
> 
> diff --git a/board/toradex/colibri_vf/colibri_vf.c b/board/toradex/colibri_vf/colibri_vf.c
> index a6d1c5b..c65ccb3 100644
> --- a/board/toradex/colibri_vf/colibri_vf.c
> +++ b/board/toradex/colibri_vf/colibri_vf.c
> @@ -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
> -- 
> 2.6.2
> 

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

* [U-Boot] [PATCH v5] colibri_vf: Add board_usb_phy_mode function
  2015-11-24 10:23           ` maitysanchayan at gmail.com
@ 2015-11-24 10:30             ` Marek Vasut
  2015-11-24 10:37             ` Stefano Babic
  1 sibling, 0 replies; 36+ messages in thread
From: Marek Vasut @ 2015-11-24 10:30 UTC (permalink / raw)
  To: u-boot

On Tuesday, November 24, 2015 at 11:23:04 AM, maitysanchayan at gmail.com wrote:
> 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

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

* [U-Boot] [PATCH v5] colibri_vf: Add board_usb_phy_mode function
  2015-11-24 10:23           ` maitysanchayan at gmail.com
  2015-11-24 10:30             ` Marek Vasut
@ 2015-11-24 10:37             ` Stefano Babic
  2015-11-24 10:38               ` maitysanchayan at gmail.com
  2016-01-07 20:02               ` maitysanchayan at gmail.com
  1 sibling, 2 replies; 36+ messages in thread
From: Stefano Babic @ 2015-11-24 10:37 UTC (permalink / raw)
  To: u-boot

On 24/11/2015 11:23, maitysanchayan at gmail.com wrote:
> Hello,
> 
> Ping?
> 
> Any further feedback? Is the patchset good to get accepted?

I'll pick it up

Best regards,
Stefano Babic

> 
> Thanks.
> 
> Regards,
> Sanchayan.
> 
> On 15-11-12 11:47:35, Sanchayan Maity wrote:
>> 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.
>>
>> Signed-off-by: Sanchayan Maity <maitysanchayan@gmail.com>
>> ---
>> 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(-)
>>
>> diff --git a/board/toradex/colibri_vf/colibri_vf.c b/board/toradex/colibri_vf/colibri_vf.c
>> index a6d1c5b..c65ccb3 100644
>> --- a/board/toradex/colibri_vf/colibri_vf.c
>> +++ b/board/toradex/colibri_vf/colibri_vf.c
>> @@ -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
>> -- 
>> 2.6.2
>>


-- 
=====================================================================
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
=====================================================================

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

* [U-Boot] [PATCH v5] colibri_vf: Add board_usb_phy_mode function
  2015-11-24 10:37             ` Stefano Babic
@ 2015-11-24 10:38               ` maitysanchayan at gmail.com
  2016-01-07 20:02               ` maitysanchayan at gmail.com
  1 sibling, 0 replies; 36+ messages in thread
From: maitysanchayan at gmail.com @ 2015-11-24 10:38 UTC (permalink / raw)
  To: u-boot

On 15-11-24 11:37:59, Stefano Babic wrote:
> On 24/11/2015 11:23, maitysanchayan at gmail.com wrote:
> > Hello,
> > 
> > Ping?
> > 
> > Any further feedback? Is the patchset good to get accepted?
> 
> I'll pick it up

Thanks.

- Sanchayan.

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

* [U-Boot] [PATCH v5] colibri_vf: Add board_usb_phy_mode function
  2015-11-24 10:37             ` Stefano Babic
  2015-11-24 10:38               ` maitysanchayan at gmail.com
@ 2016-01-07 20:02               ` maitysanchayan at gmail.com
  2016-01-07 21:12                 ` Stefano Babic
  1 sibling, 1 reply; 36+ messages in thread
From: maitysanchayan at gmail.com @ 2016-01-07 20:02 UTC (permalink / raw)
  To: u-boot

Hello Stefano,

Ping?

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

- Sanchayan.

On 15-11-24 11:37:59, Stefano Babic wrote:
> On 24/11/2015 11:23, maitysanchayan at gmail.com wrote:
> > Hello,
> > 
> > Ping?
> > 
> > Any further feedback? Is the patchset good to get accepted?
> 
> I'll pick it up
> 
> Best regards,
> Stefano Babic
> 
> > 
> > Thanks.
> > 
> > Regards,
> > Sanchayan.
> > 
> > On 15-11-12 11:47:35, Sanchayan Maity wrote:
> >> 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.
> >>
> >> Signed-off-by: Sanchayan Maity <maitysanchayan@gmail.com>
> >> ---
> >> 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(-)
> >>
> >> diff --git a/board/toradex/colibri_vf/colibri_vf.c b/board/toradex/colibri_vf/colibri_vf.c
> >> index a6d1c5b..c65ccb3 100644
> >> --- a/board/toradex/colibri_vf/colibri_vf.c
> >> +++ b/board/toradex/colibri_vf/colibri_vf.c
> >> @@ -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
> >> -- 
> >> 2.6.2
> >>
> 
> 
> -- 
> =====================================================================
> 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
> =====================================================================

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

* [U-Boot] [PATCH v5] colibri_vf: Add board_usb_phy_mode function
  2016-01-07 20:02               ` maitysanchayan at gmail.com
@ 2016-01-07 21:12                 ` Stefano Babic
  2016-01-08  5:50                   ` maitysanchayan at gmail.com
  0 siblings, 1 reply; 36+ messages in thread
From: Stefano Babic @ 2016-01-07 21:12 UTC (permalink / raw)
  To: u-boot

Hi,

On 07/01/2016 21:02, maitysanchayan at gmail.com wrote:
> 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 <maitysanchayan@gmail.com>
Date:   Thu Nov 12 11:47:35 2015 +0530

    colibri_vf: Add board_usb_phy_mode function

Regards,
Stefano

> - Sanchayan.
> 
> On 15-11-24 11:37:59, Stefano Babic wrote:
>> On 24/11/2015 11:23, maitysanchayan at gmail.com wrote:
>>> Hello,
>>>
>>> Ping?
>>>
>>> Any further feedback? Is the patchset good to get accepted?
>>
>> I'll pick it up
>>
>> Best regards,
>> Stefano Babic
>>
>>>
>>> Thanks.
>>>
>>> Regards,
>>> Sanchayan.
>>>
>>> On 15-11-12 11:47:35, Sanchayan Maity wrote:
>>>> 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.
>>>>
>>>> Signed-off-by: Sanchayan Maity <maitysanchayan@gmail.com>
>>>> ---
>>>> 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(-)
>>>>
>>>> diff --git a/board/toradex/colibri_vf/colibri_vf.c b/board/toradex/colibri_vf/colibri_vf.c
>>>> index a6d1c5b..c65ccb3 100644
>>>> --- a/board/toradex/colibri_vf/colibri_vf.c
>>>> +++ b/board/toradex/colibri_vf/colibri_vf.c
>>>> @@ -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
>>>> -- 
>>>> 2.6.2
>>>>
>>
>>
>> -- 
>> =====================================================================
>> 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
>> =====================================================================

-- 
=====================================================================
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
=====================================================================

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

* [U-Boot] [PATCH v5] colibri_vf: Add board_usb_phy_mode function
  2016-01-07 21:12                 ` Stefano Babic
@ 2016-01-08  5:50                   ` maitysanchayan at gmail.com
  2016-01-08 12:11                     ` Marek Vasut
  0 siblings, 1 reply; 36+ messages in thread
From: maitysanchayan at gmail.com @ 2016-01-08  5:50 UTC (permalink / raw)
  To: u-boot

Hello,

On 16-01-07 22:12:29, Stefano Babic wrote:
> Hi,
> 
> On 07/01/2016 21:02, maitysanchayan at gmail.com wrote:
> > 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 <maitysanchayan@gmail.com>
> 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.

> 
> Regards,
> Stefano
> 
> > - Sanchayan.
> > 
> > On 15-11-24 11:37:59, Stefano Babic wrote:
> >> On 24/11/2015 11:23, maitysanchayan at gmail.com wrote:
> >>> Hello,
> >>>
> >>> Ping?
> >>>
> >>> Any further feedback? Is the patchset good to get accepted?
> >>
> >> I'll pick it up
> >>
> >> Best regards,
> >> Stefano Babic
> >>
> >>>
> >>> Thanks.
> >>>
> >>> Regards,
> >>> Sanchayan.
> >>>
> >>> On 15-11-12 11:47:35, Sanchayan Maity wrote:
> >>>> 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.
> >>>>
> >>>> Signed-off-by: Sanchayan Maity <maitysanchayan@gmail.com>
> >>>> ---
> >>>> 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(-)
> >>>>
> >>>> diff --git a/board/toradex/colibri_vf/colibri_vf.c b/board/toradex/colibri_vf/colibri_vf.c
> >>>> index a6d1c5b..c65ccb3 100644
> >>>> --- a/board/toradex/colibri_vf/colibri_vf.c
> >>>> +++ b/board/toradex/colibri_vf/colibri_vf.c
> >>>> @@ -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
> >>>> -- 
> >>>> 2.6.2
> >>>>
> >>
> >>
> >> -- 
> >> =====================================================================
> >> 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
> >> =====================================================================
> 
> -- 
> =====================================================================
> 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
> =====================================================================

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

* [U-Boot] [PATCH v5] colibri_vf: Add board_usb_phy_mode function
  2016-01-08  5:50                   ` maitysanchayan at gmail.com
@ 2016-01-08 12:11                     ` Marek Vasut
  2016-01-08 12:18                       ` maitysanchayan at gmail.com
  0 siblings, 1 reply; 36+ messages in thread
From: Marek Vasut @ 2016-01-08 12:11 UTC (permalink / raw)
  To: u-boot

On Friday, January 08, 2016 at 06:50:41 AM, maitysanchayan at gmail.com wrote:
> Hello,
> 
> On 16-01-07 22:12:29, Stefano Babic wrote:
> > Hi,
> > 
> > On 07/01/2016 21:02, maitysanchayan at gmail.com wrote:
> > > 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 <maitysanchayan@gmail.com>
> > 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

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

* [U-Boot] [PATCH v5] colibri_vf: Add board_usb_phy_mode function
  2016-01-08 12:11                     ` Marek Vasut
@ 2016-01-08 12:18                       ` maitysanchayan at gmail.com
  2016-01-08 12:25                         ` Marek Vasut
  0 siblings, 1 reply; 36+ messages in thread
From: maitysanchayan at gmail.com @ 2016-01-08 12:18 UTC (permalink / raw)
  To: u-boot

On 16-01-08 13:11:27, Marek Vasut wrote:
> On Friday, January 08, 2016 at 06:50:41 AM, maitysanchayan at gmail.com wrote:
> > Hello,
> > 
> > On 16-01-07 22:12:29, Stefano Babic wrote:
> > > Hi,
> > > 
> > > On 07/01/2016 21:02, maitysanchayan at gmail.com wrote:
> > > > 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 <maitysanchayan@gmail.com>
> > > 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 ... ?

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.

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

* [U-Boot] [PATCH 1/3] usb: host: ehci-vf: Remove hardcoded USB host client configuration
  2015-10-26 12:58 [U-Boot] [PATCH 1/3] usb: host: ehci-vf: Remove hardcoded USB host client configuration Sanchayan Maity
                   ` (2 preceding siblings ...)
  2015-10-26 19:19 ` [U-Boot] [PATCH 1/3] usb: host: ehci-vf: Remove hardcoded USB host client configuration Marek Vasut
@ 2016-01-08 12:20 ` maitysanchayan at gmail.com
  2016-01-08 12:26   ` Marek Vasut
  2016-01-08 14:02   ` Marek Vasut
  3 siblings, 2 replies; 36+ messages in thread
From: maitysanchayan at gmail.com @ 2016-01-08 12:20 UTC (permalink / raw)
  To: u-boot

Hello Stefano / Marek,

Can you pick this up? 

- Sanchayan.

On 15-10-26 18:28:49, Sanchayan Maity wrote:
> The current ehci-vf USB driver for Vybrid hardcodes the USB host
> and client functionality. Remove this.
> 
> Reported-by: Santhosh Kumar Janardhanam <santhosh.kj@hcl.com>
> Signed-off-by: Sanchayan Maity <maitysanchayan@gmail.com>
> ---
>  drivers/usb/host/ehci-vf.c | 5 -----
>  1 file changed, 5 deletions(-)
> 
> diff --git a/drivers/usb/host/ehci-vf.c b/drivers/usb/host/ehci-vf.c
> index 98e0fc6..351e0fb 100644
> --- a/drivers/usb/host/ehci-vf.c
> +++ b/drivers/usb/host/ehci-vf.c
> @@ -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 */
> -- 
> 2.6.2
> 

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

* [U-Boot] [PATCH 2/3] usb: host: ehci-vf: Implement board_usb_phy_mode weak function
  2015-10-26 12:58 ` [U-Boot] [PATCH 2/3] usb: host: ehci-vf: Implement board_usb_phy_mode weak function Sanchayan Maity
@ 2016-01-08 12:22   ` maitysanchayan at gmail.com
  2016-01-08 14:02     ` Marek Vasut
  0 siblings, 1 reply; 36+ messages in thread
From: maitysanchayan at gmail.com @ 2016-01-08 12:22 UTC (permalink / raw)
  To: u-boot

Hello Stefano / Marek,

Can you pick this up?

- Sanchayan.

On 15-10-26 18:28:50, Sanchayan Maity wrote:
> 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.
> 
> Signed-off-by: Sanchayan Maity <maitysanchayan@gmail.com>
> ---
> 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(+)
> 
> diff --git a/drivers/usb/host/ehci-vf.c b/drivers/usb/host/ehci-vf.c
> index 351e0fb..335e303 100644
> --- a/drivers/usb/host/ehci-vf.c
> +++ b/drivers/usb/host/ehci-vf.c
> @@ -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);
> -- 
> 2.6.2
> 

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

* [U-Boot] [PATCH v5] colibri_vf: Add board_usb_phy_mode function
  2016-01-08 12:18                       ` maitysanchayan at gmail.com
@ 2016-01-08 12:25                         ` Marek Vasut
  0 siblings, 0 replies; 36+ messages in thread
From: Marek Vasut @ 2016-01-08 12:25 UTC (permalink / raw)
  To: u-boot

On Friday, January 08, 2016 at 01:18:46 PM, maitysanchayan at gmail.com wrote:
> On 16-01-08 13:11:27, Marek Vasut wrote:
> > On Friday, January 08, 2016 at 06:50:41 AM, maitysanchayan at gmail.com wrote:
> > > Hello,
> > > 
> > > On 16-01-07 22:12:29, Stefano Babic wrote:
> > > > Hi,
> > > > 
> > > > On 07/01/2016 21:02, maitysanchayan at gmail.com wrote:
> > > > > 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 <maitysanchayan@gmail.com>
> > > > 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 ...
> > ?
> 
> 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

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

* [U-Boot] [PATCH 1/3] usb: host: ehci-vf: Remove hardcoded USB host client configuration
  2016-01-08 12:20 ` maitysanchayan at gmail.com
@ 2016-01-08 12:26   ` Marek Vasut
  2016-01-08 12:26     ` maitysanchayan at gmail.com
  2016-01-08 14:02   ` Marek Vasut
  1 sibling, 1 reply; 36+ messages in thread
From: Marek Vasut @ 2016-01-08 12:26 UTC (permalink / raw)
  To: u-boot

On Friday, January 08, 2016 at 01:20:23 PM, maitysanchayan at gmail.com wrote:
> Hello Stefano / Marek,
> 
> Can you pick this up?

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

> - Sanchayan.
> 
> On 15-10-26 18:28:49, Sanchayan Maity wrote:
> > The current ehci-vf USB driver for Vybrid hardcodes the USB host
> > and client functionality. Remove this.
> > 
> > Reported-by: Santhosh Kumar Janardhanam <santhosh.kj@hcl.com>
> > Signed-off-by: Sanchayan Maity <maitysanchayan@gmail.com>
> > ---
> > 
> >  drivers/usb/host/ehci-vf.c | 5 -----
> >  1 file changed, 5 deletions(-)
> > 
> > diff --git a/drivers/usb/host/ehci-vf.c b/drivers/usb/host/ehci-vf.c
> > index 98e0fc6..351e0fb 100644
> > --- a/drivers/usb/host/ehci-vf.c
> > +++ b/drivers/usb/host/ehci-vf.c
> > @@ -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 */

Best regards,
Marek Vasut

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

* [U-Boot] [PATCH 1/3] usb: host: ehci-vf: Remove hardcoded USB host client configuration
  2016-01-08 12:26   ` Marek Vasut
@ 2016-01-08 12:26     ` maitysanchayan at gmail.com
  0 siblings, 0 replies; 36+ messages in thread
From: maitysanchayan at gmail.com @ 2016-01-08 12:26 UTC (permalink / raw)
  To: u-boot

Hello Marek,

On 16-01-08 13:26:32, Marek Vasut wrote:
> On Friday, January 08, 2016 at 01:20:23 PM, maitysanchayan at gmail.com wrote:
> > Hello Stefano / Marek,
> > 
> > Can you pick this up?
> 
> I can, but only for next. Is that fine ?

Yes it's fine. Thank you.

- Sanchayan.

> > 
> > On 15-10-26 18:28:49, Sanchayan Maity wrote:
> > > The current ehci-vf USB driver for Vybrid hardcodes the USB host
> > > and client functionality. Remove this.
> > > 
> > > Reported-by: Santhosh Kumar Janardhanam <santhosh.kj@hcl.com>
> > > Signed-off-by: Sanchayan Maity <maitysanchayan@gmail.com>
> > > ---
> > > 
> > >  drivers/usb/host/ehci-vf.c | 5 -----
> > >  1 file changed, 5 deletions(-)
> > > 
> > > diff --git a/drivers/usb/host/ehci-vf.c b/drivers/usb/host/ehci-vf.c
> > > index 98e0fc6..351e0fb 100644
> > > --- a/drivers/usb/host/ehci-vf.c
> > > +++ b/drivers/usb/host/ehci-vf.c
> > > @@ -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 */
> 
> Best regards,
> Marek Vasut

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

* [U-Boot] [PATCH 1/3] usb: host: ehci-vf: Remove hardcoded USB host client configuration
  2016-01-08 12:20 ` maitysanchayan at gmail.com
  2016-01-08 12:26   ` Marek Vasut
@ 2016-01-08 14:02   ` Marek Vasut
  1 sibling, 0 replies; 36+ messages in thread
From: Marek Vasut @ 2016-01-08 14:02 UTC (permalink / raw)
  To: u-boot

On Friday, January 08, 2016 at 01:20:23 PM, maitysanchayan at gmail.com wrote:
> Hello Stefano / Marek,
> 
> Can you pick this up?
> 

Applied, will be in next MW.

Best regards,
Marek Vasut

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

* [U-Boot] [PATCH 2/3] usb: host: ehci-vf: Implement board_usb_phy_mode weak function
  2016-01-08 12:22   ` maitysanchayan at gmail.com
@ 2016-01-08 14:02     ` Marek Vasut
  0 siblings, 0 replies; 36+ messages in thread
From: Marek Vasut @ 2016-01-08 14:02 UTC (permalink / raw)
  To: u-boot

On Friday, January 08, 2016 at 01:22:07 PM, maitysanchayan at gmail.com wrote:
> Hello Stefano / Marek,
> 
> Can you pick this up?
> 
> - Sanchayan.
> 

Applied.

Best regards,
Marek Vasut

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

end of thread, other threads:[~2016-01-08 14:02 UTC | newest]

Thread overview: 36+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-10-26 12:58 [U-Boot] [PATCH 1/3] usb: host: ehci-vf: Remove hardcoded USB host client configuration Sanchayan Maity
2015-10-26 12:58 ` [U-Boot] [PATCH 2/3] usb: host: ehci-vf: Implement board_usb_phy_mode weak function Sanchayan Maity
2016-01-08 12:22   ` maitysanchayan at gmail.com
2016-01-08 14:02     ` Marek Vasut
2015-10-26 12:58 ` [U-Boot] [PATCH 3/3] colibri_vf: Add board_usb_phy_mode function Sanchayan Maity
2015-10-27  9:18   ` Marek Vasut
2015-10-27 11:34     ` maitysanchayan at gmail.com
2015-10-29 10:15   ` [U-Boot] [PATCH v2] " Sanchayan Maity
2015-10-29 17:25     ` Marek Vasut
2015-10-30 12:26     ` [U-Boot] [PATCH v3] " Sanchayan Maity
2015-10-30 13:20       ` Marek Vasut
2015-11-06  7:00         ` maitysanchayan at gmail.com
2015-11-06 15:00           ` Marek Vasut
2015-10-30 16:12       ` Stefan Agner
2015-10-30 16:24         ` Marek Vasut
2015-10-30 16:26           ` Stefan Agner
2015-10-30 17:07             ` Marek Vasut
2015-11-09 14:59       ` [U-Boot] [PATCH v4] " Sanchayan Maity
2015-11-09 15:22         ` Marek Vasut
2015-11-12  6:17         ` [U-Boot] [PATCH v5] " Sanchayan Maity
2015-11-24 10:23           ` maitysanchayan at gmail.com
2015-11-24 10:30             ` Marek Vasut
2015-11-24 10:37             ` Stefano Babic
2015-11-24 10:38               ` maitysanchayan at gmail.com
2016-01-07 20:02               ` maitysanchayan at gmail.com
2016-01-07 21:12                 ` Stefano Babic
2016-01-08  5:50                   ` maitysanchayan at gmail.com
2016-01-08 12:11                     ` Marek Vasut
2016-01-08 12:18                       ` maitysanchayan at gmail.com
2016-01-08 12:25                         ` Marek Vasut
2015-10-26 19:19 ` [U-Boot] [PATCH 1/3] usb: host: ehci-vf: Remove hardcoded USB host client configuration Marek Vasut
2015-10-27  3:28   ` maitysanchayan at gmail.com
2016-01-08 12:20 ` maitysanchayan at gmail.com
2016-01-08 12:26   ` Marek Vasut
2016-01-08 12:26     ` maitysanchayan at gmail.com
2016-01-08 14:02   ` Marek Vasut

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.