[U-Boot] [PATCH 2/2] usb: extend generic OHCI with CLOCK, RESET and PHY

Patrice CHOTARD patrice.chotard at st.com
Fri May 12 15:57:42 UTC 2017


Hi Marek

On 05/12/2017 03:21 PM, Marek Vasut wrote:
> On 05/12/2017 03:13 PM, patrice.chotard at st.com wrote:
>> From: Patrice Chotard <patrice.chotard at st.com>
>>
>> Add CLOCK, RESET and generic PHY frameworks support
>>
>> Signed-off-by: Patrice Chotard <patrice.chotard at st.com>
>> ---
>>  drivers/usb/host/ohci-generic.c | 40 ++++++++++++++++++++++++++++++++++------
>>  1 file changed, 34 insertions(+), 6 deletions(-)
>>
>> diff --git a/drivers/usb/host/ohci-generic.c b/drivers/usb/host/ohci-generic.c
>> index f3307f4..c9d8b74 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,36 @@ struct generic_ohci {
>>  static int ohci_usb_probe(struct udevice *dev)
>>  {
>>  	struct ohci_regs *regs = (struct ohci_regs *)dev_get_addr(dev);
>> +	struct phy usb_phy;
>> +	int i, ret;
>>
>> -	return ohci_register(dev, regs);
>> -}
>> +	for (i = 0; ; i++) {
>> +		struct clk clk;
>>
>> -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))
>> +			error("failed to enable clock %d\n", i);
>> +		clk_free(&clk);
>
> Who disables the clock if this loop fails mid-way through ?

Ok, i will add an error path where all previous enable clocks will be 
released

I will also add a remove callback instead of calling ohci_deregister() 
in which clocks will be disabled, reset asserted and phy de-init.

>
>> +	}
>> +
>> +	for (i = 0; ; i++) {
>> +		struct reset_ctl reset;
>> +
>> +		ret = reset_get_by_index(dev, i, &reset);
>> +		if (ret < 0)
>> +			break;
>> +		if (reset_deassert(&reset))
>> +			error("failed to deassert reset %d\n", i);
>
> DTTO here, plus you'll likely only have one reset .

same as clocks

Patrice

>
>> +		reset_free(&reset);
>> +	}
>> +
>> +	if (!generic_phy_get_by_index(dev, 0, &usb_phy))
>> +		if (generic_phy_init(&usb_phy))
>> +			error("failed to init usb phy %d\n", i);
>> +
>> +	return ohci_register(dev, regs);
>>  }
>>
>>  static const struct udevice_id ohci_usb_ids[] = {
>> @@ -38,7 +66,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