ftp://ftp.kernel.org/pub/linux/kernel/v2.6/linux-2.6.6.tar.bz2
[linux-2.6.git] / arch / arm / mach-sa1100 / hackkit.c
1 /*
2  * linux/arch/arm/mach-sa1100/hackkit.c
3  *
4  * Copyright (C) 2002 Stefan Eletzhofer <stefan.eletzhofer@eletztrick.de>
5  *
6  * This file contains all HackKit tweaks. Based on original work from
7  * Nicolas Pitre's assabet fixes
8  *
9  * This program is free software; you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License version 2 as
11  * published by the Free Software Foundation.
12  *
13  */
14 #include <linux/init.h>
15 #include <linux/kernel.h>
16 #include <linux/sched.h>
17 #include <linux/tty.h>
18 #include <linux/module.h>
19 #include <linux/errno.h>
20 #include <linux/cpufreq.h>
21 #include <linux/serial_core.h>
22
23 #include <asm/hardware.h>
24 #include <asm/mach-types.h>
25 #include <asm/setup.h>
26 #include <asm/page.h>
27 #include <asm/pgtable.h>
28 #include <asm/irq.h>
29
30 #include <asm/mach/arch.h>
31 #include <asm/mach/map.h>
32 #include <asm/mach/irq.h>
33 #include <asm/mach/serial_sa1100.h>
34
35 #include "generic.h"
36
37 /**********************************************************************
38  *  prototypes
39  */
40
41 /* init funcs */
42 static int __init hackkit_init(void);
43 static void __init hackkit_init_irq(void);
44 static void __init hackkit_map_io(void);
45
46 static u_int hackkit_get_mctrl(struct uart_port *port);
47 static void hackkit_set_mctrl(struct uart_port *port, u_int mctrl);
48 static void hackkit_uart_pm(struct uart_port *port, u_int state, u_int oldstate);
49
50 /**********************************************************************
51  *  global data
52  */
53
54 /**********************************************************************
55  *  static data
56  */
57
58 static struct map_desc hackkit_io_desc[] __initdata = {
59  /* virtual     physical    length      type */
60   { 0xe8000000, 0x00000000, 0x01000000, MT_DEVICE } /* Flash bank 0 */
61 };
62
63 static struct sa1100_port_fns hackkit_port_fns __initdata = {
64         .set_mctrl      = hackkit_set_mctrl,
65         .get_mctrl      = hackkit_get_mctrl,
66         .pm             = hackkit_uart_pm,
67 };
68
69 /**********************************************************************
70  *  Static functions
71  */
72
73 static void __init hackkit_map_io(void)
74 {
75         sa1100_map_io();
76         iotable_init(hackkit_io_desc, ARRAY_SIZE(hackkit_io_desc));
77
78         sa1100_register_uart_fns(&hackkit_port_fns);
79         sa1100_register_uart(0, 1);     /* com port */
80         sa1100_register_uart(1, 2);
81         sa1100_register_uart(2, 3);     /* radio module */
82
83         Ser1SDCR0 |= SDCR0_SUS;
84 }
85
86 static void __init hackkit_init_irq(void)
87 {
88         /* none used yet */
89 }
90
91 /**
92  *      hackkit_uart_pm - powermgmt callback function for system 3 UART
93  *      @port: uart port structure
94  *      @state: pm state
95  *      @oldstate: old pm state
96  *
97  */
98 static void hackkit_uart_pm(struct uart_port *port, u_int state, u_int oldstate)
99 {
100         /* TODO: switch on/off uart in powersave mode */
101 }
102
103 /*
104  * Note! this can be called from IRQ context.
105  * FIXME: No modem ctrl lines yet.
106  */
107 static void hackkit_set_mctrl(struct uart_port *port, u_int mctrl)
108 {
109 #if 0
110         if (port->mapbase == _Ser1UTCR0) {
111                 u_int set = 0, clear = 0;
112
113                 if (mctrl & TIOCM_RTS)
114                         set |= PT_CTRL2_RS1_RTS;
115                 else
116                         clear |= PT_CTRL2_RS1_RTS;
117
118                 if (mctrl & TIOCM_DTR)
119                         set |= PT_CTRL2_RS1_DTR;
120                 else
121                         clear |= PT_CTRL2_RS1_DTR;
122
123                 PTCTRL2_clear(clear);
124                 PTCTRL2_set(set);
125         }
126 #endif
127 }
128
129 static u_int hackkit_get_mctrl(struct uart_port *port)
130 {
131         u_int ret = 0;
132 #if 0
133         u_int irqsr = PT_IRQSR;
134
135         /* need 2 reads to read current value */
136         irqsr = PT_IRQSR;
137
138         /* TODO: check IRQ source register for modem/com
139          status lines and set them correctly. */
140 #endif
141
142         ret = TIOCM_CD | TIOCM_CTS | TIOCM_DSR;
143
144         return ret;
145 }
146
147 static int __init hackkit_init(void)
148 {
149         int ret = 0;
150
151         if ( !machine_is_hackkit() ) {
152                 ret = -EINVAL;
153                 goto DONE;
154         }
155
156         hackkit_init_irq();
157
158         ret = 0;
159 DONE:
160         return ret;
161 }
162
163 /**********************************************************************
164  *  Exported Functions
165  */
166
167 /**********************************************************************
168  *  kernel magic macros
169  */
170 arch_initcall(hackkit_init);
171
172 MACHINE_START(HACKKIT, "HackKit Cpu Board")
173         BOOT_MEM(0xc0000000, 0x80000000, 0xf8000000)
174         BOOT_PARAMS(0xc0000100)
175         MAPIO(hackkit_map_io)
176         INITIRQ(sa1100_init_irq)
177 MACHINE_END