blob: 11cff6625dcce8ae12b5e6d77abc2b17680edda5 [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>
15#include <linux/interrupt.h>
Greg Ungerer96db2712008-02-01 17:34:55 +100016#include <linux/io.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070017#include <asm/machdep.h>
18#include <asm/coldfire.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070019#include <asm/mcfsim.h>
Greg Ungerer96db2712008-02-01 17:34:55 +100020#include <asm/mcfuart.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070021#include <asm/mcfwdebug.h>
22
23/***************************************************************************/
24
Linus Torvalds1da177e2005-04-16 15:20:36 -070025void coldfire_reset(void);
26
27extern unsigned int mcf_timervector;
28extern unsigned int mcf_profilevector;
29extern unsigned int mcf_timerlevel;
30
31/***************************************************************************/
32
33/*
34 * Some platforms need software versions of the GPIO data registers.
35 */
36unsigned short ppdata;
37unsigned char ledbank = 0xff;
38
39/***************************************************************************/
40
Greg Ungerer96db2712008-02-01 17:34:55 +100041static struct mcf_platform_uart m5307_uart_platform[] = {
42 {
43 .mapbase = MCF_MBAR + MCFUART_BASE1,
44 .irq = 73,
45 },
46 {
47 .mapbase = MCF_MBAR + MCFUART_BASE2,
48 .irq = 74,
49 },
50 { },
Linus Torvalds1da177e2005-04-16 15:20:36 -070051};
52
Greg Ungerer96db2712008-02-01 17:34:55 +100053static struct platform_device m5307_uart = {
54 .name = "mcfuart",
55 .id = 0,
56 .dev.platform_data = m5307_uart_platform,
57};
58
59static struct platform_device *m5307_devices[] __initdata = {
60 &m5307_uart,
61};
62
63/***************************************************************************/
64
65static void __init m5307_uart_init_line(int line, int irq)
66{
67 if (line == 0) {
68 writel(MCFSIM_ICR_LEVEL6 | MCFSIM_ICR_PRI1, MCF_MBAR + MCFSIM_UART1ICR);
69 writeb(irq, MCFUART_BASE1 + MCFUART_UIVR);
70 mcf_setimr(mcf_getimr() & ~MCFSIM_IMR_UART1);
71 } else if (line == 1) {
72 writel(MCFSIM_ICR_LEVEL6 | MCFSIM_ICR_PRI2, MCF_MBAR + MCFSIM_UART2ICR);
73 writeb(irq, MCFUART_BASE2 + MCFUART_UIVR);
74 mcf_setimr(mcf_getimr() & ~MCFSIM_IMR_UART2);
75 }
76}
77
78static void __init m5307_uarts_init(void)
79{
80 const int nrlines = ARRAY_SIZE(m5307_uart_platform);
81 int line;
82
83 for (line = 0; (line < nrlines); line++)
84 m5307_uart_init_line(line, m5307_uart_platform[line].irq);
85}
Linus Torvalds1da177e2005-04-16 15:20:36 -070086
87/***************************************************************************/
88
89void mcf_autovector(unsigned int vec)
90{
91 volatile unsigned char *mbar;
92
93 if ((vec >= 25) && (vec <= 31)) {
94 mbar = (volatile unsigned char *) MCF_MBAR;
95 vec = 0x1 << (vec - 24);
96 *(mbar + MCFSIM_AVR) |= vec;
97 mcf_setimr(mcf_getimr() & ~vec);
98 }
99}
100
101/***************************************************************************/
102
103void mcf_settimericr(unsigned int timer, unsigned int level)
104{
105 volatile unsigned char *icrp;
106 unsigned int icr, imr;
107
108 if (timer <= 2) {
109 switch (timer) {
110 case 2: icr = MCFSIM_TIMER2ICR; imr = MCFSIM_IMR_TIMER2; break;
111 default: icr = MCFSIM_TIMER1ICR; imr = MCFSIM_IMR_TIMER1; break;
112 }
113
114 icrp = (volatile unsigned char *) (MCF_MBAR + icr);
115 *icrp = MCFSIM_ICR_AUTOVEC | (level << 2) | MCFSIM_ICR_PRI3;
116 mcf_setimr(mcf_getimr() & ~imr);
117 }
118}
119
120/***************************************************************************/
121
Greg Ungerer96db2712008-02-01 17:34:55 +1000122void __init config_BSP(char *commandp, int size)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700123{
124 mcf_setimr(MCFSIM_IMR_MASKALL);
125
Greg Ungererbc724502007-07-25 22:07:20 +1000126#if defined(CONFIG_NETtel) || defined(CONFIG_eLIA) || \
Greg Ungerercff28b52008-05-01 12:17:21 +1000127 defined(CONFIG_SECUREEDGEMP3) || defined(CONFIG_CLEOPATRA)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700128 /* Copy command line from FLASH to local buffer... */
129 memcpy(commandp, (char *) 0xf0004000, size);
130 commandp[size-1] = 0;
131 /* Different timer setup - to prevent device clash */
132 mcf_timervector = 30;
133 mcf_profilevector = 31;
134 mcf_timerlevel = 6;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700135#endif
136
Linus Torvalds1da177e2005-04-16 15:20:36 -0700137 mach_reset = coldfire_reset;
138
Greg Ungerer96db2712008-02-01 17:34:55 +1000139#ifdef CONFIG_BDM_DISABLE
Linus Torvalds1da177e2005-04-16 15:20:36 -0700140 /*
141 * Disable the BDM clocking. This also turns off most of the rest of
142 * the BDM device. This is good for EMC reasons. This option is not
143 * incompatible with the memory protection option.
144 */
145 wdebug(MCFDEBUG_CSR, MCFDEBUG_CSR_PSTCLK);
146#endif
147}
148
149/***************************************************************************/
Greg Ungerer96db2712008-02-01 17:34:55 +1000150
151static int __init init_BSP(void)
152{
153 m5307_uarts_init();
154 platform_add_devices(m5307_devices, ARRAY_SIZE(m5307_devices));
155 return 0;
156}
157
158arch_initcall(init_BSP);
159
160/***************************************************************************/