0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013 #include <linux/kernel.h>
0014 #include <linux/initrd.h>
0015 #include <linux/of_platform.h>
0016
0017 #include <asm/time.h>
0018 #include <asm/mpic.h>
0019 #include <asm/pci-bridge.h>
0020
0021 #include "mpc10x.h"
0022
0023 static const struct of_device_id of_bus_ids[] __initconst = {
0024 { .type = "soc", },
0025 { .compatible = "simple-bus", },
0026 {},
0027 };
0028
0029 static int __init declare_of_platform_devices(void)
0030 {
0031 of_platform_bus_probe(NULL, of_bus_ids, NULL);
0032 return 0;
0033 }
0034 machine_device_initcall(linkstation, declare_of_platform_devices);
0035
0036 static int __init linkstation_add_bridge(struct device_node *dev)
0037 {
0038 #ifdef CONFIG_PCI
0039 int len;
0040 struct pci_controller *hose;
0041 const int *bus_range;
0042
0043 printk("Adding PCI host bridge %pOF\n", dev);
0044
0045 bus_range = of_get_property(dev, "bus-range", &len);
0046 if (bus_range == NULL || len < 2 * sizeof(int))
0047 printk(KERN_WARNING "Can't get bus-range for %pOF, assume"
0048 " bus 0\n", dev);
0049
0050 hose = pcibios_alloc_controller(dev);
0051 if (hose == NULL)
0052 return -ENOMEM;
0053 hose->first_busno = bus_range ? bus_range[0] : 0;
0054 hose->last_busno = bus_range ? bus_range[1] : 0xff;
0055 setup_indirect_pci(hose, 0xfec00000, 0xfee00000, 0);
0056
0057
0058
0059 pci_process_bridge_OF_ranges(hose, dev, 1);
0060 #endif
0061 return 0;
0062 }
0063
0064 static void __init linkstation_setup_arch(void)
0065 {
0066 printk(KERN_INFO "BUFFALO Network Attached Storage Series\n");
0067 printk(KERN_INFO "(C) 2002-2005 BUFFALO INC.\n");
0068 }
0069
0070 static void __init linkstation_setup_pci(void)
0071 {
0072 struct device_node *np;
0073
0074
0075 for_each_compatible_node(np, "pci", "mpc10x-pci")
0076 linkstation_add_bridge(np);
0077 }
0078
0079
0080
0081
0082
0083 static void __init linkstation_init_IRQ(void)
0084 {
0085 struct mpic *mpic;
0086
0087 mpic = mpic_alloc(NULL, 0, 0, 4, 0, " EPIC ");
0088 BUG_ON(mpic == NULL);
0089
0090
0091 mpic_assign_isu(mpic, 0, mpic->paddr + 0x10200);
0092
0093
0094 mpic_assign_isu(mpic, 1, mpic->paddr + 0x11000);
0095
0096
0097 mpic_assign_isu(mpic, 2, mpic->paddr + 0x11100);
0098
0099 mpic_init(mpic);
0100 }
0101
0102 extern void avr_uart_configure(void);
0103 extern void avr_uart_send(const char);
0104
0105 static void __noreturn linkstation_restart(char *cmd)
0106 {
0107 local_irq_disable();
0108
0109
0110 avr_uart_configure();
0111
0112 avr_uart_send('C');
0113
0114 for(;;)
0115 avr_uart_send('G');
0116 }
0117
0118 static void __noreturn linkstation_power_off(void)
0119 {
0120 local_irq_disable();
0121
0122
0123 avr_uart_configure();
0124
0125 avr_uart_send('E');
0126
0127 for(;;)
0128 avr_uart_send('G');
0129
0130 }
0131
0132 static void __noreturn linkstation_halt(void)
0133 {
0134 linkstation_power_off();
0135
0136 }
0137
0138 static void linkstation_show_cpuinfo(struct seq_file *m)
0139 {
0140 seq_printf(m, "vendor\t\t: Buffalo Technology\n");
0141 seq_printf(m, "machine\t\t: Linkstation I/Kurobox(HG)\n");
0142 }
0143
0144 static int __init linkstation_probe(void)
0145 {
0146 if (!of_machine_is_compatible("linkstation"))
0147 return 0;
0148
0149 pm_power_off = linkstation_power_off;
0150
0151 return 1;
0152 }
0153
0154 define_machine(linkstation){
0155 .name = "Buffalo Linkstation",
0156 .probe = linkstation_probe,
0157 .setup_arch = linkstation_setup_arch,
0158 .discover_phbs = linkstation_setup_pci,
0159 .init_IRQ = linkstation_init_IRQ,
0160 .show_cpuinfo = linkstation_show_cpuinfo,
0161 .get_irq = mpic_get_irq,
0162 .restart = linkstation_restart,
0163 .halt = linkstation_halt,
0164 .calibrate_decr = generic_calibrate_decr,
0165 };