m520x.c 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198
  1. // SPDX-License-Identifier: GPL-2.0
  2. /***************************************************************************/
  3. /*
  4. * m520x.c -- platform support for ColdFire 520x based boards
  5. *
  6. * Copyright (C) 2005, Freescale (www.freescale.com)
  7. * Copyright (C) 2005, Intec Automation (mike@steroidmicros.com)
  8. * Copyright (C) 1999-2007, Greg Ungerer (gerg@snapgear.com)
  9. * Copyright (C) 2001-2003, SnapGear Inc. (www.snapgear.com)
  10. */
  11. /***************************************************************************/
  12. #include <linux/kernel.h>
  13. #include <linux/param.h>
  14. #include <linux/init.h>
  15. #include <linux/io.h>
  16. #include <asm/machdep.h>
  17. #include <asm/coldfire.h>
  18. #include <asm/mcfsim.h>
  19. #include <asm/mcfuart.h>
  20. #include <asm/mcfclk.h>
  21. /***************************************************************************/
  22. DEFINE_CLK(0, "flexbus", 2, MCF_CLK);
  23. DEFINE_CLK(0, "fec.0", 12, MCF_CLK);
  24. DEFINE_CLK(0, "edma", 17, MCF_CLK);
  25. DEFINE_CLK(0, "intc.0", 18, MCF_CLK);
  26. DEFINE_CLK(0, "iack.0", 21, MCF_CLK);
  27. DEFINE_CLK(0, "imx1-i2c.0", 22, MCF_CLK);
  28. DEFINE_CLK(0, "mcfqspi.0", 23, MCF_CLK);
  29. DEFINE_CLK(0, "mcfuart.0", 24, MCF_BUSCLK);
  30. DEFINE_CLK(0, "mcfuart.1", 25, MCF_BUSCLK);
  31. DEFINE_CLK(0, "mcfuart.2", 26, MCF_BUSCLK);
  32. DEFINE_CLK(0, "mcftmr.0", 28, MCF_CLK);
  33. DEFINE_CLK(0, "mcftmr.1", 29, MCF_CLK);
  34. DEFINE_CLK(0, "mcftmr.2", 30, MCF_CLK);
  35. DEFINE_CLK(0, "mcftmr.3", 31, MCF_CLK);
  36. DEFINE_CLK(0, "mcfpit.0", 32, MCF_CLK);
  37. DEFINE_CLK(0, "mcfpit.1", 33, MCF_CLK);
  38. DEFINE_CLK(0, "mcfeport.0", 34, MCF_CLK);
  39. DEFINE_CLK(0, "mcfwdt.0", 35, MCF_CLK);
  40. DEFINE_CLK(0, "pll.0", 36, MCF_CLK);
  41. DEFINE_CLK(0, "sys.0", 40, MCF_BUSCLK);
  42. DEFINE_CLK(0, "gpio.0", 41, MCF_BUSCLK);
  43. DEFINE_CLK(0, "sdram.0", 42, MCF_CLK);
  44. struct clk *mcf_clks[] = {
  45. &__clk_0_2, /* flexbus */
  46. &__clk_0_12, /* fec.0 */
  47. &__clk_0_17, /* edma */
  48. &__clk_0_18, /* intc.0 */
  49. &__clk_0_21, /* iack.0 */
  50. &__clk_0_22, /* imx1-i2c.0 */
  51. &__clk_0_23, /* mcfqspi.0 */
  52. &__clk_0_24, /* mcfuart.0 */
  53. &__clk_0_25, /* mcfuart.1 */
  54. &__clk_0_26, /* mcfuart.2 */
  55. &__clk_0_28, /* mcftmr.0 */
  56. &__clk_0_29, /* mcftmr.1 */
  57. &__clk_0_30, /* mcftmr.2 */
  58. &__clk_0_31, /* mcftmr.3 */
  59. &__clk_0_32, /* mcfpit.0 */
  60. &__clk_0_33, /* mcfpit.1 */
  61. &__clk_0_34, /* mcfeport.0 */
  62. &__clk_0_35, /* mcfwdt.0 */
  63. &__clk_0_36, /* pll.0 */
  64. &__clk_0_40, /* sys.0 */
  65. &__clk_0_41, /* gpio.0 */
  66. &__clk_0_42, /* sdram.0 */
  67. NULL,
  68. };
  69. static struct clk * const enable_clks[] __initconst = {
  70. &__clk_0_2, /* flexbus */
  71. &__clk_0_18, /* intc.0 */
  72. &__clk_0_21, /* iack.0 */
  73. &__clk_0_24, /* mcfuart.0 */
  74. &__clk_0_25, /* mcfuart.1 */
  75. &__clk_0_26, /* mcfuart.2 */
  76. &__clk_0_32, /* mcfpit.0 */
  77. &__clk_0_33, /* mcfpit.1 */
  78. &__clk_0_34, /* mcfeport.0 */
  79. &__clk_0_36, /* pll.0 */
  80. &__clk_0_40, /* sys.0 */
  81. &__clk_0_41, /* gpio.0 */
  82. &__clk_0_42, /* sdram.0 */
  83. };
  84. static struct clk * const disable_clks[] __initconst = {
  85. &__clk_0_12, /* fec.0 */
  86. &__clk_0_17, /* edma */
  87. &__clk_0_22, /* imx1-i2c.0 */
  88. &__clk_0_23, /* mcfqspi.0 */
  89. &__clk_0_28, /* mcftmr.0 */
  90. &__clk_0_29, /* mcftmr.1 */
  91. &__clk_0_30, /* mcftmr.2 */
  92. &__clk_0_31, /* mcftmr.3 */
  93. &__clk_0_35, /* mcfwdt.0 */
  94. };
  95. static void __init m520x_clk_init(void)
  96. {
  97. unsigned i;
  98. /* make sure these clocks are enabled */
  99. for (i = 0; i < ARRAY_SIZE(enable_clks); ++i)
  100. __clk_init_enabled(enable_clks[i]);
  101. /* make sure these clocks are disabled */
  102. for (i = 0; i < ARRAY_SIZE(disable_clks); ++i)
  103. __clk_init_disabled(disable_clks[i]);
  104. }
  105. /***************************************************************************/
  106. static void __init m520x_qspi_init(void)
  107. {
  108. #if IS_ENABLED(CONFIG_SPI_COLDFIRE_QSPI)
  109. u16 par;
  110. /* setup Port QS for QSPI with gpio CS control */
  111. writeb(0x3f, MCF_GPIO_PAR_QSPI);
  112. /* make U1CTS and U2RTS gpio for cs_control */
  113. par = readw(MCF_GPIO_PAR_UART);
  114. par &= 0x00ff;
  115. writew(par, MCF_GPIO_PAR_UART);
  116. #endif /* IS_ENABLED(CONFIG_SPI_COLDFIRE_QSPI) */
  117. }
  118. /***************************************************************************/
  119. static void __init m520x_i2c_init(void)
  120. {
  121. #if IS_ENABLED(CONFIG_I2C_IMX)
  122. u8 par;
  123. /* setup Port FECI2C Pin Assignment Register for I2C */
  124. /* set PAR_SCL to SCL and PAR_SDA to SDA */
  125. par = readb(MCF_GPIO_PAR_FECI2C);
  126. par |= 0x0f;
  127. writeb(par, MCF_GPIO_PAR_FECI2C);
  128. #endif /* IS_ENABLED(CONFIG_I2C_IMX) */
  129. }
  130. /***************************************************************************/
  131. static void __init m520x_uarts_init(void)
  132. {
  133. u16 par;
  134. u8 par2;
  135. /* UART0 and UART1 GPIO pin setup */
  136. par = readw(MCF_GPIO_PAR_UART);
  137. par |= MCF_GPIO_PAR_UART_PAR_UTXD0 | MCF_GPIO_PAR_UART_PAR_URXD0;
  138. par |= MCF_GPIO_PAR_UART_PAR_UTXD1 | MCF_GPIO_PAR_UART_PAR_URXD1;
  139. writew(par, MCF_GPIO_PAR_UART);
  140. /* UART1 GPIO pin setup */
  141. par2 = readb(MCF_GPIO_PAR_FECI2C);
  142. par2 &= ~0x0F;
  143. par2 |= MCF_GPIO_PAR_FECI2C_PAR_SCL_UTXD2 |
  144. MCF_GPIO_PAR_FECI2C_PAR_SDA_URXD2;
  145. writeb(par2, MCF_GPIO_PAR_FECI2C);
  146. }
  147. /***************************************************************************/
  148. static void __init m520x_fec_init(void)
  149. {
  150. u8 v;
  151. /* Set multi-function pins to ethernet mode */
  152. v = readb(MCF_GPIO_PAR_FEC);
  153. writeb(v | 0xf0, MCF_GPIO_PAR_FEC);
  154. v = readb(MCF_GPIO_PAR_FECI2C);
  155. writeb(v | 0x0f, MCF_GPIO_PAR_FECI2C);
  156. }
  157. /***************************************************************************/
  158. void __init config_BSP(char *commandp, int size)
  159. {
  160. mach_sched_init = hw_timer_init;
  161. m520x_clk_init();
  162. m520x_uarts_init();
  163. m520x_fec_init();
  164. m520x_qspi_init();
  165. m520x_i2c_init();
  166. }
  167. /***************************************************************************/