[U-Boot] [PATCH 0/4] enable the host controller for rk3036

To enable usb host function, you need: - enable the host port power, usually controled by a gpio named vbus_drv; - enable the controller driver like dwc2; - enable the usb framework like CONFIG_CMD_USB and CONFIG_USB; - enable the usb function like storage or ether;
Kever Yang (4): config: rk3036: enable configs for USB HOST config: rk3036: enable fix regulator dts: arm: rk3036: add usb vbus node rk3036: enable the vbus regulator when borad_init
arch/arm/dts/rk3036-sdk.dts | 37 +++++++++++++++++++++++++++++++---- arch/arm/mach-rockchip/rk3036-board.c | 20 +++++++++++++++++++ configs/kylin-rk3036_defconfig | 4 ++++ include/configs/rk3036_common.h | 7 +++++++ 4 files changed, 64 insertions(+), 4 deletions(-)

rk3036 using dwc2 usb controller, need enable relate configs for it.
Signed-off-by: Kever Yang kever.yang@rock-chips.com ---
configs/kylin-rk3036_defconfig | 3 +++ include/configs/rk3036_common.h | 7 +++++++ 2 files changed, 10 insertions(+)
diff --git a/configs/kylin-rk3036_defconfig b/configs/kylin-rk3036_defconfig index 424cdab..5a8b85a 100644 --- a/configs/kylin-rk3036_defconfig +++ b/configs/kylin-rk3036_defconfig @@ -36,3 +36,6 @@ CONFIG_RAM=y CONFIG_SYSRESET=y CONFIG_CMD_DHRYSTONE=y CONFIG_ERRNO_STR=y +CONFIG_CMD_USB=y +CONFIG_USB=y +CONFIG_USB_STORAGE=y diff --git a/include/configs/rk3036_common.h b/include/configs/rk3036_common.h index 4eef3f8..92be29e 100644 --- a/include/configs/rk3036_common.h +++ b/include/configs/rk3036_common.h @@ -79,6 +79,13 @@ #define CONFIG_G_DNL_VENDOR_NUM 0x2207 #define CONFIG_G_DNL_PRODUCT_NUM 0x310a
+/* usb host */ +#ifdef CONFIG_CMD_USB +#define CONFIG_USB_DWC2 +#define CONFIG_USB_HOST_ETHER +#define CONFIG_USB_ETHER_SMSC95XX +#define CONFIG_USB_ETHER_ASIX +#endif #define ENV_MEM_LAYOUT_SETTINGS \ "scriptaddr=0x60000000\0" \ "pxefile_addr_r=0x60100000\0" \

Hi Kever,
On 8 November 2016 at 03:13, Kever Yang kever.yang@rock-chips.com wrote:
rk3036 using dwc2 usb controller, need enable relate configs for it.
Signed-off-by: Kever Yang kever.yang@rock-chips.com
configs/kylin-rk3036_defconfig | 3 +++ include/configs/rk3036_common.h | 7 +++++++ 2 files changed, 10 insertions(+)
Acked-by: Simon Glass sjg@chromium.org
Are these added in the right order? Did you use 'make savedefconfig' afterwards?
diff --git a/configs/kylin-rk3036_defconfig b/configs/kylin-rk3036_defconfig index 424cdab..5a8b85a 100644 --- a/configs/kylin-rk3036_defconfig +++ b/configs/kylin-rk3036_defconfig @@ -36,3 +36,6 @@ CONFIG_RAM=y CONFIG_SYSRESET=y CONFIG_CMD_DHRYSTONE=y CONFIG_ERRNO_STR=y +CONFIG_CMD_USB=y +CONFIG_USB=y +CONFIG_USB_STORAGE=y diff --git a/include/configs/rk3036_common.h b/include/configs/rk3036_common.h index 4eef3f8..92be29e 100644 --- a/include/configs/rk3036_common.h +++ b/include/configs/rk3036_common.h @@ -79,6 +79,13 @@ #define CONFIG_G_DNL_VENDOR_NUM 0x2207 #define CONFIG_G_DNL_PRODUCT_NUM 0x310a
+/* usb host */ +#ifdef CONFIG_CMD_USB +#define CONFIG_USB_DWC2 +#define CONFIG_USB_HOST_ETHER +#define CONFIG_USB_ETHER_SMSC95XX +#define CONFIG_USB_ETHER_ASIX +#endif #define ENV_MEM_LAYOUT_SETTINGS \ "scriptaddr=0x60000000\0" \ "pxefile_addr_r=0x60100000\0" \ -- 1.9.1
Regards, Simon

On 11 November 2016 at 09:16, Simon Glass sjg@chromium.org wrote:
Hi Kever,
On 8 November 2016 at 03:13, Kever Yang kever.yang@rock-chips.com wrote:
rk3036 using dwc2 usb controller, need enable relate configs for it.
Signed-off-by: Kever Yang kever.yang@rock-chips.com
configs/kylin-rk3036_defconfig | 3 +++ include/configs/rk3036_common.h | 7 +++++++ 2 files changed, 10 insertions(+)
Acked-by: Simon Glass sjg@chromium.org
Are these added in the right order? Did you use 'make savedefconfig' afterwards?
No response - please send a follow-up patch if needed.
Applied to u-boot-rockchip, thanks!

usb host vbus power is using gpio fix regulator, enable it.
Signed-off-by: Kever Yang kever.yang@rock-chips.com ---
configs/kylin-rk3036_defconfig | 1 + 1 file changed, 1 insertion(+)
diff --git a/configs/kylin-rk3036_defconfig b/configs/kylin-rk3036_defconfig index 5a8b85a..631d1f5 100644 --- a/configs/kylin-rk3036_defconfig +++ b/configs/kylin-rk3036_defconfig @@ -32,6 +32,7 @@ CONFIG_LED=y CONFIG_ROCKCHIP_DWMMC=y CONFIG_PINCTRL=y CONFIG_ROCKCHIP_RK3036_PINCTRL=y +CONFIG_DM_REGULATOR_FIXED=y CONFIG_RAM=y CONFIG_SYSRESET=y CONFIG_CMD_DHRYSTONE=y

On 8 November 2016 at 03:13, Kever Yang kever.yang@rock-chips.com wrote:
usb host vbus power is using gpio fix regulator, enable it.
Signed-off-by: Kever Yang kever.yang@rock-chips.com
configs/kylin-rk3036_defconfig | 1 + 1 file changed, 1 insertion(+)
Acked-by: Simon Glass sjg@chromium.org

On 11 November 2016 at 09:17, Simon Glass sjg@chromium.org wrote:
On 8 November 2016 at 03:13, Kever Yang kever.yang@rock-chips.com wrote:
usb host vbus power is using gpio fix regulator, enable it.
Signed-off-by: Kever Yang kever.yang@rock-chips.com
configs/kylin-rk3036_defconfig | 1 + 1 file changed, 1 insertion(+)
Acked-by: Simon Glass sjg@chromium.org
Applied to u-boot-rockchip, thanks!

add fix regulator node for usb vbus power control.
Signed-off-by: Kever Yang kever.yang@rock-chips.com ---
arch/arm/dts/rk3036-sdk.dts | 37 +++++++++++++++++++++++++++++++++---- 1 file changed, 33 insertions(+), 4 deletions(-)
diff --git a/arch/arm/dts/rk3036-sdk.dts b/arch/arm/dts/rk3036-sdk.dts index 1c9ddf9..bdc7b98 100644 --- a/arch/arm/dts/rk3036-sdk.dts +++ b/arch/arm/dts/rk3036-sdk.dts @@ -16,10 +16,25 @@ stdout-path = &uart2; };
- usb_control { - compatible = "rockchip,rk3036-usb-control"; - host_drv_gpio = <&gpio2 23 GPIO_ACTIVE_LOW>; - otg_drv_gpio = <&gpio0 26 GPIO_ACTIVE_LOW>; + vcc5v0_otg: vcc5v0-otg-drv { + compatible = "regulator-fixed"; + regulator-name = "vcc5v0_otg"; + gpio = <&gpio0 26 GPIO_ACTIVE_HIGH>; + pinctrl-names = "default"; + pinctrl-0 = <&otg_vbus_drv>; + regulator-min-microvolt = <5000000>; + regulator-max-microvolt = <5000000>; + }; + + vcc5v0_host: vcc5v0-host-drv { + compatible = "regulator-fixed"; + regulator-name = "vcc5v0_host"; + gpio = <&gpio2 23 GPIO_ACTIVE_HIGH>; + pinctrl-names = "default"; + pinctrl-0 = <&host_vbus_drv>; + regulator-min-microvolt = <5000000>; + regulator-max-microvolt = <5000000>; + regulator-always-on; }; };
@@ -42,3 +57,17 @@ &usb_otg { status = "okay"; }; + +&pinctrl { + usb_otg { + otg_vbus_drv: host-vbus-drv { + rockchip,pins = <0 26 RK_FUNC_GPIO &pcfg_pull_none>; + }; + }; + + usb_host { + host_vbus_drv: host-vbus-drv { + rockchip,pins = <2 23 RK_FUNC_GPIO &pcfg_pull_none>; + }; + }; +};

On 8 November 2016 at 03:13, Kever Yang kever.yang@rock-chips.com wrote:
add fix regulator node for usb vbus power control.
Signed-off-by: Kever Yang kever.yang@rock-chips.com
arch/arm/dts/rk3036-sdk.dts | 37 +++++++++++++++++++++++++++++++++---- 1 file changed, 33 insertions(+), 4 deletions(-)
Acked-by: Simon Glass sjg@chromium.org

On 11 November 2016 at 09:17, Simon Glass sjg@chromium.org wrote:
On 8 November 2016 at 03:13, Kever Yang kever.yang@rock-chips.com wrote:
add fix regulator node for usb vbus power control.
Signed-off-by: Kever Yang kever.yang@rock-chips.com
arch/arm/dts/rk3036-sdk.dts | 37 +++++++++++++++++++++++++++++++++---- 1 file changed, 33 insertions(+), 4 deletions(-)
Acked-by: Simon Glass sjg@chromium.org
Applied to u-boot-rockchip, thanks!

enable the vbus for usb host in board_init().
Signed-off-by: Kever Yang kever.yang@rock-chips.com ---
arch/arm/mach-rockchip/rk3036-board.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+)
diff --git a/arch/arm/mach-rockchip/rk3036-board.c b/arch/arm/mach-rockchip/rk3036-board.c index bf2b268..90d3d33 100644 --- a/arch/arm/mach-rockchip/rk3036-board.c +++ b/arch/arm/mach-rockchip/rk3036-board.c @@ -16,6 +16,7 @@ #include <asm/arch/sdram_rk3036.h> #include <asm/gpio.h> #include <dm/pinctrl.h> +#include <power/regulator.h>
DECLARE_GLOBAL_DATA_PTR;
@@ -57,7 +58,26 @@ int board_late_init(void)
int board_init(void) { + int ret; + struct udevice *regulator; + + ret = regulator_get_by_platname("vcc5v0_host", ®ulator); + if (ret) { + printf("%s vcc5v0_host init fail! ret %d\n", __func__, ret); + goto out; + } + + ret = regulator_set_enable(regulator, true); + if (ret) { + printf("%s vcc5v0-host enable fail!\n", __func__); + goto out; + } + return 0; +out: + printf("%s board ini error %x\n", __func__, ret); + + return ret; }
int dram_init(void)

Hi Kever,
On 8 November 2016 at 03:13, Kever Yang kever.yang@rock-chips.com wrote:
enable the vbus for usb host in board_init().
Note 'borad_init' typo in subject.
Signed-off-by: Kever Yang kever.yang@rock-chips.com
arch/arm/mach-rockchip/rk3036-board.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+)
diff --git a/arch/arm/mach-rockchip/rk3036-board.c b/arch/arm/mach-rockchip/rk3036-board.c index bf2b268..90d3d33 100644 --- a/arch/arm/mach-rockchip/rk3036-board.c +++ b/arch/arm/mach-rockchip/rk3036-board.c @@ -16,6 +16,7 @@ #include <asm/arch/sdram_rk3036.h> #include <asm/gpio.h> #include <dm/pinctrl.h> +#include <power/regulator.h>
DECLARE_GLOBAL_DATA_PTR;
@@ -57,7 +58,26 @@ int board_late_init(void)
int board_init(void) {
int ret;
struct udevice *regulator;
ret = regulator_get_by_platname("vcc5v0_host", ®ulator);
Can this be done in the USB driver? Then you might be able to use device_get_supply_regulator().
In fact it looks like board_usb_init() should move into a driver.
if (ret) {
printf("%s vcc5v0_host init fail! ret %d\n", __func__, ret);
goto out;
}
ret = regulator_set_enable(regulator, true);
if (ret) {
printf("%s vcc5v0-host enable fail!\n", __func__);
goto out;
}
return 0;
+out:
printf("%s board ini error %x\n", __func__, ret);
return ret;
}
int dram_init(void)
1.9.1

Hi Simon,
On 11/12/2016 12:17 AM, Simon Glass wrote:
Hi Kever,
On 8 November 2016 at 03:13, Kever Yang kever.yang@rock-chips.com wrote:
enable the vbus for usb host in board_init().
Note 'borad_init' typo in subject.
Will fix in next version.
Signed-off-by: Kever Yang kever.yang@rock-chips.com
arch/arm/mach-rockchip/rk3036-board.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+)
diff --git a/arch/arm/mach-rockchip/rk3036-board.c b/arch/arm/mach-rockchip/rk3036-board.c index bf2b268..90d3d33 100644 --- a/arch/arm/mach-rockchip/rk3036-board.c +++ b/arch/arm/mach-rockchip/rk3036-board.c @@ -16,6 +16,7 @@ #include <asm/arch/sdram_rk3036.h> #include <asm/gpio.h> #include <dm/pinctrl.h> +#include <power/regulator.h>
DECLARE_GLOBAL_DATA_PTR;
@@ -57,7 +58,26 @@ int board_late_init(void)
int board_init(void) {
int ret;
struct udevice *regulator;
ret = regulator_get_by_platname("vcc5v0_host", ®ulator);
Can this be done in the USB driver? Then you might be able to use device_get_supply_regulator().
In dwc2 controller, there do have a bit for host power to control a signal named HOST_DRV_VBUS and init at dwc_otg_core_host_init(), but we do not using that controller signal, and using a GPIO instead, which may be different in different board, so we usually enable it in board file.
Let me have a try if we can move it to USB driver.
In fact it looks like board_usb_init() should move into a driver.
We are not using board_usb_init() for usb host now, this function is only used for usb gadget/udc.
Thanks, - Kever
if (ret) {
printf("%s vcc5v0_host init fail! ret %d\n", __func__, ret);
goto out;
}
ret = regulator_set_enable(regulator, true);
if (ret) {
printf("%s vcc5v0-host enable fail!\n", __func__);
goto out;
}
return 0;
+out:
printf("%s board ini error %x\n", __func__, ret);
return ret;
}
int dram_init(void)
-- 1.9.1

Hi Kever,
On 14 November 2016 at 03:07, Kever Yang kever.yang@rock-chips.com wrote:
Hi Simon,
On 11/12/2016 12:17 AM, Simon Glass wrote:
Hi Kever,
On 8 November 2016 at 03:13, Kever Yang kever.yang@rock-chips.com wrote:
enable the vbus for usb host in board_init().
Note 'borad_init' typo in subject.
Will fix in next version.
Signed-off-by: Kever Yang kever.yang@rock-chips.com
arch/arm/mach-rockchip/rk3036-board.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+)
diff --git a/arch/arm/mach-rockchip/rk3036-board.c b/arch/arm/mach-rockchip/rk3036-board.c index bf2b268..90d3d33 100644 --- a/arch/arm/mach-rockchip/rk3036-board.c +++ b/arch/arm/mach-rockchip/rk3036-board.c @@ -16,6 +16,7 @@ #include <asm/arch/sdram_rk3036.h> #include <asm/gpio.h> #include <dm/pinctrl.h> +#include <power/regulator.h>
DECLARE_GLOBAL_DATA_PTR;
@@ -57,7 +58,26 @@ int board_late_init(void)
int board_init(void) {
int ret;
struct udevice *regulator;
ret = regulator_get_by_platname("vcc5v0_host", ®ulator);
Can this be done in the USB driver? Then you might be able to use device_get_supply_regulator().
In dwc2 controller, there do have a bit for host power to control a signal named HOST_DRV_VBUS and init at dwc_otg_core_host_init(), but we do not using that controller signal, and using a GPIO instead, which may be different in different board, so we usually enable it in board file.
Let me have a try if we can move it to USB driver.
In that case it should be mentioned in the device tree, so you can perhaps use gpio-regulator.
In fact it looks like board_usb_init() should move into a driver.
We are not using board_usb_init() for usb host now, this function is only used for usb gadget/udc.
OK I see, that's fine.
BTW the merge window will open soon so please send any other patches you have planned for the next release.
Regards, Simon
participants (2)
-
Kever Yang
-
Simon Glass