From: Kever Yang <kever.yang@rock-chips.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [RESEND PATCH v4] usb: dwc2: add support for external vbus supply
Date: Tue, 07 Mar 2017 14:50:36 +0800 [thread overview]
Message-ID: <58BE583C.30900@rock-chips.com> (raw)
In-Reply-To: <e6462d3e-ec8f-e323-31c7-445a30492e43@denx.de>
Hi Marek,
On 03/07/2017 10:55 AM, Marek Vasut wrote:
> On 03/06/2017 01:54 PM, Kever Yang wrote:
>> Some board do not use the dwc2 internal VBUS_DRV signal, but
>> use a gpio pin to enable the 5.0V VBUS power, add interface to
>> enable the power in dwc2 driver.
>>
>> Signed-off-by: Kever Yang <kever.yang@rock-chips.com>
>> Signed-off-by: Simon Glass <sjg@chromium.org>
>> ---
>>
>> Changes in v4:
>> - Drop no use code comment by Marek.
>>
>> Changes in v3:
>> - Drop use of static variable
>>
>> drivers/usb/host/dwc2.c | 37 ++++++++++++++++++++++++++++++++-----
>> 1 file changed, 32 insertions(+), 5 deletions(-)
>>
>> diff --git a/drivers/usb/host/dwc2.c b/drivers/usb/host/dwc2.c
>> index d253b94..5ac602e 100644
>> --- a/drivers/usb/host/dwc2.c
>> +++ b/drivers/usb/host/dwc2.c
>> @@ -15,6 +15,7 @@
>> #include <usbroothubdes.h>
>> #include <wait_bit.h>
>> #include <asm/io.h>
>> +#include <power/regulator.h>
>>
>> #include "dwc2.h"
>>
>> @@ -159,6 +160,27 @@ static void dwc_otg_core_reset(struct
>> dwc2_core_regs *regs)
>> mdelay(100);
>> }
>
> Nit:
>
> add the ifdef around the function, ie.
I don't understand what to do here, we already have
"#if defined(CONFIG_DM_USB) && defined(CONFIG_DM_REGULATOR) "
in the function, do you mean move this out of the function or
do you need add any other MACRO?
Thanks,
- Kever
>
> #ifdef (.....)
> static foo()
> {
> do stuff
> }
> #else
> static foo() { return 0 }
> #endif
>
> The rest is great, thanks!
>
>> +static int dwc_vbus_supply_init(struct udevice *dev)
>> +{
>> +#if defined(CONFIG_DM_USB) && defined(CONFIG_DM_REGULATOR)
>> + struct udevice *vbus_supply;
>> + int ret;
>> +
>> + ret = device_get_supply_regulator(dev, "vbus-supply",
>> &vbus_supply);
>> + if (ret) {
>> + debug("%s: No vbus supply\n", dev->name);
>> + return 0;
>> + }
>> +
>> + ret = regulator_set_enable(vbus_supply, true);
>> + if (ret) {
>> + error("Error enabling vbus supply\n");
>> + return ret;
>> + }
>> +#endif
>> + return 0;
>> +}
>> +
>> /*
>> * This function initializes the DWC_otg controller registers for
>> * host mode.
>> @@ -167,10 +189,12 @@ static void dwc_otg_core_reset(struct
>> dwc2_core_regs *regs)
>> * request queues. Host channels are reset to ensure that they are
>> ready for
>> * performing transfers.
>> *
>> + * @param dev USB Device (NULL if driver model is not being used)
>> * @param regs Programming view of DWC_otg controller
>> *
>> */
>> -static void dwc_otg_core_host_init(struct dwc2_core_regs *regs)
>> +static void dwc_otg_core_host_init(struct udevice *dev,
>> + struct dwc2_core_regs *regs)
>> {
>> uint32_t nptxfifosize = 0;
>> uint32_t ptxfifosize = 0;
>> @@ -248,6 +272,9 @@ static void dwc_otg_core_host_init(struct
>> dwc2_core_regs *regs)
>> writel(hprt0, ®s->hprt0);
>> }
>> }
>> +
>> + if (dev)
>> + dwc_vbus_supply_init(dev);
>> }
>>
>> /*
>> @@ -1048,7 +1075,7 @@ int _submit_int_msg(struct dwc2_priv *priv,
>> struct usb_device *dev,
>> }
>> }
>>
>> -static int dwc2_init_common(struct dwc2_priv *priv)
>> +static int dwc2_init_common(struct udevice *dev, struct dwc2_priv
>> *priv)
>> {
>> struct dwc2_core_regs *regs = priv->regs;
>> uint32_t snpsid;
>> @@ -1070,7 +1097,7 @@ static int dwc2_init_common(struct dwc2_priv
>> *priv)
>> #endif
>>
>> dwc_otg_core_init(priv);
>> - dwc_otg_core_host_init(regs);
>> + dwc_otg_core_host_init(dev, regs);
>>
>> clrsetbits_le32(®s->hprt0, DWC2_HPRT0_PRTENA |
>> DWC2_HPRT0_PRTCONNDET | DWC2_HPRT0_PRTENCHNG |
>> @@ -1143,7 +1170,7 @@ int usb_lowlevel_init(int index, enum
>> usb_init_type init, void **controller)
>> if (board_usb_init(index, USB_INIT_HOST))
>> return -1;
>>
>> - return dwc2_init_common(priv);
>> + return dwc2_init_common(NULL, priv);
>> }
>>
>> int usb_lowlevel_stop(int index)
>> @@ -1214,7 +1241,7 @@ static int dwc2_usb_probe(struct udevice *dev)
>>
>> bus_priv->desc_before_addr = true;
>>
>> - return dwc2_init_common(priv);
>> + return dwc2_init_common(dev, priv);
>> }
>>
>> static int dwc2_usb_remove(struct udevice *dev)
>>
>
>
>
>
next prev parent reply other threads:[~2017-03-07 6:50 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-03-06 12:54 [U-Boot] [RESEND PATCH v4] usb: dwc2: add support for external vbus supply Kever Yang
2017-03-07 2:55 ` Marek Vasut
2017-03-07 6:50 ` Kever Yang [this message]
2017-03-10 2:16 ` Marek Vasut
2017-03-10 4:02 ` Kever Yang
2017-03-10 4:50 ` Marek Vasut
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=58BE583C.30900@rock-chips.com \
--to=kever.yang@rock-chips.com \
--cc=u-boot@lists.denx.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox