18c2ecf20Sopenharmony_ci/* 28c2ecf20Sopenharmony_ci * TX3927 setup routines 38c2ecf20Sopenharmony_ci * Based on linux/arch/mips/txx9/jmr3927/setup.c 48c2ecf20Sopenharmony_ci * 58c2ecf20Sopenharmony_ci * Copyright 2001 MontaVista Software Inc. 68c2ecf20Sopenharmony_ci * Copyright (C) 2000-2001 Toshiba Corporation 78c2ecf20Sopenharmony_ci * Copyright (C) 2007 Ralf Baechle (ralf@linux-mips.org) 88c2ecf20Sopenharmony_ci * 98c2ecf20Sopenharmony_ci * This file is subject to the terms and conditions of the GNU General Public 108c2ecf20Sopenharmony_ci * License. See the file "COPYING" in the main directory of this archive 118c2ecf20Sopenharmony_ci * for more details. 128c2ecf20Sopenharmony_ci */ 138c2ecf20Sopenharmony_ci#include <linux/init.h> 148c2ecf20Sopenharmony_ci#include <linux/ioport.h> 158c2ecf20Sopenharmony_ci#include <linux/delay.h> 168c2ecf20Sopenharmony_ci#include <linux/param.h> 178c2ecf20Sopenharmony_ci#include <linux/io.h> 188c2ecf20Sopenharmony_ci#include <linux/mtd/physmap.h> 198c2ecf20Sopenharmony_ci#include <asm/mipsregs.h> 208c2ecf20Sopenharmony_ci#include <asm/txx9irq.h> 218c2ecf20Sopenharmony_ci#include <asm/txx9tmr.h> 228c2ecf20Sopenharmony_ci#include <asm/txx9pio.h> 238c2ecf20Sopenharmony_ci#include <asm/txx9/generic.h> 248c2ecf20Sopenharmony_ci#include <asm/txx9/tx3927.h> 258c2ecf20Sopenharmony_ci 268c2ecf20Sopenharmony_civoid __init tx3927_wdt_init(void) 278c2ecf20Sopenharmony_ci{ 288c2ecf20Sopenharmony_ci txx9_wdt_init(TX3927_TMR_REG(2)); 298c2ecf20Sopenharmony_ci} 308c2ecf20Sopenharmony_ci 318c2ecf20Sopenharmony_civoid __init tx3927_setup(void) 328c2ecf20Sopenharmony_ci{ 338c2ecf20Sopenharmony_ci int i; 348c2ecf20Sopenharmony_ci unsigned int conf; 358c2ecf20Sopenharmony_ci 368c2ecf20Sopenharmony_ci txx9_reg_res_init(TX3927_REV_PCODE(), TX3927_REG_BASE, 378c2ecf20Sopenharmony_ci TX3927_REG_SIZE); 388c2ecf20Sopenharmony_ci 398c2ecf20Sopenharmony_ci /* SDRAMC,ROMC are configured by PROM */ 408c2ecf20Sopenharmony_ci for (i = 0; i < 8; i++) { 418c2ecf20Sopenharmony_ci if (!(tx3927_romcptr->cr[i] & 0x8)) 428c2ecf20Sopenharmony_ci continue; /* disabled */ 438c2ecf20Sopenharmony_ci txx9_ce_res[i].start = (unsigned long)TX3927_ROMC_BA(i); 448c2ecf20Sopenharmony_ci txx9_ce_res[i].end = 458c2ecf20Sopenharmony_ci txx9_ce_res[i].start + TX3927_ROMC_SIZE(i) - 1; 468c2ecf20Sopenharmony_ci request_resource(&iomem_resource, &txx9_ce_res[i]); 478c2ecf20Sopenharmony_ci } 488c2ecf20Sopenharmony_ci 498c2ecf20Sopenharmony_ci /* clocks */ 508c2ecf20Sopenharmony_ci txx9_gbus_clock = txx9_cpu_clock / 2; 518c2ecf20Sopenharmony_ci /* change default value to udelay/mdelay take reasonable time */ 528c2ecf20Sopenharmony_ci loops_per_jiffy = txx9_cpu_clock / HZ / 2; 538c2ecf20Sopenharmony_ci 548c2ecf20Sopenharmony_ci /* CCFG */ 558c2ecf20Sopenharmony_ci /* enable Timeout BusError */ 568c2ecf20Sopenharmony_ci if (txx9_ccfg_toeon) 578c2ecf20Sopenharmony_ci tx3927_ccfgptr->ccfg |= TX3927_CCFG_TOE; 588c2ecf20Sopenharmony_ci 598c2ecf20Sopenharmony_ci /* clear BusErrorOnWrite flag */ 608c2ecf20Sopenharmony_ci tx3927_ccfgptr->ccfg &= ~TX3927_CCFG_BEOW; 618c2ecf20Sopenharmony_ci if (read_c0_conf() & TX39_CONF_WBON) 628c2ecf20Sopenharmony_ci /* Disable PCI snoop */ 638c2ecf20Sopenharmony_ci tx3927_ccfgptr->ccfg &= ~TX3927_CCFG_PSNP; 648c2ecf20Sopenharmony_ci else 658c2ecf20Sopenharmony_ci /* Enable PCI SNOOP - with write through only */ 668c2ecf20Sopenharmony_ci tx3927_ccfgptr->ccfg |= TX3927_CCFG_PSNP; 678c2ecf20Sopenharmony_ci /* do reset on watchdog */ 688c2ecf20Sopenharmony_ci tx3927_ccfgptr->ccfg |= TX3927_CCFG_WR; 698c2ecf20Sopenharmony_ci 708c2ecf20Sopenharmony_ci pr_info("TX3927 -- CRIR:%08lx CCFG:%08lx PCFG:%08lx\n", 718c2ecf20Sopenharmony_ci tx3927_ccfgptr->crir, tx3927_ccfgptr->ccfg, 728c2ecf20Sopenharmony_ci tx3927_ccfgptr->pcfg); 738c2ecf20Sopenharmony_ci 748c2ecf20Sopenharmony_ci /* TMR */ 758c2ecf20Sopenharmony_ci for (i = 0; i < TX3927_NR_TMR; i++) 768c2ecf20Sopenharmony_ci txx9_tmr_init(TX3927_TMR_REG(i)); 778c2ecf20Sopenharmony_ci 788c2ecf20Sopenharmony_ci /* DMA */ 798c2ecf20Sopenharmony_ci tx3927_dmaptr->mcr = 0; 808c2ecf20Sopenharmony_ci for (i = 0; i < ARRAY_SIZE(tx3927_dmaptr->ch); i++) { 818c2ecf20Sopenharmony_ci /* reset channel */ 828c2ecf20Sopenharmony_ci tx3927_dmaptr->ch[i].ccr = TX3927_DMA_CCR_CHRST; 838c2ecf20Sopenharmony_ci tx3927_dmaptr->ch[i].ccr = 0; 848c2ecf20Sopenharmony_ci } 858c2ecf20Sopenharmony_ci /* enable DMA */ 868c2ecf20Sopenharmony_ci#ifdef __BIG_ENDIAN 878c2ecf20Sopenharmony_ci tx3927_dmaptr->mcr = TX3927_DMA_MCR_MSTEN; 888c2ecf20Sopenharmony_ci#else 898c2ecf20Sopenharmony_ci tx3927_dmaptr->mcr = TX3927_DMA_MCR_MSTEN | TX3927_DMA_MCR_LE; 908c2ecf20Sopenharmony_ci#endif 918c2ecf20Sopenharmony_ci 928c2ecf20Sopenharmony_ci /* PIO */ 938c2ecf20Sopenharmony_ci __raw_writel(0, &tx3927_pioptr->maskcpu); 948c2ecf20Sopenharmony_ci __raw_writel(0, &tx3927_pioptr->maskext); 958c2ecf20Sopenharmony_ci 968c2ecf20Sopenharmony_ci conf = read_c0_conf(); 978c2ecf20Sopenharmony_ci if (conf & TX39_CONF_DCE) { 988c2ecf20Sopenharmony_ci if (!(conf & TX39_CONF_WBON)) 998c2ecf20Sopenharmony_ci pr_info("TX3927 D-Cache WriteThrough.\n"); 1008c2ecf20Sopenharmony_ci else if (!(conf & TX39_CONF_CWFON)) 1018c2ecf20Sopenharmony_ci pr_info("TX3927 D-Cache WriteBack.\n"); 1028c2ecf20Sopenharmony_ci else 1038c2ecf20Sopenharmony_ci pr_info("TX3927 D-Cache WriteBack (CWF) .\n"); 1048c2ecf20Sopenharmony_ci } 1058c2ecf20Sopenharmony_ci} 1068c2ecf20Sopenharmony_ci 1078c2ecf20Sopenharmony_civoid __init tx3927_time_init(unsigned int evt_tmrnr, unsigned int src_tmrnr) 1088c2ecf20Sopenharmony_ci{ 1098c2ecf20Sopenharmony_ci txx9_clockevent_init(TX3927_TMR_REG(evt_tmrnr), 1108c2ecf20Sopenharmony_ci TXX9_IRQ_BASE + TX3927_IR_TMR(evt_tmrnr), 1118c2ecf20Sopenharmony_ci TXX9_IMCLK); 1128c2ecf20Sopenharmony_ci txx9_clocksource_init(TX3927_TMR_REG(src_tmrnr), TXX9_IMCLK); 1138c2ecf20Sopenharmony_ci} 1148c2ecf20Sopenharmony_ci 1158c2ecf20Sopenharmony_civoid __init tx3927_sio_init(unsigned int sclk, unsigned int cts_mask) 1168c2ecf20Sopenharmony_ci{ 1178c2ecf20Sopenharmony_ci int i; 1188c2ecf20Sopenharmony_ci 1198c2ecf20Sopenharmony_ci for (i = 0; i < 2; i++) 1208c2ecf20Sopenharmony_ci txx9_sio_init(TX3927_SIO_REG(i), 1218c2ecf20Sopenharmony_ci TXX9_IRQ_BASE + TX3927_IR_SIO(i), 1228c2ecf20Sopenharmony_ci i, sclk, (1 << i) & cts_mask); 1238c2ecf20Sopenharmony_ci} 1248c2ecf20Sopenharmony_ci 1258c2ecf20Sopenharmony_civoid __init tx3927_mtd_init(int ch) 1268c2ecf20Sopenharmony_ci{ 1278c2ecf20Sopenharmony_ci struct physmap_flash_data pdata = { 1288c2ecf20Sopenharmony_ci .width = TX3927_ROMC_WIDTH(ch) / 8, 1298c2ecf20Sopenharmony_ci }; 1308c2ecf20Sopenharmony_ci unsigned long start = txx9_ce_res[ch].start; 1318c2ecf20Sopenharmony_ci unsigned long size = txx9_ce_res[ch].end - start + 1; 1328c2ecf20Sopenharmony_ci 1338c2ecf20Sopenharmony_ci if (!(tx3927_romcptr->cr[ch] & 0x8)) 1348c2ecf20Sopenharmony_ci return; /* disabled */ 1358c2ecf20Sopenharmony_ci txx9_physmap_flash_init(ch, start, size, &pdata); 1368c2ecf20Sopenharmony_ci} 137