3 * Stäubli Faverges - <www.staubli.com>
4 * Pierre AUBERT p.aubert@staubli.com
5 * U-Boot port on RPXClassic LF (CLLF_BW31) board
8 * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
10 * See file CREDITS for list of people who contributed to this
13 * This program is free software; you can redistribute it and/or
14 * modify it under the terms of the GNU General Public License as
15 * published by the Free Software Foundation; either version 2 of
16 * the License, or (at your option) any later version.
18 * This program is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU General Public License for more details.
23 * You should have received a copy of the GNU General Public License
24 * along with this program; if not, write to the Free Software
25 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
35 /* ------------------------------------------------------------------------- */
37 static long int dram_size (long int, long int *, long int);
38 static unsigned char aschex_to_byte (unsigned char *cp);
40 /* ------------------------------------------------------------------------- */
42 #define _NOT_USED_ 0xFFFFCC25
44 const uint sdram_table[] =
47 * Single Read. (Offset 00h in UPMA RAM)
49 0xCFFFCC24, 0x0FFFCC04, 0X0CAFCC04, 0X03AFCC08,
50 0x3FBFCC27, /* last */
51 _NOT_USED_, _NOT_USED_, _NOT_USED_,
54 * Burst Read. (Offset 08h in UPMA RAM)
56 0xCFFFCC24, 0x0FFFCC04, 0x0CAFCC84, 0x03AFCC88,
57 0x3FBFCC27, /* last */
58 _NOT_USED_, _NOT_USED_, _NOT_USED_, _NOT_USED_,
59 _NOT_USED_, _NOT_USED_, _NOT_USED_, _NOT_USED_,
60 _NOT_USED_, _NOT_USED_, _NOT_USED_,
63 * Single Write. (Offset 18h in UPMA RAM)
65 0xCFFFCC24, 0x0FFFCC04, 0x0CFFCC04, 0x03FFCC00,
66 0x3FFFCC27, /* last */
67 _NOT_USED_, _NOT_USED_, _NOT_USED_,
70 * Burst Write. (Offset 20h in UPMA RAM)
72 0xCFFFCC24, 0x0FFFCC04, 0x0CFFCC80, 0x03FFCC8C,
73 0x0CFFCC00, 0x33FFCC27, /* last */
74 _NOT_USED_, _NOT_USED_, _NOT_USED_, _NOT_USED_,
75 _NOT_USED_, _NOT_USED_, _NOT_USED_, _NOT_USED_,
76 _NOT_USED_, _NOT_USED_,
79 * Refresh. (Offset 30h in UPMA RAM)
81 0xC0FFCC24, 0x03FFCC24, 0x0FFFCC24, 0x0FFFCC24,
82 0x3FFFCC27, /* last */
83 _NOT_USED_, _NOT_USED_, _NOT_USED_, _NOT_USED_,
84 _NOT_USED_, _NOT_USED_, _NOT_USED_,
87 * Exception. (Offset 3Ch in UPMA RAM)
89 _NOT_USED_, _NOT_USED_, _NOT_USED_, _NOT_USED_
92 /* ------------------------------------------------------------------------- */
96 * Check Board Identity:
101 puts ("Board: RPXClassic\n");
105 /*-----------------------------------------------------------------------------
106 * board_get_enetaddr -- Read the MAC Address in the I2C EEPROM
107 *-----------------------------------------------------------------------------
109 static void board_get_enetaddr(uchar *enet)
115 i2c_init (CONFIG_SYS_I2C_SPEED, CONFIG_SYS_I2C_SLAVE);
117 /* Read 256 bytes in EEPROM */
118 i2c_read (0x54, 0, 1, (uchar *)buff, 128);
119 i2c_read (0x54, 128, 1, (uchar *)buff + 128, 128);
121 /* Retrieve MAC address in buffer (key EA) */
123 if (cp[0] == 'E' && cp[1] == 'A') {
125 /* Read MAC address */
126 for (i = 0; i < 6; i++, cp += 2) {
127 enet[i] = aschex_to_byte ((unsigned char *)cp);
130 /* Scan to the end of the record */
131 while ((*cp != '\n') && (*cp != (char)0xff)) {
134 /* If the next character is a \n, 0 or ff, we are done. */
136 if ((*cp == '\n') || (*cp == 0) || (*cp == (char)0xff))
140 #ifdef CONFIG_FEC_ENET
141 /* The MAC address is the same as normal ethernet except the 3rd byte */
142 /* (See the E.P. Planet Core Overview manual */
146 printf("MAC address = %pM\n", enet);
149 int misc_init_r(void)
153 if (!eth_getenv_enetaddr("ethaddr", enetaddr)) {
154 board_get_enetaddr(enetaddr);
155 eth_setenv_enetaddr("ethaddr", enetaddr);
161 void rpxclassic_init (void)
164 *((uchar *) BCSR0) |= BCSR0_ENNVRAM;
166 #ifdef CONFIG_FEC_ENET
168 /* Validate the fast ethernet tranceiver */
169 *((volatile uchar *) BCSR2) &= ~BCSR2_MIICTL;
170 *((volatile uchar *) BCSR2) &= ~BCSR2_MIIPWRDWN;
171 *((volatile uchar *) BCSR2) |= BCSR2_MIIRST;
172 *((volatile uchar *) BCSR2) |= BCSR2_MIIPWRDWN;
177 /* ------------------------------------------------------------------------- */
179 phys_size_t initdram (int board_type)
181 volatile immap_t *immap = (immap_t *) CONFIG_SYS_IMMR;
182 volatile memctl8xx_t *memctl = &immap->im_memctl;
185 upmconfig (UPMA, (uint *) sdram_table,
186 sizeof (sdram_table) / sizeof (uint));
188 /* Refresh clock prescalar */
189 memctl->memc_mptpr = CONFIG_SYS_MPTPR;
191 memctl->memc_mar = 0x00000000;
193 /* Map controller banks 1 to the SDRAM bank */
194 memctl->memc_or1 = CONFIG_SYS_OR1_PRELIM;
195 memctl->memc_br1 = CONFIG_SYS_BR1_PRELIM;
197 memctl->memc_mamr = CONFIG_SYS_MAMR_10COL & (~(MAMR_PTAE)); /* no refresh yet */
201 /* perform SDRAM initializsation sequence */
203 memctl->memc_mcr = 0x80002230; /* SDRAM bank 0 - refresh twice */
206 memctl->memc_mamr |= MAMR_PTAE; /* enable refresh */
210 /* Check Bank 0 Memory Size
214 size10 = dram_size (CONFIG_SYS_MAMR_10COL, SDRAM_BASE_PRELIM,
220 /* ------------------------------------------------------------------------- */
223 * Check memory range for valid RAM. A simple memory test determines
224 * the actually available RAM size between addresses `base' and
225 * `base + maxsize'. Some (not all) hardware errors are detected:
226 * - short between address lines
227 * - short between data lines
230 static long int dram_size (long int mamr_value, long int *base, long int maxsize)
232 volatile immap_t *immap = (immap_t *) CONFIG_SYS_IMMR;
233 volatile memctl8xx_t *memctl = &immap->im_memctl;
235 memctl->memc_mamr = mamr_value;
237 return (get_ram_size(base, maxsize));
239 /*-----------------------------------------------------------------------------
241 *-----------------------------------------------------------------------------
243 static unsigned char aschex_to_byte (unsigned char *cp)
249 if ((c >= 'A') && (c <= 'F')) {
252 } else if ((c >= 'a') && (c <= 'f')) {
263 if ((c >= 'A') && (c <= 'F')) {
266 } else if ((c >= 'a') && (c <= 'f')) {