powerpc: fix i2c on PPC linkstation / kurobox machines
[deliverable/linux.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>
04d76b93 15#include <linux/mtd/physmap.h>
22e181ba 16#include <linux/of_platform.h>
04d76b93
GL
17
18#include <asm/time.h>
19#include <asm/prom.h>
20#include <asm/mpic.h>
04d76b93
GL
21#include <asm/pci-bridge.h>
22
33d71d26
KG
23#include "mpc10x.h"
24
04d76b93
GL
25static struct mtd_partition linkstation_physmap_partitions[] = {
26 {
27 .name = "mtd_firmimg",
28 .offset = 0x000000,
29 .size = 0x300000,
30 },
31 {
32 .name = "mtd_bootcode",
33 .offset = 0x300000,
34 .size = 0x070000,
35 },
36 {
37 .name = "mtd_status",
38 .offset = 0x370000,
39 .size = 0x010000,
40 },
41 {
42 .name = "mtd_conf",
43 .offset = 0x380000,
44 .size = 0x080000,
45 },
46 {
47 .name = "mtd_allflash",
48 .offset = 0x000000,
49 .size = 0x400000,
50 },
51 {
52 .name = "mtd_data",
53 .offset = 0x310000,
54 .size = 0x0f0000,
55 },
56};
57
22e181ba
GL
58static __initdata struct of_device_id of_bus_ids[] = {
59 { .type = "soc", },
60 { .compatible = "simple-bus", },
61 {},
62};
63
64static int __init declare_of_platform_devices(void)
65{
66 of_platform_bus_probe(NULL, of_bus_ids, NULL);
67 return 0;
68}
69machine_device_initcall(linkstation, declare_of_platform_devices);
70
09b55f76 71static int __init linkstation_add_bridge(struct device_node *dev)
04d76b93 72{
d6658408 73#ifdef CONFIG_PCI
04d76b93
GL
74 int len;
75 struct pci_controller *hose;
e2eb6392 76 const int *bus_range;
04d76b93
GL
77
78 printk("Adding PCI host bridge %s\n", dev->full_name);
79
e2eb6392 80 bus_range = of_get_property(dev, "bus-range", &len);
04d76b93
GL
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);
84
dbf8471f 85 hose = pcibios_alloc_controller(dev);
04d76b93
GL
86 if (hose == NULL)
87 return -ENOMEM;
88 hose->first_busno = bus_range ? bus_range[0] : 0;
89 hose->last_busno = bus_range ? bus_range[1] : 0xff;
2e56ff20 90 setup_indirect_pci(hose, 0xfec00000, 0xfee00000, 0);
04d76b93
GL
91
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);
d6658408 95#endif
04d76b93
GL
96 return 0;
97}
98
99static void __init linkstation_setup_arch(void)
100{
101 struct device_node *np;
102#ifdef CONFIG_MTD_PHYSMAP
103 physmap_set_partitions(linkstation_physmap_partitions,
104 ARRAY_SIZE(linkstation_physmap_partitions));
105#endif
106
04d76b93 107 /* Lookup PCI host bridges */
c9438aff 108 for_each_compatible_node(np, "pci", "mpc10x-pci")
09b55f76 109 linkstation_add_bridge(np);
04d76b93
GL
110
111 printk(KERN_INFO "BUFFALO Network Attached Storage Series\n");
112 printk(KERN_INFO "(C) 2002-2005 BUFFALO INC.\n");
113}
114
115/*
33567a02 116 * Interrupt setup and service. Interrupts on the linkstation come
04d76b93
GL
117 * from the four PCI slots plus onboard 8241 devices: I2C, DUART.
118 */
119static void __init linkstation_init_IRQ(void)
120{
121 struct mpic *mpic;
122 struct device_node *dnp;
e2eb6392 123 const u32 *prop;
04d76b93
GL
124 int size;
125 phys_addr_t paddr;
126
127 dnp = of_find_node_by_type(NULL, "open-pic");
128 if (dnp == NULL)
129 return;
130
e2eb6392 131 prop = of_get_property(dnp, "reg", &size);
04d76b93
GL
132 paddr = (phys_addr_t)of_translate_address(dnp, prop);
133
134 mpic = mpic_alloc(dnp, paddr, MPIC_PRIMARY | MPIC_WANTS_RESET, 4, 32, " EPIC ");
135 BUG_ON(mpic == NULL);
136
137 /* PCI IRQs */
138 mpic_assign_isu(mpic, 0, paddr + 0x10200);
139
140 /* I2C */
141 mpic_assign_isu(mpic, 1, paddr + 0x11000);
142
143 /* ttyS0, ttyS1 */
144 mpic_assign_isu(mpic, 2, paddr + 0x11100);
145
146 mpic_init(mpic);
147}
148
149extern void avr_uart_configure(void);
150extern void avr_uart_send(const char);
151
152static void linkstation_restart(char *cmd)
153{
154 local_irq_disable();
155
156 /* Reset system via AVR */
157 avr_uart_configure();
158 /* Send reboot command */
159 avr_uart_send('C');
160
161 for(;;) /* Spin until reset happens */
162 avr_uart_send('G'); /* "kick" */
163}
164
165static void linkstation_power_off(void)
166{
167 local_irq_disable();
168
169 /* Power down system via AVR */
170 avr_uart_configure();
171 /* send shutdown command */
172 avr_uart_send('E');
173
174 for(;;) /* Spin until power-off happens */
175 avr_uart_send('G'); /* "kick" */
176 /* NOTREACHED */
177}
178
179static void linkstation_halt(void)
180{
181 linkstation_power_off();
182 /* NOTREACHED */
183}
184
185static void linkstation_show_cpuinfo(struct seq_file *m)
186{
187 seq_printf(m, "vendor\t\t: Buffalo Technology\n");
188 seq_printf(m, "machine\t\t: Linkstation I/Kurobox(HG)\n");
189}
190
191static int __init linkstation_probe(void)
192{
193 unsigned long root;
194
195 root = of_get_flat_dt_root();
196
197 if (!of_flat_dt_is_compatible(root, "linkstation"))
198 return 0;
199 return 1;
200}
201
202define_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,
213};
This page took 0.289715 seconds and 5 git commands to generate.