m525x.c 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  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. struct clk *mcf_clks[] = {
  26. &clk_pll,
  27. &clk_sys,
  28. &clk_mcftmr0,
  29. &clk_mcftmr1,
  30. &clk_mcfuart0,
  31. &clk_mcfuart1,
  32. &clk_mcfqspi0,
  33. NULL
  34. };
  35. /***************************************************************************/
  36. static void __init m525x_qspi_init(void)
  37. {
  38. #if IS_ENABLED(CONFIG_SPI_COLDFIRE_QSPI)
  39. /* set the GPIO function for the qspi cs gpios */
  40. /* FIXME: replace with pinmux/pinctl support */
  41. u32 f = readl(MCFSIM2_GPIOFUNC);
  42. f |= (1 << MCFQSPI_CS2) | (1 << MCFQSPI_CS1) | (1 << MCFQSPI_CS0);
  43. writel(f, MCFSIM2_GPIOFUNC);
  44. /* QSPI irq setup */
  45. writeb(MCFSIM_ICR_AUTOVEC | MCFSIM_ICR_LEVEL4 | MCFSIM_ICR_PRI0,
  46. MCFSIM_QSPIICR);
  47. mcf_mapirq2imr(MCF_IRQ_QSPI, MCFINTC_QSPI);
  48. #endif /* IS_ENABLED(CONFIG_SPI_COLDFIRE_QSPI) */
  49. }
  50. static void __init m525x_i2c_init(void)
  51. {
  52. #if IS_ENABLED(CONFIG_I2C_COLDFIRE)
  53. u32 r;
  54. /* first I2C controller uses regular irq setup */
  55. writeb(MCFSIM_ICR_AUTOVEC | MCFSIM_ICR_LEVEL5 | MCFSIM_ICR_PRI0,
  56. MCFSIM_I2CICR);
  57. mcf_mapirq2imr(MCF_IRQ_I2C0, MCFINTC_I2C);
  58. /* second I2C controller is completely different */
  59. r = readl(MCFINTC2_INTPRI_REG(MCF_IRQ_I2C1));
  60. r &= ~MCFINTC2_INTPRI_BITS(0xf, MCF_IRQ_I2C1);
  61. r |= MCFINTC2_INTPRI_BITS(0x5, MCF_IRQ_I2C1);
  62. writel(r, MCFINTC2_INTPRI_REG(MCF_IRQ_I2C1));
  63. #endif /* IS_ENABLED(CONFIG_I2C_COLDFIRE) */
  64. }
  65. /***************************************************************************/
  66. void __init config_BSP(char *commandp, int size)
  67. {
  68. mach_sched_init = hw_timer_init;
  69. m525x_qspi_init();
  70. m525x_i2c_init();
  71. }
  72. /***************************************************************************/