config.c 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183
  1. /***************************************************************************/
  2. /*
  3. * linux/arch/m68knommu/platform/528x/config.c
  4. *
  5. * Sub-architcture dependant initialization code for the Freescale
  6. * 5280, 5281 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/platform_device.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. static struct mcf_platform_uart m528x_uart_platform[] = {
  23. {
  24. .mapbase = MCF_MBAR + MCFUART_BASE1,
  25. .irq = MCFINT_VECBASE + MCFINT_UART0,
  26. },
  27. {
  28. .mapbase = MCF_MBAR + MCFUART_BASE2,
  29. .irq = MCFINT_VECBASE + MCFINT_UART0 + 1,
  30. },
  31. {
  32. .mapbase = MCF_MBAR + MCFUART_BASE3,
  33. .irq = MCFINT_VECBASE + MCFINT_UART0 + 2,
  34. },
  35. { },
  36. };
  37. static struct platform_device m528x_uart = {
  38. .name = "mcfuart",
  39. .id = 0,
  40. .dev.platform_data = m528x_uart_platform,
  41. };
  42. static struct resource m528x_fec_resources[] = {
  43. {
  44. .start = MCF_MBAR + 0x1000,
  45. .end = MCF_MBAR + 0x1000 + 0x7ff,
  46. .flags = IORESOURCE_MEM,
  47. },
  48. {
  49. .start = 64 + 23,
  50. .end = 64 + 23,
  51. .flags = IORESOURCE_IRQ,
  52. },
  53. {
  54. .start = 64 + 27,
  55. .end = 64 + 27,
  56. .flags = IORESOURCE_IRQ,
  57. },
  58. {
  59. .start = 64 + 29,
  60. .end = 64 + 29,
  61. .flags = IORESOURCE_IRQ,
  62. },
  63. };
  64. static struct platform_device m528x_fec = {
  65. .name = "fec",
  66. .id = 0,
  67. .num_resources = ARRAY_SIZE(m528x_fec_resources),
  68. .resource = m528x_fec_resources,
  69. };
  70. static struct platform_device *m528x_devices[] __initdata = {
  71. &m528x_uart,
  72. &m528x_fec,
  73. };
  74. /***************************************************************************/
  75. static void __init m528x_uart_init_line(int line, int irq)
  76. {
  77. u8 port;
  78. if ((line < 0) || (line > 2))
  79. return;
  80. /* make sure PUAPAR is set for UART0 and UART1 */
  81. if (line < 2) {
  82. port = readb(MCF_MBAR + MCF5282_GPIO_PUAPAR);
  83. port |= (0x03 << (line * 2));
  84. writeb(port, MCF_MBAR + MCF5282_GPIO_PUAPAR);
  85. }
  86. }
  87. static void __init m528x_uarts_init(void)
  88. {
  89. const int nrlines = ARRAY_SIZE(m528x_uart_platform);
  90. int line;
  91. for (line = 0; (line < nrlines); line++)
  92. m528x_uart_init_line(line, m528x_uart_platform[line].irq);
  93. }
  94. /***************************************************************************/
  95. static void __init m528x_fec_init(void)
  96. {
  97. u16 v16;
  98. /* Set multi-function pins to ethernet mode for fec0 */
  99. v16 = readw(MCF_IPSBAR + 0x100056);
  100. writew(v16 | 0xf00, MCF_IPSBAR + 0x100056);
  101. writeb(0xc0, MCF_IPSBAR + 0x100058);
  102. }
  103. /***************************************************************************/
  104. static void m528x_cpu_reset(void)
  105. {
  106. local_irq_disable();
  107. __raw_writeb(MCF_RCR_SWRESET, MCF_IPSBAR + MCF_RCR);
  108. }
  109. /***************************************************************************/
  110. #ifdef CONFIG_WILDFIRE
  111. void wildfire_halt(void)
  112. {
  113. writeb(0, 0x30000007);
  114. writeb(0x2, 0x30000007);
  115. }
  116. #endif
  117. #ifdef CONFIG_WILDFIREMOD
  118. void wildfiremod_halt(void)
  119. {
  120. printk(KERN_INFO "WildFireMod hibernating...\n");
  121. /* Set portE.5 to Digital IO */
  122. MCF5282_GPIO_PEPAR &= ~(1 << (5 * 2));
  123. /* Make portE.5 an output */
  124. MCF5282_GPIO_DDRE |= (1 << 5);
  125. /* Now toggle portE.5 from low to high */
  126. MCF5282_GPIO_PORTE &= ~(1 << 5);
  127. MCF5282_GPIO_PORTE |= (1 << 5);
  128. printk(KERN_EMERG "Failed to hibernate. Halting!\n");
  129. }
  130. #endif
  131. void __init config_BSP(char *commandp, int size)
  132. {
  133. #ifdef CONFIG_WILDFIRE
  134. mach_halt = wildfire_halt;
  135. #endif
  136. #ifdef CONFIG_WILDFIREMOD
  137. mach_halt = wildfiremod_halt;
  138. #endif
  139. }
  140. /***************************************************************************/
  141. static int __init init_BSP(void)
  142. {
  143. mach_reset = m528x_cpu_reset;
  144. m528x_uarts_init();
  145. m528x_fec_init();
  146. platform_add_devices(m528x_devices, ARRAY_SIZE(m528x_devices));
  147. return 0;
  148. }
  149. arch_initcall(init_BSP);
  150. /***************************************************************************/