]> git.kernelconcepts.de Git - karo-tx-uboot.git/blob - board/BuS/eb_cpu5282/eb_cpu5282.c
rename EB+MCF-EV123 to its current marketing name EB+CPU5282
[karo-tx-uboot.git] / board / BuS / eb_cpu5282 / eb_cpu5282.c
1 /*
2  * (C) Copyright 2005-2009
3  * 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"
30 #include <bmp_layout.h>
31 #include <status_led.h>
32 #include <bus_vcxk.h>
33
34 /*---------------------------------------------------------------------------*/
35
36 DECLARE_GLOBAL_DATA_PTR;
37
38 unsigned long display_width;
39 unsigned long display_height;
40
41 /*---------------------------------------------------------------------------*/
42
43 int checkboard (void)
44 {
45         puts ("Board: MCF-EV1 + MCF-EV23 (BuS Elektronik GmbH & Co. KG)\n");
46 #if (CONFIG_SYS_TEXT_BASE ==  CONFIG_SYS_INT_FLASH_BASE)
47         puts ("       Boot from Internal FLASH\n");
48 #endif
49
50         return 0;
51 }
52
53 phys_size_t initdram (int board_type)
54 {
55         int size, i;
56
57         size = 0;
58         MCFSDRAMC_DCR = MCFSDRAMC_DCR_RTIM_6
59                         | MCFSDRAMC_DCR_RC ((15 * CONFIG_SYS_CLK) >> 4);
60 #ifdef CONFIG_SYS_SDRAM_BASE0
61
62         MCFSDRAMC_DACR0 = MCFSDRAMC_DACR_BASE (CONFIG_SYS_SDRAM_BASE0)
63                         | MCFSDRAMC_DACR_CASL (1)
64                         | MCFSDRAMC_DACR_CBM (3)
65                         | MCFSDRAMC_DACR_PS_16;
66
67         MCFSDRAMC_DMR0 = MCFSDRAMC_DMR_BAM_16M | MCFSDRAMC_DMR_V;
68
69         MCFSDRAMC_DACR0 |= MCFSDRAMC_DACR_IP;
70
71         *(unsigned short *) (CONFIG_SYS_SDRAM_BASE0) = 0xA5A5;
72         MCFSDRAMC_DACR0 |= MCFSDRAMC_DACR_RE;
73         for (i = 0; i < 2000; i++)
74                 asm (" nop");
75         mbar_writeLong (MCFSDRAMC_DACR0,
76                         mbar_readLong (MCFSDRAMC_DACR0) | MCFSDRAMC_DACR_IMRS);
77         *(unsigned int *) (CONFIG_SYS_SDRAM_BASE0 + 0x220) = 0xA5A5;
78         size += CONFIG_SYS_SDRAM_SIZE * 1024 * 1024;
79 #endif
80 #ifdef CONFIG_SYS_SDRAM_BASE1
81         MCFSDRAMC_DACR1 = MCFSDRAMC_DACR_BASE (CONFIG_SYS_SDRAM_BASE1)
82                         | MCFSDRAMC_DACR_CASL (1)
83                         | MCFSDRAMC_DACR_CBM (3)
84                         | MCFSDRAMC_DACR_PS_16;
85
86         MCFSDRAMC_DMR1 = MCFSDRAMC_DMR_BAM_16M | MCFSDRAMC_DMR_V;
87
88         MCFSDRAMC_DACR1 |= MCFSDRAMC_DACR_IP;
89
90         *(unsigned short *) (CONFIG_SYS_SDRAM_BASE1) = 0xA5A5;
91         MCFSDRAMC_DACR1 |= MCFSDRAMC_DACR_RE;
92
93         for (i = 0; i < 2000; i++)
94                 asm (" nop");
95
96         MCFSDRAMC_DACR1 |= MCFSDRAMC_DACR_IMRS;
97         *(unsigned int *) (CONFIG_SYS_SDRAM_BASE1 + 0x220) = 0xA5A5;
98         size += CONFIG_SYS_SDRAM_SIZE1 * 1024 * 1024;
99 #endif
100         return size;
101 }
102
103 #if defined(CONFIG_SYS_DRAM_TEST)
104 int testdram (void)
105 {
106         uint *pstart = (uint *) CONFIG_SYS_MEMTEST_START;
107         uint *pend = (uint *) CONFIG_SYS_MEMTEST_END;
108         uint *p;
109
110         printf("SDRAM test phase 1:\n");
111         for (p = pstart; p < pend; p++)
112                 *p = 0xaaaaaaaa;
113
114         for (p = pstart; p < pend; p++) {
115                 if (*p != 0xaaaaaaaa) {
116                         printf ("SDRAM test fails at: %08x\n", (uint) p);
117                         return 1;
118                 }
119         }
120
121         printf("SDRAM test phase 2:\n");
122         for (p = pstart; p < pend; p++)
123                 *p = 0x55555555;
124
125         for (p = pstart; p < pend; p++) {
126                 if (*p != 0x55555555) {
127                         printf ("SDRAM test fails at: %08x\n", (uint) p);
128                         return 1;
129                 }
130         }
131
132         printf("SDRAM test passed.\n");
133         return 0;
134 }
135 #endif
136
137 int misc_init_r(void)
138 {
139 #ifdef  CONFIG_HW_WATCHDOG
140         hw_watchdog_init();
141 #endif
142 #ifndef CONFIG_VIDEO
143         vcxk_init(16, 16);
144 #endif
145         return 1;
146 }
147
148 #if defined(CONFIG_VIDEO)
149
150 /*
151  ****h* EB+CPU5282-T1/drv_video_init
152  * FUNCTION
153  ***
154  */
155
156 int drv_video_init(void)
157 {
158         char *s;
159         unsigned long splash;
160
161         printf("Init Video as ");
162
163         if ((s = getenv("displaywidth")) != NULL)
164                 display_width = simple_strtoul(s, NULL, 10);
165         else
166                 display_width = 256;
167
168         if ((s = getenv("displayheight")) != NULL)
169                 display_height = simple_strtoul(s, NULL, 10);
170         else
171                 display_height = 256;
172
173         printf("%lu x %lu pixel matrix\n", display_width, display_height);
174
175         MCFCCM_CCR &= ~MCFCCM_CCR_SZEN;
176         MCFGPIO_PEPAR &= ~MCFGPIO_PEPAR_PEPA2;
177
178         vcxk_init(display_width, display_height);
179
180 #ifdef CONFIG_SPLASH_SCREEN
181         if ((s = getenv("splashimage")) != NULL) {
182                 debug("use splashimage: %s\n", s);
183                 splash = simple_strtoul(s, NULL, 16);
184                 debug("use splashimage: %x\n", splash);
185                 vcxk_acknowledge_wait();
186                 video_display_bitmap(splash, 0, 0);
187         }
188 #endif
189         return 0;
190 }
191 #endif
192
193 /*---------------------------------------------------------------------------*/
194
195 #ifdef CONFIG_VIDEO
196 int do_brightness(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
197 {
198         int rcode = 0;
199         ulong side;
200         ulong bright;
201
202         switch (argc) {
203         case 3:
204                 side = simple_strtoul(argv[1], NULL, 10);
205                 bright = simple_strtoul(argv[2], NULL, 10);
206                 if ((side >= 0) && (side <= 3) &&
207                         (bright >= 0) && (bright <= 1000)) {
208                         vcxk_setbrightness(side, bright);
209                         rcode = 0;
210                 } else {
211                         printf("parameters out of range\n");
212                         printf("Usage:\n%s\n", cmdtp->usage);
213                         rcode = 1;
214                 }
215                 break;
216         default:
217                 printf("Usage:\n%s\n", cmdtp->usage);
218                 rcode = 1;
219                 break;
220         }
221         return rcode;
222 }
223
224 /*---------------------------------------------------------------------------*/
225
226 U_BOOT_CMD(
227         bright, 3,      0,      do_brightness,
228         "sets the display brightness\n",
229         " <side> <0..1000>\n        side: 0/3=both; 1=first; 2=second\n"
230 );
231
232 #endif
233
234 /* EOF EB+MCF-EV123.c */