config.c 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209
  1. /***************************************************************************/
  2. /*
  3. * linux/arch/m68knommu/platform/5272/config.c
  4. *
  5. * Copyright (C) 1999-2002, Greg Ungerer (gerg@snapgear.com)
  6. * Copyright (C) 2001-2002, SnapGear Inc. (www.snapgear.com)
  7. */
  8. /***************************************************************************/
  9. #include <linux/kernel.h>
  10. #include <linux/param.h>
  11. #include <linux/init.h>
  12. #include <linux/io.h>
  13. #include <asm/machdep.h>
  14. #include <asm/coldfire.h>
  15. #include <asm/mcfsim.h>
  16. #include <asm/mcfuart.h>
  17. /***************************************************************************/
  18. /*
  19. * Some platforms need software versions of the GPIO data registers.
  20. */
  21. unsigned short ppdata;
  22. unsigned char ledbank = 0xff;
  23. /***************************************************************************/
  24. static struct mcf_platform_uart m5272_uart_platform[] = {
  25. {
  26. .mapbase = MCF_MBAR + MCFUART_BASE1,
  27. .irq = 73,
  28. },
  29. {
  30. .mapbase = MCF_MBAR + MCFUART_BASE2,
  31. .irq = 74,
  32. },
  33. { },
  34. };
  35. static struct platform_device m5272_uart = {
  36. .name = "mcfuart",
  37. .id = 0,
  38. .dev.platform_data = m5272_uart_platform,
  39. };
  40. static struct resource m5272_fec_resources[] = {
  41. {
  42. .start = MCF_MBAR + 0x840,
  43. .end = MCF_MBAR + 0x840 + 0x1cf,
  44. .flags = IORESOURCE_MEM,
  45. },
  46. {
  47. .start = 86,
  48. .end = 86,
  49. .flags = IORESOURCE_IRQ,
  50. },
  51. {
  52. .start = 87,
  53. .end = 87,
  54. .flags = IORESOURCE_IRQ,
  55. },
  56. {
  57. .start = 88,
  58. .end = 88,
  59. .flags = IORESOURCE_IRQ,
  60. },
  61. };
  62. static struct platform_device m5272_fec = {
  63. .name = "fec",
  64. .id = 0,
  65. .num_resources = ARRAY_SIZE(m5272_fec_resources),
  66. .resource = m5272_fec_resources,
  67. };
  68. static struct platform_device *m5272_devices[] __initdata = {
  69. &m5272_uart,
  70. &m5272_fec,
  71. };
  72. /***************************************************************************/
  73. static void __init m5272_uart_init_line(int line, int irq)
  74. {
  75. u32 v;
  76. if ((line >= 0) && (line < 2)) {
  77. v = (line) ? 0x0e000000 : 0xe0000000;
  78. writel(v, MCF_MBAR + MCFSIM_ICR2);
  79. /* Enable the output lines for the serial ports */
  80. v = readl(MCF_MBAR + MCFSIM_PBCNT);
  81. v = (v & ~0x000000ff) | 0x00000055;
  82. writel(v, MCF_MBAR + MCFSIM_PBCNT);
  83. v = readl(MCF_MBAR + MCFSIM_PDCNT);
  84. v = (v & ~0x000003fc) | 0x000002a8;
  85. writel(v, MCF_MBAR + MCFSIM_PDCNT);
  86. }
  87. }
  88. static void __init m5272_uarts_init(void)
  89. {
  90. const int nrlines = ARRAY_SIZE(m5272_uart_platform);
  91. int line;
  92. for (line = 0; (line < nrlines); line++)
  93. m5272_uart_init_line(line, m5272_uart_platform[line].irq);
  94. }
  95. /***************************************************************************/
  96. static void __init m5272_fec_init(void)
  97. {
  98. u32 imr;
  99. /* Unmask FEC interrupts at ColdFire interrupt controller */
  100. imr = readl(MCF_MBAR + MCFSIM_ICR3);
  101. imr = (imr & ~0x00000fff) | 0x00000ddd;
  102. writel(imr, MCF_MBAR + MCFSIM_ICR3);
  103. imr = readl(MCF_MBAR + MCFSIM_ICR1);
  104. imr = (imr & ~0x0f000000) | 0x0d000000;
  105. writel(imr, MCF_MBAR + MCFSIM_ICR1);
  106. }
  107. /***************************************************************************/
  108. void mcf_disableall(void)
  109. {
  110. volatile unsigned long *icrp;
  111. icrp = (volatile unsigned long *) (MCF_MBAR + MCFSIM_ICR1);
  112. icrp[0] = 0x88888888;
  113. icrp[1] = 0x88888888;
  114. icrp[2] = 0x88888888;
  115. icrp[3] = 0x88888888;
  116. }
  117. /***************************************************************************/
  118. static void __init m5272_timers_init(void)
  119. {
  120. /* Timer1 @ level6 is always used as system timer */
  121. writel((0x8 | 0x6) << ((4 - 1) * 4), MCF_MBAR + MCFSIM_ICR1);
  122. #ifdef CONFIG_HIGHPROFILE
  123. /* Timer2 @ level7 is to be used as a high speed profile timer */
  124. writel((0x8 | 0x7) << ((4 - 2) * 4), MCF_MBAR + MCFSIM_ICR1);
  125. #endif
  126. }
  127. /***************************************************************************/
  128. static void m5272_cpu_reset(void)
  129. {
  130. local_irq_disable();
  131. /* Set watchdog to reset, and enabled */
  132. __raw_writew(0, MCF_MBAR + MCFSIM_WIRR);
  133. __raw_writew(1, MCF_MBAR + MCFSIM_WRRR);
  134. __raw_writew(0, MCF_MBAR + MCFSIM_WCR);
  135. for (;;)
  136. /* wait for watchdog to timeout */;
  137. }
  138. /***************************************************************************/
  139. void __init config_BSP(char *commandp, int size)
  140. {
  141. #if defined (CONFIG_MOD5272)
  142. volatile unsigned char *pivrp;
  143. /* Set base of device vectors to be 64 */
  144. pivrp = (volatile unsigned char *) (MCF_MBAR + MCFSIM_PIVR);
  145. *pivrp = 0x40;
  146. #endif
  147. mcf_disableall();
  148. #if defined(CONFIG_NETtel) || defined(CONFIG_SCALES)
  149. /* Copy command line from FLASH to local buffer... */
  150. memcpy(commandp, (char *) 0xf0004000, size);
  151. commandp[size-1] = 0;
  152. #elif defined(CONFIG_CANCam)
  153. /* Copy command line from FLASH to local buffer... */
  154. memcpy(commandp, (char *) 0xf0010000, size);
  155. commandp[size-1] = 0;
  156. #endif
  157. mach_reset = m5272_cpu_reset;
  158. m5272_timers_init();
  159. }
  160. /***************************************************************************/
  161. static int __init init_BSP(void)
  162. {
  163. m5272_uarts_init();
  164. m5272_fec_init();
  165. platform_add_devices(m5272_devices, ARRAY_SIZE(m5272_devices));
  166. return 0;
  167. }
  168. arch_initcall(init_BSP);
  169. /***************************************************************************/