m525x.c 2.5 KB

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