blob: 4bc2f859379d95fc8b136792dfb3731d0eda9d8b [file] [log] [blame]
Atsushi Nemotof6727fb2008-07-24 00:25:19 +09001/*
2 * TX3927 setup routines
3 * Based on linux/arch/mips/txx9/jmr3927/setup.c
4 *
5 * Copyright 2001 MontaVista Software Inc.
6 * Copyright (C) 2000-2001 Toshiba Corporation
7 * Copyright (C) 2007 Ralf Baechle (ralf@linux-mips.org)
8 *
9 * This file is subject to the terms and conditions of the GNU General Public
10 * License. See the file "COPYING" in the main directory of this archive
11 * for more details.
12 */
13#include <linux/init.h>
14#include <linux/ioport.h>
15#include <linux/delay.h>
Atsushi Nemotof6727fb2008-07-24 00:25:19 +090016#include <linux/param.h>
Atsushi Nemoto7779a5e2008-07-25 23:08:06 +090017#include <linux/io.h>
Atsushi Nemotof6727fb2008-07-24 00:25:19 +090018#include <asm/mipsregs.h>
19#include <asm/txx9irq.h>
20#include <asm/txx9tmr.h>
21#include <asm/txx9pio.h>
22#include <asm/txx9/generic.h>
23#include <asm/txx9/tx3927.h>
24
25void __init tx3927_wdt_init(void)
26{
27 txx9_wdt_init(TX3927_TMR_REG(2));
28}
29
30void __init tx3927_setup(void)
31{
32 int i;
33 unsigned int conf;
34
35 /* don't enable - see errata */
36 txx9_ccfg_toeon = 0;
37 if (strstr(prom_getcmdline(), "toeon") != NULL)
38 txx9_ccfg_toeon = 1;
39
40 txx9_reg_res_init(TX3927_REV_PCODE(), TX3927_REG_BASE,
41 TX3927_REG_SIZE);
42
43 /* SDRAMC,ROMC are configured by PROM */
44 for (i = 0; i < 8; i++) {
45 if (!(tx3927_romcptr->cr[i] & 0x8))
46 continue; /* disabled */
47 txx9_ce_res[i].start = (unsigned long)TX3927_ROMC_BA(i);
48 txx9_ce_res[i].end =
49 txx9_ce_res[i].start + TX3927_ROMC_SIZE(i) - 1;
50 request_resource(&iomem_resource, &txx9_ce_res[i]);
51 }
52
53 /* clocks */
54 txx9_gbus_clock = txx9_cpu_clock / 2;
55 /* change default value to udelay/mdelay take reasonable time */
56 loops_per_jiffy = txx9_cpu_clock / HZ / 2;
57
58 /* CCFG */
59 /* enable Timeout BusError */
60 if (txx9_ccfg_toeon)
61 tx3927_ccfgptr->ccfg |= TX3927_CCFG_TOE;
62
63 /* clear BusErrorOnWrite flag */
64 tx3927_ccfgptr->ccfg &= ~TX3927_CCFG_BEOW;
65 if (read_c0_conf() & TX39_CONF_WBON)
66 /* Disable PCI snoop */
67 tx3927_ccfgptr->ccfg &= ~TX3927_CCFG_PSNP;
68 else
69 /* Enable PCI SNOOP - with write through only */
70 tx3927_ccfgptr->ccfg |= TX3927_CCFG_PSNP;
71 /* do reset on watchdog */
72 tx3927_ccfgptr->ccfg |= TX3927_CCFG_WR;
73
74 printk(KERN_INFO "TX3927 -- CRIR:%08lx CCFG:%08lx PCFG:%08lx\n",
75 tx3927_ccfgptr->crir,
76 tx3927_ccfgptr->ccfg, tx3927_ccfgptr->pcfg);
77
78 /* TMR */
79 for (i = 0; i < TX3927_NR_TMR; i++)
80 txx9_tmr_init(TX3927_TMR_REG(i));
81
82 /* DMA */
83 tx3927_dmaptr->mcr = 0;
84 for (i = 0; i < ARRAY_SIZE(tx3927_dmaptr->ch); i++) {
85 /* reset channel */
86 tx3927_dmaptr->ch[i].ccr = TX3927_DMA_CCR_CHRST;
87 tx3927_dmaptr->ch[i].ccr = 0;
88 }
89 /* enable DMA */
90#ifdef __BIG_ENDIAN
91 tx3927_dmaptr->mcr = TX3927_DMA_MCR_MSTEN;
92#else
93 tx3927_dmaptr->mcr = TX3927_DMA_MCR_MSTEN | TX3927_DMA_MCR_LE;
94#endif
95
96 /* PIO */
97 __raw_writel(0, &tx3927_pioptr->maskcpu);
98 __raw_writel(0, &tx3927_pioptr->maskext);
99 txx9_gpio_init(TX3927_PIO_REG, 0, 16);
100
101 conf = read_c0_conf();
Atsushi Nemotod10e0252008-08-19 22:55:09 +0900102 if (conf & TX39_CONF_DCE) {
103 if (!(conf & TX39_CONF_WBON))
104 pr_info("TX3927 D-Cache WriteThrough.\n");
105 else if (!(conf & TX39_CONF_CWFON))
106 pr_info("TX3927 D-Cache WriteBack.\n");
107 else
108 pr_info("TX3927 D-Cache WriteBack (CWF) .\n");
109 }
Atsushi Nemotof6727fb2008-07-24 00:25:19 +0900110}
111
112void __init tx3927_time_init(unsigned int evt_tmrnr, unsigned int src_tmrnr)
113{
114 txx9_clockevent_init(TX3927_TMR_REG(evt_tmrnr),
115 TXX9_IRQ_BASE + TX3927_IR_TMR(evt_tmrnr),
116 TXX9_IMCLK);
117 txx9_clocksource_init(TX3927_TMR_REG(src_tmrnr), TXX9_IMCLK);
118}
119
Atsushi Nemoto7779a5e2008-07-25 23:08:06 +0900120void __init tx3927_sio_init(unsigned int sclk, unsigned int cts_mask)
Atsushi Nemotof6727fb2008-07-24 00:25:19 +0900121{
Atsushi Nemotof6727fb2008-07-24 00:25:19 +0900122 int i;
Atsushi Nemotof6727fb2008-07-24 00:25:19 +0900123
Atsushi Nemoto7779a5e2008-07-25 23:08:06 +0900124 for (i = 0; i < 2; i++)
125 txx9_sio_init(TX3927_SIO_REG(i),
126 TXX9_IRQ_BASE + TX3927_IR_SIO(i),
127 i, sclk, (1 << i) & cts_mask);
Atsushi Nemotof6727fb2008-07-24 00:25:19 +0900128}