]>
Commit | Line | Data |
---|---|---|
83d290c5 | 1 | // SPDX-License-Identifier: GPL-2.0+ |
9acb626f | 2 | /* |
35cf3b57 | 3 | * (C) Copyright 2005-2009 |
9acb626f HS |
4 | * BuS Elektronik GmbH & Co.KG <[email protected]> |
5 | * | |
6 | * (C) Copyright 2000-2003 | |
7 | * Wolfgang Denk, DENX Software Engineering, [email protected]. | |
9acb626f HS |
8 | */ |
9 | ||
10 | #include <common.h> | |
11 | #include <command.h> | |
401d1c4f | 12 | #include <asm/global_data.h> |
9acb626f | 13 | #include "asm/m5282.h" |
35cf3b57 | 14 | #include <bmp_layout.h> |
7b51b576 | 15 | #include <env.h> |
49acd56e | 16 | #include <init.h> |
35cf3b57 JS |
17 | #include <status_led.h> |
18 | #include <bus_vcxk.h> | |
19 | ||
20 | /*---------------------------------------------------------------------------*/ | |
21 | ||
22 | DECLARE_GLOBAL_DATA_PTR; | |
23 | ||
8c9940d5 | 24 | #if IS_ENABLED(CONFIG_VIDEO_VCXK) |
265724cb TR |
25 | extern unsigned long display_width; |
26 | extern unsigned long display_height; | |
d858c335 | 27 | #endif |
35cf3b57 JS |
28 | |
29 | /*---------------------------------------------------------------------------*/ | |
9acb626f HS |
30 | |
31 | int checkboard (void) | |
32 | { | |
d858c335 | 33 | puts("Board: EB+CPU5282 (BuS Elektronik GmbH & Co. KG)\n"); |
14d0a02a | 34 | #if (CONFIG_SYS_TEXT_BASE == CONFIG_SYS_INT_FLASH_BASE) |
d858c335 | 35 | puts(" Boot from Internal FLASH\n"); |
9acb626f | 36 | #endif |
9acb626f HS |
37 | return 0; |
38 | } | |
39 | ||
f1683aa7 | 40 | int dram_init(void) |
9acb626f | 41 | { |
0fe34058 | 42 | int size, i; |
9acb626f HS |
43 | |
44 | size = 0; | |
d858c335 JSBE |
45 | MCFSDRAMC_DCR = MCFSDRAMC_DCR_RTIM_6 | |
46 | MCFSDRAMC_DCR_RC((15 * CONFIG_SYS_CLK / 1000000) >> 4); | |
47 | asm (" nop"); | |
6d0f6bcf | 48 | #ifdef CONFIG_SYS_SDRAM_BASE0 |
d858c335 JSBE |
49 | MCFSDRAMC_DACR0 = MCFSDRAMC_DACR_BASE(CONFIG_SYS_SDRAM_BASE0)| |
50 | MCFSDRAMC_DACR_CASL(1) | MCFSDRAMC_DACR_CBM(3) | | |
51 | MCFSDRAMC_DACR_PS_32; | |
52 | asm (" nop"); | |
0fe34058 WD |
53 | |
54 | MCFSDRAMC_DMR0 = MCFSDRAMC_DMR_BAM_16M | MCFSDRAMC_DMR_V; | |
d858c335 | 55 | asm (" nop"); |
0fe34058 WD |
56 | |
57 | MCFSDRAMC_DACR0 |= MCFSDRAMC_DACR_IP; | |
d858c335 JSBE |
58 | asm (" nop"); |
59 | for (i = 0; i < 10; i++) | |
60 | asm (" nop"); | |
0fe34058 | 61 | |
d858c335 JSBE |
62 | *(unsigned long *)(CONFIG_SYS_SDRAM_BASE0) = 0xA5A5A5A5; |
63 | asm (" nop"); | |
0fe34058 | 64 | MCFSDRAMC_DACR0 |= MCFSDRAMC_DACR_RE; |
d858c335 JSBE |
65 | asm (" nop"); |
66 | ||
0fe34058 WD |
67 | for (i = 0; i < 2000; i++) |
68 | asm (" nop"); | |
d858c335 JSBE |
69 | |
70 | MCFSDRAMC_DACR0 |= MCFSDRAMC_DACR_IMRS; | |
71 | asm (" nop"); | |
72 | /* write SDRAM mode register */ | |
73 | *(unsigned long *)(CONFIG_SYS_SDRAM_BASE0 + 0x80440) = 0xA5A5A5A5; | |
74 | asm (" nop"); | |
75 | size += CONFIG_SYS_SDRAM_SIZE0 * 1024 * 1024; | |
0fe34058 | 76 | #endif |
d858c335 | 77 | #ifdef CONFIG_SYS_SDRAM_BASE1xx |
6d0f6bcf | 78 | MCFSDRAMC_DACR1 = MCFSDRAMC_DACR_BASE (CONFIG_SYS_SDRAM_BASE1) |
0fe34058 WD |
79 | | MCFSDRAMC_DACR_CASL (1) |
80 | | MCFSDRAMC_DACR_CBM (3) | |
81 | | MCFSDRAMC_DACR_PS_16; | |
82 | ||
83 | MCFSDRAMC_DMR1 = MCFSDRAMC_DMR_BAM_16M | MCFSDRAMC_DMR_V; | |
84 | ||
85 | MCFSDRAMC_DACR1 |= MCFSDRAMC_DACR_IP; | |
86 | ||
6d0f6bcf | 87 | *(unsigned short *) (CONFIG_SYS_SDRAM_BASE1) = 0xA5A5; |
0fe34058 WD |
88 | MCFSDRAMC_DACR1 |= MCFSDRAMC_DACR_RE; |
89 | ||
90 | for (i = 0; i < 2000; i++) | |
91 | asm (" nop"); | |
92 | ||
93 | MCFSDRAMC_DACR1 |= MCFSDRAMC_DACR_IMRS; | |
6d0f6bcf JCPV |
94 | *(unsigned int *) (CONFIG_SYS_SDRAM_BASE1 + 0x220) = 0xA5A5; |
95 | size += CONFIG_SYS_SDRAM_SIZE1 * 1024 * 1024; | |
0fe34058 | 96 | #endif |
088454cd SG |
97 | gd->ram_size = size; |
98 | ||
99 | return 0; | |
9acb626f HS |
100 | } |
101 | ||
6d0f6bcf | 102 | #if defined(CONFIG_SYS_DRAM_TEST) |
49acd56e | 103 | int testdram(void) |
9acb626f | 104 | { |
6d0f6bcf JCPV |
105 | uint *pstart = (uint *) CONFIG_SYS_MEMTEST_START; |
106 | uint *pend = (uint *) CONFIG_SYS_MEMTEST_END; | |
9acb626f HS |
107 | uint *p; |
108 | ||
109 | printf("SDRAM test phase 1:\n"); | |
110 | for (p = pstart; p < pend; p++) | |
111 | *p = 0xaaaaaaaa; | |
112 | ||
113 | for (p = pstart; p < pend; p++) { | |
114 | if (*p != 0xaaaaaaaa) { | |
115 | printf ("SDRAM test fails at: %08x\n", (uint) p); | |
116 | return 1; | |
117 | } | |
118 | } | |
119 | ||
120 | printf("SDRAM test phase 2:\n"); | |
121 | for (p = pstart; p < pend; p++) | |
122 | *p = 0x55555555; | |
123 | ||
124 | for (p = pstart; p < pend; p++) { | |
125 | if (*p != 0x55555555) { | |
126 | printf ("SDRAM test fails at: %08x\n", (uint) p); | |
127 | return 1; | |
128 | } | |
129 | } | |
130 | ||
131 | printf("SDRAM test passed.\n"); | |
132 | return 0; | |
133 | } | |
134 | #endif | |
135 | ||
d858c335 JSBE |
136 | #if defined(CONFIG_HW_WATCHDOG) |
137 | ||
138 | void hw_watchdog_init(void) | |
139 | { | |
140 | char *s; | |
141 | int enable; | |
142 | ||
143 | enable = 1; | |
00caae6d | 144 | s = env_get("watchdog"); |
d858c335 JSBE |
145 | if (s != NULL) |
146 | if ((strncmp(s, "off", 3) == 0) || (strncmp(s, "0", 1) == 0)) | |
147 | enable = 0; | |
148 | if (enable) | |
149 | MCFGPTA_GPTDDR |= (1<<2); | |
150 | else | |
151 | MCFGPTA_GPTDDR &= ~(1<<2); | |
152 | } | |
153 | ||
154 | void hw_watchdog_reset(void) | |
155 | { | |
156 | MCFGPTA_GPTPORT ^= (1<<2); | |
157 | } | |
158 | #endif | |
159 | ||
9acb626f HS |
160 | int misc_init_r(void) |
161 | { | |
35cf3b57 JS |
162 | #ifdef CONFIG_HW_WATCHDOG |
163 | hw_watchdog_init(); | |
35cf3b57 | 164 | #endif |
9acb626f HS |
165 | return 1; |
166 | } | |
167 | ||
d858c335 JSBE |
168 | void __led_toggle(led_id_t mask) |
169 | { | |
170 | MCFGPTA_GPTPORT ^= (1 << 3); | |
171 | } | |
35cf3b57 | 172 | |
d858c335 JSBE |
173 | void __led_init(led_id_t mask, int state) |
174 | { | |
175 | __led_set(mask, state); | |
176 | MCFGPTA_GPTDDR |= (1 << 3); | |
177 | } | |
178 | ||
179 | void __led_set(led_id_t mask, int state) | |
180 | { | |
2d8d190c | 181 | if (state == CONFIG_LED_STATUS_ON) |
d858c335 JSBE |
182 | MCFGPTA_GPTPORT |= (1 << 3); |
183 | else | |
184 | MCFGPTA_GPTPORT &= ~(1 << 3); | |
185 | } | |
186 | ||
8c9940d5 | 187 | #if IS_ENABLED(CONFIG_VIDEO_VCXK) |
35cf3b57 JS |
188 | int drv_video_init(void) |
189 | { | |
190 | char *s; | |
d858c335 | 191 | #ifdef CONFIG_SPLASH_SCREEN |
35cf3b57 | 192 | unsigned long splash; |
d858c335 | 193 | #endif |
35cf3b57 | 194 | printf("Init Video as "); |
00caae6d | 195 | s = env_get("displaywidth"); |
d858c335 | 196 | if (s != NULL) |
0b1284eb | 197 | display_width = dectoul(s, NULL); |
35cf3b57 JS |
198 | else |
199 | display_width = 256; | |
200 | ||
00caae6d | 201 | s = env_get("displayheight"); |
d858c335 | 202 | if (s != NULL) |
0b1284eb | 203 | display_height = dectoul(s, NULL); |
35cf3b57 JS |
204 | else |
205 | display_height = 256; | |
206 | ||
207 | printf("%lu x %lu pixel matrix\n", display_width, display_height); | |
208 | ||
209 | MCFCCM_CCR &= ~MCFCCM_CCR_SZEN; | |
210 | MCFGPIO_PEPAR &= ~MCFGPIO_PEPAR_PEPA2; | |
211 | ||
212 | vcxk_init(display_width, display_height); | |
213 | ||
214 | #ifdef CONFIG_SPLASH_SCREEN | |
00caae6d | 215 | s = env_get("splashimage"); |
d858c335 | 216 | if (s != NULL) { |
7e5f460e | 217 | splash = hextoul(s, NULL); |
35cf3b57 JS |
218 | vcxk_acknowledge_wait(); |
219 | video_display_bitmap(splash, 0, 0); | |
220 | } | |
221 | #endif | |
222 | return 0; | |
223 | } | |
224 | #endif | |
225 | ||
9acb626f HS |
226 | /*---------------------------------------------------------------------------*/ |
227 | ||
8c9940d5 | 228 | #if IS_ENABLED(CONFIG_VIDEO_VCXK) |
09140113 | 229 | int do_brightness(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) |
9acb626f HS |
230 | { |
231 | int rcode = 0; | |
35cf3b57 JS |
232 | ulong side; |
233 | ulong bright; | |
9acb626f HS |
234 | |
235 | switch (argc) { | |
35cf3b57 | 236 | case 3: |
0b1284eb SG |
237 | side = dectoul(argv[1], NULL); |
238 | bright = dectoul(argv[2], NULL); | |
35cf3b57 JS |
239 | if ((side >= 0) && (side <= 3) && |
240 | (bright >= 0) && (bright <= 1000)) { | |
241 | vcxk_setbrightness(side, bright); | |
242 | rcode = 0; | |
243 | } else { | |
244 | printf("parameters out of range\n"); | |
245 | printf("Usage:\n%s\n", cmdtp->usage); | |
246 | rcode = 1; | |
247 | } | |
9acb626f HS |
248 | break; |
249 | default: | |
35cf3b57 | 250 | printf("Usage:\n%s\n", cmdtp->usage); |
9acb626f HS |
251 | rcode = 1; |
252 | break; | |
253 | } | |
254 | return rcode; | |
255 | } | |
256 | ||
35cf3b57 | 257 | /*---------------------------------------------------------------------------*/ |
9acb626f HS |
258 | |
259 | U_BOOT_CMD( | |
35cf3b57 JS |
260 | bright, 3, 0, do_brightness, |
261 | "sets the display brightness\n", | |
262 | " <side> <0..1000>\n side: 0/3=both; 1=first; 2=second\n" | |
9acb626f HS |
263 | ); |
264 | ||
35cf3b57 JS |
265 | #endif |
266 | ||
267 | /* EOF EB+MCF-EV123.c */ |