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