1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28#include <asm/arch/pxa-regs.h>
29#include <common.h>
30
31DECLARE_GLOBAL_DATA_PTR;
32
33
34
35
36
37void set_led (int led, int color);
38void error_code_halt (int code);
39int init_sio (int led, unsigned long base);
40inline void cradle_outb (unsigned short val, unsigned long base,
41 unsigned long reg);
42inline unsigned char cradle_inb (unsigned long base, unsigned long reg);
43inline void sleep (int i);
44
45inline void
46
47sleep (int i)
48
49{
50 while (i--) {
51 udelay (1000000);
52 }
53}
54
55void
56
57error_code_halt (int code)
58
59{
60 while (1) {
61 led_code (code, RED);
62 sleep (1);
63 led_code (0, OFF);
64 sleep (1);
65 }
66}
67
68void
69
70led_code (int code, int color)
71
72{
73 int i;
74
75 code &= 0xf;
76
77 for (i = 0; i < 4; i++) {
78 if (code & (1 << i)) {
79 set_led (i, color);
80 } else {
81 set_led (i, OFF);
82 }
83 }
84}
85
86void
87
88set_led (int led, int color)
89
90{
91 int shift = led * 2;
92 unsigned long mask = 0x3 << shift;
93
94 CRADLE_LED_CLR_REG = mask;
95 CRADLE_LED_SET_REG = (color << shift);
96 udelay (5000);
97}
98
99inline void
100
101cradle_outb (unsigned short val, unsigned long base, unsigned long reg)
102
103{
104 *(volatile unsigned short *) (base + (reg * 2)) = val;
105}
106
107inline unsigned char
108
109cradle_inb (unsigned long base, unsigned long reg)
110
111{
112 unsigned short val;
113
114 val = *(volatile unsigned short *) (base + (reg * 2));
115 return (val & 0xff);
116}
117
118int
119
120init_sio (int led, unsigned long base)
121
122{
123 unsigned char val;
124
125 set_led (led, YELLOW);
126 val = cradle_inb (base, CRADLE_SIO_INDEX);
127 val = cradle_inb (base, CRADLE_SIO_INDEX);
128 if (val != 0) {
129 set_led (led, RED);
130 return -1;
131 }
132
133
134 cradle_outb (0x01, base, CRADLE_SIO_INDEX);
135 cradle_outb (0x00, base, CRADLE_SIO_DATA);
136
137
138 cradle_outb (0x40, base, CRADLE_SIO_INDEX);
139 cradle_outb (0xa0, base, CRADLE_SIO_DATA);
140
141
142 cradle_outb (0x51, base, CRADLE_SIO_INDEX);
143 cradle_outb (0x04, base, CRADLE_SIO_DATA);
144
145
146 cradle_outb (0x00, base, CRADLE_SIO_INDEX);
147 cradle_outb (0x04, base, CRADLE_SIO_DATA);
148
149
150 cradle_outb (0x4f, base, CRADLE_SIO_INDEX);
151 cradle_outb (0x09, base, CRADLE_SIO_DATA);
152
153
154 cradle_outb (0xe4, base, 0x3f8 + 0x3);
155 val = cradle_inb (base, 0x3f8 + 0x0);
156 if ((val & 0xf0) != 0x20) {
157 set_led (led, RED);
158
159 cradle_outb (0, base, CRADLE_SIO_INDEX);
160 cradle_outb (0, base, CRADLE_SIO_DATA);
161 return -1;
162 }
163
164 cradle_outb (0, base, 0x3f8 + 0x3);
165 set_led (led, GREEN);
166 return 0;
167}
168
169
170
171
172
173int
174
175board_late_init (void)
176
177{
178 return (0);
179}
180
181int
182
183board_init (void)
184
185{
186 led_code (0xf, YELLOW);
187
188
189 gd->bd->bi_arch_number = MACH_TYPE_HHP_CRADLE;
190
191
192 gd->bd->bi_boot_params = 0xa0000100;
193
194
195 udelay (100000);
196 init_sio (0, CRADLE_SIO1_PHYS);
197 udelay (100000);
198 init_sio (1, CRADLE_SIO2_PHYS);
199 udelay (100000);
200 init_sio (2, CRADLE_SIO3_PHYS);
201 udelay (100000);
202 set_led (3, GREEN);
203
204 return 1;
205}
206
207int
208
209dram_init (void)
210
211{
212 gd->bd->bi_dram[0].start = PHYS_SDRAM_1;
213 gd->bd->bi_dram[0].size = PHYS_SDRAM_1_SIZE;
214 gd->bd->bi_dram[1].start = PHYS_SDRAM_2;
215 gd->bd->bi_dram[1].size = PHYS_SDRAM_2_SIZE;
216 gd->bd->bi_dram[2].start = PHYS_SDRAM_3;
217 gd->bd->bi_dram[2].size = PHYS_SDRAM_3_SIZE;
218 gd->bd->bi_dram[3].start = PHYS_SDRAM_4;
219 gd->bd->bi_dram[3].size = PHYS_SDRAM_4_SIZE;
220
221 return (PHYS_SDRAM_1_SIZE +
222 PHYS_SDRAM_2_SIZE +
223 PHYS_SDRAM_3_SIZE +
224 PHYS_SDRAM_4_SIZE );
225}
226