blob: 51202b1096cc20d850dd20af1f9be3dc63e14185 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/***************************************************************************/
2
3/*
4 * linux/arch/m68knommu/platform/5249/config.c
5 *
6 * Copyright (C) 2002, Greg Ungerer (gerg@snapgear.com)
7 */
8
9/***************************************************************************/
10
Linus Torvalds1da177e2005-04-16 15:20:36 -070011#include <linux/kernel.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070012#include <linux/param.h>
13#include <linux/init.h>
Greg Ungerer5f84bd52008-02-01 17:34:30 +100014#include <linux/io.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070015#include <asm/machdep.h>
16#include <asm/coldfire.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070017#include <asm/mcfsim.h>
Greg Ungerer5f84bd52008-02-01 17:34:30 +100018#include <asm/mcfuart.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070019
20/***************************************************************************/
21
Greg Ungerer5f84bd52008-02-01 17:34:30 +100022static struct mcf_platform_uart m5249_uart_platform[] = {
23 {
24 .mapbase = MCF_MBAR + MCFUART_BASE1,
25 .irq = 73,
26 },
27 {
28 .mapbase = MCF_MBAR + MCFUART_BASE2,
29 .irq = 74,
Greg Ungerer4ce2cba2009-03-24 15:15:14 +100030 },
31 { },
Linus Torvalds1da177e2005-04-16 15:20:36 -070032};
33
Greg Ungerer5f84bd52008-02-01 17:34:30 +100034static struct platform_device m5249_uart = {
35 .name = "mcfuart",
36 .id = 0,
37 .dev.platform_data = m5249_uart_platform,
38};
39
40static struct platform_device *m5249_devices[] __initdata = {
41 &m5249_uart,
42};
43
44/***************************************************************************/
45
46static void __init m5249_uart_init_line(int line, int irq)
47{
48 if (line == 0) {
Greg Ungererde1fc5c2009-03-24 16:50:09 +100049 writeb(MCFSIM_ICR_LEVEL6 | MCFSIM_ICR_PRI1, MCF_MBAR + MCFSIM_UART1ICR);
Greg Ungererd62db602009-03-24 17:14:32 +100050 writeb(irq, MCF_MBAR + MCFUART_BASE1 + MCFUART_UIVR);
Greg Ungererf2154be2009-05-19 14:38:08 +100051 mcf_clrimr(MCFINTC_UART0);
Greg Ungerer5f84bd52008-02-01 17:34:30 +100052 } else if (line == 1) {
Greg Ungererde1fc5c2009-03-24 16:50:09 +100053 writeb(MCFSIM_ICR_LEVEL6 | MCFSIM_ICR_PRI2, MCF_MBAR + MCFSIM_UART2ICR);
Greg Ungererd62db602009-03-24 17:14:32 +100054 writeb(irq, MCF_MBAR + MCFUART_BASE2 + MCFUART_UIVR);
Greg Ungererf2154be2009-05-19 14:38:08 +100055 mcf_clrimr(MCFINTC_UART1);
Greg Ungerer5f84bd52008-02-01 17:34:30 +100056 }
57}
58
59static void __init m5249_uarts_init(void)
60{
61 const int nrlines = ARRAY_SIZE(m5249_uart_platform);
62 int line;
63
64 for (line = 0; (line < nrlines); line++)
65 m5249_uart_init_line(line, m5249_uart_platform[line].irq);
66}
67
Linus Torvalds1da177e2005-04-16 15:20:36 -070068/***************************************************************************/
69
Greg Ungerer04b75b12009-05-19 14:52:40 +100070static void __init m5249_timers_init(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -070071{
Greg Ungerer04b75b12009-05-19 14:52:40 +100072 /* Timer1 is always used as system timer */
73 writeb(MCFSIM_ICR_AUTOVEC | MCFSIM_ICR_LEVEL6 | MCFSIM_ICR_PRI3,
74 MCF_MBAR + MCFSIM_TIMER1ICR);
Linus Torvalds1da177e2005-04-16 15:20:36 -070075
Greg Ungerer04b75b12009-05-19 14:52:40 +100076#ifdef CONFIG_HIGHPROFILE
77 /* Timer2 is to be used as a high speed profile timer */
78 writeb(MCFSIM_ICR_AUTOVEC | MCFSIM_ICR_LEVEL7 | MCFSIM_ICR_PRI3,
79 MCF_MBAR + MCFSIM_TIMER2ICR);
80#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -070081}
82
83/***************************************************************************/
84
Greg Ungerer6f5aa7c2009-04-30 17:31:19 +100085void m5249_cpu_reset(void)
86{
87 local_irq_disable();
88 /* Set watchdog to soft reset, and enabled */
89 __raw_writeb(0xc0, MCF_MBAR + MCFSIM_SYPCR);
90 for (;;)
91 /* wait for watchdog to timeout */;
92}
93
94/***************************************************************************/
95
Greg Ungerer5f84bd52008-02-01 17:34:30 +100096void __init config_BSP(char *commandp, int size)
Linus Torvalds1da177e2005-04-16 15:20:36 -070097{
Greg Ungerer6f5aa7c2009-04-30 17:31:19 +100098 mach_reset = m5249_cpu_reset;
Greg Ungerer04b75b12009-05-19 14:52:40 +100099 m5249_timers_init();
Linus Torvalds1da177e2005-04-16 15:20:36 -0700100}
101
102/***************************************************************************/
Greg Ungerer5f84bd52008-02-01 17:34:30 +1000103
104static int __init init_BSP(void)
105{
106 m5249_uarts_init();
107 platform_add_devices(m5249_devices, ARRAY_SIZE(m5249_devices));
108 return 0;
109}
110
111arch_initcall(init_BSP);
112
113/***************************************************************************/