blob: f73431eff59b4d018236bd04fbe4672c6d697a57 [file] [log] [blame]
Heiko Schocherac1956e2006-04-20 08:42:42 +02001/*
Jens Scharsig772d9b02009-07-24 10:31:48 +02002 * (C) Copyright 2005-2009
Heiko Schocherac1956e2006-04-20 08:42:42 +02003 * BuS Elektronik GmbH & Co.KG <esw@bus-elektonik.de>
4 *
5 * (C) Copyright 2000-2003
6 * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
7 *
8 * See file CREDITS for list of people who contributed to this
9 * project.
10 *
11 * This program is free software; you can redistribute it and/or
12 * modify it under the terms of the GNU General Public License as
13 * published by the Free Software Foundation; either version 2 of
14 * the License, or (at your option) any later version.
15 *
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
20 *
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
24 * MA 02111-1307 USA
25 */
26
27#include <common.h>
28#include <command.h>
29#include "asm/m5282.h"
Jens Scharsig772d9b02009-07-24 10:31:48 +020030#include <bmp_layout.h>
31#include <status_led.h>
32#include <bus_vcxk.h>
33
34/*---------------------------------------------------------------------------*/
35
36DECLARE_GLOBAL_DATA_PTR;
37
Jens Scharsig (BuS Elektronik)e5e58372012-10-30 00:46:05 +000038#ifdef CONFIG_VIDEO
Jens Scharsig772d9b02009-07-24 10:31:48 +020039unsigned long display_width;
40unsigned long display_height;
Jens Scharsig (BuS Elektronik)e5e58372012-10-30 00:46:05 +000041#endif
Jens Scharsig772d9b02009-07-24 10:31:48 +020042
43/*---------------------------------------------------------------------------*/
Heiko Schocherac1956e2006-04-20 08:42:42 +020044
45int checkboard (void)
46{
Jens Scharsig (BuS Elektronik)e5e58372012-10-30 00:46:05 +000047 puts("Board: EB+CPU5282 (BuS Elektronik GmbH & Co. KG)\n");
Wolfgang Denk0708bc62010-10-07 21:51:12 +020048#if (CONFIG_SYS_TEXT_BASE == CONFIG_SYS_INT_FLASH_BASE)
Jens Scharsig (BuS Elektronik)e5e58372012-10-30 00:46:05 +000049 puts(" Boot from Internal FLASH\n");
Heiko Schocherac1956e2006-04-20 08:42:42 +020050#endif
Heiko Schocherac1956e2006-04-20 08:42:42 +020051 return 0;
52}
53
Becky Brucebd99ae72008-06-09 16:03:40 -050054phys_size_t initdram (int board_type)
Heiko Schocherac1956e2006-04-20 08:42:42 +020055{
Wolfgang Denkc4f55ee2008-07-14 20:38:26 +020056 int size, i;
Heiko Schocherac1956e2006-04-20 08:42:42 +020057
58 size = 0;
Jens Scharsig (BuS Elektronik)e5e58372012-10-30 00:46:05 +000059 MCFSDRAMC_DCR = MCFSDRAMC_DCR_RTIM_6 |
60 MCFSDRAMC_DCR_RC((15 * CONFIG_SYS_CLK / 1000000) >> 4);
61 asm (" nop");
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +020062#ifdef CONFIG_SYS_SDRAM_BASE0
Jens Scharsig (BuS Elektronik)e5e58372012-10-30 00:46:05 +000063 MCFSDRAMC_DACR0 = MCFSDRAMC_DACR_BASE(CONFIG_SYS_SDRAM_BASE0)|
64 MCFSDRAMC_DACR_CASL(1) | MCFSDRAMC_DACR_CBM(3) |
65 MCFSDRAMC_DACR_PS_32;
66 asm (" nop");
Heiko Schocherac1956e2006-04-20 08:42:42 +020067
Wolfgang Denkc4f55ee2008-07-14 20:38:26 +020068 MCFSDRAMC_DMR0 = MCFSDRAMC_DMR_BAM_16M | MCFSDRAMC_DMR_V;
Jens Scharsig (BuS Elektronik)e5e58372012-10-30 00:46:05 +000069 asm (" nop");
Heiko Schocherac1956e2006-04-20 08:42:42 +020070
Wolfgang Denkc4f55ee2008-07-14 20:38:26 +020071 MCFSDRAMC_DACR0 |= MCFSDRAMC_DACR_IP;
Jens Scharsig (BuS Elektronik)e5e58372012-10-30 00:46:05 +000072 asm (" nop");
73 for (i = 0; i < 10; i++)
74 asm (" nop");
Heiko Schocherac1956e2006-04-20 08:42:42 +020075
Jens Scharsig (BuS Elektronik)e5e58372012-10-30 00:46:05 +000076 *(unsigned long *)(CONFIG_SYS_SDRAM_BASE0) = 0xA5A5A5A5;
77 asm (" nop");
Wolfgang Denkc4f55ee2008-07-14 20:38:26 +020078 MCFSDRAMC_DACR0 |= MCFSDRAMC_DACR_RE;
Jens Scharsig (BuS Elektronik)e5e58372012-10-30 00:46:05 +000079 asm (" nop");
80
Wolfgang Denkc4f55ee2008-07-14 20:38:26 +020081 for (i = 0; i < 2000; i++)
82 asm (" nop");
Jens Scharsig (BuS Elektronik)e5e58372012-10-30 00:46:05 +000083
84 MCFSDRAMC_DACR0 |= MCFSDRAMC_DACR_IMRS;
85 asm (" nop");
86 /* write SDRAM mode register */
87 *(unsigned long *)(CONFIG_SYS_SDRAM_BASE0 + 0x80440) = 0xA5A5A5A5;
88 asm (" nop");
89 size += CONFIG_SYS_SDRAM_SIZE0 * 1024 * 1024;
Wolfgang Denkc4f55ee2008-07-14 20:38:26 +020090#endif
Jens Scharsig (BuS Elektronik)e5e58372012-10-30 00:46:05 +000091#ifdef CONFIG_SYS_SDRAM_BASE1xx
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +020092 MCFSDRAMC_DACR1 = MCFSDRAMC_DACR_BASE (CONFIG_SYS_SDRAM_BASE1)
Wolfgang Denkc4f55ee2008-07-14 20:38:26 +020093 | MCFSDRAMC_DACR_CASL (1)
94 | MCFSDRAMC_DACR_CBM (3)
95 | MCFSDRAMC_DACR_PS_16;
Heiko Schocherac1956e2006-04-20 08:42:42 +020096
Wolfgang Denkc4f55ee2008-07-14 20:38:26 +020097 MCFSDRAMC_DMR1 = MCFSDRAMC_DMR_BAM_16M | MCFSDRAMC_DMR_V;
Heiko Schocherac1956e2006-04-20 08:42:42 +020098
Wolfgang Denkc4f55ee2008-07-14 20:38:26 +020099 MCFSDRAMC_DACR1 |= MCFSDRAMC_DACR_IP;
100
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +0200101 *(unsigned short *) (CONFIG_SYS_SDRAM_BASE1) = 0xA5A5;
Wolfgang Denkc4f55ee2008-07-14 20:38:26 +0200102 MCFSDRAMC_DACR1 |= MCFSDRAMC_DACR_RE;
103
104 for (i = 0; i < 2000; i++)
105 asm (" nop");
Heiko Schocherac1956e2006-04-20 08:42:42 +0200106
Wolfgang Denkc4f55ee2008-07-14 20:38:26 +0200107 MCFSDRAMC_DACR1 |= MCFSDRAMC_DACR_IMRS;
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +0200108 *(unsigned int *) (CONFIG_SYS_SDRAM_BASE1 + 0x220) = 0xA5A5;
109 size += CONFIG_SYS_SDRAM_SIZE1 * 1024 * 1024;
Wolfgang Denkc4f55ee2008-07-14 20:38:26 +0200110#endif
Heiko Schocherac1956e2006-04-20 08:42:42 +0200111 return size;
112}
113
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +0200114#if defined(CONFIG_SYS_DRAM_TEST)
Heiko Schocherac1956e2006-04-20 08:42:42 +0200115int testdram (void)
116{
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +0200117 uint *pstart = (uint *) CONFIG_SYS_MEMTEST_START;
118 uint *pend = (uint *) CONFIG_SYS_MEMTEST_END;
Heiko Schocherac1956e2006-04-20 08:42:42 +0200119 uint *p;
120
121 printf("SDRAM test phase 1:\n");
122 for (p = pstart; p < pend; p++)
123 *p = 0xaaaaaaaa;
124
125 for (p = pstart; p < pend; p++) {
126 if (*p != 0xaaaaaaaa) {
127 printf ("SDRAM test fails at: %08x\n", (uint) p);
128 return 1;
129 }
130 }
131
132 printf("SDRAM test phase 2:\n");
133 for (p = pstart; p < pend; p++)
134 *p = 0x55555555;
135
136 for (p = pstart; p < pend; p++) {
137 if (*p != 0x55555555) {
138 printf ("SDRAM test fails at: %08x\n", (uint) p);
139 return 1;
140 }
141 }
142
143 printf("SDRAM test passed.\n");
144 return 0;
145}
146#endif
147
Jens Scharsig (BuS Elektronik)e5e58372012-10-30 00:46:05 +0000148#if defined(CONFIG_HW_WATCHDOG)
149
150void hw_watchdog_init(void)
151{
152 char *s;
153 int enable;
154
155 enable = 1;
156 s = getenv("watchdog");
157 if (s != NULL)
158 if ((strncmp(s, "off", 3) == 0) || (strncmp(s, "0", 1) == 0))
159 enable = 0;
160 if (enable)
161 MCFGPTA_GPTDDR |= (1<<2);
162 else
163 MCFGPTA_GPTDDR &= ~(1<<2);
164}
165
166void hw_watchdog_reset(void)
167{
168 MCFGPTA_GPTPORT ^= (1<<2);
169}
170#endif
171
Heiko Schocherac1956e2006-04-20 08:42:42 +0200172int misc_init_r(void)
173{
Jens Scharsig772d9b02009-07-24 10:31:48 +0200174#ifdef CONFIG_HW_WATCHDOG
175 hw_watchdog_init();
176#endif
Heiko Schocherac1956e2006-04-20 08:42:42 +0200177 return 1;
178}
Jens Scharsig772d9b02009-07-24 10:31:48 +0200179
Jens Scharsig (BuS Elektronik)e5e58372012-10-30 00:46:05 +0000180void __led_toggle(led_id_t mask)
181{
182 MCFGPTA_GPTPORT ^= (1 << 3);
183}
184
185void __led_init(led_id_t mask, int state)
186{
187 __led_set(mask, state);
188 MCFGPTA_GPTDDR |= (1 << 3);
189}
Jens Scharsig772d9b02009-07-24 10:31:48 +0200190
Jens Scharsig (BuS Elektronik)e5e58372012-10-30 00:46:05 +0000191void __led_set(led_id_t mask, int state)
192{
193 if (state == STATUS_LED_ON)
194 MCFGPTA_GPTPORT |= (1 << 3);
195 else
196 MCFGPTA_GPTPORT &= ~(1 << 3);
197}
198
199#if defined(CONFIG_VIDEO)
Jens Scharsig772d9b02009-07-24 10:31:48 +0200200
201int drv_video_init(void)
202{
203 char *s;
Jens Scharsig (BuS Elektronik)e5e58372012-10-30 00:46:05 +0000204#ifdef CONFIG_SPLASH_SCREEN
Jens Scharsig772d9b02009-07-24 10:31:48 +0200205 unsigned long splash;
Jens Scharsig (BuS Elektronik)e5e58372012-10-30 00:46:05 +0000206#endif
Jens Scharsig772d9b02009-07-24 10:31:48 +0200207 printf("Init Video as ");
Jens Scharsig (BuS Elektronik)e5e58372012-10-30 00:46:05 +0000208 s = getenv("displaywidth");
209 if (s != NULL)
Jens Scharsig772d9b02009-07-24 10:31:48 +0200210 display_width = simple_strtoul(s, NULL, 10);
211 else
212 display_width = 256;
213
Jens Scharsig (BuS Elektronik)e5e58372012-10-30 00:46:05 +0000214 s = getenv("displayheight");
215 if (s != NULL)
Jens Scharsig772d9b02009-07-24 10:31:48 +0200216 display_height = simple_strtoul(s, NULL, 10);
217 else
218 display_height = 256;
219
220 printf("%lu x %lu pixel matrix\n", display_width, display_height);
221
222 MCFCCM_CCR &= ~MCFCCM_CCR_SZEN;
223 MCFGPIO_PEPAR &= ~MCFGPIO_PEPAR_PEPA2;
224
225 vcxk_init(display_width, display_height);
226
227#ifdef CONFIG_SPLASH_SCREEN
Jens Scharsig (BuS Elektronik)e5e58372012-10-30 00:46:05 +0000228 s = getenv("splashimage");
229 if (s != NULL) {
Jens Scharsig772d9b02009-07-24 10:31:48 +0200230 splash = simple_strtoul(s, NULL, 16);
Jens Scharsig772d9b02009-07-24 10:31:48 +0200231 vcxk_acknowledge_wait();
232 video_display_bitmap(splash, 0, 0);
233 }
234#endif
235 return 0;
236}
237#endif
Heiko Schocherac1956e2006-04-20 08:42:42 +0200238
239/*---------------------------------------------------------------------------*/
240
Jens Scharsig772d9b02009-07-24 10:31:48 +0200241#ifdef CONFIG_VIDEO
Wolfgang Denk6262d0212010-06-28 22:00:46 +0200242int do_brightness(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
Heiko Schocherac1956e2006-04-20 08:42:42 +0200243{
244 int rcode = 0;
Jens Scharsig772d9b02009-07-24 10:31:48 +0200245 ulong side;
246 ulong bright;
Heiko Schocherac1956e2006-04-20 08:42:42 +0200247
248 switch (argc) {
Jens Scharsig772d9b02009-07-24 10:31:48 +0200249 case 3:
250 side = simple_strtoul(argv[1], NULL, 10);
251 bright = simple_strtoul(argv[2], NULL, 10);
252 if ((side >= 0) && (side <= 3) &&
253 (bright >= 0) && (bright <= 1000)) {
254 vcxk_setbrightness(side, bright);
255 rcode = 0;
256 } else {
257 printf("parameters out of range\n");
258 printf("Usage:\n%s\n", cmdtp->usage);
259 rcode = 1;
260 }
Heiko Schocherac1956e2006-04-20 08:42:42 +0200261 break;
262 default:
Jens Scharsig772d9b02009-07-24 10:31:48 +0200263 printf("Usage:\n%s\n", cmdtp->usage);
Heiko Schocherac1956e2006-04-20 08:42:42 +0200264 rcode = 1;
265 break;
266 }
267 return rcode;
268}
269
Jens Scharsig772d9b02009-07-24 10:31:48 +0200270/*---------------------------------------------------------------------------*/
Heiko Schocherac1956e2006-04-20 08:42:42 +0200271
272U_BOOT_CMD(
Jens Scharsig772d9b02009-07-24 10:31:48 +0200273 bright, 3, 0, do_brightness,
274 "sets the display brightness\n",
275 " <side> <0..1000>\n side: 0/3=both; 1=first; 2=second\n"
Heiko Schocherac1956e2006-04-20 08:42:42 +0200276);
277
Jens Scharsig772d9b02009-07-24 10:31:48 +0200278#endif
279
280/* EOF EB+MCF-EV123.c */