Merge branch 'linus' into core/generic-dma-coherent
[pandora-kernel.git] / arch / powerpc / platforms / 86xx / sbc8641d.c
1 /*
2  * SBC8641D board specific routines
3  *
4  * Copyright 2008 Wind River Systems Inc.
5  *
6  * By Paul Gortmaker (see MAINTAINERS for contact information)
7  *
8  * Based largely on the 8641 HPCN support by Freescale Semiconductor Inc.
9  *
10  * This program is free software; you can redistribute  it and/or modify it
11  * under  the terms of  the GNU General  Public License as published by the
12  * Free Software Foundation;  either version 2 of the  License, or (at your
13  * option) any later version.
14  */
15
16 #include <linux/stddef.h>
17 #include <linux/kernel.h>
18 #include <linux/pci.h>
19 #include <linux/kdev_t.h>
20 #include <linux/delay.h>
21 #include <linux/seq_file.h>
22 #include <linux/of_platform.h>
23
24 #include <asm/system.h>
25 #include <asm/time.h>
26 #include <asm/machdep.h>
27 #include <asm/pci-bridge.h>
28 #include <asm/mpc86xx.h>
29 #include <asm/prom.h>
30 #include <mm/mmu_decl.h>
31 #include <asm/udbg.h>
32
33 #include <asm/mpic.h>
34
35 #include <sysdev/fsl_pci.h>
36 #include <sysdev/fsl_soc.h>
37
38 #include "mpc86xx.h"
39
40 static void __init
41 sbc8641_setup_arch(void)
42 {
43 #ifdef CONFIG_PCI
44         struct device_node *np;
45 #endif
46
47         if (ppc_md.progress)
48                 ppc_md.progress("sbc8641_setup_arch()", 0);
49
50 #ifdef CONFIG_PCI
51         for_each_compatible_node(np, "pci", "fsl,mpc8641-pcie")
52                 fsl_add_bridge(np, 0);
53 #endif
54
55         printk("SBC8641 board from Wind River\n");
56
57 #ifdef CONFIG_SMP
58         mpc86xx_smp_init();
59 #endif
60 }
61
62
63 static void
64 sbc8641_show_cpuinfo(struct seq_file *m)
65 {
66         struct device_node *root;
67         uint memsize = total_memory;
68         const char *model = "";
69         uint svid = mfspr(SPRN_SVR);
70
71         seq_printf(m, "Vendor\t\t: Wind River Systems\n");
72
73         root = of_find_node_by_path("/");
74         if (root)
75                 model = of_get_property(root, "model", NULL);
76         seq_printf(m, "Machine\t\t: %s\n", model);
77         of_node_put(root);
78
79         seq_printf(m, "SVR\t\t: 0x%x\n", svid);
80         seq_printf(m, "Memory\t\t: %d MB\n", memsize / (1024 * 1024));
81 }
82
83
84 /*
85  * Called very early, device-tree isn't unflattened
86  */
87 static int __init sbc8641_probe(void)
88 {
89         unsigned long root = of_get_flat_dt_root();
90
91         if (of_flat_dt_is_compatible(root, "wind,sbc8641"))
92                 return 1;       /* Looks good */
93
94         return 0;
95 }
96
97 static long __init
98 mpc86xx_time_init(void)
99 {
100         unsigned int temp;
101
102         /* Set the time base to zero */
103         mtspr(SPRN_TBWL, 0);
104         mtspr(SPRN_TBWU, 0);
105
106         temp = mfspr(SPRN_HID0);
107         temp |= HID0_TBEN;
108         mtspr(SPRN_HID0, temp);
109         asm volatile("isync");
110
111         return 0;
112 }
113
114 static __initdata struct of_device_id of_bus_ids[] = {
115         { .compatible = "simple-bus", },
116         {},
117 };
118
119 static int __init declare_of_platform_devices(void)
120 {
121         of_platform_bus_probe(NULL, of_bus_ids, NULL);
122
123         return 0;
124 }
125 machine_device_initcall(sbc8641, declare_of_platform_devices);
126
127 define_machine(sbc8641) {
128         .name                   = "SBC8641D",
129         .probe                  = sbc8641_probe,
130         .setup_arch             = sbc8641_setup_arch,
131         .init_IRQ               = mpc86xx_init_irq,
132         .show_cpuinfo           = sbc8641_show_cpuinfo,
133         .get_irq                = mpic_get_irq,
134         .restart                = fsl_rstcr_restart,
135         .time_init              = mpc86xx_time_init,
136         .calibrate_decr         = generic_calibrate_decr,
137         .progress               = udbg_progress,
138 #ifdef CONFIG_PCI
139         .pcibios_fixup_bus      = fsl_pcibios_fixup_bus,
140 #endif
141 };