m528x.c 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  1. // SPDX-License-Identifier: GPL-2.0
  2. /***************************************************************************/
  3. /*
  4. * m528x.c -- platform support for ColdFire 528x based boards
  5. *
  6. * Sub-architcture dependent initialization code for the Freescale
  7. * 5280, 5281 and 5282 CPUs.
  8. *
  9. * Copyright (C) 1999-2003, Greg Ungerer (gerg@snapgear.com)
  10. * Copyright (C) 2001-2003, SnapGear Inc. (www.snapgear.com)
  11. */
  12. /***************************************************************************/
  13. #include <linux/kernel.h>
  14. #include <linux/param.h>
  15. #include <linux/init.h>
  16. #include <linux/platform_device.h>
  17. #include <linux/io.h>
  18. #include <asm/machdep.h>
  19. #include <asm/coldfire.h>
  20. #include <asm/mcfsim.h>
  21. #include <asm/mcfuart.h>
  22. #include <asm/mcfclk.h>
  23. /***************************************************************************/
  24. DEFINE_CLK(pll, "pll.0", MCF_CLK);
  25. DEFINE_CLK(sys, "sys.0", MCF_BUSCLK);
  26. DEFINE_CLK(mcfpit0, "mcfpit.0", MCF_CLK);
  27. DEFINE_CLK(mcfpit1, "mcfpit.1", MCF_CLK);
  28. DEFINE_CLK(mcfpit2, "mcfpit.2", MCF_CLK);
  29. DEFINE_CLK(mcfpit3, "mcfpit.3", MCF_CLK);
  30. DEFINE_CLK(mcfuart0, "mcfuart.0", MCF_BUSCLK);
  31. DEFINE_CLK(mcfuart1, "mcfuart.1", MCF_BUSCLK);
  32. DEFINE_CLK(mcfuart2, "mcfuart.2", MCF_BUSCLK);
  33. DEFINE_CLK(mcfqspi0, "mcfqspi.0", MCF_BUSCLK);
  34. DEFINE_CLK(fec0, "fec.0", MCF_BUSCLK);
  35. DEFINE_CLK(mcfi2c0, "imx1-i2c.0", MCF_BUSCLK);
  36. struct clk *mcf_clks[] = {
  37. &clk_pll,
  38. &clk_sys,
  39. &clk_mcfpit0,
  40. &clk_mcfpit1,
  41. &clk_mcfpit2,
  42. &clk_mcfpit3,
  43. &clk_mcfuart0,
  44. &clk_mcfuart1,
  45. &clk_mcfuart2,
  46. &clk_mcfqspi0,
  47. &clk_fec0,
  48. &clk_mcfi2c0,
  49. NULL
  50. };
  51. /***************************************************************************/
  52. static void __init m528x_qspi_init(void)
  53. {
  54. #if IS_ENABLED(CONFIG_SPI_COLDFIRE_QSPI)
  55. /* setup Port QS for QSPI with gpio CS control */
  56. __raw_writeb(0x07, MCFGPIO_PQSPAR);
  57. #endif /* IS_ENABLED(CONFIG_SPI_COLDFIRE_QSPI) */
  58. }
  59. /***************************************************************************/
  60. static void __init m528x_i2c_init(void)
  61. {
  62. #if IS_ENABLED(CONFIG_I2C_IMX)
  63. u16 paspar;
  64. /* setup Port AS Pin Assignment Register for I2C */
  65. /* set PASPA0 to SCL and PASPA1 to SDA */
  66. paspar = readw(MCFGPIO_PASPAR);
  67. paspar |= 0xF;
  68. writew(paspar, MCFGPIO_PASPAR);
  69. #endif /* IS_ENABLED(CONFIG_I2C_IMX) */
  70. }
  71. /***************************************************************************/
  72. static void __init m528x_uarts_init(void)
  73. {
  74. u8 port;
  75. /* make sure PUAPAR is set for UART0 and UART1 */
  76. port = readb(MCFGPIO_PUAPAR);
  77. port |= 0x03 | (0x03 << 2);
  78. writeb(port, MCFGPIO_PUAPAR);
  79. }
  80. /***************************************************************************/
  81. static void __init m528x_fec_init(void)
  82. {
  83. u16 v16;
  84. /* Set multi-function pins to ethernet mode for fec0 */
  85. v16 = readw(MCFGPIO_PASPAR);
  86. writew(v16 | 0xf00, MCFGPIO_PASPAR);
  87. writeb(0xc0, MCFGPIO_PEHLPAR);
  88. }
  89. /***************************************************************************/
  90. #ifdef CONFIG_WILDFIRE
  91. void wildfire_halt(void)
  92. {
  93. writeb(0, 0x30000007);
  94. writeb(0x2, 0x30000007);
  95. }
  96. #endif
  97. #ifdef CONFIG_WILDFIREMOD
  98. void wildfiremod_halt(void)
  99. {
  100. printk(KERN_INFO "WildFireMod hibernating...\n");
  101. /* Set portE.5 to Digital IO */
  102. writew(readw(MCFGPIO_PEPAR) & ~(1 << (5 * 2)), MCFGPIO_PEPAR);
  103. /* Make portE.5 an output */
  104. writeb(readb(MCFGPIO_PDDR_E) | (1 << 5), MCFGPIO_PDDR_E);
  105. /* Now toggle portE.5 from low to high */
  106. writeb(readb(MCFGPIO_PODR_E) & ~(1 << 5), MCFGPIO_PODR_E);
  107. writeb(readb(MCFGPIO_PODR_E) | (1 << 5), MCFGPIO_PODR_E);
  108. printk(KERN_EMERG "Failed to hibernate. Halting!\n");
  109. }
  110. #endif
  111. void __init config_BSP(char *commandp, int size)
  112. {
  113. #ifdef CONFIG_WILDFIRE
  114. mach_halt = wildfire_halt;
  115. #endif
  116. #ifdef CONFIG_WILDFIREMOD
  117. mach_halt = wildfiremod_halt;
  118. #endif
  119. mach_sched_init = hw_timer_init;
  120. m528x_uarts_init();
  121. m528x_fec_init();
  122. m528x_qspi_init();
  123. m528x_i2c_init();
  124. }
  125. /***************************************************************************/