aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGreg Ungerer <gerg@linux-m68k.org>2016-08-26 00:24:27 -0400
committerGreg Ungerer <gerg@linux-m68k.org>2016-09-25 22:02:58 -0400
commitf71160655d1efda10081482c486481f2108abca5 (patch)
tree9188556e282d838a45e893decca762fb6f07bd7b
parentcbd5b982f6a1540ebb0144774d64381e7b2d39fd (diff)
m68k: move ColdFire _bootmem_alloc code
The early ColdFire bootmem_alloc() code is currently only included in the board support for the Coldire 54xx platforms. It will be used on all ColdFire MMU enabled platforms as others are supported. So move the mcf54xx_bootmem_alloc() function to be generally available to all MMU enabled ColdFire parts (and use a more generic name for it). Signed-off-by: Greg Ungerer <gerg@linux-m68k.org>
-rw-r--r--arch/m68k/coldfire/m54xx.c40
-rw-r--r--arch/m68k/include/asm/mcfmmu.h1
-rw-r--r--arch/m68k/mm/mcfmmu.c31
3 files changed, 32 insertions, 40 deletions
diff --git a/arch/m68k/coldfire/m54xx.c b/arch/m68k/coldfire/m54xx.c
index c32f76791f48..386df3b68cdf 100644
--- a/arch/m68k/coldfire/m54xx.c
+++ b/arch/m68k/coldfire/m54xx.c
@@ -25,7 +25,6 @@
25#include <asm/m54xxgpt.h> 25#include <asm/m54xxgpt.h>
26#ifdef CONFIG_MMU 26#ifdef CONFIG_MMU
27#include <asm/mmu_context.h> 27#include <asm/mmu_context.h>
28#include <linux/pfn.h>
29#endif 28#endif
30 29
31/***************************************************************************/ 30/***************************************************************************/
@@ -78,47 +77,10 @@ static void mcf54xx_reset(void)
78 77
79/***************************************************************************/ 78/***************************************************************************/
80 79
81#ifdef CONFIG_MMU
82
83unsigned long num_pages;
84
85static void __init mcf54xx_bootmem_alloc(void)
86{
87 unsigned long start_pfn;
88 unsigned long memstart;
89
90 /* _rambase and _ramend will be naturally page aligned */
91 m68k_memory[0].addr = _rambase;
92 m68k_memory[0].size = _ramend - _rambase;
93
94 /* compute total pages in system */
95 num_pages = PFN_DOWN(_ramend - _rambase);
96
97 /* page numbers */
98 memstart = PAGE_ALIGN(_ramstart);
99 min_low_pfn = PFN_DOWN(_rambase);
100 start_pfn = PFN_DOWN(memstart);
101 max_pfn = max_low_pfn = PFN_DOWN(_ramend);
102 high_memory = (void *)_ramend;
103
104 m68k_virt_to_node_shift = fls(_ramend - _rambase - 1) - 6;
105 module_fixup(NULL, __start_fixup, __stop_fixup);
106
107 /* setup bootmem data */
108 m68k_setup_node(0);
109 memstart += init_bootmem_node(NODE_DATA(0), start_pfn,
110 min_low_pfn, max_low_pfn);
111 free_bootmem_node(NODE_DATA(0), memstart, _ramend - memstart);
112}
113
114#endif /* CONFIG_MMU */
115
116/***************************************************************************/
117
118void __init config_BSP(char *commandp, int size) 80void __init config_BSP(char *commandp, int size)
119{ 81{
120#ifdef CONFIG_MMU 82#ifdef CONFIG_MMU
121 mcf54xx_bootmem_alloc(); 83 cf_bootmem_alloc();
122 mmu_context_init(); 84 mmu_context_init();
123#endif 85#endif
124 mach_reset = mcf54xx_reset; 86 mach_reset = mcf54xx_reset;
diff --git a/arch/m68k/include/asm/mcfmmu.h b/arch/m68k/include/asm/mcfmmu.h
index 8824236e303f..10f9930ec49a 100644
--- a/arch/m68k/include/asm/mcfmmu.h
+++ b/arch/m68k/include/asm/mcfmmu.h
@@ -105,6 +105,7 @@ static inline void mmu_write(u32 a, u32 v)
105 __asm__ __volatile__ ("nop"); 105 __asm__ __volatile__ ("nop");
106} 106}
107 107
108void cf_bootmem_alloc(void);
108int cf_tlb_miss(struct pt_regs *regs, int write, int dtlb, int extension_word); 109int cf_tlb_miss(struct pt_regs *regs, int write, int dtlb, int extension_word);
109 110
110#endif 111#endif
diff --git a/arch/m68k/mm/mcfmmu.c b/arch/m68k/mm/mcfmmu.c
index f58fafe7e4c9..87131cd3bc8f 100644
--- a/arch/m68k/mm/mcfmmu.c
+++ b/arch/m68k/mm/mcfmmu.c
@@ -27,7 +27,7 @@ mm_context_t next_mmu_context;
27unsigned long context_map[LAST_CONTEXT / BITS_PER_LONG + 1]; 27unsigned long context_map[LAST_CONTEXT / BITS_PER_LONG + 1];
28atomic_t nr_free_contexts; 28atomic_t nr_free_contexts;
29struct mm_struct *context_mm[LAST_CONTEXT+1]; 29struct mm_struct *context_mm[LAST_CONTEXT+1];
30extern unsigned long num_pages; 30unsigned long num_pages;
31 31
32/* 32/*
33 * ColdFire paging_init derived from sun3. 33 * ColdFire paging_init derived from sun3.
@@ -150,6 +150,35 @@ int cf_tlb_miss(struct pt_regs *regs, int write, int dtlb, int extension_word)
150 return 0; 150 return 0;
151} 151}
152 152
153void __init cf_bootmem_alloc(void)
154{
155 unsigned long start_pfn;
156 unsigned long memstart;
157
158 /* _rambase and _ramend will be naturally page aligned */
159 m68k_memory[0].addr = _rambase;
160 m68k_memory[0].size = _ramend - _rambase;
161
162 /* compute total pages in system */
163 num_pages = PFN_DOWN(_ramend - _rambase);
164
165 /* page numbers */
166 memstart = PAGE_ALIGN(_ramstart);
167 min_low_pfn = PFN_DOWN(_rambase);
168 start_pfn = PFN_DOWN(memstart);
169 max_pfn = max_low_pfn = PFN_DOWN(_ramend);
170 high_memory = (void *)_ramend;
171
172 m68k_virt_to_node_shift = fls(_ramend - _rambase - 1) - 6;
173 module_fixup(NULL, __start_fixup, __stop_fixup);
174
175 /* setup bootmem data */
176 m68k_setup_node(0);
177 memstart += init_bootmem_node(NODE_DATA(0), start_pfn,
178 min_low_pfn, max_low_pfn);
179 free_bootmem_node(NODE_DATA(0), memstart, _ramend - memstart);
180}
181
153/* 182/*
154 * Initialize the context management stuff. 183 * Initialize the context management stuff.
155 * The following was taken from arch/ppc/mmu_context.c 184 * The following was taken from arch/ppc/mmu_context.c