blob: 20672dadb25276c4c629ad4bf5516b9a6a4ce396 [file] [log] [blame]
Philippe De Muyterea49f8ff2010-09-20 13:11:11 +02001/***************************************************************************/
2
3/*
Greg Ungerer5b2e6552010-11-02 12:05:29 +10004 * linux/arch/m68knommu/platform/54xx/config.c
Philippe De Muyterea49f8ff2010-09-20 13:11:11 +02005 *
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 Ungerer88be3512011-10-14 15:06:22 +100016#include <linux/mm.h>
17#include <linux/bootmem.h>
18#include <asm/pgalloc.h>
Philippe De Muyterea49f8ff2010-09-20 13:11:11 +020019#include <asm/machdep.h>
20#include <asm/coldfire.h>
Greg Ungerer5b2e6552010-11-02 12:05:29 +100021#include <asm/m54xxsim.h>
Philippe De Muyterea49f8ff2010-09-20 13:11:11 +020022#include <asm/mcfuart.h>
Greg Ungerer5b2e6552010-11-02 12:05:29 +100023#include <asm/m54xxgpt.h>
Greg Ungererf23c1442012-04-17 13:25:38 +100024#include <asm/mcfgpio.h>
Greg Ungerer88be3512011-10-14 15:06:22 +100025#ifdef CONFIG_MMU
26#include <asm/mmu_context.h>
27#endif
Philippe De Muyterea49f8ff2010-09-20 13:11:11 +020028
29/***************************************************************************/
30
Greg Ungererf23c1442012-04-17 13:25:38 +100031struct mcf_gpio_chip mcf_gpio_chips[] = { };
32
33unsigned int mcf_gpio_chips_size = ARRAY_SIZE(mcf_gpio_chips);
34
35/***************************************************************************/
36
Greg Ungerer5b2e6552010-11-02 12:05:29 +100037static void __init m54xx_uarts_init(void)
Philippe De Muyterea49f8ff2010-09-20 13:11:11 +020038{
Greg Ungererb9a0c3f2011-12-24 01:08:47 +100039 /* enable io pins */
40 __raw_writeb(MCF_PAR_PSC_TXD | MCF_PAR_PSC_RXD,
41 MCF_MBAR + MCF_PAR_PSC(0));
42 __raw_writeb(MCF_PAR_PSC_TXD | MCF_PAR_PSC_RXD | MCF_PAR_PSC_RTS_RTS,
43 MCF_MBAR + MCF_PAR_PSC(1));
44 __raw_writeb(MCF_PAR_PSC_TXD | MCF_PAR_PSC_RXD | MCF_PAR_PSC_RTS_RTS |
45 MCF_PAR_PSC_CTS_CTS, MCF_MBAR + MCF_PAR_PSC(2));
46 __raw_writeb(MCF_PAR_PSC_TXD | MCF_PAR_PSC_RXD,
47 MCF_MBAR + MCF_PAR_PSC(3));
Philippe De Muyterea49f8ff2010-09-20 13:11:11 +020048}
49
50/***************************************************************************/
51
Greg Ungerer5b2e6552010-11-02 12:05:29 +100052static void mcf54xx_reset(void)
Philippe De Muyterea49f8ff2010-09-20 13:11:11 +020053{
54 /* disable interrupts and enable the watchdog */
55 asm("movew #0x2700, %sr\n");
56 __raw_writel(0, MCF_MBAR + MCF_GPT_GMS0);
57 __raw_writel(MCF_GPT_GCIR_CNT(1), MCF_MBAR + MCF_GPT_GCIR0);
58 __raw_writel(MCF_GPT_GMS_WDEN | MCF_GPT_GMS_CE | MCF_GPT_GMS_TMS(4),
59 MCF_MBAR + MCF_GPT_GMS0);
60}
61
62/***************************************************************************/
63
Greg Ungerer88be3512011-10-14 15:06:22 +100064#ifdef CONFIG_MMU
65
66unsigned long num_pages;
67
68static void __init mcf54xx_bootmem_alloc(void)
69{
70 unsigned long start_pfn;
71 unsigned long memstart;
72
73 /* _rambase and _ramend will be naturally page aligned */
74 m68k_memory[0].addr = _rambase;
75 m68k_memory[0].size = _ramend - _rambase;
76
77 /* compute total pages in system */
78 num_pages = (_ramend - _rambase) >> PAGE_SHIFT;
79
80 /* page numbers */
81 memstart = PAGE_ALIGN(_ramstart);
82 min_low_pfn = _rambase >> PAGE_SHIFT;
83 start_pfn = memstart >> PAGE_SHIFT;
84 max_low_pfn = _ramend >> PAGE_SHIFT;
85 high_memory = (void *)_ramend;
86
87 m68k_virt_to_node_shift = fls(_ramend - _rambase - 1) - 6;
88 module_fixup(NULL, __start_fixup, __stop_fixup);
89
90 /* setup bootmem data */
91 m68k_setup_node(0);
92 memstart += init_bootmem_node(NODE_DATA(0), start_pfn,
93 min_low_pfn, max_low_pfn);
94 free_bootmem_node(NODE_DATA(0), memstart, _ramend - memstart);
95}
96
97#endif /* CONFIG_MMU */
98
99/***************************************************************************/
100
Philippe De Muyterea49f8ff2010-09-20 13:11:11 +0200101void __init config_BSP(char *commandp, int size)
102{
Greg Ungerer88be3512011-10-14 15:06:22 +1000103#ifdef CONFIG_MMU
104 mcf54xx_bootmem_alloc();
105 mmu_context_init();
106#endif
Greg Ungerer5b2e6552010-11-02 12:05:29 +1000107 mach_reset = mcf54xx_reset;
Greg Ungerer35aefb22012-01-23 15:34:58 +1000108 mach_sched_init = hw_timer_init;
Greg Ungerer5b2e6552010-11-02 12:05:29 +1000109 m54xx_uarts_init();
Philippe De Muyterea49f8ff2010-09-20 13:11:11 +0200110}
111
112/***************************************************************************/