m54xx.c 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  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. struct clk *mcf_clks[] = {
  36. &clk_pll,
  37. &clk_sys,
  38. &clk_mcfslt0,
  39. &clk_mcfslt1,
  40. &clk_mcfuart0,
  41. &clk_mcfuart1,
  42. &clk_mcfuart2,
  43. &clk_mcfuart3,
  44. NULL
  45. };
  46. /***************************************************************************/
  47. static void __init m54xx_uarts_init(void)
  48. {
  49. /* enable io pins */
  50. __raw_writeb(MCF_PAR_PSC_TXD | MCF_PAR_PSC_RXD, MCFGPIO_PAR_PSC0);
  51. __raw_writeb(MCF_PAR_PSC_TXD | MCF_PAR_PSC_RXD | MCF_PAR_PSC_RTS_RTS,
  52. MCFGPIO_PAR_PSC1);
  53. __raw_writeb(MCF_PAR_PSC_TXD | MCF_PAR_PSC_RXD | MCF_PAR_PSC_RTS_RTS |
  54. MCF_PAR_PSC_CTS_CTS, MCFGPIO_PAR_PSC2);
  55. __raw_writeb(MCF_PAR_PSC_TXD | MCF_PAR_PSC_RXD, MCFGPIO_PAR_PSC3);
  56. }
  57. /***************************************************************************/
  58. static void mcf54xx_reset(void)
  59. {
  60. /* disable interrupts and enable the watchdog */
  61. asm("movew #0x2700, %sr\n");
  62. __raw_writel(0, MCF_GPT_GMS0);
  63. __raw_writel(MCF_GPT_GCIR_CNT(1), MCF_GPT_GCIR0);
  64. __raw_writel(MCF_GPT_GMS_WDEN | MCF_GPT_GMS_CE | MCF_GPT_GMS_TMS(4),
  65. MCF_GPT_GMS0);
  66. }
  67. /***************************************************************************/
  68. #ifdef CONFIG_MMU
  69. unsigned long num_pages;
  70. static void __init mcf54xx_bootmem_alloc(void)
  71. {
  72. unsigned long start_pfn;
  73. unsigned long memstart;
  74. /* _rambase and _ramend will be naturally page aligned */
  75. m68k_memory[0].addr = _rambase;
  76. m68k_memory[0].size = _ramend - _rambase;
  77. /* compute total pages in system */
  78. num_pages = (_ramend - _rambase) >> PAGE_SHIFT;
  79. /* page numbers */
  80. memstart = PAGE_ALIGN(_ramstart);
  81. min_low_pfn = _rambase >> PAGE_SHIFT;
  82. start_pfn = memstart >> PAGE_SHIFT;
  83. max_low_pfn = _ramend >> PAGE_SHIFT;
  84. high_memory = (void *)_ramend;
  85. m68k_virt_to_node_shift = fls(_ramend - _rambase - 1) - 6;
  86. module_fixup(NULL, __start_fixup, __stop_fixup);
  87. /* setup bootmem data */
  88. m68k_setup_node(0);
  89. memstart += init_bootmem_node(NODE_DATA(0), start_pfn,
  90. min_low_pfn, max_low_pfn);
  91. free_bootmem_node(NODE_DATA(0), memstart, _ramend - memstart);
  92. }
  93. #endif /* CONFIG_MMU */
  94. /***************************************************************************/
  95. void __init config_BSP(char *commandp, int size)
  96. {
  97. #ifdef CONFIG_MMU
  98. mcf54xx_bootmem_alloc();
  99. mmu_context_init();
  100. #endif
  101. mach_reset = mcf54xx_reset;
  102. mach_sched_init = hw_timer_init;
  103. m54xx_uarts_init();
  104. }
  105. /***************************************************************************/