setup_tx3927.c 3.6 KB

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