m525x.c 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. // SPDX-License-Identifier: GPL-2.0
  2. /***************************************************************************/
  3. /*
  4. * 525x.c -- platform support for ColdFire 525x based boards
  5. *
  6. * Copyright (C) 2012, Steven King <sfking@fdwdc.com>
  7. */
  8. /***************************************************************************/
  9. #include <linux/kernel.h>
  10. #include <linux/param.h>
  11. #include <linux/init.h>
  12. #include <linux/io.h>
  13. #include <linux/platform_device.h>
  14. #include <asm/machdep.h>
  15. #include <asm/coldfire.h>
  16. #include <asm/mcfsim.h>
  17. #include <asm/mcfclk.h>
  18. /***************************************************************************/
  19. DEFINE_CLK(pll, "pll.0", MCF_CLK);
  20. DEFINE_CLK(sys, "sys.0", MCF_BUSCLK);
  21. DEFINE_CLK(mcftmr0, "mcftmr.0", MCF_BUSCLK);
  22. DEFINE_CLK(mcftmr1, "mcftmr.1", MCF_BUSCLK);
  23. DEFINE_CLK(mcfuart0, "mcfuart.0", MCF_BUSCLK);
  24. DEFINE_CLK(mcfuart1, "mcfuart.1", MCF_BUSCLK);
  25. DEFINE_CLK(mcfqspi0, "mcfqspi.0", MCF_BUSCLK);
  26. DEFINE_CLK(mcfi2c0, "imx1-i2c.0", MCF_BUSCLK);
  27. DEFINE_CLK(mcfi2c1, "imx1-i2c.1", MCF_BUSCLK);
  28. struct clk *mcf_clks[] = {
  29. &clk_pll,
  30. &clk_sys,
  31. &clk_mcftmr0,
  32. &clk_mcftmr1,
  33. &clk_mcfuart0,
  34. &clk_mcfuart1,
  35. &clk_mcfqspi0,
  36. &clk_mcfi2c0,
  37. &clk_mcfi2c1,
  38. NULL
  39. };
  40. /***************************************************************************/
  41. static void __init m525x_qspi_init(void)
  42. {
  43. #if IS_ENABLED(CONFIG_SPI_COLDFIRE_QSPI)
  44. /* set the GPIO function for the qspi cs gpios */
  45. /* FIXME: replace with pinmux/pinctl support */
  46. u32 f = readl(MCFSIM2_GPIOFUNC);
  47. f |= (1 << MCFQSPI_CS2) | (1 << MCFQSPI_CS1) | (1 << MCFQSPI_CS0);
  48. writel(f, MCFSIM2_GPIOFUNC);
  49. /* QSPI irq setup */
  50. writeb(MCFSIM_ICR_AUTOVEC | MCFSIM_ICR_LEVEL4 | MCFSIM_ICR_PRI0,
  51. MCFSIM_QSPIICR);
  52. mcf_mapirq2imr(MCF_IRQ_QSPI, MCFINTC_QSPI);
  53. #endif /* IS_ENABLED(CONFIG_SPI_COLDFIRE_QSPI) */
  54. }
  55. static void __init m525x_i2c_init(void)
  56. {
  57. #if IS_ENABLED(CONFIG_I2C_IMX)
  58. u32 r;
  59. /* first I2C controller uses regular irq setup */
  60. writeb(MCFSIM_ICR_AUTOVEC | MCFSIM_ICR_LEVEL5 | MCFSIM_ICR_PRI0,
  61. MCFSIM_I2CICR);
  62. mcf_mapirq2imr(MCF_IRQ_I2C0, MCFINTC_I2C);
  63. /* second I2C controller is completely different */
  64. r = readl(MCFINTC2_INTPRI_REG(MCF_IRQ_I2C1));
  65. r &= ~MCFINTC2_INTPRI_BITS(0xf, MCF_IRQ_I2C1);
  66. r |= MCFINTC2_INTPRI_BITS(0x5, MCF_IRQ_I2C1);
  67. writel(r, MCFINTC2_INTPRI_REG(MCF_IRQ_I2C1));
  68. #endif /* IS_ENABLED(CONFIG_I2C_IMX) */
  69. }
  70. /***************************************************************************/
  71. void __init config_BSP(char *commandp, int size)
  72. {
  73. mach_sched_init = hw_timer_init;
  74. m525x_qspi_init();
  75. m525x_i2c_init();
  76. }
  77. /***************************************************************************/