powerpc/85xx/86xx: some refactoring for fsl_uli1575 code
[deliverable/linux.git] / arch / powerpc / platforms / 86xx / mpc86xx_hpcn.c
CommitLineData
4ca4b627
JL
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
4ca4b627
JL
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>
15061d60 21#include <linux/of_platform.h>
4ca4b627
JL
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>
4ca4b627
JL
31
32#include <asm/mpic.h>
33
9ac4dd30 34#include <sysdev/fsl_pci.h>
4ca4b627
JL
35#include <sysdev/fsl_soc.h>
36
37#include "mpc86xx.h"
38
919fede6
JL
39#undef DEBUG
40
41#ifdef DEBUG
42#define DBG(fmt...) do { printk(KERN_ERR fmt); } while(0)
43#else
44#define DBG(fmt...) do { } while(0)
45#endif
46
4ca4b627 47#ifdef CONFIG_PCI
b66510cb
KG
48extern int uli_exclude_device(struct pci_controller *hose,
49 u_char bus, u_char devfn);
4ca4b627 50
b66510cb
KG
51static int mpc86xx_exclude_device(struct pci_controller *hose,
52 u_char bus, u_char devfn)
4ca4b627 53{
b66510cb
KG
54 struct device_node* node;
55 struct resource rsrc;
9ad494f6 56
44ef3390 57 node = hose->dn;
b66510cb 58 of_address_to_resource(node, 0, &rsrc);
9ad494f6 59
b66510cb
KG
60 if ((rsrc.start & 0xfffff) == 0x8000) {
61 return uli_exclude_device(hose, bus, devfn);
62 }
9ad494f6 63
b66510cb 64 return PCIBIOS_SUCCESSFUL;
9ad494f6 65}
4ca4b627
JL
66#endif /* CONFIG_PCI */
67
68
69static void __init
70mpc86xx_hpcn_setup_arch(void)
71{
d347b329 72#ifdef CONFIG_PCI
4ca4b627 73 struct device_node *np;
d347b329 74#endif
4ca4b627
JL
75
76 if (ppc_md.progress)
77 ppc_md.progress("mpc86xx_hpcn_setup_arch()", 0);
78
4ca4b627 79#ifdef CONFIG_PCI
c9438aff 80 for_each_compatible_node(np, "pci", "fsl,mpc8641-pcie") {
9ac4dd30
ZR
81 struct resource rsrc;
82 of_address_to_resource(np, 0, &rsrc);
83 if ((rsrc.start & 0xfffff) == 0x8000)
84 fsl_add_bridge(np, 1);
85 else
86 fsl_add_bridge(np, 0);
87 }
c9438aff 88
b66510cb
KG
89 ppc_md.pci_exclude_device = mpc86xx_exclude_device;
90
4ca4b627
JL
91#endif
92
93 printk("MPC86xx HPCN board from Freescale Semiconductor\n");
94
4ca4b627
JL
95#ifdef CONFIG_SMP
96 mpc86xx_smp_init();
97#endif
98}
99
100
06f35b4b 101static void
4ca4b627
JL
102mpc86xx_hpcn_show_cpuinfo(struct seq_file *m)
103{
104 struct device_node *root;
105 uint memsize = total_memory;
106 const char *model = "";
107 uint svid = mfspr(SPRN_SVR);
108
109 seq_printf(m, "Vendor\t\t: Freescale Semiconductor\n");
110
111 root = of_find_node_by_path("/");
112 if (root)
e2eb6392 113 model = of_get_property(root, "model", NULL);
4ca4b627
JL
114 seq_printf(m, "Machine\t\t: %s\n", model);
115 of_node_put(root);
116
117 seq_printf(m, "SVR\t\t: 0x%x\n", svid);
118 seq_printf(m, "Memory\t\t: %d MB\n", memsize / (1024 * 1024));
119}
120
121
122/*
123 * Called very early, device-tree isn't unflattened
124 */
125static int __init mpc86xx_hpcn_probe(void)
126{
127 unsigned long root = of_get_flat_dt_root();
128
06f35b4b 129 if (of_flat_dt_is_compatible(root, "fsl,mpc8641hpcn"))
4ca4b627
JL
130 return 1; /* Looks good */
131
16787b43
PG
132 /* Be nice and don't give silent boot death. Delete this in 2.6.27 */
133 if (of_flat_dt_is_compatible(root, "mpc86xx")) {
134 pr_warning("WARNING: your dts/dtb is old. You must update before the next kernel release\n");
135 return 1;
136 }
137
4ca4b627
JL
138 return 0;
139}
140
06f35b4b 141static long __init
4ca4b627
JL
142mpc86xx_time_init(void)
143{
144 unsigned int temp;
145
146 /* Set the time base to zero */
147 mtspr(SPRN_TBWL, 0);
148 mtspr(SPRN_TBWU, 0);
149
150 temp = mfspr(SPRN_HID0);
151 temp |= HID0_TBEN;
152 mtspr(SPRN_HID0, temp);
153 asm volatile("isync");
154
155 return 0;
156}
157
15061d60
WF
158static __initdata struct of_device_id of_bus_ids[] = {
159 { .compatible = "simple-bus", },
182e143b 160 { .compatible = "fsl,rapidio-delta", },
15061d60
WF
161 {},
162};
163
164static int __init declare_of_platform_devices(void)
165{
166 of_platform_bus_probe(NULL, of_bus_ids, NULL);
167
168 return 0;
169}
170machine_device_initcall(mpc86xx_hpcn, declare_of_platform_devices);
171
4ca4b627
JL
172define_machine(mpc86xx_hpcn) {
173 .name = "MPC86xx HPCN",
174 .probe = mpc86xx_hpcn_probe,
175 .setup_arch = mpc86xx_hpcn_setup_arch,
98384c6c 176 .init_IRQ = mpc86xx_init_irq,
4ca4b627
JL
177 .show_cpuinfo = mpc86xx_hpcn_show_cpuinfo,
178 .get_irq = mpic_get_irq,
e1c1575f 179 .restart = fsl_rstcr_restart,
4ca4b627
JL
180 .time_init = mpc86xx_time_init,
181 .calibrate_decr = generic_calibrate_decr,
182 .progress = udbg_progress,
2af8569d 183#ifdef CONFIG_PCI
6c0a11c1 184 .pcibios_fixup_bus = fsl_pcibios_fixup_bus,
2af8569d 185#endif
4ca4b627 186};
This page took 0.19941 seconds and 5 git commands to generate.