Atsushi Nemoto | f6727fb | 2008-07-24 00:25:19 +0900 | [diff] [blame] | 1 | /* |
| 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 Nemoto | f6727fb | 2008-07-24 00:25:19 +0900 | [diff] [blame] | 16 | #include <linux/param.h> |
Atsushi Nemoto | 7779a5e | 2008-07-25 23:08:06 +0900 | [diff] [blame] | 17 | #include <linux/io.h> |
Atsushi Nemoto | f6727fb | 2008-07-24 00:25:19 +0900 | [diff] [blame] | 18 | #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 | |
| 25 | void __init tx3927_wdt_init(void) |
| 26 | { |
| 27 | txx9_wdt_init(TX3927_TMR_REG(2)); |
| 28 | } |
| 29 | |
| 30 | void __init tx3927_setup(void) |
| 31 | { |
| 32 | int i; |
| 33 | unsigned int conf; |
| 34 | |
Atsushi Nemoto | f6727fb | 2008-07-24 00:25:19 +0900 | [diff] [blame] | 35 | txx9_reg_res_init(TX3927_REV_PCODE(), TX3927_REG_BASE, |
| 36 | TX3927_REG_SIZE); |
| 37 | |
| 38 | /* SDRAMC,ROMC are configured by PROM */ |
| 39 | for (i = 0; i < 8; i++) { |
| 40 | if (!(tx3927_romcptr->cr[i] & 0x8)) |
| 41 | continue; /* disabled */ |
| 42 | txx9_ce_res[i].start = (unsigned long)TX3927_ROMC_BA(i); |
| 43 | txx9_ce_res[i].end = |
| 44 | txx9_ce_res[i].start + TX3927_ROMC_SIZE(i) - 1; |
| 45 | request_resource(&iomem_resource, &txx9_ce_res[i]); |
| 46 | } |
| 47 | |
| 48 | /* clocks */ |
| 49 | txx9_gbus_clock = txx9_cpu_clock / 2; |
| 50 | /* change default value to udelay/mdelay take reasonable time */ |
| 51 | loops_per_jiffy = txx9_cpu_clock / HZ / 2; |
| 52 | |
| 53 | /* CCFG */ |
| 54 | /* enable Timeout BusError */ |
| 55 | if (txx9_ccfg_toeon) |
| 56 | tx3927_ccfgptr->ccfg |= TX3927_CCFG_TOE; |
| 57 | |
| 58 | /* clear BusErrorOnWrite flag */ |
| 59 | tx3927_ccfgptr->ccfg &= ~TX3927_CCFG_BEOW; |
| 60 | if (read_c0_conf() & TX39_CONF_WBON) |
| 61 | /* Disable PCI snoop */ |
| 62 | tx3927_ccfgptr->ccfg &= ~TX3927_CCFG_PSNP; |
| 63 | else |
| 64 | /* Enable PCI SNOOP - with write through only */ |
| 65 | tx3927_ccfgptr->ccfg |= TX3927_CCFG_PSNP; |
| 66 | /* do reset on watchdog */ |
| 67 | tx3927_ccfgptr->ccfg |= TX3927_CCFG_WR; |
| 68 | |
| 69 | printk(KERN_INFO "TX3927 -- CRIR:%08lx CCFG:%08lx PCFG:%08lx\n", |
| 70 | tx3927_ccfgptr->crir, |
| 71 | tx3927_ccfgptr->ccfg, tx3927_ccfgptr->pcfg); |
| 72 | |
| 73 | /* TMR */ |
| 74 | for (i = 0; i < TX3927_NR_TMR; i++) |
| 75 | txx9_tmr_init(TX3927_TMR_REG(i)); |
| 76 | |
| 77 | /* DMA */ |
| 78 | tx3927_dmaptr->mcr = 0; |
| 79 | for (i = 0; i < ARRAY_SIZE(tx3927_dmaptr->ch); i++) { |
| 80 | /* reset channel */ |
| 81 | tx3927_dmaptr->ch[i].ccr = TX3927_DMA_CCR_CHRST; |
| 82 | tx3927_dmaptr->ch[i].ccr = 0; |
| 83 | } |
| 84 | /* enable DMA */ |
| 85 | #ifdef __BIG_ENDIAN |
| 86 | tx3927_dmaptr->mcr = TX3927_DMA_MCR_MSTEN; |
| 87 | #else |
| 88 | tx3927_dmaptr->mcr = TX3927_DMA_MCR_MSTEN | TX3927_DMA_MCR_LE; |
| 89 | #endif |
| 90 | |
| 91 | /* PIO */ |
| 92 | __raw_writel(0, &tx3927_pioptr->maskcpu); |
| 93 | __raw_writel(0, &tx3927_pioptr->maskext); |
| 94 | txx9_gpio_init(TX3927_PIO_REG, 0, 16); |
| 95 | |
| 96 | conf = read_c0_conf(); |
Atsushi Nemoto | d10e025 | 2008-08-19 22:55:09 +0900 | [diff] [blame] | 97 | if (conf & TX39_CONF_DCE) { |
| 98 | if (!(conf & TX39_CONF_WBON)) |
| 99 | pr_info("TX3927 D-Cache WriteThrough.\n"); |
| 100 | else if (!(conf & TX39_CONF_CWFON)) |
| 101 | pr_info("TX3927 D-Cache WriteBack.\n"); |
| 102 | else |
| 103 | pr_info("TX3927 D-Cache WriteBack (CWF) .\n"); |
| 104 | } |
Atsushi Nemoto | f6727fb | 2008-07-24 00:25:19 +0900 | [diff] [blame] | 105 | } |
| 106 | |
| 107 | void __init tx3927_time_init(unsigned int evt_tmrnr, unsigned int src_tmrnr) |
| 108 | { |
| 109 | txx9_clockevent_init(TX3927_TMR_REG(evt_tmrnr), |
| 110 | TXX9_IRQ_BASE + TX3927_IR_TMR(evt_tmrnr), |
| 111 | TXX9_IMCLK); |
| 112 | txx9_clocksource_init(TX3927_TMR_REG(src_tmrnr), TXX9_IMCLK); |
| 113 | } |
| 114 | |
Atsushi Nemoto | 7779a5e | 2008-07-25 23:08:06 +0900 | [diff] [blame] | 115 | void __init tx3927_sio_init(unsigned int sclk, unsigned int cts_mask) |
Atsushi Nemoto | f6727fb | 2008-07-24 00:25:19 +0900 | [diff] [blame] | 116 | { |
Atsushi Nemoto | f6727fb | 2008-07-24 00:25:19 +0900 | [diff] [blame] | 117 | int i; |
Atsushi Nemoto | f6727fb | 2008-07-24 00:25:19 +0900 | [diff] [blame] | 118 | |
Atsushi Nemoto | 7779a5e | 2008-07-25 23:08:06 +0900 | [diff] [blame] | 119 | for (i = 0; i < 2; i++) |
| 120 | txx9_sio_init(TX3927_SIO_REG(i), |
| 121 | TXX9_IRQ_BASE + TX3927_IR_SIO(i), |
| 122 | i, sclk, (1 << i) & cts_mask); |
Atsushi Nemoto | f6727fb | 2008-07-24 00:25:19 +0900 | [diff] [blame] | 123 | } |