blob: 7e9e83c04a8ac631fad1677d0f55f8d60558a432 [file] [log] [blame]
Jon Loeliger4ca4b622006-06-17 17:52:45 -05001/*
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 Loeliger4ca4b622006-06-17 17:52:45 -050015#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 Farnsworth15061d62008-01-22 13:17:45 -070021#include <linux/of_platform.h>
Jon Loeliger4ca4b622006-06-17 17:52:45 -050022
23#include <asm/system.h>
24#include <asm/time.h>
25#include <asm/machdep.h>
26#include <asm/pci-bridge.h>
Jon Loeliger4ca4b622006-06-17 17:52:45 -050027#include <asm/prom.h>
28#include <mm/mmu_decl.h>
29#include <asm/udbg.h>
Jon Loeliger4ca4b622006-06-17 17:52:45 -050030
31#include <asm/mpic.h>
32
Zang Roy-r619119ac4dd32007-07-10 18:46:35 +080033#include <sysdev/fsl_pci.h>
Jon Loeliger4ca4b622006-06-17 17:52:45 -050034#include <sysdev/fsl_soc.h>
35
36#include "mpc86xx.h"
37
Jon Loeliger919fede2006-07-31 15:35:41 -050038#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 Loeliger869d7f32006-08-15 16:19:02 -050046#ifdef CONFIG_PCI
Kumar Galab66510c2007-08-16 23:55:55 -050047extern int uli_exclude_device(struct pci_controller *hose,
48 u_char bus, u_char devfn);
Jon Loeliger4ca4b622006-06-17 17:52:45 -050049
Kumar Galab66510c2007-08-16 23:55:55 -050050static int mpc86xx_exclude_device(struct pci_controller *hose,
51 u_char bus, u_char devfn)
Jon Loeliger4ca4b622006-06-17 17:52:45 -050052{
Kumar Galab66510c2007-08-16 23:55:55 -050053 struct device_node* node;
54 struct resource rsrc;
Jon Loeliger4ca4b622006-06-17 17:52:45 -050055
Stephen Rothwell44ef3392007-12-10 14:33:21 +110056 node = hose->dn;
Kumar Galab66510c2007-08-16 23:55:55 -050057 of_address_to_resource(node, 0, &rsrc);
Jon Loeliger919fede2006-07-31 15:35:41 -050058
Kumar Galab66510c2007-08-16 23:55:55 -050059 if ((rsrc.start & 0xfffff) == 0x8000) {
60 return uli_exclude_device(hose, bus, devfn);
Jon Loeliger919fede2006-07-31 15:35:41 -050061 }
Kumar Gala9ad494f2006-06-28 00:37:45 -050062
Kumar Galab66510c2007-08-16 23:55:55 -050063 return PCIBIOS_SUCCESSFUL;
Jon Loeliger4ca4b622006-06-17 17:52:45 -050064}
Jon Loeliger4ca4b622006-06-17 17:52:45 -050065#endif /* CONFIG_PCI */
66
67
68static void __init
69mpc86xx_hpcn_setup_arch(void)
70{
Jon Loeligerd347b322007-07-27 13:24:36 -050071#ifdef CONFIG_PCI
Jon Loeliger4ca4b622006-06-17 17:52:45 -050072 struct device_node *np;
Jon Loeligerd347b322007-07-27 13:24:36 -050073#endif
Jon Loeliger4ca4b622006-06-17 17:52:45 -050074
75 if (ppc_md.progress)
76 ppc_md.progress("mpc86xx_hpcn_setup_arch()", 0);
77
Jon Loeliger4ca4b622006-06-17 17:52:45 -050078#ifdef CONFIG_PCI
Kumar Galac9438af2007-10-04 00:28:43 -050079 for_each_compatible_node(np, "pci", "fsl,mpc8641-pcie") {
Zang Roy-r619119ac4dd32007-07-10 18:46:35 +080080 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 Galac9438af2007-10-04 00:28:43 -050087
Kumar Galab66510c2007-08-16 23:55:55 -050088 ppc_md.pci_exclude_device = mpc86xx_exclude_device;
89
Jon Loeliger4ca4b622006-06-17 17:52:45 -050090#endif
91
92 printk("MPC86xx HPCN board from Freescale Semiconductor\n");
93
Jon Loeliger4ca4b622006-06-17 17:52:45 -050094#ifdef CONFIG_SMP
95 mpc86xx_smp_init();
96#endif
97}
98
99
Paul Gortmaker06f35b42008-04-16 13:53:06 -0400100static void
Jon Loeliger4ca4b622006-06-17 17:52:45 -0500101mpc86xx_hpcn_show_cpuinfo(struct seq_file *m)
102{
Jon Loeliger4ca4b622006-06-17 17:52:45 -0500103 uint svid = mfspr(SPRN_SVR);
104
105 seq_printf(m, "Vendor\t\t: Freescale Semiconductor\n");
106
Jon Loeliger4ca4b622006-06-17 17:52:45 -0500107 seq_printf(m, "SVR\t\t: 0x%x\n", svid);
Jon Loeliger4ca4b622006-06-17 17:52:45 -0500108}
109
110
111/*
112 * Called very early, device-tree isn't unflattened
113 */
114static int __init mpc86xx_hpcn_probe(void)
115{
116 unsigned long root = of_get_flat_dt_root();
117
Paul Gortmaker06f35b42008-04-16 13:53:06 -0400118 if (of_flat_dt_is_compatible(root, "fsl,mpc8641hpcn"))
Jon Loeliger4ca4b622006-06-17 17:52:45 -0500119 return 1; /* Looks good */
120
Paul Gortmaker16787b42008-04-16 13:53:07 -0400121 /* 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 Loeliger4ca4b622006-06-17 17:52:45 -0500127 return 0;
128}
129
Paul Gortmaker06f35b42008-04-16 13:53:06 -0400130static long __init
Jon Loeliger4ca4b622006-06-17 17:52:45 -0500131mpc86xx_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 Farnsworth15061d62008-01-22 13:17:45 -0700147static __initdata struct of_device_id of_bus_ids[] = {
148 { .compatible = "simple-bus", },
Zhang Wei182e1432008-04-18 13:33:43 -0700149 { .compatible = "fsl,rapidio-delta", },
Anton Vorontsovd8bc55f2009-03-19 21:01:51 +0300150 { .compatible = "gianfar", },
Wade Farnsworth15061d62008-01-22 13:17:45 -0700151 {},
152};
153
154static int __init declare_of_platform_devices(void)
155{
156 of_platform_bus_probe(NULL, of_bus_ids, NULL);
157
158 return 0;
159}
160machine_device_initcall(mpc86xx_hpcn, declare_of_platform_devices);
161
Jon Loeliger4ca4b622006-06-17 17:52:45 -0500162define_machine(mpc86xx_hpcn) {
163 .name = "MPC86xx HPCN",
164 .probe = mpc86xx_hpcn_probe,
165 .setup_arch = mpc86xx_hpcn_setup_arch,
Kumar Gala98384c62008-07-02 11:46:20 -0500166 .init_IRQ = mpc86xx_init_irq,
Jon Loeliger4ca4b622006-06-17 17:52:45 -0500167 .show_cpuinfo = mpc86xx_hpcn_show_cpuinfo,
Jon Loeliger4ca4b622006-06-17 17:52:45 -0500168 .get_irq = mpic_get_irq,
Kumar Galae1c15752007-10-04 01:04:57 -0500169 .restart = fsl_rstcr_restart,
Jon Loeliger4ca4b622006-06-17 17:52:45 -0500170 .time_init = mpc86xx_time_init,
171 .calibrate_decr = generic_calibrate_decr,
172 .progress = udbg_progress,
Kumar Gala2af85692007-09-10 14:30:33 -0500173#ifdef CONFIG_PCI
Kumar Gala6c0a11c2007-07-19 15:29:53 -0500174 .pcibios_fixup_bus = fsl_pcibios_fixup_bus,
Kumar Gala2af85692007-09-10 14:30:33 -0500175#endif
Jon Loeliger4ca4b622006-06-17 17:52:45 -0500176};