1 // SPDX-License-Identifier: GPL-2.0+
3 * Based on the DA8xx "glue layer" code.
4 * Copyright (c) 2008-2019, MontaVista Software, Inc. <source@mvista.com>
6 * DT support added by: Adam Ford <aford173@gmail.com>
12 #include <dm/device-internal.h>
14 #include <asm/arch/hardware.h>
15 #include <asm/arch/da8xx-usb.h>
17 #include <generic-phy.h>
19 static int da8xx_usb_phy_power_on(struct phy *phy)
21 unsigned long timeout;
23 clrsetbits_le32(&davinci_syscfg_regs->cfgchip2,
24 CFGCHIP2_RESET | CFGCHIP2_PHYPWRDN | CFGCHIP2_OTGPWRDN |
25 CFGCHIP2_OTGMODE | CFGCHIP2_REFFREQ,
26 CFGCHIP2_SESENDEN | CFGCHIP2_VBDTCTEN |
27 CFGCHIP2_PHY_PLLON | CFGCHIP2_REFFREQ_24MHZ);
29 /* wait until the usb phy pll locks */
30 timeout = get_timer(0);
31 while (get_timer(timeout) < 10) {
32 if (readl(&davinci_syscfg_regs->cfgchip2) & CFGCHIP2_PHYCLKGD)
36 debug("Phy was not turned on\n");
41 static int da8xx_usb_phy_power_off(struct phy *phy)
43 clrsetbits_le32(&davinci_syscfg_regs->cfgchip2,
45 CFGCHIP2_PHYPWRDN | CFGCHIP2_OTGPWRDN);
50 static const struct udevice_id da8xx_phy_ids[] = {
51 { .compatible = "ti,da830-usb-phy" },
55 static struct phy_ops da8xx_phy_ops = {
56 .power_on = da8xx_usb_phy_power_on,
57 .power_off = da8xx_usb_phy_power_off,
60 U_BOOT_DRIVER(da8xx_phy) = {
61 .name = "da8xx-usb-phy",
63 .of_match = da8xx_phy_ids,
64 .ops = &da8xx_phy_ops,