blob: 6bf7c1cca62755406f21f5e20997db34eb3569f1 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/***************************************************************************/
2
3/*
4 * linux/arch/m68knommu/platform/5307/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 Ungerer96db2712008-02-01 17:34:55 +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 Ungerer96db2712008-02-01 17:34:55 +100019#include <asm/mcfuart.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070020#include <asm/mcfwdebug.h>
21
22/***************************************************************************/
23
Linus Torvalds1da177e2005-04-16 15:20:36 -070024/*
25 * Some platforms need software versions of the GPIO data registers.
26 */
27unsigned short ppdata;
28unsigned char ledbank = 0xff;
29
30/***************************************************************************/
31
Greg Ungerer96db2712008-02-01 17:34:55 +100032static struct mcf_platform_uart m5307_uart_platform[] = {
33 {
34 .mapbase = MCF_MBAR + MCFUART_BASE1,
35 .irq = 73,
36 },
37 {
38 .mapbase = MCF_MBAR + MCFUART_BASE2,
39 .irq = 74,
40 },
41 { },
Linus Torvalds1da177e2005-04-16 15:20:36 -070042};
43
Greg Ungerer96db2712008-02-01 17:34:55 +100044static struct platform_device m5307_uart = {
45 .name = "mcfuart",
46 .id = 0,
47 .dev.platform_data = m5307_uart_platform,
48};
49
50static struct platform_device *m5307_devices[] __initdata = {
51 &m5307_uart,
52};
53
54/***************************************************************************/
55
56static void __init m5307_uart_init_line(int line, int irq)
57{
58 if (line == 0) {
Greg Ungerer9242ef12009-03-24 17:22:05 +100059 writeb(MCFSIM_ICR_LEVEL6 | MCFSIM_ICR_PRI1, MCF_MBAR + MCFSIM_UART1ICR);
60 writeb(irq, MCF_MBAR + MCFUART_BASE1 + MCFUART_UIVR);
Greg Ungerer39f0fb62009-05-22 13:33:35 +100061 mcf_mapirq2imr(irq, MCFINTC_UART0);
Greg Ungerer96db2712008-02-01 17:34:55 +100062 } else if (line == 1) {
Greg Ungerer9242ef12009-03-24 17:22:05 +100063 writeb(MCFSIM_ICR_LEVEL6 | MCFSIM_ICR_PRI2, MCF_MBAR + MCFSIM_UART2ICR);
64 writeb(irq, MCF_MBAR + MCFUART_BASE2 + MCFUART_UIVR);
Greg Ungerer39f0fb62009-05-22 13:33:35 +100065 mcf_mapirq2imr(irq, MCFINTC_UART1);
Greg Ungerer96db2712008-02-01 17:34:55 +100066 }
67}
68
69static void __init m5307_uarts_init(void)
70{
71 const int nrlines = ARRAY_SIZE(m5307_uart_platform);
72 int line;
73
74 for (line = 0; (line < nrlines); line++)
75 m5307_uart_init_line(line, m5307_uart_platform[line].irq);
76}
Linus Torvalds1da177e2005-04-16 15:20:36 -070077
78/***************************************************************************/
79
Greg Ungerer04b75b12009-05-19 14:52:40 +100080static void __init m5307_timers_init(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -070081{
Greg Ungerer04b75b12009-05-19 14:52:40 +100082 /* Timer1 is always used as system timer */
83 writeb(MCFSIM_ICR_AUTOVEC | MCFSIM_ICR_LEVEL6 | MCFSIM_ICR_PRI3,
84 MCF_MBAR + MCFSIM_TIMER1ICR);
Greg Ungerer39f0fb62009-05-22 13:33:35 +100085 mcf_mapirq2imr(MCF_IRQ_TIMER, MCFINTC_TIMER1);
Linus Torvalds1da177e2005-04-16 15:20:36 -070086
Greg Ungerer04b75b12009-05-19 14:52:40 +100087#ifdef CONFIG_HIGHPROFILE
88 /* Timer2 is to be used as a high speed profile timer */
89 writeb(MCFSIM_ICR_AUTOVEC | MCFSIM_ICR_LEVEL7 | MCFSIM_ICR_PRI3,
90 MCF_MBAR + MCFSIM_TIMER2ICR);
Greg Ungerer39f0fb62009-05-22 13:33:35 +100091 mcf_mapirq2imr(MCF_IRQ_PROFILER, MCFINTC_TIMER2);
Greg Ungerer04b75b12009-05-19 14:52:40 +100092#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -070093}
94
95/***************************************************************************/
96
Greg Ungererc18e52c2009-04-30 17:03:09 +100097void m5307_cpu_reset(void)
98{
99 local_irq_disable();
100 /* Set watchdog to soft reset, and enabled */
101 __raw_writeb(0xc0, MCF_MBAR + MCFSIM_SYPCR);
102 for (;;)
103 /* wait for watchdog to timeout */;
104}
105
106/***************************************************************************/
107
Greg Ungerer96db2712008-02-01 17:34:55 +1000108void __init config_BSP(char *commandp, int size)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700109{
Adrian Bunk3947fca2009-01-13 14:20:01 +1000110#if defined(CONFIG_NETtel) || \
Greg Ungerercff28b52008-05-01 12:17:21 +1000111 defined(CONFIG_SECUREEDGEMP3) || defined(CONFIG_CLEOPATRA)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700112 /* Copy command line from FLASH to local buffer... */
113 memcpy(commandp, (char *) 0xf0004000, size);
114 commandp[size-1] = 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700115#endif
116
Greg Ungererc18e52c2009-04-30 17:03:09 +1000117 mach_reset = m5307_cpu_reset;
Greg Ungerer35aefb22012-01-23 15:34:58 +1000118 mach_sched_init = hw_timer_init;
Greg Ungerer04b75b12009-05-19 14:52:40 +1000119 m5307_timers_init();
Greg Ungerer39f0fb62009-05-22 13:33:35 +1000120 m5307_uarts_init();
121
122 /* Only support the external interrupts on their primary level */
123 mcf_mapirq2imr(25, MCFINTC_EINT1);
124 mcf_mapirq2imr(27, MCFINTC_EINT3);
125 mcf_mapirq2imr(29, MCFINTC_EINT5);
126 mcf_mapirq2imr(31, MCFINTC_EINT7);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700127
Greg Ungerer96db2712008-02-01 17:34:55 +1000128#ifdef CONFIG_BDM_DISABLE
Linus Torvalds1da177e2005-04-16 15:20:36 -0700129 /*
130 * Disable the BDM clocking. This also turns off most of the rest of
131 * the BDM device. This is good for EMC reasons. This option is not
132 * incompatible with the memory protection option.
133 */
134 wdebug(MCFDEBUG_CSR, MCFDEBUG_CSR_PSTCLK);
135#endif
136}
137
138/***************************************************************************/
Greg Ungerer96db2712008-02-01 17:34:55 +1000139
140static int __init init_BSP(void)
141{
Greg Ungerer96db2712008-02-01 17:34:55 +1000142 platform_add_devices(m5307_devices, ARRAY_SIZE(m5307_devices));
143 return 0;
144}
145
146arch_initcall(init_BSP);
147
148/***************************************************************************/