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
29#include <common.h>
30#include <mpc5xxx.h>
31#include <miiphy.h>
32#include <libfdt.h>
33
34#if defined(CONFIG_STATUS_LED)
35#include <status_led.h>
36#endif
37
38
39struct init_elem {
40 unsigned long addr;
41 unsigned len;
42 char *data;
43 } init_seq[] = {
44 {0x500003F2, 2, "\x86\x00"},
45 {0x500003F0, 2, "\x00\x00"},
46 {0x500003EC, 4, "\x00\x80\xc1\x52"},
47 };
48
49
50
51
52static void kollmorgen_init(void)
53{
54 unsigned i, j;
55 vu_char *p;
56
57 for (i = 0; i < sizeof(init_seq) / sizeof(struct init_elem); ++i) {
58 p = (vu_char *)init_seq[i].addr;
59 for (j = 0; j < init_seq[i].len; ++j)
60 *(p + j) = *(init_seq[i].data + j);
61 }
62
63 printf("DPR: Kollmorgen DPR initialized\n");
64}
65
66
67
68
69
70int board_early_init_r(void)
71{
72
73 *(vu_long *)MPC5XXX_ADDECR &= ~(1 << 25);
74 *(vu_long *)MPC5XXX_ADDECR |= (1 << 16);
75
76
77 kollmorgen_init();
78
79 return 0;
80}
81
82
83
84
85
86
87
88
89void reset_phy(void)
90{
91 unsigned short mode_control;
92
93 miiphy_read("FEC", CONFIG_PHY_ADDR, 0x15, &mode_control);
94 miiphy_write("FEC", CONFIG_PHY_ADDR, 0x15,
95 mode_control & 0xfffe);
96 return;
97}
98
99#ifndef CONFIG_SYS_RAMBOOT
100
101
102
103static void sdram_start(int hi_addr)
104{
105 long hi_addr_bit = hi_addr ? 0x01000000 : 0;
106
107
108 *(vu_long *)MPC5XXX_SDRAM_CTRL = SDRAM_CONTROL | 0x80000000 |
109 hi_addr_bit;
110
111
112 *(vu_long *)MPC5XXX_SDRAM_CTRL = SDRAM_CONTROL | 0x80000002 |
113 hi_addr_bit;
114
115
116 *(vu_long *)MPC5XXX_SDRAM_CTRL = SDRAM_CONTROL | 0x80000004 |
117 hi_addr_bit;
118
119
120 *(vu_long *)MPC5XXX_SDRAM_CTRL = SDRAM_CONTROL | 0x80000004 |
121 hi_addr_bit;
122
123
124 *(vu_long *)MPC5XXX_SDRAM_MODE = SDRAM_MODE;
125
126
127 *(vu_long *)MPC5XXX_SDRAM_CTRL = SDRAM_CONTROL | hi_addr_bit;
128}
129#endif
130
131
132
133
134
135phys_size_t initdram(int board_type)
136{
137 ulong dramsize = 0;
138#ifndef CONFIG_SYS_RAMBOOT
139 ulong test1, test2;
140
141
142
143
144
145 *(vu_long *)MPC5XXX_SDRAM_SDELAY = 0x04;
146
147
148 *(vu_long *)MPC5XXX_SDRAM_CS0CFG = 0x0000001e;
149 *(vu_long *)MPC5XXX_SDRAM_CS1CFG = 0x80000000;
150
151
152 *(vu_long *)MPC5XXX_SDRAM_CONFIG1 = SDRAM_CONFIG1;
153 *(vu_long *)MPC5XXX_SDRAM_CONFIG2 = SDRAM_CONFIG2;
154
155 sdram_start(0);
156 test1 = get_ram_size((long *)CONFIG_SYS_SDRAM_BASE, 0x80000000);
157 sdram_start(1);
158 test2 = get_ram_size((long *)CONFIG_SYS_SDRAM_BASE, 0x80000000);
159 if (test1 > test2) {
160 sdram_start(0);
161 dramsize = test1;
162 } else {
163 dramsize = test2;
164 }
165
166
167 if (dramsize < (1 << 20))
168 dramsize = 0;
169
170
171 if (dramsize > 0) {
172 *(vu_long *)MPC5XXX_SDRAM_CS0CFG = 0x13 +
173 __builtin_ffs(dramsize >> 20) - 1;
174 } else {
175 *(vu_long *)MPC5XXX_SDRAM_CS0CFG = 0;
176 }
177
178
179 *(vu_long *) MPC5XXX_SDRAM_CS1CFG = dramsize;
180
181#else
182
183 dramsize = *(vu_long *)MPC5XXX_SDRAM_CS0CFG & 0xFF;
184 if (dramsize >= 0x13)
185 dramsize = (1 << (dramsize - 0x13)) << 20;
186 else
187 dramsize = 0;
188#endif
189
190
191 return dramsize;
192}
193
194
195int checkboard(void)
196{
197 uchar rev = *(vu_char *)CPLD_REV_REGISTER;
198 printf("Board: Promess Motion-PRO board (CPLD rev. 0x%02x)\n", rev);
199 return 0;
200}
201
202
203#if defined(CONFIG_OF_LIBFDT) && defined(CONFIG_OF_BOARD_SETUP)
204void ft_board_setup(void *blob, bd_t *bd)
205{
206 ft_cpu_setup(blob, bd);
207}
208#endif
209
210
211#if defined(CONFIG_STATUS_LED)
212void __led_init(led_id_t regaddr, int state)
213{
214 *((vu_long *) regaddr) |= ENABLE_GPIO_OUT;
215
216 if (state == STATUS_LED_ON)
217 *((vu_long *) regaddr) |= LED_ON;
218 else
219 *((vu_long *) regaddr) &= ~LED_ON;
220}
221
222void __led_set(led_id_t regaddr, int state)
223{
224 if (state == STATUS_LED_ON)
225 *((vu_long *) regaddr) |= LED_ON;
226 else
227 *((vu_long *) regaddr) &= ~LED_ON;
228}
229
230void __led_toggle(led_id_t regaddr)
231{
232 *((vu_long *) regaddr) ^= LED_ON;
233}
234#endif
235