rk3328: add support of usb host and gadget
Subsystems (4)
v5 cover rk3328: add support of usb host and gadget
Add support of usb host and gadget function for rk3328.
Changes in v5:
- Propagate return value and print error message when failed
Changes in v4:
- Splite patch [U-boot,v3,04/10] into two patches
- Define set vbus as empty function if the macros aren't set
- Prepare a mask and set capabilities in GUSBCFG register once
Changes in v3:
- Revert change of macro definition in dwc2 driver
- Support host mode without HNP/SRP capability through DTS
Changes in v2:
- Add commit messages
- Split patch [U-boot,7/8] into two patches
- Use fixed regulator to control vbus instead of gpio
Meng Dongyang (11):
rockchip: configs: rk3328: support ehci and ohci controller
rockchip: dts: rk3328: add ehci and ohci node and enable host0 port
rockchip: configs: rk3328: config xhci controller
usb: host: xhci-rockchip: use fixed regulator to control vbus
usb: host: xhci-rockchip: add support for rk3328
rockchip: dts: rk3328: support and enable xhci
rockchip: configs: rk3328: enable dwc2 driver and config fastboot
usb: dwc2: force to host mode if not support HNP/SRP
rockchip: rk3328: board: add support of dwc2 gadget
rockchip: dts: rk3328: support and enable dwc2
rockchip: dts: rk3399: control vbus of typec by fixed regulator
arch/arm/dts/rk3328-evb.dts | 36 +++++++++++++++++++++ arch/arm/dts/rk3328.dtsi | 35 +++++++++++++++++++++ arch/arm/dts/rk3399-evb.dts | 16 ++++++++-- board/rockchip/evb_rk3328/evb-rk3328.c | 43 +++++++++++++++++++++++-- configs/evb-rk3328_defconfig | 25 +++++++++++++++ drivers/usb/host/dwc2.c | 19 ++++++++++-- drivers/usb/host/xhci-rockchip.c | 57 ++++++++++++++++++++++++++-------- include/configs/rk3328_common.h | 9 ++++++ 8 files changed, 219 insertions(+), 21 deletions(-)
Signature · 1 line
1.9.1
PATCH v5 1/11 rockchip: configs: rk3328: support ehci and ohci controller
Add defconfig for usb and ehci and ohci controller, config maximal number of ports of the root hub for ohci driver.
---
Changes in v5: None
Changes in v4: None
Changes in v3: None
Changes in v2: None
configs/evb-rk3328_defconfig | 8 ++++++++ include/configs/rk3328_common.h | 3 +++ 2 files changed, 11 insertions(+)
configs/evb-rk3328_defconfig +8 -0
@@ -31,3 +31,11 @@ CONFIG_SYS_NS16550=y CONFIG_SYSRESET=y CONFIG_USE_TINY_PRINTF=y CONFIG_ERRNO_STR=y +CONFIG_USB=y +CONFIG_DM_USB=y +CONFIG_CMD_USB=y +CONFIG_USB_STORAGE=y +CONFIG_USB_EHCI_HCD=y +CONFIG_USB_EHCI_GENERIC=y +CONFIG_USB_OHCI_HCD=y +CONFIG_USB_OHCI_GENERIC=y
include/configs/rk3328_common.h +3 -0
@@ -61,4 +61,7 @@#endif +/* rockchip ohci host driver */ +#define CONFIG_USB_OHCI_NEW +#define CONFIG_SYS_USB_OHCI_MAX_ROOT_PORTS 1#endif
Signature · 1 line
1.9.1
PATCH v5 2/11 rockchip: dts: rk3328: add ehci and ohci node and enable host0 port
In reply to Meng DongyangAdd dts node for ehci and ohci controller, enable the controllers.
---
Changes in v4: None
Changes in v3: None
Changes in v2: None
arch/arm/dts/rk3328-evb.dts | 8 ++++++++ arch/arm/dts/rk3328.dtsi | 14 ++++++++++++++ 2 files changed, 22 insertions(+)
arch/arm/dts/rk3328-evb.dts +8 -0
@@ -43,3 +43,11 @@ pinctrl-0 = <&emmc_clk &emmc_cmd &emmc_bus8>; status = "okay"; }; + +&usb_host0_ehci { + status = "okay"; +}; + +&usb_host0_ohci { + status = "okay"; +};
arch/arm/dts/rk3328.dtsi +14 -0
@@ -446,6 +446,20 @@ status = "disabled"; }; + usb_host0_ehci: usb at ff5c0000 { + compatible = "generic-ehci"; + reg = <0x0 0xff5c0000 0x0 0x10000>; + interrupts = <GIC_SPI 16 IRQ_TYPE_LEVEL_HIGH>; + status = "disabled"; + }; + + usb_host0_ohci: usb at ff5d0000 { + compatible = "generic-ohci"; + reg = <0x0 0xff5d0000 0x0 0x10000>; + interrupts = <GIC_SPI 17 IRQ_TYPE_LEVEL_HIGH>; + status = "disabled"; + }; + sdmmc_ext: rksdmmc at ff5f0000 { compatible = "rockchip,rk3328-dw-mshc", "rockchip,rk3288-dw-mshc"; reg = <0x0 0xff5f0000 0x0 0x4000>;
Signature · 1 line
1.9.1
PATCH v5 3/11 rockchip: configs: rk3328: config xhci controller
In reply to Meng DongyangAdd config of max root ports and add config to enable xhci controller.
---
Changes in v5: None
Changes in v4: None
Changes in v3: None
Changes in v2: None
configs/evb-rk3328_defconfig | 3 +++ include/configs/rk3328_common.h | 3 +++ 2 files changed, 6 insertions(+)
configs/evb-rk3328_defconfig +3 -0
@@ -39,3 +39,6 @@ CONFIG_USB_EHCI_HCD=y CONFIG_USB_EHCI_GENERIC=y CONFIG_USB_OHCI_HCD=y CONFIG_USB_OHCI_GENERIC=y +CONFIG_USB_XHCI_DWC3=y +CONFIG_USB_XHCI_HCD=y +CONFIG_USB_XHCI_RK=y
include/configs/rk3328_common.h +3 -0
@@ -64,4 +64,7 @@/* rockchip ohci host driver */ #define CONFIG_USB_OHCI_NEW #define CONFIG_SYS_USB_OHCI_MAX_ROOT_PORTS 1 + +/* xhci host */ +#define CONFIG_SYS_USB_XHCI_MAX_ROOT_PORTS 2#endif
Signature · 1 line
1.9.1
PATCH v5 4/11 usb: host: xhci-rockchip: use fixed regulator to control vbus
In reply to Meng DongyangUse fixed regulator to control the voltage of vbus and turn off vbus when usb stop.
---
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(-)
drivers/usb/host/xhci-rockchip.c +42 -13
@@ -11,10 +11,10 @@#include <malloc.h> #include <usb.h> #include <watchdog.h> -#include <asm/gpio.h> #include <linux/errno.h> #include <linux/compat.h> #include <linux/usb/dwc3.h> +#include <power/regulator.h> #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 ) +/* Vbus regulator */ + ret =device_get_supply_regulator (dev,"vbus-supply" , + &plat->vbus_supply);if (ret) -debug ("rockchip,vbus-gpio node missing!" ); +debug ("Can't get VBus regulator!\n" ); +#endif return 0 ; } +#if defined(CONFIG_DM_USB ) && defined(CONFIG_DM_REGULATOR ) +static int rockchip_xhci_set_vbus (struct udevice *vbus_supply,bool value) +{ +int ret; + + ret =regulator_set_enable (vbus_supply, value); +if (ret) +error ("XHCI: Failed to set vbus supply\n" ); + +return ret; +} +#else +static int rockchip_xhci_set_vbus (struct udevice *vbus_supply,bool value) +{ +return 0 ; +} +#endif +/* * rockchip_dwc3_phy_setup() - Configure USB PHY Interface of DWC3 Core * @dwc: Pointer to our controller context structure
@@ -124,7 +144,7 @@ static int rockchip_xhci_core_init(struct rockchip_xhci *rkxhci, ret =dwc3_core_init (rkxhci->dwc3_reg);if (ret) { -debug ("failed to initialize core\n" ); +error ("failed to initialize core\n" );return ret; }
@@ -153,13 +173,15 @@ static int xhci_usb_probe(struct udevice *dev) hcor = (struct xhci_hcor *)((uint64_t )ctx->hcd +HC_LENGTH (xhci_readl (&ctx->hcd->cr_capbase))); -/* setup the Vbus gpio here */ -if (dm_gpio_is_valid (&plat->vbus_gpio)) -dm_gpio_set_value (&plat->vbus_gpio,1 ); +if (plat->vbus_supply) { + ret =rockchip_xhci_set_vbus (plat->vbus_supply, true); +if (ret) +return ret; + } ret =rockchip_xhci_core_init (ctx, dev);if (ret) { -debug ("XHCI: failed to initialize controller\n" ); +error ("XHCI: failed to initialize controller\n" );return ret; }
@@ -168,6 +190,7 @@ static int xhci_usb_probe(struct udevice *dev)static int xhci_usb_remove (struct udevice *dev) { +struct rockchip_xhci_platdata *plat =dev_get_platdata (dev);struct rockchip_xhci *ctx =dev_get_priv (dev);int ret;
@@ -178,6 +201,12 @@ static int xhci_usb_remove(struct udevice *dev)if (ret)return ret; +if (plat->vbus_supply) { + ret =rockchip_xhci_set_vbus (plat->vbus_supply, false); +if (ret) +return ret; + } +return 0 ; }
Signature · 1 line
1.9.1
PATCH v5 4/11 usb: host: xhci-rockchip: use fixed regulator to control vbus
Quoted 57 lines · Meng Dongyang
Use fixed regulator to control the voltage of vbus and turn off vbus when usb stop.
Signed-off-by Meng Dongyang <[email protected]>---
Changes in v5:
- Propagate return value and print error message when failedChanges in v4:
- Splited from patch [Uboot,v3,04/10]
- Define set vbus as empty function if the macros aren't setChanges in v3: None
Changes in v2:
- Use fixed regulator to control vbus instead of gpiodrivers/usb/host/xhci-rockchip.c | 55 ++++++++++++++++++++++++++++++---------- 1 file changed, 42 insertions(+), 13 deletions(-)drivers/usb/host/xhci-rockchip.c +3
-3@@ -11,10 +11,10 @@#include <malloc.h> #include <usb.h> #include <watchdog.h> -#include <asm/gpio.h> #include <linux/errno.h> #include <linux/compat.h> #include <linux/usb/dwc3.h> +#include <power/regulator.h> #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) }
drivers/usb/host/xhci-rockchip.c static int xhci_usb_ofdata_to_platdata(struct udevice *dev) · line 69
Quoted 10 lines
drivers/usb/host/xhci-rockchip.c +2
-4if (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.
drivers/usb/host/xhci-rockchip.c static int xhci_usb_ofdata_to_platdata(struct udevice *dev) · line 72
Quoted 3 lines
drivers/usb/host/xhci-rockchip.c +3
-0+/* 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 ?
Quoted 6 lines
drivers/usb/host/xhci-rockchip.c +2
-1if (ret) -debug ("rockchip,vbus-gpio node missing!" ); +debug ("Can't get VBus regulator!\n" ); +#endif return 0 ;
drivers/usb/host/xhci-rockchip.c static int xhci_usb_ofdata_to_platdata(struct udevice *dev) · line 87
Quoted 10 lines
drivers/usb/host/xhci-rockchip.c +8
-0} +#if defined(CONFIG_DM_USB ) && defined(CONFIG_DM_REGULATOR ) +static int rockchip_xhci_set_vbus (struct udevice *vbus_supply,bool value) +{ +int ret; + + ret =regulator_set_enable (vbus_supply, value); +if (ret) +error ("XHCI: Failed to set vbus supply\n" );
Please be consistent with the VBus usage. You use VBus above and vbus here.
Quoted 51 lines
drivers/usb/host/xhci-rockchip.c +18
-5+ + return ret; +} +#else +static int rockchip_xhci_set_vbus (struct udevice *vbus_supply,bool value) +{ +return 0 ; +} +#endif +/* * rockchip_dwc3_phy_setup() - Configure USB PHY Interface of DWC3 Core * @dwc: Pointer to our controller context structure @@ -124,7 +144,7 @@ static int rockchip_xhci_core_init(struct rockchip_xhci *rkxhci, ret =dwc3_core_init (rkxhci->dwc3_reg);if (ret) { -debug ("failed to initialize core\n" ); +error ("failed to initialize core\n" );return ret; }@@ -153,13 +173,15 @@ static int xhci_usb_probe(struct udevice *dev) hcor = (struct xhci_hcor *)((uint64_t )ctx->hcd +HC_LENGTH (xhci_readl (&ctx->hcd->cr_capbase))); -/* setup the Vbus gpio here */ -if (dm_gpio_is_valid (&plat->vbus_gpio)) -dm_gpio_set_value (&plat->vbus_gpio,1 ); +if (plat->vbus_supply) { + ret =rockchip_xhci_set_vbus (plat->vbus_supply, true); +if (ret) +return ret; + } ret =rockchip_xhci_core_init (ctx, dev);if (ret) { -debug ("XHCI: failed to initialize controller\n" ); +error ("XHCI: failed to initialize controller\n" );return ret; }@@ -168,6 +190,7 @@ static int xhci_usb_probe(struct udevice *dev)static int xhci_usb_remove (struct udevice *dev) { +struct rockchip_xhci_platdata *plat =dev_get_platdata (dev);struct rockchip_xhci *ctx =dev_get_priv (dev);int ret;
drivers/usb/host/xhci-rockchip.c static int xhci_usb_remove(struct udevice *dev) · line 210
Quoted 10 lines
drivers/usb/host/xhci-rockchip.c +6
-0@@ -178,6 +201,12 @@ static int xhci_usb_remove(struct udevice *dev)if (ret)return ret; +if (plat->vbus_supply) { + ret =rockchip_xhci_set_vbus (plat->vbus_supply, false); +if (ret) +return ret; + } +return 0 ;
Just do return ret here, then you don't need the if (ret) above.
Quoted 3 lines
drivers/usb/host/xhci-rockchip.c +0
-0}
Signature · 2 lines
Best regards, Marek Vasut
PATCH v5 4/11 usb: host: xhci-rockchip: use fixed regulator to control vbus
Quoted 64 lines · Marek Vasut
Quoted 63 lines · Meng Dongyang
Use fixed regulator to control the voltage of vbus and turn off vbus when usb stop.
Signed-off-by Meng Dongyang <[email protected]>---
Changes in v5:
- Propagate return value and print error message when failedChanges in v4:
- Splited from patch [Uboot,v3,04/10]
- Define set vbus as empty function if the macros aren't setChanges in v3: None
Changes in v2:
- Use fixed regulator to control vbus instead of gpiodrivers/usb/host/xhci-rockchip.c | 55 ++++++++++++++++++++++++++++++---------- 1 file changed, 42 insertions(+), 13 deletions(-)drivers/usb/host/xhci-rockchip.c +4
-4@@ -11,10 +11,10 @@#include <malloc.h> #include <usb.h> #include <watchdog.h> -#include <asm/gpio.h> #include <linux/errno.h> #include <linux/compat.h> #include <linux/usb/dwc3.h> +#include <power/regulator.h> #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 ; }
Quoted 6 lines
drivers/usb/host/xhci-rockchip.c static int xhci_usb_ofdata_to_platdata(struct udevice *dev) · line 69
Quoted 4 lines
drivers/usb/host/xhci-rockchip.c +1
-3-/* 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.
Quoted 6 lines
drivers/usb/host/xhci-rockchip.c static int xhci_usb_ofdata_to_platdata(struct udevice *dev) · line 72
Quoted 4 lines
drivers/usb/host/xhci-rockchip.c +3
-0+/* 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_REGULATORis not defined ?
This is not defined if CONFIG_DM_REGULATOR is not defined.
Quoted 9 lines
Quoted 9 lines
drivers/usb/host/xhci-rockchip.c +2
-1if (ret) -debug ("rockchip,vbus-gpio node missing!" ); +debug ("Can't get VBus regulator!\n" ); +#endif return 0 ; }
Quoted 9 lines
drivers/usb/host/xhci-rockchip.c static int xhci_usb_ofdata_to_platdata(struct udevice *dev) · line 87
Quoted 8 lines
drivers/usb/host/xhci-rockchip.c +8
-0+#if defined(CONFIG_DM_USB ) && defined(CONFIG_DM_REGULATOR ) +static int rockchip_xhci_set_vbus (struct udevice *vbus_supply,bool value) +{ +int ret; + + ret =regulator_set_enable (vbus_supply, value); +if (ret) +error ("XHCI: Failed to set vbus supply\n" );Please be consistent with the VBus usage. You use VBus above and vbus here.
OK
Quoted 55 lines
Quoted 55 lines
drivers/usb/host/xhci-rockchip.c +18
-5+ + return ret; +} +#else +static int rockchip_xhci_set_vbus (struct udevice *vbus_supply,bool value) +{ +return 0 ; +} +#endif +/* * rockchip_dwc3_phy_setup() - Configure USB PHY Interface of DWC3 Core * @dwc: Pointer to our controller context structure @@ -124,7 +144,7 @@ static int rockchip_xhci_core_init(struct rockchip_xhci *rkxhci, ret =dwc3_core_init (rkxhci->dwc3_reg);if (ret) { -debug ("failed to initialize core\n" ); +error ("failed to initialize core\n" );return ret; }@@ -153,13 +173,15 @@ static int xhci_usb_probe(struct udevice *dev) hcor = (struct xhci_hcor *)((uint64_t )ctx->hcd +HC_LENGTH (xhci_readl (&ctx->hcd->cr_capbase))); -/* setup the Vbus gpio here */ -if (dm_gpio_is_valid (&plat->vbus_gpio)) -dm_gpio_set_value (&plat->vbus_gpio,1 ); +if (plat->vbus_supply) { + ret =rockchip_xhci_set_vbus (plat->vbus_supply, true); +if (ret) +return ret; + } ret =rockchip_xhci_core_init (ctx, dev);if (ret) { -debug ("XHCI: failed to initialize controller\n" ); +error ("XHCI: failed to initialize controller\n" );return ret; }@@ -168,6 +190,7 @@ static int xhci_usb_probe(struct udevice *dev)static int xhci_usb_remove (struct udevice *dev) { +struct rockchip_xhci_platdata *plat =dev_get_platdata (dev);struct rockchip_xhci *ctx =dev_get_priv (dev);int ret;@@ -178,6 +201,12 @@ static int xhci_usb_remove(struct udevice *dev)if (ret)return ret;
Quoted 8 lines
drivers/usb/host/xhci-rockchip.c static int xhci_usb_remove(struct udevice *dev) · line 210
Quoted 7 lines
drivers/usb/host/xhci-rockchip.c +6
-0+if (plat->vbus_supply) { + ret =rockchip_xhci_set_vbus (plat->vbus_supply, false); +if (ret) +return ret; + } +return 0 ;Just do return ret here, then you don't need the if (ret) above.
OK
Quoted 5 lines
Quoted 4 lines
drivers/usb/host/xhci-rockchip.c +0
-0}
PATCH v5 4/11 usb: host: xhci-rockchip: use fixed regulator to control vbus
Quoted 72 lines · rock-chips(daniel.meng)
Quoted 60 lines · Marek Vasut
Quoted 59 lines · Meng Dongyang
Use fixed regulator to control the voltage of vbus and turn off vbus when usb stop.
Signed-off-by Meng Dongyang <[email protected]>---
Changes in v5:
- Propagate return value and print error message when failedChanges in v4:
- Splited from patch [Uboot,v3,04/10]
- Define set vbus as empty function if the macros aren't setChanges in v3: None
Changes in v2:
- Use fixed regulator to control vbus instead of gpiodrivers/usb/host/xhci-rockchip.c | 55 ++++++++++++++++++++++++++++++---------- 1 file changed, 42 insertions(+), 13 deletions(-)drivers/usb/host/xhci-rockchip.c +1
-1@@ -11,10 +11,10 @@#include <malloc.h> #include <usb.h> #include <watchdog.h> -#include <asm/gpio.h> #include <linux/errno.h> #include <linux/compat.h> #include <linux/usb/dwc3.h> +#include <power/regulator.h> #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;drivers/usb/host/xhci-rockchip.c +2
-2-struct gpio_desc vbus_gpio; +struct udevice *vbus_supply; };/* @@ -48,7 +48,7 @@ static int xhci_usb_ofdata_to_platdata(structudevice *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) {drivers/usb/host/xhci-rockchip.c +1
-1-debug ("Can't get the usbphy register address\n" ); +error ("Can't get the usbphy register address\n" );Quoted 8 lines
drivers/usb/host/xhci-rockchip.c static int xhci_usb_ofdata_to_platdata(struct udevice *dev) · line 69
Quoted 6 lines
return -ENXIO; }- /* Vbus gpio */
drivers/usb/host/xhci-rockchip.c +1
-2- 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.
Quoted 8 lines
Yes, I will remove it in v6.
Quoted 6 lines
drivers/usb/host/xhci-rockchip.c static int xhci_usb_ofdata_to_platdata(struct udevice *dev) · line 72
Quoted 4 lines
drivers/usb/host/xhci-rockchip.c +3
-0+/* 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_REGULATORis not defined ?This is not defined if
CONFIG_DM_REGULATORis not defined.
Simon, can you comment on this ?
Daniel, I recommend you fix your mailer to insert at least one newline before the reply text.
Signature · 2 lines
Best regards, Marek Vasut
PATCH v5 4/11 usb: host: xhci-rockchip: use fixed regulator to control vbus
Hi Marek,
Quoted 75 lines · Marek Vasut
Quoted 74 lines · rock-chips(daniel.meng)
Quoted 60 lines · Marek Vasut
Quoted 59 lines · Meng Dongyang
Use fixed regulator to control the voltage of vbus and turn off vbus when usb stop.
Signed-off-by Meng Dongyang <[email protected]>---
Changes in v5:
- Propagate return value and print error message when failedChanges in v4:
- Splited from patch [Uboot,v3,04/10]
- Define set vbus as empty function if the macros aren't setChanges in v3: None
Changes in v2:
- Use fixed regulator to control vbus instead of gpiodrivers/usb/host/xhci-rockchip.c | 55 ++++++++++++++++++++++++++++++---------- 1 file changed, 42 insertions(+), 13 deletions(-)drivers/usb/host/xhci-rockchip.c +1
-1@@ -11,10 +11,10 @@#include <malloc.h> #include <usb.h> #include <watchdog.h> -#include <asm/gpio.h> #include <linux/errno.h> #include <linux/compat.h> #include <linux/usb/dwc3.h> +#include <power/regulator.h> #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;drivers/usb/host/xhci-rockchip.c +2
-2-struct gpio_desc vbus_gpio; +struct udevice *vbus_supply; };/* @@ -48,7 +48,7 @@ static int xhci_usb_ofdata_to_platdata(structudevice *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) {drivers/usb/host/xhci-rockchip.c +1
-1-debug ("Can't get the usbphy register address\n" ); +error ("Can't get the usbphy register address\n" );Quoted 8 lines
drivers/usb/host/xhci-rockchip.c static int xhci_usb_ofdata_to_platdata(struct udevice *dev) · line 69
Quoted 6 lines
return -ENXIO; }- /* Vbus gpio */
drivers/usb/host/xhci-rockchip.c +1
-2- 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.
Quoted 1 line
Quoted 8 lines
Quoted 6 lines
Quoted 5 lines
drivers/usb/host/xhci-rockchip.c static int xhci_usb_ofdata_to_platdata(struct udevice *dev) · line 72
Quoted 3 lines
drivers/usb/host/xhci-rockchip.c +3
-0+/* 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_REGULATORis not defined ?This is not defined if
CONFIG_DM_REGULATORis not defined.Simon, can you comment on this ?
It looks OK to me.
Quoted 7 lines
Daniel, I recommend you fix your mailer to insert at least one newline before the reply text.
--
Best regards,
Marek Vasut
PATCH v5 4/11 usb: host: xhci-rockchip: use fixed regulator to control vbus
Quoted 81 lines · Simon Glass
Hi Marek,
Quoted 78 lines · Marek Vasut
Quoted 77 lines · rock-chips(daniel.meng)
Quoted 60 lines · Marek Vasut
Quoted 59 lines · Meng Dongyang
Use fixed regulator to control the voltage of vbus and turn off vbus when usb stop.
Signed-off-by Meng Dongyang <[email protected]>---
Changes in v5:
- Propagate return value and print error message when failedChanges in v4:
- Splited from patch [Uboot,v3,04/10]
- Define set vbus as empty function if the macros aren't setChanges in v3: None
Changes in v2:
- Use fixed regulator to control vbus instead of gpiodrivers/usb/host/xhci-rockchip.c | 55 ++++++++++++++++++++++++++++++---------- 1 file changed, 42 insertions(+), 13 deletions(-)drivers/usb/host/xhci-rockchip.c +1
-1@@ -11,10 +11,10 @@#include <malloc.h> #include <usb.h> #include <watchdog.h> -#include <asm/gpio.h> #include <linux/errno.h> #include <linux/compat.h> #include <linux/usb/dwc3.h> +#include <power/regulator.h> #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;drivers/usb/host/xhci-rockchip.c +2
-2-struct gpio_desc vbus_gpio; +struct udevice *vbus_supply; };/* @@ -48,7 +48,7 @@ static int xhci_usb_ofdata_to_platdata(structudevice *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) {drivers/usb/host/xhci-rockchip.c +1
-1-debug ("Can't get the usbphy register address\n" ); +error ("Can't get the usbphy register address\n" );Quoted 8 lines
drivers/usb/host/xhci-rockchip.c static int xhci_usb_ofdata_to_platdata(struct udevice *dev) · line 69
Quoted 6 lines
return -ENXIO; }- /* Vbus gpio */
drivers/usb/host/xhci-rockchip.c +1
-2- 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.
Quoted 4 lines
Quoted 4 lines
drivers/usb/host/xhci-rockchip.c +3
-0+/* Vbus regulator */ + ret =device_get_supply_regulator (dev,"vbus-supply" , + &plat->vbus_supply);
Quoted 7 lines
Quoted 5 lines
Quoted 3 lines
Quoted 2 lines
So I was curious, does this expand to empty function or is this not defined if
CONFIG_DM_REGULATORis not defined ?This is not defined if
CONFIG_DM_REGULATORis 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 ?
Signature · 2 lines
Best regards, Marek Vasut
PATCH v5 4/11 usb: host: xhci-rockchip: use fixed regulator to control vbus
Hi Marek,
Quoted 84 lines · Marek Vasut
Quoted 83 lines · Simon Glass
Hi Marek,
Quoted 80 lines · Marek Vasut
Quoted 79 lines · rock-chips(daniel.meng)
Quoted 60 lines · Marek Vasut
Quoted 59 lines · Meng Dongyang
Use fixed regulator to control the voltage of vbus and turn off vbus when usb stop.
Signed-off-by Meng Dongyang <[email protected]>---
Changes in v5:
- Propagate return value and print error message when failedChanges in v4:
- Splited from patch [Uboot,v3,04/10]
- Define set vbus as empty function if the macros aren't setChanges in v3: None
Changes in v2:
- Use fixed regulator to control vbus instead of gpiodrivers/usb/host/xhci-rockchip.c | 55 ++++++++++++++++++++++++++++++---------- 1 file changed, 42 insertions(+), 13 deletions(-)drivers/usb/host/xhci-rockchip.c +1
-1@@ -11,10 +11,10 @@#include <malloc.h> #include <usb.h> #include <watchdog.h> -#include <asm/gpio.h> #include <linux/errno.h> #include <linux/compat.h> #include <linux/usb/dwc3.h> +#include <power/regulator.h> #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;drivers/usb/host/xhci-rockchip.c +2
-2-struct gpio_desc vbus_gpio; +struct udevice *vbus_supply; };/* @@ -48,7 +48,7 @@ static int xhci_usb_ofdata_to_platdata(structudevice *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) {drivers/usb/host/xhci-rockchip.c +1
-1-debug ("Can't get the usbphy register address\n" ); +error ("Can't get the usbphy register address\n" );Quoted 8 lines
drivers/usb/host/xhci-rockchip.c static int xhci_usb_ofdata_to_platdata(struct udevice *dev) · line 69
Quoted 6 lines
return -ENXIO; }- /* Vbus gpio */
drivers/usb/host/xhci-rockchip.c +1
-2- 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.
Quoted 6 lines
drivers/usb/host/xhci-rockchip.c static int xhci_usb_ofdata_to_platdata(struct udevice *dev) · line 72
Quoted 4 lines
drivers/usb/host/xhci-rockchip.c +3
-0+/* 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_REGULATORis not defined ?
Quoted 8 lines
Quoted 5 lines
Quoted 3 lines
Quoted 1 line
This is not defined if
CONFIG_DM_REGULATORis 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_FOOthroughout the codebase ?
You could, but this is just a temporary state while apparently some rockchip boards don't use DM_USB and DM_REGULATOR. I'm not sure what those bad boards are, actually.
Regards,
Simon
PATCH v5 4/11 usb: host: xhci-rockchip: use fixed regulator to control vbus
Quoted 91 lines · Simon Glass
Hi Marek,
Quoted 88 lines · Marek Vasut
Quoted 87 lines · Simon Glass
Hi Marek,
Quoted 83 lines · Marek Vasut
Quoted 72 lines · rock-chips(daniel.meng)
Quoted 60 lines · Marek Vasut
Quoted 59 lines · Meng Dongyang
Use fixed regulator to control the voltage of vbus and turn off vbus when usb stop.
Signed-off-by Meng Dongyang <[email protected]>---
Changes in v5:
- Propagate return value and print error message when failedChanges in v4:
- Splited from patch [Uboot,v3,04/10]
- Define set vbus as empty function if the macros aren't setChanges in v3: None
Changes in v2:
- Use fixed regulator to control vbus instead of gpiodrivers/usb/host/xhci-rockchip.c | 55 ++++++++++++++++++++++++++++++---------- 1 file changed, 42 insertions(+), 13 deletions(-)drivers/usb/host/xhci-rockchip.c +1
-1@@ -11,10 +11,10 @@#include <malloc.h> #include <usb.h> #include <watchdog.h> -#include <asm/gpio.h> #include <linux/errno.h> #include <linux/compat.h> #include <linux/usb/dwc3.h> +#include <power/regulator.h> #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;drivers/usb/host/xhci-rockchip.c +2
-2-struct gpio_desc vbus_gpio; +struct udevice *vbus_supply; };/* @@ -48,7 +48,7 @@ static int xhci_usb_ofdata_to_platdata(structudevice *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) {drivers/usb/host/xhci-rockchip.c +1
-1-debug ("Can't get the usbphy register address\n" ); +error ("Can't get the usbphy register address\n" );Quoted 8 lines
drivers/usb/host/xhci-rockchip.c
Quoted 6 lines
return -ENXIO; }- /* Vbus gpio */
drivers/usb/host/xhci-rockchip.c +1
-2- 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.Quoted 8 lines
Yes, I will remove it in v6.
Quoted 6 lines
drivers/usb/host/xhci-rockchip.c
Quoted 4 lines
drivers/usb/host/xhci-rockchip.c +3
-0+/* 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_REGULATORis not defined ?This is not defined if
CONFIG_DM_REGULATORis not defined.Simon, can you comment on this ?
Quoted 8 lines
Quoted 4 lines
Quoted 1 line
It looks OK to me.
Shouldn't you have empty stub functions instead to avoid proliferation of adhoc #ifdef
CONFIG_FOOthroughout the codebase ?You could, but this is just a temporary state while apparently some rockchip boards don't use
DM_USBandDM_REGULATOR. I'm not sure what those bad boards are, actually.
Temporary state ? What's the final state then ?
Anyway, what if you just disable regulator support (because you don't need it for whatever reason), but want to keep USB ? Wouldn't it make more sense to have empty stub functions instead of swamping the drivers with ifdefs ?
Signature · 2 lines
Best regards, Marek Vasut
PATCH v5 4/11 usb: host: xhci-rockchip: use fixed regulator to control vbus
Hi Marek,
Quoted 94 lines · Marek Vasut
Quoted 93 lines · Simon Glass
Hi Marek,
Quoted 90 lines · Marek Vasut
Quoted 88 lines · Simon Glass
Hi Marek,
Quoted 75 lines · Marek Vasut
Quoted 74 lines · rock-chips(daniel.meng)
Quoted 60 lines · Marek Vasut
Quoted 59 lines · Meng Dongyang
Use fixed regulator to control the voltage of vbus and turn off vbus when usb stop.
Signed-off-by Meng Dongyang <[email protected]>---
Changes in v5:
- Propagate return value and print error message when failedChanges in v4:
- Splited from patch [Uboot,v3,04/10]
- Define set vbus as empty function if the macros aren't setChanges in v3: None
Changes in v2:
- Use fixed regulator to control vbus instead of gpiodrivers/usb/host/xhci-rockchip.c | 55 ++++++++++++++++++++++++++++++---------- 1 file changed, 42 insertions(+), 13 deletions(-)drivers/usb/host/xhci-rockchip.c +1
-1@@ -11,10 +11,10 @@#include <malloc.h> #include <usb.h> #include <watchdog.h> -#include <asm/gpio.h> #include <linux/errno.h> #include <linux/compat.h> #include <linux/usb/dwc3.h> +#include <power/regulator.h> #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;drivers/usb/host/xhci-rockchip.c +2
-2-struct gpio_desc vbus_gpio; +struct udevice *vbus_supply; };/* @@ -48,7 +48,7 @@ static int xhci_usb_ofdata_to_platdata(structudevice *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) {drivers/usb/host/xhci-rockchip.c +1
-1-debug ("Can't get the usbphy register address\n" ); +error ("Can't get the usbphy register address\n" );Quoted 8 lines
drivers/usb/host/xhci-rockchip.c
Quoted 6 lines
return -ENXIO; }- /* Vbus gpio */
drivers/usb/host/xhci-rockchip.c +1
-2- 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.
Quoted 1 line
Quoted 8 lines
Quoted 6 lines
Quoted 5 lines
drivers/usb/host/xhci-rockchip.c
Quoted 3 lines
drivers/usb/host/xhci-rockchip.c +3
-0+/* 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_REGULATORis not defined ?This is not defined if
CONFIG_DM_REGULATORis not defined.Simon, can you comment on this ?
It looks OK to me.
Quoted 8 lines
Quoted 6 lines
Quoted 2 lines
Shouldn't you have empty stub functions instead to avoid proliferation of adhoc #ifdef
CONFIG_FOOthroughout the codebase ?You could, but this is just a temporary state while apparently some rockchip boards don't use
DM_USBandDM_REGULATOR. I'm not sure what those bad boards are, actually.Temporary state ? What's the final state then ?
Well I wasn't aware that any rockchip boards didn't use regulators. Presumably this #ifdef is because of a board that does not.
Quoted 5 lines
Anyway, what if you just disable regulator support (because you don't need it for whatever reason), but want to keep USB ? Wouldn't it make more sense to have empty stub functions instead of swamping the drivers with ifdefs ?
USB would not work without VBUS, which is handled with regulators, so there is something I don't understand here. Anyway I don't see any point in adding stub functions here.
Meng can you please explain why the #ifdef is needed?
Regards,
Simon
PATCH v5 4/11 usb: host: xhci-rockchip: use fixed regulator to control vbus
Quoted 100 lines · Simon Glass
Hi Marek,
Quoted 97 lines · Marek Vasut
Quoted 96 lines · Simon Glass
Hi Marek,
Quoted 92 lines · Marek Vasut
Quoted 81 lines · Simon Glass
Hi Marek,
Quoted 78 lines · Marek Vasut
Quoted 77 lines · rock-chips(daniel.meng)
Quoted 60 lines · Marek Vasut
Quoted 59 lines · Meng Dongyang
Use fixed regulator to control the voltage of vbus and turn off vbus when usb stop.
Signed-off-by Meng Dongyang <[email protected]>---
Changes in v5:
- Propagate return value and print error message when failedChanges in v4:
- Splited from patch [Uboot,v3,04/10]
- Define set vbus as empty function if the macros aren't setChanges in v3: None
Changes in v2:
- Use fixed regulator to control vbus instead of gpiodrivers/usb/host/xhci-rockchip.c | 55 ++++++++++++++++++++++++++++++---------- 1 file changed, 42 insertions(+), 13 deletions(-)drivers/usb/host/xhci-rockchip.c +1
-1@@ -11,10 +11,10 @@#include <malloc.h> #include <usb.h> #include <watchdog.h> -#include <asm/gpio.h> #include <linux/errno.h> #include <linux/compat.h> #include <linux/usb/dwc3.h> +#include <power/regulator.h> #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;drivers/usb/host/xhci-rockchip.c +2
-2-struct gpio_desc vbus_gpio; +struct udevice *vbus_supply; };/* @@ -48,7 +48,7 @@ static int xhci_usb_ofdata_to_platdata(structudevice *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) {drivers/usb/host/xhci-rockchip.c +1
-1-debug ("Can't get the usbphy register address\n" ); +error ("Can't get the usbphy register address\n" );Quoted 8 lines
drivers/usb/host/xhci-rockchip.c
Quoted 6 lines
return -ENXIO; }- /* Vbus gpio */
drivers/usb/host/xhci-rockchip.c +1
-2- 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.
Quoted 4 lines
Quoted 4 lines
drivers/usb/host/xhci-rockchip.c +3
-0+/* Vbus regulator */ + ret =device_get_supply_regulator (dev,"vbus-supply" , + &plat->vbus_supply);Quoted 7 lines
Quoted 5 lines
Quoted 3 lines
Quoted 2 lines
So I was curious, does this expand to empty function or is this not defined if
CONFIG_DM_REGULATORis not defined ?This is not defined if
CONFIG_DM_REGULATORis 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_FOOthroughout the codebase ?
Quoted 8 lines
Quoted 5 lines
Quoted 3 lines
You could, but this is just a temporary state while apparently some rockchip boards don't use
DM_USBandDM_REGULATOR. I'm not sure what those bad boards are, actually.Temporary state ? What's the final state then ?
Well I wasn't aware that any rockchip boards didn't use regulators. Presumably this #ifdef is because of a board that does not.
This is IMO unrelated to rockchip.
Quoted 6 lines
Quoted 4 lines
Anyway, what if you just disable regulator support (because you don't need it for whatever reason), but want to keep USB ? Wouldn't it make more sense to have empty stub functions instead of swamping the drivers with ifdefs ?
USB would not work without VBUS, which is handled with regulators
The VBUS can be directly tied to 5V rail without power switching.
Quoted 3 lines
, so
there is something I don't understand here. Anyway I don't see any point in adding stub functions here.
Not here, into the regulator framework, so you don't have to pollute drivers which use the regulators with ifdefs if the regulator framework is not enabled in the config.
Quoted 5 lines
Meng can you please explain why the #ifdef is needed?
Regards,
Simon
Signature · 2 lines
Best regards, Marek Vasut
PATCH v5 4/11 usb: host: xhci-rockchip: use fixed regulator to control vbus
Quoted 107 lines · Marek Vasut
Quoted 91 lines · Simon Glass
Hi Marek,
Quoted 88 lines · Marek Vasut
Quoted 87 lines · Simon Glass
Hi Marek,
Quoted 84 lines · Marek Vasut
Quoted 83 lines · Simon Glass
Hi Marek,
Quoted 71 lines · Marek Vasut
Quoted 70 lines · rock-chips(daniel.meng)
Quoted 68 lines · Marek Vasut
Quoted 57 lines · Meng Dongyang
Use fixed regulator to control the voltage of vbus and turn off vbus when usb stop.
Signed-off-by Meng Dongyang <[email protected]>---
Changes in v5:
- Propagate return value and print error message when failedChanges in v4:
- Splited from patch [Uboot,v3,04/10]
- Define set vbus as empty function if the macros aren't setChanges in v3: None
Changes in v2:
- Use fixed regulator to control vbus instead of gpiodrivers/usb/host/xhci-rockchip.c | 55 ++++++++++++++++++++++++++++++---------- 1 file changed, 42 insertions(+), 13 deletions(-)drivers/usb/host/xhci-rockchip.c +1
-1@@ -11,10 +11,10 @@#include <malloc.h> #include <usb.h> #include <watchdog.h> -#include <asm/gpio.h> #include <linux/errno.h> #include <linux/compat.h> #include <linux/usb/dwc3.h> +#include <power/regulator.h> #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;drivers/usb/host/xhci-rockchip.c +2
-2-struct gpio_desc vbus_gpio; +struct udevice *vbus_supply; };/* @@ -48,7 +48,7 @@ static int xhci_usb_ofdata_to_platdata(structudevice *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) {drivers/usb/host/xhci-rockchip.c
Quoted 8 lines
drivers/usb/host/xhci-rockchip.c +2
-3-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.Quoted 8 lines
Quoted 7 lines
Yes, I will remove it in v6.
Quoted 5 lines
drivers/usb/host/xhci-rockchip.c
Quoted 3 lines
drivers/usb/host/xhci-rockchip.c +3
-0+/* 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_REGULATORis not defined ?This is not defined if
CONFIG_DM_REGULATORis not defined.Simon, can you comment on this ?
It looks OK to me.
Quoted 8 lines
Quoted 6 lines
Quoted 5 lines
Quoted 2 lines
Shouldn't you have empty stub functions instead to avoid proliferation of adhoc #ifdef
CONFIG_FOOthroughout the codebase ?You could, but this is just a temporary state while apparently some rockchip boards don't use
DM_USBandDM_REGULATOR. I'm not sure what those bad boards are, actually.Temporary state ? What's the final state then ?
Well I wasn't aware that any rockchip boards didn't use regulators. Presumably this #ifdef is because of a board that does not.
This is IMO unrelated to rockchip.
Quoted 5 lines
Quoted 4 lines
Anyway, what if you just disable regulator support (because you don't need it for whatever reason), but want to keep USB ? Wouldn't it make more sense to have empty stub functions instead of swamping the drivers with ifdefs ?
USB would not work without VBUS, which is handled with regulators
Quoted 10 lines
The VBUS can be directly tied to 5V rail without power switching.
Quoted 3 lines
, so
there is something I don't understand here. Anyway I don't see any point in adding stub functions here.Not here, into the regulator framework, so you don't have to pollute drivers which use the regulators with ifdefs if the regulator framework is not enabled in the config.
Quoted 1 line
Meng can you please explain why the #ifdef is needed?
Because the function "device_get_supply_regulator" is undefined if undefined CONFIG_DM_REGULATOR and this will result in a compile error. Maybe the regulator framework can be optimized and make it compiled successful whether define CONFIG_DM_REGULATOR.
So is this #ifdef still needed here?
Quoted 5 lines
Quoted 4 lines
Regards,
Simon
PATCH v5 4/11 usb: host: xhci-rockchip: use fixed regulator to control vbus
Quoted 125 lines · rock-chips(daniel.meng)
Quoted 111 lines · Marek Vasut
Quoted 97 lines · Simon Glass
Hi Marek,
Quoted 94 lines · Marek Vasut
Quoted 93 lines · Simon Glass
Hi Marek,
Quoted 90 lines · Marek Vasut
Quoted 80 lines · Simon Glass
Hi Marek,
Quoted 77 lines · Marek Vasut
Quoted 76 lines · rock-chips(daniel.meng)
Quoted 62 lines · Marek Vasut
Quoted 61 lines · Meng Dongyang
Use fixed regulator to control the voltage of vbus and turn off vbus when usb stop.
Signed-off-by Meng Dongyang <[email protected]>---
Changes in v5:
- Propagate return value and print error message when failedChanges in v4:
- Splited from patch [Uboot,v3,04/10]
- Define set vbus as empty function if the macros aren't setChanges in v3: None
Changes in v2:
- Use fixed regulator to control vbus instead of gpiodrivers/usb/host/xhci-rockchip.c | 55 ++++++++++++++++++++++++++++++---------- 1 file changed, 42 insertions(+), 13 deletions(-)drivers/usb/host/xhci-rockchip.c +1
-1@@ -11,10 +11,10 @@#include <malloc.h> #include <usb.h> #include <watchdog.h> -#include <asm/gpio.h> #include <linux/errno.h> #include <linux/compat.h> #include <linux/usb/dwc3.h> +#include <power/regulator.h> #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;drivers/usb/host/xhci-rockchip.c +2
-2-struct gpio_desc vbus_gpio; +struct udevice *vbus_supply; };/* @@ -48,7 +48,7 @@ static int xhci_usb_ofdata_to_platdata(structudevice *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) {drivers/usb/host/xhci-rockchip.c +1
-1-debug ("Can't get the usbphy register address\n" ); +error ("Can't get the usbphy register address\n" );return -ENXIO ;Quoted 8 lines
drivers/usb/host/xhci-rockchip.c
Quoted 5 lines
}- /* Vbus gpio */
drivers/usb/host/xhci-rockchip.c +1
-2- 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.
Quoted 3 lines
Quoted 3 lines
drivers/usb/host/xhci-rockchip.c +3
-0+/* Vbus regulator */ + ret =device_get_supply_regulator (dev,"vbus-supply" , + &plat->vbus_supply);Quoted 6 lines
Quoted 5 lines
Quoted 4 lines
Quoted 3 lines
So I was curious, does this expand to empty function or is this not
defined ifCONFIG_DM_REGULATORis not defined ?This is not defined if
CONFIG_DM_REGULATORis 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 #ifdefCONFIG_FOOthroughout the codebase ?Quoted 6 lines
Quoted 4 lines
Quoted 3 lines
You could, but this is just a temporary state while apparently some rockchip boards don't use
DM_USBandDM_REGULATOR. I'm not sure what those bad boards are, actually.Temporary state ? What's the final state then ?
Well I wasn't aware that any rockchip boards didn't use regulators. Presumably this #ifdef is because of a board that does not.
This is IMO unrelated to rockchip.
Quoted 5 lines
Quoted 4 lines
Anyway, what if you just disable regulator support (because you don't need it for whatever reason), but want to keep USB ? Wouldn't it make more sense to have empty stub functions instead of swamping the drivers with ifdefs ?
USB would not work without VBUS, which is handled with regulators
Quoted 10 lines
The VBUS can be directly tied to 5V rail without power switching.
Quoted 3 lines
, so
there is something I don't understand here. Anyway I don't see any point in adding stub functions here.Not here, into the regulator framework, so you don't have to pollute drivers which use the regulators with ifdefs if the regulator framework is not enabled in the config.
Quoted 1 line
Meng can you please explain why the #ifdef is needed?
Quoted 7 lines
Because the function "
device_get_supply_regulator" is undefined if undefinedCONFIG_DM_REGULATORand this will result in a compile error. Maybe the regulator
framework can be optimized and make it compiled successful whether defineCONFIG_DM_REGULATOR.
So is this #ifdef still needed here?
Thus my discussion with Simon. Linux does keep the ifdefs in framework header files , so I think we should do the same.
Signature · 2 lines
Best regards, Marek Vasut
PATCH v5 4/11 usb: host: xhci-rockchip: use fixed regulator to control vbus
Quoted 105 lines · Marek Vasut
Quoted 104 lines · rock-chips(daniel.meng)
Quoted 101 lines · Marek Vasut
Quoted 100 lines · Simon Glass
Hi Marek,
Quoted 97 lines · Marek Vasut
Quoted 96 lines · Simon Glass
Hi Marek,
Quoted 84 lines · Marek Vasut
Quoted 83 lines · Simon Glass
Hi Marek,
Quoted 80 lines · Marek Vasut
Quoted 79 lines · rock-chips(daniel.meng)
Quoted 62 lines · Marek Vasut
Quoted 61 lines · Meng Dongyang
Use fixed regulator to control the voltage of vbus and turn off vbus when usb stop.
Signed-off-by Meng Dongyang <[email protected]>---
Changes in v5:
- Propagate return value and print error message when failedChanges in v4:
- Splited from patch [Uboot,v3,04/10]
- Define set vbus as empty function if the macros aren't setChanges 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(-)drivers/usb/host/xhci-rockchip.c +3
-3@@ -11,10 +11,10 @@#include <malloc.h> #include <usb.h> #include <watchdog.h> -#include <asm/gpio.h> #include <linux/errno.h> #include <linux/compat.h> #include <linux/usb/dwc3.h> +#include <power/regulator.h> #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(structudevice *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 intxhci_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;Quoted 8 lines
Quoted 5 lines
}
- /* Vbus gpio */
- ret = gpio_request_by_name(dev, "rockchip,vbus-gpio", 0,
-&plat->vbus_gpio,GPIOD_IS_OUT);
+#ifdefined(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.
Quoted 6 lines
Quoted 3 lines
+ /* 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 ifCONFIG_DM_REGULATORis not defined ?Quoted 6 lines
Quoted 3 lines
Quoted 2 lines
Quoted 1 line
This is not defined if
CONFIG_DM_REGULATORis 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 #ifdefCONFIG_FOOthroughout the codebase ?You could, but this is just a temporary state while apparently some rockchip boards don't use
DM_USBandDM_REGULATOR. I'm not sure what those bad boards are, actually.
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 3 lines
Quoted 1 line
Temporary state ? What's the final state then ?
Well I wasn't aware that any rockchip boards didn't use regulators. Presumably this #ifdef is because of a board that does not.
This is IMO unrelated to rockchip.
Quoted 3 lines
Quoted 3 lines
Anyway, what if you just disable regulator support (because you don't need it for whatever reason), but want to keep USB ? Wouldn't it make more sense to have empty stub functions instead of swamping the
drivers
Quoted 21 lines
Quoted 13 lines
Quoted 12 lines
Quoted 2 lines
Quoted 1 line
with ifdefs ?
USB would not work without VBUS, which is handled with regulators
The VBUS can be directly tied to 5V rail without power switching.
Quoted 3 lines
, so
there is something I don't understand here. Anyway I don't see any point in adding stub functions here.Not here, into the regulator framework, so you don't have to pollute drivers which use the regulators with ifdefs if the regulator framework is not enabled in the config.
Quoted 1 line
Meng can you please explain why the #ifdef is needed?
Quoted 7 lines
Because the function "
device_get_supply_regulator" is undefined if undefinedCONFIG_DM_REGULATORand this will result in a compile error. Maybe the regulator
framework can be optimized and make it compiled successful whether defineCONFIG_DM_REGULATOR.
So is this #ifdef still needed here?
Quoted 2 lines
Thus my discussion with Simon. Linux does keep the ifdefs in framework header files , so I think we should do the same.
OK, but arguably that is a separate issue from this patch.
Also I hope we can always enable DM_REGULATOR for rockchip and drop the #ifdefs.
Regards,
Simon
PATCH v5 4/11 usb: host: xhci-rockchip: use fixed regulator to control vbus
Quoted 141 lines · Simon Glass
Quoted 8 lines · On 19 June 2017 at 04:15, Marek Vasut <[email protected] <mailto:[email protected]>>…
Quoted 7 lines · rock-chips(daniel.meng)
Quoted 4 lines · Marek Vasut
Quoted 3 lines · Simon Glass
Hi Marek,
On 17 June 2017 at 13:33, Marek Vasut <[email protected]
Quoted 4 lines · <mailto:[email protected]>> wrote:
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines · Simon Glass
Quoted 3 lines
Hi Marek,
On 17 June 2017 at 00:22, Marek Vasut <[email protected]
Quoted 4 lines · <mailto:[email protected]>> wrote:
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines · Simon Glass
Quoted 3 lines
Hi Marek,
On 15 June 2017 at 10:53, Marek Vasut <[email protected]
Quoted 8 lines · <mailto:[email protected]>> wrote:
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines · rock-chips(daniel.meng)
Quoted 7 lines · Marek Vasut
Quoted 5 lines · Meng Dongyang
Quoted 4 lines
Use fixed regulator to control the voltage of vbus and turn off
vbus when usb stop.Signed-off-by: Meng Dongyang <[email protected]
<mailto:[email protected]>>
Quoted 81 lines
Quoted 81 lines
Quoted 81 lines
Quoted 81 lines
Quoted 81 lines
Quoted 81 lines
Quoted 72 lines
Quoted 72 lines
Quoted 72 lines
Quoted 72 lines
Quoted 57 lines
Quoted 57 lines
---
Changes in v5:
- Propagate return value and print error message when failedChanges in v4:
- Splited from patch [Uboot,v3,04/10]
- Define set vbus as empty function if the macros aren't setChanges in v3: None
Changes in v2:
- Use fixed regulator to control vbus instead of gpiodrivers/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 <malloc.h>
#include <usb.h>
#include <watchdog.h>
-#include <asm/gpio.h>
#include <linux/errno.h>
#include <linux/compat.h>
#include <linux/usb/dwc3.h>
+#include <power/regulator.h>
#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;Quoted 8 lines
Quoted 5 lines
}
- /* 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.
Quoted 6 lines
Quoted 3 lines
+ /* 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 ifCONFIG_DM_REGULATORis not defined ?Quoted 6 lines
Quoted 3 lines
Quoted 2 lines
Quoted 1 line
This is not defined if
CONFIG_DM_REGULATORis 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 #ifdefCONFIG_FOOthroughout the codebase ?You could, but this is just a temporary state while apparently some rockchip boards don't use
DM_USBandDM_REGULATOR. I'm not sure what those bad boards are, actually.Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 3 lines
Quoted 1 line
Temporary state ? What's the final state then ?
Well I wasn't aware that any rockchip boards didn't use regulators. Presumably this #ifdef is because of a board that does not.
This is IMO unrelated to rockchip.
Quoted 3 lines
Quoted 3 lines
Anyway, what if you just disable regulator support (because you don't need it for whatever reason), but want to keep USB ? Wouldn't it make more sense to have empty stub functions instead of swamping the
drivers
Quoted 21 lines
Quoted 20 lines
Quoted 12 lines
Quoted 2 lines
Quoted 1 line
with ifdefs ?
USB would not work without VBUS, which is handled with regulators
The VBUS can be directly tied to 5V rail without power switching.
Quoted 3 lines
, so
there is something I don't understand here. Anyway I don't see any point in adding stub functions here.Not here, into the regulator framework, so you don't have to pollute drivers which use the regulators with ifdefs if the regulator framework is not enabled in the config.
Quoted 1 line
Meng can you please explain why the #ifdef is needed?
Because the function "
device_get_supply_regulator" is undefined if undefinedCONFIG_DM_REGULATORand this will result in a compile error. Maybe the regulator
framework can be optimized and make it compiled successful whether defineCONFIG_DM_REGULATOR.
So is this #ifdef still needed here?
Quoted 4 lines
Quoted 2 lines
Thus my discussion with Simon. Linux does keep the ifdefs in framework header files , so I think we should do the same.
OK, but arguably that is a separate issue from this patch.
It is, and I believe it should be discussed and possibly fixed.
Quoted 2 lines
Also I hope we can always enable
DM_REGULATORfor rockchip and drop the #ifdefs.
If the driver explicitly depends on DM_REGULATOR in Kconfig , then yes.
Signature · 2 lines
Best regards, Marek Vasut
PATCH v5 5/11 usb: host: xhci-rockchip: add support for rk3328
In reply to Meng DongyangAdd the compatible "rockchip,rk3328-xhci" in match table for rk3328 to probe xhci controller.
---
Chagnes in v5: None
Changes in v4:
- New patch, splited from patch [Uboot,v3,04/10]
drivers/usb/host/xhci-rockchip.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/usb/host/xhci-rockchip.c +2 -0
@@ -212,6 +212,7 @@ static int xhci_usb_remove(struct udevice *dev)static const struct udevice_id xhci_usb_ids[] = { { .compatible ="rockchip,rk3399-xhci" }, + { .compatible ="rockchip,rk3328-xhci" }, { } };
@@ -231,6 +232,7 @@ U_BOOT_DRIVER(usb_xhci) = {static const struct udevice_id usb_phy_ids[] = { { .compatible ="rockchip,rk3399-usb3-phy" }, + { .compatible ="rockchip,rk3328-usb3-phy" }, { } };
Signature · 1 line
1.9.1
PATCH v5 5/11 usb: host: xhci-rockchip: add support for rk3328
Quoted 4 lines · Meng Dongyang
Add the compatible "rockchip,rk3328-xhci" in match table for rk3328 to probe xhci controller.
Signed-off-by Meng Dongyang <[email protected]>
Quoted 8 lines
---
Chagnes in v5: None
Changes in v4:
- New patch, splited from patch [Uboot,v3,04/10]drivers/usb/host/xhci-rockchip.c | 2 ++ 1 file changed, 2 insertions(+)
PATCH v5 6/11 rockchip: dts: rk3328: support and enable xhci
In reply to Meng DongyangAdd dts node of xhci and enable the controller.
---
changes in v5: None
Changes in v4: None
Changes in v3: None
arch/arm/dts/rk3328-evb.dts | 14 ++++++++++++++ arch/arm/dts/rk3328.dtsi | 11 +++++++++++ 2 files changed, 25 insertions(+)
arch/arm/dts/rk3328-evb.dts +14 -0
@@ -14,6 +14,15 @@ chosen { stdout-path = &uart2; }; + + vcc5v0_host_xhci: vcc5v0-host-xhci-drv { + compatible = "regulator-fixed"; + enable-active-high; + regulator-name = "vcc5v0_host_xhci"; + gpio = <&gpio0 0 GPIO_ACTIVE_HIGH>; + regulator-min-microvolt = <5000000>; + regulator-max-microvolt = <5000000>; + }; }; &uart2 {
@@ -51,3 +60,8 @@ &usb_host0_ohci { status = "okay"; }; + +&usb_host0_xhci { + vbus-supply = <&vcc5v0_host_xhci>; + status = "okay"; +};
arch/arm/dts/rk3328.dtsi +11 -0
@@ -471,6 +471,17 @@ status = "disabled"; }; + usb_host0_xhci: usb at ff600000 { + compatible = "rockchip,rk3328-xhci"; + reg = <0x0 0xff600000 0x0 0x100000>; + interrupts = <GIC_SPI 67 IRQ_TYPE_LEVEL_HIGH>; + snps,dis-enblslpm-quirk; + snps,phyif-utmi-bits = <16>; + snps,dis-u2-freeclk-exists-quirk; + snps,dis-u2-susphy-quirk; + status = "disabled"; + }; + gic: interrupt-controller at ffb70000 { compatible = "arm,gic-400"; #interrupt-cells = <3>;
Signature · 1 line
1.9.1
PATCH v5 7/11 rockchip: configs: rk3328: enable dwc2 driver and config fastboot
In reply to Meng DongyangConfig dwc2 driver support host and gadget function. Add support of fastboot function.
---
Changes in v5: None
Changes in v4: None
Changes in v3: None
Changes in v2: None
configs/evb-rk3328_defconfig | 14 ++++++++++++++ include/configs/rk3328_common.h | 3 +++ 2 files changed, 17 insertions(+)
configs/evb-rk3328_defconfig +14 -0
@@ -42,3 +42,17 @@ CONFIG_USB_OHCI_GENERIC=y CONFIG_USB_XHCI_DWC3=y CONFIG_USB_XHCI_HCD=y CONFIG_USB_XHCI_RK=y +CONFIG_USB_GADGET=y +CONFIG_USB_GADGET_DOWNLOAD=y +CONFIG_USB_GADGET_DUALSPEED=y +CONFIG_USB_GADGET_DWC2_OTG=y +CONFIG_USB_FUNCTION_FASTBOOT=y +CONFIG_G_DNL_MANUFACTURER="Rockchip" +CONFIG_G_DNL_VENDOR_NUM=0x2207 +CONFIG_G_DNL_PRODUCT_NUM=0x330a +CONFIG_FASTBOOT=y +CONFIG_CMD_FASTBOOT=y +CONFIG_FASTBOOT_FLASH=y +CONFIG_FASTBOOT_FLASH_MMC_DEV=1 +CONFIG_FASTBOOT_BUF_ADDR=0x00800800 +CONFIG_FASTBOOT_BUF_SIZE=0x08000000
include/configs/rk3328_common.h +3 -0
@@ -61,6 +61,9 @@#endif +/* dwc2 otg */ +#define CONFIG_USB_DWC2 +/* rockchip ohci host driver */ #define CONFIG_USB_OHCI_NEW #define CONFIG_SYS_USB_OHCI_MAX_ROOT_PORTS 1
Signature · 1 line
1.9.1
PATCH v5 8/11 usb: dwc2: force to host mode if not support HNP/SRP
In reply to Meng DongyangIn current code, after running the command of "usb start", the controller will keep in otg mode and can't switch to host mode if not support SNP/SRP capability. So add the property of "hnp-srp-disable" in the DTS to config the contrller work in force mode of host.
---
Changes in v5: None
Changes in v4:
- Prepare a mask and set capabilities in GUSBCFG register once
Changes in v3:
- revert change of macro definition in dwc2 driver
- support host mode without HNP/SRP capability through DTS
Changes in v2:
- Splited from patch [07/08] of v1
drivers/usb/host/dwc2.c | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-)
drivers/usb/host/dwc2.c +16 -3
@@ -43,6 +43,7 @@ struct dwc2_priv {struct dwc2_core_regs *regs;int root_hub_devnum;bool ext_vbus; +bool hnp_srp_disable;bool oc_disable; };
@@ -394,6 +395,9 @@ static void dwc_otg_core_init(struct dwc2_priv *priv) usbcfg |= DWC2_GUSBCFG_ULPI_CLK_SUS_M; }#endif +if (priv->hnp_srp_disable) + usbcfg |=DWC2_GUSBCFG_FORCEHOSTMODE ; +writel (usbcfg, ®s->gusbcfg);/* Program the GAHBCFG Register. */
@@ -422,12 +426,16 @@ static void dwc_otg_core_init(struct dwc2_priv *priv)writel (ahbcfg, ®s->gahbcfg); -/* Program the GUSBCFG register for HNP/SRP. */ -setbits_le32 (®s->gusbcfg,DWC2_GUSBCFG_HNPCAP |DWC2_GUSBCFG_SRPCAP ); +/* Program the capabilities in GUSBCFG Register */ + usbcfg =0 ; +if (!priv->hnp_srp_disable) + usbcfg |=DWC2_GUSBCFG_HNPCAP |DWC2_GUSBCFG_SRPCAP ;#ifdef CONFIG_DWC2_IC_USB_CAP -setbits_le32 (®s->gusbcfg,DWC2_GUSBCFG_IC_USB_CAP ); + usbcfg |=DWC2_GUSBCFG_IC_USB_CAP ;#endif + +setbits_le32 (®s->gusbcfg, usbcfg); }/*
@@ -1244,6 +1252,11 @@ static int dwc2_usb_ofdata_to_platdata(struct udevice *dev)if (prop) priv->oc_disable = true; + prop =fdt_getprop (gd->fdt_blob,dev_of_offset (dev), +"hnp-srp-disable" ,NULL ); +if (prop) + priv->hnp_srp_disable = true; +return 0 ; }
Signature · 1 line
1.9.1
PATCH v5 8/11 usb: dwc2: force to host mode if not support HNP/SRP
Hi Meng,
Quoted 16 lines · Meng Dongyang
In current code, after running the command of "usb start", the controller will keep in otg mode and can't switch to host mode if not support SNP/SRP capability. So add the property of "hnp-srp-disable" in the DTS to config the contrller work in force mode of host.
Signed-off-by Meng Dongyang <[email protected]>---
Changes in v5: None
Changes in v4:
- Prepare a mask and set capabilities in GUSBCFG register onceChanges in v3:
- revert change of macro definition in dwc2 driver
- support host mode without HNP/SRP capability through DTS
Quoted 5 lines
Changes in v2:
- Splited from patch [07/08] of v1drivers/usb/host/dwc2.c | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-)
Please see below.
drivers/usb/host/dwc2.c struct dwc2_priv { · line 46
Quoted 10 lines
drivers/usb/host/dwc2.c +1
-0@@ -43,6 +43,7 @@ struct dwc2_priv {struct dwc2_core_regs *regs;int root_hub_devnum;bool ext_vbus; +bool hnp_srp_disable;
Please add a comment for this that fully describes its effect.
Quoted 34 lines
drivers/usb/host/dwc2.c +10
-3bool oc_disable; };@@ -394,6 +395,9 @@ static void dwc_otg_core_init(struct dwc2_priv *priv) usbcfg |= DWC2_GUSBCFG_ULPI_CLK_SUS_M; }#endif +if (priv->hnp_srp_disable) + usbcfg |=DWC2_GUSBCFG_FORCEHOSTMODE ; +writel (usbcfg, ®s->gusbcfg);/* Program the GAHBCFG Register. */ @@ -422,12 +426,16 @@ static void dwc_otg_core_init(struct dwc2_priv *priv)writel (ahbcfg, ®s->gahbcfg); -/* Program the GUSBCFG register for HNP/SRP. */ -setbits_le32 (®s->gusbcfg,DWC2_GUSBCFG_HNPCAP |DWC2_GUSBCFG_SRPCAP ); +/* Program the capabilities in GUSBCFG Register */ + usbcfg =0 ; +if (!priv->hnp_srp_disable) + usbcfg |=DWC2_GUSBCFG_HNPCAP |DWC2_GUSBCFG_SRPCAP ;#ifdef CONFIG_DWC2_IC_USB_CAP -setbits_le32 (®s->gusbcfg,DWC2_GUSBCFG_IC_USB_CAP ); + usbcfg |=DWC2_GUSBCFG_IC_USB_CAP ;#endif + +setbits_le32 (®s->gusbcfg, usbcfg); }/*
drivers/usb/host/dwc2.c static int dwc2_usb_ofdata_to_platdata(struct udevice *dev) · line 1256
Quoted 5 lines
drivers/usb/host/dwc2.c +2
-0@@ -1244,6 +1252,11 @@ static int dwc2_usb_ofdata_to_platdata(struct udevice *dev)if (prop) priv->oc_disable = true; + prop =fdt_getprop (gd->fdt_blob,dev_of_offset (dev), +"hnp-srp-disable" ,NULL );
Can you use dev_read_boot() (preferred) or fdtdec_get_bool()?
Quoted 10 lines
drivers/usb/host/dwc2.c +3
-1+if (prop) + priv->hnp_srp_disable = true; +return 0 ; } --1.9.1
Regards,
Simon
PATCH v5 8/11 usb: dwc2: force to host mode if not support HNP/SRP
Sorry I just see this email.
Quoted 28 lines · Simon Glass
Hi Meng,
Quoted 16 lines · Meng Dongyang
In current code, after running the command of "usb start", the controller will keep in otg mode and can't switch to host mode if not support SNP/SRP capability. So add the property of "hnp-srp-disable" in the DTS to config the contrller work in force mode of host.
Signed-off-by Meng Dongyang <[email protected]>---
Changes in v5: None
Changes in v4:
- Prepare a mask and set capabilities in GUSBCFG register onceChanges in v3:
- revert change of macro definition in dwc2 driver
- support host mode without HNP/SRP capability through DTSQuoted 5 lines
Changes in v2:
- Splited from patch [07/08] of v1drivers/usb/host/dwc2.c | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-)Reviewed-by Simon Glass <[email protected]>Please see below.
Quoted 10 lines
drivers/usb/host/dwc2.c struct dwc2_priv { · line 46
Quoted 9 lines
drivers/usb/host/dwc2.c +1
-0@@ -43,6 +43,7 @@ struct dwc2_priv {struct dwc2_core_regs *regs;int root_hub_devnum;bool ext_vbus; +bool hnp_srp_disable;Please add a comment for this that fully describes its effect.
OK.
Quoted 33 lines
Quoted 33 lines
drivers/usb/host/dwc2.c +10
-3bool oc_disable; };@@ -394,6 +395,9 @@ static void dwc_otg_core_init(struct dwc2_priv *priv) usbcfg |= DWC2_GUSBCFG_ULPI_CLK_SUS_M; }#endif +if (priv->hnp_srp_disable) + usbcfg |=DWC2_GUSBCFG_FORCEHOSTMODE ; +writel (usbcfg, ®s->gusbcfg);/* Program the GAHBCFG Register. */ @@ -422,12 +426,16 @@ static void dwc_otg_core_init(struct dwc2_priv *priv)writel (ahbcfg, ®s->gahbcfg); -/* Program the GUSBCFG register for HNP/SRP. */ -setbits_le32 (®s->gusbcfg,DWC2_GUSBCFG_HNPCAP |DWC2_GUSBCFG_SRPCAP ); +/* Program the capabilities in GUSBCFG Register */ + usbcfg =0 ; +if (!priv->hnp_srp_disable) + usbcfg |=DWC2_GUSBCFG_HNPCAP |DWC2_GUSBCFG_SRPCAP ;#ifdef CONFIG_DWC2_IC_USB_CAP -setbits_le32 (®s->gusbcfg,DWC2_GUSBCFG_IC_USB_CAP ); + usbcfg |=DWC2_GUSBCFG_IC_USB_CAP ;#endif + +setbits_le32 (®s->gusbcfg, usbcfg); }
Quoted 8 lines
drivers/usb/host/dwc2.c static int dwc2_usb_ofdata_to_platdata(struct udevice *dev) · line 1256
Quoted 7 lines
drivers/usb/host/dwc2.c +2
-0/* @@ -1244,6 +1252,11 @@ static int dwc2_usb_ofdata_to_platdata(struct udevice *dev)if (prop) priv->oc_disable = true; + prop =fdt_getprop (gd->fdt_blob,dev_of_offset (dev), +"hnp-srp-disable" ,NULL );Can you use
dev_read_boot()(preferred) orfdtdec_get_bool()?
OK.
Quoted 16 lines
Quoted 11 lines
drivers/usb/host/dwc2.c +3
-1+if (prop) + priv->hnp_srp_disable = true; +return 0 ; } --1.9.1
Regards,
Simon
PATCH v5 9/11 rockchip: rk3328: board: add support of dwc2 gadget
In reply to Meng DongyangProbe dwc2 udc in the function of board_usb_start to enable usb gadget function.
---
Chagnes in v5: None
Changes in v4: None
Changes in v3: None
board/rockchip/evb_rk3328/evb-rk3328.c | 43 +++++++++++++++++++++++++++++++--- 1 file changed, 40 insertions(+), 3 deletions(-)
board/rockchip/evb_rk3328/evb-rk3328.c +40 -3
@@ -31,12 +31,49 @@ int dram_init_banksize(void)return 0 ; } -int usb_gadget_handle_interrupts (void ) +#if defined(CONFIG_USB_GADGET ) && defined(CONFIG_USB_GADGET_DWC2_OTG ) +#include <usb.h> +#include <usb/dwc2_udc.h> + +static struct dwc2_plat_otg_data rk3328_otg_data = { + .rx_fifo_sz =512 , + .np_tx_fifo_sz =16 , + .tx_fifo_sz =128 , +}; + +int board_usb_init (int index,enum usb_init_type init) { -return 0 ; +int node; +const char *mode; +bool matched = false; +const void *blob = gd->fdt_blob; + +/* find the usb_otg node */ + node =fdt_node_offset_by_compatible (blob,-1 , +"rockchip,rk3328-usb" ); + +while (node >0 ) { + mode =fdt_getprop (blob, node,"dr_mode" ,NULL ); +if (mode &&strcmp (mode,"otg" ) ==0 ) { + matched = true; +break ; + } + + node =fdt_node_offset_by_compatible (blob, node, +"rockchip,rk3328-usb" ); + } +if (!matched) { +debug ("Not found usb_otg device\n" ); +return -ENODEV ; + } + + rk3328_otg_data.regs_otg =fdtdec_get_addr (blob, node,"reg" ); + +return dwc2_udc_probe (&rk3328_otg_data); } -int board_usb_init (int index,enum usb_init_type init) +int board_usb_cleanup (int index,enum usb_init_type init) {return 0 ; } +#endif
Signature · 1 line
1.9.1
PATCH v5 10/11 rockchip: dts: rk3328: support and enable dwc2
In reply to Meng DongyangEnable dwc2 controller and add fixed regulator for dwc2 controller to control vbus.
---
Changes in v5: None
Changes in v4: None
Changes in v3:
- add hnp-srp-disable property
arch/arm/dts/rk3328-evb.dts | 14 ++++++++++++++ arch/arm/dts/rk3328.dtsi | 10 ++++++++++ 2 files changed, 24 insertions(+)
arch/arm/dts/rk3328-evb.dts +14 -0
@@ -15,6 +15,15 @@ stdout-path = &uart2; }; + vcc5v0_otg: vcc5v0-otg-drv { + compatible = "regulator-fixed"; + enable-active-high; + regulator-name = "vcc5v0_otg"; + gpio = <&gpio0 27 GPIO_ACTIVE_HIGH>; + regulator-min-microvolt = <5000000>; + regulator-max-microvolt = <5000000>; + }; + vcc5v0_host_xhci: vcc5v0-host-xhci-drv { compatible = "regulator-fixed"; enable-active-high;
@@ -61,6 +70,11 @@ status = "okay"; }; +&usb20_otg { + vbus-supply = <&vcc5v0_otg>; + status = "okay"; +}; + &usb_host0_xhci { vbus-supply = <&vcc5v0_host_xhci>; status = "okay";
arch/arm/dts/rk3328.dtsi +10 -0
@@ -460,6 +460,16 @@ status = "disabled"; }; + usb20_otg: usb at ff580000 { + compatible = "rockchip,rk3328-usb", "rockchip,rk3066-usb", + "snps,dwc2"; + reg = <0x0 0xff580000 0x0 0x40000>; + interrupts = <GIC_SPI 23 IRQ_TYPE_LEVEL_HIGH>; + hnp-srp-disable; + dr_mode = "otg"; + status = "disabled"; + }; + sdmmc_ext: rksdmmc at ff5f0000 { compatible = "rockchip,rk3328-dw-mshc", "rockchip,rk3288-dw-mshc"; reg = <0x0 0xff5f0000 0x0 0x4000>;
Signature · 1 line
1.9.1
PATCH v5 11/11 rockchip: dts: rk3399: control vbus of typec by fixed regulator
In reply to Meng DongyangAdd fixed regulator for the port of typec0 and typec1 to control vbus instead of gpio.
---
Changes in v5: None
Changes in v4: None
Changes in v3: None
Changes in v2:
- New change, add fixed regulator for rk3399
arch/arm/dts/rk3399-evb.dts | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-)
arch/arm/dts/rk3399-evb.dts +14 -2
@@ -60,6 +60,18 @@ gpio = <&gpio4 25 GPIO_ACTIVE_HIGH>; }; + vcc5v0_typec0: vcc5v0-typec0-en { + compatible = "regulator-fixed"; + regulator-name = "vcc5v0_typec0"; + gpio = <&gpio1 3 GPIO_ACTIVE_HIGH>; + }; + + vcc5v0_typec1: vcc5v0-typec1-en { + compatible = "regulator-fixed"; + regulator-name = "vcc5v0_typec1"; + gpio = <&gpio1 4 GPIO_ACTIVE_HIGH>; + }; + clkin_gmac: external-gmac-clock { compatible = "fixed-clock"; clock-frequency = <125000000>;
@@ -163,7 +175,7 @@ }; &dwc3_typec0 { - rockchip,vbus-gpio = <&gpio1 3 GPIO_ACTIVE_HIGH>; + vbus-supply = <&vcc5v0_typec0>; status = "okay"; };
@@ -176,7 +188,7 @@ }; &dwc3_typec1 { - rockchip,vbus-gpio = <&gpio1 4 GPIO_ACTIVE_HIGH>; + vbus-supply = <&vcc5v0_typec1>; status = "okay"; };
Signature · 1 line
1.9.1