2 * Board setup routines for the IBM 750GX/CL platform w/ TSI10x bridge
4 * Copyright 2007 IBM Corporation
6 * Stephen Winiecki <stevewin@us.ibm.com>
7 * Josh Boyer <jwboyer@linux.vnet.ibm.com>
9 * Based on code from mpc7448_hpc2.c
11 * This program is free software; you can redistribute it and/or
12 * modify it under the terms of the GNU General Public License
13 * version 2 as published by the Free Software Foundation.
16 #include <linux/stddef.h>
17 #include <linux/kernel.h>
18 #include <linux/pci.h>
19 #include <linux/kdev_t.h>
20 #include <linux/console.h>
21 #include <linux/delay.h>
22 #include <linux/irq.h>
23 #include <linux/ide.h>
24 #include <linux/seq_file.h>
25 #include <linux/root_dev.h>
26 #include <linux/serial.h>
27 #include <linux/tty.h>
28 #include <linux/serial_core.h>
30 #include <asm/system.h>
32 #include <asm/machdep.h>
35 #include <asm/tsi108.h>
36 #include <asm/pci-bridge.h>
38 #include <mm/mmu_decl.h>
39 #include <asm/tsi108_irq.h>
40 #include <asm/tsi108_pci.h>
42 #include <asm/of_platform.h>
46 #define HOLLY_PCI_CFG_PHYS 0x7c000000
48 int holly_exclude_device(struct pci_controller *hose, u_char bus, u_char devfn)
50 if (bus == 0 && PCI_SLOT(devfn) == 0)
51 return PCIBIOS_DEVICE_NOT_FOUND;
53 return PCIBIOS_SUCCESSFUL;
56 static void holly_remap_bridge(void)
58 u32 lut_val, lut_addr;
61 printk(KERN_INFO "Remapping PCI bridge\n");
63 /* Re-init the PCI bridge and LUT registers to have mappings that don't
67 for (i = 0; i < 31; i++) {
68 tsi108_write_reg(TSI108_PB_OFFSET + lut_addr, 0x00000201);
70 tsi108_write_reg(TSI108_PB_OFFSET + lut_addr, 0x0);
74 /* Reserve the last LUT entry for PCI I/O space */
75 tsi108_write_reg(TSI108_PB_OFFSET + lut_addr, 0x00000241);
77 tsi108_write_reg(TSI108_PB_OFFSET + lut_addr, 0x0);
79 /* Map PCI I/O space */
80 tsi108_write_reg(TSI108_PCI_PFAB_IO_UPPER, 0x0);
81 tsi108_write_reg(TSI108_PCI_PFAB_IO, 0x1);
83 /* Map PCI CFG space */
84 tsi108_write_reg(TSI108_PCI_PFAB_BAR0_UPPER, 0x0);
85 tsi108_write_reg(TSI108_PCI_PFAB_BAR0, 0x7c000000 | 0x01);
87 /* We don't need MEM32 and PRM remapping so disable them */
88 tsi108_write_reg(TSI108_PCI_PFAB_MEM32, 0x0);
89 tsi108_write_reg(TSI108_PCI_PFAB_PFM3, 0x0);
90 tsi108_write_reg(TSI108_PCI_PFAB_PFM4, 0x0);
93 tsi108_write_reg(TSI108_PCI_P2O_BAR0_UPPER, 0x0);
94 tsi108_write_reg(TSI108_PCI_P2O_BAR0, 0xc0000000);
96 /* Init the PCI LUTs to do no remapping */
100 for (i = 0; i < 32; i++) {
101 tsi108_write_reg(TSI108_PCI_OFFSET + lut_addr, lut_val);
103 tsi108_write_reg(TSI108_PCI_OFFSET + lut_addr, 0x40000000);
105 lut_val += 0x02000000;
107 tsi108_write_reg(TSI108_PCI_P2O_PAGE_SIZES, 0x00007900);
109 /* Set 64-bit PCI bus address for system memory */
110 tsi108_write_reg(TSI108_PCI_P2O_BAR2_UPPER, 0x0);
111 tsi108_write_reg(TSI108_PCI_P2O_BAR2, 0x0);
114 static void __init holly_setup_arch(void)
116 struct device_node *np;
119 ppc_md.progress("holly_setup_arch():set_bridge", 0);
121 tsi108_csr_vir_base = get_vir_csrbase();
123 /* setup PCI host bridge */
124 holly_remap_bridge();
126 np = of_find_node_by_type(NULL, "pci");
128 tsi108_setup_pci(np, HOLLY_PCI_CFG_PHYS, 1);
130 ppc_md.pci_exclude_device = holly_exclude_device;
132 ppc_md.progress("tsi108: resources set", 0x100);
134 printk(KERN_INFO "PPC750GX/CL Platform\n");
138 * Interrupt setup and service. Interrupts on the holly come
139 * from the four external INT pins, PCI interrupts are routed via
140 * PCI interrupt control registers, it generates internal IRQ23
142 * Interrupt routing on the Holly Board:
143 * TSI108:PB_INT[0] -> CPU0:INT#
144 * TSI108:PB_INT[1] -> CPU0:MCP#
145 * TSI108:PB_INT[2] -> N/C
146 * TSI108:PB_INT[3] -> N/C
148 static void __init holly_init_IRQ(void)
151 phys_addr_t mpic_paddr = 0;
152 struct device_node *tsi_pic;
154 unsigned int cascade_pci_irq;
155 struct device_node *tsi_pci;
156 struct device_node *cascade_node = NULL;
159 tsi_pic = of_find_node_by_type(NULL, "open-pic");
162 const void *prop = of_get_property(tsi_pic, "reg", &size);
163 mpic_paddr = of_translate_address(tsi_pic, prop);
166 if (mpic_paddr == 0) {
167 printk(KERN_ERR "%s: No tsi108 PIC found !\n", __func__);
171 pr_debug("%s: tsi108 pic phys_addr = 0x%x\n", __func__, (u32) mpic_paddr);
173 mpic = mpic_alloc(tsi_pic, mpic_paddr,
174 MPIC_PRIMARY | MPIC_BIG_ENDIAN | MPIC_WANTS_RESET |
175 MPIC_SPV_EOI | MPIC_NO_PTHROU_DIS | MPIC_REGSET_TSI108,
177 NR_IRQS-4, /* num_sources used */
180 BUG_ON(mpic == NULL);
182 mpic_assign_isu(mpic, 0, mpic_paddr + 0x100);
187 tsi_pci = of_find_node_by_type(NULL, "pci");
188 if (tsi_pci == NULL) {
189 printk(KERN_ERR "%s: No tsi108 pci node found !\n", __func__);
193 cascade_node = of_find_node_by_type(NULL, "pic-router");
194 if (cascade_node == NULL) {
195 printk(KERN_ERR "%s: No tsi108 pci cascade node found !\n", __func__);
199 cascade_pci_irq = irq_of_parse_and_map(tsi_pci, 0);
200 pr_debug("%s: tsi108 cascade_pci_irq = 0x%x\n", __func__, (u32) cascade_pci_irq);
201 tsi108_pci_int_init(cascade_node);
202 set_irq_data(cascade_pci_irq, mpic);
203 set_irq_chained_handler(cascade_pci_irq, tsi108_irq_cascade);
205 /* Configure MPIC outputs to CPU0 */
206 tsi108_write_reg(TSI108_MPIC_OFFSET + 0x30c, 0);
207 of_node_put(tsi_pic);
210 void holly_show_cpuinfo(struct seq_file *m)
212 seq_printf(m, "vendor\t\t: IBM\n");
213 seq_printf(m, "machine\t\t: PPC750 GX/CL\n");
216 void holly_restart(char *cmd)
218 __be32 __iomem *ocn_bar1 = NULL;
220 struct device_node *bridge = NULL;
223 phys_addr_t addr = 0xc0000000;
227 bridge = of_find_node_by_type(NULL, "tsi-bridge");
229 prop = of_get_property(bridge, "reg", &size);
230 addr = of_translate_address(bridge, prop);
232 addr += (TSI108_PB_OFFSET + 0x414);
234 ocn_bar1 = ioremap(addr, 0x4);
236 /* Turn on the BOOT bit so the addresses are correctly
237 * routed to the HLP interface */
238 bar = ioread32be(ocn_bar1);
240 iowrite32be(bar, ocn_bar1);
243 /* Set SRR0 to the reset vector and turn on MSR_IP */
244 mtspr(SPRN_SRR0, 0xfff00100);
245 mtspr(SPRN_SRR1, MSR_IP);
247 /* Do an rfi to jump back to firmware. Somewhat evil,
250 __asm__ __volatile__("rfi" : : : "memory");
252 /* Spin until reset happens. Shouldn't really get here */
256 void holly_power_off(void)
259 /* No way to shut power off with software */
263 void holly_halt(void)
269 * Called very early, device-tree isn't unflattened
271 static int __init holly_probe(void)
273 unsigned long root = of_get_flat_dt_root();
275 if (!of_flat_dt_is_compatible(root, "ibm,holly"))
280 static int ppc750_machine_check_exception(struct pt_regs *regs)
282 const struct exception_table_entry *entry;
284 /* Are we prepared to handle this fault */
285 if ((entry = search_exception_tables(regs->nip)) != NULL) {
286 tsi108_clear_pci_cfg_error();
288 regs->nip = entry->fixup;
294 define_machine(holly){
295 .name = "PPC750 GX/CL TSI",
296 .probe = holly_probe,
297 .setup_arch = holly_setup_arch,
298 .init_IRQ = holly_init_IRQ,
299 .show_cpuinfo = holly_show_cpuinfo,
300 .get_irq = mpic_get_irq,
301 .restart = holly_restart,
302 .calibrate_decr = generic_calibrate_decr,
303 .machine_check_exception = ppc750_machine_check_exception,
304 .progress = udbg_progress,