]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
ARM: meson: g12a: switch dwc2 otg to DM
authorMattijs Korpershoek <mkorpershoek@baylibre.com>
Wed, 23 Nov 2022 15:42:50 +0000 (16:42 +0100)
committerNeil Armstrong <neil.armstrong@linaro.org>
Tue, 17 Jan 2023 08:27:17 +0000 (09:27 +0100)
With CONFIG_DM_USB_GADGET=y, we no longer need any board_usb_*() logic
because:
* the dwc2 driver is DM compatible, and handles its own clock enabling
* the dwc3-meson-g12a glue drivers handles "force mode switching"

Remove all mach-meson/g12a usb code and enable CONFIG_DM_USB_GADGET.

Note: Only configs having both CONFIG_USB_DWC3_MESON_G12A=y *and*
      USB_GADGET_DWC2_OTG=y have been updated.

Signed-off-by: Mattijs Korpershoek <mkorpershoek@baylibre.com>
Link: https://lore.kernel.org/r/20221024-meson-dm-usb-v1-2-2ab077a503b9@baylibre.com
Signed-off-by: Neil Armstrong <neil.armstrong@linaro.org>
18 files changed:
arch/arm/mach-meson/board-g12a.c
configs/bananapi-m5_defconfig
configs/beelink-gsking-x_defconfig
configs/beelink-gtking_defconfig
configs/beelink-gtkingpro_defconfig
configs/khadas-vim3_android_ab_defconfig
configs/khadas-vim3_android_defconfig
configs/khadas-vim3_defconfig
configs/khadas-vim3l_android_ab_defconfig
configs/khadas-vim3l_android_defconfig
configs/khadas-vim3l_defconfig
configs/odroid-c4_defconfig
configs/odroid-hc4_defconfig
configs/odroid-n2_defconfig
configs/radxa-zero_defconfig
configs/sei510_defconfig
configs/sei610_defconfig
configs/u200_defconfig

index 2e59eee8f7924ecb94320d7a89c2b80510295739..d5a830fb1db8de9c67db41f7013ccc9515f70f4c 100644 (file)
 #include <asm/io.h>
 #include <asm/armv8/mmu.h>
 #include <linux/sizes.h>
-#include <usb.h>
-#include <linux/usb/otg.h>
-#include <asm/arch/usb.h>
-#include <usb/dwc2_udc.h>
-#include <phy.h>
-#include <clk.h>
 
 DECLARE_GLOBAL_DATA_PTR;
 
@@ -96,124 +90,3 @@ static struct mm_region g12a_mem_map[] = {
 };
 
 struct mm_region *mem_map = g12a_mem_map;
-
-#if CONFIG_IS_ENABLED(USB_DWC3_MESON_G12A) && \
-       CONFIG_IS_ENABLED(USB_GADGET_DWC2_OTG)
-static struct dwc2_plat_otg_data meson_g12a_dwc2_data;
-
-int board_usb_init(int index, enum usb_init_type init)
-{
-       struct fdtdec_phandle_args args;
-       const void *blob = gd->fdt_blob;
-       int node, dwc2_node;
-       struct udevice *dev, *clk_dev;
-       struct clk clk;
-       int ret;
-
-       /* find the usb glue node */
-       node = fdt_node_offset_by_compatible(blob, -1,
-                                            "amlogic,meson-g12a-usb-ctrl");
-       if (node < 0) {
-               debug("Not found usb-control node\n");
-               return -ENODEV;
-       }
-
-       if (!fdtdec_get_is_enabled(blob, node)) {
-               debug("usb is disabled in the device tree\n");
-               return -ENODEV;
-       }
-
-       ret = uclass_get_device_by_of_offset(UCLASS_SIMPLE_BUS, node, &dev);
-       if (ret) {
-               debug("Not found usb-control device\n");
-               return ret;
-       }
-
-       /* find the dwc2 node */
-       dwc2_node = fdt_node_offset_by_compatible(blob, node,
-                                                 "amlogic,meson-g12a-usb");
-       if (dwc2_node < 0) {
-               debug("Not found dwc2 node\n");
-               return -ENODEV;
-       }
-
-       if (!fdtdec_get_is_enabled(blob, dwc2_node)) {
-               debug("dwc2 is disabled in the device tree\n");
-               return -ENODEV;
-       }
-
-       meson_g12a_dwc2_data.regs_otg = fdtdec_get_addr(blob, dwc2_node, "reg");
-       if (meson_g12a_dwc2_data.regs_otg == FDT_ADDR_T_NONE) {
-               debug("usbotg: can't get base address\n");
-               return -ENODATA;
-       }
-
-       /* Enable clock */
-       ret = fdtdec_parse_phandle_with_args(blob, dwc2_node, "clocks",
-                                            "#clock-cells", 0, 0, &args);
-       if (ret) {
-               debug("usbotg has no clocks defined in the device tree\n");
-               return ret;
-       }
-
-       ret = uclass_get_device_by_of_offset(UCLASS_CLK, args.node, &clk_dev);
-       if (ret)
-               return ret;
-
-       if (args.args_count != 1) {
-               debug("Can't find clock ID in the device tree\n");
-               return -ENODATA;
-       }
-
-       clk.dev = clk_dev;
-       clk.id = args.args[0];
-
-       ret = clk_enable(&clk);
-       if (ret) {
-               debug("Failed to enable usbotg clock\n");
-               return ret;
-       }
-
-       meson_g12a_dwc2_data.rx_fifo_sz = fdtdec_get_int(blob, dwc2_node,
-                                                    "g-rx-fifo-size", 0);
-       meson_g12a_dwc2_data.np_tx_fifo_sz = fdtdec_get_int(blob, dwc2_node,
-                                                       "g-np-tx-fifo-size", 0);
-       meson_g12a_dwc2_data.tx_fifo_sz = fdtdec_get_int(blob, dwc2_node,
-                                                    "g-tx-fifo-size", 0);
-
-       /* Switch to peripheral mode */
-       ret = dwc3_meson_g12a_force_mode(dev, USB_DR_MODE_PERIPHERAL);
-       if (ret)
-               return ret;
-
-       return dwc2_udc_probe(&meson_g12a_dwc2_data);
-}
-
-int board_usb_cleanup(int index, enum usb_init_type init)
-{
-       const void *blob = gd->fdt_blob;
-       struct udevice *dev;
-       int node;
-       int ret;
-
-       /* find the usb glue node */
-       node = fdt_node_offset_by_compatible(blob, -1,
-                                            "amlogic,meson-g12a-usb-ctrl");
-       if (node < 0)
-               return -ENODEV;
-
-       if (!fdtdec_get_is_enabled(blob, node))
-               return -ENODEV;
-
-       ret = uclass_get_device_by_of_offset(UCLASS_SIMPLE_BUS, node, &dev);
-       if (ret)
-               return ret;
-
-       /* Switch to OTG mode */
-       ret = dwc3_meson_g12a_force_mode(dev, USB_DR_MODE_HOST);
-       if (ret)
-               return ret;
-
-       return 0;
-}
-#endif
index 0eb4fa7ceeaadfc0255b38f3e3389e2ae294c4e4..cb6eca770bf873844a280852f1583fdc57460631 100644 (file)
@@ -49,6 +49,7 @@ CONFIG_DEBUG_UART_ANNOUNCE=y
 CONFIG_DEBUG_UART_SKIP_INIT=y
 CONFIG_MESON_SERIAL=y
 CONFIG_USB=y
+CONFIG_DM_USB_GADGET=y
 CONFIG_USB_XHCI_HCD=y
 CONFIG_USB_XHCI_DWC3=y
 CONFIG_USB_DWC3=y
index ae018bb91ed2484c9b5b5f9775b53146d2ef4163..3e06002c5c5bc24eb49dbb5732b34541430bc03c 100644 (file)
@@ -50,6 +50,7 @@ CONFIG_DEBUG_UART_ANNOUNCE=y
 CONFIG_DEBUG_UART_SKIP_INIT=y
 CONFIG_MESON_SERIAL=y
 CONFIG_USB=y
+CONFIG_DM_USB_GADGET=y
 CONFIG_USB_XHCI_HCD=y
 CONFIG_USB_XHCI_DWC3=y
 CONFIG_USB_DWC3=y
index d5b071d0cc68c61107988c2e94d60dccc2e77dd0..091858bc38cbe72c67f6ea8456553204efb7272e 100644 (file)
@@ -50,6 +50,7 @@ CONFIG_DEBUG_UART_ANNOUNCE=y
 CONFIG_DEBUG_UART_SKIP_INIT=y
 CONFIG_MESON_SERIAL=y
 CONFIG_USB=y
+CONFIG_DM_USB_GADGET=y
 CONFIG_USB_XHCI_HCD=y
 CONFIG_USB_XHCI_DWC3=y
 CONFIG_USB_DWC3=y
index b179f7b3b300d604973fa6b5864741871537c3bc..965639ee73b728192879d49f7daf3f609f5caf68 100644 (file)
@@ -50,6 +50,7 @@ CONFIG_DEBUG_UART_ANNOUNCE=y
 CONFIG_DEBUG_UART_SKIP_INIT=y
 CONFIG_MESON_SERIAL=y
 CONFIG_USB=y
+CONFIG_DM_USB_GADGET=y
 CONFIG_USB_XHCI_HCD=y
 CONFIG_USB_XHCI_DWC3=y
 CONFIG_USB_DWC3=y
index 01a91573e31ae47052f8b7c51e01fded69e499ef..f212b862aa646edb3c397ac96309000fcde0ed78 100644 (file)
@@ -84,6 +84,7 @@ CONFIG_MESON_SPIFC=y
 CONFIG_SYSINFO=y
 CONFIG_SYSINFO_SMBIOS=y
 CONFIG_USB=y
+CONFIG_DM_USB_GADGET=y
 CONFIG_USB_XHCI_HCD=y
 CONFIG_USB_XHCI_DWC3=y
 CONFIG_USB_DWC3=y
index 7a2815d29f604ca2a129635581951659bde13729..3ac915ef1710e3b0a820af148c0000411cad8f91 100644 (file)
@@ -82,6 +82,7 @@ CONFIG_MESON_SPIFC=y
 CONFIG_SYSINFO=y
 CONFIG_SYSINFO_SMBIOS=y
 CONFIG_USB=y
+CONFIG_DM_USB_GADGET=y
 CONFIG_USB_XHCI_HCD=y
 CONFIG_USB_XHCI_DWC3=y
 CONFIG_USB_DWC3=y
index 792ee71f58aa2dd852d690349d12f21cd3785602..26a14855174344356946a913ff1baa752b82fa94 100644 (file)
@@ -70,6 +70,7 @@ CONFIG_MESON_SPIFC=y
 CONFIG_SYSINFO=y
 CONFIG_SYSINFO_SMBIOS=y
 CONFIG_USB=y
+CONFIG_DM_USB_GADGET=y
 CONFIG_USB_XHCI_HCD=y
 CONFIG_USB_XHCI_DWC3=y
 CONFIG_USB_DWC3=y
index e182a3ea2682f1b60ffe80696fe7a94613613a40..c3eb25abd945cb612c2404ccdcca4a9a3a559440 100644 (file)
@@ -84,6 +84,7 @@ CONFIG_MESON_SPIFC=y
 CONFIG_SYSINFO=y
 CONFIG_SYSINFO_SMBIOS=y
 CONFIG_USB=y
+CONFIG_DM_USB_GADGET=y
 CONFIG_USB_XHCI_HCD=y
 CONFIG_USB_XHCI_DWC3=y
 CONFIG_USB_DWC3=y
index bf3e2df83e2bdbb0f0ac88e872acde789518f54d..5e298272e50b044330518d139cd87f7493293ce4 100644 (file)
@@ -82,6 +82,7 @@ CONFIG_MESON_SPIFC=y
 CONFIG_SYSINFO=y
 CONFIG_SYSINFO_SMBIOS=y
 CONFIG_USB=y
+CONFIG_DM_USB_GADGET=y
 CONFIG_USB_XHCI_HCD=y
 CONFIG_USB_XHCI_DWC3=y
 CONFIG_USB_DWC3=y
index a99d4cacc5c1a750dce3a2bc9023d2ced38df7ab..a3fd6a13de7fed30d0c53818e1bbb79ed8cadcc4 100644 (file)
@@ -70,6 +70,7 @@ CONFIG_MESON_SPIFC=y
 CONFIG_SYSINFO=y
 CONFIG_SYSINFO_SMBIOS=y
 CONFIG_USB=y
+CONFIG_DM_USB_GADGET=y
 CONFIG_USB_XHCI_HCD=y
 CONFIG_USB_XHCI_DWC3=y
 CONFIG_USB_DWC3=y
index af37b4dbc82bcbc6a717c2a73f9b3b908671939e..2c449a1f4287ab6b7f54ebf7d2433efee5135c07 100644 (file)
@@ -50,6 +50,7 @@ CONFIG_DEBUG_UART_ANNOUNCE=y
 CONFIG_DEBUG_UART_SKIP_INIT=y
 CONFIG_MESON_SERIAL=y
 CONFIG_USB=y
+CONFIG_DM_USB_GADGET=y
 CONFIG_USB_XHCI_HCD=y
 CONFIG_USB_XHCI_DWC3=y
 CONFIG_USB_DWC3=y
index 1af9c1139538e630a29a68e3113b52972e828450..2893802f22976405c6e17fbc371119d1eb6e0adc 100644 (file)
@@ -68,6 +68,7 @@ CONFIG_SPI=y
 CONFIG_DM_SPI=y
 CONFIG_MESON_SPIFC=y
 CONFIG_USB=y
+CONFIG_DM_USB_GADGET=y
 CONFIG_USB_XHCI_HCD=y
 CONFIG_USB_XHCI_DWC3=y
 CONFIG_USB_DWC3=y
index fcd99623123d6350ef1bd1af32f126ca64aead39..190645da2559050d2e99db8b0efd03f80f29d487 100644 (file)
@@ -50,6 +50,7 @@ CONFIG_DEBUG_UART_ANNOUNCE=y
 CONFIG_DEBUG_UART_SKIP_INIT=y
 CONFIG_MESON_SERIAL=y
 CONFIG_USB=y
+CONFIG_DM_USB_GADGET=y
 CONFIG_USB_XHCI_HCD=y
 CONFIG_USB_XHCI_DWC3=y
 CONFIG_USB_DWC3=y
index 19bd9f3e35709aaa85a1f5786cb1b0cf0eb6f36a..0c6d3751c5f688a0be70627be12f4eb1d96bba85 100644 (file)
@@ -45,6 +45,7 @@ CONFIG_DEBUG_UART_ANNOUNCE=y
 CONFIG_DEBUG_UART_SKIP_INIT=y
 CONFIG_MESON_SERIAL=y
 CONFIG_USB=y
+CONFIG_DM_USB_GADGET=y
 CONFIG_USB_XHCI_HCD=y
 CONFIG_USB_XHCI_DWC3=y
 CONFIG_USB_DWC3=y
index 30b49ccad4b059a2eb2f7907f3be1be4652e62cc..96e114a3bef9516581658990e028e874639afff4 100644 (file)
@@ -70,6 +70,7 @@ CONFIG_DEBUG_UART_ANNOUNCE=y
 CONFIG_DEBUG_UART_SKIP_INIT=y
 CONFIG_MESON_SERIAL=y
 CONFIG_USB=y
+CONFIG_DM_USB_GADGET=y
 CONFIG_USB_XHCI_HCD=y
 CONFIG_USB_XHCI_DWC3=y
 CONFIG_USB_DWC3=y
index a922765eded6ad046b1010305013c22769296abc..bba46a87ac866ef2a7b53528dcd5fe86737930e6 100644 (file)
@@ -70,6 +70,7 @@ CONFIG_DEBUG_UART_ANNOUNCE=y
 CONFIG_DEBUG_UART_SKIP_INIT=y
 CONFIG_MESON_SERIAL=y
 CONFIG_USB=y
+CONFIG_DM_USB_GADGET=y
 CONFIG_USB_XHCI_HCD=y
 CONFIG_USB_XHCI_DWC3=y
 CONFIG_USB_DWC3=y
index f346b381e2f480096cf3507aa5c0ec11e5641d67..1d19c06fa5de3698f545a569b36c159dde2a5a94 100644 (file)
@@ -44,6 +44,7 @@ CONFIG_DEBUG_UART_ANNOUNCE=y
 CONFIG_DEBUG_UART_SKIP_INIT=y
 CONFIG_MESON_SERIAL=y
 CONFIG_USB=y
+CONFIG_DM_USB_GADGET=y
 CONFIG_USB_XHCI_HCD=y
 CONFIG_USB_XHCI_DWC3=y
 CONFIG_USB_DWC3=y