OMAPDSS: VENC: fix NULL pointer dereference in DSS2 VENC sysfs debug attr on OMAP4
[zen-stable.git] / arch / powerpc / platforms / embedded6xx / linkstation.c
blobbcfad92c9cecbd43f0385303a593ff89fa563df4
1 /*
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>
17 #include <asm/time.h>
18 #include <asm/prom.h>
19 #include <asm/mpic.h>
20 #include <asm/pci-bridge.h>
22 #include "mpc10x.h"
24 static __initdata struct of_device_id of_bus_ids[] = {
25 { .type = "soc", },
26 { .compatible = "simple-bus", },
27 {},
30 static int __init declare_of_platform_devices(void)
32 of_platform_bus_probe(NULL, of_bus_ids, NULL);
33 return 0;
35 machine_device_initcall(linkstation, declare_of_platform_devices);
37 static int __init linkstation_add_bridge(struct device_node *dev)
39 #ifdef CONFIG_PCI
40 int len;
41 struct pci_controller *hose;
42 const int *bus_range;
44 printk("Adding PCI host bridge %s\n", dev->full_name);
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 %s, assume"
49 " bus 0\n", dev->full_name);
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);
58 /* Interpret the "ranges" property */
59 /* This also maps the I/O region and sets isa_io/mem_base */
60 pci_process_bridge_OF_ranges(hose, dev, 1);
61 #endif
62 return 0;
65 static void __init linkstation_setup_arch(void)
67 struct device_node *np;
69 /* Lookup PCI host bridges */
70 for_each_compatible_node(np, "pci", "mpc10x-pci")
71 linkstation_add_bridge(np);
73 printk(KERN_INFO "BUFFALO Network Attached Storage Series\n");
74 printk(KERN_INFO "(C) 2002-2005 BUFFALO INC.\n");
78 * Interrupt setup and service. Interrupts on the linkstation come
79 * from the four PCI slots plus onboard 8241 devices: I2C, DUART.
81 static void __init linkstation_init_IRQ(void)
83 struct mpic *mpic;
85 mpic = mpic_alloc(NULL, 0, MPIC_WANTS_RESET,
86 4, 32, " EPIC ");
87 BUG_ON(mpic == NULL);
89 /* PCI IRQs */
90 mpic_assign_isu(mpic, 0, mpic->paddr + 0x10200);
92 /* I2C */
93 mpic_assign_isu(mpic, 1, mpic->paddr + 0x11000);
95 /* ttyS0, ttyS1 */
96 mpic_assign_isu(mpic, 2, mpic->paddr + 0x11100);
98 mpic_init(mpic);
101 extern void avr_uart_configure(void);
102 extern void avr_uart_send(const char);
104 static void linkstation_restart(char *cmd)
106 local_irq_disable();
108 /* Reset system via AVR */
109 avr_uart_configure();
110 /* Send reboot command */
111 avr_uart_send('C');
113 for(;;) /* Spin until reset happens */
114 avr_uart_send('G'); /* "kick" */
117 static void linkstation_power_off(void)
119 local_irq_disable();
121 /* Power down system via AVR */
122 avr_uart_configure();
123 /* send shutdown command */
124 avr_uart_send('E');
126 for(;;) /* Spin until power-off happens */
127 avr_uart_send('G'); /* "kick" */
128 /* NOTREACHED */
131 static void linkstation_halt(void)
133 linkstation_power_off();
134 /* NOTREACHED */
137 static void linkstation_show_cpuinfo(struct seq_file *m)
139 seq_printf(m, "vendor\t\t: Buffalo Technology\n");
140 seq_printf(m, "machine\t\t: Linkstation I/Kurobox(HG)\n");
143 static int __init linkstation_probe(void)
145 unsigned long root;
147 root = of_get_flat_dt_root();
149 if (!of_flat_dt_is_compatible(root, "linkstation"))
150 return 0;
151 return 1;
154 define_machine(linkstation){
155 .name = "Buffalo Linkstation",
156 .probe = linkstation_probe,
157 .setup_arch = linkstation_setup_arch,
158 .init_IRQ = linkstation_init_IRQ,
159 .show_cpuinfo = linkstation_show_cpuinfo,
160 .get_irq = mpic_get_irq,
161 .restart = linkstation_restart,
162 .power_off = linkstation_power_off,
163 .halt = linkstation_halt,
164 .calibrate_decr = generic_calibrate_decr,