]> Git Repo - J-u-boot.git/blame - board/freescale/mpc8569mds/mpc8569mds.c
common: Drop flash.h from common header
[J-u-boot.git] / board / freescale / mpc8569mds / mpc8569mds.c
CommitLineData
83d290c5 1// SPDX-License-Identifier: GPL-2.0+
765547dc 2/*
6525d51f 3 * Copyright 2009-2010 Freescale Semiconductor.
765547dc
HW
4 *
5 * (C) Copyright 2002 Scott McNutt <[email protected]>
765547dc
HW
6 */
7
8#include <common.h>
24b852a7 9#include <console.h>
b79fdc76 10#include <flash.h>
7f52ed5e 11#include <hwconfig.h>
5255932f 12#include <init.h>
765547dc
HW
13#include <pci.h>
14#include <asm/processor.h>
15#include <asm/mmu.h>
3aed5507 16#include <asm/cache.h>
765547dc 17#include <asm/immap_85xx.h>
c8514622 18#include <asm/fsl_pci.h>
5614e71b 19#include <fsl_ddr_sdram.h>
5d27e02c 20#include <asm/fsl_serdes.h>
765547dc
HW
21#include <asm/io.h>
22#include <spd_sdram.h>
23#include <i2c.h>
24#include <ioports.h>
b08c8c48 25#include <linux/libfdt.h>
765547dc 26#include <fdt_support.h>
7f52ed5e 27#include <fsl_esdhc.h>
865ff856 28#include <phy.h>
765547dc
HW
29
30#include "bcsr.h"
d9180382
LY
31#if defined(CONFIG_PQ_MDS_PIB)
32#include "../common/pq-mds-pib.h"
33#endif
765547dc 34
765547dc
HW
35const qe_iop_conf_t qe_iop_conf_tab[] = {
36 /* QE_MUX_MDC */
37 {2, 31, 1, 0, 1}, /* QE_MUX_MDC */
38
39 /* QE_MUX_MDIO */
40 {2, 30, 3, 0, 2}, /* QE_MUX_MDIO */
41
f82107f6 42#if defined(CONFIG_SYS_UCC_RGMII_MODE)
765547dc
HW
43 /* UCC_1_RGMII */
44 {2, 11, 2, 0, 1}, /* CLK12 */
45 {0, 0, 1, 0, 3}, /* ENET1_TXD0_SER1_TXD0 */
46 {0, 1, 1, 0, 3}, /* ENET1_TXD1_SER1_TXD1 */
47 {0, 2, 1, 0, 1}, /* ENET1_TXD2_SER1_TXD2 */
48 {0, 3, 1, 0, 2}, /* ENET1_TXD3_SER1_TXD3 */
49 {0, 6, 2, 0, 3}, /* ENET1_RXD0_SER1_RXD0 */
50 {0, 7, 2, 0, 1}, /* ENET1_RXD1_SER1_RXD1 */
51 {0, 8, 2, 0, 2}, /* ENET1_RXD2_SER1_RXD2 */
52 {0, 9, 2, 0, 2}, /* ENET1_RXD3_SER1_RXD3 */
53 {0, 4, 1, 0, 2}, /* ENET1_TX_EN_SER1_RTS_B */
54 {0, 12, 2, 0, 3}, /* ENET1_RX_DV_SER1_CTS_B */
55 {2, 8, 2, 0, 1}, /* ENET1_GRXCLK */
56 {2, 20, 1, 0, 2}, /* ENET1_GTXCLK */
57
58 /* UCC_2_RGMII */
59 {2, 16, 2, 0, 3}, /* CLK17 */
60 {0, 14, 1, 0, 2}, /* ENET2_TXD0_SER2_TXD0 */
61 {0, 15, 1, 0, 2}, /* ENET2_TXD1_SER2_TXD1 */
62 {0, 16, 1, 0, 1}, /* ENET2_TXD2_SER2_TXD2 */
63 {0, 17, 1, 0, 1}, /* ENET2_TXD3_SER2_TXD3 */
64 {0, 20, 2, 0, 2}, /* ENET2_RXD0_SER2_RXD0 */
65 {0, 21, 2, 0, 1}, /* ENET2_RXD1_SER2_RXD1 */
66 {0, 22, 2, 0, 1}, /* ENET2_RXD2_SER2_RXD2 */
67 {0, 23, 2, 0, 1}, /* ENET2_RXD3_SER2_RXD3 */
68 {0, 18, 1, 0, 2}, /* ENET2_TX_EN_SER2_RTS_B */
69 {0, 26, 2, 0, 3}, /* ENET2_RX_DV_SER2_CTS_B */
70 {2, 3, 2, 0, 1}, /* ENET2_GRXCLK */
71 {2, 2, 1, 0, 2}, /* ENET2_GTXCLK */
72
750098d3
HW
73 /* UCC_3_RGMII */
74 {2, 11, 2, 0, 1}, /* CLK12 */
75 {0, 29, 1, 0, 2}, /* ENET3_TXD0_SER3_TXD0 */
76 {0, 30, 1, 0, 3}, /* ENET3_TXD1_SER3_TXD1 */
77 {0, 31, 1, 0, 2}, /* ENET3_TXD2_SER3_TXD2 */
78 {1, 0, 1, 0, 3}, /* ENET3_TXD3_SER3_TXD3 */
79 {1, 3, 2, 0, 3}, /* ENET3_RXD0_SER3_RXD0 */
80 {1, 4, 2, 0, 1}, /* ENET3_RXD1_SER3_RXD1 */
81 {1, 5, 2, 0, 2}, /* ENET3_RXD2_SER3_RXD2 */
82 {1, 6, 2, 0, 3}, /* ENET3_RXD3_SER3_RXD3 */
83 {1, 1, 1, 0, 1}, /* ENET3_TX_EN_SER3_RTS_B */
84 {1, 9, 2, 0, 3}, /* ENET3_RX_DV_SER3_CTS_B */
85 {2, 9, 2, 0, 2}, /* ENET3_GRXCLK */
86 {2, 25, 1, 0, 2}, /* ENET3_GTXCLK */
87
88 /* UCC_4_RGMII */
89 {2, 16, 2, 0, 3}, /* CLK17 */
90 {1, 12, 1, 0, 2}, /* ENET4_TXD0_SER4_TXD0 */
91 {1, 13, 1, 0, 2}, /* ENET4_TXD1_SER4_TXD1 */
92 {1, 14, 1, 0, 1}, /* ENET4_TXD2_SER4_TXD2 */
93 {1, 15, 1, 0, 2}, /* ENET4_TXD3_SER4_TXD3 */
94 {1, 18, 2, 0, 2}, /* ENET4_RXD0_SER4_RXD0 */
95 {1, 19, 2, 0, 1}, /* ENET4_RXD1_SER4_RXD1 */
96 {1, 20, 2, 0, 1}, /* ENET4_RXD2_SER4_RXD2 */
97 {1, 21, 2, 0, 2}, /* ENET4_RXD3_SER4_RXD3 */
98 {1, 16, 1, 0, 2}, /* ENET4_TX_EN_SER4_RTS_B */
99 {1, 24, 2, 0, 3}, /* ENET4_RX_DV_SER4_CTS_B */
100 {2, 17, 2, 0, 2}, /* ENET4_GRXCLK */
101 {2, 24, 1, 0, 2}, /* ENET4_GTXCLK */
102
f82107f6
HW
103#elif defined(CONFIG_SYS_UCC_RMII_MODE)
104 /* UCC_1_RMII */
105 {2, 15, 2, 0, 1}, /* CLK16 */
106 {0, 0, 1, 0, 3}, /* ENET1_TXD0_SER1_TXD0 */
107 {0, 1, 1, 0, 3}, /* ENET1_TXD1_SER1_TXD1 */
108 {0, 6, 2, 0, 3}, /* ENET1_RXD0_SER1_RXD0 */
109 {0, 7, 2, 0, 1}, /* ENET1_RXD1_SER1_RXD1 */
110 {0, 4, 1, 0, 2}, /* ENET1_TX_EN_SER1_RTS_B */
111 {0, 12, 2, 0, 3}, /* ENET1_RX_DV_SER1_CTS_B */
112
113 /* UCC_2_RMII */
114 {2, 15, 2, 0, 1}, /* CLK16 */
115 {0, 14, 1, 0, 2}, /* ENET2_TXD0_SER2_TXD0 */
116 {0, 15, 1, 0, 2}, /* ENET2_TXD1_SER2_TXD1 */
117 {0, 20, 2, 0, 2}, /* ENET2_RXD0_SER2_RXD0 */
118 {0, 21, 2, 0, 1}, /* ENET2_RXD1_SER2_RXD1 */
119 {0, 18, 1, 0, 2}, /* ENET2_TX_EN_SER2_RTS_B */
120 {0, 26, 2, 0, 3}, /* ENET2_RX_DV_SER2_CTS_B */
121
122 /* UCC_3_RMII */
123 {2, 15, 2, 0, 1}, /* CLK16 */
124 {0, 29, 1, 0, 2}, /* ENET3_TXD0_SER3_TXD0 */
125 {0, 30, 1, 0, 3}, /* ENET3_TXD1_SER3_TXD1 */
126 {1, 3, 2, 0, 3}, /* ENET3_RXD0_SER3_RXD0 */
127 {1, 4, 2, 0, 1}, /* ENET3_RXD1_SER3_RXD1 */
128 {1, 1, 1, 0, 1}, /* ENET3_TX_EN_SER3_RTS_B */
129 {1, 9, 2, 0, 3}, /* ENET3_RX_DV_SER3_CTS_B */
130
131 /* UCC_4_RMII */
132 {2, 15, 2, 0, 1}, /* CLK16 */
133 {1, 12, 1, 0, 2}, /* ENET4_TXD0_SER4_TXD0 */
134 {1, 13, 1, 0, 2}, /* ENET4_TXD1_SER4_TXD1 */
135 {1, 18, 2, 0, 2}, /* ENET4_RXD0_SER4_RXD0 */
136 {1, 19, 2, 0, 1}, /* ENET4_RXD1_SER4_RXD1 */
137 {1, 16, 1, 0, 2}, /* ENET4_TX_EN_SER4_RTS_B */
138 {1, 24, 2, 0, 3}, /* ENET4_RX_DV_SER4_CTS_B */
139#endif
140
b2aab386
HW
141 /* UART1 is muxed with QE PortF bit [9-12].*/
142 {5, 12, 2, 0, 3}, /* UART1_SIN */
143 {5, 9, 1, 0, 3}, /* UART1_SOUT */
144 {5, 10, 2, 0, 3}, /* UART1_CTS_B */
145 {5, 11, 1, 0, 2}, /* UART1_RTS_B */
146
14809b6c
AV
147 /* QE UART */
148 {0, 19, 1, 0, 2}, /* QEUART_TX */
149 {1, 17, 2, 0, 3}, /* QEUART_RX */
150 {0, 25, 1, 0, 1}, /* QEUART_RTS */
151 {1, 23, 2, 0, 1}, /* QEUART_CTS */
152
3fca8037
AV
153 /* QE USB */
154 {5, 3, 1, 0, 1}, /* USB_OE */
155 {5, 4, 1, 0, 2}, /* USB_TP */
156 {5, 5, 1, 0, 2}, /* USB_TN */
157 {5, 6, 2, 0, 2}, /* USB_RP */
158 {5, 7, 2, 0, 1}, /* USB_RX */
159 {5, 8, 2, 0, 1}, /* USB_RN */
160 {2, 4, 2, 0, 2}, /* CLK5 */
161
70d665b1
AV
162 /* SPI Flash, M25P40 */
163 {4, 27, 3, 0, 1}, /* SPI_MOSI */
164 {4, 28, 3, 0, 1}, /* SPI_MISO */
165 {4, 29, 3, 0, 1}, /* SPI_CLK */
166 {4, 30, 1, 0, 0}, /* SPI_SEL, GPIO */
167
765547dc
HW
168 {0, 0, 0, 0, QE_IOP_TAB_END} /* END of table */
169};
170
171void local_bus_init(void);
172
173int board_early_init_f (void)
174{
175 /*
176 * Initialize local bus.
177 */
178 local_bus_init ();
179
180 enable_8569mds_flash_write();
181
182#ifdef CONFIG_QE
f82107f6 183 enable_8569mds_qe_uec();
765547dc
HW
184#endif
185
186#if CONFIG_SYS_I2C2_OFFSET
187 /* Enable I2C2 signals instead of SD signals */
188 volatile struct ccsr_gur *gur;
189 gur = (struct ccsr_gur *)(CONFIG_SYS_IMMR + 0xe0000);
190 gur->plppar1 &= ~PLPPAR1_I2C_BIT_MASK;
191 gur->plppar1 |= PLPPAR1_I2C2_VAL;
192 gur->plpdir1 &= ~PLPDIR1_I2C_BIT_MASK;
193 gur->plpdir1 |= PLPDIR1_I2C2_VAL;
194
195 disable_8569mds_brd_eeprom_write_protect();
196#endif
197
198 return 0;
199}
200
3aed5507
HW
201int board_early_init_r(void)
202{
203 const unsigned int flashbase = CONFIG_SYS_NAND_BASE;
204 const u8 flash_esel = 0;
205
206 /*
207 * Remap Boot flash to caching-inhibited
208 * so that flash can be erased properly.
209 */
210
211 /* Flush d-cache and invalidate i-cache of any FLASH data */
212 flush_dcache();
213 invalidate_icache();
214
215 /* invalidate existing TLB entry for flash */
216 disable_tlb(flash_esel);
217
218 set_tlb(1, flashbase, CONFIG_SYS_NAND_BASE, /* tlb, epn, rpn */
219 MAS3_SX|MAS3_SW|MAS3_SR, MAS2_I|MAS2_G, /* perms, wimge */
220 0, flash_esel, /* ts, esel */
221 BOOKE_PAGESZ_64M, 1); /* tsize, iprot */
222
223 return 0;
224}
225
765547dc
HW
226int checkboard (void)
227{
228 printf ("Board: 8569 MDS\n");
229
230 return 0;
231}
232
765547dc
HW
233#if !defined(CONFIG_SPD_EEPROM)
234phys_size_t fixed_sdram(void)
235{
9a17eb5b
YS
236 struct ccsr_ddr __iomem *ddr =
237 (struct ccsr_ddr __iomem *)CONFIG_SYS_FSL_DDR_ADDR;
765547dc
HW
238 uint d_init;
239
240 out_be32(&ddr->cs0_bnds, CONFIG_SYS_DDR_CS0_BNDS);
241 out_be32(&ddr->cs0_config, CONFIG_SYS_DDR_CS0_CONFIG);
242 out_be32(&ddr->timing_cfg_3, CONFIG_SYS_DDR_TIMING_3);
243 out_be32(&ddr->timing_cfg_0, CONFIG_SYS_DDR_TIMING_0);
244 out_be32(&ddr->timing_cfg_1, CONFIG_SYS_DDR_TIMING_1);
245 out_be32(&ddr->timing_cfg_2, CONFIG_SYS_DDR_TIMING_2);
246 out_be32(&ddr->sdram_cfg, CONFIG_SYS_DDR_SDRAM_CFG);
247 out_be32(&ddr->sdram_cfg_2, CONFIG_SYS_DDR_SDRAM_CFG_2);
248 out_be32(&ddr->sdram_mode, CONFIG_SYS_DDR_SDRAM_MODE);
249 out_be32(&ddr->sdram_mode_2, CONFIG_SYS_DDR_SDRAM_MODE_2);
250 out_be32(&ddr->sdram_interval, CONFIG_SYS_DDR_SDRAM_INTERVAL);
251 out_be32(&ddr->sdram_data_init, CONFIG_SYS_DDR_DATA_INIT);
252 out_be32(&ddr->sdram_clk_cntl, CONFIG_SYS_DDR_SDRAM_CLK_CNTL);
253 out_be32(&ddr->timing_cfg_4, CONFIG_SYS_DDR_TIMING_4);
254 out_be32(&ddr->timing_cfg_5, CONFIG_SYS_DDR_TIMING_5);
255 out_be32(&ddr->ddr_zq_cntl, CONFIG_SYS_DDR_ZQ_CNTL);
256 out_be32(&ddr->ddr_wrlvl_cntl, CONFIG_SYS_DDR_WRLVL_CNTL);
257 out_be32(&ddr->sdram_cfg_2, CONFIG_SYS_DDR_SDRAM_CFG_2);
258#if defined (CONFIG_DDR_ECC)
259 out_be32(&ddr->err_int_en, CONFIG_SYS_DDR_ERR_INT_EN);
260 out_be32(&ddr->err_disable, CONFIG_SYS_DDR_ERR_DIS);
261 out_be32(&ddr->err_sbe, CONFIG_SYS_DDR_SBE);
262#endif
263 udelay(500);
264
265 out_be32(&ddr->sdram_cfg, CONFIG_SYS_DDR_CONTROL);
266#if defined(CONFIG_ECC_INIT_VIA_DDRCONTROLLER)
267 d_init = 1;
268 debug("DDR - 1st controller: memory initializing\n");
269 /*
270 * Poll until memory is initialized.
271 * 512 Meg at 400 might hit this 200 times or so.
272 */
273 while ((ddr->sdram_cfg_2 & (d_init << 4)) != 0) {
274 udelay(1000);
275 }
276 debug("DDR: memory initialized\n\n");
277 udelay(500);
278#endif
279 return CONFIG_SYS_SDRAM_SIZE * 1024 * 1024;
280}
281#endif
282
283/*
284 * Initialize Local Bus
285 */
286void
287local_bus_init(void)
288{
289 volatile ccsr_gur_t *gur = (void *)(CONFIG_SYS_MPC85xx_GUTS_ADDR);
f51cdaf1 290 volatile fsl_lbc_t *lbc = LBC_BASE_ADDR;
765547dc
HW
291
292 uint clkdiv;
765547dc
HW
293 sys_info_t sysinfo;
294
295 get_sys_info(&sysinfo);
296 clkdiv = (lbc->lcrr & LCRR_CLKDIV) * 2;
765547dc
HW
297
298 out_be32(&gur->lbiuiplldcr1, 0x00078080);
299 if (clkdiv == 16)
300 out_be32(&gur->lbiuiplldcr0, 0x7c0f1bf0);
301 else if (clkdiv == 8)
302 out_be32(&gur->lbiuiplldcr0, 0x6c0f1bf0);
303 else if (clkdiv == 4)
304 out_be32(&gur->lbiuiplldcr0, 0x5c0f1bf0);
305
306 out_be32(&lbc->lcrr, (u32)in_be32(&lbc->lcrr)| 0x00030000);
307}
308
14809b6c
AV
309static void fdt_board_disable_serial(void *blob, bd_t *bd, const char *alias)
310{
311 const char *status = "disabled";
312 int off;
313 int err;
314
315 off = fdt_path_offset(blob, alias);
316 if (off < 0) {
317 printf("WARNING: could not find %s alias: %s.\n", alias,
318 fdt_strerror(off));
319 return;
320 }
321
322 err = fdt_setprop(blob, off, "status", status, strlen(status) + 1);
323 if (err) {
324 printf("WARNING: could not set status for serial0: %s.\n",
325 fdt_strerror(err));
326 return;
327 }
328}
7f52ed5e
AV
329
330/*
331 * Because of an erratum in prototype boards it is impossible to use eSDHC
332 * without disabling UART0 (which makes it quite easy to 'brick' the board
333 * by simply issung 'setenv hwconfig esdhc', and not able to interact with
334 * U-Boot anylonger).
335 *
336 * So, but default we assume that the board is a prototype, which is a most
337 * safe assumption. There is no way to determine board revision from a
338 * register, so we use hwconfig.
339 */
340
341static int prototype_board(void)
342{
343 if (hwconfig_subarg("board", "rev", NULL))
344 return hwconfig_subarg_cmp("board", "rev", "prototype");
345 return 1;
346}
347
348static int esdhc_disables_uart0(void)
349{
350 return prototype_board() ||
351 hwconfig_subarg_cmp("esdhc", "mode", "4-bits");
352}
353
14809b6c
AV
354static void fdt_board_fixup_qe_uart(void *blob, bd_t *bd)
355{
356 u8 *bcsr = (u8 *)CONFIG_SYS_BCSR_BASE;
357 const char *devtype = "serial";
358 const char *compat = "ucc_uart";
359 const char *clk = "brg9";
360 u32 portnum = 0;
361 int off = -1;
362
363 if (!hwconfig("qe_uart"))
364 return;
365
366 if (hwconfig("esdhc") && esdhc_disables_uart0()) {
367 printf("QE UART: won't enable with esdhc.\n");
368 return;
369 }
370
371 fdt_board_disable_serial(blob, bd, "serial1");
372
373 while (1) {
374 const u32 *idx;
375 int len;
376
377 off = fdt_node_offset_by_compatible(blob, off, "ucc_geth");
378 if (off < 0) {
379 printf("WARNING: unable to fixup device tree for "
380 "QE UART\n");
381 return;
382 }
383
384 idx = fdt_getprop(blob, off, "cell-index", &len);
385 if (!idx || len != sizeof(*idx) || *idx != fdt32_to_cpu(2))
386 continue;
387 break;
388 }
389
390 fdt_setprop(blob, off, "device_type", devtype, strlen(devtype) + 1);
391 fdt_setprop(blob, off, "compatible", compat, strlen(compat) + 1);
392 fdt_setprop(blob, off, "tx-clock-name", clk, strlen(clk) + 1);
393 fdt_setprop(blob, off, "rx-clock-name", clk, strlen(clk) + 1);
394 fdt_setprop(blob, off, "port-number", &portnum, sizeof(portnum));
395
396 setbits_8(&bcsr[15], BCSR15_QEUART_EN);
397}
398
399#ifdef CONFIG_FSL_ESDHC
400
7f52ed5e
AV
401int board_mmc_init(bd_t *bd)
402{
403 struct ccsr_gur *gur = (struct ccsr_gur *)CONFIG_SYS_MPC85xx_GUTS_ADDR;
404 u8 *bcsr = (u8 *)CONFIG_SYS_BCSR_BASE;
405 u8 bcsr6 = BCSR6_SD_CARD_1BIT;
406
407 if (!hwconfig("esdhc"))
408 return 0;
409
410 printf("Enabling eSDHC...\n"
411 " For eSDHC to function, I2C2 ");
412 if (esdhc_disables_uart0()) {
413 printf("and UART0 should be disabled.\n");
414 printf(" Redirecting stderr, stdout and stdin to UART1...\n");
415 console_assign(stderr, "eserial1");
416 console_assign(stdout, "eserial1");
417 console_assign(stdin, "eserial1");
418 printf("Switched to UART1 (initial log has been printed to "
419 "UART0).\n");
c4ca10f1
AV
420
421 clrsetbits_be32(&gur->plppar1, PLPPAR1_UART0_BIT_MASK,
422 PLPPAR1_ESDHC_4BITS_VAL);
423 clrsetbits_be32(&gur->plpdir1, PLPDIR1_UART0_BIT_MASK,
424 PLPDIR1_ESDHC_4BITS_VAL);
7f52ed5e
AV
425 bcsr6 |= BCSR6_SD_CARD_4BITS;
426 } else {
427 printf("should be disabled.\n");
428 }
429
430 /* Assign I2C2 signals to eSDHC. */
431 clrsetbits_be32(&gur->plppar1, PLPPAR1_I2C_BIT_MASK,
432 PLPPAR1_ESDHC_VAL);
433 clrsetbits_be32(&gur->plpdir1, PLPDIR1_I2C_BIT_MASK,
434 PLPDIR1_ESDHC_VAL);
435
436 /* Mux I2C2 (and optionally UART0) signals to eSDHC. */
437 setbits_8(&bcsr[6], bcsr6);
438
439 return fsl_esdhc_mmc_init(bd);
440}
441
442static void fdt_board_fixup_esdhc(void *blob, bd_t *bd)
443{
444 const char *status = "disabled";
14809b6c 445 int off = -1;
7f52ed5e
AV
446
447 if (!hwconfig("esdhc"))
448 return;
449
14809b6c
AV
450 if (esdhc_disables_uart0())
451 fdt_board_disable_serial(blob, bd, "serial0");
7f52ed5e 452
7f52ed5e
AV
453 while (1) {
454 const u32 *idx;
455 int len;
456
457 off = fdt_node_offset_by_compatible(blob, off, "fsl-i2c");
458 if (off < 0)
459 break;
460
461 idx = fdt_getprop(blob, off, "cell-index", &len);
462 if (!idx || len != sizeof(*idx))
463 continue;
464
465 if (*idx == 1) {
466 fdt_setprop(blob, off, "status", status,
467 strlen(status) + 1);
468 break;
469 }
470 }
c4ca10f1
AV
471
472 if (hwconfig_subarg_cmp("esdhc", "mode", "4-bits")) {
473 off = fdt_node_offset_by_compatible(blob, -1, "fsl,esdhc");
474 if (off < 0) {
475 printf("WARNING: could not find esdhc node\n");
476 return;
477 }
478 fdt_delprop(blob, off, "sdhci,1-bit-only");
479 }
7f52ed5e
AV
480}
481#else
482static inline void fdt_board_fixup_esdhc(void *blob, bd_t *bd) {}
483#endif
484
3fca8037
AV
485static void fdt_board_fixup_qe_usb(void *blob, bd_t *bd)
486{
487 u8 *bcsr = (u8 *)CONFIG_SYS_BCSR_BASE;
488
489 if (hwconfig_subarg_cmp("qe_usb", "speed", "low"))
490 clrbits_8(&bcsr[17], BCSR17_nUSBLOWSPD);
491 else
492 setbits_8(&bcsr[17], BCSR17_nUSBLOWSPD);
493
494 if (hwconfig_subarg_cmp("qe_usb", "mode", "peripheral")) {
495 clrbits_8(&bcsr[17], BCSR17_USBVCC);
496 clrbits_8(&bcsr[17], BCSR17_USBMODE);
497 do_fixup_by_compat(blob, "fsl,mpc8569-qe-usb", "mode",
498 "peripheral", sizeof("peripheral"), 1);
499 } else {
500 setbits_8(&bcsr[17], BCSR17_USBVCC);
501 setbits_8(&bcsr[17], BCSR17_USBMODE);
502 }
503
504 clrbits_8(&bcsr[17], BCSR17_nUSBEN);
505}
506
765547dc 507#ifdef CONFIG_PCI
c847e98b 508void pci_init_board(void)
765547dc 509{
d9180382
LY
510#if defined(CONFIG_PQ_MDS_PIB)
511 pib_init();
512#endif
513
94f2bc48 514 fsl_pcie_init_board(0);
765547dc
HW
515}
516#endif /* CONFIG_PCI */
517
518#if defined(CONFIG_OF_BOARD_SETUP)
e895a4b0 519int ft_board_setup(void *blob, bd_t *bd)
765547dc 520{
f82107f6
HW
521#if defined(CONFIG_SYS_UCC_RMII_MODE)
522 int nodeoff, off, err;
523 unsigned int val;
524 const u32 *ph;
525 const u32 *index;
526
527 /* fixup device tree for supporting rmii mode */
528 nodeoff = -1;
529 while ((nodeoff = fdt_node_offset_by_compatible(blob, nodeoff,
530 "ucc_geth")) >= 0) {
531 err = fdt_setprop_string(blob, nodeoff, "tx-clock-name",
532 "clk16");
533 if (err < 0) {
534 printf("WARNING: could not set tx-clock-name %s.\n",
535 fdt_strerror(err));
536 break;
537 }
538
865ff856
AF
539 err = fdt_fixup_phy_connection(blob, nodeoff,
540 PHY_INTERFACE_MODE_RMII);
a1964ea5 541
f82107f6
HW
542 if (err < 0) {
543 printf("WARNING: could not set phy-connection-type "
544 "%s.\n", fdt_strerror(err));
545 break;
546 }
547
548 index = fdt_getprop(blob, nodeoff, "cell-index", 0);
549 if (index == NULL) {
550 printf("WARNING: could not get cell-index of ucc\n");
551 break;
552 }
553
554 ph = fdt_getprop(blob, nodeoff, "phy-handle", 0);
555 if (ph == NULL) {
556 printf("WARNING: could not get phy-handle of ucc\n");
557 break;
558 }
559
560 off = fdt_node_offset_by_phandle(blob, *ph);
561 if (off < 0) {
562 printf("WARNING: could not get phy node %s.\n",
563 fdt_strerror(err));
564 break;
565 }
566
567 val = 0x7 + *index; /* RMII phy address starts from 0x8 */
568
569 err = fdt_setprop(blob, off, "reg", &val, sizeof(u32));
570 if (err < 0) {
571 printf("WARNING: could not set reg for phy-handle "
572 "%s.\n", fdt_strerror(err));
573 break;
574 }
575 }
576#endif
765547dc
HW
577 ft_cpu_setup(blob, bd);
578
6525d51f
KG
579 FT_FSL_PCI_SETUP;
580
7f52ed5e 581 fdt_board_fixup_esdhc(blob, bd);
14809b6c 582 fdt_board_fixup_qe_uart(blob, bd);
3fca8037 583 fdt_board_fixup_qe_usb(blob, bd);
e895a4b0
SG
584
585 return 0;
765547dc
HW
586}
587#endif
This page took 0.582496 seconds and 4 git commands to generate.