m5249.c 3.7 KB

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