config.c 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  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 struct mcf_platform_uart m54xx_uart_platform[] = {
  26. {
  27. .mapbase = MCF_MBAR + MCFUART_BASE1,
  28. .irq = 64 + 35,
  29. },
  30. {
  31. .mapbase = MCF_MBAR + MCFUART_BASE2,
  32. .irq = 64 + 34,
  33. },
  34. {
  35. .mapbase = MCF_MBAR + MCFUART_BASE3,
  36. .irq = 64 + 33,
  37. },
  38. {
  39. .mapbase = MCF_MBAR + MCFUART_BASE4,
  40. .irq = 64 + 32,
  41. },
  42. };
  43. static struct platform_device m54xx_uart = {
  44. .name = "mcfuart",
  45. .id = 0,
  46. .dev.platform_data = m54xx_uart_platform,
  47. };
  48. static struct platform_device *m54xx_devices[] __initdata = {
  49. &m54xx_uart,
  50. };
  51. /***************************************************************************/
  52. static void __init m54xx_uart_init_line(int line, int irq)
  53. {
  54. int rts_cts;
  55. /* enable io pins */
  56. switch (line) {
  57. case 0:
  58. rts_cts = 0; break;
  59. case 1:
  60. rts_cts = MCF_PAR_PSC_RTS_RTS; break;
  61. case 2:
  62. rts_cts = MCF_PAR_PSC_RTS_RTS | MCF_PAR_PSC_CTS_CTS; break;
  63. case 3:
  64. rts_cts = 0; break;
  65. }
  66. __raw_writeb(MCF_PAR_PSC_TXD | rts_cts | MCF_PAR_PSC_RXD,
  67. MCF_MBAR + MCF_PAR_PSC(line));
  68. }
  69. static void __init m54xx_uarts_init(void)
  70. {
  71. const int nrlines = ARRAY_SIZE(m54xx_uart_platform);
  72. int line;
  73. for (line = 0; (line < nrlines); line++)
  74. m54xx_uart_init_line(line, m54xx_uart_platform[line].irq);
  75. }
  76. /***************************************************************************/
  77. static void mcf54xx_reset(void)
  78. {
  79. /* disable interrupts and enable the watchdog */
  80. asm("movew #0x2700, %sr\n");
  81. __raw_writel(0, MCF_MBAR + MCF_GPT_GMS0);
  82. __raw_writel(MCF_GPT_GCIR_CNT(1), MCF_MBAR + MCF_GPT_GCIR0);
  83. __raw_writel(MCF_GPT_GMS_WDEN | MCF_GPT_GMS_CE | MCF_GPT_GMS_TMS(4),
  84. MCF_MBAR + MCF_GPT_GMS0);
  85. }
  86. /***************************************************************************/
  87. #ifdef CONFIG_MMU
  88. unsigned long num_pages;
  89. static void __init mcf54xx_bootmem_alloc(void)
  90. {
  91. unsigned long start_pfn;
  92. unsigned long memstart;
  93. /* _rambase and _ramend will be naturally page aligned */
  94. m68k_memory[0].addr = _rambase;
  95. m68k_memory[0].size = _ramend - _rambase;
  96. /* compute total pages in system */
  97. num_pages = (_ramend - _rambase) >> PAGE_SHIFT;
  98. /* page numbers */
  99. memstart = PAGE_ALIGN(_ramstart);
  100. min_low_pfn = _rambase >> PAGE_SHIFT;
  101. start_pfn = memstart >> PAGE_SHIFT;
  102. max_low_pfn = _ramend >> PAGE_SHIFT;
  103. high_memory = (void *)_ramend;
  104. m68k_virt_to_node_shift = fls(_ramend - _rambase - 1) - 6;
  105. module_fixup(NULL, __start_fixup, __stop_fixup);
  106. /* setup bootmem data */
  107. m68k_setup_node(0);
  108. memstart += init_bootmem_node(NODE_DATA(0), start_pfn,
  109. min_low_pfn, max_low_pfn);
  110. free_bootmem_node(NODE_DATA(0), memstart, _ramend - memstart);
  111. }
  112. #endif /* CONFIG_MMU */
  113. /***************************************************************************/
  114. void __init config_BSP(char *commandp, int size)
  115. {
  116. #ifdef CONFIG_MMU
  117. mcf54xx_bootmem_alloc();
  118. mmu_context_init();
  119. #endif
  120. mach_reset = mcf54xx_reset;
  121. m54xx_uarts_init();
  122. }
  123. /***************************************************************************/
  124. static int __init init_BSP(void)
  125. {
  126. platform_add_devices(m54xx_devices, ARRAY_SIZE(m54xx_devices));
  127. return 0;
  128. }
  129. arch_initcall(init_BSP);
  130. /***************************************************************************/