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. #include <linux/pfn.h>
  26. #endif
  27. /***************************************************************************/
  28. DEFINE_CLK(pll, "pll.0", MCF_CLK);
  29. DEFINE_CLK(sys, "sys.0", MCF_BUSCLK);
  30. DEFINE_CLK(mcfslt0, "mcfslt.0", MCF_BUSCLK);
  31. DEFINE_CLK(mcfslt1, "mcfslt.1", MCF_BUSCLK);
  32. DEFINE_CLK(mcfuart0, "mcfuart.0", MCF_BUSCLK);
  33. DEFINE_CLK(mcfuart1, "mcfuart.1", MCF_BUSCLK);
  34. DEFINE_CLK(mcfuart2, "mcfuart.2", MCF_BUSCLK);
  35. DEFINE_CLK(mcfuart3, "mcfuart.3", 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. NULL
  46. };
  47. /***************************************************************************/
  48. static void __init m54xx_uarts_init(void)
  49. {
  50. /* enable io pins */
  51. __raw_writeb(MCF_PAR_PSC_TXD | MCF_PAR_PSC_RXD, MCFGPIO_PAR_PSC0);
  52. __raw_writeb(MCF_PAR_PSC_TXD | MCF_PAR_PSC_RXD | MCF_PAR_PSC_RTS_RTS,
  53. MCFGPIO_PAR_PSC1);
  54. __raw_writeb(MCF_PAR_PSC_TXD | MCF_PAR_PSC_RXD | MCF_PAR_PSC_RTS_RTS |
  55. MCF_PAR_PSC_CTS_CTS, MCFGPIO_PAR_PSC2);
  56. __raw_writeb(MCF_PAR_PSC_TXD | MCF_PAR_PSC_RXD, MCFGPIO_PAR_PSC3);
  57. }
  58. /***************************************************************************/
  59. static void mcf54xx_reset(void)
  60. {
  61. /* disable interrupts and enable the watchdog */
  62. asm("movew #0x2700, %sr\n");
  63. __raw_writel(0, MCF_GPT_GMS0);
  64. __raw_writel(MCF_GPT_GCIR_CNT(1), MCF_GPT_GCIR0);
  65. __raw_writel(MCF_GPT_GMS_WDEN | MCF_GPT_GMS_CE | MCF_GPT_GMS_TMS(4),
  66. MCF_GPT_GMS0);
  67. }
  68. /***************************************************************************/
  69. #ifdef CONFIG_MMU
  70. unsigned long num_pages;
  71. static void __init mcf54xx_bootmem_alloc(void)
  72. {
  73. unsigned long start_pfn;
  74. unsigned long memstart;
  75. /* _rambase and _ramend will be naturally page aligned */
  76. m68k_memory[0].addr = _rambase;
  77. m68k_memory[0].size = _ramend - _rambase;
  78. /* compute total pages in system */
  79. num_pages = PFN_DOWN(_ramend - _rambase);
  80. /* page numbers */
  81. memstart = PAGE_ALIGN(_ramstart);
  82. min_low_pfn = PFN_DOWN(_rambase);
  83. start_pfn = PFN_DOWN(memstart);
  84. max_pfn = max_low_pfn = PFN_DOWN(_ramend);
  85. high_memory = (void *)_ramend;
  86. m68k_virt_to_node_shift = fls(_ramend - _rambase - 1) - 6;
  87. module_fixup(NULL, __start_fixup, __stop_fixup);
  88. /* setup bootmem data */
  89. m68k_setup_node(0);
  90. memstart += init_bootmem_node(NODE_DATA(0), start_pfn,
  91. min_low_pfn, max_low_pfn);
  92. free_bootmem_node(NODE_DATA(0), memstart, _ramend - memstart);
  93. }
  94. #endif /* CONFIG_MMU */
  95. /***************************************************************************/
  96. void __init config_BSP(char *commandp, int size)
  97. {
  98. #ifdef CONFIG_MMU
  99. mcf54xx_bootmem_alloc();
  100. mmu_context_init();
  101. #endif
  102. mach_reset = mcf54xx_reset;
  103. mach_sched_init = hw_timer_init;
  104. m54xx_uarts_init();
  105. }
  106. /***************************************************************************/