wdenk | c8434db | 2003-03-26 06:55:25 +0000 | [diff] [blame] | 1 | /* |
| 2 | * (C) Copyright 2000, 2001, 2002 |
| 3 | * Wolfgang Denk, DENX Software Engineering, wd@denx.de. |
| 4 | * |
| 5 | * See file CREDITS for list of people who contributed to this |
| 6 | * project. |
| 7 | * |
| 8 | * This program is free software; you can redistribute it and/or |
| 9 | * modify it under the terms of the GNU General Public License as |
| 10 | * published by the Free Software Foundation; either version 2 of |
| 11 | * the License, or (at your option) any later version. |
| 12 | * |
| 13 | * This program is distributed in the hope that it will be useful, |
| 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 16 | * GNU General Public License for more details. |
| 17 | * |
| 18 | * You should have received a copy of the GNU General Public License |
| 19 | * along with this program; if not, write to the Free Software |
| 20 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, |
| 21 | * MA 02111-1307 USA |
| 22 | */ |
| 23 | |
| 24 | #include <common.h> |
| 25 | #include <mpc8xx.h> |
| 26 | |
| 27 | /* ------------------------------------------------------------------------- */ |
| 28 | const uint sdram_table[] = |
| 29 | { |
| 30 | /*----------------- |
| 31 | UPM A contents: |
| 32 | ----------------- */ |
| 33 | /*--------------------------------------------------- |
| 34 | Read Single Beat Cycle. Offset 0 in the RAM array. |
| 35 | ---------------------------------------------------- */ |
| 36 | 0x1f07fc04, 0xeeaefc04, 0x11adfc04, 0xefbbbc00 , |
| 37 | 0x1ff77c47, 0x1ff77c35, 0xefeabc34, 0x1fb57c35 , |
| 38 | /*------------------------------------------------ |
| 39 | Read Burst Cycle. Offset 0x8 in the RAM array. |
| 40 | ------------------------------------------------ */ |
| 41 | 0x1f07fc04, 0xeeaefc04, 0x10adfc04, 0xf0affc00, |
| 42 | 0xf0affc00, 0xf1affc00, 0xefbbbc00, 0x1ff77c47, |
| 43 | 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, |
| 44 | 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, |
| 45 | /*------------------------------------------------------- |
| 46 | Write Single Beat Cycle. Offset 0x18 in the RAM array |
| 47 | ------------------------------------------------------- */ |
| 48 | 0x1f27fc04, 0xeeaebc00, 0x01b93c04, 0x1ff77c47 , |
| 49 | 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff , |
| 50 | /*------------------------------------------------- |
| 51 | Write Burst Cycle. Offset 0x20 in the RAM array |
| 52 | ------------------------------------------------- */ |
| 53 | 0x1f07fc04, 0xeeaebc00, 0x10ad7c00, 0xf0affc00, |
| 54 | 0xf0affc00, 0xe1bbbc04, 0x1ff77c47, 0xffffffff, |
| 55 | 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff , |
| 56 | 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff , |
| 57 | /*------------------------------------------------------------------------ |
| 58 | Periodic Timer Expired. For DRAM refresh. Offset 0x30 in the RAM array |
| 59 | ------------------------------------------------------------------------ */ |
| 60 | 0x1ff5fc84, 0xfffffc04, 0xfffffc04, 0xfffffc04, |
| 61 | 0xfffffc84, 0xfffffc07, 0xffffffff, 0xffffffff, |
| 62 | 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff , |
| 63 | /*----------- |
| 64 | * Exception: |
| 65 | * ----------- */ |
| 66 | 0x7ffefc07, 0xffffffff, 0xffffffff, 0xffffffff , |
| 67 | }; |
| 68 | |
| 69 | /* ------------------------------------------------------------------------- */ |
| 70 | /* |
| 71 | * Check Board Identity: |
| 72 | * |
| 73 | * Test ID string (SVM8...) |
| 74 | * |
| 75 | * Return 1 for "SC8xx" type, 0 else. |
| 76 | */ |
| 77 | |
Wolfgang Denk | 5c1cfee | 2011-05-04 10:32:28 +0000 | [diff] [blame] | 78 | int checkboard(void) |
wdenk | c8434db | 2003-03-26 06:55:25 +0000 | [diff] [blame] | 79 | { |
Wolfgang Denk | 5c1cfee | 2011-05-04 10:32:28 +0000 | [diff] [blame] | 80 | char buf[64]; |
| 81 | int i; |
| 82 | int l = getenv_f("serial#", buf, sizeof(buf)); |
wdenk | c8434db | 2003-03-26 06:55:25 +0000 | [diff] [blame] | 83 | |
Wolfgang Denk | 5c1cfee | 2011-05-04 10:32:28 +0000 | [diff] [blame] | 84 | if (l < 0 || strncmp(buf, "SVM8", 4)) { |
| 85 | printf("### No HW ID - assuming SVM SC8xx\n"); |
| 86 | return (0); |
| 87 | } |
wdenk | c8434db | 2003-03-26 06:55:25 +0000 | [diff] [blame] | 88 | |
Wolfgang Denk | 5c1cfee | 2011-05-04 10:32:28 +0000 | [diff] [blame] | 89 | for (i = 0; i < l; ++i) { |
| 90 | if (buf[i] == ' ') |
| 91 | break; |
| 92 | putc(buf[i]); |
| 93 | } |
wdenk | c8434db | 2003-03-26 06:55:25 +0000 | [diff] [blame] | 94 | |
Wolfgang Denk | 5c1cfee | 2011-05-04 10:32:28 +0000 | [diff] [blame] | 95 | putc('\n'); |
wdenk | c8434db | 2003-03-26 06:55:25 +0000 | [diff] [blame] | 96 | |
Wolfgang Denk | e5999e4 | 2011-11-04 15:55:48 +0000 | [diff] [blame^] | 97 | return 0; |
wdenk | c8434db | 2003-03-26 06:55:25 +0000 | [diff] [blame] | 98 | } |
| 99 | |
| 100 | /* ------------------------------------------------------------------------- */ |
| 101 | |
Becky Bruce | bd99ae7 | 2008-06-09 16:03:40 -0500 | [diff] [blame] | 102 | phys_size_t initdram (int board_type) |
wdenk | 57b2d80 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 103 | { |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 104 | volatile immap_t *immap = (immap_t *)CONFIG_SYS_IMMR; |
wdenk | c8434db | 2003-03-26 06:55:25 +0000 | [diff] [blame] | 105 | volatile memctl8xx_t *memctl = &immap->im_memctl; |
| 106 | long int size_b0 = 0; |
| 107 | |
| 108 | upmconfig(UPMA, (uint *)sdram_table, sizeof(sdram_table)/sizeof(uint)); |
| 109 | |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 110 | memctl->memc_mptpr = CONFIG_SYS_MPTPR; |
wdenk | c8434db | 2003-03-26 06:55:25 +0000 | [diff] [blame] | 111 | #if defined (CONFIG_SDRAM_16M) |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 112 | memctl->memc_mamr = 0x00802114 | CONFIG_SYS_MxMR_PTx; |
wdenk | c8434db | 2003-03-26 06:55:25 +0000 | [diff] [blame] | 113 | memctl->memc_mcr = 0x80002105; /* SDRAM bank 0 */ |
| 114 | udelay(1); |
| 115 | memctl->memc_mcr = 0x80002830; |
| 116 | udelay(1); |
| 117 | memctl->memc_mar = 0x00000088; |
| 118 | udelay(1); |
| 119 | memctl->memc_mcr = 0x80002106; |
| 120 | udelay(1); |
| 121 | memctl->memc_or1 = 0xff000a00; |
| 122 | size_b0 = 0x01000000; |
| 123 | #elif defined (CONFIG_SDRAM_32M) |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 124 | memctl->memc_mamr = 0x00904114 | CONFIG_SYS_MxMR_PTx; |
wdenk | c8434db | 2003-03-26 06:55:25 +0000 | [diff] [blame] | 125 | memctl->memc_mcr = 0x80002105; /* SDRAM bank 0 */ |
| 126 | udelay(1); |
| 127 | memctl->memc_mcr = 0x80002830; |
| 128 | udelay(1); |
| 129 | memctl->memc_mar = 0x00000088; |
| 130 | udelay(1); |
| 131 | memctl->memc_mcr = 0x80002106; |
| 132 | udelay(1); |
| 133 | memctl->memc_or1 = 0xfe000a00; |
| 134 | size_b0 = 0x02000000; |
| 135 | #elif defined (CONFIG_SDRAM_64M) |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 136 | memctl->memc_mamr = 0x00a04114 | CONFIG_SYS_MxMR_PTx; |
wdenk | c8434db | 2003-03-26 06:55:25 +0000 | [diff] [blame] | 137 | memctl->memc_mcr = 0x80002105; /* SDRAM bank 0 */ |
| 138 | udelay(1); |
| 139 | memctl->memc_mcr = 0x80002830; |
| 140 | udelay(1); |
| 141 | memctl->memc_mar = 0x00000088; |
| 142 | udelay(1); |
| 143 | memctl->memc_mcr = 0x80002106; |
| 144 | udelay(1); |
| 145 | memctl->memc_or1 = 0xfc000a00; |
| 146 | size_b0 = 0x04000000; |
wdenk | 57b2d80 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 147 | #else |
wdenk | c8434db | 2003-03-26 06:55:25 +0000 | [diff] [blame] | 148 | #error SDRAM size configuration missing. |
| 149 | #endif |
| 150 | memctl->memc_br1 = 0x00000081; |
| 151 | udelay(200); |
| 152 | return (size_b0 ); |
| 153 | } |
| 154 | |
Jon Loeliger | e11c123 | 2007-07-09 18:45:16 -0500 | [diff] [blame] | 155 | #if defined(CONFIG_CMD_DOC) |
wdenk | c8434db | 2003-03-26 06:55:25 +0000 | [diff] [blame] | 156 | void doc_init (void) |
| 157 | { |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 158 | doc_probe (CONFIG_SYS_DOC_BASE); |
wdenk | c8434db | 2003-03-26 06:55:25 +0000 | [diff] [blame] | 159 | } |
| 160 | #endif |