config.c 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  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/io.h>
  15. #include <asm/machdep.h>
  16. #include <asm/coldfire.h>
  17. #include <asm/mcfsim.h>
  18. #include <asm/mcfuart.h>
  19. /***************************************************************************/
  20. static struct mcf_platform_uart m520x_uart_platform[] = {
  21. {
  22. .mapbase = MCF_MBAR + MCFUART_BASE1,
  23. .irq = MCFINT_VECBASE + MCFINT_UART0,
  24. },
  25. {
  26. .mapbase = MCF_MBAR + MCFUART_BASE2,
  27. .irq = MCFINT_VECBASE + MCFINT_UART1,
  28. },
  29. {
  30. .mapbase = MCF_MBAR + MCFUART_BASE3,
  31. .irq = MCFINT_VECBASE + MCFINT_UART2,
  32. },
  33. { },
  34. };
  35. static struct platform_device m520x_uart = {
  36. .name = "mcfuart",
  37. .id = 0,
  38. .dev.platform_data = m520x_uart_platform,
  39. };
  40. static struct resource m520x_fec_resources[] = {
  41. {
  42. .start = MCF_MBAR + 0x30000,
  43. .end = MCF_MBAR + 0x30000 + 0x7ff,
  44. .flags = IORESOURCE_MEM,
  45. },
  46. {
  47. .start = 64 + 36,
  48. .end = 64 + 36,
  49. .flags = IORESOURCE_IRQ,
  50. },
  51. {
  52. .start = 64 + 40,
  53. .end = 64 + 40,
  54. .flags = IORESOURCE_IRQ,
  55. },
  56. {
  57. .start = 64 + 42,
  58. .end = 64 + 42,
  59. .flags = IORESOURCE_IRQ,
  60. },
  61. };
  62. static struct platform_device m520x_fec = {
  63. .name = "fec",
  64. .id = 0,
  65. .num_resources = ARRAY_SIZE(m520x_fec_resources),
  66. .resource = m520x_fec_resources,
  67. };
  68. static struct platform_device *m520x_devices[] __initdata = {
  69. &m520x_uart,
  70. &m520x_fec,
  71. };
  72. /***************************************************************************/
  73. static void __init m520x_uart_init_line(int line, int irq)
  74. {
  75. u16 par;
  76. u8 par2;
  77. switch (line) {
  78. case 0:
  79. par = readw(MCF_IPSBAR + MCF_GPIO_PAR_UART);
  80. par |= MCF_GPIO_PAR_UART_PAR_UTXD0 |
  81. MCF_GPIO_PAR_UART_PAR_URXD0;
  82. writew(par, MCF_IPSBAR + MCF_GPIO_PAR_UART);
  83. break;
  84. case 1:
  85. par = readw(MCF_IPSBAR + MCF_GPIO_PAR_UART);
  86. par |= MCF_GPIO_PAR_UART_PAR_UTXD1 |
  87. MCF_GPIO_PAR_UART_PAR_URXD1;
  88. writew(par, MCF_IPSBAR + MCF_GPIO_PAR_UART);
  89. break;
  90. case 2:
  91. par2 = readb(MCF_IPSBAR + MCF_GPIO_PAR_FECI2C);
  92. par2 &= ~0x0F;
  93. par2 |= MCF_GPIO_PAR_FECI2C_PAR_SCL_UTXD2 |
  94. MCF_GPIO_PAR_FECI2C_PAR_SDA_URXD2;
  95. writeb(par2, MCF_IPSBAR + MCF_GPIO_PAR_FECI2C);
  96. break;
  97. }
  98. }
  99. static void __init m520x_uarts_init(void)
  100. {
  101. const int nrlines = ARRAY_SIZE(m520x_uart_platform);
  102. int line;
  103. for (line = 0; (line < nrlines); line++)
  104. m520x_uart_init_line(line, m520x_uart_platform[line].irq);
  105. }
  106. /***************************************************************************/
  107. static void __init m520x_fec_init(void)
  108. {
  109. u8 v;
  110. /* Set multi-function pins to ethernet mode */
  111. v = readb(MCF_IPSBAR + MCF_GPIO_PAR_FEC);
  112. writeb(v | 0xf0, MCF_IPSBAR + MCF_GPIO_PAR_FEC);
  113. v = readb(MCF_IPSBAR + MCF_GPIO_PAR_FECI2C);
  114. writeb(v | 0x0f, MCF_IPSBAR + MCF_GPIO_PAR_FECI2C);
  115. }
  116. /***************************************************************************/
  117. static void m520x_cpu_reset(void)
  118. {
  119. local_irq_disable();
  120. __raw_writeb(MCF_RCR_SWRESET, MCF_RCR);
  121. }
  122. /***************************************************************************/
  123. void __init config_BSP(char *commandp, int size)
  124. {
  125. mach_reset = m520x_cpu_reset;
  126. m520x_uarts_init();
  127. m520x_fec_init();
  128. }
  129. /***************************************************************************/
  130. static int __init init_BSP(void)
  131. {
  132. platform_add_devices(m520x_devices, ARRAY_SIZE(m520x_devices));
  133. return 0;
  134. }
  135. arch_initcall(init_BSP);
  136. /***************************************************************************/