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

MLK-17210 usb: imx8m: Add PU power on/off to USB


ATF will power off all PUs at default, so for USB, we enable
its PU power for both host and device modes in board_usb_init and
disable the power when usb is stop in board_usb_cleanup.

Signed-off-by: default avatarYe Li <ye.li@nxp.com>
Reviewed-by: default avatarLi Jun <jun.li@nxp.com>
parent 093dfc8f
No related branches found
No related tags found
No related merge requests found
...@@ -224,3 +224,22 @@ void reset_cpu(ulong addr) ...@@ -224,3 +224,22 @@ void reset_cpu(ulong addr)
*/ */
} }
} }
#ifdef CONFIG_USB_XHCI_IMX8M
#define FSL_SIP_GPC 0xC2000000
#define FSL_SIP_CONFIG_GPC_PM_DOMAIN 0x03
int imx8m_usb_power(int usb_id, bool on)
{
unsigned long ret;
if (usb_id > 1)
return -EINVAL;
ret = call_imx_sip(FSL_SIP_GPC,
FSL_SIP_CONFIG_GPC_PM_DOMAIN, 2 + usb_id, on, 0);
if (ret)
return -EPERM;
return 0;
}
#endif
...@@ -42,8 +42,14 @@ struct imx8m_xhci { ...@@ -42,8 +42,14 @@ struct imx8m_xhci {
struct imx8m_usbmix *usbmix_reg; struct imx8m_usbmix *usbmix_reg;
}; };
struct imx8m_usbctrl_data {
u32 usb_id;
unsigned long ctr_addr;
};
static struct imx8m_xhci imx8m_xhci; static struct imx8m_xhci imx8m_xhci;
unsigned long ctr_addr[] = {USB2_BASE_ADDR}; static struct imx8m_usbctrl_data ctr_data[] = {
{1, USB2_BASE_ADDR},
};
static void imx8m_usb_phy_init(struct imx8m_usbmix *usbmix_reg) static void imx8m_usb_phy_init(struct imx8m_usbmix *usbmix_reg)
{ {
...@@ -107,13 +113,14 @@ int xhci_hcd_init(int index, struct xhci_hccr **hccr, struct xhci_hcor **hcor) ...@@ -107,13 +113,14 @@ int xhci_hcd_init(int index, struct xhci_hccr **hccr, struct xhci_hcor **hcor)
struct imx8m_xhci *ctx = &imx8m_xhci; struct imx8m_xhci *ctx = &imx8m_xhci;
int ret = 0; int ret = 0;
ctx->hcd = (struct xhci_hccr *)ctr_addr[index]; ctx->hcd = (struct xhci_hccr *)(ctr_data[index].ctr_addr);
ctx->dwc3_reg = (struct dwc3 *)((char *)(ctx->hcd) + DWC3_REG_OFFSET); ctx->dwc3_reg = (struct dwc3 *)((char *)(ctx->hcd) + DWC3_REG_OFFSET);
ctx->usbmix_reg = (struct imx8m_usbmix *)((char *)(ctx->hcd) + ctx->usbmix_reg = (struct imx8m_usbmix *)((char *)(ctx->hcd) +
USBMIX_PHY_OFFSET); USBMIX_PHY_OFFSET);
ret = board_usb_init(index, USB_INIT_HOST); ret = board_usb_init(ctr_data[index].usb_id, USB_INIT_HOST);
if (ret != 0) { if (ret != 0) {
imx8m_usb_power(ctr_data[index].usb_id, false);
puts("Failed to initialize board for imx8m USB\n"); puts("Failed to initialize board for imx8m USB\n");
return ret; return ret;
} }
...@@ -137,4 +144,5 @@ int xhci_hcd_init(int index, struct xhci_hccr **hccr, struct xhci_hcor **hcor) ...@@ -137,4 +144,5 @@ int xhci_hcd_init(int index, struct xhci_hccr **hccr, struct xhci_hcor **hcor)
void xhci_hcd_stop(int index) void xhci_hcd_stop(int index)
{ {
board_usb_cleanup(ctr_data[index].usb_id, USB_INIT_HOST);
} }
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