[U-Boot] [PATCH v5 12/14] usb: extend generic OHCI with clock, reset and phy

Patrice CHOTARD patrice.chotard at st.com
Thu May 11 09:36:43 UTC 2017


Hi Marek

On 05/10/2017 11:20 PM, Marek Vasut wrote:
> On 05/10/2017 06:09 PM, patrice.chotard at st.com wrote:
>> From: Patrice Chotard <patrice.chotard at st.com>
>>
>> Make this driver more generic as echi-generic
>
> EHCI , although the typo is kinda funny .

ok i will fix it

>
>> Signed-off-by: Patrice Chotard <patrice.chotard at st.com>
>> ---
>>
>> v5:   _ add clock, reset and generic phy support
>>
>>  drivers/usb/host/ohci-generic.c | 48 +++++++++++++++++++++++++++++++++++------
>>  1 file changed, 42 insertions(+), 6 deletions(-)
>>
>> diff --git a/drivers/usb/host/ohci-generic.c b/drivers/usb/host/ohci-generic.c
>> index f3307f4..33e8095 100644
>> --- a/drivers/usb/host/ohci-generic.c
>> +++ b/drivers/usb/host/ohci-generic.c
>> @@ -5,7 +5,12 @@
>>   */
>>
>>  #include <common.h>
>> +#include <clk.h>
>>  #include <dm.h>
>> +#include <fdtdec.h>
>> +#include <generic-phy.h>
>> +#include <reset.h>
>> +
>>  #include "ohci.h"
>>
>>  #if !defined(CONFIG_USB_OHCI_NEW)
>> @@ -19,13 +24,44 @@ struct generic_ohci {
>>  static int ohci_usb_probe(struct udevice *dev)
>>  {
>>  	struct ohci_regs *regs = (struct ohci_regs *)dev_get_addr(dev);
>> +	int i;
>>
>> -	return ohci_register(dev, regs);
>> -}
>> +	for (i = 0; ; i++) {
>> +		struct clk clk;
>> +		int ret;
>>
>> -static int ohci_usb_remove(struct udevice *dev)
>> -{
>> -	return ohci_deregister(dev);
>> +		ret = clk_get_by_index(dev, i, &clk);
>> +		if (ret < 0)
>> +			break;
>> +		if (clk_enable(&clk))
>> +			printf("failed to enable clock %d\n", i);
>> +		clk_free(&clk);
>> +	}
>> +
>> +	for (i = 0; ; i++) {
>> +		struct reset_ctl reset;
>> +		int ret;
>> +
>> +		ret = reset_get_by_index(dev, i, &reset);
>> +		if (ret < 0)
>> +			break;
>> +		if (reset_deassert(&reset))
>> +			printf("failed to deassert reset %d\n", i);
>
> You should look up the resets and clock and whatnot by phandle .

Sorry, i didn't understand what you mean.

If you have a look at clk_get_by_index(), reset_get_by_index() and 
generic_phy_get_by_index() implementations, these functions already 
looks up respectively to clock, reset and phy through phandle.

Patrice
>
>> +		reset_free(&reset);
>> +	}
>> +
>> +	for (i = 0; ; i++) {
>> +		struct phy usb_phy;
>> +		int ret;
>> +
>> +		ret = generic_phy_get_by_index(dev, i, &usb_phy);
>> +		if (ret < 0)
>> +			break;
>> +		if (generic_phy_init(&usb_phy))
>> +			printf("failed to init usb phy %d\n", i);
>> +	}
>> +
>> +	return ohci_register(dev, regs);
>>  }
>>
>>  static const struct udevice_id ohci_usb_ids[] = {
>> @@ -38,7 +74,7 @@ U_BOOT_DRIVER(ohci_generic) = {
>>  	.id	= UCLASS_USB,
>>  	.of_match = ohci_usb_ids,
>>  	.probe = ohci_usb_probe,
>> -	.remove = ohci_usb_remove,
>> +	.remove = ohci_deregister,
>>  	.ops	= &ohci_usb_ops,
>>  	.priv_auto_alloc_size = sizeof(struct generic_ohci),
>>  	.flags	= DM_FLAG_ALLOC_PRIV_DMA,
>>
>
>


More information about the U-Boot mailing list