config.c 3.3 KB

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