blob: 9c926dedb7c2f7ca454986716de582eb405975c9 [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 Ungerereaefd5f2007-02-07 12:03:19 +100014#include <linux/interrupt.h>
Greg Ungerer5f84bd52008-02-01 17:34:30 +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 Ungerer5f84bd52008-02-01 17:34:30 +100019#include <asm/mcfuart.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070020
21/***************************************************************************/
22
Linus Torvalds1da177e2005-04-16 15:20:36 -070023void coldfire_reset(void);
24
25/***************************************************************************/
26
Greg Ungerer5f84bd52008-02-01 17:34:30 +100027static struct mcf_platform_uart m5249_uart_platform[] = {
28 {
29 .mapbase = MCF_MBAR + MCFUART_BASE1,
30 .irq = 73,
31 },
32 {
33 .mapbase = MCF_MBAR + MCFUART_BASE2,
34 .irq = 74,
Greg Ungerer4ce2cba2009-03-24 15:15:14 +100035 },
36 { },
Linus Torvalds1da177e2005-04-16 15:20:36 -070037};
38
Greg Ungerer5f84bd52008-02-01 17:34:30 +100039static struct platform_device m5249_uart = {
40 .name = "mcfuart",
41 .id = 0,
42 .dev.platform_data = m5249_uart_platform,
43};
44
45static struct platform_device *m5249_devices[] __initdata = {
46 &m5249_uart,
47};
48
49/***************************************************************************/
50
51static void __init m5249_uart_init_line(int line, int irq)
52{
53 if (line == 0) {
54 writel(MCFSIM_ICR_LEVEL6 | MCFSIM_ICR_PRI1, MCF_MBAR + MCFSIM_UART1ICR);
55 writeb(irq, MCFUART_BASE1 + MCFUART_UIVR);
56 mcf_setimr(mcf_getimr() & ~MCFSIM_IMR_UART1);
57 } else if (line == 1) {
58 writel(MCFSIM_ICR_LEVEL6 | MCFSIM_ICR_PRI2, MCF_MBAR + MCFSIM_UART2ICR);
59 writeb(irq, MCFUART_BASE2 + MCFUART_UIVR);
60 mcf_setimr(mcf_getimr() & ~MCFSIM_IMR_UART2);
61 }
62}
63
64static void __init m5249_uarts_init(void)
65{
66 const int nrlines = ARRAY_SIZE(m5249_uart_platform);
67 int line;
68
69 for (line = 0; (line < nrlines); line++)
70 m5249_uart_init_line(line, m5249_uart_platform[line].irq);
71}
72
Linus Torvalds1da177e2005-04-16 15:20:36 -070073
74/***************************************************************************/
75
76void mcf_autovector(unsigned int vec)
77{
78 volatile unsigned char *mbar;
79
80 if ((vec >= 25) && (vec <= 31)) {
81 mbar = (volatile unsigned char *) MCF_MBAR;
82 vec = 0x1 << (vec - 24);
83 *(mbar + MCFSIM_AVR) |= vec;
84 mcf_setimr(mcf_getimr() & ~vec);
85 }
86}
87
88/***************************************************************************/
89
90void mcf_settimericr(unsigned int timer, unsigned int level)
91{
92 volatile unsigned char *icrp;
93 unsigned int icr, imr;
94
95 if (timer <= 2) {
96 switch (timer) {
97 case 2: icr = MCFSIM_TIMER2ICR; imr = MCFSIM_IMR_TIMER2; break;
98 default: icr = MCFSIM_TIMER1ICR; imr = MCFSIM_IMR_TIMER1; break;
99 }
100
101 icrp = (volatile unsigned char *) (MCF_MBAR + icr);
102 *icrp = MCFSIM_ICR_AUTOVEC | (level << 2) | MCFSIM_ICR_PRI3;
103 mcf_setimr(mcf_getimr() & ~imr);
104 }
105}
106
107/***************************************************************************/
108
Greg Ungerer5f84bd52008-02-01 17:34:30 +1000109void __init config_BSP(char *commandp, int size)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700110{
111 mcf_setimr(MCFSIM_IMR_MASKALL);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700112 mach_reset = coldfire_reset;
113}
114
115/***************************************************************************/
Greg Ungerer5f84bd52008-02-01 17:34:30 +1000116
117static int __init init_BSP(void)
118{
119 m5249_uarts_init();
120 platform_add_devices(m5249_devices, ARRAY_SIZE(m5249_devices));
121 return 0;
122}
123
124arch_initcall(init_BSP);
125
126/***************************************************************************/