m54xx.c 3.1 KB

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