3 * Heiko Schocher, DENX Software Engineering, hs@denx.de.
5 * SPDX-License-Identifier: GPL-2.0+
12 #if defined(CONFIG_OF_BOARD_SETUP) && defined(CONFIG_OF_LIBFDT)
17 * I/O Port configuration table
19 * if conf is 1, then that port pin will be configured at boot time
20 * according to the five values podr/pdir/ppar/psor/pdat for that entry
22 const iop_conf_t iop_conf_tab[4][32] = {
25 { /* conf ppar psor pdir podr pdat */
26 /* PA31 */ { 0, 0, 0, 0, 0, 0 }, /* PA31 */
27 /* PA30 */ { 0, 0, 0, 0, 0, 0 }, /* PA30 */
28 /* PA29 */ { 1, 1, 1, 1, 0, 0 }, /* FCC1 TXER */
29 /* PA28 */ { 1, 1, 1, 1, 0, 0 }, /* FCC1 TXEN */
30 /* PA27 */ { 1, 1, 1, 0, 0, 0 }, /* FCC1 RXDV */
31 /* PA26 */ { 1, 1, 1, 0, 0, 0 }, /* FCC1 RXER */
32 /* PA25 */ { 1, 0, 0, 1, 0, 0 }, /* ETH_PWRDWN */
33 /* PA24 */ { 1, 0, 0, 1, 0, 1 }, /* ETH_RESET */
34 /* PA23 */ { 0, 0, 0, 0, 0, 0 }, /* PA23 */
35 /* PA22 */ { 0, 0, 0, 0, 0, 0 }, /* PA22 */
36 /* PA21 */ { 1, 1, 0, 1, 0, 0 }, /* FCC1 TXD3 */
37 /* PA20 */ { 1, 1, 0, 1, 0, 0 }, /* FCC1 TXD2 */
38 /* PA19 */ { 1, 1, 0, 1, 0, 0 }, /* FCC1 TXD1 */
39 /* PA18 */ { 1, 1, 0, 1, 0, 0 }, /* FCC1 TXD0 */
40 /* PA17 */ { 1, 1, 0, 0, 0, 0 }, /* FCC1 RXD0 */
41 /* PA16 */ { 1, 1, 0, 0, 0, 0 }, /* FCC1 RXD1 */
42 /* PA15 */ { 1, 1, 0, 0, 0, 0 }, /* FCC1 RXD2 */
43 /* PA14 */ { 1, 1, 0, 0, 0, 0 }, /* FCC1 RXD3 */
44 /* PA13 */ { 0, 0, 0, 0, 0, 0 }, /* PA13 */
45 /* PA12 */ { 1, 0, 0, 1, 0, 0 }, /* ETH_SLEEP */
46 /* PA11 */ { 0, 0, 0, 0, 0, 0 }, /* PA11 */
47 /* PA10 */ { 1, 0, 0, 1, 0, 0 }, /* MDIO */
48 /* PA9 */ { 1, 0, 0, 1, 0, 0 }, /* MDC */
49 /* PA8 */ { 1, 1, 0, 0, 0, 0 }, /* SMC2 RxD */
50 /* PA7 */ { 0, 0, 0, 0, 0, 0 }, /* PA7 */
51 /* PA6 */ { 0, 0, 0, 0, 0, 0 }, /* PA6 */
52 /* PA5 */ { 0, 0, 0, 0, 0, 0 }, /* PA5 */
53 /* PA4 */ { 0, 0, 0, 0, 0, 0 }, /* PA4 */
54 /* PA3 */ { 0, 0, 0, 0, 0, 0 }, /* PA3 */
55 /* PA2 */ { 0, 0, 0, 0, 0, 0 }, /* PA2 */
56 /* PA1 */ { 0, 0, 0, 0, 0, 0 }, /* PA1 */
57 /* PA0 */ { 0, 0, 0, 0, 0, 0 } /* PA0 */
61 { /* conf ppar psor pdir podr pdat */
62 /* PB31 */ { 0, 0, 0, 0, 0, 0 }, /* PB31 */
63 /* PB30 */ { 0, 0, 0, 0, 0, 0 }, /* PB30 */
64 /* PB29 */ { 0, 0, 0, 0, 0, 0 }, /* PB29 */
65 /* PB28 */ { 1, 1, 1, 1, 0, 0 }, /* SCC1 TxD */
66 /* PB27 */ { 0, 0, 0, 0, 0, 0 }, /* PB27 */
67 /* PB26 */ { 0, 0, 0, 0, 0, 0 }, /* PB26 */
68 /* PB25 */ { 0, 0, 0, 0, 0, 0 }, /* PB25 */
69 /* PB24 */ { 0, 0, 0, 0, 0, 0 }, /* PB24 */
70 /* PB23 */ { 0, 0, 0, 0, 0, 0 }, /* PB23 */
71 /* PB22 */ { 0, 0, 0, 0, 0, 0 }, /* PB22 */
72 /* PB21 */ { 0, 0, 0, 0, 0, 0 }, /* PB21 */
73 /* PB20 */ { 0, 0, 0, 0, 0, 0 }, /* PB20 */
74 /* PB19 */ { 0, 0, 0, 0, 0, 0 }, /* PB19 */
75 /* PB18 */ { 0, 0, 0, 0, 0, 0 }, /* PB18 */
76 /* PB17 */ { 0, 0, 0, 0, 0, 0 }, /* non-existent */
77 /* PB16 */ { 0, 0, 0, 0, 0, 0 }, /* non-existent */
78 /* PB15 */ { 1, 1, 0, 0, 0, 0 }, /* SCC2 RxD */
79 /* PB14 */ { 1, 1, 0, 0, 0, 0 }, /* SCC3 RxD */
80 /* PB13 */ { 0, 0, 0, 0, 0, 0 }, /* non-existent */
81 /* PB12 */ { 1, 1, 1, 1, 0, 0 }, /* SCC2 TxD */
82 /* PB11 */ { 0, 0, 0, 0, 0, 0 }, /* non-existent */
83 /* PB10 */ { 0, 0, 0, 0, 0, 0 }, /* non-existent */
84 /* PB9 */ { 0, 0, 0, 0, 0, 0 }, /* non-existent */
85 /* PB8 */ { 1, 1, 1, 1, 0, 0 }, /* SCC3 TxD */
86 /* PB7 */ { 0, 0, 0, 0, 0, 0 }, /* non-existent */
87 /* PB6 */ { 0, 0, 0, 0, 0, 0 }, /* non-existent */
88 /* PB5 */ { 0, 0, 0, 0, 0, 0 }, /* non-existent */
89 /* PB4 */ { 0, 0, 0, 0, 0, 0 }, /* non-existent */
90 /* PB3 */ { 0, 0, 0, 0, 0, 0 }, /* non-existent */
91 /* PB2 */ { 0, 0, 0, 0, 0, 0 }, /* non-existent */
92 /* PB1 */ { 0, 0, 0, 0, 0, 0 }, /* non-existent */
93 /* PB0 */ { 0, 0, 0, 0, 0, 0 } /* non-existent */
97 { /* conf ppar psor pdir podr pdat */
98 /* PC31 */ { 0, 0, 0, 0, 0, 0 }, /* PC31 */
99 /* PC30 */ { 1, 1, 1, 1, 0, 0 }, /* Timer1 OUT */
100 /* PC29 */ { 0, 0, 0, 0, 0, 0 }, /* PC29 */
101 /* PC28 */ { 0, 0, 0, 0, 0, 0 }, /* PC28 */
102 /* PC27 */ { 0, 0, 0, 0, 0, 0 }, /* PC27 */
103 /* PC26 */ { 0, 0, 0, 0, 0, 0 }, /* PC26 */
104 /* PC25 */ { 0, 0, 0, 0, 0, 0 }, /* PC25 */
105 /* PC24 */ { 0, 0, 0, 0, 0, 0 }, /* PC24 */
106 /* PC23 */ { 0, 0, 0, 0, 0, 0 }, /* PC23 */
107 /* PC22 */ { 0, 0, 0, 0, 0, 0 }, /* PC22 */
108 /* PC21 */ { 1, 1, 0, 0, 0, 0 }, /* FCC RxCLK 11 */
109 /* PC20 */ { 1, 1, 0, 0, 0, 0 }, /* FCC TxCLK 12 */
110 /* PC19 */ { 0, 0, 0, 0, 0, 0 }, /* PC19 */
111 /* PC18 */ { 0, 0, 0, 0, 0, 0 }, /* PC18 */
112 /* PC17 */ { 0, 0, 0, 0, 0, 0 }, /* PC17 */
113 /* PC16 */ { 0, 0, 0, 0, 0, 0 }, /* PC16 */
114 /* PC15 */ { 1, 1, 0, 1, 0, 0 }, /* SMC2 TxD */
115 /* PC14 */ { 0, 0, 0, 0, 0, 0 }, /* PC14 */
116 /* PC13 */ { 0, 0, 0, 0, 0, 0 }, /* PC13 */
117 /* PC12 */ { 1, 0, 0, 1, 0, 0 }, /* TX OUTPUT SLEW1 */
118 /* PC11 */ { 1, 0, 0, 1, 0, 0 }, /* TX OUTPUT SLEW0 */
119 /* PC10 */ { 0, 0, 0, 0, 0, 0 }, /* PC10 */
120 /* PC9 */ { 1, 0, 0, 1, 0, 1 }, /* SPA_TX_EN */
121 /* PC8 */ { 0, 0, 0, 0, 0, 0 }, /* PC8 */
122 /* PC7 */ { 0, 0, 0, 0, 0, 0 }, /* PC7 */
123 /* PC6 */ { 0, 0, 0, 0, 0, 0 }, /* PC6 */
124 /* PC5 */ { 0, 0, 0, 0, 0, 0 }, /* PC5 */
125 /* PC4 */ { 0, 0, 0, 0, 0, 0 }, /* PC4 */
126 /* PC3 */ { 0, 0, 0, 0, 0, 0 }, /* PC3 */
127 /* PC2 */ { 0, 0, 0, 0, 0, 0 }, /* PC2 */
128 /* PC1 */ { 0, 0, 0, 0, 0, 0 }, /* PC1 */
129 /* PC0 */ { 0, 0, 0, 0, 0, 0 }, /* PC0 */
133 { /* conf ppar psor pdir podr pdat */
134 /* PD31 */ { 1, 1, 0, 0, 0, 0 }, /* SCC1 RxD */
135 /* PD30 */ { 0, 0, 0, 0, 0, 0 }, /* PD30 */
136 /* PD29 */ { 0, 0, 0, 0, 0, 0 }, /* PD29 */
137 /* PD28 */ { 0, 0, 0, 0, 0, 0 }, /* PD28 */
138 /* PD27 */ { 0, 0, 0, 0, 0, 0 }, /* PD27 */
139 /* PD26 */ { 0, 0, 0, 0, 0, 0 }, /* PD26 */
140 /* PD25 */ { 0, 0, 0, 0, 0, 0 }, /* PD25 */
141 /* PD24 */ { 0, 0, 0, 0, 0, 0 }, /* PD24 */
142 /* PD23 */ { 0, 0, 0, 0, 0, 0 }, /* PD23 */
143 /* PD22 */ { 1, 1, 0, 0, 0, 0 }, /* SCC4: RXD */
144 /* PD21 */ { 1, 1, 0, 1, 0, 0 }, /* SCC4: TXD */
145 /* PD20 */ { 0, 0, 0, 0, 0, 0 }, /* PD18 */
146 /* PD19 */ { 0, 0, 0, 0, 0, 0 }, /* PD19 */
147 /* PD18 */ { 0, 0, 0, 0, 0, 0 }, /* PD18 */
148 /* PD17 */ { 0, 0, 0, 0, 0, 0 }, /* PD17 */
149 /* PD16 */ { 0, 0, 0, 0, 0, 0 }, /* PD16 */
150 #if defined(CONFIG_HARD_I2C)
151 /* PD15 */ { 1, 1, 1, 0, 1, 0 }, /* I2C SDA */
152 /* PD14 */ { 1, 1, 1, 0, 1, 0 }, /* I2C SCL */
154 /* PD15 */ { 1, 0, 0, 0, 1, 1 }, /* PD15 */
155 /* PD14 */ { 1, 0, 0, 1, 1, 1 }, /* PD14 */
157 /* PD13 */ { 0, 0, 0, 0, 0, 0 }, /* PD13 */
158 /* PD12 */ { 0, 0, 0, 0, 0, 0 }, /* PD12 */
159 /* PD11 */ { 0, 0, 0, 0, 0, 0 }, /* PD11 */
160 /* PD10 */ { 0, 0, 0, 0, 0, 0 }, /* PD10 */
161 /* PD9 */ { 1, 1, 0, 1, 0, 0 }, /* SMC1 TxD */
162 /* PD8 */ { 1, 1, 0, 0, 0, 0 }, /* SMC1 RxD */
163 /* PD7 */ { 0, 0, 0, 0, 0, 0 }, /* PD7 */
164 /* PD6 */ { 0, 0, 0, 0, 0, 0 }, /* PD6 */
165 /* PD5 */ { 0, 0, 0, 0, 0, 0 }, /* PD5 */
166 /* PD4 */ { 0, 0, 0, 0, 0, 0 }, /* PD4 */
167 /* PD3 */ { 0, 0, 0, 0, 0, 0 }, /* non-existent */
168 /* PD2 */ { 0, 0, 0, 0, 0, 0 }, /* non-existent */
169 /* PD1 */ { 0, 0, 0, 0, 0, 0 }, /* non-existent */
170 /* PD0 */ { 0, 0, 0, 0, 0, 0 } /* non-existent */
174 /* Try SDRAM initialization with P/LSDMR=sdmr and ORx=orx
176 * This routine performs standard 8260 initialization sequence
177 * and calculates the available memory size. It may be called
178 * several times to try different SDRAM configurations on both
179 * 60x and local buses.
181 static long int try_init (volatile memctl8260_t * memctl, ulong sdmr,
182 ulong orx, volatile uchar * base)
184 volatile uchar c = 0xff;
185 volatile uint *sdmr_ptr;
186 volatile uint *orx_ptr;
190 /* We must be able to test a location outsize the maximum legal size
191 * to find out THAT we are outside; but this address still has to be
192 * mapped by the controller. That means, that the initial mapping has
193 * to be (at least) twice as large as the maximum expected size.
195 maxsize = (1 + (~orx | 0x7fff))/* / 2*/;
197 sdmr_ptr = &memctl->memc_psdmr;
198 orx_ptr = &memctl->memc_or1;
203 * Quote from 8260 UM (10.4.2 SDRAM Power-On Initialization, 10-35):
205 * "At system reset, initialization software must set up the
206 * programmable parameters in the memory controller banks registers
207 * (ORx, BRx, P/LSDMR). After all memory parameters are configured,
208 * system software should execute the following initialization sequence
209 * for each SDRAM device.
211 * 1. Issue a PRECHARGE-ALL-BANKS command
212 * 2. Issue eight CBR REFRESH commands
213 * 3. Issue a MODE-SET command to initialize the mode register
215 * The initial commands are executed by setting P/LSDMR[OP] and
216 * accessing the SDRAM with a single-byte transaction."
218 * The appropriate BRx/ORx registers have already been set when we
219 * get here. The SDRAM can be accessed at the address CONFIG_SYS_SDRAM_BASE.
222 *sdmr_ptr = sdmr | PSDMR_OP_PREA;
225 *sdmr_ptr = sdmr | PSDMR_OP_CBRR;
226 for (i = 0; i < 8; i++)
229 *sdmr_ptr = sdmr | PSDMR_OP_MRW;
230 *(base + CONFIG_SYS_MRS_OFFS) = c; /* setting MR on address lines */
232 *sdmr_ptr = sdmr | PSDMR_OP_NORM | PSDMR_RFEN;
235 size = get_ram_size ((long *)base, maxsize);
236 *orx_ptr = orx | ~(size - 1);
241 phys_size_t initdram (int board_type)
243 volatile immap_t *immap = (immap_t *) CONFIG_SYS_IMMR;
244 volatile memctl8260_t *memctl = &immap->im_memctl;
246 #ifndef CONFIG_SYS_RAMBOOT
247 long sizelittle, sizebig;
250 memctl->memc_psrt = CONFIG_SYS_PSRT;
251 memctl->memc_mptpr = CONFIG_SYS_MPTPR;
253 #ifndef CONFIG_SYS_RAMBOOT
256 sizelittle = try_init (memctl, CONFIG_SYS_PSDMR_LITTLE, CONFIG_SYS_OR1_LITTLE,
257 (uchar *) CONFIG_SYS_SDRAM_BASE);
258 sizebig = try_init (memctl, CONFIG_SYS_PSDMR_BIG, CONFIG_SYS_OR1_BIG,
259 (uchar *) CONFIG_SYS_SDRAM_BASE);
260 if (sizelittle < sizebig) {
263 psize = try_init (memctl, CONFIG_SYS_PSDMR_LITTLE, CONFIG_SYS_OR1_LITTLE,
264 (uchar *) CONFIG_SYS_SDRAM_BASE);
266 #endif /* CONFIG_SYS_RAMBOOT */
273 int checkboard (void)
275 puts ("Board: MUAS3001\n");
281 * Early board initalization.
283 int board_early_init_r (void)
288 #if defined(CONFIG_OF_BOARD_SETUP) && defined(CONFIG_OF_LIBFDT)
290 * update "memory" property in the blob
292 void ft_blob_update (void *blob, bd_t *bd)
294 int ret, nodeoffset = 0;
295 ulong flash_data[4] = {0};
298 /* update Flash addr, size */
299 flash_data[2] = cpu_to_be32 (CONFIG_SYS_FLASH_BASE);
300 flash_data[3] = cpu_to_be32 (CONFIG_SYS_FLASH_SIZE);
301 nodeoffset = fdt_path_offset (blob, "/localbus");
302 if (nodeoffset >= 0) {
303 ret = fdt_setprop (blob, nodeoffset, "ranges", flash_data,
304 sizeof (flash_data));
306 printf ("ft_blob_update): cannot set /localbus/ranges "
307 "property err:%s\n", fdt_strerror(ret));
309 /* memory node is required in dts */
310 printf ("ft_blob_update(): cannot find /localbus node "
311 "err:%s\n", fdt_strerror (nodeoffset));
315 nodeoffset = fdt_path_offset (blob, "/soc/cpm/serial");
316 if (nodeoffset >= 0) {
317 speed = cpu_to_be32 (bd->bi_baudrate);
318 ret = fdt_setprop (blob, nodeoffset, "current-speed", &speed,
319 sizeof (unsigned long));
321 printf ("ft_blob_update): cannot set /soc/cpm/serial/current-speed "
322 "property err:%s\n", fdt_strerror (ret));
324 /* baudrate is required in dts */
325 printf ("ft_blob_update(): cannot find /soc/cpm/smc2/current-speed node "
326 "err:%s\n", fdt_strerror (nodeoffset));
330 void ft_board_setup (void *blob, bd_t *bd)
332 ft_cpu_setup (blob, bd);
333 ft_blob_update (blob, bd);
335 #endif /* defined(CONFIG_OF_BOARD_SETUP) && defined(CONFIG_OF_LIBFDT) */