diff mbox series

[U-Boot,RFC,1/6] odroid: exynos: USB initialization on the U3/X2

Message ID 20190401115232.453-2-linux.amoon@gmail.com
State RFC
Delegated to: Lukasz Majewski
Headers show
Series Odroid U3 usb initialization | expand

Commit Message

Anand Moon April 1, 2019, 11:52 a.m. UTC
From: Tobias Jakobi <tjakobi@math.uni-bielefeld.de>

Rename board_usb_init() to exynos_usb_init() and call it
early in the Exynos EHCI driver when probing.

This kind of works. After a 'usb start; usb stop; usb start'
cycle the attached devices are recognized.

Add small delay between gpio_direction_output to stable
initialization of usb gpio pins.

Signed-off-by: Tobias Jakobi <tjakobi@math.uni-bielefeld.de>
Signed-off-by: Anand Moon <linux.amoon@gmail.com>
---
Reoder the exynos_usb_init so that "usb start" command initialization
correcly.
---
---
 board/samsung/odroid/odroid.c  | 14 +++++++++-----
 drivers/usb/host/ehci-exynos.c |  7 +++++++
 2 files changed, 16 insertions(+), 5 deletions(-)

Comments

Krzysztof Kozlowski April 1, 2019, 12:48 p.m. UTC | #1
On Mon, 1 Apr 2019 at 13:52, Anand Moon <linux.amoon@gmail.com> wrote:
>
> From: Tobias Jakobi <tjakobi@math.uni-bielefeld.de>
>
> Rename board_usb_init() to exynos_usb_init() and call it
> early in the Exynos EHCI driver when probing.
>
> This kind of works. After a 'usb start; usb stop; usb start'
> cycle the attached devices are recognized.
>
> Add small delay between gpio_direction_output to stable
> initialization of usb gpio pins.
>
> Signed-off-by: Tobias Jakobi <tjakobi@math.uni-bielefeld.de>
> Signed-off-by: Anand Moon <linux.amoon@gmail.com>
> ---
> Reoder the exynos_usb_init so that "usb start" command initialization
> correcly.
> ---
> ---
>  board/samsung/odroid/odroid.c  | 14 +++++++++-----
>  drivers/usb/host/ehci-exynos.c |  7 +++++++
>  2 files changed, 16 insertions(+), 5 deletions(-)
>
> diff --git a/board/samsung/odroid/odroid.c b/board/samsung/odroid/odroid.c
> index 3e594fd850..79d14ead01 100644
> --- a/board/samsung/odroid/odroid.c
> +++ b/board/samsung/odroid/odroid.c
> @@ -468,8 +468,6 @@ struct dwc2_plat_otg_data s5pc210_otg_data = {
>  };
>  #endif
>
> -#if defined(CONFIG_USB_GADGET) || defined(CONFIG_CMD_USB)
> -
>  static void set_usb3503_ref_clk(void)
>  {
>  #ifdef CONFIG_BOARD_TYPES
> @@ -490,9 +488,8 @@ static void set_usb3503_ref_clk(void)
>  #endif /* CONFIG_BOARD_TYPES */
>  }
>
> -int board_usb_init(int index, enum usb_init_type init)
> +int exynos_usb_init(void)
>  {
> -#ifdef CONFIG_CMD_USB
>         struct udevice *dev;
>         int ret;
>
> @@ -501,6 +498,7 @@ int board_usb_init(int index, enum usb_init_type init)
>         /* Disconnect, Reset, Connect */
>         gpio_direction_output(EXYNOS4X12_GPIO_X34, 0);
>         gpio_direction_output(EXYNOS4X12_GPIO_X35, 0);
> +       sdelay(200000);

This should be a separate patch with its own explanation.

>         gpio_direction_output(EXYNOS4X12_GPIO_X35, 1);
>         gpio_direction_output(EXYNOS4X12_GPIO_X34, 1);
>
> @@ -530,7 +528,13 @@ int board_usb_init(int index, enum usb_init_type init)
>                 pr_err("Regulator %s value setting error: %d\n", dev->name, ret);
>                 return ret;
>         }
> -#endif
> +
> +       return 0;
> +}
> +
> +#ifdef CONFIG_USB_GADGET
> +int board_usb_init(int index, enum usb_init_type init)
> +{
>         debug("USB_udc_probe\n");
>         return dwc2_udc_probe(&s5pc210_otg_data);
>  }
> diff --git a/drivers/usb/host/ehci-exynos.c b/drivers/usb/host/ehci-exynos.c
> index fabc662eb6..b0f7bd4936 100644
> --- a/drivers/usb/host/ehci-exynos.c
> +++ b/drivers/usb/host/ehci-exynos.c
> @@ -31,6 +31,8 @@ struct exynos_ehci_platdata {
>         struct gpio_desc vbus_gpio;
>  };
>
> +extern int exynos_usb_init(void);
> +
>  /**
>   * Contains pointers to register base addresses
>   * for the usb controller.
> @@ -152,6 +154,11 @@ static void exynos4412_setup_usb_phy(struct exynos4412_usb_phy *usb)
>         setbits_le32(&usb->usbphyrstcon, (RSTCON_HOSTPHY_SWRST | RSTCON_SWRST));
>         udelay(10);
>         clrbits_le32(&usb->usbphyrstcon, (RSTCON_HOSTPHY_SWRST | RSTCON_SWRST));
> +
> +       /*
> +        * "usb start" initialize the usb driver
> +        */
> +       exynos_usb_init();

It should be something more generic like
CONFIG_SYS_USB_OHCI_BOARD_INIT which calls board_usb_init()... but it
still will be calling board code from the driver. Why do you need this
in the first place?

Best regards,
Krzysztof
Lukasz Majewski April 1, 2019, 12:57 p.m. UTC | #2
Hi Anand,

> From: Tobias Jakobi <tjakobi@math.uni-bielefeld.de>
> 
> Rename board_usb_init() to exynos_usb_init() and call it
> early in the Exynos EHCI driver when probing.
> 
> This kind of works. After a 'usb start; usb stop; usb start'
> cycle the attached devices are recognized.
> 
> Add small delay between gpio_direction_output to stable
> initialization of usb gpio pins.
> 
> Signed-off-by: Tobias Jakobi <tjakobi@math.uni-bielefeld.de>
> Signed-off-by: Anand Moon <linux.amoon@gmail.com>
> ---
> Reoder the exynos_usb_init so that "usb start" command initialization
> correcly.
> ---
> ---
>  board/samsung/odroid/odroid.c  | 14 +++++++++-----
>  drivers/usb/host/ehci-exynos.c |  7 +++++++
>  2 files changed, 16 insertions(+), 5 deletions(-)
> 
> diff --git a/board/samsung/odroid/odroid.c
> b/board/samsung/odroid/odroid.c index 3e594fd850..79d14ead01 100644
> --- a/board/samsung/odroid/odroid.c
> +++ b/board/samsung/odroid/odroid.c
> @@ -468,8 +468,6 @@ struct dwc2_plat_otg_data s5pc210_otg_data = {
>  };
>  #endif
>  
> -#if defined(CONFIG_USB_GADGET) || defined(CONFIG_CMD_USB)
> -
>  static void set_usb3503_ref_clk(void)
>  {
>  #ifdef CONFIG_BOARD_TYPES
> @@ -490,9 +488,8 @@ static void set_usb3503_ref_clk(void)
>  #endif /* CONFIG_BOARD_TYPES */
>  }
>  
> -int board_usb_init(int index, enum usb_init_type init)
> +int exynos_usb_init(void)
>  {
> -#ifdef CONFIG_CMD_USB
>  	struct udevice *dev;
>  	int ret;
>  
> @@ -501,6 +498,7 @@ int board_usb_init(int index, enum usb_init_type
> init) /* Disconnect, Reset, Connect */
>  	gpio_direction_output(EXYNOS4X12_GPIO_X34, 0);
>  	gpio_direction_output(EXYNOS4X12_GPIO_X35, 0);
> +	sdelay(200000);
>  	gpio_direction_output(EXYNOS4X12_GPIO_X35, 1);
>  	gpio_direction_output(EXYNOS4X12_GPIO_X34, 1);
>  
> @@ -530,7 +528,13 @@ int board_usb_init(int index, enum usb_init_type
> init) pr_err("Regulator %s value setting error: %d\n", dev->name,
> ret); return ret;
>  	}
> -#endif
> +
> +	return 0;
> +}
> +
> +#ifdef CONFIG_USB_GADGET
> +int board_usb_init(int index, enum usb_init_type init)

We are not allowed to add board_usb_* code anymore. The _only_ way to
update/fix the USB gadget code is to convert it to driver model [DM] and
describe it via DTS.

Please consider converting this code to DM/DTS.

> +{
>  	debug("USB_udc_probe\n");
>  	return dwc2_udc_probe(&s5pc210_otg_data);
>  }
> diff --git a/drivers/usb/host/ehci-exynos.c
> b/drivers/usb/host/ehci-exynos.c index fabc662eb6..b0f7bd4936 100644
> --- a/drivers/usb/host/ehci-exynos.c
> +++ b/drivers/usb/host/ehci-exynos.c
> @@ -31,6 +31,8 @@ struct exynos_ehci_platdata {
>  	struct gpio_desc vbus_gpio;
>  };
>  
> +extern int exynos_usb_init(void);
> +
>  /**
>   * Contains pointers to register base addresses
>   * for the usb controller.
> @@ -152,6 +154,11 @@ static void exynos4412_setup_usb_phy(struct
> exynos4412_usb_phy *usb) setbits_le32(&usb->usbphyrstcon,
> (RSTCON_HOSTPHY_SWRST | RSTCON_SWRST)); udelay(10);
>  	clrbits_le32(&usb->usbphyrstcon, (RSTCON_HOSTPHY_SWRST |
> RSTCON_SWRST)); +
> +	/*
> +	 * "usb start" initialize the usb driver
> +	 */
> +	exynos_usb_init();
>  }
>  
>  static void setup_usb_phy(struct exynos_usb_phy *usb)




Best regards,

Lukasz Majewski

--

DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-59 Fax: (+49)-8142-66989-80 Email: lukma@denx.de
Jack Mitchell April 1, 2019, 1:22 p.m. UTC | #3
On 01/04/2019 13:57, Lukasz Majewski wrote:
> Hi Anand,
> 
>> From: Tobias Jakobi <tjakobi@math.uni-bielefeld.de>
>>
>> Rename board_usb_init() to exynos_usb_init() and call it
>> early in the Exynos EHCI driver when probing.
>>
>> This kind of works. After a 'usb start; usb stop; usb start'
>> cycle the attached devices are recognized.
>>
>> Add small delay between gpio_direction_output to stable
>> initialization of usb gpio pins.
>>
>> Signed-off-by: Tobias Jakobi <tjakobi@math.uni-bielefeld.de>
>> Signed-off-by: Anand Moon <linux.amoon@gmail.com>
>> ---
>> Reoder the exynos_usb_init so that "usb start" command initialization
>> correcly.
>> ---
>> ---
>>  board/samsung/odroid/odroid.c  | 14 +++++++++-----
>>  drivers/usb/host/ehci-exynos.c |  7 +++++++
>>  2 files changed, 16 insertions(+), 5 deletions(-)
>>
>> diff --git a/board/samsung/odroid/odroid.c
>> b/board/samsung/odroid/odroid.c index 3e594fd850..79d14ead01 100644
>> --- a/board/samsung/odroid/odroid.c
>> +++ b/board/samsung/odroid/odroid.c
>> @@ -468,8 +468,6 @@ struct dwc2_plat_otg_data s5pc210_otg_data = {
>>  };
>>  #endif
>>  
>> -#if defined(CONFIG_USB_GADGET) || defined(CONFIG_CMD_USB)
>> -
>>  static void set_usb3503_ref_clk(void)
>>  {
>>  #ifdef CONFIG_BOARD_TYPES
>> @@ -490,9 +488,8 @@ static void set_usb3503_ref_clk(void)
>>  #endif /* CONFIG_BOARD_TYPES */
>>  }
>>  
>> -int board_usb_init(int index, enum usb_init_type init)
>> +int exynos_usb_init(void)
>>  {
>> -#ifdef CONFIG_CMD_USB
>>  	struct udevice *dev;
>>  	int ret;
>>  
>> @@ -501,6 +498,7 @@ int board_usb_init(int index, enum usb_init_type
>> init) /* Disconnect, Reset, Connect */
>>  	gpio_direction_output(EXYNOS4X12_GPIO_X34, 0);
>>  	gpio_direction_output(EXYNOS4X12_GPIO_X35, 0);
>> +	sdelay(200000);
>>  	gpio_direction_output(EXYNOS4X12_GPIO_X35, 1);
>>  	gpio_direction_output(EXYNOS4X12_GPIO_X34, 1);
>>  
>> @@ -530,7 +528,13 @@ int board_usb_init(int index, enum usb_init_type
>> init) pr_err("Regulator %s value setting error: %d\n", dev->name,
>> ret); return ret;
>>  	}
>> -#endif
>> +
>> +	return 0;
>> +}
>> +
>> +#ifdef CONFIG_USB_GADGET
>> +int board_usb_init(int index, enum usb_init_type init)
> 
> We are not allowed to add board_usb_* code anymore. The _only_ way to
> update/fix the USB gadget code is to convert it to driver model [DM] and
> describe it via DTS.
> 
> Please consider converting this code to DM/DTS.

Patrick currently has a series enabling DWC2 OTG DM support which I'm
attempting to switch the rk3288 over too. A branch can be found at
https://github.com/patrickdelaunay/u-boot/tree/v2019.04-stm32mp for testing.

> 
>> +{
>>  	debug("USB_udc_probe\n");
>>  	return dwc2_udc_probe(&s5pc210_otg_data);
>>  }
>> diff --git a/drivers/usb/host/ehci-exynos.c
>> b/drivers/usb/host/ehci-exynos.c index fabc662eb6..b0f7bd4936 100644
>> --- a/drivers/usb/host/ehci-exynos.c
>> +++ b/drivers/usb/host/ehci-exynos.c
>> @@ -31,6 +31,8 @@ struct exynos_ehci_platdata {
>>  	struct gpio_desc vbus_gpio;
>>  };
>>  
>> +extern int exynos_usb_init(void);
>> +
>>  /**
>>   * Contains pointers to register base addresses
>>   * for the usb controller.
>> @@ -152,6 +154,11 @@ static void exynos4412_setup_usb_phy(struct
>> exynos4412_usb_phy *usb) setbits_le32(&usb->usbphyrstcon,
>> (RSTCON_HOSTPHY_SWRST | RSTCON_SWRST)); udelay(10);
>>  	clrbits_le32(&usb->usbphyrstcon, (RSTCON_HOSTPHY_SWRST |
>> RSTCON_SWRST)); +
>> +	/*
>> +	 * "usb start" initialize the usb driver
>> +	 */
>> +	exynos_usb_init();
>>  }
>>  
>>  static void setup_usb_phy(struct exynos_usb_phy *usb)
> 
> 
> 
> 
> Best regards,
> 
> Lukasz Majewski
> 
> --
> 
> DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
> HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
> Phone: (+49)-8142-66989-59 Fax: (+49)-8142-66989-80 Email: lukma@denx.de
> 
> 
> _______________________________________________
> U-Boot mailing list
> U-Boot@lists.denx.de
> https://lists.denx.de/listinfo/u-boot
>
Anand Moon April 1, 2019, 4:20 p.m. UTC | #4
Hi Krzysztof,

On Mon, 1 Apr 2019 at 18:18, Krzysztof Kozlowski <krzk@kernel.org> wrote:
>
> On Mon, 1 Apr 2019 at 13:52, Anand Moon <linux.amoon@gmail.com> wrote:
> >
> > From: Tobias Jakobi <tjakobi@math.uni-bielefeld.de>
> >
> > Rename board_usb_init() to exynos_usb_init() and call it
> > early in the Exynos EHCI driver when probing.
> >
> > This kind of works. After a 'usb start; usb stop; usb start'
> > cycle the attached devices are recognized.
> >
> > Add small delay between gpio_direction_output to stable
> > initialization of usb gpio pins.
> >
> > Signed-off-by: Tobias Jakobi <tjakobi@math.uni-bielefeld.de>
> > Signed-off-by: Anand Moon <linux.amoon@gmail.com>
> > ---
> > Reoder the exynos_usb_init so that "usb start" command initialization
> > correcly.
> > ---
> > ---
> >  board/samsung/odroid/odroid.c  | 14 +++++++++-----
> >  drivers/usb/host/ehci-exynos.c |  7 +++++++
> >  2 files changed, 16 insertions(+), 5 deletions(-)
> >
> > diff --git a/board/samsung/odroid/odroid.c b/board/samsung/odroid/odroid.c
> > index 3e594fd850..79d14ead01 100644
> > --- a/board/samsung/odroid/odroid.c
> > +++ b/board/samsung/odroid/odroid.c
> > @@ -468,8 +468,6 @@ struct dwc2_plat_otg_data s5pc210_otg_data = {
> >  };
> >  #endif
> >
> > -#if defined(CONFIG_USB_GADGET) || defined(CONFIG_CMD_USB)
> > -
> >  static void set_usb3503_ref_clk(void)
> >  {
> >  #ifdef CONFIG_BOARD_TYPES
> > @@ -490,9 +488,8 @@ static void set_usb3503_ref_clk(void)
> >  #endif /* CONFIG_BOARD_TYPES */
> >  }
> >
> > -int board_usb_init(int index, enum usb_init_type init)
> > +int exynos_usb_init(void)
> >  {
> > -#ifdef CONFIG_CMD_USB
> >         struct udevice *dev;
> >         int ret;
> >
> > @@ -501,6 +498,7 @@ int board_usb_init(int index, enum usb_init_type init)
> >         /* Disconnect, Reset, Connect */
> >         gpio_direction_output(EXYNOS4X12_GPIO_X34, 0);
> >         gpio_direction_output(EXYNOS4X12_GPIO_X35, 0);
> > +       sdelay(200000);
>
> This should be a separate patch with its own explanation.
>
> >         gpio_direction_output(EXYNOS4X12_GPIO_X35, 1);
> >         gpio_direction_output(EXYNOS4X12_GPIO_X34, 1);
> >
> > @@ -530,7 +528,13 @@ int board_usb_init(int index, enum usb_init_type init)
> >                 pr_err("Regulator %s value setting error: %d\n", dev->name, ret);
> >                 return ret;
> >         }
> > -#endif
> > +
> > +       return 0;
> > +}
> > +
> > +#ifdef CONFIG_USB_GADGET
> > +int board_usb_init(int index, enum usb_init_type init)
> > +{
> >         debug("USB_udc_probe\n");
> >         return dwc2_udc_probe(&s5pc210_otg_data);
> >  }
> > diff --git a/drivers/usb/host/ehci-exynos.c b/drivers/usb/host/ehci-exynos.c
> > index fabc662eb6..b0f7bd4936 100644
> > --- a/drivers/usb/host/ehci-exynos.c
> > +++ b/drivers/usb/host/ehci-exynos.c
> > @@ -31,6 +31,8 @@ struct exynos_ehci_platdata {
> >         struct gpio_desc vbus_gpio;
> >  };
> >
> > +extern int exynos_usb_init(void);
> > +
> >  /**
> >   * Contains pointers to register base addresses
> >   * for the usb controller.
> > @@ -152,6 +154,11 @@ static void exynos4412_setup_usb_phy(struct exynos4412_usb_phy *usb)
> >         setbits_le32(&usb->usbphyrstcon, (RSTCON_HOSTPHY_SWRST | RSTCON_SWRST));
> >         udelay(10);
> >         clrbits_le32(&usb->usbphyrstcon, (RSTCON_HOSTPHY_SWRST | RSTCON_SWRST));
> > +
> > +       /*
> > +        * "usb start" initialize the usb driver
> > +        */
> > +       exynos_usb_init();
>
> It should be something more generic like
> CONFIG_SYS_USB_OHCI_BOARD_INIT which calls board_usb_init()... but it
> still will be calling board code from the driver. Why do you need this
> in the first place?

Ideally usb start should be invoked while loading of the u-boot.
but some how this is missing I could not figure out this.

I have tried following in odroid.c but still no sign of usb to get
initialize usb,

int board_eth_init(bd_t *bis)
{
        printf("Registered USB_ETHER\n");
        exynos_usb_init();
        return 0;
}

Here is the debugging I tried to under stand before I tried to modify the code.
Before usb start is called.

Odroid # dm help
dm - Driver model low level access
...
 gpio        44  [   ]   gpio_exynos           |   |-- gpv3
 gpio        45  [   ]   gpio_exynos           |   `-- gpv4
 usb          0  [   ]   ehci_exynos           `-- ehci@12580000

After usb start
Odroid # usb start
starting USB...
USB0:   USB EHCI 1.00
scanning bus 0 for devices... 4 USB Device(s) found
       scanning usb for storage devices... 1 Storage Device(s) found
       scanning usb for ethernet devices... 1 Ethernet Device(s) found
Odroid # dm tree

 gpio        45  [   ]   gpio_exynos           |   `-- gpv4
 usb          0  [ + ]   ehci_exynos           `-- ehci@12580000
 usb_hub      0  [ + ]   usb_hub                   `-- usb_hub
 usb_dev_ge   0  [ + ]   usb_dev_generic_drv           |-- generic_bus_0_dev_2
 usb_hub      1  [ + ]   usb_hub                       `-- usb_hub
 usb_mass_s   0  [ + ]   usb_mass_storage                  `-- usb_mass_storage
 blk          2  [   ]   usb_storage_blk                       `--
usb_mass_storage.lun0

After the dm node register we can perform usb and ethernet operation on u-boot.

Any other input's I can try this out.

Best Regards
-Anand
Tobias Jakobi April 3, 2019, 7:58 p.m. UTC | #5
Hello,

in case this isn't totally obvious, I want to state it here again: THIS IS A HACK!

This patch of mine was never meant for upstream submission. Note that the
original commit has a TODO included, which again makes clear: This is not the
proper way to do it. It's a quick&dirty solution because I needed booting via
tftp. Nothing more.

I have seen this plently of times now. Anand Moon takes some code, tinkers
around with it and then presents it for review. The problem is that he doesn't
even bother to understand what he's doing and when he arrives at something
semi-working, it is more by chance than anything else. I feel sorry for
Krzysztof (and others), who, with the patience of a monk to say the least, has
to deal with this time and time again.

- Tobias



Anand Moon wrote:
> From: Tobias Jakobi <tjakobi@math.uni-bielefeld.de>
> 
> Rename board_usb_init() to exynos_usb_init() and call it
> early in the Exynos EHCI driver when probing.
> 
> This kind of works. After a 'usb start; usb stop; usb start'
> cycle the attached devices are recognized.
> 
> Add small delay between gpio_direction_output to stable
> initialization of usb gpio pins.
> 
> Signed-off-by: Tobias Jakobi <tjakobi@math.uni-bielefeld.de>
> Signed-off-by: Anand Moon <linux.amoon@gmail.com>
> ---
> Reoder the exynos_usb_init so that "usb start" command initialization
> correcly.
> ---
> ---
>  board/samsung/odroid/odroid.c  | 14 +++++++++-----
>  drivers/usb/host/ehci-exynos.c |  7 +++++++
>  2 files changed, 16 insertions(+), 5 deletions(-)
> 
> diff --git a/board/samsung/odroid/odroid.c b/board/samsung/odroid/odroid.c
> index 3e594fd850..79d14ead01 100644
> --- a/board/samsung/odroid/odroid.c
> +++ b/board/samsung/odroid/odroid.c
> @@ -468,8 +468,6 @@ struct dwc2_plat_otg_data s5pc210_otg_data = {
>  };
>  #endif
>  
> -#if defined(CONFIG_USB_GADGET) || defined(CONFIG_CMD_USB)
> -
>  static void set_usb3503_ref_clk(void)
>  {
>  #ifdef CONFIG_BOARD_TYPES
> @@ -490,9 +488,8 @@ static void set_usb3503_ref_clk(void)
>  #endif /* CONFIG_BOARD_TYPES */
>  }
>  
> -int board_usb_init(int index, enum usb_init_type init)
> +int exynos_usb_init(void)
>  {
> -#ifdef CONFIG_CMD_USB
>  	struct udevice *dev;
>  	int ret;
>  
> @@ -501,6 +498,7 @@ int board_usb_init(int index, enum usb_init_type init)
>  	/* Disconnect, Reset, Connect */
>  	gpio_direction_output(EXYNOS4X12_GPIO_X34, 0);
>  	gpio_direction_output(EXYNOS4X12_GPIO_X35, 0);
> +	sdelay(200000);
>  	gpio_direction_output(EXYNOS4X12_GPIO_X35, 1);
>  	gpio_direction_output(EXYNOS4X12_GPIO_X34, 1);
>  
> @@ -530,7 +528,13 @@ int board_usb_init(int index, enum usb_init_type init)
>  		pr_err("Regulator %s value setting error: %d\n", dev->name, ret);
>  		return ret;
>  	}
> -#endif
> +
> +	return 0;
> +}
> +
> +#ifdef CONFIG_USB_GADGET
> +int board_usb_init(int index, enum usb_init_type init)
> +{
>  	debug("USB_udc_probe\n");
>  	return dwc2_udc_probe(&s5pc210_otg_data);
>  }
> diff --git a/drivers/usb/host/ehci-exynos.c b/drivers/usb/host/ehci-exynos.c
> index fabc662eb6..b0f7bd4936 100644
> --- a/drivers/usb/host/ehci-exynos.c
> +++ b/drivers/usb/host/ehci-exynos.c
> @@ -31,6 +31,8 @@ struct exynos_ehci_platdata {
>  	struct gpio_desc vbus_gpio;
>  };
>  
> +extern int exynos_usb_init(void);
> +
>  /**
>   * Contains pointers to register base addresses
>   * for the usb controller.
> @@ -152,6 +154,11 @@ static void exynos4412_setup_usb_phy(struct exynos4412_usb_phy *usb)
>  	setbits_le32(&usb->usbphyrstcon, (RSTCON_HOSTPHY_SWRST | RSTCON_SWRST));
>  	udelay(10);
>  	clrbits_le32(&usb->usbphyrstcon, (RSTCON_HOSTPHY_SWRST | RSTCON_SWRST));
> +
> +	/*
> +	 * "usb start" initialize the usb driver
> +	 */
> +	exynos_usb_init();
>  }
>  
>  static void setup_usb_phy(struct exynos_usb_phy *usb)
>
Anand Moon April 4, 2019, 3:01 a.m. UTC | #6
Hi Tobias,

On Thu, 4 Apr 2019 at 01:28, Tobias Jakobi
<tjakobi@math.uni-bielefeld.de> wrote:
>
> Hello,
>
> in case this isn't totally obvious, I want to state it here again: THIS IS A HACK!
>
> This patch of mine was never meant for upstream submission. Note that the
> original commit has a TODO included, which again makes clear: This is not the
> proper way to do it. It's a quick&dirty solution because I needed booting via
> tftp. Nothing more.
>
> I have seen this plently of times now. Anand Moon takes some code, tinkers
> around with it and then presents it for review. The problem is that he doesn't
> even bother to understand what he's doing and when he arrives at something
> semi-working, it is more by chance than anything else. I feel sorry for
> Krzysztof (and others), who, with the patience of a monk to say the least, has
> to deal with this time and time again.
>
> - Tobias
>

Yes I completely understand you point,  their could be other way to
fix this issue
which I over looked, sorry for the trouble. Let discard this for now.

Best Regards
-Anand
diff mbox series

Patch

diff --git a/board/samsung/odroid/odroid.c b/board/samsung/odroid/odroid.c
index 3e594fd850..79d14ead01 100644
--- a/board/samsung/odroid/odroid.c
+++ b/board/samsung/odroid/odroid.c
@@ -468,8 +468,6 @@  struct dwc2_plat_otg_data s5pc210_otg_data = {
 };
 #endif
 
-#if defined(CONFIG_USB_GADGET) || defined(CONFIG_CMD_USB)
-
 static void set_usb3503_ref_clk(void)
 {
 #ifdef CONFIG_BOARD_TYPES
@@ -490,9 +488,8 @@  static void set_usb3503_ref_clk(void)
 #endif /* CONFIG_BOARD_TYPES */
 }
 
-int board_usb_init(int index, enum usb_init_type init)
+int exynos_usb_init(void)
 {
-#ifdef CONFIG_CMD_USB
 	struct udevice *dev;
 	int ret;
 
@@ -501,6 +498,7 @@  int board_usb_init(int index, enum usb_init_type init)
 	/* Disconnect, Reset, Connect */
 	gpio_direction_output(EXYNOS4X12_GPIO_X34, 0);
 	gpio_direction_output(EXYNOS4X12_GPIO_X35, 0);
+	sdelay(200000);
 	gpio_direction_output(EXYNOS4X12_GPIO_X35, 1);
 	gpio_direction_output(EXYNOS4X12_GPIO_X34, 1);
 
@@ -530,7 +528,13 @@  int board_usb_init(int index, enum usb_init_type init)
 		pr_err("Regulator %s value setting error: %d\n", dev->name, ret);
 		return ret;
 	}
-#endif
+
+	return 0;
+}
+
+#ifdef CONFIG_USB_GADGET
+int board_usb_init(int index, enum usb_init_type init)
+{
 	debug("USB_udc_probe\n");
 	return dwc2_udc_probe(&s5pc210_otg_data);
 }
diff --git a/drivers/usb/host/ehci-exynos.c b/drivers/usb/host/ehci-exynos.c
index fabc662eb6..b0f7bd4936 100644
--- a/drivers/usb/host/ehci-exynos.c
+++ b/drivers/usb/host/ehci-exynos.c
@@ -31,6 +31,8 @@  struct exynos_ehci_platdata {
 	struct gpio_desc vbus_gpio;
 };
 
+extern int exynos_usb_init(void);
+
 /**
  * Contains pointers to register base addresses
  * for the usb controller.
@@ -152,6 +154,11 @@  static void exynos4412_setup_usb_phy(struct exynos4412_usb_phy *usb)
 	setbits_le32(&usb->usbphyrstcon, (RSTCON_HOSTPHY_SWRST | RSTCON_SWRST));
 	udelay(10);
 	clrbits_le32(&usb->usbphyrstcon, (RSTCON_HOSTPHY_SWRST | RSTCON_SWRST));
+
+	/*
+	 * "usb start" initialize the usb driver
+	 */
+	exynos_usb_init();
 }
 
 static void setup_usb_phy(struct exynos_usb_phy *usb)