config.c 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212
  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/interrupt.h>
  13. #include <linux/io.h>
  14. #include <asm/machdep.h>
  15. #include <asm/coldfire.h>
  16. #include <asm/mcfsim.h>
  17. #include <asm/mcfuart.h>
  18. /***************************************************************************/
  19. void coldfire_reset(void);
  20. extern unsigned int mcf_timervector;
  21. extern unsigned int mcf_profilevector;
  22. extern unsigned int mcf_timerlevel;
  23. /***************************************************************************/
  24. /*
  25. * Some platforms need software versions of the GPIO data registers.
  26. */
  27. unsigned short ppdata;
  28. unsigned char ledbank = 0xff;
  29. /***************************************************************************/
  30. static struct mcf_platform_uart m5272_uart_platform[] = {
  31. {
  32. .mapbase = MCF_MBAR + MCFUART_BASE1,
  33. .irq = 73,
  34. },
  35. {
  36. .mapbase = MCF_MBAR + MCFUART_BASE2,
  37. .irq = 74,
  38. },
  39. { },
  40. };
  41. static struct platform_device m5272_uart = {
  42. .name = "mcfuart",
  43. .id = 0,
  44. .dev.platform_data = m5272_uart_platform,
  45. };
  46. static struct resource m5272_fec_resources[] = {
  47. {
  48. .start = MCF_MBAR + 0x840,
  49. .end = MCF_MBAR + 0x840 + 0x1cf,
  50. .flags = IORESOURCE_MEM,
  51. },
  52. {
  53. .start = 86,
  54. .end = 86,
  55. .flags = IORESOURCE_IRQ,
  56. },
  57. {
  58. .start = 87,
  59. .end = 87,
  60. .flags = IORESOURCE_IRQ,
  61. },
  62. {
  63. .start = 88,
  64. .end = 88,
  65. .flags = IORESOURCE_IRQ,
  66. },
  67. };
  68. static struct platform_device m5272_fec = {
  69. .name = "fec",
  70. .id = 0,
  71. .num_resources = ARRAY_SIZE(m5272_fec_resources),
  72. .resource = m5272_fec_resources,
  73. };
  74. static struct platform_device *m5272_devices[] __initdata = {
  75. &m5272_uart,
  76. &m5272_fec,
  77. };
  78. /***************************************************************************/
  79. static void __init m5272_uart_init_line(int line, int irq)
  80. {
  81. u32 v;
  82. if ((line >= 0) && (line < 2)) {
  83. v = (line) ? 0x0e000000 : 0xe0000000;
  84. writel(v, MCF_MBAR + MCFSIM_ICR2);
  85. /* Enable the output lines for the serial ports */
  86. v = readl(MCF_MBAR + MCFSIM_PBCNT);
  87. v = (v & ~0x000000ff) | 0x00000055;
  88. writel(v, MCF_MBAR + MCFSIM_PBCNT);
  89. v = readl(MCF_MBAR + MCFSIM_PDCNT);
  90. v = (v & ~0x000003fc) | 0x000002a8;
  91. writel(v, MCF_MBAR + MCFSIM_PDCNT);
  92. }
  93. }
  94. static void __init m5272_uarts_init(void)
  95. {
  96. const int nrlines = ARRAY_SIZE(m5272_uart_platform);
  97. int line;
  98. for (line = 0; (line < nrlines); line++)
  99. m5272_uart_init_line(line, m5272_uart_platform[line].irq);
  100. }
  101. /***************************************************************************/
  102. static void __init m5272_fec_init(void)
  103. {
  104. u32 imr;
  105. /* Unmask FEC interrupts at ColdFire interrupt controller */
  106. imr = readl(MCF_MBAR + MCFSIM_ICR3);
  107. imr = (imr & ~0x00000fff) | 0x00000ddd;
  108. writel(imr, MCF_MBAR + MCFSIM_ICR3);
  109. imr = readl(MCF_MBAR + MCFSIM_ICR1);
  110. imr = (imr & ~0x0f000000) | 0x0d000000;
  111. writel(imr, MCF_MBAR + MCFSIM_ICR1);
  112. }
  113. /***************************************************************************/
  114. void mcf_disableall(void)
  115. {
  116. volatile unsigned long *icrp;
  117. icrp = (volatile unsigned long *) (MCF_MBAR + MCFSIM_ICR1);
  118. icrp[0] = 0x88888888;
  119. icrp[1] = 0x88888888;
  120. icrp[2] = 0x88888888;
  121. icrp[3] = 0x88888888;
  122. }
  123. /***************************************************************************/
  124. void mcf_autovector(unsigned int vec)
  125. {
  126. /* Everything is auto-vectored on the 5272 */
  127. }
  128. /***************************************************************************/
  129. void mcf_settimericr(int timer, int level)
  130. {
  131. volatile unsigned long *icrp;
  132. if ((timer >= 1 ) && (timer <= 4)) {
  133. icrp = (volatile unsigned long *) (MCF_MBAR + MCFSIM_ICR1);
  134. *icrp = (0x8 | level) << ((4 - timer) * 4);
  135. }
  136. }
  137. /***************************************************************************/
  138. void __init config_BSP(char *commandp, int size)
  139. {
  140. #if defined (CONFIG_MOD5272)
  141. volatile unsigned char *pivrp;
  142. /* Set base of device vectors to be 64 */
  143. pivrp = (volatile unsigned char *) (MCF_MBAR + MCFSIM_PIVR);
  144. *pivrp = 0x40;
  145. #endif
  146. mcf_disableall();
  147. #if defined(CONFIG_NETtel) || defined(CONFIG_SCALES)
  148. /* Copy command line from FLASH to local buffer... */
  149. memcpy(commandp, (char *) 0xf0004000, size);
  150. commandp[size-1] = 0;
  151. #elif defined(CONFIG_CANCam)
  152. /* Copy command line from FLASH to local buffer... */
  153. memcpy(commandp, (char *) 0xf0010000, size);
  154. commandp[size-1] = 0;
  155. #endif
  156. mcf_timervector = 69;
  157. mcf_profilevector = 70;
  158. mach_reset = coldfire_reset;
  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. /***************************************************************************/