config.c 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248
  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 resource m527x_fec0_resources[] = {
  45. {
  46. .start = MCF_MBAR + 0x1000,
  47. .end = MCF_MBAR + 0x1000 + 0x7ff,
  48. .flags = IORESOURCE_MEM,
  49. },
  50. {
  51. .start = 64 + 23,
  52. .end = 64 + 23,
  53. .flags = IORESOURCE_IRQ,
  54. },
  55. {
  56. .start = 64 + 27,
  57. .end = 64 + 27,
  58. .flags = IORESOURCE_IRQ,
  59. },
  60. {
  61. .start = 64 + 29,
  62. .end = 64 + 29,
  63. .flags = IORESOURCE_IRQ,
  64. },
  65. };
  66. static struct resource m527x_fec1_resources[] = {
  67. {
  68. .start = MCF_MBAR + 0x1800,
  69. .end = MCF_MBAR + 0x1800 + 0x7ff,
  70. .flags = IORESOURCE_MEM,
  71. },
  72. {
  73. .start = 128 + 23,
  74. .end = 128 + 23,
  75. .flags = IORESOURCE_IRQ,
  76. },
  77. {
  78. .start = 128 + 27,
  79. .end = 128 + 27,
  80. .flags = IORESOURCE_IRQ,
  81. },
  82. {
  83. .start = 128 + 29,
  84. .end = 128 + 29,
  85. .flags = IORESOURCE_IRQ,
  86. },
  87. };
  88. static struct platform_device m527x_fec[] = {
  89. {
  90. .name = "fec",
  91. .id = 0,
  92. .num_resources = ARRAY_SIZE(m527x_fec0_resources),
  93. .resource = m527x_fec0_resources,
  94. },
  95. {
  96. .name = "fec",
  97. .id = 1,
  98. .num_resources = ARRAY_SIZE(m527x_fec1_resources),
  99. .resource = m527x_fec1_resources,
  100. },
  101. };
  102. static struct platform_device *m527x_devices[] __initdata = {
  103. &m527x_uart,
  104. &m527x_fec[0],
  105. #ifdef CONFIG_FEC2
  106. &m527x_fec[1],
  107. #endif
  108. };
  109. /***************************************************************************/
  110. #define INTC0 (MCF_MBAR + MCFICM_INTC0)
  111. static void __init m527x_uart_init_line(int line, int irq)
  112. {
  113. u16 sepmask;
  114. u32 imr;
  115. if ((line < 0) || (line > 2))
  116. return;
  117. /* level 6, line based priority */
  118. writeb(0x30+line, INTC0 + MCFINTC_ICR0 + MCFINT_UART0 + line);
  119. imr = readl(INTC0 + MCFINTC_IMRL);
  120. imr &= ~((1 << (irq - MCFINT_VECBASE)) | 1);
  121. writel(imr, INTC0 + MCFINTC_IMRL);
  122. /*
  123. * External Pin Mask Setting & Enable External Pin for Interface
  124. */
  125. sepmask = readw(MCF_IPSBAR + MCF_GPIO_PAR_UART);
  126. if (line == 0)
  127. sepmask |= UART0_ENABLE_MASK;
  128. else if (line == 1)
  129. sepmask |= UART1_ENABLE_MASK;
  130. else if (line == 2)
  131. sepmask |= UART2_ENABLE_MASK;
  132. writew(sepmask, MCF_IPSBAR + MCF_GPIO_PAR_UART);
  133. }
  134. static void __init m527x_uarts_init(void)
  135. {
  136. const int nrlines = ARRAY_SIZE(m527x_uart_platform);
  137. int line;
  138. for (line = 0; (line < nrlines); line++)
  139. m527x_uart_init_line(line, m527x_uart_platform[line].irq);
  140. }
  141. /***************************************************************************/
  142. static void __init m527x_fec_irq_init(int nr)
  143. {
  144. unsigned long base;
  145. u32 imr;
  146. base = MCF_IPSBAR + (nr ? MCFICM_INTC1 : MCFICM_INTC0);
  147. writeb(0x28, base + MCFINTC_ICR0 + 23);
  148. writeb(0x27, base + MCFINTC_ICR0 + 27);
  149. writeb(0x26, base + MCFINTC_ICR0 + 29);
  150. imr = readl(base + MCFINTC_IMRH);
  151. imr &= ~0xf;
  152. writel(imr, base + MCFINTC_IMRH);
  153. imr = readl(base + MCFINTC_IMRL);
  154. imr &= ~0xff800001;
  155. writel(imr, base + MCFINTC_IMRL);
  156. }
  157. static void __init m527x_fec_init(void)
  158. {
  159. u16 par;
  160. u8 v;
  161. m527x_fec_irq_init(0);
  162. /* Set multi-function pins to ethernet mode for fec0 */
  163. #if defined(CONFIG_M5271)
  164. v = readb(MCF_IPSBAR + 0x100047);
  165. writeb(v | 0xf0, MCF_IPSBAR + 0x100047);
  166. #else
  167. par = readw(MCF_IPSBAR + 0x100082);
  168. writew(par | 0xf00, MCF_IPSBAR + 0x100082);
  169. v = readb(MCF_IPSBAR + 0x100078);
  170. writeb(v | 0xc0, MCF_IPSBAR + 0x100078);
  171. #endif
  172. #ifdef CONFIG_FEC2
  173. m527x_fec_irq_init(1);
  174. /* Set multi-function pins to ethernet mode for fec1 */
  175. par = readw(MCF_IPSBAR + 0x100082);
  176. writew(par | 0xa0, MCF_IPSBAR + 0x100082);
  177. v = readb(MCF_IPSBAR + 0x100079);
  178. writeb(v | 0xc0, MCF_IPSBAR + 0x100079);
  179. #endif
  180. }
  181. /***************************************************************************/
  182. void mcf_disableall(void)
  183. {
  184. *((volatile unsigned long *) (MCF_IPSBAR + MCFICM_INTC0 + MCFINTC_IMRH)) = 0xffffffff;
  185. *((volatile unsigned long *) (MCF_IPSBAR + MCFICM_INTC0 + MCFINTC_IMRL)) = 0xffffffff;
  186. }
  187. /***************************************************************************/
  188. void mcf_autovector(unsigned int vec)
  189. {
  190. /* Everything is auto-vectored on the 5272 */
  191. }
  192. /***************************************************************************/
  193. void __init config_BSP(char *commandp, int size)
  194. {
  195. mcf_disableall();
  196. mach_reset = coldfire_reset;
  197. m527x_uarts_init();
  198. m527x_fec_init();
  199. }
  200. /***************************************************************************/
  201. static int __init init_BSP(void)
  202. {
  203. platform_add_devices(m527x_devices, ARRAY_SIZE(m527x_devices));
  204. return 0;
  205. }
  206. arch_initcall(init_BSP);
  207. /***************************************************************************/