rk3328: add support of usb host and gadget
Subsystems (4)
v3 cover rk3328: add support of usb host and gadget
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 (10):
configs: rk3328: add support for usb and config ehci and ohci driver
rockchip: dts: rk3328: add ehci and ohci node and enable host0 port
configs: rk3328: config xhci controller
usb: host: xhci-rockchip: add support for rk3328
rockchip: dts: rk3328: support and enable xhci
configs: rk3328: enable dwc2 driver and config for fastboot
usb: dwc2: force to host mode if HNP/SRP not support
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 | 13 +++++++++- drivers/usb/host/xhci-rockchip.c | 31 +++++++++++++++++------- include/configs/rk3328_common.h | 9 +++++++ 8 files changed, 193 insertions(+), 15 deletions(-)
Signature · 1 line
1.9.1
PATCH v3 1/10 configs: rk3328: add support for usb and config ehci and ohci driver
Add defconfig for usb and ehci and ohci controller, config maximal number of ports of the root hub for ohci driver.
---
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 v3 2/10 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 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 v3 3/10 configs: rk3328: config xhci controller
In reply to Meng DongyangAdd config of max root ports and add config to enable xhci controller.
---
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 v3 4/10 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. Use fixed regulator to control the voltage of vbus and turn off vbus when usb stop.
---
Changes in v3: None
Changes in v2:
- Use fixed regulator to control vbus instead of gpio
drivers/usb/host/xhci-rockchip.c | 31 ++++++++++++++++++++++--------- 1 file changed, 22 insertions(+), 9 deletions(-)
drivers/usb/host/xhci-rockchip.c +22 -9
@@ -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; };/*
@@ -66,11 +66,13 @@ static int xhci_usb_ofdata_to_platdata(struct udevice *dev)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 supply\n" ); +#endif return 0 ; }
@@ -153,9 +155,11 @@ 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 defined(CONFIG_DM_USB ) && defined(CONFIG_DM_REGULATOR ) + ret =regulator_set_enable (plat->vbus_supply, true); +if (ret) +debug ("XHCI: Failed to enable vbus supply\n" ); +#endif ret =rockchip_xhci_core_init (ctx, dev);if (ret) {
@@ -168,6 +172,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,11 +183,18 @@ static int xhci_usb_remove(struct udevice *dev)if (ret)return ret; +#if defined(CONFIG_DM_USB ) && defined(CONFIG_DM_REGULATOR ) + ret =regulator_set_enable (plat->vbus_supply, false); +if (ret) +debug ("XHCI: Failed to disable vbus supply\n" ); +#endif +return 0 ; }static const struct udevice_id xhci_usb_ids[] = { { .compatible ="rockchip,rk3399-xhci" }, + { .compatible ="rockchip,rk3328-xhci" }, { } };
@@ -202,6 +214,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 v3 4/10 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. Use fixed regulator to control the voltage of vbus and turn off vbus when usb stop.
That's two patches in one, please split.
Quoted 79 lines
Signed-off-by Meng Dongyang <[email protected]>Reviewed-by Simon Glass <[email protected]>---
Changes in v3: None
Changes in v2:
- Use fixed regulator to control vbus instead of gpiodrivers/usb/host/xhci-rockchip.c | 31 ++++++++++++++++++++++--------- 1 file changed, 22 insertions(+), 9 deletions(-)drivers/usb/host/xhci-rockchip.c +14
-9@@ -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; };/* @@ -66,11 +66,13 @@ static int xhci_usb_ofdata_to_platdata(struct udevice *dev)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 supply\n" ); +#endif return 0 ; }@@ -153,9 +155,11 @@ 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 defined(CONFIG_DM_USB ) && defined(CONFIG_DM_REGULATOR ) + ret =regulator_set_enable (plat->vbus_supply, true); +if (ret) +debug ("XHCI: Failed to enable vbus supply\n" ); +#endif ret =rockchip_xhci_core_init (ctx, dev);if (ret) {@@ -168,6 +172,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 187
Quoted 5 lines
drivers/usb/host/xhci-rockchip.c +2
-0@@ -178,11 +183,18 @@ static int xhci_usb_remove(struct udevice *dev)if (ret)return ret; +#if defined(CONFIG_DM_USB ) && defined(CONFIG_DM_REGULATOR ) + ret =regulator_set_enable (plat->vbus_supply, false);
Shouldn't this be defined as empty function if the above macros aren't set ?
Quoted 22 lines
drivers/usb/host/xhci-rockchip.c +6
-0+if (ret) +debug ("XHCI: Failed to disable vbus supply\n" ); +#endif +return 0 ; }static const struct udevice_id xhci_usb_ids[] = { { .compatible ="rockchip,rk3399-xhci" }, + { .compatible ="rockchip,rk3328-xhci" }, { } };@@ -202,6 +214,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 · 2 lines
Best regards, Marek Vasut