config.c 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. /***************************************************************************/
  2. /*
  3. * linux/arch/m68knommu/platform/520x/config.c
  4. *
  5. * Copyright (C) 2005, Freescale (www.freescale.com)
  6. * Copyright (C) 2005, Intec Automation (mike@steroidmicros.com)
  7. * Copyright (C) 1999-2007, Greg Ungerer (gerg@snapgear.com)
  8. * Copyright (C) 2001-2003, SnapGear Inc. (www.snapgear.com)
  9. */
  10. /***************************************************************************/
  11. #include <linux/kernel.h>
  12. #include <linux/param.h>
  13. #include <linux/init.h>
  14. #include <linux/interrupt.h>
  15. #include <linux/io.h>
  16. #include <asm/machdep.h>
  17. #include <asm/coldfire.h>
  18. #include <asm/mcfsim.h>
  19. #include <asm/mcfuart.h>
  20. /***************************************************************************/
  21. void coldfire_reset(void);
  22. /***************************************************************************/
  23. static struct mcf_platform_uart m520x_uart_platform[] = {
  24. {
  25. .mapbase = MCF_MBAR + MCFUART_BASE1,
  26. .irq = MCFINT_VECBASE + MCFINT_UART0,
  27. },
  28. {
  29. .mapbase = MCF_MBAR + MCFUART_BASE2,
  30. .irq = MCFINT_VECBASE + MCFINT_UART1,
  31. },
  32. {
  33. .mapbase = MCF_MBAR + MCFUART_BASE3,
  34. .irq = MCFINT_VECBASE + MCFINT_UART2,
  35. },
  36. { },
  37. };
  38. static struct platform_device m520x_uart = {
  39. .name = "mcfuart",
  40. .id = 0,
  41. .dev.platform_data = m520x_uart_platform,
  42. };
  43. static struct platform_device *m520x_devices[] __initdata = {
  44. &m520x_uart,
  45. };
  46. /***************************************************************************/
  47. #define INTC0 (MCF_MBAR + MCFICM_INTC0)
  48. static void __init m520x_uart_init_line(int line, int irq)
  49. {
  50. u32 imr;
  51. u16 par;
  52. u8 par2;
  53. writeb(0x03, INTC0 + MCFINTC_ICR0 + MCFINT_UART0 + line);
  54. imr = readl(INTC0 + MCFINTC_IMRL);
  55. imr &= ~((1 << (irq - MCFINT_VECBASE)) | 1);
  56. writel(imr, INTC0 + MCFINTC_IMRL);
  57. switch (line) {
  58. case 0:
  59. par = readw(MCF_IPSBAR + MCF_GPIO_PAR_UART);
  60. par |= MCF_GPIO_PAR_UART_PAR_UTXD0 |
  61. MCF_GPIO_PAR_UART_PAR_URXD0;
  62. writew(par, MCF_IPSBAR + MCF_GPIO_PAR_UART);
  63. break;
  64. case 1:
  65. par = readw(MCF_IPSBAR + MCF_GPIO_PAR_UART);
  66. par |= MCF_GPIO_PAR_UART_PAR_UTXD1 |
  67. MCF_GPIO_PAR_UART_PAR_URXD1;
  68. writew(par, MCF_IPSBAR + MCF_GPIO_PAR_UART);
  69. break;
  70. case 2:
  71. par2 = readb(MCF_IPSBAR + MCF_GPIO_PAR_FECI2C);
  72. par2 &= ~0x0F;
  73. par2 |= MCF_GPIO_PAR_FECI2C_PAR_SCL_UTXD2 |
  74. MCF_GPIO_PAR_FECI2C_PAR_SDA_URXD2;
  75. writeb(par2, MCF_IPSBAR + MCF_GPIO_PAR_FECI2C);
  76. break;
  77. }
  78. }
  79. static void __init m520x_uarts_init(void)
  80. {
  81. const int nrlines = ARRAY_SIZE(m520x_uart_platform);
  82. int line;
  83. for (line = 0; (line < nrlines); line++)
  84. m520x_uart_init_line(line, m520x_uart_platform[line].irq);
  85. }
  86. /***************************************************************************/
  87. /*
  88. * Program the vector to be an auto-vectored.
  89. */
  90. void mcf_autovector(unsigned int vec)
  91. {
  92. /* Everything is auto-vectored on the 520x devices */
  93. }
  94. /***************************************************************************/
  95. void __init config_BSP(char *commandp, int size)
  96. {
  97. mach_reset = coldfire_reset;
  98. m520x_uarts_init();
  99. }
  100. /***************************************************************************/
  101. static int __init init_BSP(void)
  102. {
  103. platform_add_devices(m520x_devices, ARRAY_SIZE(m520x_devices));
  104. return 0;
  105. }
  106. arch_initcall(init_BSP);
  107. /***************************************************************************/