Heiko Schocher | ac1956e | 2006-04-20 08:42:42 +0200 | [diff] [blame] | 1 | /* |
| 2 | * (C) Copyright 2005 |
| 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 "VCxK.h" |
| 31 | |
| 32 | int checkboard (void) |
| 33 | { |
| 34 | puts ("Board: MCF-EV1 + MCF-EV23 (BuS Elektronik GmbH & Co. KG)\n"); |
| 35 | #if (TEXT_BASE == CFG_INT_FLASH_BASE) |
| 36 | puts (" Boot from Internal FLASH\n"); |
| 37 | #endif |
| 38 | |
| 39 | return 0; |
| 40 | } |
| 41 | |
Becky Bruce | bd99ae7 | 2008-06-09 16:03:40 -0500 | [diff] [blame] | 42 | phys_size_t initdram (int board_type) |
Heiko Schocher | ac1956e | 2006-04-20 08:42:42 +0200 | [diff] [blame] | 43 | { |
Wolfgang Denk | c4f55ee | 2008-07-14 20:38:26 +0200 | [diff] [blame] | 44 | int size, i; |
Heiko Schocher | ac1956e | 2006-04-20 08:42:42 +0200 | [diff] [blame] | 45 | |
| 46 | size = 0; |
Wolfgang Denk | c4f55ee | 2008-07-14 20:38:26 +0200 | [diff] [blame] | 47 | MCFSDRAMC_DCR = MCFSDRAMC_DCR_RTIM_6 |
| 48 | | MCFSDRAMC_DCR_RC ((15 * CFG_CLK) >> 4); |
| 49 | #ifdef CFG_SDRAM_BASE0 |
Heiko Schocher | ac1956e | 2006-04-20 08:42:42 +0200 | [diff] [blame] | 50 | |
Wolfgang Denk | c4f55ee | 2008-07-14 20:38:26 +0200 | [diff] [blame] | 51 | MCFSDRAMC_DACR0 = MCFSDRAMC_DACR_BASE (CFG_SDRAM_BASE0) |
| 52 | | MCFSDRAMC_DACR_CASL (1) |
| 53 | | MCFSDRAMC_DACR_CBM (3) |
| 54 | | MCFSDRAMC_DACR_PS_16; |
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 | MCFSDRAMC_DMR0 = MCFSDRAMC_DMR_BAM_16M | MCFSDRAMC_DMR_V; |
Heiko Schocher | ac1956e | 2006-04-20 08:42:42 +0200 | [diff] [blame] | 57 | |
Wolfgang Denk | c4f55ee | 2008-07-14 20:38:26 +0200 | [diff] [blame] | 58 | MCFSDRAMC_DACR0 |= MCFSDRAMC_DACR_IP; |
Heiko Schocher | ac1956e | 2006-04-20 08:42:42 +0200 | [diff] [blame] | 59 | |
Wolfgang Denk | c4f55ee | 2008-07-14 20:38:26 +0200 | [diff] [blame] | 60 | *(unsigned short *) (CFG_SDRAM_BASE0) = 0xA5A5; |
| 61 | MCFSDRAMC_DACR0 |= MCFSDRAMC_DACR_RE; |
| 62 | for (i = 0; i < 2000; i++) |
| 63 | asm (" nop"); |
| 64 | mbar_writeLong (MCFSDRAMC_DACR0, |
| 65 | mbar_readLong (MCFSDRAMC_DACR0) | MCFSDRAMC_DACR_IMRS); |
| 66 | *(unsigned int *) (CFG_SDRAM_BASE0 + 0x220) = 0xA5A5; |
| 67 | size += CFG_SDRAM_SIZE * 1024 * 1024; |
| 68 | #endif |
| 69 | #ifdef CFG_SDRAM_BASE1 |
| 70 | MCFSDRAMC_DACR1 = MCFSDRAMC_DACR_BASE (CFG_SDRAM_BASE1) |
| 71 | | MCFSDRAMC_DACR_CASL (1) |
| 72 | | MCFSDRAMC_DACR_CBM (3) |
| 73 | | MCFSDRAMC_DACR_PS_16; |
Heiko Schocher | ac1956e | 2006-04-20 08:42:42 +0200 | [diff] [blame] | 74 | |
Wolfgang Denk | c4f55ee | 2008-07-14 20:38:26 +0200 | [diff] [blame] | 75 | MCFSDRAMC_DMR1 = MCFSDRAMC_DMR_BAM_16M | MCFSDRAMC_DMR_V; |
Heiko Schocher | ac1956e | 2006-04-20 08:42:42 +0200 | [diff] [blame] | 76 | |
Wolfgang Denk | c4f55ee | 2008-07-14 20:38:26 +0200 | [diff] [blame] | 77 | MCFSDRAMC_DACR1 |= MCFSDRAMC_DACR_IP; |
| 78 | |
| 79 | *(unsigned short *) (CFG_SDRAM_BASE1) = 0xA5A5; |
| 80 | MCFSDRAMC_DACR1 |= MCFSDRAMC_DACR_RE; |
| 81 | |
| 82 | for (i = 0; i < 2000; i++) |
| 83 | asm (" nop"); |
Heiko Schocher | ac1956e | 2006-04-20 08:42:42 +0200 | [diff] [blame] | 84 | |
Wolfgang Denk | c4f55ee | 2008-07-14 20:38:26 +0200 | [diff] [blame] | 85 | MCFSDRAMC_DACR1 |= MCFSDRAMC_DACR_IMRS; |
| 86 | *(unsigned int *) (CFG_SDRAM_BASE1 + 0x220) = 0xA5A5; |
| 87 | size += CFG_SDRAM_SIZE1 * 1024 * 1024; |
| 88 | #endif |
Heiko Schocher | ac1956e | 2006-04-20 08:42:42 +0200 | [diff] [blame] | 89 | return size; |
| 90 | } |
| 91 | |
| 92 | |
| 93 | #if defined(CFG_DRAM_TEST) |
| 94 | int testdram (void) |
| 95 | { |
| 96 | uint *pstart = (uint *) CFG_MEMTEST_START; |
| 97 | uint *pend = (uint *) CFG_MEMTEST_END; |
| 98 | uint *p; |
| 99 | |
| 100 | printf("SDRAM test phase 1:\n"); |
| 101 | for (p = pstart; p < pend; p++) |
| 102 | *p = 0xaaaaaaaa; |
| 103 | |
| 104 | for (p = pstart; p < pend; p++) { |
| 105 | if (*p != 0xaaaaaaaa) { |
| 106 | printf ("SDRAM test fails at: %08x\n", (uint) p); |
| 107 | return 1; |
| 108 | } |
| 109 | } |
| 110 | |
| 111 | printf("SDRAM test phase 2:\n"); |
| 112 | for (p = pstart; p < pend; p++) |
| 113 | *p = 0x55555555; |
| 114 | |
| 115 | for (p = pstart; p < pend; p++) { |
| 116 | if (*p != 0x55555555) { |
| 117 | printf ("SDRAM test fails at: %08x\n", (uint) p); |
| 118 | return 1; |
| 119 | } |
| 120 | } |
| 121 | |
| 122 | printf("SDRAM test passed.\n"); |
| 123 | return 0; |
| 124 | } |
| 125 | #endif |
| 126 | |
| 127 | int misc_init_r(void) |
| 128 | { |
| 129 | init_vcxk(); |
| 130 | return 1; |
| 131 | } |
| 132 | |
| 133 | /*---------------------------------------------------------------------------*/ |
| 134 | |
| 135 | int do_vcimage (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) |
| 136 | { |
| 137 | int rcode = 0; |
| 138 | ulong source; |
| 139 | |
| 140 | switch (argc) { |
| 141 | case 2: |
| 142 | source = simple_strtoul(argv[1],NULL,16); |
| 143 | vcxk_loadimage(source); |
| 144 | rcode = 0; |
| 145 | break; |
| 146 | default: |
| 147 | printf ("Usage:\n%s\n", cmdtp->usage); |
| 148 | rcode = 1; |
| 149 | break; |
| 150 | } |
| 151 | return rcode; |
| 152 | } |
| 153 | |
| 154 | /***************************************************/ |
| 155 | |
| 156 | U_BOOT_CMD( |
| 157 | vcimage, 2, 0, do_vcimage, |
| 158 | "vcimage - loads an image to Display\n", |
| 159 | "vcimage addr\n" |
| 160 | ); |
| 161 | |
| 162 | /* EOF EB+MCF-EV123c */ |