config.c 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251
  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. #define INTC0 (MCF_MBAR + MCFICM_INTC0)
  108. static void __init m527x_uart_init_line(int line, int irq)
  109. {
  110. u16 sepmask;
  111. u32 imr;
  112. if ((line < 0) || (line > 2))
  113. return;
  114. /* level 6, line based priority */
  115. writeb(0x30+line, INTC0 + MCFINTC_ICR0 + MCFINT_UART0 + line);
  116. imr = readl(INTC0 + MCFINTC_IMRL);
  117. imr &= ~((1 << (irq - MCFINT_VECBASE)) | 1);
  118. writel(imr, INTC0 + MCFINTC_IMRL);
  119. /*
  120. * External Pin Mask Setting & Enable External Pin for Interface
  121. */
  122. sepmask = readw(MCF_IPSBAR + MCF_GPIO_PAR_UART);
  123. if (line == 0)
  124. sepmask |= UART0_ENABLE_MASK;
  125. else if (line == 1)
  126. sepmask |= UART1_ENABLE_MASK;
  127. else if (line == 2)
  128. sepmask |= UART2_ENABLE_MASK;
  129. writew(sepmask, MCF_IPSBAR + MCF_GPIO_PAR_UART);
  130. }
  131. static void __init m527x_uarts_init(void)
  132. {
  133. const int nrlines = ARRAY_SIZE(m527x_uart_platform);
  134. int line;
  135. for (line = 0; (line < nrlines); line++)
  136. m527x_uart_init_line(line, m527x_uart_platform[line].irq);
  137. }
  138. /***************************************************************************/
  139. static void __init m527x_fec_irq_init(int nr)
  140. {
  141. unsigned long base;
  142. u32 imr;
  143. base = MCF_IPSBAR + (nr ? MCFICM_INTC1 : MCFICM_INTC0);
  144. writeb(0x28, base + MCFINTC_ICR0 + 23);
  145. writeb(0x27, base + MCFINTC_ICR0 + 27);
  146. writeb(0x26, base + MCFINTC_ICR0 + 29);
  147. imr = readl(base + MCFINTC_IMRH);
  148. imr &= ~0xf;
  149. writel(imr, base + MCFINTC_IMRH);
  150. imr = readl(base + MCFINTC_IMRL);
  151. imr &= ~0xff800001;
  152. writel(imr, base + MCFINTC_IMRL);
  153. }
  154. static void __init m527x_fec_init(void)
  155. {
  156. u16 par;
  157. u8 v;
  158. m527x_fec_irq_init(0);
  159. /* Set multi-function pins to ethernet mode for fec0 */
  160. #if defined(CONFIG_M5271)
  161. v = readb(MCF_IPSBAR + 0x100047);
  162. writeb(v | 0xf0, MCF_IPSBAR + 0x100047);
  163. #else
  164. par = readw(MCF_IPSBAR + 0x100082);
  165. writew(par | 0xf00, MCF_IPSBAR + 0x100082);
  166. v = readb(MCF_IPSBAR + 0x100078);
  167. writeb(v | 0xc0, MCF_IPSBAR + 0x100078);
  168. #endif
  169. #ifdef CONFIG_FEC2
  170. m527x_fec_irq_init(1);
  171. /* Set multi-function pins to ethernet mode for fec1 */
  172. par = readw(MCF_IPSBAR + 0x100082);
  173. writew(par | 0xa0, MCF_IPSBAR + 0x100082);
  174. v = readb(MCF_IPSBAR + 0x100079);
  175. writeb(v | 0xc0, MCF_IPSBAR + 0x100079);
  176. #endif
  177. }
  178. /***************************************************************************/
  179. void mcf_disableall(void)
  180. {
  181. *((volatile unsigned long *) (MCF_IPSBAR + MCFICM_INTC0 + MCFINTC_IMRH)) = 0xffffffff;
  182. *((volatile unsigned long *) (MCF_IPSBAR + MCFICM_INTC0 + MCFINTC_IMRL)) = 0xffffffff;
  183. }
  184. /***************************************************************************/
  185. void mcf_autovector(unsigned int vec)
  186. {
  187. /* Everything is auto-vectored on the 5272 */
  188. }
  189. /***************************************************************************/
  190. static void m527x_cpu_reset(void)
  191. {
  192. local_irq_disable();
  193. __raw_writeb(MCF_RCR_SWRESET, MCF_IPSBAR + MCF_RCR);
  194. }
  195. /***************************************************************************/
  196. void __init config_BSP(char *commandp, int size)
  197. {
  198. mcf_disableall();
  199. mach_reset = m527x_cpu_reset;
  200. m527x_uarts_init();
  201. m527x_fec_init();
  202. }
  203. /***************************************************************************/
  204. static int __init init_BSP(void)
  205. {
  206. platform_add_devices(m527x_devices, ARRAY_SIZE(m527x_devices));
  207. return 0;
  208. }
  209. arch_initcall(init_BSP);
  210. /***************************************************************************/