config.c 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230
  1. /***************************************************************************/
  2. /*
  3. * linux/arch/m68knommu/platform/528x/config.c
  4. *
  5. * Sub-architcture dependant initialization code for the Motorola
  6. * 5280 and 5282 CPUs.
  7. *
  8. * Copyright (C) 1999-2003, Greg Ungerer (gerg@snapgear.com)
  9. * Copyright (C) 2001-2003, 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/platform_device.h>
  17. #include <linux/spi/spi.h>
  18. #include <linux/spi/flash.h>
  19. #include <linux/io.h>
  20. #include <asm/machdep.h>
  21. #include <asm/coldfire.h>
  22. #include <asm/mcfsim.h>
  23. #include <asm/mcfuart.h>
  24. #ifdef CONFIG_MTD_PARTITIONS
  25. #include <linux/mtd/partitions.h>
  26. #endif
  27. /***************************************************************************/
  28. static struct mcf_platform_uart m528x_uart_platform[] = {
  29. {
  30. .mapbase = MCF_MBAR + MCFUART_BASE1,
  31. .irq = MCFINT_VECBASE + MCFINT_UART0,
  32. },
  33. {
  34. .mapbase = MCF_MBAR + MCFUART_BASE2,
  35. .irq = MCFINT_VECBASE + MCFINT_UART0 + 1,
  36. },
  37. {
  38. .mapbase = MCF_MBAR + MCFUART_BASE3,
  39. .irq = MCFINT_VECBASE + MCFINT_UART0 + 2,
  40. },
  41. { },
  42. };
  43. static struct platform_device m528x_uart = {
  44. .name = "mcfuart",
  45. .id = 0,
  46. .dev.platform_data = m528x_uart_platform,
  47. };
  48. static struct resource m528x_fec_resources[] = {
  49. {
  50. .start = MCF_MBAR + 0x1000,
  51. .end = MCF_MBAR + 0x1000 + 0x7ff,
  52. .flags = IORESOURCE_MEM,
  53. },
  54. {
  55. .start = 64 + 23,
  56. .end = 64 + 23,
  57. .flags = IORESOURCE_IRQ,
  58. },
  59. {
  60. .start = 64 + 27,
  61. .end = 64 + 27,
  62. .flags = IORESOURCE_IRQ,
  63. },
  64. {
  65. .start = 64 + 29,
  66. .end = 64 + 29,
  67. .flags = IORESOURCE_IRQ,
  68. },
  69. };
  70. static struct platform_device m528x_fec = {
  71. .name = "fec",
  72. .id = 0,
  73. .num_resources = ARRAY_SIZE(m528x_fec_resources),
  74. .resource = m528x_fec_resources,
  75. };
  76. static struct platform_device *m528x_devices[] __initdata = {
  77. &m528x_uart,
  78. &m528x_fec,
  79. };
  80. /***************************************************************************/
  81. #define INTC0 (MCF_MBAR + MCFICM_INTC0)
  82. static void __init m528x_uart_init_line(int line, int irq)
  83. {
  84. u8 port;
  85. u32 imr;
  86. if ((line < 0) || (line > 2))
  87. return;
  88. /* level 6, line based priority */
  89. writeb(0x30+line, INTC0 + MCFINTC_ICR0 + MCFINT_UART0 + line);
  90. imr = readl(INTC0 + MCFINTC_IMRL);
  91. imr &= ~((1 << (irq - MCFINT_VECBASE)) | 1);
  92. writel(imr, INTC0 + MCFINTC_IMRL);
  93. /* make sure PUAPAR is set for UART0 and UART1 */
  94. if (line < 2) {
  95. port = readb(MCF_MBAR + MCF5282_GPIO_PUAPAR);
  96. port |= (0x03 << (line * 2));
  97. writeb(port, MCF_MBAR + MCF5282_GPIO_PUAPAR);
  98. }
  99. }
  100. static void __init m528x_uarts_init(void)
  101. {
  102. const int nrlines = ARRAY_SIZE(m528x_uart_platform);
  103. int line;
  104. for (line = 0; (line < nrlines); line++)
  105. m528x_uart_init_line(line, m528x_uart_platform[line].irq);
  106. }
  107. /***************************************************************************/
  108. static void __init m528x_fec_init(void)
  109. {
  110. u32 imr;
  111. u16 v16;
  112. /* Unmask FEC interrupts at ColdFire interrupt controller */
  113. writeb(0x28, MCF_IPSBAR + MCFICM_INTC0 + MCFINTC_ICR0 + 23);
  114. writeb(0x27, MCF_IPSBAR + MCFICM_INTC0 + MCFINTC_ICR0 + 27);
  115. writeb(0x26, MCF_IPSBAR + MCFICM_INTC0 + MCFINTC_ICR0 + 29);
  116. imr = readl(MCF_IPSBAR + MCFICM_INTC0 + MCFINTC_IMRH);
  117. imr &= ~0xf;
  118. writel(imr, MCF_IPSBAR + MCFICM_INTC0 + MCFINTC_IMRH);
  119. imr = readl(MCF_IPSBAR + MCFICM_INTC0 + MCFINTC_IMRL);
  120. imr &= ~0xff800001;
  121. writel(imr, MCF_IPSBAR + MCFICM_INTC0 + MCFINTC_IMRL);
  122. /* Set multi-function pins to ethernet mode for fec0 */
  123. v16 = readw(MCF_IPSBAR + 0x100056);
  124. writew(v16 | 0xf00, MCF_IPSBAR + 0x100056);
  125. writeb(0xc0, MCF_IPSBAR + 0x100058);
  126. }
  127. /***************************************************************************/
  128. void mcf_disableall(void)
  129. {
  130. *((volatile unsigned long *) (MCF_IPSBAR + MCFICM_INTC0 + MCFINTC_IMRH)) = 0xffffffff;
  131. *((volatile unsigned long *) (MCF_IPSBAR + MCFICM_INTC0 + MCFINTC_IMRL)) = 0xffffffff;
  132. }
  133. /***************************************************************************/
  134. void mcf_autovector(unsigned int vec)
  135. {
  136. /* Everything is auto-vectored on the 5272 */
  137. }
  138. /***************************************************************************/
  139. static void m528x_cpu_reset(void)
  140. {
  141. local_irq_disable();
  142. __raw_writeb(MCF_RCR_SWRESET, MCF_IPSBAR + MCF_RCR);
  143. }
  144. /***************************************************************************/
  145. #ifdef CONFIG_WILDFIRE
  146. void wildfire_halt(void)
  147. {
  148. writeb(0, 0x30000007);
  149. writeb(0x2, 0x30000007);
  150. }
  151. #endif
  152. #ifdef CONFIG_WILDFIREMOD
  153. void wildfiremod_halt(void)
  154. {
  155. printk(KERN_INFO "WildFireMod hibernating...\n");
  156. /* Set portE.5 to Digital IO */
  157. MCF5282_GPIO_PEPAR &= ~(1 << (5 * 2));
  158. /* Make portE.5 an output */
  159. MCF5282_GPIO_DDRE |= (1 << 5);
  160. /* Now toggle portE.5 from low to high */
  161. MCF5282_GPIO_PORTE &= ~(1 << 5);
  162. MCF5282_GPIO_PORTE |= (1 << 5);
  163. printk(KERN_EMERG "Failed to hibernate. Halting!\n");
  164. }
  165. #endif
  166. void __init config_BSP(char *commandp, int size)
  167. {
  168. mcf_disableall();
  169. #ifdef CONFIG_WILDFIRE
  170. mach_halt = wildfire_halt;
  171. #endif
  172. #ifdef CONFIG_WILDFIREMOD
  173. mach_halt = wildfiremod_halt;
  174. #endif
  175. }
  176. /***************************************************************************/
  177. static int __init init_BSP(void)
  178. {
  179. mach_reset = m528x_cpu_reset;
  180. m528x_uarts_init();
  181. m528x_fec_init();
  182. platform_add_devices(m528x_devices, ARRAY_SIZE(m528x_devices));
  183. return 0;
  184. }
  185. arch_initcall(init_BSP);
  186. /***************************************************************************/