blob: b11c3535f3509cac28e2baf7fd5e999001ab0709 [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>
Yinghai Lu95f72d12010-07-12 14:36:09 +100022#include <linux/memblock.h>
Jon Loeliger4ca4b622006-06-17 17:52:45 -050023
24#include <asm/system.h>
25#include <asm/time.h>
26#include <asm/machdep.h>
27#include <asm/pci-bridge.h>
Jon Loeliger4ca4b622006-06-17 17:52:45 -050028#include <asm/prom.h>
29#include <mm/mmu_decl.h>
30#include <asm/udbg.h>
Becky Bruce5cef3792009-05-14 17:42:29 -050031#include <asm/swiotlb.h>
Jon Loeliger4ca4b622006-06-17 17:52:45 -050032
33#include <asm/mpic.h>
34
Zang Roy-r619119ac4dd32007-07-10 18:46:35 +080035#include <sysdev/fsl_pci.h>
Jon Loeliger4ca4b622006-06-17 17:52:45 -050036#include <sysdev/fsl_soc.h>
37
38#include "mpc86xx.h"
39
Jon Loeliger919fede2006-07-31 15:35:41 -050040#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 Loeliger869d7f32006-08-15 16:19:02 -050048#ifdef CONFIG_PCI
Kumar Galab66510c2007-08-16 23:55:55 -050049extern int uli_exclude_device(struct pci_controller *hose,
50 u_char bus, u_char devfn);
Jon Loeliger4ca4b622006-06-17 17:52:45 -050051
Kumar Galab66510c2007-08-16 23:55:55 -050052static int mpc86xx_exclude_device(struct pci_controller *hose,
53 u_char bus, u_char devfn)
Jon Loeliger4ca4b622006-06-17 17:52:45 -050054{
Kumar Galab66510c2007-08-16 23:55:55 -050055 struct device_node* node;
56 struct resource rsrc;
Jon Loeliger4ca4b622006-06-17 17:52:45 -050057
Stephen Rothwell44ef3392007-12-10 14:33:21 +110058 node = hose->dn;
Kumar Galab66510c2007-08-16 23:55:55 -050059 of_address_to_resource(node, 0, &rsrc);
Jon Loeliger919fede2006-07-31 15:35:41 -050060
Kumar Galab66510c2007-08-16 23:55:55 -050061 if ((rsrc.start & 0xfffff) == 0x8000) {
62 return uli_exclude_device(hose, bus, devfn);
Jon Loeliger919fede2006-07-31 15:35:41 -050063 }
Kumar Gala9ad494f2006-06-28 00:37:45 -050064
Kumar Galab66510c2007-08-16 23:55:55 -050065 return PCIBIOS_SUCCESSFUL;
Jon Loeliger4ca4b622006-06-17 17:52:45 -050066}
Jon Loeliger4ca4b622006-06-17 17:52:45 -050067#endif /* CONFIG_PCI */
68
69
70static void __init
71mpc86xx_hpcn_setup_arch(void)
72{
Jon Loeligerd347b322007-07-27 13:24:36 -050073#ifdef CONFIG_PCI
Jon Loeliger4ca4b622006-06-17 17:52:45 -050074 struct device_node *np;
Becky Bruce5cef3792009-05-14 17:42:29 -050075 struct pci_controller *hose;
Jon Loeligerd347b322007-07-27 13:24:36 -050076#endif
Becky Bruce5cef3792009-05-14 17:42:29 -050077 dma_addr_t max = 0xffffffff;
Jon Loeliger4ca4b622006-06-17 17:52:45 -050078
79 if (ppc_md.progress)
80 ppc_md.progress("mpc86xx_hpcn_setup_arch()", 0);
81
Jon Loeliger4ca4b622006-06-17 17:52:45 -050082#ifdef CONFIG_PCI
Kumar Galac9438af2007-10-04 00:28:43 -050083 for_each_compatible_node(np, "pci", "fsl,mpc8641-pcie") {
Zang Roy-r619119ac4dd32007-07-10 18:46:35 +080084 struct resource rsrc;
85 of_address_to_resource(np, 0, &rsrc);
86 if ((rsrc.start & 0xfffff) == 0x8000)
87 fsl_add_bridge(np, 1);
88 else
89 fsl_add_bridge(np, 0);
Becky Bruce5cef3792009-05-14 17:42:29 -050090 hose = pci_find_hose_for_OF_device(np);
91 max = min(max, hose->dma_window_base_cur +
92 hose->dma_window_size);
Zang Roy-r619119ac4dd32007-07-10 18:46:35 +080093 }
Kumar Galac9438af2007-10-04 00:28:43 -050094
Kumar Galab66510c2007-08-16 23:55:55 -050095 ppc_md.pci_exclude_device = mpc86xx_exclude_device;
96
Jon Loeliger4ca4b622006-06-17 17:52:45 -050097#endif
98
99 printk("MPC86xx HPCN board from Freescale Semiconductor\n");
100
Jon Loeliger4ca4b622006-06-17 17:52:45 -0500101#ifdef CONFIG_SMP
102 mpc86xx_smp_init();
103#endif
Becky Bruce5cef3792009-05-14 17:42:29 -0500104
105#ifdef CONFIG_SWIOTLB
Yinghai Lu95f72d12010-07-12 14:36:09 +1000106 if (memblock_end_of_DRAM() > max) {
Becky Bruce5cef3792009-05-14 17:42:29 -0500107 ppc_swiotlb_enable = 1;
FUJITA Tomonori37029772009-08-04 19:08:23 +0000108 set_pci_dma_ops(&swiotlb_dma_ops);
FUJITA Tomonori762afb72009-08-04 19:08:22 +0000109 ppc_md.pci_dma_dev_setup = pci_dma_dev_setup_swiotlb;
Becky Bruce5cef3792009-05-14 17:42:29 -0500110 }
111#endif
Jon Loeliger4ca4b622006-06-17 17:52:45 -0500112}
113
114
Paul Gortmaker06f35b42008-04-16 13:53:06 -0400115static void
Jon Loeliger4ca4b622006-06-17 17:52:45 -0500116mpc86xx_hpcn_show_cpuinfo(struct seq_file *m)
117{
Jon Loeliger4ca4b622006-06-17 17:52:45 -0500118 uint svid = mfspr(SPRN_SVR);
119
120 seq_printf(m, "Vendor\t\t: Freescale Semiconductor\n");
121
Jon Loeliger4ca4b622006-06-17 17:52:45 -0500122 seq_printf(m, "SVR\t\t: 0x%x\n", svid);
Jon Loeliger4ca4b622006-06-17 17:52:45 -0500123}
124
125
126/*
127 * Called very early, device-tree isn't unflattened
128 */
129static int __init mpc86xx_hpcn_probe(void)
130{
131 unsigned long root = of_get_flat_dt_root();
132
Paul Gortmaker06f35b42008-04-16 13:53:06 -0400133 if (of_flat_dt_is_compatible(root, "fsl,mpc8641hpcn"))
Jon Loeliger4ca4b622006-06-17 17:52:45 -0500134 return 1; /* Looks good */
135
Paul Gortmaker16787b42008-04-16 13:53:07 -0400136 /* Be nice and don't give silent boot death. Delete this in 2.6.27 */
137 if (of_flat_dt_is_compatible(root, "mpc86xx")) {
138 pr_warning("WARNING: your dts/dtb is old. You must update before the next kernel release\n");
139 return 1;
140 }
141
Jon Loeliger4ca4b622006-06-17 17:52:45 -0500142 return 0;
143}
144
Paul Gortmaker06f35b42008-04-16 13:53:06 -0400145static long __init
Jon Loeliger4ca4b622006-06-17 17:52:45 -0500146mpc86xx_time_init(void)
147{
148 unsigned int temp;
149
150 /* Set the time base to zero */
151 mtspr(SPRN_TBWL, 0);
152 mtspr(SPRN_TBWU, 0);
153
154 temp = mfspr(SPRN_HID0);
155 temp |= HID0_TBEN;
156 mtspr(SPRN_HID0, temp);
157 asm volatile("isync");
158
159 return 0;
160}
161
Wade Farnsworth15061d62008-01-22 13:17:45 -0700162static __initdata struct of_device_id of_bus_ids[] = {
163 { .compatible = "simple-bus", },
Zhang Wei182e1432008-04-18 13:33:43 -0700164 { .compatible = "fsl,rapidio-delta", },
Anton Vorontsovd8bc55f2009-03-19 21:01:51 +0300165 { .compatible = "gianfar", },
Wade Farnsworth15061d62008-01-22 13:17:45 -0700166 {},
167};
168
169static int __init declare_of_platform_devices(void)
170{
171 of_platform_bus_probe(NULL, of_bus_ids, NULL);
172
173 return 0;
174}
175machine_device_initcall(mpc86xx_hpcn, declare_of_platform_devices);
Becky Bruce5cef3792009-05-14 17:42:29 -0500176machine_arch_initcall(mpc86xx_hpcn, swiotlb_setup_bus_notifier);
Wade Farnsworth15061d62008-01-22 13:17:45 -0700177
Jon Loeliger4ca4b622006-06-17 17:52:45 -0500178define_machine(mpc86xx_hpcn) {
179 .name = "MPC86xx HPCN",
180 .probe = mpc86xx_hpcn_probe,
181 .setup_arch = mpc86xx_hpcn_setup_arch,
Kumar Gala98384c62008-07-02 11:46:20 -0500182 .init_IRQ = mpc86xx_init_irq,
Jon Loeliger4ca4b622006-06-17 17:52:45 -0500183 .show_cpuinfo = mpc86xx_hpcn_show_cpuinfo,
Jon Loeliger4ca4b622006-06-17 17:52:45 -0500184 .get_irq = mpic_get_irq,
Kumar Galae1c15752007-10-04 01:04:57 -0500185 .restart = fsl_rstcr_restart,
Jon Loeliger4ca4b622006-06-17 17:52:45 -0500186 .time_init = mpc86xx_time_init,
187 .calibrate_decr = generic_calibrate_decr,
188 .progress = udbg_progress,
Kumar Gala2af85692007-09-10 14:30:33 -0500189#ifdef CONFIG_PCI
Kumar Gala6c0a11c2007-07-19 15:29:53 -0500190 .pcibios_fixup_bus = fsl_pcibios_fixup_bus,
Kumar Gala2af85692007-09-10 14:30:33 -0500191#endif
Jon Loeliger4ca4b622006-06-17 17:52:45 -0500192};