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 * SPDX-License-Identifier: GPL-2.0+
18 #if defined(CONFIG_STATUS_LED)
19 #include <status_led.h>
20 #endif /* CONFIG_STATUS_LED */
22 /* Kollmorgen DPR initialization data */
28 {0x500003F2, 2, "\x86\x00"}, /* HW parameter */
29 {0x500003F0, 2, "\x00\x00"},
30 {0x500003EC, 4, "\x00\x80\xc1\x52"}, /* Magic word */
34 * Initialize Kollmorgen DPR
36 static void kollmorgen_init(void)
41 for (i = 0; i < sizeof(init_seq) / sizeof(struct init_elem); ++i) {
42 p = (vu_char *)init_seq[i].addr;
43 for (j = 0; j < init_seq[i].len; ++j)
44 *(p + j) = *(init_seq[i].data + j);
47 printf("DPR: Kollmorgen DPR initialized\n");
52 * Early board initalization.
54 int board_early_init_r(void)
56 /* Now, when we are in RAM, disable Boot Chipselect and enable CS0 */
57 *(vu_long *)MPC5XXX_ADDECR &= ~(1 << 25);
58 *(vu_long *)MPC5XXX_ADDECR |= (1 << 16);
60 /* Initialize Kollmorgen DPR */
68 * Additional PHY intialization. After being reset in mpc5xxx_fec_init_phy(),
69 * PHY goes into FX mode. To take it out of the FX mode and switch into
70 * desired TX operation, one needs to clear the FX_SEL bit of Mode Control
75 unsigned short mode_control;
77 miiphy_read("FEC", CONFIG_PHY_ADDR, 0x15, &mode_control);
78 miiphy_write("FEC", CONFIG_PHY_ADDR, 0x15,
79 mode_control & 0xfffe);
83 #ifndef CONFIG_SYS_RAMBOOT
85 * Helper function to initialize SDRAM controller.
87 static void sdram_start(int hi_addr)
89 long hi_addr_bit = hi_addr ? 0x01000000 : 0;
91 /* unlock mode register */
92 *(vu_long *)MPC5XXX_SDRAM_CTRL = SDRAM_CONTROL | 0x80000000 |
95 /* precharge all banks */
96 *(vu_long *)MPC5XXX_SDRAM_CTRL = SDRAM_CONTROL | 0x80000002 |
100 *(vu_long *)MPC5XXX_SDRAM_CTRL = SDRAM_CONTROL | 0x80000004 |
103 /* auto refresh, second time */
104 *(vu_long *)MPC5XXX_SDRAM_CTRL = SDRAM_CONTROL | 0x80000004 |
107 /* set mode register */
108 *(vu_long *)MPC5XXX_SDRAM_MODE = SDRAM_MODE;
110 /* normal operation */
111 *(vu_long *)MPC5XXX_SDRAM_CTRL = SDRAM_CONTROL | hi_addr_bit;
113 #endif /* !CONFIG_SYS_RAMBOOT */
117 * Initalize SDRAM - configure SDRAM controller, detect memory size.
119 phys_size_t initdram(int board_type)
122 #ifndef CONFIG_SYS_RAMBOOT
125 /* According to AN3221 (MPC5200B SDRAM Initialization and
126 * Configuration), the SDelay register must be written a value of
127 * 0x00000004 as the first step of the SDRAM contorller configuration.
129 *(vu_long *)MPC5XXX_SDRAM_SDELAY = 0x04;
131 /* configure SDRAM start/end for detection */
132 *(vu_long *)MPC5XXX_SDRAM_CS0CFG = 0x0000001e; /* 2G at 0x0 */
133 *(vu_long *)MPC5XXX_SDRAM_CS1CFG = 0x80000000; /* disabled */
135 /* setup config registers */
136 *(vu_long *)MPC5XXX_SDRAM_CONFIG1 = SDRAM_CONFIG1;
137 *(vu_long *)MPC5XXX_SDRAM_CONFIG2 = SDRAM_CONFIG2;
140 test1 = get_ram_size((long *)CONFIG_SYS_SDRAM_BASE, 0x80000000);
142 test2 = get_ram_size((long *)CONFIG_SYS_SDRAM_BASE, 0x80000000);
150 /* memory smaller than 1MB is impossible */
151 if (dramsize < (1 << 20))
154 /* set SDRAM CS0 size according to the amount of RAM found */
156 *(vu_long *)MPC5XXX_SDRAM_CS0CFG = 0x13 +
157 __builtin_ffs(dramsize >> 20) - 1;
159 *(vu_long *)MPC5XXX_SDRAM_CS0CFG = 0; /* disabled */
162 /* let SDRAM CS1 start right after CS0 and disable it */
163 *(vu_long *) MPC5XXX_SDRAM_CS1CFG = dramsize;
165 #else /* !CONFIG_SYS_RAMBOOT */
166 /* retrieve size of memory connected to SDRAM CS0 */
167 dramsize = *(vu_long *)MPC5XXX_SDRAM_CS0CFG & 0xFF;
168 if (dramsize >= 0x13)
169 dramsize = (1 << (dramsize - 0x13)) << 20;
172 #endif /* CONFIG_SYS_RAMBOOT */
174 /* return total ram size */
181 uchar rev = *(vu_char *)CPLD_REV_REGISTER;
182 printf("Board: Promess Motion-PRO board (CPLD rev. 0x%02x)\n", rev);
187 #if defined(CONFIG_OF_LIBFDT) && defined(CONFIG_OF_BOARD_SETUP)
188 int ft_board_setup(void *blob, bd_t *bd)
190 ft_cpu_setup(blob, bd);
194 #endif /* defined(CONFIG_OF_LIBFDT) && defined(CONFIG_OF_BOARD_SETUP) */
197 #if defined(CONFIG_STATUS_LED)
198 void __led_init(led_id_t regaddr, int state)
200 *((vu_long *) regaddr) |= ENABLE_GPIO_OUT;
202 if (state == STATUS_LED_ON)
203 *((vu_long *) regaddr) |= LED_ON;
205 *((vu_long *) regaddr) &= ~LED_ON;
208 void __led_set(led_id_t regaddr, int state)
210 if (state == STATUS_LED_ON)
211 *((vu_long *) regaddr) |= LED_ON;
213 *((vu_long *) regaddr) &= ~LED_ON;
216 void __led_toggle(led_id_t regaddr)
218 *((vu_long *) regaddr) ^= LED_ON;
220 #endif /* CONFIG_STATUS_LED */