From: Marek Vasut Date: Sat, 17 Jun 2017 08:22:41 +0200 Subject: [U-Boot] [PATCH v5 04/11] usb: host: xhci-rockchip: use fixed regulator to control vbus In-Reply-To: References: <1497259182-3568-1-git-send-email-daniel.meng@rock-chips.com> <1497259182-3568-5-git-send-email-daniel.meng@rock-chips.com> <1ff26ece-a68d-3cc6-be20-6f02caa2afb2@denx.de> <31997e11-645d-a596-4159-a153aaaf8e35@rock-chips.com> <2bd8d992-79e2-89f8-263d-eb84d0581656@denx.de> Message-ID: <835f59ce-2b60-13ba-d7c1-36cb0c9bcb9e@denx.de> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de On 06/17/2017 05:41 AM, Simon Glass wrote: > Hi Marek, > > On 15 June 2017 at 10:53, Marek Vasut wrote: >> On 06/15/2017 05:51 AM, rock-chips(daniel.meng) wrote: >>> >>> >>> On 2017/6/13 17:11, Marek Vasut wrote: >>>> On 06/12/2017 11:19 AM, Meng Dongyang wrote: >>>>> Use fixed regulator to control the voltage of vbus and turn off >>>>> vbus when usb stop. >>>>> >>>>> Signed-off-by: Meng Dongyang >>>>> --- >>>>> >>>>> Changes in v5: >>>>> - Propagate return value and print error message when failed >>>>> >>>>> Changes in v4: >>>>> - Splited from patch [Uboot,v3,04/10] >>>>> - Define set vbus as empty function if the macros aren't set >>>>> >>>>> Changes in v3: None >>>>> Changes in v2: >>>>> - Use fixed regulator to control vbus instead of gpio >>>>> >>>>> drivers/usb/host/xhci-rockchip.c | 55 >>>>> ++++++++++++++++++++++++++++++---------- >>>>> 1 file changed, 42 insertions(+), 13 deletions(-) >>>>> >>>>> diff --git a/drivers/usb/host/xhci-rockchip.c >>>>> b/drivers/usb/host/xhci-rockchip.c >>>>> index f559830..15df6ef 100644 >>>>> --- a/drivers/usb/host/xhci-rockchip.c >>>>> +++ b/drivers/usb/host/xhci-rockchip.c >>>>> @@ -11,10 +11,10 @@ >>>>> #include >>>>> #include >>>>> #include >>>>> -#include >>>>> #include >>>>> #include >>>>> #include >>>>> +#include >>>>> #include "xhci.h" >>>>> @@ -23,7 +23,7 @@ DECLARE_GLOBAL_DATA_PTR; >>>>> struct rockchip_xhci_platdata { >>>>> fdt_addr_t hcd_base; >>>>> fdt_addr_t phy_base; >>>>> - struct gpio_desc vbus_gpio; >>>>> + struct udevice *vbus_supply; >>>>> }; >>>>> /* >>>>> @@ -48,7 +48,7 @@ static int xhci_usb_ofdata_to_platdata(struct >>>>> udevice *dev) >>>>> */ >>>>> plat->hcd_base = dev_get_addr(dev); >>>>> if (plat->hcd_base == FDT_ADDR_T_NONE) { >>>>> - debug("Can't get the XHCI register base address\n"); >>>>> + error("Can't get the XHCI register base address\n"); >>>>> return -ENXIO; >>>>> } >>>>> @@ -62,19 +62,39 @@ static int xhci_usb_ofdata_to_platdata(struct >>>>> udevice *dev) >>>>> } >>>>> if (plat->phy_base == FDT_ADDR_T_NONE) { >>>>> - debug("Can't get the usbphy register address\n"); >>>>> + error("Can't get the usbphy register address\n"); >>>>> return -ENXIO; >>>>> } >>>>> - /* Vbus gpio */ >>>>> - ret = gpio_request_by_name(dev, "rockchip,vbus-gpio", 0, >>>>> - &plat->vbus_gpio, GPIOD_IS_OUT); >>>>> +#if defined(CONFIG_DM_USB) && defined(CONFIG_DM_REGULATOR) >>>> I don't think you need the CONFIG_DM_USB , the driver depends on it (or >>>> should) already anyway. >>> >>> Yes, I will remove it in v6. >>>> >>>>> + /* Vbus regulator */ >>>>> + ret = device_get_supply_regulator(dev, "vbus-supply", >>>>> + &plat->vbus_supply); >>>> So I was curious, does this expand to empty function or is this not >>>> defined if CONFIG_DM_REGULATOR is not defined ? >>> This is not defined if CONFIG_DM_REGULATOR is not defined. >> >> Simon, can you comment on this ? > > It looks OK to me. Shouldn't you have empty stub functions instead to avoid proliferation of adhoc #ifdef CONFIG_FOO throughout the codebase ? -- Best regards, Marek Vasut