m5272.c 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. // SPDX-License-Identifier: GPL-2.0
  2. /***************************************************************************/
  3. /*
  4. * m5272.c -- platform support for ColdFire 5272 based boards
  5. *
  6. * Copyright (C) 1999-2002, Greg Ungerer ([email protected])
  7. * Copyright (C) 2001-2002, SnapGear Inc. (www.snapgear.com)
  8. */
  9. /***************************************************************************/
  10. #include <linux/clkdev.h>
  11. #include <linux/kernel.h>
  12. #include <linux/param.h>
  13. #include <linux/init.h>
  14. #include <linux/io.h>
  15. #include <linux/phy.h>
  16. #include <linux/phy_fixed.h>
  17. #include <asm/machdep.h>
  18. #include <asm/coldfire.h>
  19. #include <asm/mcfsim.h>
  20. #include <asm/mcfuart.h>
  21. #include <asm/mcfclk.h>
  22. /***************************************************************************/
  23. /*
  24. * Some platforms need software versions of the GPIO data registers.
  25. */
  26. unsigned short ppdata;
  27. unsigned char ledbank = 0xff;
  28. /***************************************************************************/
  29. DEFINE_CLK(pll, "pll.0", MCF_CLK);
  30. DEFINE_CLK(sys, "sys.0", MCF_BUSCLK);
  31. static struct clk_lookup m5272_clk_lookup[] = {
  32. CLKDEV_INIT(NULL, "pll.0", &clk_pll),
  33. CLKDEV_INIT(NULL, "sys.0", &clk_sys),
  34. CLKDEV_INIT("mcftmr.0", NULL, &clk_sys),
  35. CLKDEV_INIT("mcftmr.1", NULL, &clk_sys),
  36. CLKDEV_INIT("mcftmr.2", NULL, &clk_sys),
  37. CLKDEV_INIT("mcftmr.3", NULL, &clk_sys),
  38. CLKDEV_INIT("mcfuart.0", NULL, &clk_sys),
  39. CLKDEV_INIT("mcfuart.1", NULL, &clk_sys),
  40. CLKDEV_INIT("mcfqspi.0", NULL, &clk_sys),
  41. CLKDEV_INIT("fec.0", NULL, &clk_sys),
  42. };
  43. /***************************************************************************/
  44. static void __init m5272_uarts_init(void)
  45. {
  46. u32 v;
  47. /* Enable the output lines for the serial ports */
  48. v = readl(MCFSIM_PBCNT);
  49. v = (v & ~0x000000ff) | 0x00000055;
  50. writel(v, MCFSIM_PBCNT);
  51. v = readl(MCFSIM_PDCNT);
  52. v = (v & ~0x000003fc) | 0x000002a8;
  53. writel(v, MCFSIM_PDCNT);
  54. }
  55. /***************************************************************************/
  56. static void m5272_cpu_reset(void)
  57. {
  58. local_irq_disable();
  59. /* Set watchdog to reset, and enabled */
  60. __raw_writew(0, MCFSIM_WIRR);
  61. __raw_writew(1, MCFSIM_WRRR);
  62. __raw_writew(0, MCFSIM_WCR);
  63. for (;;)
  64. /* wait for watchdog to timeout */;
  65. }
  66. /***************************************************************************/
  67. void __init config_BSP(char *commandp, int size)
  68. {
  69. #if defined (CONFIG_MOD5272)
  70. /* Set base of device vectors to be 64 */
  71. writeb(0x40, MCFSIM_PIVR);
  72. #endif
  73. #if defined(CONFIG_NETtel) || defined(CONFIG_SCALES)
  74. /* Copy command line from FLASH to local buffer... */
  75. memcpy(commandp, (char *) 0xf0004000, size);
  76. commandp[size-1] = 0;
  77. #elif defined(CONFIG_CANCam)
  78. /* Copy command line from FLASH to local buffer... */
  79. memcpy(commandp, (char *) 0xf0010000, size);
  80. commandp[size-1] = 0;
  81. #endif
  82. mach_reset = m5272_cpu_reset;
  83. mach_sched_init = hw_timer_init;
  84. }
  85. /***************************************************************************/
  86. /*
  87. * Some 5272 based boards have the FEC ethernet directly connected to
  88. * an ethernet switch. In this case we need to use the fixed phy type,
  89. * and we need to declare it early in boot.
  90. */
  91. static struct fixed_phy_status nettel_fixed_phy_status __initdata = {
  92. .link = 1,
  93. .speed = 100,
  94. .duplex = 0,
  95. };
  96. /***************************************************************************/
  97. static int __init init_BSP(void)
  98. {
  99. m5272_uarts_init();
  100. fixed_phy_add(PHY_POLL, 0, &nettel_fixed_phy_status);
  101. clkdev_add_table(m5272_clk_lookup, ARRAY_SIZE(m5272_clk_lookup));
  102. return 0;
  103. }
  104. arch_initcall(init_BSP);
  105. /***************************************************************************/