/* U-Boot USB control interface */ int usb_lowlevel_init(int index, enum usb_init_type init, void **controller) { uint32_t snpsid; int i, j; root_hub_devnum = 0; snpsid = readl(®s->gsnpsid); printf("Core Release: %x.%03x\n", snpsid >> 12 & 0xf, snpsid & 0xfff); if ((snpsid & DWC2_SNPSID_DEVID_MASK) != DWC2_SNPSID_DEVID_VER_2xx && (snpsid & DWC2_SNPSID_DEVID_MASK) != DWC2_SNPSID_DEVID_VER_3xx) { printf("SNPSID invalid (not DWC2 OTG device): %08x\n", snpsid); return -ENODEV; } dwc_otg_core_init(regs); dwc_otg_core_host_init(regs); clrsetbits_le32(®s->hprt0, DWC2_HPRT0_PRTENA | DWC2_HPRT0_PRTCONNDET | DWC2_HPRT0_PRTENCHNG | DWC2_HPRT0_PRTOVRCURRCHNG, DWC2_HPRT0_PRTRST); mdelay(50); clrbits_le32(®s->hprt0, DWC2_HPRT0_PRTENA | DWC2_HPRT0_PRTCONNDET | DWC2_HPRT0_PRTENCHNG | DWC2_HPRT0_PRTOVRCURRCHNG | DWC2_HPRT0_PRTRST); for (i = 0; i < MAX_DEVICE; i++) { for (j = 0; j < MAX_ENDPOINT; j++) bulk_data_toggle[i][j] = DWC2_HC_PID_DATA0; } return 0; }
/* * U-Boot USB interface */ int usb_lowlevel_init(int index, void **controller) { /* * We need doubleword-aligned buffers for DMA transfers */ allocated_buffer = (uint8_t *)malloc(DWC_OTG_HCD_STATUS_BUF_SIZE + DWC_OTG_HCD_DATA_BUF_SIZE + 8); uint32_t addr = (uint32_t)allocated_buffer; aligned_buffer = (uint8_t *) ((addr + 7) & ~7); status_buffer = (uint8_t *)((uint32_t)aligned_buffer + DWC_OTG_HCD_DATA_BUF_SIZE); int i, j; hprt0_data_t hprt0 = {.d32 = 0 }; root_hub_devnum = 0; memset(&g_core_if, 0, sizeof(g_core_if)); dwc_otg_cil_init(&g_core_if, (uint32_t *)CONFIG_SYS_USB_ADDRESS); if ((g_core_if.snpsid & 0xFFFFF000) != 0x4F542000) { printf("SNPSID is invalid (not DWC OTG device): %08x\n", g_core_if.snpsid); return -1; } dwc_otg_core_init(&g_core_if); dwc_otg_core_host_init(&g_core_if); hprt0.d32 = dwc_otg_read_hprt0(&g_core_if); hprt0.b.prtrst = 1; dwc_write_reg32(g_core_if.host_if->hprt0, hprt0.d32); mdelay(50); hprt0.b.prtrst = 0; dwc_write_reg32(g_core_if.host_if->hprt0, hprt0.d32); for (i = 0; i < MAX_DEVICE; i++) { for (j = 0; j < MAX_ENDPOINT; j++) { control_data_toggle[i][j] = DWC_OTG_HC_PID_DATA1; bulk_data_toggle[i][j] = DWC_OTG_HC_PID_DATA0; } } return 0; } int usb_lowlevel_stop(int index) { free(allocated_buffer); return 0; }