Heiko Schocher | 9acb626 | 2006-04-20 08:42:42 +0200 | [diff] [blame] | 1 | /* |
Jens Scharsig | 35cf3b5 | 2009-07-24 10:31:48 +0200 | [diff] [blame] | 2 | * (C) Copyright 2005-2009 |
Heiko Schocher | 9acb626 | 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 | 35cf3b5 | 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 | |
| 38 | unsigned long display_width; |
| 39 | unsigned long display_height; |
| 40 | |
| 41 | /*---------------------------------------------------------------------------*/ |
Heiko Schocher | 9acb626 | 2006-04-20 08:42:42 +0200 | [diff] [blame] | 42 | |
| 43 | int checkboard (void) |
| 44 | { |
| 45 | puts ("Board: MCF-EV1 + MCF-EV23 (BuS Elektronik GmbH & Co. KG)\n"); |
Wolfgang Denk | 14d0a02 | 2010-10-07 21:51:12 +0200 | [diff] [blame] | 46 | #if (CONFIG_SYS_TEXT_BASE == CONFIG_SYS_INT_FLASH_BASE) |
Heiko Schocher | 9acb626 | 2006-04-20 08:42:42 +0200 | [diff] [blame] | 47 | puts (" Boot from Internal FLASH\n"); |
| 48 | #endif |
| 49 | |
| 50 | return 0; |
| 51 | } |
| 52 | |
Becky Bruce | 9973e3c | 2008-06-09 16:03:40 -0500 | [diff] [blame] | 53 | phys_size_t initdram (int board_type) |
Heiko Schocher | 9acb626 | 2006-04-20 08:42:42 +0200 | [diff] [blame] | 54 | { |
Wolfgang Denk | 0fe3405 | 2008-07-14 20:38:26 +0200 | [diff] [blame] | 55 | int size, i; |
Heiko Schocher | 9acb626 | 2006-04-20 08:42:42 +0200 | [diff] [blame] | 56 | |
| 57 | size = 0; |
Wolfgang Denk | 0fe3405 | 2008-07-14 20:38:26 +0200 | [diff] [blame] | 58 | MCFSDRAMC_DCR = MCFSDRAMC_DCR_RTIM_6 |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 59 | | MCFSDRAMC_DCR_RC ((15 * CONFIG_SYS_CLK) >> 4); |
| 60 | #ifdef CONFIG_SYS_SDRAM_BASE0 |
Heiko Schocher | 9acb626 | 2006-04-20 08:42:42 +0200 | [diff] [blame] | 61 | |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 62 | MCFSDRAMC_DACR0 = MCFSDRAMC_DACR_BASE (CONFIG_SYS_SDRAM_BASE0) |
Wolfgang Denk | 0fe3405 | 2008-07-14 20:38:26 +0200 | [diff] [blame] | 63 | | MCFSDRAMC_DACR_CASL (1) |
| 64 | | MCFSDRAMC_DACR_CBM (3) |
| 65 | | MCFSDRAMC_DACR_PS_16; |
Heiko Schocher | 9acb626 | 2006-04-20 08:42:42 +0200 | [diff] [blame] | 66 | |
Wolfgang Denk | 0fe3405 | 2008-07-14 20:38:26 +0200 | [diff] [blame] | 67 | MCFSDRAMC_DMR0 = MCFSDRAMC_DMR_BAM_16M | MCFSDRAMC_DMR_V; |
Heiko Schocher | 9acb626 | 2006-04-20 08:42:42 +0200 | [diff] [blame] | 68 | |
Wolfgang Denk | 0fe3405 | 2008-07-14 20:38:26 +0200 | [diff] [blame] | 69 | MCFSDRAMC_DACR0 |= MCFSDRAMC_DACR_IP; |
Heiko Schocher | 9acb626 | 2006-04-20 08:42:42 +0200 | [diff] [blame] | 70 | |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 71 | *(unsigned short *) (CONFIG_SYS_SDRAM_BASE0) = 0xA5A5; |
Wolfgang Denk | 0fe3405 | 2008-07-14 20:38:26 +0200 | [diff] [blame] | 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); |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 77 | *(unsigned int *) (CONFIG_SYS_SDRAM_BASE0 + 0x220) = 0xA5A5; |
| 78 | size += CONFIG_SYS_SDRAM_SIZE * 1024 * 1024; |
Wolfgang Denk | 0fe3405 | 2008-07-14 20:38:26 +0200 | [diff] [blame] | 79 | #endif |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 80 | #ifdef CONFIG_SYS_SDRAM_BASE1 |
| 81 | MCFSDRAMC_DACR1 = MCFSDRAMC_DACR_BASE (CONFIG_SYS_SDRAM_BASE1) |
Wolfgang Denk | 0fe3405 | 2008-07-14 20:38:26 +0200 | [diff] [blame] | 82 | | MCFSDRAMC_DACR_CASL (1) |
| 83 | | MCFSDRAMC_DACR_CBM (3) |
| 84 | | MCFSDRAMC_DACR_PS_16; |
Heiko Schocher | 9acb626 | 2006-04-20 08:42:42 +0200 | [diff] [blame] | 85 | |
Wolfgang Denk | 0fe3405 | 2008-07-14 20:38:26 +0200 | [diff] [blame] | 86 | MCFSDRAMC_DMR1 = MCFSDRAMC_DMR_BAM_16M | MCFSDRAMC_DMR_V; |
Heiko Schocher | 9acb626 | 2006-04-20 08:42:42 +0200 | [diff] [blame] | 87 | |
Wolfgang Denk | 0fe3405 | 2008-07-14 20:38:26 +0200 | [diff] [blame] | 88 | MCFSDRAMC_DACR1 |= MCFSDRAMC_DACR_IP; |
Heiko Schocher | 9acb626 | 2006-04-20 08:42:42 +0200 | [diff] [blame] | 89 | |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 90 | *(unsigned short *) (CONFIG_SYS_SDRAM_BASE1) = 0xA5A5; |
Wolfgang Denk | 0fe3405 | 2008-07-14 20:38:26 +0200 | [diff] [blame] | 91 | 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-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 97 | *(unsigned int *) (CONFIG_SYS_SDRAM_BASE1 + 0x220) = 0xA5A5; |
| 98 | size += CONFIG_SYS_SDRAM_SIZE1 * 1024 * 1024; |
Wolfgang Denk | 0fe3405 | 2008-07-14 20:38:26 +0200 | [diff] [blame] | 99 | #endif |
Heiko Schocher | 9acb626 | 2006-04-20 08:42:42 +0200 | [diff] [blame] | 100 | return size; |
| 101 | } |
| 102 | |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 103 | #if defined(CONFIG_SYS_DRAM_TEST) |
Heiko Schocher | 9acb626 | 2006-04-20 08:42:42 +0200 | [diff] [blame] | 104 | int testdram (void) |
| 105 | { |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 106 | uint *pstart = (uint *) CONFIG_SYS_MEMTEST_START; |
| 107 | uint *pend = (uint *) CONFIG_SYS_MEMTEST_END; |
Heiko Schocher | 9acb626 | 2006-04-20 08:42:42 +0200 | [diff] [blame] | 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 | { |
Jens Scharsig | 35cf3b5 | 2009-07-24 10:31:48 +0200 | [diff] [blame] | 139 | #ifdef CONFIG_HW_WATCHDOG |
| 140 | hw_watchdog_init(); |
| 141 | #endif |
| 142 | #ifndef CONFIG_VIDEO |
| 143 | vcxk_init(16, 16); |
| 144 | #endif |
Heiko Schocher | 9acb626 | 2006-04-20 08:42:42 +0200 | [diff] [blame] | 145 | return 1; |
| 146 | } |
| 147 | |
Jens Scharsig | 35cf3b5 | 2009-07-24 10:31:48 +0200 | [diff] [blame] | 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 | |
Heiko Schocher | 9acb626 | 2006-04-20 08:42:42 +0200 | [diff] [blame] | 193 | /*---------------------------------------------------------------------------*/ |
| 194 | |
Jens Scharsig | 35cf3b5 | 2009-07-24 10:31:48 +0200 | [diff] [blame] | 195 | #ifdef CONFIG_VIDEO |
Wolfgang Denk | 54841ab | 2010-06-28 22:00:46 +0200 | [diff] [blame] | 196 | int do_brightness(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) |
Heiko Schocher | 9acb626 | 2006-04-20 08:42:42 +0200 | [diff] [blame] | 197 | { |
| 198 | int rcode = 0; |
Jens Scharsig | 35cf3b5 | 2009-07-24 10:31:48 +0200 | [diff] [blame] | 199 | ulong side; |
| 200 | ulong bright; |
Heiko Schocher | 9acb626 | 2006-04-20 08:42:42 +0200 | [diff] [blame] | 201 | |
| 202 | switch (argc) { |
Jens Scharsig | 35cf3b5 | 2009-07-24 10:31:48 +0200 | [diff] [blame] | 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 | } |
Heiko Schocher | 9acb626 | 2006-04-20 08:42:42 +0200 | [diff] [blame] | 215 | break; |
| 216 | default: |
Jens Scharsig | 35cf3b5 | 2009-07-24 10:31:48 +0200 | [diff] [blame] | 217 | printf("Usage:\n%s\n", cmdtp->usage); |
Heiko Schocher | 9acb626 | 2006-04-20 08:42:42 +0200 | [diff] [blame] | 218 | rcode = 1; |
| 219 | break; |
| 220 | } |
| 221 | return rcode; |
| 222 | } |
| 223 | |
Jens Scharsig | 35cf3b5 | 2009-07-24 10:31:48 +0200 | [diff] [blame] | 224 | /*---------------------------------------------------------------------------*/ |
Heiko Schocher | 9acb626 | 2006-04-20 08:42:42 +0200 | [diff] [blame] | 225 | |
| 226 | U_BOOT_CMD( |
Jens Scharsig | 35cf3b5 | 2009-07-24 10:31:48 +0200 | [diff] [blame] | 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" |
Heiko Schocher | 9acb626 | 2006-04-20 08:42:42 +0200 | [diff] [blame] | 230 | ); |
| 231 | |
Jens Scharsig | 35cf3b5 | 2009-07-24 10:31:48 +0200 | [diff] [blame] | 232 | #endif |
| 233 | |
| 234 | /* EOF EB+MCF-EV123.c */ |