Commit 3a61b080acee941a1b14b709b58ff9cde0b367bc
1 parent
cfa34996b0
Exists in
smarc_8mq_lf_v2020.04
and in
17 other branches
musb: sunxi: switch to the device model
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: Łukasz Majewski <lukma@denx.de> Reviewed-by: Simon Glass <sjg@chromium.org> Signed-off-by: Maxime Ripard <maxime.ripard@free-electrons.com>
Showing 3 changed files with 27 additions and 37 deletions Side-by-side Diff
arch/arm/include/asm/arch-sunxi/usb_phy.h
... | ... | @@ -19,11 +19,4 @@ |
19 | 19 | int sunxi_usb_phy_vbus_detect(int index); |
20 | 20 | int sunxi_usb_phy_id_detect(int index); |
21 | 21 | void sunxi_usb_phy_enable_squelch_detect(int index, int enable); |
22 | - | |
23 | -/* Not really phy related, but we have to declare this somewhere ... */ | |
24 | -#if defined(CONFIG_USB_MUSB_HOST) || defined(CONFIG_USB_MUSB_GADGET) | |
25 | -void sunxi_musb_board_init(void); | |
26 | -#else | |
27 | -#define sunxi_musb_board_init() | |
28 | -#endif |
board/sunxi/board.c
drivers/usb/musb-new/sunxi.c
... | ... | @@ -308,9 +308,6 @@ |
308 | 308 | .platform_ops = &sunxi_musb_ops, |
309 | 309 | }; |
310 | 310 | |
311 | -#ifdef CONFIG_USB_MUSB_HOST | |
312 | -static int musb_usb_remove(struct udevice *dev); | |
313 | - | |
314 | 311 | static int musb_usb_probe(struct udevice *dev) |
315 | 312 | { |
316 | 313 | struct musb_host_data *host = dev_get_priv(dev); |
317 | 314 | |
... | ... | @@ -319,16 +316,20 @@ |
319 | 316 | |
320 | 317 | priv->desc_before_addr = true; |
321 | 318 | |
319 | +#ifdef CONFIG_USB_MUSB_HOST | |
322 | 320 | host->host = musb_init_controller(&musb_plat, NULL, |
323 | 321 | (void *)SUNXI_USB0_BASE); |
324 | 322 | if (!host->host) |
325 | 323 | return -EIO; |
326 | 324 | |
327 | 325 | ret = musb_lowlevel_init(host); |
328 | - if (ret == 0) | |
329 | - printf("MUSB OTG\n"); | |
330 | - else | |
331 | - musb_usb_remove(dev); | |
326 | + if (!ret) | |
327 | + printf("Allwinner mUSB OTG (Host)\n"); | |
328 | +#else | |
329 | + ret = musb_register(&musb_plat, NULL, (void *)SUNXI_USB0_BASE); | |
330 | + if (!ret) | |
331 | + printf("Allwinner mUSB OTG (Peripheral)\n"); | |
332 | +#endif | |
332 | 333 | |
333 | 334 | return ret; |
334 | 335 | } |
335 | 336 | |
336 | 337 | |
337 | 338 | |
338 | 339 | |
339 | 340 | |
... | ... | @@ -352,31 +353,28 @@ |
352 | 353 | return 0; |
353 | 354 | } |
354 | 355 | |
355 | -U_BOOT_DRIVER(usb_musb) = { | |
356 | - .name = "sunxi-musb", | |
357 | - .id = UCLASS_USB, | |
358 | - .probe = musb_usb_probe, | |
359 | - .remove = musb_usb_remove, | |
360 | - .ops = &musb_usb_ops, | |
361 | - .platdata_auto_alloc_size = sizeof(struct usb_platdata), | |
362 | - .priv_auto_alloc_size = sizeof(struct musb_host_data), | |
356 | +static const struct udevice_id sunxi_musb_ids[] = { | |
357 | + { .compatible = "allwinner,sun4i-a10-musb" }, | |
358 | + { .compatible = "allwinner,sun6i-a31-musb" }, | |
359 | + { .compatible = "allwinner,sun8i-a33-musb" }, | |
360 | + { .compatible = "allwinner,sun8i-h3-musb" }, | |
361 | + { } | |
363 | 362 | }; |
364 | -#endif | |
365 | 363 | |
366 | -void sunxi_musb_board_init(void) | |
367 | -{ | |
364 | +U_BOOT_DRIVER(usb_musb) = { | |
365 | + .name = "sunxi-musb", | |
368 | 366 | #ifdef CONFIG_USB_MUSB_HOST |
369 | - struct udevice *dev; | |
370 | - | |
371 | - /* | |
372 | - * Bind the driver directly for now as musb linux kernel support is | |
373 | - * still pending upstream so our dts files do not have the necessary | |
374 | - * nodes yet. TODO: Remove this as soon as the dts nodes are in place | |
375 | - * and bind by compatible instead. | |
376 | - */ | |
377 | - device_bind_driver(dm_root(), "sunxi-musb", "sunxi-musb", &dev); | |
367 | + .id = UCLASS_USB, | |
378 | 368 | #else |
379 | - musb_register(&musb_plat, NULL, (void *)SUNXI_USB0_BASE); | |
369 | + .id = UCLASS_USB_DEV_GENERIC, | |
380 | 370 | #endif |
381 | -} | |
371 | + .of_match = sunxi_musb_ids, | |
372 | + .probe = musb_usb_probe, | |
373 | + .remove = musb_usb_remove, | |
374 | +#ifdef CONFIG_USB_MUSB_HOST | |
375 | + .ops = &musb_usb_ops, | |
376 | +#endif | |
377 | + .platdata_auto_alloc_size = sizeof(struct usb_platdata), | |
378 | + .priv_auto_alloc_size = sizeof(struct musb_host_data), | |
379 | +}; |
-
mentioned in commit f4f989
-
mentioned in commit f4f989
-
mentioned in commit f4f989
-
mentioned in commit f4f989
-
mentioned in commit f4f989
-
mentioned in commit f4f989
-
mentioned in commit f4f989
-
mentioned in commit f4f989
-
mentioned in commit f4f989
-
mentioned in commit f4f989
-
mentioned in commit f4f989
-
mentioned in commit f4f989
-
mentioned in commit f4f989
-
mentioned in commit f4f989
-
mentioned in commit f4f989
-
mentioned in commit f4f989
-
mentioned in commit f4f989
-
mentioned in commit f4f989
-
mentioned in commit f4f989
-
mentioned in commit f4f989