aboutsummaryrefslogtreecommitdiffstats
path: root/arch/mips/txx9/rbtx4938/setup.c
diff options
context:
space:
mode:
authorAtsushi Nemoto <anemo@mba.ocn.ne.jp>2008-07-18 12:51:47 -0400
committerRalf Baechle <ralf@linux-mips.org>2008-07-20 09:38:21 -0400
commit94a4c32939dede9328c6e4face335eb8441fc18d (patch)
tree0ac510bf3b90cb79fe94112b95dd77d96c190bf9 /arch/mips/txx9/rbtx4938/setup.c
parent255033a9bb900a06c9a7798908ce12557d24fb66 (diff)
[MIPS] TXx9: Add 64-bit support
SYS_SUPPORTS_64BIT_KERNEL is enabled for RBTX4927/RBTX4938, but actually it was broken for long time (or from the beginning). Now it should work. Signed-off-by: Atsushi Nemoto <anemo@mba.ocn.ne.jp> Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
Diffstat (limited to 'arch/mips/txx9/rbtx4938/setup.c')
-rw-r--r--arch/mips/txx9/rbtx4938/setup.c218
1 files changed, 8 insertions, 210 deletions
diff --git a/arch/mips/txx9/rbtx4938/setup.c b/arch/mips/txx9/rbtx4938/setup.c
index c1e076c7b2d2..6c2b99bb8af6 100644
--- a/arch/mips/txx9/rbtx4938/setup.c
+++ b/arch/mips/txx9/rbtx4938/setup.c
@@ -20,21 +20,14 @@
20#include <linux/gpio.h> 20#include <linux/gpio.h>
21 21
22#include <asm/reboot.h> 22#include <asm/reboot.h>
23#include <asm/time.h>
24#include <asm/txx9tmr.h>
25#include <asm/io.h> 23#include <asm/io.h>
26#include <asm/txx9/generic.h> 24#include <asm/txx9/generic.h>
27#include <asm/txx9/pci.h> 25#include <asm/txx9/pci.h>
28#include <asm/txx9/rbtx4938.h> 26#include <asm/txx9/rbtx4938.h>
29#ifdef CONFIG_SERIAL_TXX9
30#include <linux/serial_core.h>
31#endif
32#include <linux/spi/spi.h> 27#include <linux/spi/spi.h>
33#include <asm/txx9/spi.h> 28#include <asm/txx9/spi.h>
34#include <asm/txx9pio.h> 29#include <asm/txx9pio.h>
35 30
36static int tx4938_ccfg_toeon = 1;
37
38static void rbtx4938_machine_halt(void) 31static void rbtx4938_machine_halt(void)
39{ 32{
40 printk(KERN_NOTICE "System Halted\n"); 33 printk(KERN_NOTICE "System Halted\n");
@@ -182,189 +175,10 @@ static void __init rbtx4938_spi_setup(void)
182} 175}
183 176
184static struct resource rbtx4938_fpga_resource; 177static struct resource rbtx4938_fpga_resource;
185static struct resource tx4938_sdram_resource[4];
186static struct resource tx4938_sram_resource;
187
188void __init tx4938_board_setup(void)
189{
190 int i;
191 unsigned long divmode;
192 int cpuclk = 0;
193 unsigned long pcode = TX4938_REV_PCODE();
194
195 ioport_resource.start = 0;
196 ioport_resource.end = 0xffffffff;
197 iomem_resource.start = 0;
198 iomem_resource.end = 0xffffffff; /* expand to 4GB */
199
200 txx9_reg_res_init(pcode, TX4938_REG_BASE,
201 TX4938_REG_SIZE);
202 /* SDRAMC,EBUSC are configured by PROM */
203 for (i = 0; i < 8; i++) {
204 if (!(TX4938_EBUSC_CR(i) & 0x8))
205 continue; /* disabled */
206 txx9_ce_res[i].start = (unsigned long)TX4938_EBUSC_BA(i);
207 txx9_ce_res[i].end =
208 txx9_ce_res[i].start + TX4938_EBUSC_SIZE(i) - 1;
209 request_resource(&iomem_resource, &txx9_ce_res[i]);
210 }
211
212 /* clocks */
213 if (txx9_master_clock) {
214 u64 ccfg = ____raw_readq(&tx4938_ccfgptr->ccfg);
215 /* calculate gbus_clock and cpu_clock_freq from master_clock */
216 divmode = (__u32)ccfg & TX4938_CCFG_DIVMODE_MASK;
217 switch (divmode) {
218 case TX4938_CCFG_DIVMODE_8:
219 case TX4938_CCFG_DIVMODE_10:
220 case TX4938_CCFG_DIVMODE_12:
221 case TX4938_CCFG_DIVMODE_16:
222 case TX4938_CCFG_DIVMODE_18:
223 txx9_gbus_clock = txx9_master_clock * 4; break;
224 default:
225 txx9_gbus_clock = txx9_master_clock;
226 }
227 switch (divmode) {
228 case TX4938_CCFG_DIVMODE_2:
229 case TX4938_CCFG_DIVMODE_8:
230 cpuclk = txx9_gbus_clock * 2; break;
231 case TX4938_CCFG_DIVMODE_2_5:
232 case TX4938_CCFG_DIVMODE_10:
233 cpuclk = txx9_gbus_clock * 5 / 2; break;
234 case TX4938_CCFG_DIVMODE_3:
235 case TX4938_CCFG_DIVMODE_12:
236 cpuclk = txx9_gbus_clock * 3; break;
237 case TX4938_CCFG_DIVMODE_4:
238 case TX4938_CCFG_DIVMODE_16:
239 cpuclk = txx9_gbus_clock * 4; break;
240 case TX4938_CCFG_DIVMODE_4_5:
241 case TX4938_CCFG_DIVMODE_18:
242 cpuclk = txx9_gbus_clock * 9 / 2; break;
243 }
244 txx9_cpu_clock = cpuclk;
245 } else {
246 u64 ccfg = ____raw_readq(&tx4938_ccfgptr->ccfg);
247 if (txx9_cpu_clock == 0) {
248 txx9_cpu_clock = 300000000; /* 300MHz */
249 }
250 /* calculate gbus_clock and master_clock from cpu_clock_freq */
251 cpuclk = txx9_cpu_clock;
252 divmode = (__u32)ccfg & TX4938_CCFG_DIVMODE_MASK;
253 switch (divmode) {
254 case TX4938_CCFG_DIVMODE_2:
255 case TX4938_CCFG_DIVMODE_8:
256 txx9_gbus_clock = cpuclk / 2; break;
257 case TX4938_CCFG_DIVMODE_2_5:
258 case TX4938_CCFG_DIVMODE_10:
259 txx9_gbus_clock = cpuclk * 2 / 5; break;
260 case TX4938_CCFG_DIVMODE_3:
261 case TX4938_CCFG_DIVMODE_12:
262 txx9_gbus_clock = cpuclk / 3; break;
263 case TX4938_CCFG_DIVMODE_4:
264 case TX4938_CCFG_DIVMODE_16:
265 txx9_gbus_clock = cpuclk / 4; break;
266 case TX4938_CCFG_DIVMODE_4_5:
267 case TX4938_CCFG_DIVMODE_18:
268 txx9_gbus_clock = cpuclk * 2 / 9; break;
269 }
270 switch (divmode) {
271 case TX4938_CCFG_DIVMODE_8:
272 case TX4938_CCFG_DIVMODE_10:
273 case TX4938_CCFG_DIVMODE_12:
274 case TX4938_CCFG_DIVMODE_16:
275 case TX4938_CCFG_DIVMODE_18:
276 txx9_master_clock = txx9_gbus_clock / 4; break;
277 default:
278 txx9_master_clock = txx9_gbus_clock;
279 }
280 }
281 /* change default value to udelay/mdelay take reasonable time */
282 loops_per_jiffy = txx9_cpu_clock / HZ / 2;
283
284 /* CCFG */
285 /* clear WatchDogReset,BusErrorOnWrite flag (W1C) */
286 tx4938_ccfg_set(TX4938_CCFG_WDRST | TX4938_CCFG_BEOW);
287 /* do reset on watchdog */
288 tx4938_ccfg_set(TX4938_CCFG_WR);
289 /* clear PCIC1 reset */
290 txx9_clear64(&tx4938_ccfgptr->clkctr, TX4938_CLKCTR_PCIC1RST);
291
292 /* enable Timeout BusError */
293 if (tx4938_ccfg_toeon)
294 tx4938_ccfg_set(TX4938_CCFG_TOE);
295
296 /* DMA selection */
297 txx9_clear64(&tx4938_ccfgptr->pcfg, TX4938_PCFG_DMASEL_ALL);
298
299 /* Use external clock for external arbiter */
300 if (!(____raw_readq(&tx4938_ccfgptr->ccfg) & TX4938_CCFG_PCIARB))
301 txx9_clear64(&tx4938_ccfgptr->pcfg, TX4938_PCFG_PCICLKEN_ALL);
302
303 printk(KERN_INFO "%s -- %dMHz(M%dMHz) CRIR:%08x CCFG:%llx PCFG:%llx\n",
304 txx9_pcode_str,
305 (cpuclk + 500000) / 1000000,
306 (txx9_master_clock + 500000) / 1000000,
307 (__u32)____raw_readq(&tx4938_ccfgptr->crir),
308 (unsigned long long)____raw_readq(&tx4938_ccfgptr->ccfg),
309 (unsigned long long)____raw_readq(&tx4938_ccfgptr->pcfg));
310
311 printk(KERN_INFO "%s SDRAMC --", txx9_pcode_str);
312 for (i = 0; i < 4; i++) {
313 u64 cr = TX4938_SDRAMC_CR(i);
314 unsigned long ram_base, ram_size;
315 if (!((unsigned long)cr & 0x00000400))
316 continue; /* disabled */
317 ram_base = (unsigned long)(cr >> 49) << 21;
318 ram_size = ((unsigned long)(cr >> 33) + 1) << 21;
319 if (ram_base >= 0x20000000)
320 continue; /* high memory (ignore) */
321 printk(KERN_CONT " CR%d:%016llx", i, cr);
322 tx4938_sdram_resource[i].name = "SDRAM";
323 tx4938_sdram_resource[i].start = ram_base;
324 tx4938_sdram_resource[i].end = ram_base + ram_size - 1;
325 tx4938_sdram_resource[i].flags = IORESOURCE_MEM;
326 request_resource(&iomem_resource, &tx4938_sdram_resource[i]);
327 }
328 printk(KERN_CONT " TR:%09llx\n", ____raw_readq(&tx4938_sdramcptr->tr));
329
330 /* SRAM */
331 if (____raw_readq(&tx4938_sramcptr->cr) & 1) {
332 unsigned int size = 0x800;
333 unsigned long base =
334 (____raw_readq(&tx4938_sramcptr->cr) >> (39-11))
335 & ~(size - 1);
336 tx4938_sram_resource.name = "SRAM";
337 tx4938_sram_resource.start = base;
338 tx4938_sram_resource.end = base + size - 1;
339 tx4938_sram_resource.flags = IORESOURCE_MEM;
340 request_resource(&iomem_resource, &tx4938_sram_resource);
341 }
342
343 /* TMR */
344 for (i = 0; i < TX4938_NR_TMR; i++)
345 txx9_tmr_init(TX4938_TMR_REG(i) & 0xfffffffffULL);
346
347 /* enable DMA */
348 for (i = 0; i < 2; i++)
349 ____raw_writeq(TX4938_DMA_MCR_MSTEN,
350 (void __iomem *)(TX4938_DMA_REG(i) + 0x50));
351
352 /* PIO */
353 __raw_writel(0, &tx4938_pioptr->maskcpu);
354 __raw_writel(0, &tx4938_pioptr->maskext);
355
356#ifdef CONFIG_PCI
357 txx9_alloc_pci_controller(&txx9_primary_pcic, 0, 0, 0, 0);
358#endif
359}
360 178
361static void __init rbtx4938_time_init(void) 179static void __init rbtx4938_time_init(void)
362{ 180{
363 mips_hpt_frequency = txx9_cpu_clock / 2; 181 tx4938_time_init(0);
364 if (____raw_readq(&tx4938_ccfgptr->ccfg) & TX4938_CCFG_TINTDIS)
365 txx9_clockevent_init(TX4938_TMR_REG(0) & 0xfffffffffULL,
366 TXX9_IRQ_BASE + TX4938_IR_TMR(0),
367 txx9_gbus_clock / 2);
368} 182}
369 183
370static void __init rbtx4938_mem_setup(void) 184static void __init rbtx4938_mem_setup(void)
@@ -372,39 +186,24 @@ static void __init rbtx4938_mem_setup(void)
372 unsigned long long pcfg; 186 unsigned long long pcfg;
373 char *argptr; 187 char *argptr;
374 188
375 iomem_resource.end = 0xffffffff; /* 4GB */
376
377 if (txx9_master_clock == 0) 189 if (txx9_master_clock == 0)
378 txx9_master_clock = 25000000; /* 25MHz */ 190 txx9_master_clock = 25000000; /* 25MHz */
379 tx4938_board_setup(); 191
380#ifndef CONFIG_PCI 192 tx4938_setup();
193
194#ifdef CONFIG_PCI
195 txx9_alloc_pci_controller(&txx9_primary_pcic, 0, 0, 0, 0);
196#else
381 set_io_port_base(RBTX4938_ETHER_BASE); 197 set_io_port_base(RBTX4938_ETHER_BASE);
382#endif 198#endif
383 199
384#ifdef CONFIG_SERIAL_TXX9 200 tx4938_setup_serial();
385 {
386 extern int early_serial_txx9_setup(struct uart_port *port);
387 int i;
388 struct uart_port req;
389 for(i = 0; i < 2; i++) {
390 memset(&req, 0, sizeof(req));
391 req.line = i;
392 req.iotype = UPIO_MEM;
393 req.membase = (char *)(0xff1ff300 + i * 0x100);
394 req.mapbase = 0xff1ff300 + i * 0x100;
395 req.irq = RBTX4938_IRQ_IRC_SIO(i);
396 req.flags |= UPF_BUGGY_UART /*HAVE_CTS_LINE*/;
397 req.uartclk = 50000000;
398 early_serial_txx9_setup(&req);
399 }
400 }
401#ifdef CONFIG_SERIAL_TXX9_CONSOLE 201#ifdef CONFIG_SERIAL_TXX9_CONSOLE
402 argptr = prom_getcmdline(); 202 argptr = prom_getcmdline();
403 if (strstr(argptr, "console=") == NULL) { 203 if (strstr(argptr, "console=") == NULL) {
404 strcat(argptr, " console=ttyS0,38400"); 204 strcat(argptr, " console=ttyS0,38400");
405 } 205 }
406#endif 206#endif
407#endif
408 207
409#ifdef CONFIG_TOSHIBA_RBTX4938_MPLEX_PIO58_61 208#ifdef CONFIG_TOSHIBA_RBTX4938_MPLEX_PIO58_61
410 printk("PIOSEL: disabling both ata and nand selection\n"); 209 printk("PIOSEL: disabling both ata and nand selection\n");
@@ -568,7 +367,6 @@ static int __init rbtx4938_spi_init(void)
568 367
569static void __init rbtx4938_arch_init(void) 368static void __init rbtx4938_arch_init(void)
570{ 369{
571 txx9_gpio_init(TX4938_PIO_REG & 0xfffffffffULL, 0, 16);
572 gpiochip_add(&rbtx4938_spi_gpio_chip); 370 gpiochip_add(&rbtx4938_spi_gpio_chip);
573 rbtx4938_pci_setup(); 371 rbtx4938_pci_setup();
574 rbtx4938_spi_init(); 372 rbtx4938_spi_init();