config.c 3.1 KB

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