1
2
3
4
5
6
7
8
9
10
11
12
13#include <linux/kernel.h>
14#include <linux/initrd.h>
15#include <linux/of_platform.h>
16
17#include <asm/time.h>
18#include <asm/prom.h>
19#include <asm/mpic.h>
20#include <asm/pci-bridge.h>
21
22#include "mpc10x.h"
23
24static const struct of_device_id of_bus_ids[] __initconst = {
25 { .type = "soc", },
26 { .compatible = "simple-bus", },
27 {},
28};
29
30static int __init declare_of_platform_devices(void)
31{
32 of_platform_bus_probe(NULL, of_bus_ids, NULL);
33 return 0;
34}
35machine_device_initcall(linkstation, declare_of_platform_devices);
36
37static int __init linkstation_add_bridge(struct device_node *dev)
38{
39#ifdef CONFIG_PCI
40 int len;
41 struct pci_controller *hose;
42 const int *bus_range;
43
44 printk("Adding PCI host bridge %pOF\n", dev);
45
46 bus_range = of_get_property(dev, "bus-range", &len);
47 if (bus_range == NULL || len < 2 * sizeof(int))
48 printk(KERN_WARNING "Can't get bus-range for %pOF, assume"
49 " bus 0\n", dev);
50
51 hose = pcibios_alloc_controller(dev);
52 if (hose == NULL)
53 return -ENOMEM;
54 hose->first_busno = bus_range ? bus_range[0] : 0;
55 hose->last_busno = bus_range ? bus_range[1] : 0xff;
56 setup_indirect_pci(hose, 0xfec00000, 0xfee00000, 0);
57
58
59
60 pci_process_bridge_OF_ranges(hose, dev, 1);
61#endif
62 return 0;
63}
64
65static void __init linkstation_setup_arch(void)
66{
67 printk(KERN_INFO "BUFFALO Network Attached Storage Series\n");
68 printk(KERN_INFO "(C) 2002-2005 BUFFALO INC.\n");
69}
70
71static void __init linkstation_setup_pci(void)
72{
73 struct device_node *np;
74
75
76 for_each_compatible_node(np, "pci", "mpc10x-pci")
77 linkstation_add_bridge(np);
78}
79
80
81
82
83
84static void __init linkstation_init_IRQ(void)
85{
86 struct mpic *mpic;
87
88 mpic = mpic_alloc(NULL, 0, 0, 4, 0, " EPIC ");
89 BUG_ON(mpic == NULL);
90
91
92 mpic_assign_isu(mpic, 0, mpic->paddr + 0x10200);
93
94
95 mpic_assign_isu(mpic, 1, mpic->paddr + 0x11000);
96
97
98 mpic_assign_isu(mpic, 2, mpic->paddr + 0x11100);
99
100 mpic_init(mpic);
101}
102
103extern void avr_uart_configure(void);
104extern void avr_uart_send(const char);
105
106static void __noreturn linkstation_restart(char *cmd)
107{
108 local_irq_disable();
109
110
111 avr_uart_configure();
112
113 avr_uart_send('C');
114
115 for(;;)
116 avr_uart_send('G');
117}
118
119static void __noreturn linkstation_power_off(void)
120{
121 local_irq_disable();
122
123
124 avr_uart_configure();
125
126 avr_uart_send('E');
127
128 for(;;)
129 avr_uart_send('G');
130
131}
132
133static void __noreturn linkstation_halt(void)
134{
135 linkstation_power_off();
136
137}
138
139static void linkstation_show_cpuinfo(struct seq_file *m)
140{
141 seq_printf(m, "vendor\t\t: Buffalo Technology\n");
142 seq_printf(m, "machine\t\t: Linkstation I/Kurobox(HG)\n");
143}
144
145static int __init linkstation_probe(void)
146{
147 if (!of_machine_is_compatible("linkstation"))
148 return 0;
149
150 pm_power_off = linkstation_power_off;
151
152 return 1;
153}
154
155define_machine(linkstation){
156 .name = "Buffalo Linkstation",
157 .probe = linkstation_probe,
158 .setup_arch = linkstation_setup_arch,
159 .discover_phbs = linkstation_setup_pci,
160 .init_IRQ = linkstation_init_IRQ,
161 .show_cpuinfo = linkstation_show_cpuinfo,
162 .get_irq = mpic_get_irq,
163 .restart = linkstation_restart,
164 .halt = linkstation_halt,
165 .calibrate_decr = generic_calibrate_decr,
166};
167