blob: 2fc3eafbd82f7728185aa1d37577a2dbbfd063f3 [file] [log] [blame]
Heiko Schocher9acb6262006-04-20 08:42:42 +02001/*
Jens Scharsig35cf3b52009-07-24 10:31:48 +02002 * (C) Copyright 2005-2009
Heiko Schocher9acb6262006-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 Scharsig35cf3b52009-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
38unsigned long display_width;
39unsigned long display_height;
40
41/*---------------------------------------------------------------------------*/
Heiko Schocher9acb6262006-04-20 08:42:42 +020042
43int checkboard (void)
44{
45 puts ("Board: MCF-EV1 + MCF-EV23 (BuS Elektronik GmbH & Co. KG)\n");
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +020046#if (TEXT_BASE == CONFIG_SYS_INT_FLASH_BASE)
Heiko Schocher9acb6262006-04-20 08:42:42 +020047 puts (" Boot from Internal FLASH\n");
48#endif
49
50 return 0;
51}
52
Becky Bruce9973e3c2008-06-09 16:03:40 -050053phys_size_t initdram (int board_type)
Heiko Schocher9acb6262006-04-20 08:42:42 +020054{
Wolfgang Denk0fe34052008-07-14 20:38:26 +020055 int size, i;
Heiko Schocher9acb6262006-04-20 08:42:42 +020056
57 size = 0;
Wolfgang Denk0fe34052008-07-14 20:38:26 +020058 MCFSDRAMC_DCR = MCFSDRAMC_DCR_RTIM_6
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +020059 | MCFSDRAMC_DCR_RC ((15 * CONFIG_SYS_CLK) >> 4);
60#ifdef CONFIG_SYS_SDRAM_BASE0
Heiko Schocher9acb6262006-04-20 08:42:42 +020061
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +020062 MCFSDRAMC_DACR0 = MCFSDRAMC_DACR_BASE (CONFIG_SYS_SDRAM_BASE0)
Wolfgang Denk0fe34052008-07-14 20:38:26 +020063 | MCFSDRAMC_DACR_CASL (1)
64 | MCFSDRAMC_DACR_CBM (3)
65 | MCFSDRAMC_DACR_PS_16;
Heiko Schocher9acb6262006-04-20 08:42:42 +020066
Wolfgang Denk0fe34052008-07-14 20:38:26 +020067 MCFSDRAMC_DMR0 = MCFSDRAMC_DMR_BAM_16M | MCFSDRAMC_DMR_V;
Heiko Schocher9acb6262006-04-20 08:42:42 +020068
Wolfgang Denk0fe34052008-07-14 20:38:26 +020069 MCFSDRAMC_DACR0 |= MCFSDRAMC_DACR_IP;
Heiko Schocher9acb6262006-04-20 08:42:42 +020070
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +020071 *(unsigned short *) (CONFIG_SYS_SDRAM_BASE0) = 0xA5A5;
Wolfgang Denk0fe34052008-07-14 20:38:26 +020072 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);
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +020077 *(unsigned int *) (CONFIG_SYS_SDRAM_BASE0 + 0x220) = 0xA5A5;
78 size += CONFIG_SYS_SDRAM_SIZE * 1024 * 1024;
Wolfgang Denk0fe34052008-07-14 20:38:26 +020079#endif
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +020080#ifdef CONFIG_SYS_SDRAM_BASE1
81 MCFSDRAMC_DACR1 = MCFSDRAMC_DACR_BASE (CONFIG_SYS_SDRAM_BASE1)
Wolfgang Denk0fe34052008-07-14 20:38:26 +020082 | MCFSDRAMC_DACR_CASL (1)
83 | MCFSDRAMC_DACR_CBM (3)
84 | MCFSDRAMC_DACR_PS_16;
Heiko Schocher9acb6262006-04-20 08:42:42 +020085
Wolfgang Denk0fe34052008-07-14 20:38:26 +020086 MCFSDRAMC_DMR1 = MCFSDRAMC_DMR_BAM_16M | MCFSDRAMC_DMR_V;
Heiko Schocher9acb6262006-04-20 08:42:42 +020087
Wolfgang Denk0fe34052008-07-14 20:38:26 +020088 MCFSDRAMC_DACR1 |= MCFSDRAMC_DACR_IP;
Heiko Schocher9acb6262006-04-20 08:42:42 +020089
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +020090 *(unsigned short *) (CONFIG_SYS_SDRAM_BASE1) = 0xA5A5;
Wolfgang Denk0fe34052008-07-14 20:38:26 +020091 MCFSDRAMC_DACR1 |= MCFSDRAMC_DACR_RE;
92
93 for (i = 0; i < 2000; i++)
94 asm (" nop");
95
96 MCFSDRAMC_DACR1 |= MCFSDRAMC_DACR_IMRS;
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +020097 *(unsigned int *) (CONFIG_SYS_SDRAM_BASE1 + 0x220) = 0xA5A5;
98 size += CONFIG_SYS_SDRAM_SIZE1 * 1024 * 1024;
Wolfgang Denk0fe34052008-07-14 20:38:26 +020099#endif
Heiko Schocher9acb6262006-04-20 08:42:42 +0200100 return size;
101}
102
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200103#if defined(CONFIG_SYS_DRAM_TEST)
Heiko Schocher9acb6262006-04-20 08:42:42 +0200104int testdram (void)
105{
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200106 uint *pstart = (uint *) CONFIG_SYS_MEMTEST_START;
107 uint *pend = (uint *) CONFIG_SYS_MEMTEST_END;
Heiko Schocher9acb6262006-04-20 08:42:42 +0200108 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
137int misc_init_r(void)
138{
Jens Scharsig35cf3b52009-07-24 10:31:48 +0200139#ifdef CONFIG_HW_WATCHDOG
140 hw_watchdog_init();
141#endif
142#ifndef CONFIG_VIDEO
143 vcxk_init(16, 16);
144#endif
Heiko Schocher9acb6262006-04-20 08:42:42 +0200145 return 1;
146}
147
Jens Scharsig35cf3b52009-07-24 10:31:48 +0200148#if defined(CONFIG_VIDEO)
149
150/*
151 ****h* EB+CPU5282-T1/drv_video_init
152 * FUNCTION
153 ***
154 */
155
156int 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
Heiko Schocher9acb6262006-04-20 08:42:42 +0200193/*---------------------------------------------------------------------------*/
194
Jens Scharsig35cf3b52009-07-24 10:31:48 +0200195#ifdef CONFIG_VIDEO
196int do_brightness(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
Heiko Schocher9acb6262006-04-20 08:42:42 +0200197{
198 int rcode = 0;
Jens Scharsig35cf3b52009-07-24 10:31:48 +0200199 ulong side;
200 ulong bright;
Heiko Schocher9acb6262006-04-20 08:42:42 +0200201
202 switch (argc) {
Jens Scharsig35cf3b52009-07-24 10:31:48 +0200203 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 }
Heiko Schocher9acb6262006-04-20 08:42:42 +0200215 break;
216 default:
Jens Scharsig35cf3b52009-07-24 10:31:48 +0200217 printf("Usage:\n%s\n", cmdtp->usage);
Heiko Schocher9acb6262006-04-20 08:42:42 +0200218 rcode = 1;
219 break;
220 }
221 return rcode;
222}
223
Jens Scharsig35cf3b52009-07-24 10:31:48 +0200224/*---------------------------------------------------------------------------*/
Heiko Schocher9acb6262006-04-20 08:42:42 +0200225
226U_BOOT_CMD(
Jens Scharsig35cf3b52009-07-24 10:31:48 +0200227 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"
Heiko Schocher9acb6262006-04-20 08:42:42 +0200230);
231
Jens Scharsig35cf3b52009-07-24 10:31:48 +0200232#endif
233
234/* EOF EB+MCF-EV123.c */