config.c 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. /***************************************************************************/
  2. /*
  3. * linux/arch/m68knommu/platform/5206/config.c
  4. *
  5. * Copyright (C) 1999-2002, Greg Ungerer (gerg@snapgear.com)
  6. * Copyright (C) 2000-2001, Lineo Inc. (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. /***************************************************************************/
  18. static struct mcf_platform_uart m5206_uart_platform[] = {
  19. {
  20. .mapbase = MCF_MBAR + MCFUART_BASE1,
  21. .irq = 73,
  22. },
  23. {
  24. .mapbase = MCF_MBAR + MCFUART_BASE2,
  25. .irq = 74,
  26. },
  27. { },
  28. };
  29. static struct platform_device m5206_uart = {
  30. .name = "mcfuart",
  31. .id = 0,
  32. .dev.platform_data = m5206_uart_platform,
  33. };
  34. static struct platform_device *m5206_devices[] __initdata = {
  35. &m5206_uart,
  36. };
  37. /***************************************************************************/
  38. static void __init m5206_uart_init_line(int line, int irq)
  39. {
  40. if (line == 0) {
  41. writel(MCFSIM_ICR_LEVEL6 | MCFSIM_ICR_PRI1, MCF_MBAR + MCFSIM_UART1ICR);
  42. writeb(irq, MCFUART_BASE1 + MCFUART_UIVR);
  43. mcf_setimr(mcf_getimr() & ~MCFSIM_IMR_UART1);
  44. } else if (line == 1) {
  45. writel(MCFSIM_ICR_LEVEL6 | MCFSIM_ICR_PRI2, MCF_MBAR + MCFSIM_UART2ICR);
  46. writeb(irq, MCFUART_BASE2 + MCFUART_UIVR);
  47. mcf_setimr(mcf_getimr() & ~MCFSIM_IMR_UART2);
  48. }
  49. }
  50. static void __init m5206_uarts_init(void)
  51. {
  52. const int nrlines = ARRAY_SIZE(m5206_uart_platform);
  53. int line;
  54. for (line = 0; (line < nrlines); line++)
  55. m5206_uart_init_line(line, m5206_uart_platform[line].irq);
  56. }
  57. /***************************************************************************/
  58. void mcf_autovector(unsigned int vec)
  59. {
  60. volatile unsigned char *mbar;
  61. unsigned char icr;
  62. if ((vec >= 25) && (vec <= 31)) {
  63. vec -= 25;
  64. mbar = (volatile unsigned char *) MCF_MBAR;
  65. icr = MCFSIM_ICR_AUTOVEC | (vec << 3);
  66. *(mbar + MCFSIM_ICR1 + vec) = icr;
  67. vec = 0x1 << (vec + 1);
  68. mcf_setimr(mcf_getimr() & ~vec);
  69. }
  70. }
  71. /***************************************************************************/
  72. void mcf_settimericr(unsigned int timer, unsigned int level)
  73. {
  74. volatile unsigned char *icrp;
  75. unsigned int icr, imr;
  76. if (timer <= 2) {
  77. switch (timer) {
  78. case 2: icr = MCFSIM_TIMER2ICR; imr = MCFSIM_IMR_TIMER2; break;
  79. default: icr = MCFSIM_TIMER1ICR; imr = MCFSIM_IMR_TIMER1; break;
  80. }
  81. icrp = (volatile unsigned char *) (MCF_MBAR + icr);
  82. *icrp = MCFSIM_ICR_AUTOVEC | (level << 2) | MCFSIM_ICR_PRI3;
  83. mcf_setimr(mcf_getimr() & ~imr);
  84. }
  85. }
  86. /***************************************************************************/
  87. void m5206_cpu_reset(void)
  88. {
  89. local_irq_disable();
  90. /* Set watchdog to soft reset, and enabled */
  91. __raw_writeb(0xc0, MCF_MBAR + MCFSIM_SYPCR);
  92. for (;;)
  93. /* wait for watchdog to timeout */;
  94. }
  95. /***************************************************************************/
  96. void __init config_BSP(char *commandp, int size)
  97. {
  98. mcf_setimr(MCFSIM_IMR_MASKALL);
  99. mach_reset = m5206_cpu_reset;
  100. }
  101. /***************************************************************************/
  102. static int __init init_BSP(void)
  103. {
  104. m5206_uarts_init();
  105. platform_add_devices(m5206_devices, ARRAY_SIZE(m5206_devices));
  106. return 0;
  107. }
  108. arch_initcall(init_BSP);
  109. /***************************************************************************/