Philippe De Muyter | ea49f8ff | 2010-09-20 13:11:11 +0200 | [diff] [blame] | 1 | /***************************************************************************/ |
| 2 | |
| 3 | /* |
Greg Ungerer | ece9ae6 | 2014-08-19 11:55:24 +1000 | [diff] [blame] | 4 | * m54xx.c -- platform support for ColdFire 54xx based boards |
Philippe De Muyter | ea49f8ff | 2010-09-20 13:11:11 +0200 | [diff] [blame] | 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> |
Greg Ungerer | 88be351 | 2011-10-14 15:06:22 +1000 | [diff] [blame] | 16 | #include <linux/mm.h> |
Greg Ungerer | 98122d7 | 2012-07-13 16:07:15 +1000 | [diff] [blame] | 17 | #include <linux/clk.h> |
Greg Ungerer | 88be351 | 2011-10-14 15:06:22 +1000 | [diff] [blame] | 18 | #include <linux/bootmem.h> |
| 19 | #include <asm/pgalloc.h> |
Philippe De Muyter | ea49f8ff | 2010-09-20 13:11:11 +0200 | [diff] [blame] | 20 | #include <asm/machdep.h> |
| 21 | #include <asm/coldfire.h> |
Greg Ungerer | 5b2e655 | 2010-11-02 12:05:29 +1000 | [diff] [blame] | 22 | #include <asm/m54xxsim.h> |
Philippe De Muyter | ea49f8ff | 2010-09-20 13:11:11 +0200 | [diff] [blame] | 23 | #include <asm/mcfuart.h> |
Greg Ungerer | 98122d7 | 2012-07-13 16:07:15 +1000 | [diff] [blame] | 24 | #include <asm/mcfclk.h> |
Greg Ungerer | 5b2e655 | 2010-11-02 12:05:29 +1000 | [diff] [blame] | 25 | #include <asm/m54xxgpt.h> |
Greg Ungerer | 88be351 | 2011-10-14 15:06:22 +1000 | [diff] [blame] | 26 | #ifdef CONFIG_MMU |
| 27 | #include <asm/mmu_context.h> |
Alexander Kuleshov | 50e48bd | 2015-08-12 13:14:59 +0600 | [diff] [blame] | 28 | #include <linux/pfn.h> |
Greg Ungerer | 88be351 | 2011-10-14 15:06:22 +1000 | [diff] [blame] | 29 | #endif |
Philippe De Muyter | ea49f8ff | 2010-09-20 13:11:11 +0200 | [diff] [blame] | 30 | |
| 31 | /***************************************************************************/ |
| 32 | |
Greg Ungerer | 98122d7 | 2012-07-13 16:07:15 +1000 | [diff] [blame] | 33 | DEFINE_CLK(pll, "pll.0", MCF_CLK); |
| 34 | DEFINE_CLK(sys, "sys.0", MCF_BUSCLK); |
| 35 | DEFINE_CLK(mcfslt0, "mcfslt.0", MCF_BUSCLK); |
| 36 | DEFINE_CLK(mcfslt1, "mcfslt.1", MCF_BUSCLK); |
| 37 | DEFINE_CLK(mcfuart0, "mcfuart.0", MCF_BUSCLK); |
| 38 | DEFINE_CLK(mcfuart1, "mcfuart.1", MCF_BUSCLK); |
| 39 | DEFINE_CLK(mcfuart2, "mcfuart.2", MCF_BUSCLK); |
| 40 | DEFINE_CLK(mcfuart3, "mcfuart.3", MCF_BUSCLK); |
| 41 | |
| 42 | struct clk *mcf_clks[] = { |
| 43 | &clk_pll, |
| 44 | &clk_sys, |
| 45 | &clk_mcfslt0, |
| 46 | &clk_mcfslt1, |
| 47 | &clk_mcfuart0, |
| 48 | &clk_mcfuart1, |
| 49 | &clk_mcfuart2, |
| 50 | &clk_mcfuart3, |
| 51 | NULL |
| 52 | }; |
| 53 | |
| 54 | /***************************************************************************/ |
| 55 | |
Greg Ungerer | 5b2e655 | 2010-11-02 12:05:29 +1000 | [diff] [blame] | 56 | static void __init m54xx_uarts_init(void) |
Philippe De Muyter | ea49f8ff | 2010-09-20 13:11:11 +0200 | [diff] [blame] | 57 | { |
Greg Ungerer | b9a0c3f | 2011-12-24 01:08:47 +1000 | [diff] [blame] | 58 | /* enable io pins */ |
Greg Ungerer | 632306f | 2012-09-18 14:34:04 +1000 | [diff] [blame] | 59 | __raw_writeb(MCF_PAR_PSC_TXD | MCF_PAR_PSC_RXD, MCFGPIO_PAR_PSC0); |
Greg Ungerer | b9a0c3f | 2011-12-24 01:08:47 +1000 | [diff] [blame] | 60 | __raw_writeb(MCF_PAR_PSC_TXD | MCF_PAR_PSC_RXD | MCF_PAR_PSC_RTS_RTS, |
Greg Ungerer | 632306f | 2012-09-18 14:34:04 +1000 | [diff] [blame] | 61 | MCFGPIO_PAR_PSC1); |
Greg Ungerer | b9a0c3f | 2011-12-24 01:08:47 +1000 | [diff] [blame] | 62 | __raw_writeb(MCF_PAR_PSC_TXD | MCF_PAR_PSC_RXD | MCF_PAR_PSC_RTS_RTS | |
Greg Ungerer | 632306f | 2012-09-18 14:34:04 +1000 | [diff] [blame] | 63 | MCF_PAR_PSC_CTS_CTS, MCFGPIO_PAR_PSC2); |
| 64 | __raw_writeb(MCF_PAR_PSC_TXD | MCF_PAR_PSC_RXD, MCFGPIO_PAR_PSC3); |
Philippe De Muyter | ea49f8ff | 2010-09-20 13:11:11 +0200 | [diff] [blame] | 65 | } |
| 66 | |
| 67 | /***************************************************************************/ |
| 68 | |
Greg Ungerer | 5b2e655 | 2010-11-02 12:05:29 +1000 | [diff] [blame] | 69 | static void mcf54xx_reset(void) |
Philippe De Muyter | ea49f8ff | 2010-09-20 13:11:11 +0200 | [diff] [blame] | 70 | { |
| 71 | /* disable interrupts and enable the watchdog */ |
| 72 | asm("movew #0x2700, %sr\n"); |
Greg Ungerer | 944c3d8 | 2012-09-18 14:51:46 +1000 | [diff] [blame] | 73 | __raw_writel(0, MCF_GPT_GMS0); |
| 74 | __raw_writel(MCF_GPT_GCIR_CNT(1), MCF_GPT_GCIR0); |
Philippe De Muyter | ea49f8ff | 2010-09-20 13:11:11 +0200 | [diff] [blame] | 75 | __raw_writel(MCF_GPT_GMS_WDEN | MCF_GPT_GMS_CE | MCF_GPT_GMS_TMS(4), |
Greg Ungerer | 944c3d8 | 2012-09-18 14:51:46 +1000 | [diff] [blame] | 76 | MCF_GPT_GMS0); |
Philippe De Muyter | ea49f8ff | 2010-09-20 13:11:11 +0200 | [diff] [blame] | 77 | } |
| 78 | |
| 79 | /***************************************************************************/ |
| 80 | |
Greg Ungerer | 88be351 | 2011-10-14 15:06:22 +1000 | [diff] [blame] | 81 | #ifdef CONFIG_MMU |
| 82 | |
| 83 | unsigned long num_pages; |
| 84 | |
| 85 | static 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 */ |
Alexander Kuleshov | 50e48bd | 2015-08-12 13:14:59 +0600 | [diff] [blame] | 95 | num_pages = PFN_DOWN(_ramend - _rambase); |
Greg Ungerer | 88be351 | 2011-10-14 15:06:22 +1000 | [diff] [blame] | 96 | |
| 97 | /* page numbers */ |
| 98 | memstart = PAGE_ALIGN(_ramstart); |
Alexander Kuleshov | 50e48bd | 2015-08-12 13:14:59 +0600 | [diff] [blame] | 99 | min_low_pfn = PFN_DOWN(_rambase); |
| 100 | start_pfn = PFN_DOWN(memstart); |
| 101 | max_low_pfn = PFN_DOWN(_ramend); |
Greg Ungerer | 88be351 | 2011-10-14 15:06:22 +1000 | [diff] [blame] | 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 | |
Philippe De Muyter | ea49f8ff | 2010-09-20 13:11:11 +0200 | [diff] [blame] | 118 | void __init config_BSP(char *commandp, int size) |
| 119 | { |
Greg Ungerer | 88be351 | 2011-10-14 15:06:22 +1000 | [diff] [blame] | 120 | #ifdef CONFIG_MMU |
| 121 | mcf54xx_bootmem_alloc(); |
| 122 | mmu_context_init(); |
| 123 | #endif |
Greg Ungerer | 5b2e655 | 2010-11-02 12:05:29 +1000 | [diff] [blame] | 124 | mach_reset = mcf54xx_reset; |
Greg Ungerer | 35aefb2 | 2012-01-23 15:34:58 +1000 | [diff] [blame] | 125 | mach_sched_init = hw_timer_init; |
Greg Ungerer | 5b2e655 | 2010-11-02 12:05:29 +1000 | [diff] [blame] | 126 | m54xx_uarts_init(); |
Philippe De Muyter | ea49f8ff | 2010-09-20 13:11:11 +0200 | [diff] [blame] | 127 | } |
| 128 | |
| 129 | /***************************************************************************/ |