[U-Boot] [PATCH 2/3] usb: host: ehci-vf: Implement board_usb_phy_mode weak function

maitysanchayan at gmail.com
2016-01-08T12:22:07Z

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
>