1 // SPDX-License-Identifier: GPL-2.0+
3 * Copyright 2007,2009-2011 Freescale Semiconductor, Inc.
12 #include <asm/processor.h>
14 #include <asm/immap_85xx.h>
15 #include <asm/fsl_pci.h>
16 #include <fsl_ddr_sdram.h>
17 #include <asm/fsl_serdes.h>
18 #include <spd_sdram.h>
21 #include <linux/libfdt.h>
22 #include <fdt_support.h>
26 const qe_iop_conf_t qe_iop_conf_tab[] = {
28 {4, 10, 1, 0, 2}, /* TxD0 */
29 {4, 9, 1, 0, 2}, /* TxD1 */
30 {4, 8, 1, 0, 2}, /* TxD2 */
31 {4, 7, 1, 0, 2}, /* TxD3 */
32 {4, 23, 1, 0, 2}, /* TxD4 */
33 {4, 22, 1, 0, 2}, /* TxD5 */
34 {4, 21, 1, 0, 2}, /* TxD6 */
35 {4, 20, 1, 0, 2}, /* TxD7 */
36 {4, 15, 2, 0, 2}, /* RxD0 */
37 {4, 14, 2, 0, 2}, /* RxD1 */
38 {4, 13, 2, 0, 2}, /* RxD2 */
39 {4, 12, 2, 0, 2}, /* RxD3 */
40 {4, 29, 2, 0, 2}, /* RxD4 */
41 {4, 28, 2, 0, 2}, /* RxD5 */
42 {4, 27, 2, 0, 2}, /* RxD6 */
43 {4, 26, 2, 0, 2}, /* RxD7 */
44 {4, 11, 1, 0, 2}, /* TX_EN */
45 {4, 24, 1, 0, 2}, /* TX_ER */
46 {4, 16, 2, 0, 2}, /* RX_DV */
47 {4, 30, 2, 0, 2}, /* RX_ER */
48 {4, 17, 2, 0, 2}, /* RX_CLK */
49 {4, 19, 1, 0, 2}, /* GTX_CLK */
50 {1, 31, 2, 0, 3}, /* GTX125 */
53 {5, 10, 1, 0, 2}, /* TxD0 */
54 {5, 9, 1, 0, 2}, /* TxD1 */
55 {5, 8, 1, 0, 2}, /* TxD2 */
56 {5, 7, 1, 0, 2}, /* TxD3 */
57 {5, 23, 1, 0, 2}, /* TxD4 */
58 {5, 22, 1, 0, 2}, /* TxD5 */
59 {5, 21, 1, 0, 2}, /* TxD6 */
60 {5, 20, 1, 0, 2}, /* TxD7 */
61 {5, 15, 2, 0, 2}, /* RxD0 */
62 {5, 14, 2, 0, 2}, /* RxD1 */
63 {5, 13, 2, 0, 2}, /* RxD2 */
64 {5, 12, 2, 0, 2}, /* RxD3 */
65 {5, 29, 2, 0, 2}, /* RxD4 */
66 {5, 28, 2, 0, 2}, /* RxD5 */
67 {5, 27, 2, 0, 3}, /* RxD6 */
68 {5, 26, 2, 0, 2}, /* RxD7 */
69 {5, 11, 1, 0, 2}, /* TX_EN */
70 {5, 24, 1, 0, 2}, /* TX_ER */
71 {5, 16, 2, 0, 2}, /* RX_DV */
72 {5, 30, 2, 0, 2}, /* RX_ER */
73 {5, 17, 2, 0, 2}, /* RX_CLK */
74 {5, 19, 1, 0, 2}, /* GTX_CLK */
75 {1, 31, 2, 0, 3}, /* GTX125 */
76 {4, 6, 3, 0, 2}, /* MDIO */
77 {4, 5, 1, 0, 2}, /* MDC */
80 {2, 0, 1, 0, 2}, /* UART_SOUT1 */
81 {2, 1, 1, 0, 2}, /* UART_RTS1 */
82 {2, 2, 2, 0, 2}, /* UART_CTS1 */
83 {2, 3, 2, 0, 2}, /* UART_SIN1 */
85 {0, 0, 0, 0, QE_IOP_TAB_END}, /* END of table */
88 void local_bus_init(void);
90 int board_early_init_f (void)
93 * Initialize local bus.
97 enable_8568mds_duart();
98 enable_8568mds_flash_write();
99 #if defined(CONFIG_UEC_ETH1) || defined(CONFIG_UEC_ETH2)
100 reset_8568mds_uccs();
102 #if defined(CONFIG_QE) && !defined(CONFIG_eTSEC_MDIO_BUS)
103 enable_8568mds_qe_mdio();
106 #ifdef CONFIG_SYS_I2C2_OFFSET
107 /* Enable I2C2_SCL and I2C2_SDA */
108 volatile struct par_io *port_c;
109 port_c = (struct par_io*)(CONFIG_SYS_IMMR + 0xe0140);
110 port_c->cpdir2 |= 0x0f000000;
111 port_c->cppar2 &= ~0x0f000000;
112 port_c->cppar2 |= 0x0a000000;
118 int checkboard (void)
120 printf ("Board: 8568 MDS\n");
126 * Initialize Local Bus
131 volatile ccsr_gur_t *gur = (void *)(CONFIG_SYS_MPC85xx_GUTS_ADDR);
132 volatile fsl_lbc_t *lbc = LBC_BASE_ADDR;
137 get_sys_info(&sysinfo);
138 clkdiv = (lbc->lcrr & LCRR_CLKDIV) * 2;
140 gur->lbiuiplldcr1 = 0x00078080;
142 gur->lbiuiplldcr0 = 0x7c0f1bf0;
143 } else if (clkdiv == 8) {
144 gur->lbiuiplldcr0 = 0x6c0f1bf0;
145 } else if (clkdiv == 4) {
146 gur->lbiuiplldcr0 = 0x5c0f1bf0;
149 lbc->lcrr |= 0x00030000;
151 asm("sync;isync;msync");
155 * Initialize SDRAM memory on the Local Bus.
157 void lbc_sdram_init(void)
159 #if defined(CONFIG_SYS_OR2_PRELIM) && defined(CONFIG_SYS_BR2_PRELIM)
162 volatile fsl_lbc_t *lbc = LBC_BASE_ADDR;
163 uint *sdram_addr = (uint *)CONFIG_SYS_LBC_SDRAM_BASE;
167 print_size(CONFIG_SYS_LBC_SDRAM_SIZE * 1024 * 1024,
171 * Setup SDRAM Base and Option Registers
173 set_lbc_or(2, CONFIG_SYS_OR2_PRELIM);
174 set_lbc_br(2, CONFIG_SYS_BR2_PRELIM);
177 lbc->lbcr = CONFIG_SYS_LBC_LBCR;
180 lbc->lsrt = CONFIG_SYS_LBC_LSRT;
181 lbc->mrtpr = CONFIG_SYS_LBC_MRTPR;
185 * MPC8568 uses "new" 15-16 style addressing.
187 lsdmr_common = CONFIG_SYS_LBC_LSDMR_COMMON;
188 lsdmr_common |= LSDMR_BSMA1516;
191 * Issue PRECHARGE ALL command.
193 lbc->lsdmr = lsdmr_common | LSDMR_OP_PCHALL;
196 ppcDcbf((unsigned long) sdram_addr);
200 * Issue 8 AUTO REFRESH commands.
202 for (idx = 0; idx < 8; idx++) {
203 lbc->lsdmr = lsdmr_common | LSDMR_OP_ARFRSH;
206 ppcDcbf((unsigned long) sdram_addr);
211 * Issue 8 MODE-set command.
213 lbc->lsdmr = lsdmr_common | LSDMR_OP_MRW;
216 ppcDcbf((unsigned long) sdram_addr);
220 * Issue NORMAL OP command.
222 lbc->lsdmr = lsdmr_common | LSDMR_OP_NORMAL;
225 ppcDcbf((unsigned long) sdram_addr);
226 udelay(200); /* Overkill. Must wait > 200 bus cycles */
228 #endif /* enable SDRAM init */
231 #if defined(CONFIG_PCI)
232 #ifndef CONFIG_PCI_PNP
233 static struct pci_config_table pci_mpc8568mds_config_table[] = {
235 PCI_ANY_ID, PCI_ANY_ID, PCI_ANY_ID, PCI_ANY_ID,
236 pci_cfgfunc_config_device,
239 PCI_COMMON_MEMORY | PCI_COMMAND_MASTER}
245 static struct pci_controller pci1_hose;
246 #endif /* CONFIG_PCI */
249 * pib_init() -- Initialize the PCA9555 IO expander on the PIB board
254 u8 val8, orig_i2c_bus;
256 * Assign PIB PMC2/3 to PCI bus
259 /*switch temporarily to I2C bus #2 */
260 orig_i2c_bus = i2c_get_bus_num();
264 i2c_write(0x23, 0x6, 1, &val8, 1);
265 i2c_write(0x23, 0x7, 1, &val8, 1);
267 i2c_write(0x23, 0x2, 1, &val8, 1);
268 i2c_write(0x23, 0x3, 1, &val8, 1);
271 i2c_write(0x26, 0x6, 1, &val8, 1);
273 i2c_write(0x26, 0x7, 1, &val8, 1);
275 i2c_write(0x26, 0x2, 1, &val8, 1);
277 i2c_write(0x26, 0x3, 1, &val8, 1);
280 i2c_write(0x27, 0x6, 1, &val8, 1);
281 i2c_write(0x27, 0x7, 1, &val8, 1);
283 i2c_write(0x27, 0x2, 1, &val8, 1);
285 i2c_write(0x27, 0x3, 1, &val8, 1);
288 i2c_set_bus_num(orig_i2c_bus);
292 void pci_init_board(void)
294 volatile ccsr_gur_t *gur = (void *)(CONFIG_SYS_MPC85xx_GUTS_ADDR);
295 int first_free_busno = 0;
297 struct fsl_pci_info pci_info;
298 u32 devdisr, pordevsr, io_sel;
299 u32 porpllsr, pci_agent, pci_speed, pci_32, pci_arb, pci_clk_sel;
301 devdisr = in_be32(&gur->devdisr);
302 pordevsr = in_be32(&gur->pordevsr);
303 porpllsr = in_be32(&gur->porpllsr);
304 io_sel = (pordevsr & MPC85xx_PORDEVSR_IO_SEL) >> 19;
306 debug (" pci_init_board: devdisr=%x, io_sel=%x\n", devdisr, io_sel);
308 pci_speed = 66666000;
310 pci_arb = pordevsr & MPC85xx_PORDEVSR_PCI1_ARB;
311 pci_clk_sel = porpllsr & MPC85xx_PORDEVSR_PCI1_SPD;
313 if (!(devdisr & MPC85xx_DEVDISR_PCI1)) {
314 SET_STD_PCI_INFO(pci_info, 1);
315 set_next_law(pci_info.mem_phys,
316 law_size_bits(pci_info.mem_size), pci_info.law);
317 set_next_law(pci_info.io_phys,
318 law_size_bits(pci_info.io_size), pci_info.law);
320 pci_agent = fsl_setup_hose(&pci1_hose, pci_info.regs);
321 printf("PCI: %d bit, %s MHz, %s, %s, %s (base address %lx)\n",
323 (pci_speed == 33333000) ? "33" :
324 (pci_speed == 66666000) ? "66" : "unknown",
325 pci_clk_sel ? "sync" : "async",
326 pci_agent ? "agent" : "host",
327 pci_arb ? "arbiter" : "external-arbiter",
330 #ifndef CONFIG_PCI_PNP
331 pci1_hose.config_table = pci_mpc8568mds_config_table;
333 first_free_busno = fsl_pci_init_port(&pci_info,
334 &pci1_hose, first_free_busno);
336 printf("PCI: disabled\n");
341 setbits_be32(&gur->devdisr, MPC85xx_DEVDISR_PCI1); /* disable */
344 fsl_pcie_init_board(first_free_busno);
346 #endif /* CONFIG_PCI */
348 #if defined(CONFIG_OF_BOARD_SETUP)
349 int ft_board_setup(void *blob, bd_t *bd)
351 ft_cpu_setup(blob, bd);