config.c 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160
  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 <asm/machdep.h>
  14. #include <asm/coldfire.h>
  15. #include <asm/mcfsim.h>
  16. #include <asm/mcfuart.h>
  17. /***************************************************************************/
  18. /*
  19. * Some platforms need software versions of the GPIO data registers.
  20. */
  21. unsigned short ppdata;
  22. unsigned char ledbank = 0xff;
  23. /***************************************************************************/
  24. static struct mcf_platform_uart m5272_uart_platform[] = {
  25. {
  26. .mapbase = MCF_MBAR + MCFUART_BASE1,
  27. .irq = MCF_IRQ_UART1,
  28. },
  29. {
  30. .mapbase = MCF_MBAR + MCFUART_BASE2,
  31. .irq = MCF_IRQ_UART2,
  32. },
  33. { },
  34. };
  35. static struct platform_device m5272_uart = {
  36. .name = "mcfuart",
  37. .id = 0,
  38. .dev.platform_data = m5272_uart_platform,
  39. };
  40. static struct resource m5272_fec_resources[] = {
  41. {
  42. .start = MCF_MBAR + 0x840,
  43. .end = MCF_MBAR + 0x840 + 0x1cf,
  44. .flags = IORESOURCE_MEM,
  45. },
  46. {
  47. .start = MCF_IRQ_ERX,
  48. .end = MCF_IRQ_ERX,
  49. .flags = IORESOURCE_IRQ,
  50. },
  51. {
  52. .start = MCF_IRQ_ETX,
  53. .end = MCF_IRQ_ETX,
  54. .flags = IORESOURCE_IRQ,
  55. },
  56. {
  57. .start = MCF_IRQ_ENTC,
  58. .end = MCF_IRQ_ENTC,
  59. .flags = IORESOURCE_IRQ,
  60. },
  61. };
  62. static struct platform_device m5272_fec = {
  63. .name = "fec",
  64. .id = 0,
  65. .num_resources = ARRAY_SIZE(m5272_fec_resources),
  66. .resource = m5272_fec_resources,
  67. };
  68. static struct platform_device *m5272_devices[] __initdata = {
  69. &m5272_uart,
  70. &m5272_fec,
  71. };
  72. /***************************************************************************/
  73. static void __init m5272_uart_init_line(int line, int irq)
  74. {
  75. u32 v;
  76. if ((line >= 0) && (line < 2)) {
  77. /* Enable the output lines for the serial ports */
  78. v = readl(MCF_MBAR + MCFSIM_PBCNT);
  79. v = (v & ~0x000000ff) | 0x00000055;
  80. writel(v, MCF_MBAR + MCFSIM_PBCNT);
  81. v = readl(MCF_MBAR + MCFSIM_PDCNT);
  82. v = (v & ~0x000003fc) | 0x000002a8;
  83. writel(v, MCF_MBAR + MCFSIM_PDCNT);
  84. }
  85. }
  86. static void __init m5272_uarts_init(void)
  87. {
  88. const int nrlines = ARRAY_SIZE(m5272_uart_platform);
  89. int line;
  90. for (line = 0; (line < nrlines); line++)
  91. m5272_uart_init_line(line, m5272_uart_platform[line].irq);
  92. }
  93. /***************************************************************************/
  94. static void m5272_cpu_reset(void)
  95. {
  96. local_irq_disable();
  97. /* Set watchdog to reset, and enabled */
  98. __raw_writew(0, MCF_MBAR + MCFSIM_WIRR);
  99. __raw_writew(1, MCF_MBAR + MCFSIM_WRRR);
  100. __raw_writew(0, MCF_MBAR + MCFSIM_WCR);
  101. for (;;)
  102. /* wait for watchdog to timeout */;
  103. }
  104. /***************************************************************************/
  105. void __init config_BSP(char *commandp, int size)
  106. {
  107. #if defined (CONFIG_MOD5272)
  108. volatile unsigned char *pivrp;
  109. /* Set base of device vectors to be 64 */
  110. pivrp = (volatile unsigned char *) (MCF_MBAR + MCFSIM_PIVR);
  111. *pivrp = 0x40;
  112. #endif
  113. #if defined(CONFIG_NETtel) || defined(CONFIG_SCALES)
  114. /* Copy command line from FLASH to local buffer... */
  115. memcpy(commandp, (char *) 0xf0004000, size);
  116. commandp[size-1] = 0;
  117. #elif defined(CONFIG_CANCam)
  118. /* Copy command line from FLASH to local buffer... */
  119. memcpy(commandp, (char *) 0xf0010000, size);
  120. commandp[size-1] = 0;
  121. #endif
  122. mach_reset = m5272_cpu_reset;
  123. }
  124. /***************************************************************************/
  125. static int __init init_BSP(void)
  126. {
  127. m5272_uarts_init();
  128. platform_add_devices(m5272_devices, ARRAY_SIZE(m5272_devices));
  129. return 0;
  130. }
  131. arch_initcall(init_BSP);
  132. /***************************************************************************/