Patrick Delaunay | d6e53c7 | 2018-10-26 09:02:52 +0200 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0 |
Michal Simek | 9d8cbbf | 2018-05-18 13:15:06 +0200 | [diff] [blame] | 2 | /* |
| 3 | * Generic DWC3 Glue layer |
| 4 | * |
| 5 | * Copyright (C) 2016 - 2018 Xilinx, Inc. |
| 6 | * |
| 7 | * Based on dwc3-omap.c. |
| 8 | */ |
| 9 | |
| 10 | #include <common.h> |
Simon Glass | 6333448 | 2019-11-14 12:57:39 -0700 | [diff] [blame] | 11 | #include <cpu_func.h> |
Simon Glass | 0f2af88 | 2020-05-10 11:40:05 -0600 | [diff] [blame] | 12 | #include <log.h> |
Michal Simek | 9d8cbbf | 2018-05-18 13:15:06 +0200 | [diff] [blame] | 13 | #include <dm.h> |
| 14 | #include <dm/device-internal.h> |
| 15 | #include <dm/lists.h> |
Jean-Jacques Hiblot | aa866a0 | 2018-11-29 10:52:48 +0100 | [diff] [blame] | 16 | #include <dwc3-uboot.h> |
Michal Simek | bb19d62 | 2022-03-09 10:05:45 +0100 | [diff] [blame] | 17 | #include <generic-phy.h> |
Simon Glass | 4dcacfc | 2020-05-10 11:40:13 -0600 | [diff] [blame] | 18 | #include <linux/bitops.h> |
Frank Wang | f5a6c5b | 2020-05-26 11:34:31 +0800 | [diff] [blame] | 19 | #include <linux/delay.h> |
Simon Glass | bdd5f81 | 2023-09-14 18:21:46 -0600 | [diff] [blame] | 20 | #include <linux/printk.h> |
Michal Simek | 9d8cbbf | 2018-05-18 13:15:06 +0200 | [diff] [blame] | 21 | #include <linux/usb/ch9.h> |
| 22 | #include <linux/usb/gadget.h> |
| 23 | #include <malloc.h> |
Caleb Connolly | c52bc90 | 2024-02-26 17:26:06 +0000 | [diff] [blame] | 24 | #include <power/regulator.h> |
Michal Simek | 9d8cbbf | 2018-05-18 13:15:06 +0200 | [diff] [blame] | 25 | #include <usb.h> |
| 26 | #include "core.h" |
| 27 | #include "gadget.h" |
Jean-Jacques Hiblot | aa866a0 | 2018-11-29 10:52:48 +0100 | [diff] [blame] | 28 | #include <reset.h> |
| 29 | #include <clk.h> |
Jean-Jacques Hiblot | 175cd7c | 2019-09-11 11:33:50 +0200 | [diff] [blame] | 30 | #include <usb/xhci.h> |
T Karthik Reddy | f7adf89 | 2022-07-08 11:21:59 +0200 | [diff] [blame] | 31 | #include <asm/gpio.h> |
Michal Simek | 9d8cbbf | 2018-05-18 13:15:06 +0200 | [diff] [blame] | 32 | |
Kunihiko Hayashi | 6cf357e | 2023-02-20 14:50:28 +0900 | [diff] [blame] | 33 | #include "dwc3-generic.h" |
Frank Wang | f5a6c5b | 2020-05-26 11:34:31 +0800 | [diff] [blame] | 34 | |
Jean-Jacques Hiblot | a33aa76 | 2019-09-11 11:33:48 +0200 | [diff] [blame] | 35 | struct dwc3_generic_plat { |
| 36 | fdt_addr_t base; |
| 37 | u32 maximum_speed; |
| 38 | enum usb_dr_mode dr_mode; |
| 39 | }; |
| 40 | |
Jean-Jacques Hiblot | a33aa76 | 2019-09-11 11:33:48 +0200 | [diff] [blame] | 41 | struct dwc3_generic_priv { |
Jean-Jacques Hiblot | 2bf2c35 | 2019-09-11 11:33:49 +0200 | [diff] [blame] | 42 | void *base; |
Jean-Jacques Hiblot | aa866a0 | 2018-11-29 10:52:48 +0100 | [diff] [blame] | 43 | struct dwc3 dwc3; |
developer | f8bced1 | 2020-05-02 11:35:13 +0200 | [diff] [blame] | 44 | struct phy_bulk phys; |
Venkatesh Yadav Abbarapu | 5f70b0a | 2023-01-13 10:42:02 +0530 | [diff] [blame] | 45 | struct gpio_desc *ulpi_reset; |
Jean-Jacques Hiblot | aa866a0 | 2018-11-29 10:52:48 +0100 | [diff] [blame] | 46 | }; |
| 47 | |
Jean-Jacques Hiblot | 175cd7c | 2019-09-11 11:33:50 +0200 | [diff] [blame] | 48 | struct dwc3_generic_host_priv { |
| 49 | struct xhci_ctrl xhci_ctrl; |
| 50 | struct dwc3_generic_priv gen_priv; |
Caleb Connolly | c52bc90 | 2024-02-26 17:26:06 +0000 | [diff] [blame] | 51 | struct udevice *vbus_supply; |
Jean-Jacques Hiblot | 175cd7c | 2019-09-11 11:33:50 +0200 | [diff] [blame] | 52 | }; |
| 53 | |
Jean-Jacques Hiblot | 2bf2c35 | 2019-09-11 11:33:49 +0200 | [diff] [blame] | 54 | static int dwc3_generic_probe(struct udevice *dev, |
| 55 | struct dwc3_generic_priv *priv) |
Michal Simek | 9d8cbbf | 2018-05-18 13:15:06 +0200 | [diff] [blame] | 56 | { |
Jean-Jacques Hiblot | aa866a0 | 2018-11-29 10:52:48 +0100 | [diff] [blame] | 57 | int rc; |
Simon Glass | fa20e93 | 2020-12-03 16:55:20 -0700 | [diff] [blame] | 58 | struct dwc3_generic_plat *plat = dev_get_plat(dev); |
Jean-Jacques Hiblot | aa866a0 | 2018-11-29 10:52:48 +0100 | [diff] [blame] | 59 | struct dwc3 *dwc3 = &priv->dwc3; |
Simon Glass | fa20e93 | 2020-12-03 16:55:20 -0700 | [diff] [blame] | 60 | struct dwc3_glue_data *glue = dev_get_plat(dev->parent); |
Marek Vasut | aacbcb6 | 2022-11-27 15:31:52 +0100 | [diff] [blame] | 61 | int __maybe_unused index; |
| 62 | ofnode __maybe_unused node; |
Jean-Jacques Hiblot | aa866a0 | 2018-11-29 10:52:48 +0100 | [diff] [blame] | 63 | |
Jean-Jacques Hiblot | ce868d0 | 2019-09-11 11:33:52 +0200 | [diff] [blame] | 64 | dwc3->dev = dev; |
Jean-Jacques Hiblot | a33aa76 | 2019-09-11 11:33:48 +0200 | [diff] [blame] | 65 | dwc3->maximum_speed = plat->maximum_speed; |
| 66 | dwc3->dr_mode = plat->dr_mode; |
Jean-Jacques Hiblot | ce868d0 | 2019-09-11 11:33:52 +0200 | [diff] [blame] | 67 | #if CONFIG_IS_ENABLED(OF_CONTROL) |
| 68 | dwc3_of_parse(dwc3); |
Marek Vasut | aacbcb6 | 2022-11-27 15:31:52 +0100 | [diff] [blame] | 69 | |
Marek Vasut | 4d28572 | 2023-02-20 14:50:25 +0900 | [diff] [blame] | 70 | /* |
| 71 | * There are currently four disparate placement possibilities of DWC3 |
| 72 | * reference clock phandle in SoC DTs: |
| 73 | * - in top level glue node, with generic subnode without clock (ZynqMP) |
| 74 | * - in top level generic node, with no subnode (i.MX8MQ) |
| 75 | * - in generic subnode, with other clock in top level node (i.MX8MP) |
| 76 | * - in both top level node and generic subnode (Rockchip) |
| 77 | * Cover all the possibilities here by looking into both nodes, start |
| 78 | * with the top level node as that seems to be used in majority of DTs |
| 79 | * to reference the clock. |
| 80 | */ |
Marek Vasut | aacbcb6 | 2022-11-27 15:31:52 +0100 | [diff] [blame] | 81 | node = dev_ofnode(dev->parent); |
| 82 | index = ofnode_stringlist_search(node, "clock-names", "ref"); |
| 83 | if (index < 0) |
| 84 | index = ofnode_stringlist_search(node, "clock-names", "ref_clk"); |
Marek Vasut | 4d28572 | 2023-02-20 14:50:25 +0900 | [diff] [blame] | 85 | if (index < 0) { |
| 86 | node = dev_ofnode(dev); |
| 87 | index = ofnode_stringlist_search(node, "clock-names", "ref"); |
| 88 | if (index < 0) |
| 89 | index = ofnode_stringlist_search(node, "clock-names", "ref_clk"); |
| 90 | } |
Marek Vasut | aacbcb6 | 2022-11-27 15:31:52 +0100 | [diff] [blame] | 91 | if (index >= 0) |
| 92 | dwc3->ref_clk = &glue->clks.clks[index]; |
Jean-Jacques Hiblot | ce868d0 | 2019-09-11 11:33:52 +0200 | [diff] [blame] | 93 | #endif |
Jean-Jacques Hiblot | a33aa76 | 2019-09-11 11:33:48 +0200 | [diff] [blame] | 94 | |
Frank Wang | f5a6c5b | 2020-05-26 11:34:31 +0800 | [diff] [blame] | 95 | /* |
| 96 | * It must hold whole USB3.0 OTG controller in resetting to hold pipe |
| 97 | * power state in P2 before initializing TypeC PHY on RK3399 platform. |
| 98 | */ |
| 99 | if (device_is_compatible(dev->parent, "rockchip,rk3399-dwc3")) { |
| 100 | reset_assert_bulk(&glue->resets); |
| 101 | udelay(1); |
| 102 | } |
| 103 | |
developer | f8bced1 | 2020-05-02 11:35:13 +0200 | [diff] [blame] | 104 | rc = dwc3_setup_phy(dev, &priv->phys); |
Siva Durga Prasad Paladugu | c37f8f3 | 2020-10-21 14:17:31 +0200 | [diff] [blame] | 105 | if (rc && rc != -ENOTSUPP) |
Jean-Jacques Hiblot | aa866a0 | 2018-11-29 10:52:48 +0100 | [diff] [blame] | 106 | return rc; |
| 107 | |
T Karthik Reddy | f7adf89 | 2022-07-08 11:21:59 +0200 | [diff] [blame] | 108 | if (CONFIG_IS_ENABLED(DM_GPIO) && |
| 109 | device_is_compatible(dev->parent, "xlnx,zynqmp-dwc3")) { |
Venkatesh Yadav Abbarapu | 5f70b0a | 2023-01-13 10:42:02 +0530 | [diff] [blame] | 110 | priv->ulpi_reset = devm_gpiod_get_optional(dev->parent, "reset", |
Peter Korsgaard | 686a0f0 | 2023-06-28 14:26:48 +0200 | [diff] [blame] | 111 | GPIOD_IS_OUT | GPIOD_ACTIVE_LOW); |
Venkatesh Yadav Abbarapu | 5f70b0a | 2023-01-13 10:42:02 +0530 | [diff] [blame] | 112 | /* property is optional, don't return error! */ |
| 113 | if (priv->ulpi_reset) { |
| 114 | /* Toggle ulpi to reset the phy. */ |
| 115 | rc = dm_gpio_set_value(priv->ulpi_reset, 1); |
| 116 | if (rc) |
| 117 | return rc; |
T Karthik Reddy | f7adf89 | 2022-07-08 11:21:59 +0200 | [diff] [blame] | 118 | |
Venkatesh Yadav Abbarapu | 5f70b0a | 2023-01-13 10:42:02 +0530 | [diff] [blame] | 119 | mdelay(5); |
T Karthik Reddy | f7adf89 | 2022-07-08 11:21:59 +0200 | [diff] [blame] | 120 | |
Venkatesh Yadav Abbarapu | 5f70b0a | 2023-01-13 10:42:02 +0530 | [diff] [blame] | 121 | rc = dm_gpio_set_value(priv->ulpi_reset, 0); |
| 122 | if (rc) |
| 123 | return rc; |
T Karthik Reddy | f7adf89 | 2022-07-08 11:21:59 +0200 | [diff] [blame] | 124 | |
Venkatesh Yadav Abbarapu | 5f70b0a | 2023-01-13 10:42:02 +0530 | [diff] [blame] | 125 | mdelay(5); |
| 126 | } |
T Karthik Reddy | f7adf89 | 2022-07-08 11:21:59 +0200 | [diff] [blame] | 127 | } |
| 128 | |
Frank Wang | f5a6c5b | 2020-05-26 11:34:31 +0800 | [diff] [blame] | 129 | if (device_is_compatible(dev->parent, "rockchip,rk3399-dwc3")) |
| 130 | reset_deassert_bulk(&glue->resets); |
| 131 | |
Jean-Jacques Hiblot | 2bf2c35 | 2019-09-11 11:33:49 +0200 | [diff] [blame] | 132 | priv->base = map_physmem(plat->base, DWC3_OTG_REGS_END, MAP_NOCACHE); |
| 133 | dwc3->regs = priv->base + DWC3_GLOBALS_REGS_START; |
Jean-Jacques Hiblot | ce868d0 | 2019-09-11 11:33:52 +0200 | [diff] [blame] | 134 | |
Jean-Jacques Hiblot | aa866a0 | 2018-11-29 10:52:48 +0100 | [diff] [blame] | 135 | |
| 136 | rc = dwc3_init(dwc3); |
| 137 | if (rc) { |
Jean-Jacques Hiblot | 2bf2c35 | 2019-09-11 11:33:49 +0200 | [diff] [blame] | 138 | unmap_physmem(priv->base, MAP_NOCACHE); |
Jean-Jacques Hiblot | aa866a0 | 2018-11-29 10:52:48 +0100 | [diff] [blame] | 139 | return rc; |
| 140 | } |
Michal Simek | 9d8cbbf | 2018-05-18 13:15:06 +0200 | [diff] [blame] | 141 | |
Jean-Jacques Hiblot | aa866a0 | 2018-11-29 10:52:48 +0100 | [diff] [blame] | 142 | return 0; |
Michal Simek | 9d8cbbf | 2018-05-18 13:15:06 +0200 | [diff] [blame] | 143 | } |
| 144 | |
Jean-Jacques Hiblot | 2bf2c35 | 2019-09-11 11:33:49 +0200 | [diff] [blame] | 145 | static int dwc3_generic_remove(struct udevice *dev, |
| 146 | struct dwc3_generic_priv *priv) |
Michal Simek | 9d8cbbf | 2018-05-18 13:15:06 +0200 | [diff] [blame] | 147 | { |
Jean-Jacques Hiblot | aa866a0 | 2018-11-29 10:52:48 +0100 | [diff] [blame] | 148 | struct dwc3 *dwc3 = &priv->dwc3; |
Michal Simek | 9d8cbbf | 2018-05-18 13:15:06 +0200 | [diff] [blame] | 149 | |
T Karthik Reddy | f7adf89 | 2022-07-08 11:21:59 +0200 | [diff] [blame] | 150 | if (CONFIG_IS_ENABLED(DM_GPIO) && |
Venkatesh Yadav Abbarapu | 63d5d86 | 2023-08-09 09:03:50 +0530 | [diff] [blame] | 151 | device_is_compatible(dev->parent, "xlnx,zynqmp-dwc3") && |
| 152 | priv->ulpi_reset) { |
Venkatesh Yadav Abbarapu | 5f70b0a | 2023-01-13 10:42:02 +0530 | [diff] [blame] | 153 | struct gpio_desc *ulpi_reset = priv->ulpi_reset; |
T Karthik Reddy | f7adf89 | 2022-07-08 11:21:59 +0200 | [diff] [blame] | 154 | |
| 155 | dm_gpio_free(ulpi_reset->dev, ulpi_reset); |
| 156 | } |
| 157 | |
Jean-Jacques Hiblot | aa866a0 | 2018-11-29 10:52:48 +0100 | [diff] [blame] | 158 | dwc3_remove(dwc3); |
developer | f8bced1 | 2020-05-02 11:35:13 +0200 | [diff] [blame] | 159 | dwc3_shutdown_phy(dev, &priv->phys); |
Jean-Jacques Hiblot | aa866a0 | 2018-11-29 10:52:48 +0100 | [diff] [blame] | 160 | unmap_physmem(dwc3->regs, MAP_NOCACHE); |
Michal Simek | 9d8cbbf | 2018-05-18 13:15:06 +0200 | [diff] [blame] | 161 | |
| 162 | return 0; |
| 163 | } |
| 164 | |
Simon Glass | aad29ae | 2020-12-03 16:55:21 -0700 | [diff] [blame] | 165 | static int dwc3_generic_of_to_plat(struct udevice *dev) |
Michal Simek | 9d8cbbf | 2018-05-18 13:15:06 +0200 | [diff] [blame] | 166 | { |
Simon Glass | fa20e93 | 2020-12-03 16:55:20 -0700 | [diff] [blame] | 167 | struct dwc3_generic_plat *plat = dev_get_plat(dev); |
Simon Glass | a7ece58 | 2020-12-19 10:40:14 -0700 | [diff] [blame] | 168 | ofnode node = dev_ofnode(dev); |
Michal Simek | 9d8cbbf | 2018-05-18 13:15:06 +0200 | [diff] [blame] | 169 | |
Angus Ainslie | 6e382a8 | 2022-02-02 15:08:54 -0800 | [diff] [blame] | 170 | if (!strncmp(dev->name, "port", 4) || !strncmp(dev->name, "hub", 3)) { |
| 171 | /* This is a leaf so check the parent */ |
| 172 | plat->base = dev_read_addr(dev->parent); |
| 173 | } else { |
| 174 | plat->base = dev_read_addr(dev); |
| 175 | } |
Michal Simek | 9d8cbbf | 2018-05-18 13:15:06 +0200 | [diff] [blame] | 176 | |
Jean-Jacques Hiblot | a33aa76 | 2019-09-11 11:33:48 +0200 | [diff] [blame] | 177 | plat->maximum_speed = usb_get_maximum_speed(node); |
| 178 | if (plat->maximum_speed == USB_SPEED_UNKNOWN) { |
Jean-Jacques Hiblot | 547df0d | 2019-09-11 11:33:51 +0200 | [diff] [blame] | 179 | pr_info("No USB maximum speed specified. Using super speed\n"); |
| 180 | plat->maximum_speed = USB_SPEED_SUPER; |
Michal Simek | 9d8cbbf | 2018-05-18 13:15:06 +0200 | [diff] [blame] | 181 | } |
| 182 | |
Jean-Jacques Hiblot | a33aa76 | 2019-09-11 11:33:48 +0200 | [diff] [blame] | 183 | plat->dr_mode = usb_get_dr_mode(node); |
| 184 | if (plat->dr_mode == USB_DR_MODE_UNKNOWN) { |
Angus Ainslie | 6e382a8 | 2022-02-02 15:08:54 -0800 | [diff] [blame] | 185 | /* might be a leaf so check the parent for mode */ |
| 186 | node = dev_ofnode(dev->parent); |
| 187 | plat->dr_mode = usb_get_dr_mode(node); |
| 188 | if (plat->dr_mode == USB_DR_MODE_UNKNOWN) { |
| 189 | pr_err("Invalid usb mode setup\n"); |
| 190 | return -ENODEV; |
| 191 | } |
Michal Simek | 9d8cbbf | 2018-05-18 13:15:06 +0200 | [diff] [blame] | 192 | } |
| 193 | |
| 194 | return 0; |
| 195 | } |
| 196 | |
Jean-Jacques Hiblot | 2bf2c35 | 2019-09-11 11:33:49 +0200 | [diff] [blame] | 197 | #if CONFIG_IS_ENABLED(DM_USB_GADGET) |
| 198 | int dm_usb_gadget_handle_interrupts(struct udevice *dev) |
| 199 | { |
| 200 | struct dwc3_generic_priv *priv = dev_get_priv(dev); |
| 201 | struct dwc3 *dwc3 = &priv->dwc3; |
| 202 | |
| 203 | dwc3_gadget_uboot_handle_interrupt(dwc3); |
| 204 | |
| 205 | return 0; |
| 206 | } |
| 207 | |
| 208 | static int dwc3_generic_peripheral_probe(struct udevice *dev) |
| 209 | { |
| 210 | struct dwc3_generic_priv *priv = dev_get_priv(dev); |
| 211 | |
| 212 | return dwc3_generic_probe(dev, priv); |
| 213 | } |
| 214 | |
| 215 | static int dwc3_generic_peripheral_remove(struct udevice *dev) |
| 216 | { |
| 217 | struct dwc3_generic_priv *priv = dev_get_priv(dev); |
| 218 | |
| 219 | return dwc3_generic_remove(dev, priv); |
| 220 | } |
| 221 | |
Michal Simek | 9d8cbbf | 2018-05-18 13:15:06 +0200 | [diff] [blame] | 222 | U_BOOT_DRIVER(dwc3_generic_peripheral) = { |
| 223 | .name = "dwc3-generic-peripheral", |
Jean-Jacques Hiblot | 9dc0d5c | 2018-11-29 10:52:46 +0100 | [diff] [blame] | 224 | .id = UCLASS_USB_GADGET_GENERIC, |
Simon Glass | aad29ae | 2020-12-03 16:55:21 -0700 | [diff] [blame] | 225 | .of_to_plat = dwc3_generic_of_to_plat, |
Michal Simek | 9d8cbbf | 2018-05-18 13:15:06 +0200 | [diff] [blame] | 226 | .probe = dwc3_generic_peripheral_probe, |
| 227 | .remove = dwc3_generic_peripheral_remove, |
Simon Glass | 8a2b47f | 2020-12-03 16:55:17 -0700 | [diff] [blame] | 228 | .priv_auto = sizeof(struct dwc3_generic_priv), |
Simon Glass | 71fa5b4 | 2020-12-03 16:55:18 -0700 | [diff] [blame] | 229 | .plat_auto = sizeof(struct dwc3_generic_plat), |
Michal Simek | 9d8cbbf | 2018-05-18 13:15:06 +0200 | [diff] [blame] | 230 | }; |
Jean-Jacques Hiblot | 44aaec7 | 2018-11-29 10:52:42 +0100 | [diff] [blame] | 231 | #endif |
Michal Simek | 9d8cbbf | 2018-05-18 13:15:06 +0200 | [diff] [blame] | 232 | |
Jonas Karlman | 5e8b61b | 2023-07-30 22:59:56 +0000 | [diff] [blame] | 233 | #if CONFIG_IS_ENABLED(USB_HOST) |
Jean-Jacques Hiblot | 175cd7c | 2019-09-11 11:33:50 +0200 | [diff] [blame] | 234 | static int dwc3_generic_host_probe(struct udevice *dev) |
| 235 | { |
| 236 | struct xhci_hcor *hcor; |
| 237 | struct xhci_hccr *hccr; |
| 238 | struct dwc3_generic_host_priv *priv = dev_get_priv(dev); |
| 239 | int rc; |
| 240 | |
| 241 | rc = dwc3_generic_probe(dev, &priv->gen_priv); |
| 242 | if (rc) |
| 243 | return rc; |
| 244 | |
Caleb Connolly | c52bc90 | 2024-02-26 17:26:06 +0000 | [diff] [blame] | 245 | rc = device_get_supply_regulator(dev, "vbus-supply", &priv->vbus_supply); |
| 246 | if (rc) |
| 247 | debug("%s: No vbus regulator found: %d\n", dev->name, rc); |
| 248 | |
| 249 | /* Only returns an error if regulator is valid and failed to enable due to a driver issue */ |
| 250 | rc = regulator_set_enable_if_allowed(priv->vbus_supply, true); |
| 251 | if (rc) |
| 252 | return rc; |
| 253 | |
Jean-Jacques Hiblot | 175cd7c | 2019-09-11 11:33:50 +0200 | [diff] [blame] | 254 | hccr = (struct xhci_hccr *)priv->gen_priv.base; |
| 255 | hcor = (struct xhci_hcor *)(priv->gen_priv.base + |
| 256 | HC_LENGTH(xhci_readl(&(hccr)->cr_capbase))); |
| 257 | |
Caleb Connolly | c52bc90 | 2024-02-26 17:26:06 +0000 | [diff] [blame] | 258 | rc = xhci_register(dev, hccr, hcor); |
| 259 | if (rc) |
| 260 | regulator_set_enable_if_allowed(priv->vbus_supply, false); |
| 261 | |
| 262 | return rc; |
Jean-Jacques Hiblot | 175cd7c | 2019-09-11 11:33:50 +0200 | [diff] [blame] | 263 | } |
| 264 | |
| 265 | static int dwc3_generic_host_remove(struct udevice *dev) |
| 266 | { |
| 267 | struct dwc3_generic_host_priv *priv = dev_get_priv(dev); |
| 268 | int rc; |
| 269 | |
Caleb Connolly | c52bc90 | 2024-02-26 17:26:06 +0000 | [diff] [blame] | 270 | /* This function always returns 0 */ |
| 271 | xhci_deregister(dev); |
| 272 | |
| 273 | rc = regulator_set_enable_if_allowed(priv->vbus_supply, false); |
Jean-Jacques Hiblot | 175cd7c | 2019-09-11 11:33:50 +0200 | [diff] [blame] | 274 | if (rc) |
Caleb Connolly | c52bc90 | 2024-02-26 17:26:06 +0000 | [diff] [blame] | 275 | debug("%s: Failed to disable vbus regulator: %d\n", dev->name, rc); |
Jean-Jacques Hiblot | 175cd7c | 2019-09-11 11:33:50 +0200 | [diff] [blame] | 276 | |
| 277 | return dwc3_generic_remove(dev, &priv->gen_priv); |
| 278 | } |
| 279 | |
| 280 | U_BOOT_DRIVER(dwc3_generic_host) = { |
| 281 | .name = "dwc3-generic-host", |
| 282 | .id = UCLASS_USB, |
Simon Glass | aad29ae | 2020-12-03 16:55:21 -0700 | [diff] [blame] | 283 | .of_to_plat = dwc3_generic_of_to_plat, |
Jean-Jacques Hiblot | 175cd7c | 2019-09-11 11:33:50 +0200 | [diff] [blame] | 284 | .probe = dwc3_generic_host_probe, |
| 285 | .remove = dwc3_generic_host_remove, |
Simon Glass | 8a2b47f | 2020-12-03 16:55:17 -0700 | [diff] [blame] | 286 | .priv_auto = sizeof(struct dwc3_generic_host_priv), |
Simon Glass | 71fa5b4 | 2020-12-03 16:55:18 -0700 | [diff] [blame] | 287 | .plat_auto = sizeof(struct dwc3_generic_plat), |
Jean-Jacques Hiblot | 175cd7c | 2019-09-11 11:33:50 +0200 | [diff] [blame] | 288 | .ops = &xhci_usb_ops, |
| 289 | .flags = DM_FLAG_ALLOC_PRIV_DMA, |
| 290 | }; |
| 291 | #endif |
| 292 | |
Marek Vasut | ae21934 | 2022-04-13 00:42:56 +0200 | [diff] [blame] | 293 | void dwc3_imx8mp_glue_configure(struct udevice *dev, int index, |
| 294 | enum usb_dr_mode mode) |
| 295 | { |
| 296 | /* USB glue registers */ |
| 297 | #define USB_CTRL0 0x00 |
| 298 | #define USB_CTRL1 0x04 |
| 299 | |
| 300 | #define USB_CTRL0_PORTPWR_EN BIT(12) /* 1 - PPC enabled (default) */ |
| 301 | #define USB_CTRL0_USB3_FIXED BIT(22) /* 1 - USB3 permanent attached */ |
| 302 | #define USB_CTRL0_USB2_FIXED BIT(23) /* 1 - USB2 permanent attached */ |
| 303 | |
| 304 | #define USB_CTRL1_OC_POLARITY BIT(16) /* 0 - HIGH / 1 - LOW */ |
| 305 | #define USB_CTRL1_PWR_POLARITY BIT(17) /* 0 - HIGH / 1 - LOW */ |
| 306 | fdt_addr_t regs = dev_read_addr_index(dev, 1); |
| 307 | void *base = map_physmem(regs, 0x8, MAP_NOCACHE); |
| 308 | u32 value; |
| 309 | |
| 310 | value = readl(base + USB_CTRL0); |
| 311 | |
| 312 | if (dev_read_bool(dev, "fsl,permanently-attached")) |
| 313 | value |= (USB_CTRL0_USB2_FIXED | USB_CTRL0_USB3_FIXED); |
| 314 | else |
| 315 | value &= ~(USB_CTRL0_USB2_FIXED | USB_CTRL0_USB3_FIXED); |
| 316 | |
| 317 | if (dev_read_bool(dev, "fsl,disable-port-power-control")) |
| 318 | value &= ~(USB_CTRL0_PORTPWR_EN); |
| 319 | else |
| 320 | value |= USB_CTRL0_PORTPWR_EN; |
| 321 | |
| 322 | writel(value, base + USB_CTRL0); |
| 323 | |
| 324 | value = readl(base + USB_CTRL1); |
| 325 | if (dev_read_bool(dev, "fsl,over-current-active-low")) |
| 326 | value |= USB_CTRL1_OC_POLARITY; |
| 327 | else |
| 328 | value &= ~USB_CTRL1_OC_POLARITY; |
| 329 | |
| 330 | if (dev_read_bool(dev, "fsl,power-active-low")) |
| 331 | value |= USB_CTRL1_PWR_POLARITY; |
| 332 | else |
| 333 | value &= ~USB_CTRL1_PWR_POLARITY; |
| 334 | |
| 335 | writel(value, base + USB_CTRL1); |
| 336 | |
| 337 | unmap_physmem(base, MAP_NOCACHE); |
| 338 | } |
| 339 | |
| 340 | struct dwc3_glue_ops imx8mp_ops = { |
| 341 | .glue_configure = dwc3_imx8mp_glue_configure, |
| 342 | }; |
| 343 | |
Marek Vasut | 68c8656 | 2022-04-13 00:42:55 +0200 | [diff] [blame] | 344 | void dwc3_ti_glue_configure(struct udevice *dev, int index, |
Jean-Jacques Hiblot | 65596f1 | 2018-11-29 10:57:40 +0100 | [diff] [blame] | 345 | enum usb_dr_mode mode) |
| 346 | { |
| 347 | #define USBOTGSS_UTMI_OTG_STATUS 0x0084 |
| 348 | #define USBOTGSS_UTMI_OTG_OFFSET 0x0480 |
| 349 | |
| 350 | /* UTMI_OTG_STATUS REGISTER */ |
| 351 | #define USBOTGSS_UTMI_OTG_STATUS_SW_MODE BIT(31) |
| 352 | #define USBOTGSS_UTMI_OTG_STATUS_POWERPRESENT BIT(9) |
| 353 | #define USBOTGSS_UTMI_OTG_STATUS_TXBITSTUFFENABLE BIT(8) |
| 354 | #define USBOTGSS_UTMI_OTG_STATUS_IDDIG BIT(4) |
| 355 | #define USBOTGSS_UTMI_OTG_STATUS_SESSEND BIT(3) |
| 356 | #define USBOTGSS_UTMI_OTG_STATUS_SESSVALID BIT(2) |
| 357 | #define USBOTGSS_UTMI_OTG_STATUS_VBUSVALID BIT(1) |
| 358 | enum dwc3_omap_utmi_mode { |
| 359 | DWC3_OMAP_UTMI_MODE_UNKNOWN = 0, |
| 360 | DWC3_OMAP_UTMI_MODE_HW, |
| 361 | DWC3_OMAP_UTMI_MODE_SW, |
| 362 | }; |
| 363 | |
| 364 | u32 use_id_pin; |
| 365 | u32 host_mode; |
| 366 | u32 reg; |
| 367 | u32 utmi_mode; |
| 368 | u32 utmi_status_offset = USBOTGSS_UTMI_OTG_STATUS; |
| 369 | |
Simon Glass | fa20e93 | 2020-12-03 16:55:20 -0700 | [diff] [blame] | 370 | struct dwc3_glue_data *glue = dev_get_plat(dev); |
Jean-Jacques Hiblot | 65596f1 | 2018-11-29 10:57:40 +0100 | [diff] [blame] | 371 | void *base = map_physmem(glue->regs, 0x10000, MAP_NOCACHE); |
| 372 | |
| 373 | if (device_is_compatible(dev, "ti,am437x-dwc3")) |
| 374 | utmi_status_offset += USBOTGSS_UTMI_OTG_OFFSET; |
| 375 | |
| 376 | utmi_mode = dev_read_u32_default(dev, "utmi-mode", |
| 377 | DWC3_OMAP_UTMI_MODE_UNKNOWN); |
| 378 | if (utmi_mode != DWC3_OMAP_UTMI_MODE_HW) { |
| 379 | debug("%s: OTG is not supported. defaulting to PERIPHERAL\n", |
| 380 | dev->name); |
| 381 | mode = USB_DR_MODE_PERIPHERAL; |
| 382 | } |
| 383 | |
| 384 | switch (mode) { |
| 385 | case USB_DR_MODE_PERIPHERAL: |
| 386 | use_id_pin = 0; |
| 387 | host_mode = 0; |
| 388 | break; |
| 389 | case USB_DR_MODE_HOST: |
| 390 | use_id_pin = 0; |
| 391 | host_mode = 1; |
| 392 | break; |
| 393 | case USB_DR_MODE_OTG: |
| 394 | default: |
| 395 | use_id_pin = 1; |
| 396 | host_mode = 0; |
| 397 | break; |
| 398 | } |
| 399 | |
| 400 | reg = readl(base + utmi_status_offset); |
| 401 | |
| 402 | reg &= ~(USBOTGSS_UTMI_OTG_STATUS_SW_MODE); |
| 403 | if (!use_id_pin) |
| 404 | reg |= USBOTGSS_UTMI_OTG_STATUS_SW_MODE; |
| 405 | |
| 406 | writel(reg, base + utmi_status_offset); |
| 407 | |
| 408 | reg &= ~(USBOTGSS_UTMI_OTG_STATUS_SESSEND | |
| 409 | USBOTGSS_UTMI_OTG_STATUS_VBUSVALID | |
| 410 | USBOTGSS_UTMI_OTG_STATUS_IDDIG); |
| 411 | |
| 412 | reg |= USBOTGSS_UTMI_OTG_STATUS_SESSVALID | |
| 413 | USBOTGSS_UTMI_OTG_STATUS_POWERPRESENT; |
| 414 | |
| 415 | if (!host_mode) |
| 416 | reg |= USBOTGSS_UTMI_OTG_STATUS_IDDIG | |
| 417 | USBOTGSS_UTMI_OTG_STATUS_VBUSVALID; |
| 418 | |
| 419 | writel(reg, base + utmi_status_offset); |
| 420 | |
| 421 | unmap_physmem(base, MAP_NOCACHE); |
| 422 | } |
| 423 | |
| 424 | struct dwc3_glue_ops ti_ops = { |
Marek Vasut | 68c8656 | 2022-04-13 00:42:55 +0200 | [diff] [blame] | 425 | .glue_configure = dwc3_ti_glue_configure, |
Jean-Jacques Hiblot | 65596f1 | 2018-11-29 10:57:40 +0100 | [diff] [blame] | 426 | }; |
| 427 | |
Jonas Karlman | 04c6ae8 | 2023-07-30 22:59:57 +0000 | [diff] [blame] | 428 | static int dwc3_rk_glue_get_ctrl_dev(struct udevice *dev, ofnode *node) |
| 429 | { |
| 430 | *node = dev_ofnode(dev); |
| 431 | if (!ofnode_valid(*node)) |
| 432 | return -EINVAL; |
| 433 | |
| 434 | return 0; |
| 435 | } |
| 436 | |
| 437 | struct dwc3_glue_ops rk_ops = { |
| 438 | .glue_get_ctrl_dev = dwc3_rk_glue_get_ctrl_dev, |
| 439 | }; |
| 440 | |
Kunihiko Hayashi | 8c42037 | 2023-02-20 14:50:26 +0900 | [diff] [blame] | 441 | static int dwc3_glue_bind_common(struct udevice *parent, ofnode node) |
Michal Simek | 9d8cbbf | 2018-05-18 13:15:06 +0200 | [diff] [blame] | 442 | { |
Kunihiko Hayashi | 8c42037 | 2023-02-20 14:50:26 +0900 | [diff] [blame] | 443 | const char *name = ofnode_get_name(node); |
Jonas Karlman | 5e8b61b | 2023-07-30 22:59:56 +0000 | [diff] [blame] | 444 | const char *driver; |
Angus Ainslie | 6e382a8 | 2022-02-02 15:08:54 -0800 | [diff] [blame] | 445 | enum usb_dr_mode dr_mode; |
Kunihiko Hayashi | 8c42037 | 2023-02-20 14:50:26 +0900 | [diff] [blame] | 446 | struct udevice *dev; |
| 447 | int ret; |
Michal Simek | 9d8cbbf | 2018-05-18 13:15:06 +0200 | [diff] [blame] | 448 | |
Kunihiko Hayashi | 8c42037 | 2023-02-20 14:50:26 +0900 | [diff] [blame] | 449 | debug("%s: subnode name: %s\n", __func__, name); |
Michal Simek | 9d8cbbf | 2018-05-18 13:15:06 +0200 | [diff] [blame] | 450 | |
Kunihiko Hayashi | 8c42037 | 2023-02-20 14:50:26 +0900 | [diff] [blame] | 451 | /* if the parent node doesn't have a mode check the leaf */ |
| 452 | dr_mode = usb_get_dr_mode(dev_ofnode(parent)); |
| 453 | if (!dr_mode) |
| 454 | dr_mode = usb_get_dr_mode(node); |
Michal Simek | 9d8cbbf | 2018-05-18 13:15:06 +0200 | [diff] [blame] | 455 | |
Jonas Karlman | 5e8b61b | 2023-07-30 22:59:56 +0000 | [diff] [blame] | 456 | if (CONFIG_IS_ENABLED(DM_USB_GADGET) && |
| 457 | (dr_mode == USB_DR_MODE_PERIPHERAL || dr_mode == USB_DR_MODE_OTG)) { |
Kunihiko Hayashi | 8c42037 | 2023-02-20 14:50:26 +0900 | [diff] [blame] | 458 | debug("%s: dr_mode: OTG or Peripheral\n", __func__); |
| 459 | driver = "dwc3-generic-peripheral"; |
Jonas Karlman | 5e8b61b | 2023-07-30 22:59:56 +0000 | [diff] [blame] | 460 | } else if (CONFIG_IS_ENABLED(USB_HOST) && dr_mode == USB_DR_MODE_HOST) { |
Kunihiko Hayashi | 8c42037 | 2023-02-20 14:50:26 +0900 | [diff] [blame] | 461 | debug("%s: dr_mode: HOST\n", __func__); |
| 462 | driver = "dwc3-generic-host"; |
Jonas Karlman | 5e8b61b | 2023-07-30 22:59:56 +0000 | [diff] [blame] | 463 | } else { |
| 464 | debug("%s: unsupported dr_mode %d\n", __func__, dr_mode); |
Kunihiko Hayashi | 8c42037 | 2023-02-20 14:50:26 +0900 | [diff] [blame] | 465 | return -ENODEV; |
Jonas Karlman | 5e8b61b | 2023-07-30 22:59:56 +0000 | [diff] [blame] | 466 | } |
Jean-Jacques Hiblot | aa866a0 | 2018-11-29 10:52:48 +0100 | [diff] [blame] | 467 | |
Kunihiko Hayashi | 8c42037 | 2023-02-20 14:50:26 +0900 | [diff] [blame] | 468 | ret = device_bind_driver_to_node(parent, driver, name, |
| 469 | node, &dev); |
| 470 | if (ret) { |
| 471 | debug("%s: not able to bind usb device mode\n", |
| 472 | __func__); |
| 473 | return ret; |
| 474 | } |
| 475 | |
| 476 | return 0; |
| 477 | } |
| 478 | |
Kunihiko Hayashi | 6cf357e | 2023-02-20 14:50:28 +0900 | [diff] [blame] | 479 | int dwc3_glue_bind(struct udevice *parent) |
Kunihiko Hayashi | 8c42037 | 2023-02-20 14:50:26 +0900 | [diff] [blame] | 480 | { |
| 481 | struct dwc3_glue_ops *ops = (struct dwc3_glue_ops *)dev_get_driver_data(parent); |
| 482 | ofnode node; |
| 483 | int ret; |
| 484 | |
| 485 | if (ops && ops->glue_get_ctrl_dev) { |
| 486 | ret = ops->glue_get_ctrl_dev(parent, &node); |
| 487 | if (ret) |
| 488 | return ret; |
| 489 | |
| 490 | return dwc3_glue_bind_common(parent, node); |
| 491 | } |
| 492 | |
| 493 | ofnode_for_each_subnode(node, dev_ofnode(parent)) { |
| 494 | ret = dwc3_glue_bind_common(parent, node); |
| 495 | if (ret == -ENXIO) |
| 496 | continue; |
| 497 | if (ret) |
Michal Simek | 9d8cbbf | 2018-05-18 13:15:06 +0200 | [diff] [blame] | 498 | return ret; |
Michal Simek | 9d8cbbf | 2018-05-18 13:15:06 +0200 | [diff] [blame] | 499 | } |
Jean-Jacques Hiblot | aa866a0 | 2018-11-29 10:52:48 +0100 | [diff] [blame] | 500 | |
| 501 | return 0; |
| 502 | } |
| 503 | |
| 504 | static int dwc3_glue_reset_init(struct udevice *dev, |
| 505 | struct dwc3_glue_data *glue) |
| 506 | { |
| 507 | int ret; |
| 508 | |
| 509 | ret = reset_get_bulk(dev, &glue->resets); |
Vignesh Raghavendra | e9310fc | 2019-10-25 13:48:05 +0530 | [diff] [blame] | 510 | if (ret == -ENOTSUPP || ret == -ENOENT) |
Jean-Jacques Hiblot | aa866a0 | 2018-11-29 10:52:48 +0100 | [diff] [blame] | 511 | return 0; |
| 512 | else if (ret) |
| 513 | return ret; |
| 514 | |
| 515 | ret = reset_deassert_bulk(&glue->resets); |
| 516 | if (ret) { |
| 517 | reset_release_bulk(&glue->resets); |
| 518 | return ret; |
| 519 | } |
| 520 | |
| 521 | return 0; |
| 522 | } |
| 523 | |
| 524 | static int dwc3_glue_clk_init(struct udevice *dev, |
| 525 | struct dwc3_glue_data *glue) |
| 526 | { |
| 527 | int ret; |
| 528 | |
| 529 | ret = clk_get_bulk(dev, &glue->clks); |
Vignesh Raghavendra | e9310fc | 2019-10-25 13:48:05 +0530 | [diff] [blame] | 530 | if (ret == -ENOSYS || ret == -ENOENT) |
Jean-Jacques Hiblot | aa866a0 | 2018-11-29 10:52:48 +0100 | [diff] [blame] | 531 | return 0; |
| 532 | if (ret) |
| 533 | return ret; |
| 534 | |
| 535 | #if CONFIG_IS_ENABLED(CLK) |
| 536 | ret = clk_enable_bulk(&glue->clks); |
| 537 | if (ret) { |
| 538 | clk_release_bulk(&glue->clks); |
| 539 | return ret; |
| 540 | } |
| 541 | #endif |
| 542 | |
| 543 | return 0; |
| 544 | } |
| 545 | |
Kunihiko Hayashi | 6cf357e | 2023-02-20 14:50:28 +0900 | [diff] [blame] | 546 | int dwc3_glue_probe(struct udevice *dev) |
Jean-Jacques Hiblot | aa866a0 | 2018-11-29 10:52:48 +0100 | [diff] [blame] | 547 | { |
Jean-Jacques Hiblot | ae004d3 | 2018-11-29 10:52:49 +0100 | [diff] [blame] | 548 | struct dwc3_glue_ops *ops = (struct dwc3_glue_ops *)dev_get_driver_data(dev); |
Simon Glass | fa20e93 | 2020-12-03 16:55:20 -0700 | [diff] [blame] | 549 | struct dwc3_glue_data *glue = dev_get_plat(dev); |
Jean-Jacques Hiblot | ae004d3 | 2018-11-29 10:52:49 +0100 | [diff] [blame] | 550 | struct udevice *child = NULL; |
| 551 | int index = 0; |
Jean-Jacques Hiblot | aa866a0 | 2018-11-29 10:52:48 +0100 | [diff] [blame] | 552 | int ret; |
Michal Simek | bb19d62 | 2022-03-09 10:05:45 +0100 | [diff] [blame] | 553 | struct phy phy; |
| 554 | |
| 555 | ret = generic_phy_get_by_name(dev, "usb3-phy", &phy); |
| 556 | if (!ret) { |
| 557 | ret = generic_phy_init(&phy); |
| 558 | if (ret) |
| 559 | return ret; |
Jan Kiszka | 2fe2cf0 | 2022-04-25 13:26:45 +0200 | [diff] [blame] | 560 | } else if (ret != -ENOENT && ret != -ENODATA) { |
Michal Simek | bb19d62 | 2022-03-09 10:05:45 +0100 | [diff] [blame] | 561 | debug("could not get phy (err %d)\n", ret); |
| 562 | return ret; |
| 563 | } |
Jean-Jacques Hiblot | aa866a0 | 2018-11-29 10:52:48 +0100 | [diff] [blame] | 564 | |
Kunihiko Hayashi | 54c277e | 2023-02-20 14:50:29 +0900 | [diff] [blame] | 565 | glue->regs = dev_read_addr_size_index(dev, 0, &glue->size); |
Jean-Jacques Hiblot | ae004d3 | 2018-11-29 10:52:49 +0100 | [diff] [blame] | 566 | |
Jean-Jacques Hiblot | aa866a0 | 2018-11-29 10:52:48 +0100 | [diff] [blame] | 567 | ret = dwc3_glue_clk_init(dev, glue); |
| 568 | if (ret) |
| 569 | return ret; |
| 570 | |
| 571 | ret = dwc3_glue_reset_init(dev, glue); |
| 572 | if (ret) |
| 573 | return ret; |
Michal Simek | 9d8cbbf | 2018-05-18 13:15:06 +0200 | [diff] [blame] | 574 | |
Jonas Karlman | fd5c3c2 | 2023-08-31 22:16:36 +0000 | [diff] [blame] | 575 | if (generic_phy_valid(&phy)) { |
Michal Simek | bb19d62 | 2022-03-09 10:05:45 +0100 | [diff] [blame] | 576 | ret = generic_phy_power_on(&phy); |
| 577 | if (ret) |
| 578 | return ret; |
| 579 | } |
| 580 | |
Jonas Karlman | ee1e070 | 2023-07-30 22:59:55 +0000 | [diff] [blame] | 581 | device_find_first_child(dev, &child); |
| 582 | if (!child) |
| 583 | return 0; |
Jean-Jacques Hiblot | ae004d3 | 2018-11-29 10:52:49 +0100 | [diff] [blame] | 584 | |
Kunihiko Hayashi | df0f5d3 | 2023-02-20 14:50:27 +0900 | [diff] [blame] | 585 | if (glue->clks.count == 0) { |
| 586 | ret = dwc3_glue_clk_init(child, glue); |
| 587 | if (ret) |
| 588 | return ret; |
| 589 | } |
| 590 | |
Frank Wang | f5a6c5b | 2020-05-26 11:34:31 +0800 | [diff] [blame] | 591 | if (glue->resets.count == 0) { |
| 592 | ret = dwc3_glue_reset_init(child, glue); |
| 593 | if (ret) |
| 594 | return ret; |
| 595 | } |
| 596 | |
Jean-Jacques Hiblot | ae004d3 | 2018-11-29 10:52:49 +0100 | [diff] [blame] | 597 | while (child) { |
| 598 | enum usb_dr_mode dr_mode; |
| 599 | |
Simon Glass | a7ece58 | 2020-12-19 10:40:14 -0700 | [diff] [blame] | 600 | dr_mode = usb_get_dr_mode(dev_ofnode(child)); |
Jean-Jacques Hiblot | ae004d3 | 2018-11-29 10:52:49 +0100 | [diff] [blame] | 601 | device_find_next_child(&child); |
Marek Vasut | 68c8656 | 2022-04-13 00:42:55 +0200 | [diff] [blame] | 602 | if (ops && ops->glue_configure) |
| 603 | ops->glue_configure(dev, index, dr_mode); |
Jean-Jacques Hiblot | ae004d3 | 2018-11-29 10:52:49 +0100 | [diff] [blame] | 604 | index++; |
| 605 | } |
| 606 | |
Michal Simek | 9d8cbbf | 2018-05-18 13:15:06 +0200 | [diff] [blame] | 607 | return 0; |
| 608 | } |
| 609 | |
Kunihiko Hayashi | 6cf357e | 2023-02-20 14:50:28 +0900 | [diff] [blame] | 610 | int dwc3_glue_remove(struct udevice *dev) |
Jean-Jacques Hiblot | aa866a0 | 2018-11-29 10:52:48 +0100 | [diff] [blame] | 611 | { |
Simon Glass | fa20e93 | 2020-12-03 16:55:20 -0700 | [diff] [blame] | 612 | struct dwc3_glue_data *glue = dev_get_plat(dev); |
Jean-Jacques Hiblot | aa866a0 | 2018-11-29 10:52:48 +0100 | [diff] [blame] | 613 | |
| 614 | reset_release_bulk(&glue->resets); |
| 615 | |
| 616 | clk_release_bulk(&glue->clks); |
| 617 | |
Jean-Jacques Hiblot | 5a94557 | 2019-07-05 09:33:56 +0200 | [diff] [blame] | 618 | return 0; |
Jean-Jacques Hiblot | aa866a0 | 2018-11-29 10:52:48 +0100 | [diff] [blame] | 619 | } |
| 620 | |
| 621 | static const struct udevice_id dwc3_glue_ids[] = { |
Michal Simek | 9d8cbbf | 2018-05-18 13:15:06 +0200 | [diff] [blame] | 622 | { .compatible = "xlnx,zynqmp-dwc3" }, |
Siva Durga Prasad Paladugu | 1eb3c30 | 2020-05-12 08:36:01 +0200 | [diff] [blame] | 623 | { .compatible = "xlnx,versal-dwc3" }, |
Jean-Jacques Hiblot | 3e0684b | 2018-12-04 11:12:56 +0100 | [diff] [blame] | 624 | { .compatible = "ti,keystone-dwc3"}, |
Jean-Jacques Hiblot | 65596f1 | 2018-11-29 10:57:40 +0100 | [diff] [blame] | 625 | { .compatible = "ti,dwc3", .data = (ulong)&ti_ops }, |
Jean-Jacques Hiblot | ca848df | 2018-12-04 11:30:50 +0100 | [diff] [blame] | 626 | { .compatible = "ti,am437x-dwc3", .data = (ulong)&ti_ops }, |
Vignesh Raghavendra | c628295 | 2019-12-09 10:37:29 +0530 | [diff] [blame] | 627 | { .compatible = "ti,am654-dwc3" }, |
Jagan Teki | e5b9341 | 2023-06-06 22:39:14 +0530 | [diff] [blame] | 628 | { .compatible = "rockchip,rk3328-dwc3", .data = (ulong)&rk_ops }, |
Frank Wang | f5a6c5b | 2020-05-26 11:34:31 +0800 | [diff] [blame] | 629 | { .compatible = "rockchip,rk3399-dwc3" }, |
Jonas Karlman | 04c6ae8 | 2023-07-30 22:59:57 +0000 | [diff] [blame] | 630 | { .compatible = "rockchip,rk3568-dwc3", .data = (ulong)&rk_ops }, |
Jonas Karlman | 39076d9 | 2023-11-12 15:25:25 +0000 | [diff] [blame] | 631 | { .compatible = "rockchip,rk3588-dwc3", .data = (ulong)&rk_ops }, |
Robert Marko | 746862b | 2020-09-10 16:00:05 +0200 | [diff] [blame] | 632 | { .compatible = "qcom,dwc3" }, |
Marek Vasut | ae21934 | 2022-04-13 00:42:56 +0200 | [diff] [blame] | 633 | { .compatible = "fsl,imx8mp-dwc3", .data = (ulong)&imx8mp_ops }, |
Angus Ainslie | 6e382a8 | 2022-02-02 15:08:54 -0800 | [diff] [blame] | 634 | { .compatible = "fsl,imx8mq-dwc3" }, |
Andy Shevchenko | 221d7fa | 2020-12-03 19:45:01 +0200 | [diff] [blame] | 635 | { .compatible = "intel,tangier-dwc3" }, |
Michal Simek | 9d8cbbf | 2018-05-18 13:15:06 +0200 | [diff] [blame] | 636 | { } |
| 637 | }; |
| 638 | |
| 639 | U_BOOT_DRIVER(dwc3_generic_wrapper) = { |
| 640 | .name = "dwc3-generic-wrapper", |
Jean-Jacques Hiblot | b49b5c2 | 2019-07-05 09:33:58 +0200 | [diff] [blame] | 641 | .id = UCLASS_NOP, |
Jean-Jacques Hiblot | aa866a0 | 2018-11-29 10:52:48 +0100 | [diff] [blame] | 642 | .of_match = dwc3_glue_ids, |
| 643 | .bind = dwc3_glue_bind, |
| 644 | .probe = dwc3_glue_probe, |
| 645 | .remove = dwc3_glue_remove, |
Simon Glass | 71fa5b4 | 2020-12-03 16:55:18 -0700 | [diff] [blame] | 646 | .plat_auto = sizeof(struct dwc3_glue_data), |
Jean-Jacques Hiblot | aa866a0 | 2018-11-29 10:52:48 +0100 | [diff] [blame] | 647 | |
Michal Simek | 9d8cbbf | 2018-05-18 13:15:06 +0200 | [diff] [blame] | 648 | }; |