Lines Matching +full:usb3 +full:- +full:phy0
1 // SPDX-License-Identifier: GPL-2.0
10 #include <asm-generic/io.h>
12 #include <dm/device-internal.h>
14 #include <dwc3-uboot.h>
15 #include <generic-phy.h>
104 "usb2-phy0", "usb2-phy1", "usb3-phy0",
132 regmap_update_bits(priv->regmap, U2P_R0 + (U2P_REG_SIZE * i), in dwc3_meson_g12a_usb2_set_mode()
138 regmap_update_bits(priv->regmap, U2P_R0 + (U2P_REG_SIZE * i), in dwc3_meson_g12a_usb2_set_mode()
148 if (priv->otg_mode == USB_DR_MODE_PERIPHERAL) in dwc3_meson_g12a_usb2_init()
149 priv->otg_phy_mode = USB_DR_MODE_PERIPHERAL; in dwc3_meson_g12a_usb2_init()
151 priv->otg_phy_mode = USB_DR_MODE_HOST; in dwc3_meson_g12a_usb2_init()
154 if (!priv->phys[i].dev) in dwc3_meson_g12a_usb2_init()
157 regmap_update_bits(priv->regmap, U2P_R0 + (U2P_REG_SIZE * i), in dwc3_meson_g12a_usb2_init()
162 regmap_update_bits(priv->regmap, in dwc3_meson_g12a_usb2_init()
168 priv->otg_phy_mode); in dwc3_meson_g12a_usb2_init()
173 regmap_update_bits(priv->regmap, U2P_R0 + (U2P_REG_SIZE * i), in dwc3_meson_g12a_usb2_init()
182 regmap_update_bits(priv->regmap, USB_R3, in dwc3_meson_g12a_usb3_init()
190 regmap_update_bits(priv->regmap, USB_R2, in dwc3_meson_g12a_usb3_init()
194 regmap_update_bits(priv->regmap, USB_R2, in dwc3_meson_g12a_usb3_init()
200 regmap_update_bits(priv->regmap, USB_R1, in dwc3_meson_g12a_usb3_init()
204 regmap_update_bits(priv->regmap, USB_R1, in dwc3_meson_g12a_usb3_init()
211 if (priv->otg_phy_mode == USB_DR_MODE_PERIPHERAL) { in dwc3_meson_g12a_usb_init_mode()
212 regmap_update_bits(priv->regmap, USB_R0, in dwc3_meson_g12a_usb_init_mode()
214 regmap_update_bits(priv->regmap, USB_R0, in dwc3_meson_g12a_usb_init_mode()
216 regmap_update_bits(priv->regmap, USB_R4, in dwc3_meson_g12a_usb_init_mode()
219 regmap_update_bits(priv->regmap, USB_R0, in dwc3_meson_g12a_usb_init_mode()
221 regmap_update_bits(priv->regmap, USB_R4, in dwc3_meson_g12a_usb_init_mode()
234 regmap_update_bits(priv->regmap, USB_R1, in dwc3_meson_g12a_usb_init()
238 regmap_update_bits(priv->regmap, USB_R5, in dwc3_meson_g12a_usb_init()
241 regmap_update_bits(priv->regmap, USB_R5, in dwc3_meson_g12a_usb_init()
244 regmap_update_bits(priv->regmap, USB_R5, in dwc3_meson_g12a_usb_init()
249 if (priv->usb3_ports) in dwc3_meson_g12a_usb_init()
262 return -EINVAL; in dwc3_meson_g12a_force_mode()
265 return -EINVAL; in dwc3_meson_g12a_force_mode()
267 if (!priv->phys[USB2_OTG_PHY].dev) in dwc3_meson_g12a_force_mode()
268 return -EINVAL; in dwc3_meson_g12a_force_mode()
270 if (mode == priv->otg_mode) in dwc3_meson_g12a_force_mode()
279 if (priv->vbus_supply) { in dwc3_meson_g12a_force_mode()
280 int ret = regulator_set_enable(priv->vbus_supply, in dwc3_meson_g12a_force_mode()
286 priv->otg_phy_mode = mode; in dwc3_meson_g12a_force_mode()
300 ret = generic_phy_get_by_name(priv->dev, phy_names[i], in dwc3_meson_g12a_get_phys()
301 &priv->phys[i]); in dwc3_meson_g12a_get_phys()
302 if (ret == -ENOENT) in dwc3_meson_g12a_get_phys()
309 priv->usb3_ports++; in dwc3_meson_g12a_get_phys()
311 priv->usb2_ports++; in dwc3_meson_g12a_get_phys()
314 debug("%s: usb2 ports: %d\n", __func__, priv->usb2_ports); in dwc3_meson_g12a_get_phys()
315 debug("%s: usb3 ports: %d\n", __func__, priv->usb3_ports); in dwc3_meson_g12a_get_phys()
324 ret = reset_get_by_index(priv->dev, 0, &priv->reset); in dwc3_meson_g12a_reset_init()
328 ret = reset_assert(&priv->reset); in dwc3_meson_g12a_reset_init()
330 ret |= reset_deassert(&priv->reset); in dwc3_meson_g12a_reset_init()
332 reset_free(&priv->reset); in dwc3_meson_g12a_reset_init()
343 ret = clk_get_by_index(priv->dev, 0, &priv->clk); in dwc3_meson_g12a_clk_init()
348 ret = clk_enable(&priv->clk); in dwc3_meson_g12a_clk_init()
350 clk_free(&priv->clk); in dwc3_meson_g12a_clk_init()
363 priv->dev = dev; in dwc3_meson_g12a_probe()
365 ret = regmap_init_mem(dev_ofnode(dev), &priv->regmap); in dwc3_meson_g12a_probe()
382 ret = device_get_supply_regulator(dev, "vbus-supply", in dwc3_meson_g12a_probe()
383 &priv->vbus_supply); in dwc3_meson_g12a_probe()
384 if (ret && ret != -ENOENT) { in dwc3_meson_g12a_probe()
389 if (priv->vbus_supply) { in dwc3_meson_g12a_probe()
390 ret = regulator_set_enable(priv->vbus_supply, true); in dwc3_meson_g12a_probe()
396 priv->otg_mode = usb_get_dr_mode(dev->node); in dwc3_meson_g12a_probe()
403 if (!priv->phys[i].dev) in dwc3_meson_g12a_probe()
406 ret = generic_phy_init(&priv->phys[i]); in dwc3_meson_g12a_probe()
415 if (!priv->phys[i].dev) in dwc3_meson_g12a_probe()
418 generic_phy_exit(&priv->phys[i]); in dwc3_meson_g12a_probe()
429 reset_release_all(&priv->reset, 1); in dwc3_meson_g12a_remove()
431 clk_release_all(&priv->clk, 1); in dwc3_meson_g12a_remove()
434 if (!priv->phys[i].dev) in dwc3_meson_g12a_remove()
437 generic_phy_exit(&priv->phys[i]); in dwc3_meson_g12a_remove()
444 { .compatible = "amlogic,meson-g12a-usb-ctrl" },
449 .name = "dwc3-meson-g12a",