1
2
3
4
5
6
7
8
9#include <common.h>
10#include <libfdt.h>
11#include <fdt_support.h>
12#include <spd_sdram.h>
13#include <asm/ppc4xx-emac.h>
14#include <miiphy.h>
15#include <asm/processor.h>
16#include <asm/4xx_pci.h>
17
18DECLARE_GLOBAL_DATA_PTR;
19
20extern int alpr_fpga_init(void);
21
22int board_early_init_f (void)
23{
24
25
26
27 mtebc(EBC0_CFG, EBC_CFG_LE_UNLOCK |
28 EBC_CFG_PTD_DISABLE | EBC_CFG_RTC_64PERCLK |
29 EBC_CFG_ATC_PREVIOUS | EBC_CFG_DTC_PREVIOUS |
30 EBC_CFG_CTC_PREVIOUS | EBC_CFG_EMC_NONDEFAULT |
31 EBC_CFG_PME_DISABLE | EBC_CFG_PR_32);
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48 mtdcr (UIC1SR, 0xffffffff);
49 mtdcr (UIC1ER, 0x00000000);
50 mtdcr (UIC1CR, 0x00000009);
51 mtdcr (UIC1PR, 0xfffffe03);
52 mtdcr (UIC1TR, 0x01c00000);
53 mtdcr (UIC1VR, 0x00000001);
54 mtdcr (UIC1SR, 0xffffffff);
55
56 mtdcr (UIC2SR, 0xffffffff);
57 mtdcr (UIC2ER, 0x00000000);
58 mtdcr (UIC2CR, 0x00000000);
59 mtdcr (UIC2PR, 0xffffe0ff);
60 mtdcr (UIC2TR, 0x00ffc000);
61 mtdcr (UIC2VR, 0x00000001);
62 mtdcr (UIC2SR, 0xffffffff);
63
64 mtdcr (UIC3SR, 0xffffffff);
65 mtdcr (UIC3ER, 0x00000000);
66 mtdcr (UIC3CR, 0x00000000);
67 mtdcr (UIC3PR, 0xffffffff);
68 mtdcr (UIC3TR, 0x00ff8c0f);
69 mtdcr (UIC3VR, 0x00000001);
70 mtdcr (UIC3SR, 0xffffffff);
71
72 mtdcr (UIC0SR, 0xfc000000);
73 mtdcr (UIC0ER, 0x00000000);
74 mtdcr (UIC0CR, 0x00000000);
75 mtdcr (UIC0PR, 0xfc000000);
76 mtdcr (UIC0TR, 0x00000000);
77 mtdcr (UIC0VR, 0x00000001);
78
79
80 out32(GPIO0_TCR, in32(GPIO0_TCR) & ~(CONFIG_SYS_GPIO_SHUTDOWN | CONFIG_SYS_GPIO_SSD_EMPTY));
81 out32(GPIO0_ODR, in32(GPIO0_ODR) & ~(CONFIG_SYS_GPIO_SHUTDOWN | CONFIG_SYS_GPIO_SSD_EMPTY));
82
83
84 mtsdr(SDR0_PFC0, 0x01a33e00);
85
86 return 0;
87}
88
89int last_stage_init(void)
90{
91 unsigned short reg;
92
93
94
95
96
97
98
99 miiphy_read("ppc_4xx_eth2", CONFIG_PHY2_ADDR, 0x18, ®);
100 reg |= 0x0001;
101 miiphy_write("ppc_4xx_eth2", CONFIG_PHY2_ADDR, 0x18, reg);
102 miiphy_read("ppc_4xx_eth3", CONFIG_PHY3_ADDR, 0x18, ®);
103 reg |= 0x0001;
104 miiphy_write("ppc_4xx_eth3", CONFIG_PHY3_ADDR, 0x18, reg);
105
106 return 0;
107}
108
109static int board_rev(void)
110{
111
112 out32(GPIO0_TCR, in32(GPIO0_TCR) & ~(CONFIG_SYS_GPIO_REV0 | CONFIG_SYS_GPIO_REV1));
113 out32(GPIO0_ODR, in32(GPIO0_ODR) & ~(CONFIG_SYS_GPIO_REV0 | CONFIG_SYS_GPIO_REV1));
114
115 return (in32(GPIO0_IR) >> 16) & 0x3;
116}
117
118int checkboard (void)
119{
120 char buf[64];
121 int i = getenv_f("serial#", buf, sizeof(buf));
122
123 printf ("Board: ALPR");
124 if (i > 0) {
125 puts(", serial# ");
126 puts(buf);
127 }
128 printf(" (Rev. %d)\n", board_rev());
129
130 return (0);
131}
132
133#if defined(CONFIG_PCI)
134
135
136
137int pci_pre_init(struct pci_controller *hose)
138{
139 if (__pci_pre_init(hose) == 0)
140 return 0;
141
142
143 alpr_fpga_init();
144
145 return 1;
146}
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163static void wait_for_pci_ready(void)
164{
165
166
167
168 out32(GPIO0_TCR, in32(GPIO0_TCR) & ~CONFIG_SYS_GPIO_EREADY);
169 udelay(1000);
170
171 for (;;) {
172 if (in32(GPIO0_IR) & CONFIG_SYS_GPIO_EREADY)
173 return;
174 }
175
176}
177
178int is_pci_host(struct pci_controller *hose)
179{
180 wait_for_pci_ready();
181 return 1;
182}
183#endif
184
185
186
187
188
189#if defined(CONFIG_PCI) && defined(CONFIG_SYS_PCI_MASTER_INIT)
190void pci_master_init(struct pci_controller *hose)
191{
192
193
194
195
196
197
198
199 out32r( PCIL0_POM0SA, 0 );
200 out32r( PCIL0_POM1SA, 0 );
201 out32r( PCIL0_POM2SA, 0 );
202
203 out32r(PCIL0_POM0LAL, CONFIG_SYS_PCI_MEMBASE);
204 out32r(PCIL0_POM0LAH, 0x00000003);
205 out32r(PCIL0_POM0PCIAL, CONFIG_SYS_PCI_MEMBASE);
206 out32r(PCIL0_POM0PCIAH, 0x00000000);
207 out32r(PCIL0_POM0SA, ~(0x10000000 - 1) | 1);
208
209 out32r(PCIL0_POM1LAL, CONFIG_SYS_PCI_MEMBASE2);
210 out32r(PCIL0_POM1LAH, 0x00000003);
211 out32r(PCIL0_POM1PCIAL, CONFIG_SYS_PCI_MEMBASE2);
212 out32r(PCIL0_POM1PCIAH, 0x00000000);
213 out32r(PCIL0_POM1SA, ~(0x10000000 - 1) | 1);
214}
215#endif
216