config.c 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  1. /***************************************************************************/
  2. /*
  3. * linux/arch/m68knommu/platform/5206e/config.c
  4. *
  5. * Copyright (C) 1999-2002, Greg Ungerer (gerg@snapgear.com)
  6. */
  7. /***************************************************************************/
  8. #include <linux/kernel.h>
  9. #include <linux/param.h>
  10. #include <linux/init.h>
  11. #include <linux/io.h>
  12. #include <asm/machdep.h>
  13. #include <asm/coldfire.h>
  14. #include <asm/mcfsim.h>
  15. #include <asm/mcfuart.h>
  16. #include <asm/mcfdma.h>
  17. #include <asm/mcfuart.h>
  18. /***************************************************************************/
  19. static struct mcf_platform_uart m5206e_uart_platform[] = {
  20. {
  21. .mapbase = MCF_MBAR + MCFUART_BASE1,
  22. .irq = 73,
  23. },
  24. {
  25. .mapbase = MCF_MBAR + MCFUART_BASE2,
  26. .irq = 74,
  27. },
  28. { },
  29. };
  30. static struct platform_device m5206e_uart = {
  31. .name = "mcfuart",
  32. .id = 0,
  33. .dev.platform_data = m5206e_uart_platform,
  34. };
  35. static struct platform_device *m5206e_devices[] __initdata = {
  36. &m5206e_uart,
  37. };
  38. /***************************************************************************/
  39. static void __init m5206e_uart_init_line(int line, int irq)
  40. {
  41. if (line == 0) {
  42. writel(MCFSIM_ICR_LEVEL6 | MCFSIM_ICR_PRI1, MCF_MBAR + MCFSIM_UART1ICR);
  43. writeb(irq, MCFUART_BASE1 + MCFUART_UIVR);
  44. mcf_setimr(mcf_getimr() & ~MCFSIM_IMR_UART1);
  45. } else if (line == 1) {
  46. writel(MCFSIM_ICR_LEVEL6 | MCFSIM_ICR_PRI2, MCF_MBAR + MCFSIM_UART2ICR);
  47. writeb(irq, MCFUART_BASE2 + MCFUART_UIVR);
  48. mcf_setimr(mcf_getimr() & ~MCFSIM_IMR_UART2);
  49. }
  50. }
  51. static void __init m5206e_uarts_init(void)
  52. {
  53. const int nrlines = ARRAY_SIZE(m5206e_uart_platform);
  54. int line;
  55. for (line = 0; (line < nrlines); line++)
  56. m5206e_uart_init_line(line, m5206e_uart_platform[line].irq);
  57. }
  58. /***************************************************************************/
  59. void mcf_autovector(unsigned int vec)
  60. {
  61. volatile unsigned char *mbar;
  62. unsigned char icr;
  63. if ((vec >= 25) && (vec <= 31)) {
  64. vec -= 25;
  65. mbar = (volatile unsigned char *) MCF_MBAR;
  66. icr = MCFSIM_ICR_AUTOVEC | (vec << 3);
  67. *(mbar + MCFSIM_ICR1 + vec) = icr;
  68. vec = 0x1 << (vec + 1);
  69. mcf_setimr(mcf_getimr() & ~vec);
  70. }
  71. }
  72. /***************************************************************************/
  73. void mcf_settimericr(unsigned int timer, unsigned int level)
  74. {
  75. volatile unsigned char *icrp;
  76. unsigned int icr, imr;
  77. if (timer <= 2) {
  78. switch (timer) {
  79. case 2: icr = MCFSIM_TIMER2ICR; imr = MCFSIM_IMR_TIMER2; break;
  80. default: icr = MCFSIM_TIMER1ICR; imr = MCFSIM_IMR_TIMER1; break;
  81. }
  82. icrp = (volatile unsigned char *) (MCF_MBAR + icr);
  83. *icrp = MCFSIM_ICR_AUTOVEC | (level << 2) | MCFSIM_ICR_PRI3;
  84. mcf_setimr(mcf_getimr() & ~imr);
  85. }
  86. }
  87. /***************************************************************************/
  88. void m5206e_cpu_reset(void)
  89. {
  90. local_irq_disable();
  91. /* Set watchdog to soft reset, and enabled */
  92. __raw_writeb(0xc0, MCF_MBAR + MCFSIM_SYPCR);
  93. for (;;)
  94. /* wait for watchdog to timeout */;
  95. }
  96. /***************************************************************************/
  97. void __init config_BSP(char *commandp, int size)
  98. {
  99. mcf_setimr(MCFSIM_IMR_MASKALL);
  100. #if defined(CONFIG_NETtel)
  101. /* Copy command line from FLASH to local buffer... */
  102. memcpy(commandp, (char *) 0xf0004000, size);
  103. commandp[size-1] = 0;
  104. #endif /* CONFIG_NETtel */
  105. mach_reset = m5206e_cpu_reset;
  106. }
  107. /***************************************************************************/
  108. static int __init init_BSP(void)
  109. {
  110. m5206e_uarts_init();
  111. platform_add_devices(m5206e_devices, ARRAY_SIZE(m5206e_devices));
  112. return 0;
  113. }
  114. arch_initcall(init_BSP);
  115. /***************************************************************************/