Heiko Schocher | ac1956e | 2006-04-20 08:42:42 +0200 | [diff] [blame] | 1 | /* |
Jens Scharsig | 772d9b0 | 2009-07-24 10:31:48 +0200 | [diff] [blame] | 2 | * (C) Copyright 2005-2009 |
Heiko Schocher | ac1956e | 2006-04-20 08:42:42 +0200 | [diff] [blame] | 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" |
Jens Scharsig | 772d9b0 | 2009-07-24 10:31:48 +0200 | [diff] [blame] | 30 | #include <bmp_layout.h> |
| 31 | #include <status_led.h> |
| 32 | #include <bus_vcxk.h> |
| 33 | |
| 34 | /*---------------------------------------------------------------------------*/ |
| 35 | |
| 36 | DECLARE_GLOBAL_DATA_PTR; |
| 37 | |
Jens Scharsig (BuS Elektronik) | e5e5837 | 2012-10-30 00:46:05 +0000 | [diff] [blame^] | 38 | #ifdef CONFIG_VIDEO |
Jens Scharsig | 772d9b0 | 2009-07-24 10:31:48 +0200 | [diff] [blame] | 39 | unsigned long display_width; |
| 40 | unsigned long display_height; |
Jens Scharsig (BuS Elektronik) | e5e5837 | 2012-10-30 00:46:05 +0000 | [diff] [blame^] | 41 | #endif |
Jens Scharsig | 772d9b0 | 2009-07-24 10:31:48 +0200 | [diff] [blame] | 42 | |
| 43 | /*---------------------------------------------------------------------------*/ |
Heiko Schocher | ac1956e | 2006-04-20 08:42:42 +0200 | [diff] [blame] | 44 | |
| 45 | int checkboard (void) |
| 46 | { |
Jens Scharsig (BuS Elektronik) | e5e5837 | 2012-10-30 00:46:05 +0000 | [diff] [blame^] | 47 | puts("Board: EB+CPU5282 (BuS Elektronik GmbH & Co. KG)\n"); |
Wolfgang Denk | 0708bc6 | 2010-10-07 21:51:12 +0200 | [diff] [blame] | 48 | #if (CONFIG_SYS_TEXT_BASE == CONFIG_SYS_INT_FLASH_BASE) |
Jens Scharsig (BuS Elektronik) | e5e5837 | 2012-10-30 00:46:05 +0000 | [diff] [blame^] | 49 | puts(" Boot from Internal FLASH\n"); |
Heiko Schocher | ac1956e | 2006-04-20 08:42:42 +0200 | [diff] [blame] | 50 | #endif |
Heiko Schocher | ac1956e | 2006-04-20 08:42:42 +0200 | [diff] [blame] | 51 | return 0; |
| 52 | } |
| 53 | |
Becky Bruce | bd99ae7 | 2008-06-09 16:03:40 -0500 | [diff] [blame] | 54 | phys_size_t initdram (int board_type) |
Heiko Schocher | ac1956e | 2006-04-20 08:42:42 +0200 | [diff] [blame] | 55 | { |
Wolfgang Denk | c4f55ee | 2008-07-14 20:38:26 +0200 | [diff] [blame] | 56 | int size, i; |
Heiko Schocher | ac1956e | 2006-04-20 08:42:42 +0200 | [diff] [blame] | 57 | |
| 58 | size = 0; |
Jens Scharsig (BuS Elektronik) | e5e5837 | 2012-10-30 00:46:05 +0000 | [diff] [blame^] | 59 | MCFSDRAMC_DCR = MCFSDRAMC_DCR_RTIM_6 | |
| 60 | MCFSDRAMC_DCR_RC((15 * CONFIG_SYS_CLK / 1000000) >> 4); |
| 61 | asm (" nop"); |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 62 | #ifdef CONFIG_SYS_SDRAM_BASE0 |
Jens Scharsig (BuS Elektronik) | e5e5837 | 2012-10-30 00:46:05 +0000 | [diff] [blame^] | 63 | 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 Schocher | ac1956e | 2006-04-20 08:42:42 +0200 | [diff] [blame] | 67 | |
Wolfgang Denk | c4f55ee | 2008-07-14 20:38:26 +0200 | [diff] [blame] | 68 | MCFSDRAMC_DMR0 = MCFSDRAMC_DMR_BAM_16M | MCFSDRAMC_DMR_V; |
Jens Scharsig (BuS Elektronik) | e5e5837 | 2012-10-30 00:46:05 +0000 | [diff] [blame^] | 69 | asm (" nop"); |
Heiko Schocher | ac1956e | 2006-04-20 08:42:42 +0200 | [diff] [blame] | 70 | |
Wolfgang Denk | c4f55ee | 2008-07-14 20:38:26 +0200 | [diff] [blame] | 71 | MCFSDRAMC_DACR0 |= MCFSDRAMC_DACR_IP; |
Jens Scharsig (BuS Elektronik) | e5e5837 | 2012-10-30 00:46:05 +0000 | [diff] [blame^] | 72 | asm (" nop"); |
| 73 | for (i = 0; i < 10; i++) |
| 74 | asm (" nop"); |
Heiko Schocher | ac1956e | 2006-04-20 08:42:42 +0200 | [diff] [blame] | 75 | |
Jens Scharsig (BuS Elektronik) | e5e5837 | 2012-10-30 00:46:05 +0000 | [diff] [blame^] | 76 | *(unsigned long *)(CONFIG_SYS_SDRAM_BASE0) = 0xA5A5A5A5; |
| 77 | asm (" nop"); |
Wolfgang Denk | c4f55ee | 2008-07-14 20:38:26 +0200 | [diff] [blame] | 78 | MCFSDRAMC_DACR0 |= MCFSDRAMC_DACR_RE; |
Jens Scharsig (BuS Elektronik) | e5e5837 | 2012-10-30 00:46:05 +0000 | [diff] [blame^] | 79 | asm (" nop"); |
| 80 | |
Wolfgang Denk | c4f55ee | 2008-07-14 20:38:26 +0200 | [diff] [blame] | 81 | for (i = 0; i < 2000; i++) |
| 82 | asm (" nop"); |
Jens Scharsig (BuS Elektronik) | e5e5837 | 2012-10-30 00:46:05 +0000 | [diff] [blame^] | 83 | |
| 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 Denk | c4f55ee | 2008-07-14 20:38:26 +0200 | [diff] [blame] | 90 | #endif |
Jens Scharsig (BuS Elektronik) | e5e5837 | 2012-10-30 00:46:05 +0000 | [diff] [blame^] | 91 | #ifdef CONFIG_SYS_SDRAM_BASE1xx |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 92 | MCFSDRAMC_DACR1 = MCFSDRAMC_DACR_BASE (CONFIG_SYS_SDRAM_BASE1) |
Wolfgang Denk | c4f55ee | 2008-07-14 20:38:26 +0200 | [diff] [blame] | 93 | | MCFSDRAMC_DACR_CASL (1) |
| 94 | | MCFSDRAMC_DACR_CBM (3) |
| 95 | | MCFSDRAMC_DACR_PS_16; |
Heiko Schocher | ac1956e | 2006-04-20 08:42:42 +0200 | [diff] [blame] | 96 | |
Wolfgang Denk | c4f55ee | 2008-07-14 20:38:26 +0200 | [diff] [blame] | 97 | MCFSDRAMC_DMR1 = MCFSDRAMC_DMR_BAM_16M | MCFSDRAMC_DMR_V; |
Heiko Schocher | ac1956e | 2006-04-20 08:42:42 +0200 | [diff] [blame] | 98 | |
Wolfgang Denk | c4f55ee | 2008-07-14 20:38:26 +0200 | [diff] [blame] | 99 | MCFSDRAMC_DACR1 |= MCFSDRAMC_DACR_IP; |
| 100 | |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 101 | *(unsigned short *) (CONFIG_SYS_SDRAM_BASE1) = 0xA5A5; |
Wolfgang Denk | c4f55ee | 2008-07-14 20:38:26 +0200 | [diff] [blame] | 102 | MCFSDRAMC_DACR1 |= MCFSDRAMC_DACR_RE; |
| 103 | |
| 104 | for (i = 0; i < 2000; i++) |
| 105 | asm (" nop"); |
Heiko Schocher | ac1956e | 2006-04-20 08:42:42 +0200 | [diff] [blame] | 106 | |
Wolfgang Denk | c4f55ee | 2008-07-14 20:38:26 +0200 | [diff] [blame] | 107 | MCFSDRAMC_DACR1 |= MCFSDRAMC_DACR_IMRS; |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 108 | *(unsigned int *) (CONFIG_SYS_SDRAM_BASE1 + 0x220) = 0xA5A5; |
| 109 | size += CONFIG_SYS_SDRAM_SIZE1 * 1024 * 1024; |
Wolfgang Denk | c4f55ee | 2008-07-14 20:38:26 +0200 | [diff] [blame] | 110 | #endif |
Heiko Schocher | ac1956e | 2006-04-20 08:42:42 +0200 | [diff] [blame] | 111 | return size; |
| 112 | } |
| 113 | |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 114 | #if defined(CONFIG_SYS_DRAM_TEST) |
Heiko Schocher | ac1956e | 2006-04-20 08:42:42 +0200 | [diff] [blame] | 115 | int testdram (void) |
| 116 | { |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 117 | uint *pstart = (uint *) CONFIG_SYS_MEMTEST_START; |
| 118 | uint *pend = (uint *) CONFIG_SYS_MEMTEST_END; |
Heiko Schocher | ac1956e | 2006-04-20 08:42:42 +0200 | [diff] [blame] | 119 | 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) | e5e5837 | 2012-10-30 00:46:05 +0000 | [diff] [blame^] | 148 | #if defined(CONFIG_HW_WATCHDOG) |
| 149 | |
| 150 | void 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 | |
| 166 | void hw_watchdog_reset(void) |
| 167 | { |
| 168 | MCFGPTA_GPTPORT ^= (1<<2); |
| 169 | } |
| 170 | #endif |
| 171 | |
Heiko Schocher | ac1956e | 2006-04-20 08:42:42 +0200 | [diff] [blame] | 172 | int misc_init_r(void) |
| 173 | { |
Jens Scharsig | 772d9b0 | 2009-07-24 10:31:48 +0200 | [diff] [blame] | 174 | #ifdef CONFIG_HW_WATCHDOG |
| 175 | hw_watchdog_init(); |
| 176 | #endif |
Heiko Schocher | ac1956e | 2006-04-20 08:42:42 +0200 | [diff] [blame] | 177 | return 1; |
| 178 | } |
Jens Scharsig | 772d9b0 | 2009-07-24 10:31:48 +0200 | [diff] [blame] | 179 | |
Jens Scharsig (BuS Elektronik) | e5e5837 | 2012-10-30 00:46:05 +0000 | [diff] [blame^] | 180 | void __led_toggle(led_id_t mask) |
| 181 | { |
| 182 | MCFGPTA_GPTPORT ^= (1 << 3); |
| 183 | } |
| 184 | |
| 185 | void __led_init(led_id_t mask, int state) |
| 186 | { |
| 187 | __led_set(mask, state); |
| 188 | MCFGPTA_GPTDDR |= (1 << 3); |
| 189 | } |
Jens Scharsig | 772d9b0 | 2009-07-24 10:31:48 +0200 | [diff] [blame] | 190 | |
Jens Scharsig (BuS Elektronik) | e5e5837 | 2012-10-30 00:46:05 +0000 | [diff] [blame^] | 191 | void __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 Scharsig | 772d9b0 | 2009-07-24 10:31:48 +0200 | [diff] [blame] | 200 | |
| 201 | int drv_video_init(void) |
| 202 | { |
| 203 | char *s; |
Jens Scharsig (BuS Elektronik) | e5e5837 | 2012-10-30 00:46:05 +0000 | [diff] [blame^] | 204 | #ifdef CONFIG_SPLASH_SCREEN |
Jens Scharsig | 772d9b0 | 2009-07-24 10:31:48 +0200 | [diff] [blame] | 205 | unsigned long splash; |
Jens Scharsig (BuS Elektronik) | e5e5837 | 2012-10-30 00:46:05 +0000 | [diff] [blame^] | 206 | #endif |
Jens Scharsig | 772d9b0 | 2009-07-24 10:31:48 +0200 | [diff] [blame] | 207 | printf("Init Video as "); |
Jens Scharsig (BuS Elektronik) | e5e5837 | 2012-10-30 00:46:05 +0000 | [diff] [blame^] | 208 | s = getenv("displaywidth"); |
| 209 | if (s != NULL) |
Jens Scharsig | 772d9b0 | 2009-07-24 10:31:48 +0200 | [diff] [blame] | 210 | display_width = simple_strtoul(s, NULL, 10); |
| 211 | else |
| 212 | display_width = 256; |
| 213 | |
Jens Scharsig (BuS Elektronik) | e5e5837 | 2012-10-30 00:46:05 +0000 | [diff] [blame^] | 214 | s = getenv("displayheight"); |
| 215 | if (s != NULL) |
Jens Scharsig | 772d9b0 | 2009-07-24 10:31:48 +0200 | [diff] [blame] | 216 | 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) | e5e5837 | 2012-10-30 00:46:05 +0000 | [diff] [blame^] | 228 | s = getenv("splashimage"); |
| 229 | if (s != NULL) { |
Jens Scharsig | 772d9b0 | 2009-07-24 10:31:48 +0200 | [diff] [blame] | 230 | splash = simple_strtoul(s, NULL, 16); |
Jens Scharsig | 772d9b0 | 2009-07-24 10:31:48 +0200 | [diff] [blame] | 231 | vcxk_acknowledge_wait(); |
| 232 | video_display_bitmap(splash, 0, 0); |
| 233 | } |
| 234 | #endif |
| 235 | return 0; |
| 236 | } |
| 237 | #endif |
Heiko Schocher | ac1956e | 2006-04-20 08:42:42 +0200 | [diff] [blame] | 238 | |
| 239 | /*---------------------------------------------------------------------------*/ |
| 240 | |
Jens Scharsig | 772d9b0 | 2009-07-24 10:31:48 +0200 | [diff] [blame] | 241 | #ifdef CONFIG_VIDEO |
Wolfgang Denk | 6262d021 | 2010-06-28 22:00:46 +0200 | [diff] [blame] | 242 | int do_brightness(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) |
Heiko Schocher | ac1956e | 2006-04-20 08:42:42 +0200 | [diff] [blame] | 243 | { |
| 244 | int rcode = 0; |
Jens Scharsig | 772d9b0 | 2009-07-24 10:31:48 +0200 | [diff] [blame] | 245 | ulong side; |
| 246 | ulong bright; |
Heiko Schocher | ac1956e | 2006-04-20 08:42:42 +0200 | [diff] [blame] | 247 | |
| 248 | switch (argc) { |
Jens Scharsig | 772d9b0 | 2009-07-24 10:31:48 +0200 | [diff] [blame] | 249 | 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 Schocher | ac1956e | 2006-04-20 08:42:42 +0200 | [diff] [blame] | 261 | break; |
| 262 | default: |
Jens Scharsig | 772d9b0 | 2009-07-24 10:31:48 +0200 | [diff] [blame] | 263 | printf("Usage:\n%s\n", cmdtp->usage); |
Heiko Schocher | ac1956e | 2006-04-20 08:42:42 +0200 | [diff] [blame] | 264 | rcode = 1; |
| 265 | break; |
| 266 | } |
| 267 | return rcode; |
| 268 | } |
| 269 | |
Jens Scharsig | 772d9b0 | 2009-07-24 10:31:48 +0200 | [diff] [blame] | 270 | /*---------------------------------------------------------------------------*/ |
Heiko Schocher | ac1956e | 2006-04-20 08:42:42 +0200 | [diff] [blame] | 271 | |
| 272 | U_BOOT_CMD( |
Jens Scharsig | 772d9b0 | 2009-07-24 10:31:48 +0200 | [diff] [blame] | 273 | 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 Schocher | ac1956e | 2006-04-20 08:42:42 +0200 | [diff] [blame] | 276 | ); |
| 277 | |
Jens Scharsig | 772d9b0 | 2009-07-24 10:31:48 +0200 | [diff] [blame] | 278 | #endif |
| 279 | |
| 280 | /* EOF EB+MCF-EV123.c */ |