2 * Copyright 2007,2009-2011 Freescale Semiconductor, Inc.
4 * (C) Copyright 2002 Scott McNutt <smcnutt@artesyncp.com>
6 * See file CREDITS for list of people who contributed to this
9 * This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License as
11 * published by the Free Software Foundation; either version 2 of
12 * the License, or (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
27 #include <asm/processor.h>
29 #include <asm/immap_85xx.h>
30 #include <asm/fsl_pci.h>
31 #include <asm/fsl_ddr_sdram.h>
32 #include <asm/fsl_serdes.h>
33 #include <spd_sdram.h>
37 #include <fdt_support.h>
41 const qe_iop_conf_t qe_iop_conf_tab[] = {
43 {4, 10, 1, 0, 2}, /* TxD0 */
44 {4, 9, 1, 0, 2}, /* TxD1 */
45 {4, 8, 1, 0, 2}, /* TxD2 */
46 {4, 7, 1, 0, 2}, /* TxD3 */
47 {4, 23, 1, 0, 2}, /* TxD4 */
48 {4, 22, 1, 0, 2}, /* TxD5 */
49 {4, 21, 1, 0, 2}, /* TxD6 */
50 {4, 20, 1, 0, 2}, /* TxD7 */
51 {4, 15, 2, 0, 2}, /* RxD0 */
52 {4, 14, 2, 0, 2}, /* RxD1 */
53 {4, 13, 2, 0, 2}, /* RxD2 */
54 {4, 12, 2, 0, 2}, /* RxD3 */
55 {4, 29, 2, 0, 2}, /* RxD4 */
56 {4, 28, 2, 0, 2}, /* RxD5 */
57 {4, 27, 2, 0, 2}, /* RxD6 */
58 {4, 26, 2, 0, 2}, /* RxD7 */
59 {4, 11, 1, 0, 2}, /* TX_EN */
60 {4, 24, 1, 0, 2}, /* TX_ER */
61 {4, 16, 2, 0, 2}, /* RX_DV */
62 {4, 30, 2, 0, 2}, /* RX_ER */
63 {4, 17, 2, 0, 2}, /* RX_CLK */
64 {4, 19, 1, 0, 2}, /* GTX_CLK */
65 {1, 31, 2, 0, 3}, /* GTX125 */
68 {5, 10, 1, 0, 2}, /* TxD0 */
69 {5, 9, 1, 0, 2}, /* TxD1 */
70 {5, 8, 1, 0, 2}, /* TxD2 */
71 {5, 7, 1, 0, 2}, /* TxD3 */
72 {5, 23, 1, 0, 2}, /* TxD4 */
73 {5, 22, 1, 0, 2}, /* TxD5 */
74 {5, 21, 1, 0, 2}, /* TxD6 */
75 {5, 20, 1, 0, 2}, /* TxD7 */
76 {5, 15, 2, 0, 2}, /* RxD0 */
77 {5, 14, 2, 0, 2}, /* RxD1 */
78 {5, 13, 2, 0, 2}, /* RxD2 */
79 {5, 12, 2, 0, 2}, /* RxD3 */
80 {5, 29, 2, 0, 2}, /* RxD4 */
81 {5, 28, 2, 0, 2}, /* RxD5 */
82 {5, 27, 2, 0, 3}, /* RxD6 */
83 {5, 26, 2, 0, 2}, /* RxD7 */
84 {5, 11, 1, 0, 2}, /* TX_EN */
85 {5, 24, 1, 0, 2}, /* TX_ER */
86 {5, 16, 2, 0, 2}, /* RX_DV */
87 {5, 30, 2, 0, 2}, /* RX_ER */
88 {5, 17, 2, 0, 2}, /* RX_CLK */
89 {5, 19, 1, 0, 2}, /* GTX_CLK */
90 {1, 31, 2, 0, 3}, /* GTX125 */
91 {4, 6, 3, 0, 2}, /* MDIO */
92 {4, 5, 1, 0, 2}, /* MDC */
95 {2, 0, 1, 0, 2}, /* UART_SOUT1 */
96 {2, 1, 1, 0, 2}, /* UART_RTS1 */
97 {2, 2, 2, 0, 2}, /* UART_CTS1 */
98 {2, 3, 2, 0, 2}, /* UART_SIN1 */
100 {0, 0, 0, 0, QE_IOP_TAB_END}, /* END of table */
103 void local_bus_init(void);
105 int board_early_init_f (void)
108 * Initialize local bus.
112 enable_8568mds_duart();
113 enable_8568mds_flash_write();
114 #if defined(CONFIG_UEC_ETH1) || defined(CONFIG_UEC_ETH2)
115 reset_8568mds_uccs();
117 #if defined(CONFIG_QE) && !defined(CONFIG_eTSEC_MDIO_BUS)
118 enable_8568mds_qe_mdio();
121 #ifdef CONFIG_SYS_I2C2_OFFSET
122 /* Enable I2C2_SCL and I2C2_SDA */
123 volatile struct par_io *port_c;
124 port_c = (struct par_io*)(CONFIG_SYS_IMMR + 0xe0140);
125 port_c->cpdir2 |= 0x0f000000;
126 port_c->cppar2 &= ~0x0f000000;
127 port_c->cppar2 |= 0x0a000000;
133 int checkboard (void)
135 printf ("Board: 8568 MDS\n");
141 * Initialize Local Bus
146 volatile ccsr_gur_t *gur = (void *)(CONFIG_SYS_MPC85xx_GUTS_ADDR);
147 volatile fsl_lbc_t *lbc = LBC_BASE_ADDR;
153 get_sys_info(&sysinfo);
154 clkdiv = (lbc->lcrr & LCRR_CLKDIV) * 2;
155 lbc_hz = sysinfo.freqSystemBus / 1000000 / clkdiv;
157 gur->lbiuiplldcr1 = 0x00078080;
159 gur->lbiuiplldcr0 = 0x7c0f1bf0;
160 } else if (clkdiv == 8) {
161 gur->lbiuiplldcr0 = 0x6c0f1bf0;
162 } else if (clkdiv == 4) {
163 gur->lbiuiplldcr0 = 0x5c0f1bf0;
166 lbc->lcrr |= 0x00030000;
168 asm("sync;isync;msync");
172 * Initialize SDRAM memory on the Local Bus.
174 void lbc_sdram_init(void)
176 #if defined(CONFIG_SYS_OR2_PRELIM) && defined(CONFIG_SYS_BR2_PRELIM)
179 volatile fsl_lbc_t *lbc = LBC_BASE_ADDR;
180 uint *sdram_addr = (uint *)CONFIG_SYS_LBC_SDRAM_BASE;
184 print_size(CONFIG_SYS_LBC_SDRAM_SIZE * 1024 * 1024,
188 * Setup SDRAM Base and Option Registers
190 set_lbc_or(2, CONFIG_SYS_OR2_PRELIM);
191 set_lbc_br(2, CONFIG_SYS_BR2_PRELIM);
194 lbc->lbcr = CONFIG_SYS_LBC_LBCR;
197 lbc->lsrt = CONFIG_SYS_LBC_LSRT;
198 lbc->mrtpr = CONFIG_SYS_LBC_MRTPR;
202 * MPC8568 uses "new" 15-16 style addressing.
204 lsdmr_common = CONFIG_SYS_LBC_LSDMR_COMMON;
205 lsdmr_common |= LSDMR_BSMA1516;
208 * Issue PRECHARGE ALL command.
210 lbc->lsdmr = lsdmr_common | LSDMR_OP_PCHALL;
213 ppcDcbf((unsigned long) sdram_addr);
217 * Issue 8 AUTO REFRESH commands.
219 for (idx = 0; idx < 8; idx++) {
220 lbc->lsdmr = lsdmr_common | LSDMR_OP_ARFRSH;
223 ppcDcbf((unsigned long) sdram_addr);
228 * Issue 8 MODE-set command.
230 lbc->lsdmr = lsdmr_common | LSDMR_OP_MRW;
233 ppcDcbf((unsigned long) sdram_addr);
237 * Issue NORMAL OP command.
239 lbc->lsdmr = lsdmr_common | LSDMR_OP_NORMAL;
242 ppcDcbf((unsigned long) sdram_addr);
243 udelay(200); /* Overkill. Must wait > 200 bus cycles */
245 #endif /* enable SDRAM init */
248 #if defined(CONFIG_PCI)
249 #ifndef CONFIG_PCI_PNP
250 static struct pci_config_table pci_mpc8568mds_config_table[] = {
252 PCI_ANY_ID, PCI_ANY_ID, PCI_ANY_ID, PCI_ANY_ID,
253 pci_cfgfunc_config_device,
256 PCI_COMMON_MEMORY | PCI_COMMAND_MASTER}
262 static struct pci_controller pci1_hose;
263 #endif /* CONFIG_PCI */
266 * pib_init() -- Initialize the PCA9555 IO expander on the PIB board
271 u8 val8, orig_i2c_bus;
273 * Assign PIB PMC2/3 to PCI bus
276 /*switch temporarily to I2C bus #2 */
277 orig_i2c_bus = i2c_get_bus_num();
281 i2c_write(0x23, 0x6, 1, &val8, 1);
282 i2c_write(0x23, 0x7, 1, &val8, 1);
284 i2c_write(0x23, 0x2, 1, &val8, 1);
285 i2c_write(0x23, 0x3, 1, &val8, 1);
288 i2c_write(0x26, 0x6, 1, &val8, 1);
290 i2c_write(0x26, 0x7, 1, &val8, 1);
292 i2c_write(0x26, 0x2, 1, &val8, 1);
294 i2c_write(0x26, 0x3, 1, &val8, 1);
297 i2c_write(0x27, 0x6, 1, &val8, 1);
298 i2c_write(0x27, 0x7, 1, &val8, 1);
300 i2c_write(0x27, 0x2, 1, &val8, 1);
302 i2c_write(0x27, 0x3, 1, &val8, 1);
308 void pci_init_board(void)
310 volatile ccsr_gur_t *gur = (void *)(CONFIG_SYS_MPC85xx_GUTS_ADDR);
311 int first_free_busno = 0;
313 struct fsl_pci_info pci_info;
314 u32 devdisr, pordevsr, io_sel;
315 u32 porpllsr, pci_agent, pci_speed, pci_32, pci_arb, pci_clk_sel;
317 devdisr = in_be32(&gur->devdisr);
318 pordevsr = in_be32(&gur->pordevsr);
319 porpllsr = in_be32(&gur->porpllsr);
320 io_sel = (pordevsr & MPC85xx_PORDEVSR_IO_SEL) >> 19;
322 debug (" pci_init_board: devdisr=%x, io_sel=%x\n", devdisr, io_sel);
324 pci_speed = 66666000;
326 pci_arb = pordevsr & MPC85xx_PORDEVSR_PCI1_ARB;
327 pci_clk_sel = porpllsr & MPC85xx_PORDEVSR_PCI1_SPD;
329 if (!(devdisr & MPC85xx_DEVDISR_PCI1)) {
330 SET_STD_PCI_INFO(pci_info, 1);
331 set_next_law(pci_info.mem_phys,
332 law_size_bits(pci_info.mem_size), pci_info.law);
333 set_next_law(pci_info.io_phys,
334 law_size_bits(pci_info.io_size), pci_info.law);
336 pci_agent = fsl_setup_hose(&pci1_hose, pci_info.regs);
337 printf("PCI: %d bit, %s MHz, %s, %s, %s (base address %lx)\n",
339 (pci_speed == 33333000) ? "33" :
340 (pci_speed == 66666000) ? "66" : "unknown",
341 pci_clk_sel ? "sync" : "async",
342 pci_agent ? "agent" : "host",
343 pci_arb ? "arbiter" : "external-arbiter",
346 #ifndef CONFIG_PCI_PNP
347 pci1_hose.config_table = pci_mpc8568mds_config_table;
349 first_free_busno = fsl_pci_init_port(&pci_info,
350 &pci1_hose, first_free_busno);
352 printf("PCI: disabled\n");
357 setbits_be32(&gur->devdisr, MPC85xx_DEVDISR_PCI1); /* disable */
360 fsl_pcie_init_board(first_free_busno);
362 #endif /* CONFIG_PCI */
364 #if defined(CONFIG_OF_BOARD_SETUP)
365 void ft_board_setup(void *blob, bd_t *bd)
367 ft_cpu_setup(blob, bd);