Philippe De Muyter | ea49f8ff | 2010-09-20 13:11:11 +0200 | [diff] [blame] | 1 | /***************************************************************************/ |
| 2 | |
| 3 | /* |
Greg Ungerer | 5b2e655 | 2010-11-02 12:05:29 +1000 | [diff] [blame] | 4 | * linux/arch/m68knommu/platform/54xx/config.c |
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> |
| 17 | #include <linux/bootmem.h> |
| 18 | #include <asm/pgalloc.h> |
Philippe De Muyter | ea49f8ff | 2010-09-20 13:11:11 +0200 | [diff] [blame] | 19 | #include <asm/machdep.h> |
| 20 | #include <asm/coldfire.h> |
Greg Ungerer | 5b2e655 | 2010-11-02 12:05:29 +1000 | [diff] [blame] | 21 | #include <asm/m54xxsim.h> |
Philippe De Muyter | ea49f8ff | 2010-09-20 13:11:11 +0200 | [diff] [blame] | 22 | #include <asm/mcfuart.h> |
Greg Ungerer | 5b2e655 | 2010-11-02 12:05:29 +1000 | [diff] [blame] | 23 | #include <asm/m54xxgpt.h> |
Greg Ungerer | 88be351 | 2011-10-14 15:06:22 +1000 | [diff] [blame] | 24 | #ifdef CONFIG_MMU |
| 25 | #include <asm/mmu_context.h> |
| 26 | #endif |
Philippe De Muyter | ea49f8ff | 2010-09-20 13:11:11 +0200 | [diff] [blame] | 27 | |
| 28 | /***************************************************************************/ |
| 29 | |
Greg Ungerer | 5b2e655 | 2010-11-02 12:05:29 +1000 | [diff] [blame] | 30 | static struct mcf_platform_uart m54xx_uart_platform[] = { |
Philippe De Muyter | ea49f8ff | 2010-09-20 13:11:11 +0200 | [diff] [blame] | 31 | { |
Greg Ungerer | bbbeeaf | 2011-12-24 00:46:37 +1000 | [diff] [blame] | 32 | .mapbase = MCFUART_BASE0, |
| 33 | .irq = MCF_IRQ_UART0, |
Philippe De Muyter | ea49f8ff | 2010-09-20 13:11:11 +0200 | [diff] [blame] | 34 | }, |
| 35 | { |
Greg Ungerer | bbbeeaf | 2011-12-24 00:46:37 +1000 | [diff] [blame] | 36 | .mapbase = MCFUART_BASE1, |
| 37 | .irq = MCF_IRQ_UART1, |
Philippe De Muyter | ea49f8ff | 2010-09-20 13:11:11 +0200 | [diff] [blame] | 38 | }, |
| 39 | { |
Greg Ungerer | bbbeeaf | 2011-12-24 00:46:37 +1000 | [diff] [blame] | 40 | .mapbase = MCFUART_BASE2, |
| 41 | .irq = MCF_IRQ_UART2, |
Philippe De Muyter | ea49f8ff | 2010-09-20 13:11:11 +0200 | [diff] [blame] | 42 | }, |
| 43 | { |
Greg Ungerer | bbbeeaf | 2011-12-24 00:46:37 +1000 | [diff] [blame] | 44 | .mapbase = MCFUART_BASE3, |
| 45 | .irq = MCF_IRQ_UART3, |
Philippe De Muyter | ea49f8ff | 2010-09-20 13:11:11 +0200 | [diff] [blame] | 46 | }, |
| 47 | }; |
| 48 | |
Greg Ungerer | 5b2e655 | 2010-11-02 12:05:29 +1000 | [diff] [blame] | 49 | static struct platform_device m54xx_uart = { |
Philippe De Muyter | ea49f8ff | 2010-09-20 13:11:11 +0200 | [diff] [blame] | 50 | .name = "mcfuart", |
| 51 | .id = 0, |
Greg Ungerer | 5b2e655 | 2010-11-02 12:05:29 +1000 | [diff] [blame] | 52 | .dev.platform_data = m54xx_uart_platform, |
Philippe De Muyter | ea49f8ff | 2010-09-20 13:11:11 +0200 | [diff] [blame] | 53 | }; |
| 54 | |
Greg Ungerer | 5b2e655 | 2010-11-02 12:05:29 +1000 | [diff] [blame] | 55 | static struct platform_device *m54xx_devices[] __initdata = { |
| 56 | &m54xx_uart, |
Philippe De Muyter | ea49f8ff | 2010-09-20 13:11:11 +0200 | [diff] [blame] | 57 | }; |
| 58 | |
| 59 | |
| 60 | /***************************************************************************/ |
| 61 | |
Greg Ungerer | 5b2e655 | 2010-11-02 12:05:29 +1000 | [diff] [blame] | 62 | static void __init m54xx_uart_init_line(int line, int irq) |
Philippe De Muyter | ea49f8ff | 2010-09-20 13:11:11 +0200 | [diff] [blame] | 63 | { |
| 64 | int rts_cts; |
| 65 | |
| 66 | /* enable io pins */ |
| 67 | switch (line) { |
| 68 | case 0: |
| 69 | rts_cts = 0; break; |
| 70 | case 1: |
| 71 | rts_cts = MCF_PAR_PSC_RTS_RTS; break; |
| 72 | case 2: |
| 73 | rts_cts = MCF_PAR_PSC_RTS_RTS | MCF_PAR_PSC_CTS_CTS; break; |
| 74 | case 3: |
| 75 | rts_cts = 0; break; |
| 76 | } |
| 77 | __raw_writeb(MCF_PAR_PSC_TXD | rts_cts | MCF_PAR_PSC_RXD, |
| 78 | MCF_MBAR + MCF_PAR_PSC(line)); |
| 79 | } |
| 80 | |
Greg Ungerer | 5b2e655 | 2010-11-02 12:05:29 +1000 | [diff] [blame] | 81 | static void __init m54xx_uarts_init(void) |
Philippe De Muyter | ea49f8ff | 2010-09-20 13:11:11 +0200 | [diff] [blame] | 82 | { |
Greg Ungerer | 5b2e655 | 2010-11-02 12:05:29 +1000 | [diff] [blame] | 83 | const int nrlines = ARRAY_SIZE(m54xx_uart_platform); |
Philippe De Muyter | ea49f8ff | 2010-09-20 13:11:11 +0200 | [diff] [blame] | 84 | int line; |
| 85 | |
| 86 | for (line = 0; (line < nrlines); line++) |
Greg Ungerer | 5b2e655 | 2010-11-02 12:05:29 +1000 | [diff] [blame] | 87 | m54xx_uart_init_line(line, m54xx_uart_platform[line].irq); |
Philippe De Muyter | ea49f8ff | 2010-09-20 13:11:11 +0200 | [diff] [blame] | 88 | } |
| 89 | |
| 90 | /***************************************************************************/ |
| 91 | |
Greg Ungerer | 5b2e655 | 2010-11-02 12:05:29 +1000 | [diff] [blame] | 92 | static void mcf54xx_reset(void) |
Philippe De Muyter | ea49f8ff | 2010-09-20 13:11:11 +0200 | [diff] [blame] | 93 | { |
| 94 | /* disable interrupts and enable the watchdog */ |
| 95 | asm("movew #0x2700, %sr\n"); |
| 96 | __raw_writel(0, MCF_MBAR + MCF_GPT_GMS0); |
| 97 | __raw_writel(MCF_GPT_GCIR_CNT(1), MCF_MBAR + MCF_GPT_GCIR0); |
| 98 | __raw_writel(MCF_GPT_GMS_WDEN | MCF_GPT_GMS_CE | MCF_GPT_GMS_TMS(4), |
| 99 | MCF_MBAR + MCF_GPT_GMS0); |
| 100 | } |
| 101 | |
| 102 | /***************************************************************************/ |
| 103 | |
Greg Ungerer | 88be351 | 2011-10-14 15:06:22 +1000 | [diff] [blame] | 104 | #ifdef CONFIG_MMU |
| 105 | |
| 106 | unsigned long num_pages; |
| 107 | |
| 108 | static void __init mcf54xx_bootmem_alloc(void) |
| 109 | { |
| 110 | unsigned long start_pfn; |
| 111 | unsigned long memstart; |
| 112 | |
| 113 | /* _rambase and _ramend will be naturally page aligned */ |
| 114 | m68k_memory[0].addr = _rambase; |
| 115 | m68k_memory[0].size = _ramend - _rambase; |
| 116 | |
| 117 | /* compute total pages in system */ |
| 118 | num_pages = (_ramend - _rambase) >> PAGE_SHIFT; |
| 119 | |
| 120 | /* page numbers */ |
| 121 | memstart = PAGE_ALIGN(_ramstart); |
| 122 | min_low_pfn = _rambase >> PAGE_SHIFT; |
| 123 | start_pfn = memstart >> PAGE_SHIFT; |
| 124 | max_low_pfn = _ramend >> PAGE_SHIFT; |
| 125 | high_memory = (void *)_ramend; |
| 126 | |
| 127 | m68k_virt_to_node_shift = fls(_ramend - _rambase - 1) - 6; |
| 128 | module_fixup(NULL, __start_fixup, __stop_fixup); |
| 129 | |
| 130 | /* setup bootmem data */ |
| 131 | m68k_setup_node(0); |
| 132 | memstart += init_bootmem_node(NODE_DATA(0), start_pfn, |
| 133 | min_low_pfn, max_low_pfn); |
| 134 | free_bootmem_node(NODE_DATA(0), memstart, _ramend - memstart); |
| 135 | } |
| 136 | |
| 137 | #endif /* CONFIG_MMU */ |
| 138 | |
| 139 | /***************************************************************************/ |
| 140 | |
Philippe De Muyter | ea49f8ff | 2010-09-20 13:11:11 +0200 | [diff] [blame] | 141 | void __init config_BSP(char *commandp, int size) |
| 142 | { |
Greg Ungerer | 88be351 | 2011-10-14 15:06:22 +1000 | [diff] [blame] | 143 | #ifdef CONFIG_MMU |
| 144 | mcf54xx_bootmem_alloc(); |
| 145 | mmu_context_init(); |
| 146 | #endif |
Greg Ungerer | 5b2e655 | 2010-11-02 12:05:29 +1000 | [diff] [blame] | 147 | mach_reset = mcf54xx_reset; |
Greg Ungerer | 35aefb2 | 2012-01-23 15:34:58 +1000 | [diff] [blame] | 148 | mach_sched_init = hw_timer_init; |
Greg Ungerer | 5b2e655 | 2010-11-02 12:05:29 +1000 | [diff] [blame] | 149 | m54xx_uarts_init(); |
Philippe De Muyter | ea49f8ff | 2010-09-20 13:11:11 +0200 | [diff] [blame] | 150 | } |
| 151 | |
| 152 | /***************************************************************************/ |
| 153 | |
| 154 | static int __init init_BSP(void) |
| 155 | { |
| 156 | |
Greg Ungerer | 5b2e655 | 2010-11-02 12:05:29 +1000 | [diff] [blame] | 157 | platform_add_devices(m54xx_devices, ARRAY_SIZE(m54xx_devices)); |
Philippe De Muyter | ea49f8ff | 2010-09-20 13:11:11 +0200 | [diff] [blame] | 158 | return 0; |
| 159 | } |
| 160 | |
| 161 | arch_initcall(init_BSP); |
| 162 | |
| 163 | /***************************************************************************/ |