wdenk | 16f2170 | 2002-08-26 21:58:50 +0000 | [diff] [blame] | 1 | /* |
| 2 | * (C) Copyright 2000 |
| 3 | * Wolfgang Denk, DENX Software Engineering, wd@denx.de. |
| 4 | * |
Wolfgang Denk | 1a45966 | 2013-07-08 09:37:19 +0200 | [diff] [blame] | 5 | * SPDX-License-Identifier: GPL-2.0+ |
wdenk | 16f2170 | 2002-08-26 21:58:50 +0000 | [diff] [blame] | 6 | * |
| 7 | * Modified By Conn Clark to work with Esteem 192E 7/31/00 |
wdenk | 16f2170 | 2002-08-26 21:58:50 +0000 | [diff] [blame] | 8 | */ |
| 9 | |
| 10 | #include <common.h> |
| 11 | #include <mpc8xx.h> |
| 12 | |
| 13 | /* ------------------------------------------------------------------------- */ |
| 14 | |
wdenk | 16f2170 | 2002-08-26 21:58:50 +0000 | [diff] [blame] | 15 | #define _NOT_USED_ 0xFFFFFFFF |
| 16 | |
wdenk | c83bf6a | 2004-01-06 22:38:14 +0000 | [diff] [blame] | 17 | const uint sdram_table[] = { |
wdenk | 16f2170 | 2002-08-26 21:58:50 +0000 | [diff] [blame] | 18 | /* |
| 19 | * Single Read. (Offset 0 in UPMA RAM) |
| 20 | * |
| 21 | * active, NOP, read, precharge, NOP */ |
| 22 | 0x0F27CC04, 0x0EAECC04, 0x00B98C04, 0x00F74C00, |
wdenk | c83bf6a | 2004-01-06 22:38:14 +0000 | [diff] [blame] | 23 | 0x11FFCC05, /* last */ |
wdenk | 16f2170 | 2002-08-26 21:58:50 +0000 | [diff] [blame] | 24 | /* |
| 25 | * SDRAM Initialization (offset 5 in UPMA RAM) |
| 26 | * |
wdenk | 8bde7f7 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 27 | * This is no UPM entry point. The following definition uses |
| 28 | * the remaining space to establish an initialization |
| 29 | * sequence, which is executed by a RUN command. |
wdenk | 16f2170 | 2002-08-26 21:58:50 +0000 | [diff] [blame] | 30 | * NOP, Program |
| 31 | */ |
wdenk | c83bf6a | 2004-01-06 22:38:14 +0000 | [diff] [blame] | 32 | 0x0F0A8C34, 0x1F354C37, /* last */ |
wdenk | 16f2170 | 2002-08-26 21:58:50 +0000 | [diff] [blame] | 33 | |
wdenk | c83bf6a | 2004-01-06 22:38:14 +0000 | [diff] [blame] | 34 | _NOT_USED_, /* Not used */ |
wdenk | 16f2170 | 2002-08-26 21:58:50 +0000 | [diff] [blame] | 35 | |
| 36 | /* |
| 37 | * Burst Read. (Offset 8 in UPMA RAM) |
| 38 | * active, NOP, read, NOP, NOP, NOP, NOP, NOP */ |
| 39 | 0x0F37CC04, 0x0EFECC04, 0x00FDCC04, 0x00FFCC00, |
wdenk | c83bf6a | 2004-01-06 22:38:14 +0000 | [diff] [blame] | 40 | 0x00FFCC00, 0x01FFCC00, 0x0FFFCC00, 0x1FFFCC05, /* last */ |
wdenk | 16f2170 | 2002-08-26 21:58:50 +0000 | [diff] [blame] | 41 | _NOT_USED_, _NOT_USED_, _NOT_USED_, _NOT_USED_, |
| 42 | _NOT_USED_, _NOT_USED_, _NOT_USED_, _NOT_USED_, |
| 43 | /* |
| 44 | * Single Write. (Offset 18 in UPMA RAM) |
| 45 | * active, NOP, write, NOP, precharge, NOP */ |
| 46 | 0x0F27CC04, 0x0EAE8C00, 0x01BD4C04, 0x0FFB8C04, |
wdenk | c83bf6a | 2004-01-06 22:38:14 +0000 | [diff] [blame] | 47 | 0x0FF74C04, 0x1FFFCC05, /* last */ |
wdenk | 16f2170 | 2002-08-26 21:58:50 +0000 | [diff] [blame] | 48 | _NOT_USED_, _NOT_USED_, |
| 49 | /* |
| 50 | * Burst Write. (Offset 20 in UPMA RAM) |
| 51 | * active, NOP, write, NOP, NOP, NOP, NOP, NOP */ |
| 52 | 0x0F37CC04, 0x0EFE8C00, 0x00FD4C00, 0x00FFCC00, |
wdenk | c83bf6a | 2004-01-06 22:38:14 +0000 | [diff] [blame] | 53 | 0x00FFCC00, 0x01FFCC04, 0x0FFFCC04, 0x1FFFCC05, /* last */ |
wdenk | 16f2170 | 2002-08-26 21:58:50 +0000 | [diff] [blame] | 54 | _NOT_USED_, _NOT_USED_, _NOT_USED_, _NOT_USED_, |
| 55 | _NOT_USED_, _NOT_USED_, _NOT_USED_, _NOT_USED_, |
| 56 | /* |
| 57 | * Refresh (Offset 30 in UPMA RAM) |
| 58 | * precharge, NOP, auto_ref, NOP, NOP, NOP */ |
| 59 | 0x0FF74C34, 0x0FFACCB4, 0x0FF5CC34, 0x0FFFCC34, |
wdenk | c83bf6a | 2004-01-06 22:38:14 +0000 | [diff] [blame] | 60 | 0x0FFFCCB4, 0x1FFFCC35, /* last */ |
| 61 | _NOT_USED_, _NOT_USED_, |
wdenk | 16f2170 | 2002-08-26 21:58:50 +0000 | [diff] [blame] | 62 | _NOT_USED_, _NOT_USED_, _NOT_USED_, _NOT_USED_, |
| 63 | /* |
| 64 | * Exception. (Offset 3c in UPMA RAM) |
| 65 | */ |
wdenk | c83bf6a | 2004-01-06 22:38:14 +0000 | [diff] [blame] | 66 | 0x0FFB8C00, 0x1FF74C03, /* last */ |
| 67 | _NOT_USED_, _NOT_USED_ |
wdenk | 16f2170 | 2002-08-26 21:58:50 +0000 | [diff] [blame] | 68 | }; |
| 69 | |
| 70 | /* ------------------------------------------------------------------------- */ |
| 71 | |
| 72 | |
| 73 | /* |
| 74 | * Check Board Identity: |
| 75 | */ |
| 76 | |
| 77 | int checkboard (void) |
| 78 | { |
wdenk | c83bf6a | 2004-01-06 22:38:14 +0000 | [diff] [blame] | 79 | puts ("Board: Esteem 192E\n"); |
| 80 | return (0); |
wdenk | 16f2170 | 2002-08-26 21:58:50 +0000 | [diff] [blame] | 81 | } |
| 82 | |
| 83 | /* ------------------------------------------------------------------------- */ |
| 84 | |
| 85 | |
Becky Bruce | 9973e3c | 2008-06-09 16:03:40 -0500 | [diff] [blame] | 86 | phys_size_t initdram (int board_type) |
wdenk | 16f2170 | 2002-08-26 21:58:50 +0000 | [diff] [blame] | 87 | { |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 88 | volatile immap_t *immap = (immap_t *) CONFIG_SYS_IMMR; |
wdenk | c83bf6a | 2004-01-06 22:38:14 +0000 | [diff] [blame] | 89 | volatile memctl8xx_t *memctl = &immap->im_memctl; |
| 90 | long int size_b0, size_b1; |
wdenk | 16f2170 | 2002-08-26 21:58:50 +0000 | [diff] [blame] | 91 | |
wdenk | c83bf6a | 2004-01-06 22:38:14 +0000 | [diff] [blame] | 92 | /* |
| 93 | * Explain frequency of refresh here |
| 94 | */ |
wdenk | 16f2170 | 2002-08-26 21:58:50 +0000 | [diff] [blame] | 95 | |
wdenk | c83bf6a | 2004-01-06 22:38:14 +0000 | [diff] [blame] | 96 | memctl->memc_mptpr = 0x0200; /* divide by 32 */ |
wdenk | 16f2170 | 2002-08-26 21:58:50 +0000 | [diff] [blame] | 97 | |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 98 | memctl->memc_mamr = 0x18003112; /*CONFIG_SYS_MAMR_8COL; */ /* 0x18005112 TODO: explain here */ |
wdenk | 16f2170 | 2002-08-26 21:58:50 +0000 | [diff] [blame] | 99 | |
wdenk | c83bf6a | 2004-01-06 22:38:14 +0000 | [diff] [blame] | 100 | upmconfig (UPMA, (uint *) sdram_table, |
| 101 | sizeof (sdram_table) / sizeof (uint)); |
wdenk | 16f2170 | 2002-08-26 21:58:50 +0000 | [diff] [blame] | 102 | |
wdenk | c83bf6a | 2004-01-06 22:38:14 +0000 | [diff] [blame] | 103 | /* |
| 104 | * Map cs 2 and 3 to the SDRAM banks 0 and 1 at |
| 105 | * preliminary addresses - these have to be modified after the |
| 106 | * SDRAM size has been determined. |
| 107 | */ |
wdenk | 16f2170 | 2002-08-26 21:58:50 +0000 | [diff] [blame] | 108 | |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 109 | memctl->memc_or2 = CONFIG_SYS_OR2_PRELIM; /* not defined yet */ |
| 110 | memctl->memc_br2 = CONFIG_SYS_BR2_PRELIM; |
wdenk | 16f2170 | 2002-08-26 21:58:50 +0000 | [diff] [blame] | 111 | |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 112 | memctl->memc_or3 = CONFIG_SYS_OR3_PRELIM; |
| 113 | memctl->memc_br3 = CONFIG_SYS_BR3_PRELIM; |
wdenk | 16f2170 | 2002-08-26 21:58:50 +0000 | [diff] [blame] | 114 | |
| 115 | |
wdenk | c83bf6a | 2004-01-06 22:38:14 +0000 | [diff] [blame] | 116 | /* perform SDRAM initializsation sequence */ |
| 117 | memctl->memc_mar = 0x00000088; |
| 118 | memctl->memc_mcr = 0x80004830; /* SDRAM bank 0 execute 8 refresh */ |
| 119 | memctl->memc_mcr = 0x80004105; /* SDRAM bank 0 */ |
wdenk | 16f2170 | 2002-08-26 21:58:50 +0000 | [diff] [blame] | 120 | |
wdenk | c83bf6a | 2004-01-06 22:38:14 +0000 | [diff] [blame] | 121 | memctl->memc_mcr = 0x80006830; /* SDRAM bank 1 execute 8 refresh */ |
| 122 | memctl->memc_mcr = 0x80006105; /* SDRAM bank 1 */ |
wdenk | 16f2170 | 2002-08-26 21:58:50 +0000 | [diff] [blame] | 123 | |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 124 | memctl->memc_mamr = CONFIG_SYS_MAMR_8COL; /* 0x18803112 start refresh timer TODO: explain here */ |
wdenk | 16f2170 | 2002-08-26 21:58:50 +0000 | [diff] [blame] | 125 | |
| 126 | /* printf ("banks 0 and 1 are programed\n"); */ |
| 127 | |
wdenk | c83bf6a | 2004-01-06 22:38:14 +0000 | [diff] [blame] | 128 | /* |
| 129 | * Check Bank 0 Memory Size for re-configuration |
| 130 | * |
| 131 | */ |
Wolfgang Denk | 77ddac9 | 2005-10-13 16:45:02 +0200 | [diff] [blame] | 132 | size_b0 = get_ram_size ( (long *)SDRAM_BASE2_PRELIM, SDRAM_MAX_SIZE); |
| 133 | size_b1 = get_ram_size ( (long *)SDRAM_BASE3_PRELIM, SDRAM_MAX_SIZE); |
wdenk | 16f2170 | 2002-08-26 21:58:50 +0000 | [diff] [blame] | 134 | |
wdenk | c83bf6a | 2004-01-06 22:38:14 +0000 | [diff] [blame] | 135 | printf ("\nbank 0 size %lu\nbank 1 size %lu\n", size_b0, size_b1); |
wdenk | 16f2170 | 2002-08-26 21:58:50 +0000 | [diff] [blame] | 136 | |
| 137 | /* printf ("bank 1 size %u\n",size_b1); */ |
| 138 | |
wdenk | c83bf6a | 2004-01-06 22:38:14 +0000 | [diff] [blame] | 139 | if (size_b1 == 0) { |
| 140 | /* |
| 141 | * Adjust refresh rate if bank 0 isn't stuffed |
| 142 | */ |
| 143 | memctl->memc_mptpr = 0x0400; /* divide by 64 */ |
| 144 | memctl->memc_br3 &= 0x0FFFFFFFE; |
wdenk | 16f2170 | 2002-08-26 21:58:50 +0000 | [diff] [blame] | 145 | |
wdenk | c83bf6a | 2004-01-06 22:38:14 +0000 | [diff] [blame] | 146 | /* |
| 147 | * Adjust OR2 for size of bank 0 |
| 148 | */ |
| 149 | memctl->memc_or2 |= 7 * size_b0; |
| 150 | } else { |
| 151 | if (size_b0 < size_b1) { |
| 152 | memctl->memc_br2 &= 0x00007FFE; |
| 153 | memctl->memc_br3 &= 0x00007FFF; |
wdenk | 16f2170 | 2002-08-26 21:58:50 +0000 | [diff] [blame] | 154 | |
wdenk | c83bf6a | 2004-01-06 22:38:14 +0000 | [diff] [blame] | 155 | /* |
| 156 | * Adjust OR3 for size of bank 1 |
| 157 | */ |
| 158 | memctl->memc_or3 |= 15 * size_b1; |
wdenk | 16f2170 | 2002-08-26 21:58:50 +0000 | [diff] [blame] | 159 | |
wdenk | c83bf6a | 2004-01-06 22:38:14 +0000 | [diff] [blame] | 160 | /* |
| 161 | * Adjust OR2 for size of bank 0 |
| 162 | */ |
| 163 | memctl->memc_or2 |= 15 * size_b0; |
| 164 | memctl->memc_br2 += (size_b1 + 1); |
| 165 | } else { |
| 166 | memctl->memc_br3 &= 0x00007FFE; |
wdenk | 16f2170 | 2002-08-26 21:58:50 +0000 | [diff] [blame] | 167 | |
wdenk | c83bf6a | 2004-01-06 22:38:14 +0000 | [diff] [blame] | 168 | /* |
| 169 | * Adjust OR2 for size of bank 0 |
| 170 | */ |
| 171 | memctl->memc_or2 |= 15 * size_b0; |
wdenk | 16f2170 | 2002-08-26 21:58:50 +0000 | [diff] [blame] | 172 | |
wdenk | c83bf6a | 2004-01-06 22:38:14 +0000 | [diff] [blame] | 173 | /* |
| 174 | * Adjust OR3 for size of bank 1 |
| 175 | */ |
| 176 | memctl->memc_or3 |= 15 * size_b1; |
| 177 | memctl->memc_br3 += (size_b0 + 1); |
| 178 | } |
wdenk | 16f2170 | 2002-08-26 21:58:50 +0000 | [diff] [blame] | 179 | } |
wdenk | c83bf6a | 2004-01-06 22:38:14 +0000 | [diff] [blame] | 180 | |
| 181 | /* before leaving set all unused i/o pins to outputs */ |
| 182 | |
| 183 | /* |
| 184 | * --*Unused Pin List*-- |
| 185 | * |
| 186 | * group/port bit number |
| 187 | * IP_B 0,1,3,4,5 Taken care of in pcmcia-cs-x.x.xx |
| 188 | * PA 5,7,8,9,14,15 |
| 189 | * PB 22,23,31 |
| 190 | * PC 4,5,6,7,10,11,12,13,14,15 |
| 191 | * PD 5,6,7 |
| 192 | * |
| 193 | */ |
| 194 | |
| 195 | /* |
| 196 | * --*Pin Used for I/O List*-- |
| 197 | * |
| 198 | * port input bit number output bit number either |
| 199 | * PB 18,26,27 |
| 200 | * PD 3,4 8,9,10,11,12,13,14,15 |
| 201 | * |
| 202 | */ |
| 203 | |
| 204 | immap->im_ioport.iop_papar &= ~0x05C3; /* set pins as io */ |
| 205 | immap->im_ioport.iop_padir |= 0x05C3; /* set pins as output */ |
| 206 | immap->im_ioport.iop_paodr &= 0x0008; /* config pins 9 & 14 as normal outputs */ |
| 207 | immap->im_ioport.iop_padat |= 0x05C3; /* set unused pins as high */ |
| 208 | |
| 209 | immap->im_cpm.cp_pbpar &= ~0x00001331; /* set unused port b pins as io */ |
| 210 | immap->im_cpm.cp_pbdir |= 0x00001331; /* set unused port b pins as output */ |
| 211 | immap->im_cpm.cp_pbodr &= ~0x00001331; /* config bits 18,22,23,26,27 & 31 as normal outputs */ |
| 212 | immap->im_cpm.cp_pbdat |= 0x00001331; /* set T/E LED, /NV_CS, & /POWER_ADJ_CS and the rest to a high */ |
| 213 | |
| 214 | immap->im_ioport.iop_pcpar &= ~0x0F3F; /* set unused port c pins as io */ |
| 215 | immap->im_ioport.iop_pcdir |= 0x0F3F; /* set unused port c pins as output */ |
| 216 | immap->im_ioport.iop_pcso &= ~0x0F3F; /* clear special purpose bit for unused port c pins for clarity */ |
| 217 | immap->im_ioport.iop_pcdat |= 0x0F3F; /* set unused port c pins high */ |
| 218 | |
| 219 | immap->im_ioport.iop_pdpar &= 0xE000; /* set pins as io */ |
| 220 | immap->im_ioport.iop_pddir &= 0xE000; /* set bit 3 & 4 as inputs */ |
| 221 | immap->im_ioport.iop_pddir |= 0x07FF; /* set bits 5 - 15 as outputs */ |
| 222 | immap->im_ioport.iop_pddat = 0x0055; /* set alternating pattern on test port */ |
| 223 | |
| 224 | return (size_b0 + size_b1); |
wdenk | 16f2170 | 2002-08-26 21:58:50 +0000 | [diff] [blame] | 225 | } |