musb: sunxi: Use base address from device tree
Subsystems (2)
PATCH v2 1/1 musb: sunxi: Use base address from device tree
Now that the musb sunxi glue driver is completely device model / device tree driven, we should use the base address from the device tree, instead of hard-coding it in the source code.
---
Changes since v1:
- Check return value dev_read_addr_ptr()
IMHO, having NULL represent an error for dev_read_addr_ptr() doesn't work so well as in the kernel, because U-boot doesn't acually map addresses. So NULL (or 0x0) is in fact a valid address. Something like ~0x0 might work better, but that's a whole other changeset.
--- drivers/usb/musb-new/sunxi.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)
drivers/usb/musb-new/sunxi.c +6 -3
@@ -312,13 +312,16 @@ static int musb_usb_probe(struct udevice *dev) {struct musb_host_data *host =dev_get_priv (dev);struct usb_bus_priv *priv =dev_get_uclass_priv (dev); +void *base =dev_read_addr_ptr (dev);int ret; +if (!base) +return -EINVAL ; + priv->desc_before_addr = true;#ifdef CONFIG_USB_MUSB_HOST - host->host =musb_init_controller (&musb_plat,NULL , - (void *)SUNXI_USB0_BASE ); + host->host =musb_init_controller (&musb_plat,NULL , base);if (!host->host)return -EIO ;
@@ -326,7 +329,7 @@ static int musb_usb_probe(struct udevice *dev)if (!ret)printf ("Allwinner mUSB OTG (Host)\n" );#else - ret =musb_register (&musb_plat,NULL , (void *)SUNXI_USB0_BASE ); + ret =musb_register (&musb_plat,NULL , base);if (!ret)printf ("Allwinner mUSB OTG (Peripheral)\n" );#endif
Signature · 1 line
2.15.1
PATCH v2 1/1 musb: sunxi: Use base address from device tree
Quoted 6 lines · Chen-Yu Tsai
Now that the musb sunxi glue driver is completely device model / device tree driven, we should use the base address from the device tree, instead of hard-coding it in the source code.
Fixes 3a61b080acee ("musb: sunxi: switch to the device model")Signed-off-by Chen-Yu Tsai <[email protected]>
Thanks!
Maxime
Signature · 10 lines
Maxime Ripard, Free Electrons Embedded Linux and Kernel engineering http://free-electrons.com -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 833 bytes Desc: not available URL: <http://lists.denx.de/pipermail/u-boot/attachments/20180104/cfcd62ab/attachment.sig>
PATCH v2 1/1 musb: sunxi: Use base address from device tree
Quoted 9 lines · Maxime Ripard
Quoted 6 lines · Chen-Yu Tsai
Now that the musb sunxi glue driver is completely device model / device tree driven, we should use the base address from the device tree, instead of hard-coding it in the source code.
Fixes 3a61b080acee ("musb: sunxi: switch to the device model")Signed-off-by Chen-Yu Tsai <[email protected]>Acked-by Maxime Ripard <[email protected]>
Applied to u-boot-sunxi/master
PATCH v2 1/1 musb: sunxi: Use base address from device tree
Quoted 7 lines · Jagan Teki
Quoted 5 lines · Maxime Ripard
Quoted 4 lines · Chen-Yu Tsai
Now that the musb sunxi glue driver is completely device model / device tree driven, we should use the base address from the device tree, instead of hard-coding it in the source code.
Quoted 6 lines
Quoted 4 lines
Quoted 2 lines
Fixes 3a61b080acee ("musb: sunxi: switch to the device model")Signed-off-by Chen-Yu Tsai <[email protected]>Acked-by Maxime Ripard <[email protected]>Applied to u-boot-sunxi/master
This is a USB patch, this goes through USB tree, so drop it.
Signature · 2 lines
Best regards, Marek Vasut
PATCH v2 1/1 musb: sunxi: Use base address from device tree
In reply to Chen-Yu Tsai2017-12-30 20:44 GMT+08:00 Chen-Yu Tsai <[email protected]>:
Quoted 25 lines
Now that the musb sunxi glue driver is completely device model / device tree driven, we should use the base address from the device tree, instead of hard-coding it in the source code.
Fixes 3a61b080acee ("musb: sunxi: switch to the device model")Signed-off-by Chen-Yu Tsai <[email protected]>---
Changes since v1:- Check return value
dev_read_addr_ptr()IMHO, having NULL represent an error for
dev_read_addr_ptr()doesn't work so well as in the kernel, because U-boot doesn't acually map addresses. So NULL (or0x0) is in fact a valid address. Something like ~0x0 might work better, but that's a whole other changeset.--- drivers/usb/musb-new/sunxi.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)drivers/usb/musb-new/sunxi.c +0
-0
drivers/usb/musb-new/sunxi.c static int musb_usb_probe(struct udevice *dev) · line 316
Quoted 5 lines
drivers/usb/musb-new/sunxi.c +1
-0@@ -312,13 +312,16 @@ static int musb_usb_probe(struct udevice *dev) {struct musb_host_data *host =dev_get_priv (dev);struct usb_bus_priv *priv =dev_get_uclass_priv (dev); +void *base =dev_read_addr_ptr (dev);int ret;
Chenyu,
I am not familiar with MUSB and not sure whether this driver support both host and peripheral mode. I suppose it support both mode in different build config according to macro CONFIG_USB_MUSB_HOST. H3 user manual says register address space is different for the two modes, 0x1c19000 for device mode and 0x1c1a000 for host mode. If my understanding is correct, we need different address in dts for different mode. Or I misunderstand anything? Thank you for explaining it!
Jun
PATCH v2 1/1 musb: sunxi: Use base address from device tree
Quoted 34 lines · Jun Nie
2017-12-30 20:44 GMT+08:00 Chen-Yu Tsai <[email protected]>:
Quoted 25 lines
Now that the musb sunxi glue driver is completely device model / device tree driven, we should use the base address from the device tree, instead of hard-coding it in the source code.
Fixes 3a61b080acee ("musb: sunxi: switch to the device model")Signed-off-by Chen-Yu Tsai <[email protected]>---
Changes since v1:- Check return value
dev_read_addr_ptr()IMHO, having NULL represent an error for
dev_read_addr_ptr()doesn't work so well as in the kernel, because U-boot doesn't acually map addresses. So NULL (or0x0) is in fact a valid address. Something like ~0x0 might work better, but that's a whole other changeset.--- drivers/usb/musb-new/sunxi.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)drivers/usb/musb-new/sunxi.c +0
-0drivers/usb/musb-new/sunxi.c static int musb_usb_probe(struct udevice *dev) · line 316
Quoted 5 lines
drivers/usb/musb-new/sunxi.c +1
-0@@ -312,13 +312,16 @@ static int musb_usb_probe(struct udevice *dev) {struct musb_host_data *host =dev_get_priv (dev);struct usb_bus_priv *priv =dev_get_uclass_priv (dev); +void *base =dev_read_addr_ptr (dev);int ret;Chenyu,
Quoted 8 lines
I am not familiar with MUSB and not sure whether this driver support both host and peripheral mode. I suppose it support both mode in different build config according to macro
CONFIG_USB_MUSB_HOST. H3 user manual says register address space is different for the two modes,0x1c19000for device mode and0x1c1a000for host mode. If my understanding is correct, we need different address in dts for different mode. Or I misunderstand anything? Thank you for explaining it!
For host mode, the SoC provides a proper EHCI/OHCI host pair. Those are found at 0x1c1a000. However the MUSB controller can do host mode. It's just not as good as a proper host pair.
ChenYu