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> |
Jon Loeliger | 4ca4b62 | 2006-06-17 17:52:45 -0500 | [diff] [blame] | 27 | #include <asm/prom.h> |
| 28 | #include <mm/mmu_decl.h> |
| 29 | #include <asm/udbg.h> |
Jon Loeliger | 4ca4b62 | 2006-06-17 17:52:45 -0500 | [diff] [blame] | 30 | |
| 31 | #include <asm/mpic.h> |
| 32 | |
Zang Roy-r61911 | 9ac4dd3 | 2007-07-10 18:46:35 +0800 | [diff] [blame] | 33 | #include <sysdev/fsl_pci.h> |
Jon Loeliger | 4ca4b62 | 2006-06-17 17:52:45 -0500 | [diff] [blame] | 34 | #include <sysdev/fsl_soc.h> |
| 35 | |
| 36 | #include "mpc86xx.h" |
| 37 | |
Jon Loeliger | 919fede | 2006-07-31 15:35:41 -0500 | [diff] [blame] | 38 | #undef DEBUG |
| 39 | |
| 40 | #ifdef DEBUG |
| 41 | #define DBG(fmt...) do { printk(KERN_ERR fmt); } while(0) |
| 42 | #else |
| 43 | #define DBG(fmt...) do { } while(0) |
| 44 | #endif |
| 45 | |
Jon Loeliger | 869d7f3 | 2006-08-15 16:19:02 -0500 | [diff] [blame] | 46 | #ifdef CONFIG_PCI |
Kumar Gala | b66510c | 2007-08-16 23:55:55 -0500 | [diff] [blame] | 47 | extern int uli_exclude_device(struct pci_controller *hose, |
| 48 | u_char bus, u_char devfn); |
Jon Loeliger | 4ca4b62 | 2006-06-17 17:52:45 -0500 | [diff] [blame] | 49 | |
Kumar Gala | b66510c | 2007-08-16 23:55:55 -0500 | [diff] [blame] | 50 | static int mpc86xx_exclude_device(struct pci_controller *hose, |
| 51 | u_char bus, u_char devfn) |
Jon Loeliger | 4ca4b62 | 2006-06-17 17:52:45 -0500 | [diff] [blame] | 52 | { |
Kumar Gala | b66510c | 2007-08-16 23:55:55 -0500 | [diff] [blame] | 53 | struct device_node* node; |
| 54 | struct resource rsrc; |
Jon Loeliger | 4ca4b62 | 2006-06-17 17:52:45 -0500 | [diff] [blame] | 55 | |
Stephen Rothwell | 44ef339 | 2007-12-10 14:33:21 +1100 | [diff] [blame] | 56 | node = hose->dn; |
Kumar Gala | b66510c | 2007-08-16 23:55:55 -0500 | [diff] [blame] | 57 | of_address_to_resource(node, 0, &rsrc); |
Jon Loeliger | 919fede | 2006-07-31 15:35:41 -0500 | [diff] [blame] | 58 | |
Kumar Gala | b66510c | 2007-08-16 23:55:55 -0500 | [diff] [blame] | 59 | if ((rsrc.start & 0xfffff) == 0x8000) { |
| 60 | return uli_exclude_device(hose, bus, devfn); |
Jon Loeliger | 919fede | 2006-07-31 15:35:41 -0500 | [diff] [blame] | 61 | } |
Kumar Gala | 9ad494f | 2006-06-28 00:37:45 -0500 | [diff] [blame] | 62 | |
Kumar Gala | b66510c | 2007-08-16 23:55:55 -0500 | [diff] [blame] | 63 | return PCIBIOS_SUCCESSFUL; |
Jon Loeliger | 4ca4b62 | 2006-06-17 17:52:45 -0500 | [diff] [blame] | 64 | } |
Jon Loeliger | 4ca4b62 | 2006-06-17 17:52:45 -0500 | [diff] [blame] | 65 | #endif /* CONFIG_PCI */ |
| 66 | |
| 67 | |
| 68 | static void __init |
| 69 | mpc86xx_hpcn_setup_arch(void) |
| 70 | { |
Jon Loeliger | d347b32 | 2007-07-27 13:24:36 -0500 | [diff] [blame] | 71 | #ifdef CONFIG_PCI |
Jon Loeliger | 4ca4b62 | 2006-06-17 17:52:45 -0500 | [diff] [blame] | 72 | struct device_node *np; |
Jon Loeliger | d347b32 | 2007-07-27 13:24:36 -0500 | [diff] [blame] | 73 | #endif |
Jon Loeliger | 4ca4b62 | 2006-06-17 17:52:45 -0500 | [diff] [blame] | 74 | |
| 75 | if (ppc_md.progress) |
| 76 | ppc_md.progress("mpc86xx_hpcn_setup_arch()", 0); |
| 77 | |
Jon Loeliger | 4ca4b62 | 2006-06-17 17:52:45 -0500 | [diff] [blame] | 78 | #ifdef CONFIG_PCI |
Kumar Gala | c9438af | 2007-10-04 00:28:43 -0500 | [diff] [blame] | 79 | for_each_compatible_node(np, "pci", "fsl,mpc8641-pcie") { |
Zang Roy-r61911 | 9ac4dd3 | 2007-07-10 18:46:35 +0800 | [diff] [blame] | 80 | struct resource rsrc; |
| 81 | of_address_to_resource(np, 0, &rsrc); |
| 82 | if ((rsrc.start & 0xfffff) == 0x8000) |
| 83 | fsl_add_bridge(np, 1); |
| 84 | else |
| 85 | fsl_add_bridge(np, 0); |
| 86 | } |
Kumar Gala | c9438af | 2007-10-04 00:28:43 -0500 | [diff] [blame] | 87 | |
Kumar Gala | b66510c | 2007-08-16 23:55:55 -0500 | [diff] [blame] | 88 | ppc_md.pci_exclude_device = mpc86xx_exclude_device; |
| 89 | |
Jon Loeliger | 4ca4b62 | 2006-06-17 17:52:45 -0500 | [diff] [blame] | 90 | #endif |
| 91 | |
| 92 | printk("MPC86xx HPCN board from Freescale Semiconductor\n"); |
| 93 | |
Jon Loeliger | 4ca4b62 | 2006-06-17 17:52:45 -0500 | [diff] [blame] | 94 | #ifdef CONFIG_SMP |
| 95 | mpc86xx_smp_init(); |
| 96 | #endif |
| 97 | } |
| 98 | |
| 99 | |
Paul Gortmaker | 06f35b4 | 2008-04-16 13:53:06 -0400 | [diff] [blame] | 100 | static void |
Jon Loeliger | 4ca4b62 | 2006-06-17 17:52:45 -0500 | [diff] [blame] | 101 | mpc86xx_hpcn_show_cpuinfo(struct seq_file *m) |
| 102 | { |
Jon Loeliger | 4ca4b62 | 2006-06-17 17:52:45 -0500 | [diff] [blame] | 103 | uint svid = mfspr(SPRN_SVR); |
| 104 | |
| 105 | seq_printf(m, "Vendor\t\t: Freescale Semiconductor\n"); |
| 106 | |
Jon Loeliger | 4ca4b62 | 2006-06-17 17:52:45 -0500 | [diff] [blame] | 107 | seq_printf(m, "SVR\t\t: 0x%x\n", svid); |
Jon Loeliger | 4ca4b62 | 2006-06-17 17:52:45 -0500 | [diff] [blame] | 108 | } |
| 109 | |
| 110 | |
| 111 | /* |
| 112 | * Called very early, device-tree isn't unflattened |
| 113 | */ |
| 114 | static int __init mpc86xx_hpcn_probe(void) |
| 115 | { |
| 116 | unsigned long root = of_get_flat_dt_root(); |
| 117 | |
Paul Gortmaker | 06f35b4 | 2008-04-16 13:53:06 -0400 | [diff] [blame] | 118 | if (of_flat_dt_is_compatible(root, "fsl,mpc8641hpcn")) |
Jon Loeliger | 4ca4b62 | 2006-06-17 17:52:45 -0500 | [diff] [blame] | 119 | return 1; /* Looks good */ |
| 120 | |
Paul Gortmaker | 16787b4 | 2008-04-16 13:53:07 -0400 | [diff] [blame] | 121 | /* Be nice and don't give silent boot death. Delete this in 2.6.27 */ |
| 122 | if (of_flat_dt_is_compatible(root, "mpc86xx")) { |
| 123 | pr_warning("WARNING: your dts/dtb is old. You must update before the next kernel release\n"); |
| 124 | return 1; |
| 125 | } |
| 126 | |
Jon Loeliger | 4ca4b62 | 2006-06-17 17:52:45 -0500 | [diff] [blame] | 127 | return 0; |
| 128 | } |
| 129 | |
Paul Gortmaker | 06f35b4 | 2008-04-16 13:53:06 -0400 | [diff] [blame] | 130 | static long __init |
Jon Loeliger | 4ca4b62 | 2006-06-17 17:52:45 -0500 | [diff] [blame] | 131 | mpc86xx_time_init(void) |
| 132 | { |
| 133 | unsigned int temp; |
| 134 | |
| 135 | /* Set the time base to zero */ |
| 136 | mtspr(SPRN_TBWL, 0); |
| 137 | mtspr(SPRN_TBWU, 0); |
| 138 | |
| 139 | temp = mfspr(SPRN_HID0); |
| 140 | temp |= HID0_TBEN; |
| 141 | mtspr(SPRN_HID0, temp); |
| 142 | asm volatile("isync"); |
| 143 | |
| 144 | return 0; |
| 145 | } |
| 146 | |
Wade Farnsworth | 15061d6 | 2008-01-22 13:17:45 -0700 | [diff] [blame] | 147 | static __initdata struct of_device_id of_bus_ids[] = { |
| 148 | { .compatible = "simple-bus", }, |
Zhang Wei | 182e143 | 2008-04-18 13:33:43 -0700 | [diff] [blame] | 149 | { .compatible = "fsl,rapidio-delta", }, |
Anton Vorontsov | d8bc55f | 2009-03-19 21:01:51 +0300 | [diff] [blame] | 150 | { .compatible = "gianfar", }, |
Wade Farnsworth | 15061d6 | 2008-01-22 13:17:45 -0700 | [diff] [blame] | 151 | {}, |
| 152 | }; |
| 153 | |
| 154 | static int __init declare_of_platform_devices(void) |
| 155 | { |
| 156 | of_platform_bus_probe(NULL, of_bus_ids, NULL); |
| 157 | |
| 158 | return 0; |
| 159 | } |
| 160 | machine_device_initcall(mpc86xx_hpcn, declare_of_platform_devices); |
| 161 | |
Jon Loeliger | 4ca4b62 | 2006-06-17 17:52:45 -0500 | [diff] [blame] | 162 | define_machine(mpc86xx_hpcn) { |
| 163 | .name = "MPC86xx HPCN", |
| 164 | .probe = mpc86xx_hpcn_probe, |
| 165 | .setup_arch = mpc86xx_hpcn_setup_arch, |
Kumar Gala | 98384c6 | 2008-07-02 11:46:20 -0500 | [diff] [blame] | 166 | .init_IRQ = mpc86xx_init_irq, |
Jon Loeliger | 4ca4b62 | 2006-06-17 17:52:45 -0500 | [diff] [blame] | 167 | .show_cpuinfo = mpc86xx_hpcn_show_cpuinfo, |
Jon Loeliger | 4ca4b62 | 2006-06-17 17:52:45 -0500 | [diff] [blame] | 168 | .get_irq = mpic_get_irq, |
Kumar Gala | e1c1575 | 2007-10-04 01:04:57 -0500 | [diff] [blame] | 169 | .restart = fsl_rstcr_restart, |
Jon Loeliger | 4ca4b62 | 2006-06-17 17:52:45 -0500 | [diff] [blame] | 170 | .time_init = mpc86xx_time_init, |
| 171 | .calibrate_decr = generic_calibrate_decr, |
| 172 | .progress = udbg_progress, |
Kumar Gala | 2af8569 | 2007-09-10 14:30:33 -0500 | [diff] [blame] | 173 | #ifdef CONFIG_PCI |
Kumar Gala | 6c0a11c | 2007-07-19 15:29:53 -0500 | [diff] [blame] | 174 | .pcibios_fixup_bus = fsl_pcibios_fixup_bus, |
Kumar Gala | 2af8569 | 2007-09-10 14:30:33 -0500 | [diff] [blame] | 175 | #endif |
Jon Loeliger | 4ca4b62 | 2006-06-17 17:52:45 -0500 | [diff] [blame] | 176 | }; |