config.c 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. /***************************************************************************/
  2. /*
  3. * linux/arch/m68knommu/platform/54xx/config.c
  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/bootmem.h>
  15. #include <asm/pgalloc.h>
  16. #include <asm/machdep.h>
  17. #include <asm/coldfire.h>
  18. #include <asm/m54xxsim.h>
  19. #include <asm/mcfuart.h>
  20. #include <asm/m54xxgpt.h>
  21. #ifdef CONFIG_MMU
  22. #include <asm/mmu_context.h>
  23. #endif
  24. /***************************************************************************/
  25. static void __init m54xx_uarts_init(void)
  26. {
  27. /* enable io pins */
  28. __raw_writeb(MCF_PAR_PSC_TXD | MCF_PAR_PSC_RXD,
  29. MCF_MBAR + MCF_PAR_PSC(0));
  30. __raw_writeb(MCF_PAR_PSC_TXD | MCF_PAR_PSC_RXD | MCF_PAR_PSC_RTS_RTS,
  31. MCF_MBAR + MCF_PAR_PSC(1));
  32. __raw_writeb(MCF_PAR_PSC_TXD | MCF_PAR_PSC_RXD | MCF_PAR_PSC_RTS_RTS |
  33. MCF_PAR_PSC_CTS_CTS, MCF_MBAR + MCF_PAR_PSC(2));
  34. __raw_writeb(MCF_PAR_PSC_TXD | MCF_PAR_PSC_RXD,
  35. MCF_MBAR + MCF_PAR_PSC(3));
  36. }
  37. /***************************************************************************/
  38. static void mcf54xx_reset(void)
  39. {
  40. /* disable interrupts and enable the watchdog */
  41. asm("movew #0x2700, %sr\n");
  42. __raw_writel(0, MCF_MBAR + MCF_GPT_GMS0);
  43. __raw_writel(MCF_GPT_GCIR_CNT(1), MCF_MBAR + MCF_GPT_GCIR0);
  44. __raw_writel(MCF_GPT_GMS_WDEN | MCF_GPT_GMS_CE | MCF_GPT_GMS_TMS(4),
  45. MCF_MBAR + MCF_GPT_GMS0);
  46. }
  47. /***************************************************************************/
  48. #ifdef CONFIG_MMU
  49. unsigned long num_pages;
  50. static void __init mcf54xx_bootmem_alloc(void)
  51. {
  52. unsigned long start_pfn;
  53. unsigned long memstart;
  54. /* _rambase and _ramend will be naturally page aligned */
  55. m68k_memory[0].addr = _rambase;
  56. m68k_memory[0].size = _ramend - _rambase;
  57. /* compute total pages in system */
  58. num_pages = (_ramend - _rambase) >> PAGE_SHIFT;
  59. /* page numbers */
  60. memstart = PAGE_ALIGN(_ramstart);
  61. min_low_pfn = _rambase >> PAGE_SHIFT;
  62. start_pfn = memstart >> PAGE_SHIFT;
  63. max_low_pfn = _ramend >> PAGE_SHIFT;
  64. high_memory = (void *)_ramend;
  65. m68k_virt_to_node_shift = fls(_ramend - _rambase - 1) - 6;
  66. module_fixup(NULL, __start_fixup, __stop_fixup);
  67. /* setup bootmem data */
  68. m68k_setup_node(0);
  69. memstart += init_bootmem_node(NODE_DATA(0), start_pfn,
  70. min_low_pfn, max_low_pfn);
  71. free_bootmem_node(NODE_DATA(0), memstart, _ramend - memstart);
  72. }
  73. #endif /* CONFIG_MMU */
  74. /***************************************************************************/
  75. void __init config_BSP(char *commandp, int size)
  76. {
  77. #ifdef CONFIG_MMU
  78. mcf54xx_bootmem_alloc();
  79. mmu_context_init();
  80. #endif
  81. mach_reset = mcf54xx_reset;
  82. mach_sched_init = hw_timer_init;
  83. m54xx_uarts_init();
  84. }
  85. /***************************************************************************/