1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45#include <linux/init.h>
46#include <linux/kernel.h>
47#include <linux/types.h>
48#include <linux/ioport.h>
49#include <linux/platform_device.h>
50#include <linux/delay.h>
51#include <linux/gpio.h>
52#include <linux/leds.h>
53#include <asm/io.h>
54#include <asm/reboot.h>
55#include <asm/txx9/generic.h>
56#include <asm/txx9/pci.h>
57#include <asm/txx9/rbtx4927.h>
58#include <asm/txx9/tx4938.h>
59
60#ifdef CONFIG_PCI
61static void __init tx4927_pci_setup(void)
62{
63 int extarb = !(__raw_readq(&tx4927_ccfgptr->ccfg) & TX4927_CCFG_PCIARB);
64 struct pci_controller *c = &txx9_primary_pcic;
65
66 register_pci_controller(c);
67
68 if (__raw_readq(&tx4927_ccfgptr->ccfg) & TX4927_CCFG_PCI66)
69 txx9_pci_option =
70 (txx9_pci_option & ~TXX9_PCI_OPT_CLK_MASK) |
71 TXX9_PCI_OPT_CLK_66;
72
73
74 writeb(1, rbtx4927_pcireset_addr);
75
76 txx9_set64(&tx4927_ccfgptr->clkctr, TX4927_CLKCTR_PCIRST);
77 if ((txx9_pci_option & TXX9_PCI_OPT_CLK_MASK) ==
78 TXX9_PCI_OPT_CLK_66)
79 tx4927_pciclk66_setup();
80 mdelay(10);
81
82 txx9_clear64(&tx4927_ccfgptr->clkctr, TX4927_CLKCTR_PCIRST);
83 writeb(0, rbtx4927_pcireset_addr);
84 iob();
85
86 tx4927_report_pciclk();
87 tx4927_pcic_setup(tx4927_pcicptr, c, extarb);
88 if ((txx9_pci_option & TXX9_PCI_OPT_CLK_MASK) ==
89 TXX9_PCI_OPT_CLK_AUTO &&
90 txx9_pci66_check(c, 0, 0)) {
91
92 writeb(1, rbtx4927_pcireset_addr);
93
94 txx9_set64(&tx4927_ccfgptr->clkctr, TX4927_CLKCTR_PCIRST);
95 tx4927_pciclk66_setup();
96 mdelay(10);
97
98 txx9_clear64(&tx4927_ccfgptr->clkctr, TX4927_CLKCTR_PCIRST);
99 writeb(0, rbtx4927_pcireset_addr);
100 iob();
101
102 tx4927_report_pciclk();
103 tx4927_pcic_setup(tx4927_pcicptr, c, extarb);
104 }
105 tx4927_setup_pcierr_irq();
106}
107
108static void __init tx4937_pci_setup(void)
109{
110 int extarb = !(__raw_readq(&tx4938_ccfgptr->ccfg) & TX4938_CCFG_PCIARB);
111 struct pci_controller *c = &txx9_primary_pcic;
112
113 register_pci_controller(c);
114
115 if (__raw_readq(&tx4938_ccfgptr->ccfg) & TX4938_CCFG_PCI66)
116 txx9_pci_option =
117 (txx9_pci_option & ~TXX9_PCI_OPT_CLK_MASK) |
118 TXX9_PCI_OPT_CLK_66;
119
120
121 writeb(1, rbtx4927_pcireset_addr);
122
123 txx9_set64(&tx4938_ccfgptr->clkctr, TX4938_CLKCTR_PCIRST);
124 if ((txx9_pci_option & TXX9_PCI_OPT_CLK_MASK) ==
125 TXX9_PCI_OPT_CLK_66)
126 tx4938_pciclk66_setup();
127 mdelay(10);
128
129 txx9_clear64(&tx4938_ccfgptr->clkctr, TX4938_CLKCTR_PCIRST);
130 writeb(0, rbtx4927_pcireset_addr);
131 iob();
132
133 tx4938_report_pciclk();
134 tx4927_pcic_setup(tx4938_pcicptr, c, extarb);
135 if ((txx9_pci_option & TXX9_PCI_OPT_CLK_MASK) ==
136 TXX9_PCI_OPT_CLK_AUTO &&
137 txx9_pci66_check(c, 0, 0)) {
138
139 writeb(1, rbtx4927_pcireset_addr);
140
141 txx9_set64(&tx4938_ccfgptr->clkctr, TX4938_CLKCTR_PCIRST);
142 tx4938_pciclk66_setup();
143 mdelay(10);
144
145 txx9_clear64(&tx4938_ccfgptr->clkctr, TX4938_CLKCTR_PCIRST);
146 writeb(0, rbtx4927_pcireset_addr);
147 iob();
148
149 tx4938_report_pciclk();
150 tx4927_pcic_setup(tx4938_pcicptr, c, extarb);
151 }
152 tx4938_setup_pcierr_irq();
153}
154
155static void __init rbtx4927_arch_init(void)
156{
157 tx4927_pci_setup();
158}
159
160static void __init rbtx4937_arch_init(void)
161{
162 tx4937_pci_setup();
163}
164#else
165#define rbtx4927_arch_init NULL
166#define rbtx4937_arch_init NULL
167#endif
168
169static void toshiba_rbtx4927_restart(char *command)
170{
171
172 writeb(1, rbtx4927_softresetlock_addr);
173
174
175 while (!(readb(rbtx4927_softresetlock_addr) & 1))
176 ;
177
178
179 writeb(1, rbtx4927_softreset_addr);
180
181
182 (*_machine_halt)();
183}
184
185static void __init rbtx4927_clock_init(void);
186static void __init rbtx4937_clock_init(void);
187
188static void __init rbtx4927_mem_setup(void)
189{
190 if (TX4927_REV_PCODE() == 0x4927) {
191 rbtx4927_clock_init();
192 tx4927_setup();
193 } else {
194 rbtx4937_clock_init();
195 tx4938_setup();
196 }
197
198 _machine_restart = toshiba_rbtx4927_restart;
199
200#ifdef CONFIG_PCI
201 txx9_alloc_pci_controller(&txx9_primary_pcic,
202 RBTX4927_PCIMEM, RBTX4927_PCIMEM_SIZE,
203 RBTX4927_PCIIO, RBTX4927_PCIIO_SIZE);
204 txx9_board_pcibios_setup = tx4927_pcibios_setup;
205#else
206 set_io_port_base(KSEG1 + RBTX4927_ISA_IO_OFFSET);
207#endif
208
209
210 gpio_request(15, "sio-dtr");
211 gpio_direction_output(15, 1);
212
213 tx4927_sio_init(0, 0);
214}
215
216static void __init rbtx4927_clock_init(void)
217{
218
219
220
221
222
223
224
225
226
227
228
229 switch ((unsigned long)__raw_readq(&tx4927_ccfgptr->ccfg) &
230 TX4927_CCFG_PCIDIVMODE_MASK) {
231 case TX4927_CCFG_PCIDIVMODE_2_5:
232 case TX4927_CCFG_PCIDIVMODE_5:
233 txx9_cpu_clock = 166666666;
234 break;
235 default:
236 txx9_cpu_clock = 200000000;
237 }
238}
239
240static void __init rbtx4937_clock_init(void)
241{
242
243
244
245
246
247
248
249
250
251
252
253
254
255 switch ((unsigned long)__raw_readq(&tx4938_ccfgptr->ccfg) &
256 TX4938_CCFG_PCIDIVMODE_MASK) {
257 case TX4938_CCFG_PCIDIVMODE_8:
258 case TX4938_CCFG_PCIDIVMODE_4:
259 txx9_cpu_clock = 266666666;
260 break;
261 case TX4938_CCFG_PCIDIVMODE_9:
262 case TX4938_CCFG_PCIDIVMODE_4_5:
263 txx9_cpu_clock = 300000000;
264 break;
265 default:
266 txx9_cpu_clock = 333333333;
267 }
268}
269
270static void __init rbtx4927_time_init(void)
271{
272 tx4927_time_init(0);
273}
274
275static void __init toshiba_rbtx4927_rtc_init(void)
276{
277 struct resource res = {
278 .start = RBTX4927_BRAMRTC_BASE - IO_BASE,
279 .end = RBTX4927_BRAMRTC_BASE - IO_BASE + 0x800 - 1,
280 .flags = IORESOURCE_MEM,
281 };
282 platform_device_register_simple("rtc-ds1742", -1, &res, 1);
283}
284
285static void __init rbtx4927_ne_init(void)
286{
287 struct resource res[] = {
288 {
289 .start = RBTX4927_RTL_8019_BASE,
290 .end = RBTX4927_RTL_8019_BASE + 0x20 - 1,
291 .flags = IORESOURCE_IO,
292 }, {
293 .start = RBTX4927_RTL_8019_IRQ,
294 .flags = IORESOURCE_IRQ,
295 }
296 };
297 platform_device_register_simple("ne", -1, res, ARRAY_SIZE(res));
298}
299
300static void __init rbtx4927_mtd_init(void)
301{
302 int i;
303
304 for (i = 0; i < 2; i++)
305 tx4927_mtd_init(i);
306}
307
308static void __init rbtx4927_gpioled_init(void)
309{
310 static struct gpio_led leds[] = {
311 { .name = "gpioled:green:0", .gpio = 0, .active_low = 1, },
312 { .name = "gpioled:green:1", .gpio = 1, .active_low = 1, },
313 };
314 static struct gpio_led_platform_data pdata = {
315 .num_leds = ARRAY_SIZE(leds),
316 .leds = leds,
317 };
318 struct platform_device *pdev = platform_device_alloc("leds-gpio", 0);
319
320 if (!pdev)
321 return;
322 pdev->dev.platform_data = &pdata;
323 if (platform_device_add(pdev))
324 platform_device_put(pdev);
325}
326
327static void __init rbtx4927_device_init(void)
328{
329 toshiba_rbtx4927_rtc_init();
330 rbtx4927_ne_init();
331 tx4927_wdt_init();
332 rbtx4927_mtd_init();
333 if (TX4927_REV_PCODE() == 0x4927) {
334 tx4927_dmac_init(2);
335 tx4927_aclc_init(0, 1);
336 } else {
337 tx4938_dmac_init(0, 2);
338 tx4938_aclc_init();
339 }
340 platform_device_register_simple("txx9aclc-generic", -1, NULL, 0);
341 txx9_iocled_init(RBTX4927_LED_ADDR - IO_BASE, -1, 3, 1, "green", NULL);
342 rbtx4927_gpioled_init();
343}
344
345struct txx9_board_vec rbtx4927_vec __initdata = {
346 .system = "Toshiba RBTX4927",
347 .prom_init = rbtx4927_prom_init,
348 .mem_setup = rbtx4927_mem_setup,
349 .irq_setup = rbtx4927_irq_setup,
350 .time_init = rbtx4927_time_init,
351 .device_init = rbtx4927_device_init,
352 .arch_init = rbtx4927_arch_init,
353#ifdef CONFIG_PCI
354 .pci_map_irq = rbtx4927_pci_map_irq,
355#endif
356};
357struct txx9_board_vec rbtx4937_vec __initdata = {
358 .system = "Toshiba RBTX4937",
359 .prom_init = rbtx4927_prom_init,
360 .mem_setup = rbtx4927_mem_setup,
361 .irq_setup = rbtx4927_irq_setup,
362 .time_init = rbtx4927_time_init,
363 .device_init = rbtx4927_device_init,
364 .arch_init = rbtx4937_arch_init,
365#ifdef CONFIG_PCI
366 .pci_map_irq = rbtx4927_pci_map_irq,
367#endif
368};
369