config.c 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. /***************************************************************************/
  2. /*
  3. * linux/arch/m68knommu/platform/527x/config.c
  4. *
  5. * Sub-architcture dependant initialization code for the Freescale
  6. * 5270/5271 CPUs.
  7. *
  8. * Copyright (C) 1999-2004, Greg Ungerer (gerg@snapgear.com)
  9. * Copyright (C) 2001-2004, SnapGear Inc. (www.snapgear.com)
  10. */
  11. /***************************************************************************/
  12. #include <linux/kernel.h>
  13. #include <linux/param.h>
  14. #include <linux/init.h>
  15. #include <linux/interrupt.h>
  16. #include <linux/io.h>
  17. #include <asm/machdep.h>
  18. #include <asm/coldfire.h>
  19. #include <asm/mcfsim.h>
  20. #include <asm/mcfuart.h>
  21. /***************************************************************************/
  22. void coldfire_reset(void);
  23. /***************************************************************************/
  24. static struct mcf_platform_uart m527x_uart_platform[] = {
  25. {
  26. .mapbase = MCF_MBAR + MCFUART_BASE1,
  27. .irq = MCFINT_VECBASE + MCFINT_UART0,
  28. },
  29. {
  30. .mapbase = MCF_MBAR + MCFUART_BASE2,
  31. .irq = MCFINT_VECBASE + MCFINT_UART1,
  32. },
  33. {
  34. .mapbase = MCF_MBAR + MCFUART_BASE3,
  35. .irq = MCFINT_VECBASE + MCFINT_UART2,
  36. },
  37. { },
  38. };
  39. static struct platform_device m527x_uart = {
  40. .name = "mcfuart",
  41. .id = 0,
  42. .dev.platform_data = m527x_uart_platform,
  43. };
  44. static struct platform_device *m527x_devices[] __initdata = {
  45. &m527x_uart,
  46. };
  47. /***************************************************************************/
  48. #define INTC0 (MCF_MBAR + MCFICM_INTC0)
  49. static void __init m527x_uart_init_line(int line, int irq)
  50. {
  51. u16 sepmask;
  52. u32 imr;
  53. if ((line < 0) || (line > 2))
  54. return;
  55. /* level 6, line based priority */
  56. writeb(0x30+line, INTC0 + MCFINTC_ICR0 + MCFINT_UART0 + line);
  57. imr = readl(INTC0 + MCFINTC_IMRL);
  58. imr &= ~((1 << (irq - MCFINT_VECBASE)) | 1);
  59. writel(imr, INTC0 + MCFINTC_IMRL);
  60. /*
  61. * External Pin Mask Setting & Enable External Pin for Interface
  62. */
  63. sepmask = readw(MCF_IPSBAR + MCF_GPIO_PAR_UART);
  64. if (line == 0)
  65. sepmask |= UART0_ENABLE_MASK;
  66. else if (line == 1)
  67. sepmask |= UART1_ENABLE_MASK;
  68. else if (line == 2)
  69. sepmask |= UART2_ENABLE_MASK;
  70. writew(sepmask, MCF_IPSBAR + MCF_GPIO_PAR_UART);
  71. }
  72. static void __init m527x_uarts_init(void)
  73. {
  74. const int nrlines = ARRAY_SIZE(m527x_uart_platform);
  75. int line;
  76. for (line = 0; (line < nrlines); line++)
  77. m527x_uart_init_line(line, m527x_uart_platform[line].irq);
  78. }
  79. /***************************************************************************/
  80. void mcf_disableall(void)
  81. {
  82. *((volatile unsigned long *) (MCF_IPSBAR + MCFICM_INTC0 + MCFINTC_IMRH)) = 0xffffffff;
  83. *((volatile unsigned long *) (MCF_IPSBAR + MCFICM_INTC0 + MCFINTC_IMRL)) = 0xffffffff;
  84. }
  85. /***************************************************************************/
  86. void mcf_autovector(unsigned int vec)
  87. {
  88. /* Everything is auto-vectored on the 5272 */
  89. }
  90. /***************************************************************************/
  91. void __init config_BSP(char *commandp, int size)
  92. {
  93. mcf_disableall();
  94. mach_reset = coldfire_reset;
  95. }
  96. /***************************************************************************/
  97. static int __init init_BSP(void)
  98. {
  99. m527x_uarts_init();
  100. platform_add_devices(m527x_devices, ARRAY_SIZE(m527x_devices));
  101. return 0;
  102. }
  103. arch_initcall(init_BSP);
  104. /***************************************************************************/