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/of_platform.h>
19 #include <asm/pci-bridge.h>
23 static const struct of_device_id of_bus_ids[] __initconst = {
25 { .compatible = "simple-bus", },
29 static int __init declare_of_platform_devices(void)
31 of_platform_bus_probe(NULL, of_bus_ids, NULL);
34 machine_device_initcall(linkstation, declare_of_platform_devices);
36 static int __init linkstation_add_bridge(struct device_node *dev)
40 struct pci_controller *hose;
43 printk("Adding PCI host bridge %pOF\n", dev);
45 bus_range = of_get_property(dev, "bus-range", &len);
46 if (bus_range == NULL || len < 2 * sizeof(int))
47 printk(KERN_WARNING "Can't get bus-range for %pOF, assume"
50 hose = pcibios_alloc_controller(dev);
53 hose->first_busno = bus_range ? bus_range[0] : 0;
54 hose->last_busno = bus_range ? bus_range[1] : 0xff;
55 setup_indirect_pci(hose, 0xfec00000, 0xfee00000, 0);
57 /* Interpret the "ranges" property */
58 /* This also maps the I/O region and sets isa_io/mem_base */
59 pci_process_bridge_OF_ranges(hose, dev, 1);
64 static void __init linkstation_setup_arch(void)
66 printk(KERN_INFO "BUFFALO Network Attached Storage Series\n");
67 printk(KERN_INFO "(C) 2002-2005 BUFFALO INC.\n");
70 static void __init linkstation_setup_pci(void)
72 struct device_node *np;
74 /* Lookup PCI host bridges */
75 for_each_compatible_node(np, "pci", "mpc10x-pci")
76 linkstation_add_bridge(np);
80 * Interrupt setup and service. Interrupts on the linkstation come
81 * from the four PCI slots plus onboard 8241 devices: I2C, DUART.
83 static void __init linkstation_init_IRQ(void)
87 mpic = mpic_alloc(NULL, 0, 0, 4, 0, " EPIC ");
91 mpic_assign_isu(mpic, 0, mpic->paddr + 0x10200);
94 mpic_assign_isu(mpic, 1, mpic->paddr + 0x11000);
97 mpic_assign_isu(mpic, 2, mpic->paddr + 0x11100);
102 extern void avr_uart_configure(void);
103 extern void avr_uart_send(const char);
105 static void __noreturn linkstation_restart(char *cmd)
109 /* Reset system via AVR */
110 avr_uart_configure();
111 /* Send reboot command */
114 for(;;) /* Spin until reset happens */
115 avr_uart_send('G'); /* "kick" */
118 static void __noreturn linkstation_power_off(void)
122 /* Power down system via AVR */
123 avr_uart_configure();
124 /* send shutdown command */
127 for(;;) /* Spin until power-off happens */
128 avr_uart_send('G'); /* "kick" */
132 static void __noreturn linkstation_halt(void)
134 linkstation_power_off();
138 static void linkstation_show_cpuinfo(struct seq_file *m)
140 seq_printf(m, "vendor\t\t: Buffalo Technology\n");
141 seq_printf(m, "machine\t\t: Linkstation I/Kurobox(HG)\n");
144 static int __init linkstation_probe(void)
146 pm_power_off = linkstation_power_off;
151 define_machine(linkstation){
152 .name = "Buffalo Linkstation",
153 .compatible = "linkstation",
154 .probe = linkstation_probe,
155 .setup_arch = linkstation_setup_arch,
156 .discover_phbs = linkstation_setup_pci,
157 .init_IRQ = linkstation_init_IRQ,
158 .show_cpuinfo = linkstation_show_cpuinfo,
159 .get_irq = mpic_get_irq,
160 .restart = linkstation_restart,
161 .halt = linkstation_halt,