blob: 5af6d28e74b67927e6bb9dffb0534886fb924ad0 [file] [log] [blame]
Tom Rini10e47792018-05-06 17:58:06 -04001// SPDX-License-Identifier: GPL-2.0+
Ilya Yanokcd3a8462012-11-06 13:48:27 +00002/*
3 * This file configures the internal USB PHY in AM35X.
4 *
5 * Copyright (C) 2012 Ilya Yanok <ilya.yanok@gmail.com>
6 *
7 * Based on omap_phy_internal.c code from Linux by
8 * Hema HK <hemahk@ti.com>
Ilya Yanokcd3a8462012-11-06 13:48:27 +00009 */
10
11#include <common.h>
12#include <asm/io.h>
13#include <asm/arch/am35x_def.h>
14
Mugunthan V N9224f612016-11-17 14:38:10 +053015void am35x_musb_reset(struct udevice *dev)
Ilya Yanokcd3a8462012-11-06 13:48:27 +000016{
17 /* Reset the musb interface */
18 clrsetbits_le32(&am35x_scm_general_regs->ip_sw_reset,
19 0, USBOTGSS_SW_RST);
20 clrsetbits_le32(&am35x_scm_general_regs->ip_sw_reset,
21 USBOTGSS_SW_RST, 0);
22}
23
Mugunthan V N9224f612016-11-17 14:38:10 +053024void am35x_musb_phy_power(struct udevice *dev, u8 on)
Ilya Yanokcd3a8462012-11-06 13:48:27 +000025{
26 unsigned long start = get_timer(0);
27
28 if (on) {
29 /*
30 * Start the on-chip PHY and its PLL.
31 */
32 clrsetbits_le32(&am35x_scm_general_regs->devconf2,
33 CONF2_RESET | CONF2_PHYPWRDN | CONF2_OTGPWRDN,
34 CONF2_PHY_PLLON);
35
36 debug("Waiting for PHY clock good...\n");
37 while (!(readl(&am35x_scm_general_regs->devconf2)
38 & CONF2_PHYCLKGD)) {
39
40 if (get_timer(start) > CONFIG_SYS_HZ / 10) {
41 printf("musb PHY clock good timed out\n");
42 break;
43 }
44 }
45 } else {
46 /*
47 * Power down the on-chip PHY.
48 */
49 clrsetbits_le32(&am35x_scm_general_regs->devconf2,
50 CONF2_PHY_PLLON,
51 CONF2_PHYPWRDN | CONF2_OTGPWRDN);
52 }
53}
54
Mugunthan V N9224f612016-11-17 14:38:10 +053055void am35x_musb_clear_irq(struct udevice *dev)
Ilya Yanokcd3a8462012-11-06 13:48:27 +000056{
57 clrsetbits_le32(&am35x_scm_general_regs->lvl_intr_clr,
58 0, USBOTGSS_INT_CLR);
59 readl(&am35x_scm_general_regs->lvl_intr_clr);
60}