Skip to content

Commit

Permalink
m68k: move ColdFire _bootmem_alloc code
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Greg Ungerer committed Sep 26, 2016
1 parent cbd5b98 commit f711606
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 40 deletions.
40 changes: 1 addition & 39 deletions arch/m68k/coldfire/m54xx.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
#include <asm/m54xxgpt.h>
#ifdef CONFIG_MMU
#include <asm/mmu_context.h>
#include <linux/pfn.h>
#endif

/***************************************************************************/
Expand Down Expand Up @@ -78,47 +77,10 @@ static void mcf54xx_reset(void)

/***************************************************************************/

#ifdef CONFIG_MMU

unsigned long num_pages;

static void __init mcf54xx_bootmem_alloc(void)
{
unsigned long start_pfn;
unsigned long memstart;

/* _rambase and _ramend will be naturally page aligned */
m68k_memory[0].addr = _rambase;
m68k_memory[0].size = _ramend - _rambase;

/* compute total pages in system */
num_pages = PFN_DOWN(_ramend - _rambase);

/* page numbers */
memstart = PAGE_ALIGN(_ramstart);
min_low_pfn = PFN_DOWN(_rambase);
start_pfn = PFN_DOWN(memstart);
max_pfn = max_low_pfn = PFN_DOWN(_ramend);
high_memory = (void *)_ramend;

m68k_virt_to_node_shift = fls(_ramend - _rambase - 1) - 6;
module_fixup(NULL, __start_fixup, __stop_fixup);

/* setup bootmem data */
m68k_setup_node(0);
memstart += init_bootmem_node(NODE_DATA(0), start_pfn,
min_low_pfn, max_low_pfn);
free_bootmem_node(NODE_DATA(0), memstart, _ramend - memstart);
}

#endif /* CONFIG_MMU */

/***************************************************************************/

void __init config_BSP(char *commandp, int size)
{
#ifdef CONFIG_MMU
mcf54xx_bootmem_alloc();
cf_bootmem_alloc();
mmu_context_init();
#endif
mach_reset = mcf54xx_reset;
Expand Down
1 change: 1 addition & 0 deletions arch/m68k/include/asm/mcfmmu.h
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ static inline void mmu_write(u32 a, u32 v)
__asm__ __volatile__ ("nop");
}

void cf_bootmem_alloc(void);
int cf_tlb_miss(struct pt_regs *regs, int write, int dtlb, int extension_word);

#endif
Expand Down
31 changes: 30 additions & 1 deletion arch/m68k/mm/mcfmmu.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ mm_context_t next_mmu_context;
unsigned long context_map[LAST_CONTEXT / BITS_PER_LONG + 1];
atomic_t nr_free_contexts;
struct mm_struct *context_mm[LAST_CONTEXT+1];
extern unsigned long num_pages;
unsigned long num_pages;

/*
* ColdFire paging_init derived from sun3.
Expand Down Expand Up @@ -150,6 +150,35 @@ int cf_tlb_miss(struct pt_regs *regs, int write, int dtlb, int extension_word)
return 0;
}

void __init cf_bootmem_alloc(void)
{
unsigned long start_pfn;
unsigned long memstart;

/* _rambase and _ramend will be naturally page aligned */
m68k_memory[0].addr = _rambase;
m68k_memory[0].size = _ramend - _rambase;

/* compute total pages in system */
num_pages = PFN_DOWN(_ramend - _rambase);

/* page numbers */
memstart = PAGE_ALIGN(_ramstart);
min_low_pfn = PFN_DOWN(_rambase);
start_pfn = PFN_DOWN(memstart);
max_pfn = max_low_pfn = PFN_DOWN(_ramend);
high_memory = (void *)_ramend;

m68k_virt_to_node_shift = fls(_ramend - _rambase - 1) - 6;
module_fixup(NULL, __start_fixup, __stop_fixup);

/* setup bootmem data */
m68k_setup_node(0);
memstart += init_bootmem_node(NODE_DATA(0), start_pfn,
min_low_pfn, max_low_pfn);
free_bootmem_node(NODE_DATA(0), memstart, _ramend - memstart);
}

/*
* Initialize the context management stuff.
* The following was taken from arch/ppc/mmu_context.c
Expand Down

0 comments on commit f711606

Please sign in to comment.