blob: 4861be602dcd53567e833218e49171056bc8abf2 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/***************************************************************************/
2
3/*
4 * linux/arch/m68knommu/platform/5407/config.c
5 *
6 * Copyright (C) 1999-2002, Greg Ungerer (gerg@snapgear.com)
7 * Copyright (C) 2000, Lineo (www.lineo.com)
8 */
9
10/***************************************************************************/
11
Linus Torvalds1da177e2005-04-16 15:20:36 -070012#include <linux/kernel.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070013#include <linux/param.h>
14#include <linux/init.h>
Greg Ungererc0ecfcd2008-02-01 17:35:03 +100015#include <linux/io.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070016#include <asm/machdep.h>
17#include <asm/coldfire.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070018#include <asm/mcfsim.h>
Greg Ungererc0ecfcd2008-02-01 17:35:03 +100019#include <asm/mcfuart.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070020
21/***************************************************************************/
22
Greg Ungererc0ecfcd2008-02-01 17:35:03 +100023static struct mcf_platform_uart m5407_uart_platform[] = {
24 {
25 .mapbase = MCF_MBAR + MCFUART_BASE1,
26 .irq = 73,
27 },
28 {
29 .mapbase = MCF_MBAR + MCFUART_BASE2,
30 .irq = 74,
31 },
32 { },
Linus Torvalds1da177e2005-04-16 15:20:36 -070033};
34
Greg Ungererc0ecfcd2008-02-01 17:35:03 +100035static struct platform_device m5407_uart = {
36 .name = "mcfuart",
37 .id = 0,
38 .dev.platform_data = m5407_uart_platform,
39};
40
41static struct platform_device *m5407_devices[] __initdata = {
42 &m5407_uart,
43};
44
45/***************************************************************************/
46
47static void __init m5407_uart_init_line(int line, int irq)
48{
49 if (line == 0) {
Greg Ungerer522b3d42009-03-24 17:33:41 +100050 writeb(MCFSIM_ICR_LEVEL6 | MCFSIM_ICR_PRI1, MCF_MBAR + MCFSIM_UART1ICR);
51 writeb(irq, MCF_MBAR + MCFUART_BASE1 + MCFUART_UIVR);
Greg Ungerer39f0fb62009-05-22 13:33:35 +100052 mcf_mapirq2imr(irq, MCFINTC_UART0);
Greg Ungererc0ecfcd2008-02-01 17:35:03 +100053 } else if (line == 1) {
Greg Ungerer522b3d42009-03-24 17:33:41 +100054 writeb(MCFSIM_ICR_LEVEL6 | MCFSIM_ICR_PRI2, MCF_MBAR + MCFSIM_UART2ICR);
55 writeb(irq, MCF_MBAR + MCFUART_BASE2 + MCFUART_UIVR);
Greg Ungerer39f0fb62009-05-22 13:33:35 +100056 mcf_mapirq2imr(irq, MCFINTC_UART1);
Greg Ungererc0ecfcd2008-02-01 17:35:03 +100057 }
58}
59
60static void __init m5407_uarts_init(void)
61{
62 const int nrlines = ARRAY_SIZE(m5407_uart_platform);
63 int line;
64
65 for (line = 0; (line < nrlines); line++)
66 m5407_uart_init_line(line, m5407_uart_platform[line].irq);
67}
Linus Torvalds1da177e2005-04-16 15:20:36 -070068
69/***************************************************************************/
70
Greg Ungerer04b75b12009-05-19 14:52:40 +100071static void __init m5407_timers_init(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -070072{
Greg Ungerer04b75b12009-05-19 14:52:40 +100073 /* Timer1 is always used as system timer */
74 writeb(MCFSIM_ICR_AUTOVEC | MCFSIM_ICR_LEVEL6 | MCFSIM_ICR_PRI3,
75 MCF_MBAR + MCFSIM_TIMER1ICR);
Greg Ungerer39f0fb62009-05-22 13:33:35 +100076 mcf_mapirq2imr(MCF_IRQ_TIMER, MCFINTC_TIMER1);
Linus Torvalds1da177e2005-04-16 15:20:36 -070077
Greg Ungerer04b75b12009-05-19 14:52:40 +100078#ifdef CONFIG_HIGHPROFILE
79 /* Timer2 is to be used as a high speed profile timer */
80 writeb(MCFSIM_ICR_AUTOVEC | MCFSIM_ICR_LEVEL7 | MCFSIM_ICR_PRI3,
81 MCF_MBAR + MCFSIM_TIMER2ICR);
Greg Ungerer39f0fb62009-05-22 13:33:35 +100082 mcf_mapirq2imr(MCF_IRQ_PROFILER, MCFINTC_TIMER2);
Greg Ungerer04b75b12009-05-19 14:52:40 +100083#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -070084}
85
86/***************************************************************************/
87
Greg Ungerereb7c874d2009-04-30 17:15:18 +100088void m5407_cpu_reset(void)
89{
90 local_irq_disable();
91 /* set watchdog to soft reset, and enabled */
92 __raw_writeb(0xc0, MCF_MBAR + MCFSIM_SYPCR);
93 for (;;)
94 /* wait for watchdog to timeout */;
95}
96
97/***************************************************************************/
98
Greg Ungererc0ecfcd2008-02-01 17:35:03 +100099void __init config_BSP(char *commandp, int size)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700100{
Greg Ungerereb7c874d2009-04-30 17:15:18 +1000101 mach_reset = m5407_cpu_reset;
Greg Ungerer35aefb22012-01-23 15:34:58 +1000102 mach_sched_init = hw_timer_init;
Greg Ungerer04b75b12009-05-19 14:52:40 +1000103 m5407_timers_init();
Greg Ungerer39f0fb62009-05-22 13:33:35 +1000104 m5407_uarts_init();
105
106 /* Only support the external interrupts on their primary level */
107 mcf_mapirq2imr(25, MCFINTC_EINT1);
108 mcf_mapirq2imr(27, MCFINTC_EINT3);
109 mcf_mapirq2imr(29, MCFINTC_EINT5);
110 mcf_mapirq2imr(31, MCFINTC_EINT7);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700111}
112
113/***************************************************************************/
Greg Ungererc0ecfcd2008-02-01 17:35:03 +1000114
115static int __init init_BSP(void)
116{
Greg Ungererc0ecfcd2008-02-01 17:35:03 +1000117 platform_add_devices(m5407_devices, ARRAY_SIZE(m5407_devices));
118 return 0;
119}
120
121arch_initcall(init_BSP);
122
123/***************************************************************************/