config.c 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202
  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/io.h>
  16. #include <asm/machdep.h>
  17. #include <asm/coldfire.h>
  18. #include <asm/mcfsim.h>
  19. #include <asm/mcfuart.h>
  20. /***************************************************************************/
  21. static struct mcf_platform_uart m527x_uart_platform[] = {
  22. {
  23. .mapbase = MCF_MBAR + MCFUART_BASE1,
  24. .irq = MCFINT_VECBASE + MCFINT_UART0,
  25. },
  26. {
  27. .mapbase = MCF_MBAR + MCFUART_BASE2,
  28. .irq = MCFINT_VECBASE + MCFINT_UART1,
  29. },
  30. {
  31. .mapbase = MCF_MBAR + MCFUART_BASE3,
  32. .irq = MCFINT_VECBASE + MCFINT_UART2,
  33. },
  34. { },
  35. };
  36. static struct platform_device m527x_uart = {
  37. .name = "mcfuart",
  38. .id = 0,
  39. .dev.platform_data = m527x_uart_platform,
  40. };
  41. static struct resource m527x_fec0_resources[] = {
  42. {
  43. .start = MCF_MBAR + 0x1000,
  44. .end = MCF_MBAR + 0x1000 + 0x7ff,
  45. .flags = IORESOURCE_MEM,
  46. },
  47. {
  48. .start = 64 + 23,
  49. .end = 64 + 23,
  50. .flags = IORESOURCE_IRQ,
  51. },
  52. {
  53. .start = 64 + 27,
  54. .end = 64 + 27,
  55. .flags = IORESOURCE_IRQ,
  56. },
  57. {
  58. .start = 64 + 29,
  59. .end = 64 + 29,
  60. .flags = IORESOURCE_IRQ,
  61. },
  62. };
  63. static struct resource m527x_fec1_resources[] = {
  64. {
  65. .start = MCF_MBAR + 0x1800,
  66. .end = MCF_MBAR + 0x1800 + 0x7ff,
  67. .flags = IORESOURCE_MEM,
  68. },
  69. {
  70. .start = 128 + 23,
  71. .end = 128 + 23,
  72. .flags = IORESOURCE_IRQ,
  73. },
  74. {
  75. .start = 128 + 27,
  76. .end = 128 + 27,
  77. .flags = IORESOURCE_IRQ,
  78. },
  79. {
  80. .start = 128 + 29,
  81. .end = 128 + 29,
  82. .flags = IORESOURCE_IRQ,
  83. },
  84. };
  85. static struct platform_device m527x_fec[] = {
  86. {
  87. .name = "fec",
  88. .id = 0,
  89. .num_resources = ARRAY_SIZE(m527x_fec0_resources),
  90. .resource = m527x_fec0_resources,
  91. },
  92. {
  93. .name = "fec",
  94. .id = 1,
  95. .num_resources = ARRAY_SIZE(m527x_fec1_resources),
  96. .resource = m527x_fec1_resources,
  97. },
  98. };
  99. static struct platform_device *m527x_devices[] __initdata = {
  100. &m527x_uart,
  101. &m527x_fec[0],
  102. #ifdef CONFIG_FEC2
  103. &m527x_fec[1],
  104. #endif
  105. };
  106. /***************************************************************************/
  107. static void __init m527x_uart_init_line(int line, int irq)
  108. {
  109. u16 sepmask;
  110. if ((line < 0) || (line > 2))
  111. return;
  112. /*
  113. * External Pin Mask Setting & Enable External Pin for Interface
  114. */
  115. sepmask = readw(MCF_IPSBAR + MCF_GPIO_PAR_UART);
  116. if (line == 0)
  117. sepmask |= UART0_ENABLE_MASK;
  118. else if (line == 1)
  119. sepmask |= UART1_ENABLE_MASK;
  120. else if (line == 2)
  121. sepmask |= UART2_ENABLE_MASK;
  122. writew(sepmask, MCF_IPSBAR + MCF_GPIO_PAR_UART);
  123. }
  124. static void __init m527x_uarts_init(void)
  125. {
  126. const int nrlines = ARRAY_SIZE(m527x_uart_platform);
  127. int line;
  128. for (line = 0; (line < nrlines); line++)
  129. m527x_uart_init_line(line, m527x_uart_platform[line].irq);
  130. }
  131. /***************************************************************************/
  132. static void __init m527x_fec_init(void)
  133. {
  134. u16 par;
  135. u8 v;
  136. /* Set multi-function pins to ethernet mode for fec0 */
  137. #if defined(CONFIG_M5271)
  138. v = readb(MCF_IPSBAR + 0x100047);
  139. writeb(v | 0xf0, MCF_IPSBAR + 0x100047);
  140. #else
  141. par = readw(MCF_IPSBAR + 0x100082);
  142. writew(par | 0xf00, MCF_IPSBAR + 0x100082);
  143. v = readb(MCF_IPSBAR + 0x100078);
  144. writeb(v | 0xc0, MCF_IPSBAR + 0x100078);
  145. #endif
  146. #ifdef CONFIG_FEC2
  147. /* Set multi-function pins to ethernet mode for fec1 */
  148. par = readw(MCF_IPSBAR + 0x100082);
  149. writew(par | 0xa0, MCF_IPSBAR + 0x100082);
  150. v = readb(MCF_IPSBAR + 0x100079);
  151. writeb(v | 0xc0, MCF_IPSBAR + 0x100079);
  152. #endif
  153. }
  154. /***************************************************************************/
  155. static void m527x_cpu_reset(void)
  156. {
  157. local_irq_disable();
  158. __raw_writeb(MCF_RCR_SWRESET, MCF_IPSBAR + MCF_RCR);
  159. }
  160. /***************************************************************************/
  161. void __init config_BSP(char *commandp, int size)
  162. {
  163. mach_reset = m527x_cpu_reset;
  164. m527x_uarts_init();
  165. m527x_fec_init();
  166. }
  167. /***************************************************************************/
  168. static int __init init_BSP(void)
  169. {
  170. platform_add_devices(m527x_devices, ARRAY_SIZE(m527x_devices));
  171. return 0;
  172. }
  173. arch_initcall(init_BSP);
  174. /***************************************************************************/