m527x.c 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. /***************************************************************************/
  2. /*
  3. * m527x.c -- platform support for ColdFire 527x based boards
  4. *
  5. * Sub-architcture dependent initialization code for the Freescale
  6. * 5270/5271 and 5274/5275 CPUs.
  7. *
  8. * Copyright (C) 1999-2004, Greg Ungerer (gerg@snapgear.com)
  9. * Copyright (C) 2001-2004, 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(pll, "pll.0", MCF_CLK);
  23. DEFINE_CLK(sys, "sys.0", MCF_BUSCLK);
  24. DEFINE_CLK(mcfpit0, "mcfpit.0", MCF_CLK);
  25. DEFINE_CLK(mcfpit1, "mcfpit.1", MCF_CLK);
  26. DEFINE_CLK(mcfpit2, "mcfpit.2", MCF_CLK);
  27. DEFINE_CLK(mcfpit3, "mcfpit.3", MCF_CLK);
  28. DEFINE_CLK(mcfuart0, "mcfuart.0", MCF_BUSCLK);
  29. DEFINE_CLK(mcfuart1, "mcfuart.1", MCF_BUSCLK);
  30. DEFINE_CLK(mcfuart2, "mcfuart.2", MCF_BUSCLK);
  31. DEFINE_CLK(mcfqspi0, "mcfqspi.0", MCF_BUSCLK);
  32. DEFINE_CLK(fec0, "fec.0", MCF_BUSCLK);
  33. DEFINE_CLK(fec1, "fec.1", MCF_BUSCLK);
  34. struct clk *mcf_clks[] = {
  35. &clk_pll,
  36. &clk_sys,
  37. &clk_mcfpit0,
  38. &clk_mcfpit1,
  39. &clk_mcfpit2,
  40. &clk_mcfpit3,
  41. &clk_mcfuart0,
  42. &clk_mcfuart1,
  43. &clk_mcfuart2,
  44. &clk_mcfqspi0,
  45. &clk_fec0,
  46. &clk_fec1,
  47. NULL
  48. };
  49. /***************************************************************************/
  50. static void __init m527x_qspi_init(void)
  51. {
  52. #if IS_ENABLED(CONFIG_SPI_COLDFIRE_QSPI)
  53. #if defined(CONFIG_M5271)
  54. u16 par;
  55. /* setup QSPS pins for QSPI with gpio CS control */
  56. writeb(0x1f, MCFGPIO_PAR_QSPI);
  57. /* and CS2 & CS3 as gpio */
  58. par = readw(MCFGPIO_PAR_TIMER);
  59. par &= 0x3f3f;
  60. writew(par, MCFGPIO_PAR_TIMER);
  61. #elif defined(CONFIG_M5275)
  62. /* setup QSPS pins for QSPI with gpio CS control */
  63. writew(0x003e, MCFGPIO_PAR_QSPI);
  64. #endif
  65. #endif /* IS_ENABLED(CONFIG_SPI_COLDFIRE_QSPI) */
  66. }
  67. /***************************************************************************/
  68. static void __init m527x_uarts_init(void)
  69. {
  70. u16 sepmask;
  71. /*
  72. * External Pin Mask Setting & Enable External Pin for Interface
  73. */
  74. sepmask = readw(MCFGPIO_PAR_UART);
  75. sepmask |= UART0_ENABLE_MASK | UART1_ENABLE_MASK | UART2_ENABLE_MASK;
  76. writew(sepmask, MCFGPIO_PAR_UART);
  77. }
  78. /***************************************************************************/
  79. static void __init m527x_fec_init(void)
  80. {
  81. u8 v;
  82. /* Set multi-function pins to ethernet mode for fec0 */
  83. #if defined(CONFIG_M5271)
  84. v = readb(MCFGPIO_PAR_FECI2C);
  85. writeb(v | 0xf0, MCFGPIO_PAR_FECI2C);
  86. #else
  87. u16 par;
  88. par = readw(MCFGPIO_PAR_FECI2C);
  89. writew(par | 0xf00, MCFGPIO_PAR_FECI2C);
  90. v = readb(MCFGPIO_PAR_FEC0HL);
  91. writeb(v | 0xc0, MCFGPIO_PAR_FEC0HL);
  92. /* Set multi-function pins to ethernet mode for fec1 */
  93. par = readw(MCFGPIO_PAR_FECI2C);
  94. writew(par | 0xa0, MCFGPIO_PAR_FECI2C);
  95. v = readb(MCFGPIO_PAR_FEC1HL);
  96. writeb(v | 0xc0, MCFGPIO_PAR_FEC1HL);
  97. #endif
  98. }
  99. /***************************************************************************/
  100. void __init config_BSP(char *commandp, int size)
  101. {
  102. mach_sched_init = hw_timer_init;
  103. m527x_uarts_init();
  104. m527x_fec_init();
  105. m527x_qspi_init();
  106. }
  107. /***************************************************************************/