config.c 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  1. /***************************************************************************/
  2. /*
  3. * linux/arch/m68knommu/platform/5307/config.c
  4. *
  5. * Copyright (C) 1999-2002, Greg Ungerer (gerg@snapgear.com)
  6. * Copyright (C) 2000, Lineo (www.lineo.com)
  7. */
  8. /***************************************************************************/
  9. #include <linux/kernel.h>
  10. #include <linux/param.h>
  11. #include <linux/init.h>
  12. #include <linux/io.h>
  13. #include <asm/machdep.h>
  14. #include <asm/coldfire.h>
  15. #include <asm/mcfsim.h>
  16. #include <asm/mcfuart.h>
  17. #include <asm/mcfwdebug.h>
  18. /***************************************************************************/
  19. extern unsigned int mcf_timervector;
  20. extern unsigned int mcf_profilevector;
  21. extern unsigned int mcf_timerlevel;
  22. /***************************************************************************/
  23. /*
  24. * Some platforms need software versions of the GPIO data registers.
  25. */
  26. unsigned short ppdata;
  27. unsigned char ledbank = 0xff;
  28. /***************************************************************************/
  29. static struct mcf_platform_uart m5307_uart_platform[] = {
  30. {
  31. .mapbase = MCF_MBAR + MCFUART_BASE1,
  32. .irq = 73,
  33. },
  34. {
  35. .mapbase = MCF_MBAR + MCFUART_BASE2,
  36. .irq = 74,
  37. },
  38. { },
  39. };
  40. static struct platform_device m5307_uart = {
  41. .name = "mcfuart",
  42. .id = 0,
  43. .dev.platform_data = m5307_uart_platform,
  44. };
  45. static struct platform_device *m5307_devices[] __initdata = {
  46. &m5307_uart,
  47. };
  48. /***************************************************************************/
  49. static void __init m5307_uart_init_line(int line, int irq)
  50. {
  51. if (line == 0) {
  52. writeb(MCFSIM_ICR_LEVEL6 | MCFSIM_ICR_PRI1, MCF_MBAR + MCFSIM_UART1ICR);
  53. writeb(irq, MCF_MBAR + MCFUART_BASE1 + MCFUART_UIVR);
  54. mcf_setimr(mcf_getimr() & ~MCFSIM_IMR_UART1);
  55. } else if (line == 1) {
  56. writeb(MCFSIM_ICR_LEVEL6 | MCFSIM_ICR_PRI2, MCF_MBAR + MCFSIM_UART2ICR);
  57. writeb(irq, MCF_MBAR + MCFUART_BASE2 + MCFUART_UIVR);
  58. mcf_setimr(mcf_getimr() & ~MCFSIM_IMR_UART2);
  59. }
  60. }
  61. static void __init m5307_uarts_init(void)
  62. {
  63. const int nrlines = ARRAY_SIZE(m5307_uart_platform);
  64. int line;
  65. for (line = 0; (line < nrlines); line++)
  66. m5307_uart_init_line(line, m5307_uart_platform[line].irq);
  67. }
  68. /***************************************************************************/
  69. void mcf_autovector(unsigned int vec)
  70. {
  71. volatile unsigned char *mbar;
  72. if ((vec >= 25) && (vec <= 31)) {
  73. mbar = (volatile unsigned char *) MCF_MBAR;
  74. vec = 0x1 << (vec - 24);
  75. *(mbar + MCFSIM_AVR) |= vec;
  76. mcf_setimr(mcf_getimr() & ~vec);
  77. }
  78. }
  79. /***************************************************************************/
  80. void mcf_settimericr(unsigned int timer, unsigned int level)
  81. {
  82. volatile unsigned char *icrp;
  83. unsigned int icr, imr;
  84. if (timer <= 2) {
  85. switch (timer) {
  86. case 2: icr = MCFSIM_TIMER2ICR; imr = MCFSIM_IMR_TIMER2; break;
  87. default: icr = MCFSIM_TIMER1ICR; imr = MCFSIM_IMR_TIMER1; break;
  88. }
  89. icrp = (volatile unsigned char *) (MCF_MBAR + icr);
  90. *icrp = MCFSIM_ICR_AUTOVEC | (level << 2) | MCFSIM_ICR_PRI3;
  91. mcf_setimr(mcf_getimr() & ~imr);
  92. }
  93. }
  94. /***************************************************************************/
  95. void m5307_cpu_reset(void)
  96. {
  97. local_irq_disable();
  98. /* Set watchdog to soft reset, and enabled */
  99. __raw_writeb(0xc0, MCF_MBAR + MCFSIM_SYPCR);
  100. for (;;)
  101. /* wait for watchdog to timeout */;
  102. }
  103. /***************************************************************************/
  104. void __init config_BSP(char *commandp, int size)
  105. {
  106. mcf_setimr(MCFSIM_IMR_MASKALL);
  107. #if defined(CONFIG_NETtel) || \
  108. defined(CONFIG_SECUREEDGEMP3) || defined(CONFIG_CLEOPATRA)
  109. /* Copy command line from FLASH to local buffer... */
  110. memcpy(commandp, (char *) 0xf0004000, size);
  111. commandp[size-1] = 0;
  112. /* Different timer setup - to prevent device clash */
  113. mcf_timervector = 30;
  114. mcf_profilevector = 31;
  115. mcf_timerlevel = 6;
  116. #endif
  117. mach_reset = m5307_cpu_reset;
  118. #ifdef CONFIG_BDM_DISABLE
  119. /*
  120. * Disable the BDM clocking. This also turns off most of the rest of
  121. * the BDM device. This is good for EMC reasons. This option is not
  122. * incompatible with the memory protection option.
  123. */
  124. wdebug(MCFDEBUG_CSR, MCFDEBUG_CSR_PSTCLK);
  125. #endif
  126. }
  127. /***************************************************************************/
  128. static int __init init_BSP(void)
  129. {
  130. m5307_uarts_init();
  131. platform_add_devices(m5307_devices, ARRAY_SIZE(m5307_devices));
  132. return 0;
  133. }
  134. arch_initcall(init_BSP);
  135. /***************************************************************************/