blob: 7261a3d28adc3a283f20ddae779db98132a3b41a [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/***************************************************************************/
70
Linus Torvalds1da177e2005-04-16 15:20:36 -070071void mcf_settimericr(unsigned int timer, unsigned int level)
72{
73 volatile unsigned char *icrp;
74 unsigned int icr, imr;
75
76 if (timer <= 2) {
77 switch (timer) {
Greg Ungererf2154be2009-05-19 14:38:08 +100078 case 2: icr = MCFSIM_TIMER2ICR; imr = MCFINTC_TIMER2; break;
79 default: icr = MCFSIM_TIMER1ICR; imr = MCFINTC_TIMER1; break;
Linus Torvalds1da177e2005-04-16 15:20:36 -070080 }
81
82 icrp = (volatile unsigned char *) (MCF_MBAR + icr);
83 *icrp = MCFSIM_ICR_AUTOVEC | (level << 2) | MCFSIM_ICR_PRI3;
Greg Ungererf2154be2009-05-19 14:38:08 +100084 mcf_clrimr(imr);
Linus Torvalds1da177e2005-04-16 15:20:36 -070085 }
86}
87
88/***************************************************************************/
89
Greg Ungerer6f5aa7c2009-04-30 17:31:19 +100090void m5249_cpu_reset(void)
91{
92 local_irq_disable();
93 /* Set watchdog to soft reset, and enabled */
94 __raw_writeb(0xc0, MCF_MBAR + MCFSIM_SYPCR);
95 for (;;)
96 /* wait for watchdog to timeout */;
97}
98
99/***************************************************************************/
100
Greg Ungerer5f84bd52008-02-01 17:34:30 +1000101void __init config_BSP(char *commandp, int size)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700102{
Greg Ungerer6f5aa7c2009-04-30 17:31:19 +1000103 mach_reset = m5249_cpu_reset;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700104}
105
106/***************************************************************************/
Greg Ungerer5f84bd52008-02-01 17:34:30 +1000107
108static int __init init_BSP(void)
109{
110 m5249_uarts_init();
111 platform_add_devices(m5249_devices, ARRAY_SIZE(m5249_devices));
112 return 0;
113}
114
115arch_initcall(init_BSP);
116
117/***************************************************************************/