Jon Loeliger | 4ca4b62 | 2006-06-17 17:52:45 -0500 | [diff] [blame] | 1 | /* |
| 2 | * MPC86xx HPCN board specific routines |
| 3 | * |
| 4 | * Recode: ZHANG WEI <wei.zhang@freescale.com> |
| 5 | * Initial author: Xianghua Xiao <x.xiao@freescale.com> |
| 6 | * |
| 7 | * Copyright 2006 Freescale Semiconductor Inc. |
| 8 | * |
| 9 | * This program is free software; you can redistribute it and/or modify it |
| 10 | * under the terms of the GNU General Public License as published by the |
| 11 | * Free Software Foundation; either version 2 of the License, or (at your |
| 12 | * option) any later version. |
| 13 | */ |
| 14 | |
Jon Loeliger | 4ca4b62 | 2006-06-17 17:52:45 -0500 | [diff] [blame] | 15 | #include <linux/stddef.h> |
| 16 | #include <linux/kernel.h> |
| 17 | #include <linux/pci.h> |
| 18 | #include <linux/kdev_t.h> |
| 19 | #include <linux/delay.h> |
| 20 | #include <linux/seq_file.h> |
Wade Farnsworth | 15061d6 | 2008-01-22 13:17:45 -0700 | [diff] [blame] | 21 | #include <linux/of_platform.h> |
Jon Loeliger | 4ca4b62 | 2006-06-17 17:52:45 -0500 | [diff] [blame] | 22 | |
| 23 | #include <asm/system.h> |
| 24 | #include <asm/time.h> |
| 25 | #include <asm/machdep.h> |
| 26 | #include <asm/pci-bridge.h> |
| 27 | #include <asm/mpc86xx.h> |
| 28 | #include <asm/prom.h> |
| 29 | #include <mm/mmu_decl.h> |
| 30 | #include <asm/udbg.h> |
| 31 | #include <asm/i8259.h> |
| 32 | |
| 33 | #include <asm/mpic.h> |
| 34 | |
Zang Roy-r61911 | 9ac4dd3 | 2007-07-10 18:46:35 +0800 | [diff] [blame] | 35 | #include <sysdev/fsl_pci.h> |
Jon Loeliger | 4ca4b62 | 2006-06-17 17:52:45 -0500 | [diff] [blame] | 36 | #include <sysdev/fsl_soc.h> |
| 37 | |
| 38 | #include "mpc86xx.h" |
| 39 | |
Jon Loeliger | 919fede | 2006-07-31 15:35:41 -0500 | [diff] [blame] | 40 | #undef DEBUG |
| 41 | |
| 42 | #ifdef DEBUG |
| 43 | #define DBG(fmt...) do { printk(KERN_ERR fmt); } while(0) |
| 44 | #else |
| 45 | #define DBG(fmt...) do { } while(0) |
| 46 | #endif |
| 47 | |
Jon Loeliger | 869d7f3 | 2006-08-15 16:19:02 -0500 | [diff] [blame] | 48 | #ifdef CONFIG_PCI |
Olaf Hering | 35a84c2 | 2006-10-07 22:08:26 +1000 | [diff] [blame] | 49 | static void mpc86xx_8259_cascade(unsigned int irq, struct irq_desc *desc) |
Jon Loeliger | 919fede | 2006-07-31 15:35:41 -0500 | [diff] [blame] | 50 | { |
Olaf Hering | 35a84c2 | 2006-10-07 22:08:26 +1000 | [diff] [blame] | 51 | unsigned int cascade_irq = i8259_irq(); |
Jon Loeliger | 919fede | 2006-07-31 15:35:41 -0500 | [diff] [blame] | 52 | if (cascade_irq != NO_IRQ) |
Olof Johansson | 49f19ce | 2006-10-05 20:31:10 -0500 | [diff] [blame] | 53 | generic_handle_irq(cascade_irq); |
Jon Loeliger | 919fede | 2006-07-31 15:35:41 -0500 | [diff] [blame] | 54 | desc->chip->eoi(irq); |
| 55 | } |
Jon Loeliger | 869d7f3 | 2006-08-15 16:19:02 -0500 | [diff] [blame] | 56 | #endif /* CONFIG_PCI */ |
Jon Loeliger | 4ca4b62 | 2006-06-17 17:52:45 -0500 | [diff] [blame] | 57 | |
Paul Gortmaker | 06f35b4 | 2008-04-16 13:53:06 -0400 | [diff] [blame] | 58 | static void __init |
Jon Loeliger | 4ca4b62 | 2006-06-17 17:52:45 -0500 | [diff] [blame] | 59 | mpc86xx_hpcn_init_irq(void) |
| 60 | { |
| 61 | struct mpic *mpic1; |
Jon Loeliger | 869d7f3 | 2006-08-15 16:19:02 -0500 | [diff] [blame] | 62 | struct device_node *np; |
Jon Loeliger | c85c41a | 2006-08-17 14:27:57 -0500 | [diff] [blame] | 63 | struct resource res; |
Jon Loeliger | 869d7f3 | 2006-08-15 16:19:02 -0500 | [diff] [blame] | 64 | #ifdef CONFIG_PCI |
| 65 | struct device_node *cascade_node = NULL; |
| 66 | int cascade_irq; |
| 67 | #endif |
Jon Loeliger | 4ca4b62 | 2006-06-17 17:52:45 -0500 | [diff] [blame] | 68 | |
Jon Loeliger | c85c41a | 2006-08-17 14:27:57 -0500 | [diff] [blame] | 69 | /* Determine PIC address. */ |
Jon Loeliger | 919fede | 2006-07-31 15:35:41 -0500 | [diff] [blame] | 70 | np = of_find_node_by_type(NULL, "open-pic"); |
| 71 | if (np == NULL) |
| 72 | return; |
Jon Loeliger | c85c41a | 2006-08-17 14:27:57 -0500 | [diff] [blame] | 73 | of_address_to_resource(np, 0, &res); |
Jon Loeliger | 4ca4b62 | 2006-06-17 17:52:45 -0500 | [diff] [blame] | 74 | |
| 75 | /* Alloc mpic structure and per isu has 16 INT entries. */ |
Jon Loeliger | c85c41a | 2006-08-17 14:27:57 -0500 | [diff] [blame] | 76 | mpic1 = mpic_alloc(np, res.start, |
Jon Loeliger | 4ca4b62 | 2006-06-17 17:52:45 -0500 | [diff] [blame] | 77 | MPIC_PRIMARY | MPIC_WANTS_RESET | MPIC_BIG_ENDIAN, |
Kumar Gala | b533f8a | 2007-07-03 02:35:35 -0500 | [diff] [blame] | 78 | 0, 256, " MPIC "); |
Jon Loeliger | 4ca4b62 | 2006-06-17 17:52:45 -0500 | [diff] [blame] | 79 | BUG_ON(mpic1 == NULL); |
| 80 | |
Jon Loeliger | 4ca4b62 | 2006-06-17 17:52:45 -0500 | [diff] [blame] | 81 | mpic_init(mpic1); |
| 82 | |
| 83 | #ifdef CONFIG_PCI |
Jon Loeliger | 919fede | 2006-07-31 15:35:41 -0500 | [diff] [blame] | 84 | /* Initialize i8259 controller */ |
| 85 | for_each_node_by_type(np, "interrupt-controller") |
Stephen Rothwell | 55b61fe | 2007-05-03 17:26:52 +1000 | [diff] [blame] | 86 | if (of_device_is_compatible(np, "chrp,iic")) { |
Jon Loeliger | 919fede | 2006-07-31 15:35:41 -0500 | [diff] [blame] | 87 | cascade_node = np; |
| 88 | break; |
| 89 | } |
| 90 | if (cascade_node == NULL) { |
| 91 | printk(KERN_DEBUG "mpc86xxhpcn: no ISA interrupt controller\n"); |
| 92 | return; |
| 93 | } |
| 94 | |
| 95 | cascade_irq = irq_of_parse_and_map(cascade_node, 0); |
| 96 | if (cascade_irq == NO_IRQ) { |
| 97 | printk(KERN_ERR "mpc86xxhpcn: failed to map cascade interrupt"); |
| 98 | return; |
| 99 | } |
| 100 | DBG("mpc86xxhpcn: cascade mapped to irq %d\n", cascade_irq); |
| 101 | |
| 102 | i8259_init(cascade_node, 0); |
Jon Loeliger | 00e402d | 2007-02-16 16:17:41 -0600 | [diff] [blame] | 103 | of_node_put(cascade_node); |
| 104 | |
Jon Loeliger | 919fede | 2006-07-31 15:35:41 -0500 | [diff] [blame] | 105 | set_irq_chained_handler(cascade_irq, mpc86xx_8259_cascade); |
Jon Loeliger | 4ca4b62 | 2006-06-17 17:52:45 -0500 | [diff] [blame] | 106 | #endif |
| 107 | } |
| 108 | |
Jon Loeliger | 4ca4b62 | 2006-06-17 17:52:45 -0500 | [diff] [blame] | 109 | #ifdef CONFIG_PCI |
Kumar Gala | b66510c | 2007-08-16 23:55:55 -0500 | [diff] [blame] | 110 | extern int uses_fsl_uli_m1575; |
| 111 | extern int uli_exclude_device(struct pci_controller *hose, |
| 112 | u_char bus, u_char devfn); |
Jon Loeliger | 4ca4b62 | 2006-06-17 17:52:45 -0500 | [diff] [blame] | 113 | |
Kumar Gala | b66510c | 2007-08-16 23:55:55 -0500 | [diff] [blame] | 114 | static int mpc86xx_exclude_device(struct pci_controller *hose, |
| 115 | u_char bus, u_char devfn) |
Jon Loeliger | 4ca4b62 | 2006-06-17 17:52:45 -0500 | [diff] [blame] | 116 | { |
Kumar Gala | b66510c | 2007-08-16 23:55:55 -0500 | [diff] [blame] | 117 | struct device_node* node; |
| 118 | struct resource rsrc; |
Jon Loeliger | 4ca4b62 | 2006-06-17 17:52:45 -0500 | [diff] [blame] | 119 | |
Stephen Rothwell | 44ef339 | 2007-12-10 14:33:21 +1100 | [diff] [blame] | 120 | node = hose->dn; |
Kumar Gala | b66510c | 2007-08-16 23:55:55 -0500 | [diff] [blame] | 121 | of_address_to_resource(node, 0, &rsrc); |
Jon Loeliger | 919fede | 2006-07-31 15:35:41 -0500 | [diff] [blame] | 122 | |
Kumar Gala | b66510c | 2007-08-16 23:55:55 -0500 | [diff] [blame] | 123 | if ((rsrc.start & 0xfffff) == 0x8000) { |
| 124 | return uli_exclude_device(hose, bus, devfn); |
Jon Loeliger | 919fede | 2006-07-31 15:35:41 -0500 | [diff] [blame] | 125 | } |
Kumar Gala | 9ad494f | 2006-06-28 00:37:45 -0500 | [diff] [blame] | 126 | |
Kumar Gala | b66510c | 2007-08-16 23:55:55 -0500 | [diff] [blame] | 127 | return PCIBIOS_SUCCESSFUL; |
Jon Loeliger | 4ca4b62 | 2006-06-17 17:52:45 -0500 | [diff] [blame] | 128 | } |
Jon Loeliger | 4ca4b62 | 2006-06-17 17:52:45 -0500 | [diff] [blame] | 129 | #endif /* CONFIG_PCI */ |
| 130 | |
| 131 | |
| 132 | static void __init |
| 133 | mpc86xx_hpcn_setup_arch(void) |
| 134 | { |
Jon Loeliger | d347b32 | 2007-07-27 13:24:36 -0500 | [diff] [blame] | 135 | #ifdef CONFIG_PCI |
Jon Loeliger | 4ca4b62 | 2006-06-17 17:52:45 -0500 | [diff] [blame] | 136 | struct device_node *np; |
Jon Loeliger | d347b32 | 2007-07-27 13:24:36 -0500 | [diff] [blame] | 137 | #endif |
Jon Loeliger | 4ca4b62 | 2006-06-17 17:52:45 -0500 | [diff] [blame] | 138 | |
| 139 | if (ppc_md.progress) |
| 140 | ppc_md.progress("mpc86xx_hpcn_setup_arch()", 0); |
| 141 | |
Jon Loeliger | 4ca4b62 | 2006-06-17 17:52:45 -0500 | [diff] [blame] | 142 | #ifdef CONFIG_PCI |
Kumar Gala | c9438af | 2007-10-04 00:28:43 -0500 | [diff] [blame] | 143 | for_each_compatible_node(np, "pci", "fsl,mpc8641-pcie") { |
Zang Roy-r61911 | 9ac4dd3 | 2007-07-10 18:46:35 +0800 | [diff] [blame] | 144 | struct resource rsrc; |
| 145 | of_address_to_resource(np, 0, &rsrc); |
| 146 | if ((rsrc.start & 0xfffff) == 0x8000) |
| 147 | fsl_add_bridge(np, 1); |
| 148 | else |
| 149 | fsl_add_bridge(np, 0); |
| 150 | } |
Kumar Gala | c9438af | 2007-10-04 00:28:43 -0500 | [diff] [blame] | 151 | |
Kumar Gala | b66510c | 2007-08-16 23:55:55 -0500 | [diff] [blame] | 152 | uses_fsl_uli_m1575 = 1; |
| 153 | ppc_md.pci_exclude_device = mpc86xx_exclude_device; |
| 154 | |
Jon Loeliger | 4ca4b62 | 2006-06-17 17:52:45 -0500 | [diff] [blame] | 155 | #endif |
| 156 | |
| 157 | printk("MPC86xx HPCN board from Freescale Semiconductor\n"); |
| 158 | |
Jon Loeliger | 4ca4b62 | 2006-06-17 17:52:45 -0500 | [diff] [blame] | 159 | #ifdef CONFIG_SMP |
| 160 | mpc86xx_smp_init(); |
| 161 | #endif |
| 162 | } |
| 163 | |
| 164 | |
Paul Gortmaker | 06f35b4 | 2008-04-16 13:53:06 -0400 | [diff] [blame] | 165 | static void |
Jon Loeliger | 4ca4b62 | 2006-06-17 17:52:45 -0500 | [diff] [blame] | 166 | mpc86xx_hpcn_show_cpuinfo(struct seq_file *m) |
| 167 | { |
| 168 | struct device_node *root; |
| 169 | uint memsize = total_memory; |
| 170 | const char *model = ""; |
| 171 | uint svid = mfspr(SPRN_SVR); |
| 172 | |
| 173 | seq_printf(m, "Vendor\t\t: Freescale Semiconductor\n"); |
| 174 | |
| 175 | root = of_find_node_by_path("/"); |
| 176 | if (root) |
Stephen Rothwell | e2eb639 | 2007-04-03 22:26:41 +1000 | [diff] [blame] | 177 | model = of_get_property(root, "model", NULL); |
Jon Loeliger | 4ca4b62 | 2006-06-17 17:52:45 -0500 | [diff] [blame] | 178 | seq_printf(m, "Machine\t\t: %s\n", model); |
| 179 | of_node_put(root); |
| 180 | |
| 181 | seq_printf(m, "SVR\t\t: 0x%x\n", svid); |
| 182 | seq_printf(m, "Memory\t\t: %d MB\n", memsize / (1024 * 1024)); |
| 183 | } |
| 184 | |
| 185 | |
| 186 | /* |
| 187 | * Called very early, device-tree isn't unflattened |
| 188 | */ |
| 189 | static int __init mpc86xx_hpcn_probe(void) |
| 190 | { |
| 191 | unsigned long root = of_get_flat_dt_root(); |
| 192 | |
Paul Gortmaker | 06f35b4 | 2008-04-16 13:53:06 -0400 | [diff] [blame] | 193 | if (of_flat_dt_is_compatible(root, "fsl,mpc8641hpcn")) |
Jon Loeliger | 4ca4b62 | 2006-06-17 17:52:45 -0500 | [diff] [blame] | 194 | return 1; /* Looks good */ |
| 195 | |
Paul Gortmaker | 16787b4 | 2008-04-16 13:53:07 -0400 | [diff] [blame] | 196 | /* Be nice and don't give silent boot death. Delete this in 2.6.27 */ |
| 197 | if (of_flat_dt_is_compatible(root, "mpc86xx")) { |
| 198 | pr_warning("WARNING: your dts/dtb is old. You must update before the next kernel release\n"); |
| 199 | return 1; |
| 200 | } |
| 201 | |
Jon Loeliger | 4ca4b62 | 2006-06-17 17:52:45 -0500 | [diff] [blame] | 202 | return 0; |
| 203 | } |
| 204 | |
Paul Gortmaker | 06f35b4 | 2008-04-16 13:53:06 -0400 | [diff] [blame] | 205 | static long __init |
Jon Loeliger | 4ca4b62 | 2006-06-17 17:52:45 -0500 | [diff] [blame] | 206 | mpc86xx_time_init(void) |
| 207 | { |
| 208 | unsigned int temp; |
| 209 | |
| 210 | /* Set the time base to zero */ |
| 211 | mtspr(SPRN_TBWL, 0); |
| 212 | mtspr(SPRN_TBWU, 0); |
| 213 | |
| 214 | temp = mfspr(SPRN_HID0); |
| 215 | temp |= HID0_TBEN; |
| 216 | mtspr(SPRN_HID0, temp); |
| 217 | asm volatile("isync"); |
| 218 | |
| 219 | return 0; |
| 220 | } |
| 221 | |
Wade Farnsworth | 15061d6 | 2008-01-22 13:17:45 -0700 | [diff] [blame] | 222 | static __initdata struct of_device_id of_bus_ids[] = { |
| 223 | { .compatible = "simple-bus", }, |
Zhang Wei | 182e143 | 2008-04-18 13:33:43 -0700 | [diff] [blame^] | 224 | { .compatible = "fsl,rapidio-delta", }, |
Wade Farnsworth | 15061d6 | 2008-01-22 13:17:45 -0700 | [diff] [blame] | 225 | {}, |
| 226 | }; |
| 227 | |
| 228 | static int __init declare_of_platform_devices(void) |
| 229 | { |
| 230 | of_platform_bus_probe(NULL, of_bus_ids, NULL); |
| 231 | |
| 232 | return 0; |
| 233 | } |
| 234 | machine_device_initcall(mpc86xx_hpcn, declare_of_platform_devices); |
| 235 | |
Jon Loeliger | 4ca4b62 | 2006-06-17 17:52:45 -0500 | [diff] [blame] | 236 | define_machine(mpc86xx_hpcn) { |
| 237 | .name = "MPC86xx HPCN", |
| 238 | .probe = mpc86xx_hpcn_probe, |
| 239 | .setup_arch = mpc86xx_hpcn_setup_arch, |
| 240 | .init_IRQ = mpc86xx_hpcn_init_irq, |
| 241 | .show_cpuinfo = mpc86xx_hpcn_show_cpuinfo, |
Jon Loeliger | 4ca4b62 | 2006-06-17 17:52:45 -0500 | [diff] [blame] | 242 | .get_irq = mpic_get_irq, |
Kumar Gala | e1c1575 | 2007-10-04 01:04:57 -0500 | [diff] [blame] | 243 | .restart = fsl_rstcr_restart, |
Jon Loeliger | 4ca4b62 | 2006-06-17 17:52:45 -0500 | [diff] [blame] | 244 | .time_init = mpc86xx_time_init, |
| 245 | .calibrate_decr = generic_calibrate_decr, |
| 246 | .progress = udbg_progress, |
Kumar Gala | 2af8569 | 2007-09-10 14:30:33 -0500 | [diff] [blame] | 247 | #ifdef CONFIG_PCI |
Kumar Gala | 6c0a11c | 2007-07-19 15:29:53 -0500 | [diff] [blame] | 248 | .pcibios_fixup_bus = fsl_pcibios_fixup_bus, |
Kumar Gala | 2af8569 | 2007-09-10 14:30:33 -0500 | [diff] [blame] | 249 | #endif |
Jon Loeliger | 4ca4b62 | 2006-06-17 17:52:45 -0500 | [diff] [blame] | 250 | }; |