m54xx.c 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. /***************************************************************************/
  2. /*
  3. * m54xx.c -- platform support for ColdFire 54xx based boards
  4. *
  5. * Copyright (C) 2010, Philippe De Muyter <phdm@macqel.be>
  6. */
  7. /***************************************************************************/
  8. #include <linux/kernel.h>
  9. #include <linux/param.h>
  10. #include <linux/init.h>
  11. #include <linux/interrupt.h>
  12. #include <linux/io.h>
  13. #include <linux/mm.h>
  14. #include <linux/clk.h>
  15. #include <linux/bootmem.h>
  16. #include <asm/pgalloc.h>
  17. #include <asm/machdep.h>
  18. #include <asm/coldfire.h>
  19. #include <asm/m54xxsim.h>
  20. #include <asm/mcfuart.h>
  21. #include <asm/mcfclk.h>
  22. #include <asm/m54xxgpt.h>
  23. #ifdef CONFIG_MMU
  24. #include <asm/mmu_context.h>
  25. #endif
  26. /***************************************************************************/
  27. DEFINE_CLK(pll, "pll.0", MCF_CLK);
  28. DEFINE_CLK(sys, "sys.0", MCF_BUSCLK);
  29. DEFINE_CLK(mcfslt0, "mcfslt.0", MCF_BUSCLK);
  30. DEFINE_CLK(mcfslt1, "mcfslt.1", MCF_BUSCLK);
  31. DEFINE_CLK(mcfuart0, "mcfuart.0", MCF_BUSCLK);
  32. DEFINE_CLK(mcfuart1, "mcfuart.1", MCF_BUSCLK);
  33. DEFINE_CLK(mcfuart2, "mcfuart.2", MCF_BUSCLK);
  34. DEFINE_CLK(mcfuart3, "mcfuart.3", MCF_BUSCLK);
  35. DEFINE_CLK(mcfi2c0, "imx1-i2c.0", MCF_BUSCLK);
  36. struct clk *mcf_clks[] = {
  37. &clk_pll,
  38. &clk_sys,
  39. &clk_mcfslt0,
  40. &clk_mcfslt1,
  41. &clk_mcfuart0,
  42. &clk_mcfuart1,
  43. &clk_mcfuart2,
  44. &clk_mcfuart3,
  45. &clk_mcfi2c0,
  46. NULL
  47. };
  48. /***************************************************************************/
  49. static void __init m54xx_uarts_init(void)
  50. {
  51. /* enable io pins */
  52. __raw_writeb(MCF_PAR_PSC_TXD | MCF_PAR_PSC_RXD, MCFGPIO_PAR_PSC0);
  53. __raw_writeb(MCF_PAR_PSC_TXD | MCF_PAR_PSC_RXD | MCF_PAR_PSC_RTS_RTS,
  54. MCFGPIO_PAR_PSC1);
  55. __raw_writeb(MCF_PAR_PSC_TXD | MCF_PAR_PSC_RXD | MCF_PAR_PSC_RTS_RTS |
  56. MCF_PAR_PSC_CTS_CTS, MCFGPIO_PAR_PSC2);
  57. __raw_writeb(MCF_PAR_PSC_TXD | MCF_PAR_PSC_RXD, MCFGPIO_PAR_PSC3);
  58. }
  59. /***************************************************************************/
  60. static void __init m54xx_i2c_init(void)
  61. {
  62. #if IS_ENABLED(CONFIG_I2C_IMX)
  63. u32 r;
  64. /* set the fec/i2c/irq pin assignment register for i2c */
  65. r = readl(MCF_PAR_FECI2CIRQ);
  66. r |= MCF_PAR_FECI2CIRQ_SDA | MCF_PAR_FECI2CIRQ_SCL;
  67. writel(r, MCF_PAR_FECI2CIRQ);
  68. #endif /* IS_ENABLED(CONFIG_I2C_IMX) */
  69. }
  70. /***************************************************************************/
  71. static void mcf54xx_reset(void)
  72. {
  73. /* disable interrupts and enable the watchdog */
  74. asm("movew #0x2700, %sr\n");
  75. __raw_writel(0, MCF_GPT_GMS0);
  76. __raw_writel(MCF_GPT_GCIR_CNT(1), MCF_GPT_GCIR0);
  77. __raw_writel(MCF_GPT_GMS_WDEN | MCF_GPT_GMS_CE | MCF_GPT_GMS_TMS(4),
  78. MCF_GPT_GMS0);
  79. }
  80. /***************************************************************************/
  81. void __init config_BSP(char *commandp, int size)
  82. {
  83. #ifdef CONFIG_MMU
  84. cf_bootmem_alloc();
  85. mmu_context_init();
  86. #endif
  87. mach_reset = mcf54xx_reset;
  88. mach_sched_init = hw_timer_init;
  89. m54xx_uarts_init();
  90. m54xx_i2c_init();
  91. }
  92. /***************************************************************************/