config.c 5.3 KB

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