]> git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/blame - arch/powerpc/platforms/embedded6xx/linkstation.c
Merge commit 'v2.6.29' into timers/core
[mirror_ubuntu-jammy-kernel.git] / arch / powerpc / platforms / embedded6xx / linkstation.c
CommitLineData
04d76b93
GL
1/*
2 * Board setup routines for the Buffalo Linkstation / Kurobox Platform.
3 *
4 * Copyright (C) 2006 G. Liakhovetski (g.liakhovetski@gmx.de)
5 *
6 * Based on sandpoint.c by Mark A. Greer
7 *
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.
11 */
12
13#include <linux/kernel.h>
04d76b93 14#include <linux/initrd.h>
22e181ba 15#include <linux/of_platform.h>
04d76b93
GL
16
17#include <asm/time.h>
18#include <asm/prom.h>
19#include <asm/mpic.h>
04d76b93
GL
20#include <asm/pci-bridge.h>
21
33d71d26
KG
22#include "mpc10x.h"
23
22e181ba
GL
24static __initdata struct of_device_id of_bus_ids[] = {
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
09b55f76 37static int __init linkstation_add_bridge(struct device_node *dev)
04d76b93 38{
d6658408 39#ifdef CONFIG_PCI
04d76b93
GL
40 int len;
41 struct pci_controller *hose;
e2eb6392 42 const int *bus_range;
04d76b93
GL
43
44 printk("Adding PCI host bridge %s\n", dev->full_name);
45
e2eb6392 46 bus_range = of_get_property(dev, "bus-range", &len);
04d76b93
GL
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);
50
dbf8471f 51 hose = pcibios_alloc_controller(dev);
04d76b93
GL
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;
2e56ff20 56 setup_indirect_pci(hose, 0xfec00000, 0xfee00000, 0);
04d76b93
GL
57
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);
d6658408 61#endif
04d76b93
GL
62 return 0;
63}
64
65static void __init linkstation_setup_arch(void)
66{
67 struct device_node *np;
04d76b93 68
04d76b93 69 /* Lookup PCI host bridges */
c9438aff 70 for_each_compatible_node(np, "pci", "mpc10x-pci")
09b55f76 71 linkstation_add_bridge(np);
04d76b93
GL
72
73 printk(KERN_INFO "BUFFALO Network Attached Storage Series\n");
74 printk(KERN_INFO "(C) 2002-2005 BUFFALO INC.\n");
75}
76
77/*
33567a02 78 * Interrupt setup and service. Interrupts on the linkstation come
04d76b93
GL
79 * from the four PCI slots plus onboard 8241 devices: I2C, DUART.
80 */
81static void __init linkstation_init_IRQ(void)
82{
83 struct mpic *mpic;
84 struct device_node *dnp;
e2eb6392 85 const u32 *prop;
04d76b93
GL
86 int size;
87 phys_addr_t paddr;
88
89 dnp = of_find_node_by_type(NULL, "open-pic");
90 if (dnp == NULL)
91 return;
92
e2eb6392 93 prop = of_get_property(dnp, "reg", &size);
04d76b93
GL
94 paddr = (phys_addr_t)of_translate_address(dnp, prop);
95
96 mpic = mpic_alloc(dnp, paddr, MPIC_PRIMARY | MPIC_WANTS_RESET, 4, 32, " EPIC ");
97 BUG_ON(mpic == NULL);
98
99 /* PCI IRQs */
100 mpic_assign_isu(mpic, 0, paddr + 0x10200);
101
102 /* I2C */
103 mpic_assign_isu(mpic, 1, paddr + 0x11000);
104
105 /* ttyS0, ttyS1 */
106 mpic_assign_isu(mpic, 2, paddr + 0x11100);
107
108 mpic_init(mpic);
109}
110
111extern void avr_uart_configure(void);
112extern void avr_uart_send(const char);
113
114static void linkstation_restart(char *cmd)
115{
116 local_irq_disable();
117
118 /* Reset system via AVR */
119 avr_uart_configure();
120 /* Send reboot command */
121 avr_uart_send('C');
122
123 for(;;) /* Spin until reset happens */
124 avr_uart_send('G'); /* "kick" */
125}
126
127static void linkstation_power_off(void)
128{
129 local_irq_disable();
130
131 /* Power down system via AVR */
132 avr_uart_configure();
133 /* send shutdown command */
134 avr_uart_send('E');
135
136 for(;;) /* Spin until power-off happens */
137 avr_uart_send('G'); /* "kick" */
138 /* NOTREACHED */
139}
140
141static void linkstation_halt(void)
142{
143 linkstation_power_off();
144 /* NOTREACHED */
145}
146
147static void linkstation_show_cpuinfo(struct seq_file *m)
148{
149 seq_printf(m, "vendor\t\t: Buffalo Technology\n");
150 seq_printf(m, "machine\t\t: Linkstation I/Kurobox(HG)\n");
151}
152
153static int __init linkstation_probe(void)
154{
155 unsigned long root;
156
157 root = of_get_flat_dt_root();
158
159 if (!of_flat_dt_is_compatible(root, "linkstation"))
160 return 0;
161 return 1;
162}
163
164define_machine(linkstation){
165 .name = "Buffalo Linkstation",
166 .probe = linkstation_probe,
167 .setup_arch = linkstation_setup_arch,
168 .init_IRQ = linkstation_init_IRQ,
169 .show_cpuinfo = linkstation_show_cpuinfo,
170 .get_irq = mpic_get_irq,
171 .restart = linkstation_restart,
172 .power_off = linkstation_power_off,
173 .halt = linkstation_halt,
174 .calibrate_decr = generic_calibrate_decr,
175};