2018-05-06 21:58:06 +00:00
|
|
|
// SPDX-License-Identifier: GPL-2.0+
|
2012-11-06 13:48:27 +00:00
|
|
|
/*
|
|
|
|
* This file configures the internal USB PHY in AM35X.
|
|
|
|
*
|
|
|
|
* Copyright (C) 2012 Ilya Yanok <ilya.yanok@gmail.com>
|
|
|
|
*
|
|
|
|
* Based on omap_phy_internal.c code from Linux by
|
|
|
|
* Hema HK <hemahk@ti.com>
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <common.h>
|
2020-05-10 17:40:05 +00:00
|
|
|
#include <log.h>
|
2020-10-31 03:38:53 +00:00
|
|
|
#include <dm/device.h>
|
2012-11-06 13:48:27 +00:00
|
|
|
#include <asm/io.h>
|
|
|
|
#include <asm/arch/am35x_def.h>
|
|
|
|
|
2016-11-17 09:08:10 +00:00
|
|
|
void am35x_musb_reset(struct udevice *dev)
|
2012-11-06 13:48:27 +00:00
|
|
|
{
|
|
|
|
/* Reset the musb interface */
|
|
|
|
clrsetbits_le32(&am35x_scm_general_regs->ip_sw_reset,
|
|
|
|
0, USBOTGSS_SW_RST);
|
|
|
|
clrsetbits_le32(&am35x_scm_general_regs->ip_sw_reset,
|
|
|
|
USBOTGSS_SW_RST, 0);
|
|
|
|
}
|
|
|
|
|
2016-11-17 09:08:10 +00:00
|
|
|
void am35x_musb_phy_power(struct udevice *dev, u8 on)
|
2012-11-06 13:48:27 +00:00
|
|
|
{
|
|
|
|
unsigned long start = get_timer(0);
|
|
|
|
|
|
|
|
if (on) {
|
|
|
|
/*
|
|
|
|
* Start the on-chip PHY and its PLL.
|
|
|
|
*/
|
|
|
|
clrsetbits_le32(&am35x_scm_general_regs->devconf2,
|
|
|
|
CONF2_RESET | CONF2_PHYPWRDN | CONF2_OTGPWRDN,
|
|
|
|
CONF2_PHY_PLLON);
|
|
|
|
|
|
|
|
debug("Waiting for PHY clock good...\n");
|
|
|
|
while (!(readl(&am35x_scm_general_regs->devconf2)
|
|
|
|
& CONF2_PHYCLKGD)) {
|
|
|
|
|
|
|
|
if (get_timer(start) > CONFIG_SYS_HZ / 10) {
|
|
|
|
printf("musb PHY clock good timed out\n");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
/*
|
|
|
|
* Power down the on-chip PHY.
|
|
|
|
*/
|
|
|
|
clrsetbits_le32(&am35x_scm_general_regs->devconf2,
|
|
|
|
CONF2_PHY_PLLON,
|
|
|
|
CONF2_PHYPWRDN | CONF2_OTGPWRDN);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-11-17 09:08:10 +00:00
|
|
|
void am35x_musb_clear_irq(struct udevice *dev)
|
2012-11-06 13:48:27 +00:00
|
|
|
{
|
|
|
|
clrsetbits_le32(&am35x_scm_general_regs->lvl_intr_clr,
|
|
|
|
0, USBOTGSS_INT_CLR);
|
|
|
|
readl(&am35x_scm_general_regs->lvl_intr_clr);
|
|
|
|
}
|