1
2
3
4
5
6
7
8
9
10#include <common.h>
11
12#include "vct.h"
13
14int vct_ehci_hcd_init(u32 *hccr, u32 *hcor)
15{
16 int retval;
17 u32 val;
18 u32 addr;
19
20 dcgu_set_reset_switch(DCGU_HW_MODULE_USB_24, DCGU_SWITCH_ON);
21 dcgu_set_reset_switch(DCGU_HW_MODULE_USB_60, DCGU_SWITCH_ON);
22 dcgu_set_clk_switch(DCGU_HW_MODULE_USB_24, DCGU_SWITCH_ON);
23 dcgu_set_clk_switch(DCGU_HW_MODULE_USB_PLL, DCGU_SWITCH_ON);
24 dcgu_set_reset_switch(DCGU_HW_MODULE_USB_24, DCGU_SWITCH_OFF);
25
26
27 addr = DCGU_USBPHY_STAT(DCGU_BASE);
28 val = reg_read(addr);
29 while (val != 7)
30 val = reg_read(addr);
31
32 dcgu_set_clk_switch(DCGU_HW_MODULE_USB_60, DCGU_SWITCH_ON);
33 dcgu_set_reset_switch(DCGU_HW_MODULE_USB_60, DCGU_SWITCH_OFF);
34
35 retval = scc_reset(SCC_USB_RW, 0);
36 if (retval) {
37 printf("scc_reset(SCC_USB_RW, 0) returned: 0x%x\n", retval);
38 return retval;
39 } else {
40 retval = scc_reset(SCC_CPU1_SPDMA_RW, 0);
41 if (retval) {
42 printf("scc_reset(SCC_CPU1_SPDMA_RW, 0) returned: 0x%x\n",
43 retval);
44 return retval;
45 }
46 }
47
48 if (!retval) {
49
50
51
52
53 scc_set_usb_address_generation_mode(1);
54 scc_setup_dma(SCC_USB_RW, BCU_USB_BUFFER_1, DMA_LINEAR,
55 USE_NO_FH, DMA_READ, 0);
56 scc_setup_dma(SCC_CPU1_SPDMA_RW, BCU_USB_BUFFER_1, DMA_LINEAR,
57 USE_NO_FH, DMA_WRITE, 0);
58 scc_setup_dma(SCC_USB_RW, BCU_USB_BUFFER_0, DMA_LINEAR,
59 USE_NO_FH, DMA_WRITE, 0);
60 scc_setup_dma(SCC_CPU1_SPDMA_RW, BCU_USB_BUFFER_0, DMA_LINEAR,
61 USE_NO_FH, DMA_READ, 0);
62
63
64 scc_enable(SCC_USB_RW, 1);
65
66
67 scc_dma_cmd(SCC_USB_RW, DMA_START, 0, DMA_READ);
68 scc_dma_cmd(SCC_USB_RW, DMA_START, 0, DMA_WRITE);
69 } else {
70 printf("Cannot configure USB memory channel.\n");
71 printf("USB can not access RAM. SCC configuration failed.\n");
72 return retval;
73 }
74
75
76 udelay(300000);
77
78 reg_write(USBH_BURSTSIZE(USBH_BASE), 0x00001c1c);
79
80
81 reg_write(USBH_USBHMISC(USBH_BASE), 0x00840003);
82
83 reg_write(USBH_USBMODE(USBH_BASE), 0x00000007);
84
85
86
87
88
89
90 reg_write(USBH_BURSTSIZE(USBH_BASE), 0x00001c1c);
91
92
93 *hccr = REG_GLOBAL_START_ADDR + USBH_CAPLENGTH(USBH_BASE);
94 *hcor = REG_GLOBAL_START_ADDR + USBH_USBCMD(USBH_BASE);
95
96 return 0;
97}
98