blob: e8bf3fae56060dfa2645701db57839e8092f8e28 [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
Jon Loeliger4ca4b622006-06-17 17:52:45 -050023#include <asm/time.h>
24#include <asm/machdep.h>
25#include <asm/pci-bridge.h>
Jon Loeliger4ca4b622006-06-17 17:52:45 -050026#include <asm/prom.h>
27#include <mm/mmu_decl.h>
28#include <asm/udbg.h>
Becky Bruce5cef3792009-05-14 17:42:29 -050029#include <asm/swiotlb.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{
Jia Hongtao905e75c2012-08-28 15:44:08 +080053 if (hose->dn == fsl_pci_primary)
Kumar Galab66510c2007-08-16 23:55:55 -050054 return uli_exclude_device(hose, bus, devfn);
Kumar Gala9ad494f2006-06-28 00:37:45 -050055
Kumar Galab66510c2007-08-16 23:55:55 -050056 return PCIBIOS_SUCCESSFUL;
Jon Loeliger4ca4b622006-06-17 17:52:45 -050057}
Jon Loeliger4ca4b622006-06-17 17:52:45 -050058#endif /* CONFIG_PCI */
59
60
61static void __init
62mpc86xx_hpcn_setup_arch(void)
63{
Jon Loeliger4ca4b622006-06-17 17:52:45 -050064 if (ppc_md.progress)
65 ppc_md.progress("mpc86xx_hpcn_setup_arch()", 0);
66
Jon Loeliger4ca4b622006-06-17 17:52:45 -050067#ifdef CONFIG_PCI
Kumar Galab66510c2007-08-16 23:55:55 -050068 ppc_md.pci_exclude_device = mpc86xx_exclude_device;
Jon Loeliger4ca4b622006-06-17 17:52:45 -050069#endif
70
71 printk("MPC86xx HPCN board from Freescale Semiconductor\n");
72
Jon Loeliger4ca4b622006-06-17 17:52:45 -050073#ifdef CONFIG_SMP
74 mpc86xx_smp_init();
75#endif
Becky Bruce5cef3792009-05-14 17:42:29 -050076
Jia Hongtao905e75c2012-08-28 15:44:08 +080077 fsl_pci_assign_primary();
78
79 swiotlb_detect_4g();
Jon Loeliger4ca4b622006-06-17 17:52:45 -050080}
81
82
Paul Gortmaker06f35b42008-04-16 13:53:06 -040083static void
Jon Loeliger4ca4b622006-06-17 17:52:45 -050084mpc86xx_hpcn_show_cpuinfo(struct seq_file *m)
85{
Jon Loeliger4ca4b622006-06-17 17:52:45 -050086 uint svid = mfspr(SPRN_SVR);
87
88 seq_printf(m, "Vendor\t\t: Freescale Semiconductor\n");
89
Jon Loeliger4ca4b622006-06-17 17:52:45 -050090 seq_printf(m, "SVR\t\t: 0x%x\n", svid);
Jon Loeliger4ca4b622006-06-17 17:52:45 -050091}
92
93
94/*
95 * Called very early, device-tree isn't unflattened
96 */
97static int __init mpc86xx_hpcn_probe(void)
98{
99 unsigned long root = of_get_flat_dt_root();
100
Paul Gortmaker06f35b42008-04-16 13:53:06 -0400101 if (of_flat_dt_is_compatible(root, "fsl,mpc8641hpcn"))
Jon Loeliger4ca4b622006-06-17 17:52:45 -0500102 return 1; /* Looks good */
103
Paul Gortmaker16787b42008-04-16 13:53:07 -0400104 /* Be nice and don't give silent boot death. Delete this in 2.6.27 */
105 if (of_flat_dt_is_compatible(root, "mpc86xx")) {
106 pr_warning("WARNING: your dts/dtb is old. You must update before the next kernel release\n");
107 return 1;
108 }
109
Jon Loeliger4ca4b622006-06-17 17:52:45 -0500110 return 0;
111}
112
Paul Gortmaker06f35b42008-04-16 13:53:06 -0400113static long __init
Jon Loeliger4ca4b622006-06-17 17:52:45 -0500114mpc86xx_time_init(void)
115{
116 unsigned int temp;
117
118 /* Set the time base to zero */
119 mtspr(SPRN_TBWL, 0);
120 mtspr(SPRN_TBWU, 0);
121
122 temp = mfspr(SPRN_HID0);
123 temp |= HID0_TBEN;
124 mtspr(SPRN_HID0, temp);
125 asm volatile("isync");
126
127 return 0;
128}
129
Wade Farnsworth15061d62008-01-22 13:17:45 -0700130static __initdata struct of_device_id of_bus_ids[] = {
131 { .compatible = "simple-bus", },
Kai Jiang077200c2011-11-12 20:02:31 +0800132 { .compatible = "fsl,srio", },
Anton Vorontsovd8bc55f2009-03-19 21:01:51 +0300133 { .compatible = "gianfar", },
Jia Hongtao905e75c2012-08-28 15:44:08 +0800134 { .compatible = "fsl,mpc8641-pcie", },
Wade Farnsworth15061d62008-01-22 13:17:45 -0700135 {},
136};
137
138static int __init declare_of_platform_devices(void)
139{
140 of_platform_bus_probe(NULL, of_bus_ids, NULL);
141
142 return 0;
143}
Jia Hongtao905e75c2012-08-28 15:44:08 +0800144machine_arch_initcall(mpc86xx_hpcn, declare_of_platform_devices);
Becky Bruce5cef3792009-05-14 17:42:29 -0500145machine_arch_initcall(mpc86xx_hpcn, swiotlb_setup_bus_notifier);
Wade Farnsworth15061d62008-01-22 13:17:45 -0700146
Jon Loeliger4ca4b622006-06-17 17:52:45 -0500147define_machine(mpc86xx_hpcn) {
148 .name = "MPC86xx HPCN",
149 .probe = mpc86xx_hpcn_probe,
150 .setup_arch = mpc86xx_hpcn_setup_arch,
Kumar Gala98384c62008-07-02 11:46:20 -0500151 .init_IRQ = mpc86xx_init_irq,
Jon Loeliger4ca4b622006-06-17 17:52:45 -0500152 .show_cpuinfo = mpc86xx_hpcn_show_cpuinfo,
Jon Loeliger4ca4b622006-06-17 17:52:45 -0500153 .get_irq = mpic_get_irq,
Kumar Galae1c15752007-10-04 01:04:57 -0500154 .restart = fsl_rstcr_restart,
Jon Loeliger4ca4b622006-06-17 17:52:45 -0500155 .time_init = mpc86xx_time_init,
156 .calibrate_decr = generic_calibrate_decr,
157 .progress = udbg_progress,
Kumar Gala2af85692007-09-10 14:30:33 -0500158#ifdef CONFIG_PCI
Kumar Gala6c0a11c2007-07-19 15:29:53 -0500159 .pcibios_fixup_bus = fsl_pcibios_fixup_bus,
Kumar Gala2af85692007-09-10 14:30:33 -0500160#endif
Jon Loeliger4ca4b622006-06-17 17:52:45 -0500161};