From f1f5045b2e3c0ce6540abad3cad88f5e69a59a3c Mon Sep 17 00:00:00 2001 From: cinap_lenrek Date: Sun, 12 Jun 2022 14:31:55 +0000 Subject: [PATCH] imx8/usbxhci: bring usb out of reset do all the magic dwc3 specific initalization as well as reset the hub and power on the phys. with this, "usb start" command is not needed anymore from u-boot. --- sys/src/9/imx8/usbxhciimx.c | 104 ++++++++++++++++++++++++++++++++++++ 1 file changed, 104 insertions(+) diff --git a/sys/src/9/imx8/usbxhciimx.c b/sys/src/9/imx8/usbxhciimx.c index 6eebb3dfe..18b6efc00 100644 --- a/sys/src/9/imx8/usbxhciimx.c +++ b/sys/src/9/imx8/usbxhciimx.c @@ -1785,6 +1785,92 @@ clkenable(int i, int on) setclkgate(clk, on); } +static void +hubreset(int on) +{ + /* gpio registers */ + enum { + GPIO_DR = 0x00/4, + GPIO_GDIR = 0x04/4, + GPIO_PSR = 0x08/4, + GPIO_ICR1 = 0x0C/4, + GPIO_ICR2 = 0x10/4, + GPIO_IMR = 0x14/4, + GPIO_ISR = 0x18/4, + GPIO_EDGE_SEL = 0x1C/4, + }; + static u32int *gpio1 = (u32int*)(VIRTIO + 0x200000); + + gpio1[GPIO_GDIR] |= 1<<14; /* output */ + if(on) + gpio1[GPIO_DR] |= 1<<14; + else + gpio1[GPIO_DR] &= ~(1<<14); +} + +static void +powerup(int i) +{ + /* power gating controller registers */ + enum { + GPC_PGC_CPU_0_1_MAPPING = 0xEC/4, + GPC_PGC_PU_PGC_SW_PUP_REQ = 0xF8/4, + USB_OTG1_SW_PUP_REQ = 1<<2, + }; + static u32int *gpc = (u32int*)(VIRTIO + 0x3A0000); + + gpc[GPC_PGC_CPU_0_1_MAPPING] = 0x0000FFFF; + + gpc[GPC_PGC_PU_PGC_SW_PUP_REQ] |= (USB_OTG1_SW_PUP_REQ<mmio[0xF0040/4]); + coreinit(ctlr->mmio); hp->init = init; hp->dump = dump;