config.c 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176
  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 <linux/phy.h>
  14. #include <linux/phy_fixed.h>
  15. #include <asm/machdep.h>
  16. #include <asm/coldfire.h>
  17. #include <asm/mcfsim.h>
  18. #include <asm/mcfuart.h>
  19. /***************************************************************************/
  20. /*
  21. * Some platforms need software versions of the GPIO data registers.
  22. */
  23. unsigned short ppdata;
  24. unsigned char ledbank = 0xff;
  25. /***************************************************************************/
  26. static struct mcf_platform_uart m5272_uart_platform[] = {
  27. {
  28. .mapbase = MCF_MBAR + MCFUART_BASE1,
  29. .irq = MCF_IRQ_UART1,
  30. },
  31. {
  32. .mapbase = MCF_MBAR + MCFUART_BASE2,
  33. .irq = MCF_IRQ_UART2,
  34. },
  35. { },
  36. };
  37. static struct platform_device m5272_uart = {
  38. .name = "mcfuart",
  39. .id = 0,
  40. .dev.platform_data = m5272_uart_platform,
  41. };
  42. static struct resource m5272_fec_resources[] = {
  43. {
  44. .start = MCF_MBAR + 0x840,
  45. .end = MCF_MBAR + 0x840 + 0x1cf,
  46. .flags = IORESOURCE_MEM,
  47. },
  48. {
  49. .start = MCF_IRQ_ERX,
  50. .end = MCF_IRQ_ERX,
  51. .flags = IORESOURCE_IRQ,
  52. },
  53. {
  54. .start = MCF_IRQ_ETX,
  55. .end = MCF_IRQ_ETX,
  56. .flags = IORESOURCE_IRQ,
  57. },
  58. {
  59. .start = MCF_IRQ_ENTC,
  60. .end = MCF_IRQ_ENTC,
  61. .flags = IORESOURCE_IRQ,
  62. },
  63. };
  64. static struct platform_device m5272_fec = {
  65. .name = "fec",
  66. .id = 0,
  67. .num_resources = ARRAY_SIZE(m5272_fec_resources),
  68. .resource = m5272_fec_resources,
  69. };
  70. static struct platform_device *m5272_devices[] __initdata = {
  71. &m5272_uart,
  72. &m5272_fec,
  73. };
  74. /***************************************************************************/
  75. static void __init m5272_uart_init_line(int line, int irq)
  76. {
  77. u32 v;
  78. if ((line >= 0) && (line < 2)) {
  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 m5272_cpu_reset(void)
  97. {
  98. local_irq_disable();
  99. /* Set watchdog to reset, and enabled */
  100. __raw_writew(0, MCF_MBAR + MCFSIM_WIRR);
  101. __raw_writew(1, MCF_MBAR + MCFSIM_WRRR);
  102. __raw_writew(0, MCF_MBAR + MCFSIM_WCR);
  103. for (;;)
  104. /* wait for watchdog to timeout */;
  105. }
  106. /***************************************************************************/
  107. void __init config_BSP(char *commandp, int size)
  108. {
  109. #if defined (CONFIG_MOD5272)
  110. volatile unsigned char *pivrp;
  111. /* Set base of device vectors to be 64 */
  112. pivrp = (volatile unsigned char *) (MCF_MBAR + MCFSIM_PIVR);
  113. *pivrp = 0x40;
  114. #endif
  115. #if defined(CONFIG_NETtel) || defined(CONFIG_SCALES)
  116. /* Copy command line from FLASH to local buffer... */
  117. memcpy(commandp, (char *) 0xf0004000, size);
  118. commandp[size-1] = 0;
  119. #elif defined(CONFIG_CANCam)
  120. /* Copy command line from FLASH to local buffer... */
  121. memcpy(commandp, (char *) 0xf0010000, size);
  122. commandp[size-1] = 0;
  123. #endif
  124. mach_reset = m5272_cpu_reset;
  125. }
  126. /***************************************************************************/
  127. /*
  128. * Some 5272 based boards have the FEC ethernet diectly connected to
  129. * an ethernet switch. In this case we need to use the fixed phy type,
  130. * and we need to declare it early in boot.
  131. */
  132. static struct fixed_phy_status nettel_fixed_phy_status __initdata = {
  133. .link = 1,
  134. .speed = 100,
  135. .duplex = 0,
  136. };
  137. /***************************************************************************/
  138. static int __init init_BSP(void)
  139. {
  140. m5272_uarts_init();
  141. fixed_phy_add(PHY_POLL, 0, &nettel_fixed_phy_status);
  142. platform_add_devices(m5272_devices, ARRAY_SIZE(m5272_devices));
  143. return 0;
  144. }
  145. arch_initcall(init_BSP);
  146. /***************************************************************************/