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>
11 #include <dm/device-internal.h>
13 #include <asm/arch/hardware.h>
14 #include <asm/arch/da8xx-usb.h>
16 #include <generic-phy.h>
18 static int da8xx_usb_phy_power_on(struct phy *phy)
20 unsigned long timeout;
22 clrsetbits_le32(&davinci_syscfg_regs->cfgchip2,
23 CFGCHIP2_RESET | CFGCHIP2_PHYPWRDN | CFGCHIP2_OTGPWRDN |
24 CFGCHIP2_OTGMODE | CFGCHIP2_REFFREQ,
25 CFGCHIP2_SESENDEN | CFGCHIP2_VBDTCTEN |
26 CFGCHIP2_PHY_PLLON | CFGCHIP2_REFFREQ_24MHZ);
28 /* wait until the usb phy pll locks */
29 timeout = get_timer(0);
30 while (get_timer(timeout) < 10) {
31 if (readl(&davinci_syscfg_regs->cfgchip2) & CFGCHIP2_PHYCLKGD)
35 debug("Phy was not turned on\n");
40 static int da8xx_usb_phy_power_off(struct phy *phy)
42 clrsetbits_le32(&davinci_syscfg_regs->cfgchip2,
44 CFGCHIP2_PHYPWRDN | CFGCHIP2_OTGPWRDN);
49 static const struct udevice_id da8xx_phy_ids[] = {
50 { .compatible = "ti,da830-usb-phy" },
54 static struct phy_ops da8xx_phy_ops = {
55 .power_on = da8xx_usb_phy_power_on,
56 .power_off = da8xx_usb_phy_power_off,
59 U_BOOT_DRIVER(da8xx_phy) = {
60 .name = "da8xx-usb-phy",
62 .of_match = da8xx_phy_ids,
63 .ops = &da8xx_phy_ops,