Message ID | b866ade7c8b89137a593a603ecba0d8cfedb1224.1505242834.git-series.maxime.ripard@free-electrons.com |
---|---|
State | Accepted |
Commit | 3a61b080acee941a1b14b709b58ff9cde0b367bc |
Headers | show |
Series | sunxi: convert musb to the device model and enable usb_ether | expand |
On 09/12/2017 09:01 PM, Maxime Ripard wrote: > The device model was implemented so far using a hook that needed to be > called from the board support, without DT support and only for the host. > > Switch to probing both in peripheral and host mode through the DT. > > Reviewed-by: Simon Glass <sjg@chromium.org> > Signed-off-by: Maxime Ripard <maxime.ripard@free-electrons.com> > --- > arch/arm/include/asm/arch-sunxi/usb_phy.h | 7 +--- > board/sunxi/board.c | 1 +- > drivers/usb/musb-new/sunxi.c | 56 +++++++++++------------- > 3 files changed, 27 insertions(+), 37 deletions(-) > > diff --git a/arch/arm/include/asm/arch-sunxi/usb_phy.h b/arch/arm/include/asm/arch-sunxi/usb_phy.h > index cef6c985bc8d..5a9cacb6f4a3 100644 > --- a/arch/arm/include/asm/arch-sunxi/usb_phy.h > +++ b/arch/arm/include/asm/arch-sunxi/usb_phy.h > @@ -19,10 +19,3 @@ void sunxi_usb_phy_power_off(int index); > int sunxi_usb_phy_vbus_detect(int index); > int sunxi_usb_phy_id_detect(int index); > void sunxi_usb_phy_enable_squelch_detect(int index, int enable); > - > -/* Not really phy related, but we have to declare this somewhere ... */ > -#if defined(CONFIG_USB_MUSB_HOST) || defined(CONFIG_USB_MUSB_GADGET) > -void sunxi_musb_board_init(void); > -#else > -#define sunxi_musb_board_init() > -#endif > diff --git a/board/sunxi/board.c b/board/sunxi/board.c > index 70e01437c4f4..f9224360d758 100644 > --- a/board/sunxi/board.c > +++ b/board/sunxi/board.c > @@ -736,7 +736,6 @@ int misc_init_r(void) > if (ret) > return ret; > #endif > - sunxi_musb_board_init(); > > return 0; > } > diff --git a/drivers/usb/musb-new/sunxi.c b/drivers/usb/musb-new/sunxi.c > index 5c1a902e42dc..7ee44ea91900 100644 > --- a/drivers/usb/musb-new/sunxi.c > +++ b/drivers/usb/musb-new/sunxi.c > @@ -308,9 +308,6 @@ static struct musb_hdrc_platform_data musb_plat = { > .platform_ops = &sunxi_musb_ops, > }; > > -#ifdef CONFIG_USB_MUSB_HOST > -static int musb_usb_remove(struct udevice *dev); > - > static int musb_usb_probe(struct udevice *dev) > { > struct musb_host_data *host = dev_get_priv(dev); > @@ -319,16 +316,20 @@ static int musb_usb_probe(struct udevice *dev) > > priv->desc_before_addr = true; > > +#ifdef CONFIG_USB_MUSB_HOST > host->host = musb_init_controller(&musb_plat, NULL, > (void *)SUNXI_USB0_BASE); > if (!host->host) > return -EIO; > > ret = musb_lowlevel_init(host); > - if (ret == 0) > - printf("MUSB OTG\n"); > - else > - musb_usb_remove(dev); > + if (!ret) > + printf("Allwinner mUSB OTG (Host)\n"); > +#else > + ret = musb_register(&musb_plat, NULL, (void *)SUNXI_USB0_BASE); > + if (!ret) > + printf("Allwinner mUSB OTG (Peripheral)\n"); > +#endif > > return ret; > } > @@ -352,30 +353,27 @@ static int musb_usb_remove(struct udevice *dev) > return 0; > } > > -U_BOOT_DRIVER(usb_musb) = { > - .name = "sunxi-musb", > - .id = UCLASS_USB, > - .probe = musb_usb_probe, > - .remove = musb_usb_remove, > - .ops = &musb_usb_ops, > - .platdata_auto_alloc_size = sizeof(struct usb_platdata), > - .priv_auto_alloc_size = sizeof(struct musb_host_data), > +static const struct udevice_id sunxi_musb_ids[] = { > + { .compatible = "allwinner,sun4i-a10-musb" }, > + { .compatible = "allwinner,sun6i-a31-musb" }, > + { .compatible = "allwinner,sun8i-a33-musb" }, > + { .compatible = "allwinner,sun8i-h3-musb" }, > + { } > }; > -#endif > > -void sunxi_musb_board_init(void) > -{ > +U_BOOT_DRIVER(usb_musb) = { > + .name = "sunxi-musb", > #ifdef CONFIG_USB_MUSB_HOST > - struct udevice *dev; > - > - /* > - * Bind the driver directly for now as musb linux kernel support is > - * still pending upstream so our dts files do not have the necessary > - * nodes yet. TODO: Remove this as soon as the dts nodes are in place > - * and bind by compatible instead. > - */ > - device_bind_driver(dm_root(), "sunxi-musb", "sunxi-musb", &dev); > + .id = UCLASS_USB, > #else > - musb_register(&musb_plat, NULL, (void *)SUNXI_USB0_BASE); > + .id = UCLASS_USB_DEV_GENERIC, > #endif > -} > + .of_match = sunxi_musb_ids, > + .probe = musb_usb_probe, > + .remove = musb_usb_remove, > +#ifdef CONFIG_USB_MUSB_HOST > + .ops = &musb_usb_ops, > +#endif > + .platdata_auto_alloc_size = sizeof(struct usb_platdata), > + .priv_auto_alloc_size = sizeof(struct musb_host_data), > +}; > Reviewed-by: Ćukasz Majewski <lukma@denx.de>
diff --git a/arch/arm/include/asm/arch-sunxi/usb_phy.h b/arch/arm/include/asm/arch-sunxi/usb_phy.h index cef6c985bc8d..5a9cacb6f4a3 100644 --- a/arch/arm/include/asm/arch-sunxi/usb_phy.h +++ b/arch/arm/include/asm/arch-sunxi/usb_phy.h @@ -19,10 +19,3 @@ void sunxi_usb_phy_power_off(int index); int sunxi_usb_phy_vbus_detect(int index); int sunxi_usb_phy_id_detect(int index); void sunxi_usb_phy_enable_squelch_detect(int index, int enable); - -/* Not really phy related, but we have to declare this somewhere ... */ -#if defined(CONFIG_USB_MUSB_HOST) || defined(CONFIG_USB_MUSB_GADGET) -void sunxi_musb_board_init(void); -#else -#define sunxi_musb_board_init() -#endif diff --git a/board/sunxi/board.c b/board/sunxi/board.c index 70e01437c4f4..f9224360d758 100644 --- a/board/sunxi/board.c +++ b/board/sunxi/board.c @@ -736,7 +736,6 @@ int misc_init_r(void) if (ret) return ret; #endif - sunxi_musb_board_init(); return 0; } diff --git a/drivers/usb/musb-new/sunxi.c b/drivers/usb/musb-new/sunxi.c index 5c1a902e42dc..7ee44ea91900 100644 --- a/drivers/usb/musb-new/sunxi.c +++ b/drivers/usb/musb-new/sunxi.c @@ -308,9 +308,6 @@ static struct musb_hdrc_platform_data musb_plat = { .platform_ops = &sunxi_musb_ops, }; -#ifdef CONFIG_USB_MUSB_HOST -static int musb_usb_remove(struct udevice *dev); - static int musb_usb_probe(struct udevice *dev) { struct musb_host_data *host = dev_get_priv(dev); @@ -319,16 +316,20 @@ static int musb_usb_probe(struct udevice *dev) priv->desc_before_addr = true; +#ifdef CONFIG_USB_MUSB_HOST host->host = musb_init_controller(&musb_plat, NULL, (void *)SUNXI_USB0_BASE); if (!host->host) return -EIO; ret = musb_lowlevel_init(host); - if (ret == 0) - printf("MUSB OTG\n"); - else - musb_usb_remove(dev); + if (!ret) + printf("Allwinner mUSB OTG (Host)\n"); +#else + ret = musb_register(&musb_plat, NULL, (void *)SUNXI_USB0_BASE); + if (!ret) + printf("Allwinner mUSB OTG (Peripheral)\n"); +#endif return ret; } @@ -352,30 +353,27 @@ static int musb_usb_remove(struct udevice *dev) return 0; } -U_BOOT_DRIVER(usb_musb) = { - .name = "sunxi-musb", - .id = UCLASS_USB, - .probe = musb_usb_probe, - .remove = musb_usb_remove, - .ops = &musb_usb_ops, - .platdata_auto_alloc_size = sizeof(struct usb_platdata), - .priv_auto_alloc_size = sizeof(struct musb_host_data), +static const struct udevice_id sunxi_musb_ids[] = { + { .compatible = "allwinner,sun4i-a10-musb" }, + { .compatible = "allwinner,sun6i-a31-musb" }, + { .compatible = "allwinner,sun8i-a33-musb" }, + { .compatible = "allwinner,sun8i-h3-musb" }, + { } }; -#endif -void sunxi_musb_board_init(void) -{ +U_BOOT_DRIVER(usb_musb) = { + .name = "sunxi-musb", #ifdef CONFIG_USB_MUSB_HOST - struct udevice *dev; - - /* - * Bind the driver directly for now as musb linux kernel support is - * still pending upstream so our dts files do not have the necessary - * nodes yet. TODO: Remove this as soon as the dts nodes are in place - * and bind by compatible instead. - */ - device_bind_driver(dm_root(), "sunxi-musb", "sunxi-musb", &dev); + .id = UCLASS_USB, #else - musb_register(&musb_plat, NULL, (void *)SUNXI_USB0_BASE); + .id = UCLASS_USB_DEV_GENERIC, #endif -} + .of_match = sunxi_musb_ids, + .probe = musb_usb_probe, + .remove = musb_usb_remove, +#ifdef CONFIG_USB_MUSB_HOST + .ops = &musb_usb_ops, +#endif + .platdata_auto_alloc_size = sizeof(struct usb_platdata), + .priv_auto_alloc_size = sizeof(struct musb_host_data), +};