m5249.c 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  1. // SPDX-License-Identifier: GPL-2.0
  2. /***************************************************************************/
  3. /*
  4. * m5249.c -- platform support for ColdFire 5249 based boards
  5. *
  6. * Copyright (C) 2002, Greg Ungerer (gerg@snapgear.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. #ifdef CONFIG_M5249C3
  42. static struct resource m5249_smc91x_resources[] = {
  43. {
  44. .start = 0xe0000300,
  45. .end = 0xe0000300 + 0x100,
  46. .flags = IORESOURCE_MEM,
  47. },
  48. {
  49. .start = MCF_IRQ_GPIO6,
  50. .end = MCF_IRQ_GPIO6,
  51. .flags = IORESOURCE_IRQ,
  52. },
  53. };
  54. static struct platform_device m5249_smc91x = {
  55. .name = "smc91x",
  56. .id = 0,
  57. .num_resources = ARRAY_SIZE(m5249_smc91x_resources),
  58. .resource = m5249_smc91x_resources,
  59. };
  60. #endif /* CONFIG_M5249C3 */
  61. static struct platform_device *m5249_devices[] __initdata = {
  62. #ifdef CONFIG_M5249C3
  63. &m5249_smc91x,
  64. #endif
  65. };
  66. /***************************************************************************/
  67. static void __init m5249_qspi_init(void)
  68. {
  69. #if IS_ENABLED(CONFIG_SPI_COLDFIRE_QSPI)
  70. /* QSPI irq setup */
  71. writeb(MCFSIM_ICR_AUTOVEC | MCFSIM_ICR_LEVEL4 | MCFSIM_ICR_PRI0,
  72. MCFSIM_QSPIICR);
  73. mcf_mapirq2imr(MCF_IRQ_QSPI, MCFINTC_QSPI);
  74. #endif /* IS_ENABLED(CONFIG_SPI_COLDFIRE_QSPI) */
  75. }
  76. /***************************************************************************/
  77. static void __init m5249_i2c_init(void)
  78. {
  79. #if IS_ENABLED(CONFIG_I2C_IMX)
  80. u32 r;
  81. /* first I2C controller uses regular irq setup */
  82. writeb(MCFSIM_ICR_AUTOVEC | MCFSIM_ICR_LEVEL5 | MCFSIM_ICR_PRI0,
  83. MCFSIM_I2CICR);
  84. mcf_mapirq2imr(MCF_IRQ_I2C0, MCFINTC_I2C);
  85. /* second I2C controller is completely different */
  86. r = readl(MCFINTC2_INTPRI_REG(MCF_IRQ_I2C1));
  87. r &= ~MCFINTC2_INTPRI_BITS(0xf, MCF_IRQ_I2C1);
  88. r |= MCFINTC2_INTPRI_BITS(0x5, MCF_IRQ_I2C1);
  89. writel(r, MCFINTC2_INTPRI_REG(MCF_IRQ_I2C1));
  90. #endif /* CONFIG_I2C_IMX */
  91. }
  92. /***************************************************************************/
  93. #ifdef CONFIG_M5249C3
  94. static void __init m5249_smc91x_init(void)
  95. {
  96. u32 gpio;
  97. /* Set the GPIO line as interrupt source for smc91x device */
  98. gpio = readl(MCFSIM2_GPIOINTENABLE);
  99. writel(gpio | 0x40, MCFSIM2_GPIOINTENABLE);
  100. gpio = readl(MCFINTC2_INTPRI5);
  101. writel(gpio | 0x04000000, MCFINTC2_INTPRI5);
  102. }
  103. #endif /* CONFIG_M5249C3 */
  104. /***************************************************************************/
  105. void __init config_BSP(char *commandp, int size)
  106. {
  107. mach_sched_init = hw_timer_init;
  108. #ifdef CONFIG_M5249C3
  109. m5249_smc91x_init();
  110. #endif
  111. m5249_qspi_init();
  112. m5249_i2c_init();
  113. }
  114. /***************************************************************************/
  115. static int __init init_BSP(void)
  116. {
  117. platform_add_devices(m5249_devices, ARRAY_SIZE(m5249_devices));
  118. return 0;
  119. }
  120. arch_initcall(init_BSP);
  121. /***************************************************************************/