• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /***************************************************************************/
2 
3 /*
4  *	linux/arch/m68knommu/platform/54xx/config.c
5  *
6  *	Copyright (C) 2010, Philippe De Muyter <phdm@macqel.be>
7  */
8 
9 /***************************************************************************/
10 
11 #include <linux/kernel.h>
12 #include <linux/param.h>
13 #include <linux/init.h>
14 #include <linux/interrupt.h>
15 #include <linux/io.h>
16 #include <linux/mm.h>
17 #include <linux/bootmem.h>
18 #include <asm/pgalloc.h>
19 #include <asm/machdep.h>
20 #include <asm/coldfire.h>
21 #include <asm/m54xxsim.h>
22 #include <asm/mcfuart.h>
23 #include <asm/m54xxgpt.h>
24 #ifdef CONFIG_MMU
25 #include <asm/mmu_context.h>
26 #endif
27 
28 /***************************************************************************/
29 
m54xx_uarts_init(void)30 static void __init m54xx_uarts_init(void)
31 {
32 	/* enable io pins */
33 	__raw_writeb(MCF_PAR_PSC_TXD | MCF_PAR_PSC_RXD,
34 		MCF_MBAR + MCF_PAR_PSC(0));
35 	__raw_writeb(MCF_PAR_PSC_TXD | MCF_PAR_PSC_RXD | MCF_PAR_PSC_RTS_RTS,
36 		MCF_MBAR + MCF_PAR_PSC(1));
37 	__raw_writeb(MCF_PAR_PSC_TXD | MCF_PAR_PSC_RXD | MCF_PAR_PSC_RTS_RTS |
38 		MCF_PAR_PSC_CTS_CTS, MCF_MBAR + MCF_PAR_PSC(2));
39 	__raw_writeb(MCF_PAR_PSC_TXD | MCF_PAR_PSC_RXD,
40 		MCF_MBAR + MCF_PAR_PSC(3));
41 }
42 
43 /***************************************************************************/
44 
mcf54xx_reset(void)45 static void mcf54xx_reset(void)
46 {
47 	/* disable interrupts and enable the watchdog */
48 	asm("movew #0x2700, %sr\n");
49 	__raw_writel(0, MCF_MBAR + MCF_GPT_GMS0);
50 	__raw_writel(MCF_GPT_GCIR_CNT(1), MCF_MBAR + MCF_GPT_GCIR0);
51 	__raw_writel(MCF_GPT_GMS_WDEN | MCF_GPT_GMS_CE | MCF_GPT_GMS_TMS(4),
52 						MCF_MBAR + MCF_GPT_GMS0);
53 }
54 
55 /***************************************************************************/
56 
57 #ifdef CONFIG_MMU
58 
59 unsigned long num_pages;
60 
mcf54xx_bootmem_alloc(void)61 static void __init mcf54xx_bootmem_alloc(void)
62 {
63 	unsigned long start_pfn;
64 	unsigned long memstart;
65 
66 	/* _rambase and _ramend will be naturally page aligned */
67 	m68k_memory[0].addr = _rambase;
68 	m68k_memory[0].size = _ramend - _rambase;
69 
70 	/* compute total pages in system */
71 	num_pages = (_ramend - _rambase) >> PAGE_SHIFT;
72 
73 	/* page numbers */
74 	memstart = PAGE_ALIGN(_ramstart);
75 	min_low_pfn = _rambase >> PAGE_SHIFT;
76 	start_pfn = memstart >> PAGE_SHIFT;
77 	max_low_pfn = _ramend >> PAGE_SHIFT;
78 	high_memory = (void *)_ramend;
79 
80 	m68k_virt_to_node_shift = fls(_ramend - _rambase - 1) - 6;
81 	module_fixup(NULL, __start_fixup, __stop_fixup);
82 
83 	/* setup bootmem data */
84 	m68k_setup_node(0);
85 	memstart += init_bootmem_node(NODE_DATA(0), start_pfn,
86 		min_low_pfn, max_low_pfn);
87 	free_bootmem_node(NODE_DATA(0), memstart, _ramend - memstart);
88 }
89 
90 #endif /* CONFIG_MMU */
91 
92 /***************************************************************************/
93 
config_BSP(char * commandp,int size)94 void __init config_BSP(char *commandp, int size)
95 {
96 #ifdef CONFIG_MMU
97 	mcf54xx_bootmem_alloc();
98 	mmu_context_init();
99 #endif
100 	mach_reset = mcf54xx_reset;
101 	mach_sched_init = hw_timer_init;
102 	m54xx_uarts_init();
103 }
104 
105 /***************************************************************************/
106