2 * (C) Copyright 2003-2007
7 * modified by Chris M. Tumas 6/20/06 Change CAS latency to 2 from 3
8 * Also changed the refresh for 100Mhz operation
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,
32 #if defined(CONFIG_OF_FLAT_TREE)
36 #if defined(CONFIG_STATUS_LED)
37 #include <status_led.h>
38 #endif /* CONFIG_STATUS_LED */
40 /* Kollmorgen DPR initialization data */
46 {0x500003F2, 2, "\x86\x00"}, /* HW parameter */
47 {0x500003F0, 2, "\x00\x00"},
48 {0x500003EC, 4, "\x00\x80\xc1\x52"}, /* Magic word */
52 * Initialize Kollmorgen DPR
54 static void kollmorgen_init(void)
59 for (i = 0; i < sizeof(init_seq) / sizeof(struct init_elem); ++i) {
60 p = (vu_char *)init_seq[i].addr;
61 for (j = 0; j < init_seq[i].len; ++j)
62 *(p + j) = *(init_seq[i].data + j);
65 printf("DPR: Kollmorgen DPR initialized\n");
70 * Early board initalization.
72 int board_early_init_r(void)
74 /* Now, when we are in RAM, disable Boot Chipselect and enable CS0 */
75 *(vu_long *)MPC5XXX_ADDECR &= ~(1 << 25);
76 *(vu_long *)MPC5XXX_ADDECR |= (1 << 16);
78 /* Initialize Kollmorgen DPR */
87 * Helper function to initialize SDRAM controller.
89 static void sdram_start (int hi_addr)
91 long hi_addr_bit = hi_addr ? 0x01000000 : 0;
93 /* unlock mode register */
94 *(vu_long *)MPC5XXX_SDRAM_CTRL = SDRAM_CONTROL | 0x80000000 |
97 /* precharge all banks */
98 *(vu_long *)MPC5XXX_SDRAM_CTRL = SDRAM_CONTROL | 0x80000002 |
102 *(vu_long *)MPC5XXX_SDRAM_CTRL = SDRAM_CONTROL | 0x80000004 |
105 /* auto refresh, second time */
106 *(vu_long *)MPC5XXX_SDRAM_CTRL = SDRAM_CONTROL | 0x80000004 |
109 /* set mode register */
110 *(vu_long *)MPC5XXX_SDRAM_MODE = SDRAM_MODE;
112 /* normal operation */
113 *(vu_long *)MPC5XXX_SDRAM_CTRL = SDRAM_CONTROL | hi_addr_bit;
115 #endif /* !CFG_RAMBOOT */
119 * Initalize SDRAM - configure SDRAM controller, detect memory size.
121 long int initdram (int board_type)
127 /* configure SDRAM start/end for detection */
128 *(vu_long *)MPC5XXX_SDRAM_CS0CFG = 0x0000001e; /* 2G at 0x0 */
129 *(vu_long *)MPC5XXX_SDRAM_CS1CFG = 0x80000000; /* disabled */
131 /* setup config registers */
132 *(vu_long *)MPC5XXX_SDRAM_CONFIG1 = SDRAM_CONFIG1;
133 *(vu_long *)MPC5XXX_SDRAM_CONFIG2 = SDRAM_CONFIG2;
136 test1 = get_ram_size((long *)CFG_SDRAM_BASE, 0x80000000);
138 test2 = get_ram_size((long *)CFG_SDRAM_BASE, 0x80000000);
146 /* memory smaller than 1MB is impossible */
147 if (dramsize < (1 << 20))
150 /* set SDRAM CS0 size according to the amount of RAM found */
152 *(vu_long *)MPC5XXX_SDRAM_CS0CFG = 0x13 +
153 __builtin_ffs(dramsize >> 20) - 1;
155 *(vu_long *)MPC5XXX_SDRAM_CS0CFG = 0; /* disabled */
157 /* let SDRAM CS1 start right after CS0 and disable it */
158 *(vu_long *) MPC5XXX_SDRAM_CS1CFG = dramsize;
160 #else /* !CFG_RAMBOOT */
161 /* retrieve size of memory connected to SDRAM CS0 */
162 dramsize = *(vu_long *)MPC5XXX_SDRAM_CS0CFG & 0xFF;
163 if (dramsize >= 0x13)
164 dramsize = (1 << (dramsize - 0x13)) << 20;
167 #endif /* CFG_RAMBOOT */
169 /* return total ram size */
174 int checkboard (void)
176 puts("Board: Promess Motion-PRO board\n");
181 #if defined(CONFIG_OF_FLAT_TREE) && defined(CONFIG_OF_BOARD_SETUP)
182 void ft_board_setup(void *blob, bd_t *bd)
184 ft_cpu_setup(blob, bd);
186 #endif /* defined(CONFIG_OF_FLAT_TREE) && defined(CONFIG_OF_BOARD_SETUP) */
189 #if defined(CONFIG_STATUS_LED)
190 void __led_init (led_id_t regaddr, int state)
192 *((vu_long *) regaddr) |= ENABLE_GPIO_OUT;
194 if (state == STATUS_LED_ON)
195 *((vu_long *) regaddr) |= LED_ON;
197 *((vu_long *) regaddr) &= ~LED_ON;
200 void __led_set (led_id_t regaddr, int state)
202 if (state == STATUS_LED_ON)
203 *((vu_long *) regaddr) |= LED_ON;
205 *((vu_long *) regaddr) &= ~LED_ON;
208 void __led_toggle (led_id_t regaddr)
210 *((vu_long *) regaddr) ^= LED_ON;
212 #endif /* CONFIG_STATUS_LED */