2 * Board setup routines for the Buffalo Linkstation / Kurobox Platform.
4 * Copyright (C) 2006 G. Liakhovetski (g.liakhovetski@gmx.de)
6 * Based on sandpoint.c by Mark A. Greer
8 * This file is licensed under the terms of the GNU General Public License
9 * version 2. This program is licensed "as is" without any warranty of
10 * any kind, whether express or implied.
13 #include <linux/kernel.h>
14 #include <linux/initrd.h>
15 #include <linux/mtd/physmap.h>
16 #include <linux/of_platform.h>
21 #include <asm/pci-bridge.h>
25 static struct mtd_partition linkstation_physmap_partitions
[] = {
27 .name
= "mtd_firmimg",
32 .name
= "mtd_bootcode",
47 .name
= "mtd_allflash",
58 static __initdata
struct of_device_id of_bus_ids
[] = {
60 { .compatible
= "simple-bus", },
64 static int __init
declare_of_platform_devices(void)
66 of_platform_bus_probe(NULL
, of_bus_ids
, NULL
);
69 machine_device_initcall(linkstation
, declare_of_platform_devices
);
71 static int __init
linkstation_add_bridge(struct device_node
*dev
)
75 struct pci_controller
*hose
;
78 printk("Adding PCI host bridge %s\n", dev
->full_name
);
80 bus_range
= of_get_property(dev
, "bus-range", &len
);
81 if (bus_range
== NULL
|| len
< 2 * sizeof(int))
82 printk(KERN_WARNING
"Can't get bus-range for %s, assume"
83 " bus 0\n", dev
->full_name
);
85 hose
= pcibios_alloc_controller(dev
);
88 hose
->first_busno
= bus_range
? bus_range
[0] : 0;
89 hose
->last_busno
= bus_range
? bus_range
[1] : 0xff;
90 setup_indirect_pci(hose
, 0xfec00000, 0xfee00000, 0);
92 /* Interpret the "ranges" property */
93 /* This also maps the I/O region and sets isa_io/mem_base */
94 pci_process_bridge_OF_ranges(hose
, dev
, 1);
99 static void __init
linkstation_setup_arch(void)
101 struct device_node
*np
;
102 #ifdef CONFIG_MTD_PHYSMAP
103 physmap_set_partitions(linkstation_physmap_partitions
,
104 ARRAY_SIZE(linkstation_physmap_partitions
));
107 /* Lookup PCI host bridges */
108 for_each_compatible_node(np
, "pci", "mpc10x-pci")
109 linkstation_add_bridge(np
);
111 printk(KERN_INFO
"BUFFALO Network Attached Storage Series\n");
112 printk(KERN_INFO
"(C) 2002-2005 BUFFALO INC.\n");
116 * Interrupt setup and service. Interrupts on the linkstation come
117 * from the four PCI slots plus onboard 8241 devices: I2C, DUART.
119 static void __init
linkstation_init_IRQ(void)
122 struct device_node
*dnp
;
127 dnp
= of_find_node_by_type(NULL
, "open-pic");
131 prop
= of_get_property(dnp
, "reg", &size
);
132 paddr
= (phys_addr_t
)of_translate_address(dnp
, prop
);
134 mpic
= mpic_alloc(dnp
, paddr
, MPIC_PRIMARY
| MPIC_WANTS_RESET
, 4, 32, " EPIC ");
135 BUG_ON(mpic
== NULL
);
138 mpic_assign_isu(mpic
, 0, paddr
+ 0x10200);
141 mpic_assign_isu(mpic
, 1, paddr
+ 0x11000);
144 mpic_assign_isu(mpic
, 2, paddr
+ 0x11100);
149 extern void avr_uart_configure(void);
150 extern void avr_uart_send(const char);
152 static void linkstation_restart(char *cmd
)
156 /* Reset system via AVR */
157 avr_uart_configure();
158 /* Send reboot command */
161 for(;;) /* Spin until reset happens */
162 avr_uart_send('G'); /* "kick" */
165 static void linkstation_power_off(void)
169 /* Power down system via AVR */
170 avr_uart_configure();
171 /* send shutdown command */
174 for(;;) /* Spin until power-off happens */
175 avr_uart_send('G'); /* "kick" */
179 static void linkstation_halt(void)
181 linkstation_power_off();
185 static void linkstation_show_cpuinfo(struct seq_file
*m
)
187 seq_printf(m
, "vendor\t\t: Buffalo Technology\n");
188 seq_printf(m
, "machine\t\t: Linkstation I/Kurobox(HG)\n");
191 static int __init
linkstation_probe(void)
195 root
= of_get_flat_dt_root();
197 if (!of_flat_dt_is_compatible(root
, "linkstation"))
202 define_machine(linkstation
){
203 .name
= "Buffalo Linkstation",
204 .probe
= linkstation_probe
,
205 .setup_arch
= linkstation_setup_arch
,
206 .init_IRQ
= linkstation_init_IRQ
,
207 .show_cpuinfo
= linkstation_show_cpuinfo
,
208 .get_irq
= mpic_get_irq
,
209 .restart
= linkstation_restart
,
210 .power_off
= linkstation_power_off
,
211 .halt
= linkstation_halt
,
212 .calibrate_decr
= generic_calibrate_decr
,