m527x.c 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  1. // SPDX-License-Identifier: GPL-2.0
  2. /***************************************************************************/
  3. /*
  4. * m527x.c -- platform support for ColdFire 527x based boards
  5. *
  6. * Sub-architcture dependent initialization code for the Freescale
  7. * 5270/5271 and 5274/5275 CPUs.
  8. *
  9. * Copyright (C) 1999-2004, Greg Ungerer (gerg@snapgear.com)
  10. * Copyright (C) 2001-2004, 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/io.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. DEFINE_CLK(pll, "pll.0", MCF_CLK);
  24. DEFINE_CLK(sys, "sys.0", MCF_BUSCLK);
  25. DEFINE_CLK(mcfpit0, "mcfpit.0", MCF_CLK);
  26. DEFINE_CLK(mcfpit1, "mcfpit.1", MCF_CLK);
  27. DEFINE_CLK(mcfpit2, "mcfpit.2", MCF_CLK);
  28. DEFINE_CLK(mcfpit3, "mcfpit.3", MCF_CLK);
  29. DEFINE_CLK(mcfuart0, "mcfuart.0", MCF_BUSCLK);
  30. DEFINE_CLK(mcfuart1, "mcfuart.1", MCF_BUSCLK);
  31. DEFINE_CLK(mcfuart2, "mcfuart.2", MCF_BUSCLK);
  32. DEFINE_CLK(mcfqspi0, "mcfqspi.0", MCF_BUSCLK);
  33. DEFINE_CLK(fec0, "fec.0", MCF_BUSCLK);
  34. DEFINE_CLK(fec1, "fec.1", 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_fec1,
  49. &clk_mcfi2c0,
  50. NULL
  51. };
  52. /***************************************************************************/
  53. static void __init m527x_qspi_init(void)
  54. {
  55. #if IS_ENABLED(CONFIG_SPI_COLDFIRE_QSPI)
  56. #if defined(CONFIG_M5271)
  57. u16 par;
  58. /* setup QSPS pins for QSPI with gpio CS control */
  59. writeb(0x1f, MCFGPIO_PAR_QSPI);
  60. /* and CS2 & CS3 as gpio */
  61. par = readw(MCFGPIO_PAR_TIMER);
  62. par &= 0x3f3f;
  63. writew(par, MCFGPIO_PAR_TIMER);
  64. #elif defined(CONFIG_M5275)
  65. /* setup QSPS pins for QSPI with gpio CS control */
  66. writew(0x003e, MCFGPIO_PAR_QSPI);
  67. #endif
  68. #endif /* IS_ENABLED(CONFIG_SPI_COLDFIRE_QSPI) */
  69. }
  70. /***************************************************************************/
  71. static void __init m527x_i2c_init(void)
  72. {
  73. #if IS_ENABLED(CONFIG_I2C_IMX)
  74. #if defined(CONFIG_M5271)
  75. u8 par;
  76. /* setup Port FECI2C Pin Assignment Register for I2C */
  77. /* set PAR_SCL to SCL and PAR_SDA to SDA */
  78. par = readb(MCFGPIO_PAR_FECI2C);
  79. par |= 0x0f;
  80. writeb(par, MCFGPIO_PAR_FECI2C);
  81. #elif defined(CONFIG_M5275)
  82. u16 par;
  83. /* setup Port FECI2C Pin Assignment Register for I2C */
  84. /* set PAR_SCL to SCL and PAR_SDA to SDA */
  85. par = readw(MCFGPIO_PAR_FECI2C);
  86. par |= 0x0f;
  87. writew(par, MCFGPIO_PAR_FECI2C);
  88. #endif
  89. #endif /* IS_ENABLED(CONFIG_I2C_IMX) */
  90. }
  91. /***************************************************************************/
  92. static void __init m527x_uarts_init(void)
  93. {
  94. u16 sepmask;
  95. /*
  96. * External Pin Mask Setting & Enable External Pin for Interface
  97. */
  98. sepmask = readw(MCFGPIO_PAR_UART);
  99. sepmask |= UART0_ENABLE_MASK | UART1_ENABLE_MASK | UART2_ENABLE_MASK;
  100. writew(sepmask, MCFGPIO_PAR_UART);
  101. }
  102. /***************************************************************************/
  103. static void __init m527x_fec_init(void)
  104. {
  105. u8 v;
  106. /* Set multi-function pins to ethernet mode for fec0 */
  107. #if defined(CONFIG_M5271)
  108. v = readb(MCFGPIO_PAR_FECI2C);
  109. writeb(v | 0xf0, MCFGPIO_PAR_FECI2C);
  110. #else
  111. u16 par;
  112. par = readw(MCFGPIO_PAR_FECI2C);
  113. writew(par | 0xf00, MCFGPIO_PAR_FECI2C);
  114. v = readb(MCFGPIO_PAR_FEC0HL);
  115. writeb(v | 0xc0, MCFGPIO_PAR_FEC0HL);
  116. /* Set multi-function pins to ethernet mode for fec1 */
  117. par = readw(MCFGPIO_PAR_FECI2C);
  118. writew(par | 0xa0, MCFGPIO_PAR_FECI2C);
  119. v = readb(MCFGPIO_PAR_FEC1HL);
  120. writeb(v | 0xc0, MCFGPIO_PAR_FEC1HL);
  121. #endif
  122. }
  123. /***************************************************************************/
  124. void __init config_BSP(char *commandp, int size)
  125. {
  126. mach_sched_init = hw_timer_init;
  127. m527x_uarts_init();
  128. m527x_fec_init();
  129. m527x_qspi_init();
  130. m527x_i2c_init();
  131. }
  132. /***************************************************************************/