Skip to content
Snippets Groups Projects
Commit dca47f04 authored by Ye Li's avatar Ye Li Committed by Troy Kisky
Browse files

MLK-13450-15 ehci-mx6: Add powerup_fixup implementation


When doing port reset, the PR bit of PORTSC1 will be automatically
cleared by our IP, but standard EHCI needs explicit clear by software. The
EHCI-HCD driver follow the EHCI specification, so after 50ms wait, it
clear the PR bit by writting to the PORTSC1 register with value loaded before
setting PR.

This sequence is ok for our IP when the delay time is exact. But when the timer
is slower, some bits like PE, PSPD have been set by controller automatically
after the PR is automatically cleared. So the writing to the PORTSC1 will overwrite
these bits set by controller. And eventually the driver gets wrong status.

We implement the powerup_fixup operation which delays 50ms and will check
the PR until it is cleared by controller. And will update the reg value which is written
to PORTSC register by EHCI-HCD driver. This is much safer than depending on the delay
time to be accurate and aligining with controller's behaiver.

Signed-off-by: default avatarYe Li <ye.li@nxp.com>
(cherry picked from commit 8dfdf83abaff44efb487f801cd1757a729d427c5)
parent db346211
No related branches found
No related tags found
No related merge requests found
......@@ -265,6 +265,25 @@ int usb_phy_mode(int port)
}
#endif
static void ehci_mx6_powerup_fixup(struct ehci_ctrl *ctrl, uint32_t *status_reg,
uint32_t *reg)
{
uint32_t result;
int usec = 2000;
mdelay(50);
do {
result = ehci_readl(status_reg);
udelay(5);
if (!(result & EHCI_PS_PR))
break;
usec--;
} while (usec > 0);
*reg = ehci_readl(status_reg);
}
static void usb_oc_config(int index)
{
#if defined(CONFIG_MX6)
......@@ -364,6 +383,10 @@ int ehci_mx6_common_init(struct usb_ehci *ehci, int index)
}
#ifndef CONFIG_DM_USB
static const struct ehci_ops mx6_ehci_ops = {
.powerup_fixup = ehci_mx6_powerup_fixup,
};
int ehci_hcd_init(int index, enum usb_init_type init,
struct ehci_hccr **hccr, struct ehci_hcor **hcor)
{
......@@ -391,6 +414,8 @@ int ehci_hcd_init(int index, enum usb_init_type init,
if (ret)
return ret;
ehci_set_controller_priv(index, NULL, &mx6_ehci_ops);
type = board_usb_phy_mode(index);
if (hccr && hcor) {
......@@ -462,7 +487,8 @@ static int mx6_init_after_reset(struct ehci_ctrl *dev)
}
static const struct ehci_ops mx6_ehci_ops = {
.init_after_reset = mx6_init_after_reset
.powerup_fixup = ehci_mx6_powerup_fixup,
.init_after_reset = mx6_init_after_reset
};
static int ehci_usb_phy_mode(struct udevice *dev)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment