2 * Luan board specific routines
4 * Matt Porter <mporter@kernel.crashing.org>
6 * Copyright 2004-2005 MontaVista Software Inc.
8 * This program is free software; you can redistribute it and/or modify it
9 * under the terms of the GNU General Public License as published by the
10 * Free Software Foundation; either version 2 of the License, or (at your
11 * option) any later version.
14 #include <linux/stddef.h>
15 #include <linux/kernel.h>
16 #include <linux/init.h>
17 #include <linux/errno.h>
18 #include <linux/reboot.h>
19 #include <linux/pci.h>
20 #include <linux/kdev_t.h>
21 #include <linux/types.h>
22 #include <linux/major.h>
23 #include <linux/blkdev.h>
24 #include <linux/console.h>
25 #include <linux/delay.h>
26 #include <linux/initrd.h>
27 #include <linux/seq_file.h>
28 #include <linux/root_dev.h>
29 #include <linux/tty.h>
30 #include <linux/serial.h>
31 #include <linux/serial_core.h>
32 #include <linux/serial_8250.h>
34 #include <asm/system.h>
35 #include <asm/pgtable.h>
39 #include <asm/machdep.h>
41 #include <asm/pci-bridge.h>
44 #include <asm/bootinfo.h>
45 #include <asm/ppc4xx_pic.h>
46 #include <asm/ppcboot.h>
48 #include <syslib/ibm44x_common.h>
49 #include <syslib/ibm440gx_common.h>
50 #include <syslib/ibm440sp_common.h>
54 static struct ibm44x_clocks clocks __initdata
;
57 luan_calibrate_decr(void)
61 if (mfspr(SPRN_CCR1
) & CCR1_TCS
)
66 ibm44x_calibrate_decr(freq
);
70 luan_show_cpuinfo(struct seq_file
*m
)
72 seq_printf(m
, "vendor\t\t: IBM\n");
73 seq_printf(m
, "machine\t\t: PPC440SP EVB (Luan)\n");
79 luan_map_irq(struct pci_dev
*dev
, unsigned char idsel
, unsigned char pin
)
81 struct pci_controller
*hose
= pci_bus_to_hose(dev
->bus
->number
);
83 /* PCIX0 in adapter mode, no host interrupt routing */
86 if (hose
->index
== 0) {
87 static char pci_irq_table
[][4] =
89 * PCI IDSEL/INTPIN->INTLINE
93 { 49, 49, 49, 49 }, /* IDSEL 1 - PCIX1 Slot 0 */
94 { 49, 49, 49, 49 }, /* IDSEL 2 - PCIX1 Slot 1 */
95 { 49, 49, 49, 49 }, /* IDSEL 3 - PCIX1 Slot 2 */
96 { 49, 49, 49, 49 }, /* IDSEL 4 - PCIX1 Slot 3 */
98 const long min_idsel
= 1, max_idsel
= 4, irqs_per_slot
= 4;
99 return PCI_IRQ_TABLE_LOOKUP
;
101 } else if (hose
->index
== 1) {
102 static char pci_irq_table
[][4] =
104 * PCI IDSEL/INTPIN->INTLINE
108 { 50, 50, 50, 50 }, /* IDSEL 1 - PCIX2 Slot 0 */
109 { 50, 50, 50, 50 }, /* IDSEL 2 - PCIX2 Slot 1 */
110 { 50, 50, 50, 50 }, /* IDSEL 3 - PCIX2 Slot 2 */
111 { 50, 50, 50, 50 }, /* IDSEL 4 - PCIX2 Slot 3 */
113 const long min_idsel
= 1, max_idsel
= 4, irqs_per_slot
= 4;
114 return PCI_IRQ_TABLE_LOOKUP
;
119 static void __init
luan_set_emacdata(void)
122 struct ocp_func_emac_data
*emacdata
;
124 /* Set phy_map, phy_mode, and mac_addr for the EMAC */
125 def
= ocp_get_one_device(OCP_VENDOR_IBM
, OCP_FUNC_EMAC
, 0);
126 emacdata
= def
->additions
;
127 emacdata
->phy_map
= 0x00000001; /* Skip 0x00 */
128 emacdata
->phy_mode
= PHY_MODE_GMII
;
129 memcpy(emacdata
->mac_addr
, __res
.bi_enetaddr
, 6);
132 #define PCIX_READW(offset) \
133 (readw((void *)((u32)pcix_reg_base+offset)))
135 #define PCIX_WRITEW(value, offset) \
136 (writew(value, (void *)((u32)pcix_reg_base+offset)))
138 #define PCIX_WRITEL(value, offset) \
139 (writel(value, (void *)((u32)pcix_reg_base+offset)))
142 luan_setup_pcix(void)
148 pcix_reg_base
= ioremap64(PCIX0_REG_BASE
+ i
*PCIX_REG_OFFSET
, PCIX_REG_SIZE
);
150 /* Enable PCIX0 I/O, Mem, and Busmaster cycles */
151 PCIX_WRITEW(PCIX_READW(PCIX0_COMMAND
) | PCI_COMMAND_IO
| PCI_COMMAND_MEMORY
| PCI_COMMAND_MASTER
, PCIX0_COMMAND
);
153 /* Disable all windows */
154 PCIX_WRITEL(0, PCIX0_POM0SA
);
155 PCIX_WRITEL(0, PCIX0_POM1SA
);
156 PCIX_WRITEL(0, PCIX0_POM2SA
);
157 PCIX_WRITEL(0, PCIX0_PIM0SA
);
158 PCIX_WRITEL(0, PCIX0_PIM0SAH
);
159 PCIX_WRITEL(0, PCIX0_PIM1SA
);
160 PCIX_WRITEL(0, PCIX0_PIM2SA
);
161 PCIX_WRITEL(0, PCIX0_PIM2SAH
);
164 * Setup 512MB PLB->PCI outbound mem window
165 * (a_n000_0000->0_n000_0000)
167 PCIX_WRITEL(0x0000000a, PCIX0_POM0LAH
);
168 PCIX_WRITEL(0x80000000 | i
*LUAN_PCIX_MEM_SIZE
, PCIX0_POM0LAL
);
169 PCIX_WRITEL(0x00000000, PCIX0_POM0PCIAH
);
170 PCIX_WRITEL(0x80000000 | i
*LUAN_PCIX_MEM_SIZE
, PCIX0_POM0PCIAL
);
171 PCIX_WRITEL(0xe0000001, PCIX0_POM0SA
);
173 /* Setup 2GB PCI->PLB inbound memory window at 0, enable MSIs */
174 PCIX_WRITEL(0x00000000, PCIX0_PIM0LAH
);
175 PCIX_WRITEL(0x00000000, PCIX0_PIM0LAL
);
176 PCIX_WRITEL(0xe0000007, PCIX0_PIM0SA
);
177 PCIX_WRITEL(0xffffffff, PCIX0_PIM0SAH
);
179 iounmap(pcix_reg_base
);
186 luan_setup_hose(struct pci_controller
*hose
,
195 sprintf(name
, "PCIX%d host bridge", hose
->index
);
197 hose
->pci_mem_offset
= LUAN_PCIX_MEM_OFFSET
;
199 pci_init_resource(&hose
->io_resource
,
205 pci_init_resource(&hose
->mem_resources
[0],
211 hose
->io_space
.start
= LUAN_PCIX_LOWER_IO
;
212 hose
->io_space
.end
= LUAN_PCIX_UPPER_IO
;
213 hose
->mem_space
.start
= lower_mem
;
214 hose
->mem_space
.end
= upper_mem
;
215 hose
->io_base_virt
= ioremap64(pcix_io_base
, PCIX_IO_SIZE
);
216 isa_io_base
= (unsigned long) hose
->io_base_virt
;
218 setup_indirect_pci(hose
, cfga
, cfgd
);
219 hose
->set_cfg_type
= 1;
223 luan_setup_hoses(void)
225 struct pci_controller
*hose1
, *hose2
;
227 /* Configure windows on the PCI-X host bridge */
230 /* Allocate hoses for PCIX1 and PCIX2 */
231 hose1
= pcibios_alloc_controller();
235 hose2
= pcibios_alloc_controller();
237 pcibios_free_controller(hose1
);
242 hose1
->first_busno
= 0;
243 hose1
->last_busno
= 0xff;
245 luan_setup_hose(hose1
,
246 LUAN_PCIX1_LOWER_MEM
,
247 LUAN_PCIX1_UPPER_MEM
,
252 hose1
->last_busno
= pciauto_bus_scan(hose1
, hose1
->first_busno
);
255 hose2
->first_busno
= hose1
->last_busno
+ 1;
256 hose2
->last_busno
= 0xff;
258 luan_setup_hose(hose2
,
259 LUAN_PCIX2_LOWER_MEM
,
260 LUAN_PCIX2_UPPER_MEM
,
265 hose2
->last_busno
= pciauto_bus_scan(hose2
, hose2
->first_busno
);
267 ppc_md
.pci_swizzle
= common_swizzle
;
268 ppc_md
.pci_map_irq
= luan_map_irq
;
274 luan_early_serial_map(void)
276 struct uart_port port
;
278 /* Setup ioremapped serial port access */
279 memset(&port
, 0, sizeof(port
));
280 port
.membase
= ioremap64(PPC440SP_UART0_ADDR
, 8);
281 port
.irq
= UART0_INT
;
282 port
.uartclk
= clocks
.uart0
;
284 port
.iotype
= UPIO_MEM
;
285 port
.flags
= UPF_BOOT_AUTOCONF
| UPF_SKIP_TEST
;
288 if (early_serial_setup(&port
) != 0) {
289 printk("Early serial init of port 0 failed\n");
292 port
.membase
= ioremap64(PPC440SP_UART1_ADDR
, 8);
293 port
.irq
= UART1_INT
;
294 port
.uartclk
= clocks
.uart1
;
297 if (early_serial_setup(&port
) != 0) {
298 printk("Early serial init of port 1 failed\n");
301 port
.membase
= ioremap64(PPC440SP_UART2_ADDR
, 8);
302 port
.irq
= UART2_INT
;
303 port
.uartclk
= BASE_BAUD
;
306 if (early_serial_setup(&port
) != 0) {
307 printk("Early serial init of port 2 failed\n");
312 luan_setup_arch(void)
316 #if !defined(CONFIG_BDI_SWITCH)
318 * The Abatron BDI JTAG debugger does not tolerate others
319 * mucking with the debug registers.
321 mtspr(SPRN_DBCR0
, (DBCR0_TDE
| DBCR0_IDM
));
325 * Determine various clocks.
326 * To be completely correct we should get SysClk
327 * from FPGA, because it can be changed by on-board switches
330 /* 440GX and 440SP clocking is the same -mdp */
331 ibm440gx_get_clocks(&clocks
, 33333333, 6 * 1843200);
332 ocp_sys_info
.opb_bus_freq
= clocks
.opb
;
334 /* init to some ~sane value until calibrate_delay() runs */
335 loops_per_jiffy
= 50000000/HZ
;
337 /* Setup PCIXn host bridges */
340 #ifdef CONFIG_BLK_DEV_INITRD
342 ROOT_DEV
= Root_RAM0
;
345 #ifdef CONFIG_ROOT_NFS
348 ROOT_DEV
= Root_HDA1
;
351 luan_early_serial_map();
353 /* Identify the system */
354 printk("Luan port (MontaVista Software, Inc. <source@mvista.com>)\n");
357 void __init
platform_init(unsigned long r3
, unsigned long r4
,
358 unsigned long r5
, unsigned long r6
, unsigned long r7
)
360 ibm44x_platform_init(r3
, r4
, r5
, r6
, r7
);
362 ppc_md
.setup_arch
= luan_setup_arch
;
363 ppc_md
.show_cpuinfo
= luan_show_cpuinfo
;
364 ppc_md
.find_end_of_memory
= ibm440sp_find_end_of_memory
;
365 ppc_md
.get_irq
= NULL
; /* Set in ppc4xx_pic_init() */
367 ppc_md
.calibrate_decr
= luan_calibrate_decr
;
369 ppc_md
.early_serial_map
= luan_early_serial_map
;