import of upstream 2.4.34.4 from kernel.org
[linux-2.4.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
15 #include <linux/config.h>
16 #include <linux/init.h>
17 #include <linux/kernel.h>
18 #include <linux/sched.h>
19 #include <linux/tty.h>
20 #include <linux/module.h>
21 #include <linux/errno.h>
22 #include <linux/cpufreq.h>
23 #include <linux/list.h>
24 #include <linux/timer.h>
25
26 #include <asm/hardware.h>
27 #include <asm/setup.h>
28 #include <asm/page.h>
29 #include <asm/pgtable.h>
30 #include <asm/irq.h>
31
32 #include <asm/mach/arch.h>
33 #include <asm/mach/map.h>
34 #include <asm/mach/irq.h>
35 #include <asm/mach/serial_sa1100.h>
36
37 #include <asm/arch/irq.h>
38
39 #include <linux/serial_core.h>
40
41 #include "generic.h"
42
43 #define DEBUG 1
44
45 #ifdef DEBUG
46 #       define DPRINTK( x, args... )    printk( "%s: line %d: "x, __FUNCTION__, __LINE__, ## args  );
47 #else
48 #       define DPRINTK( x, args... )    /* nix */
49 #endif
50
51 /**********************************************************************
52  *  prototypes
53  */
54
55 /* init funcs */
56 static void __init fixup_hackkit(struct machine_desc *desc,
57                 struct param_struct *params, char **cmdline, struct meminfo *mi);
58 static void __init get_hackkit_scr(void);
59 static int __init hackkit_init(void);
60 static void __init hackkit_init_irq(void);
61 static void __init hackkit_map_io(void);
62
63 static int hackkit_get_mctrl(struct uart_port *port);
64 static void hackkit_set_mctrl(struct uart_port *port, u_int mctrl);
65 static void hackkit_uart_pm(struct uart_port *port, u_int state, u_int oldstate);
66
67 extern void convert_to_tag_list(struct param_struct *params, int mem_init);
68
69
70 /**********************************************************************
71  *  global data
72  */
73
74 /**********************************************************************
75  *  static data
76  */
77
78 static struct map_desc hackkit_io_desc[] __initdata = {
79  /* virtual     physical    length      domain     r  w  c  b */
80   { 0xe8000000, 0x00000000, 0x01000000, DOMAIN_IO, 0, 1, 0, 0 }, /* Flash bank 0 */
81   LAST_DESC
82 };
83
84 static struct sa1100_port_fns hackkit_port_fns __initdata = {
85         .set_mctrl      = hackkit_set_mctrl,
86         .get_mctrl      = hackkit_get_mctrl,
87         .pm             = hackkit_uart_pm,
88 };
89
90 /**********************************************************************
91  *  Static functions
92  */
93
94 static void __init hackkit_map_io(void)
95 {
96         DPRINTK( "%s\n", "START" );
97         sa1100_map_io();
98         iotable_init(hackkit_io_desc);
99
100         sa1100_register_uart_fns(&hackkit_port_fns);
101         sa1100_register_uart(0, 1);     /* com port */
102         sa1100_register_uart(1, 2);
103         sa1100_register_uart(2, 3);     /* radio module */
104
105         Ser1SDCR0 |= SDCR0_SUS;
106 }
107
108 static void __init hackkit_init_irq(void)
109 {
110         /* none used yet */
111 }
112
113 /**
114  *      fixup_hackkit - fixup function for system 3 board
115  *      @desc:          machine description
116  *      @param:         kernel params
117  *      @cmdline:       kernel cmdline
118  *      @mi:            memory info struct
119  *
120  */
121 static void __init fixup_hackkit(struct machine_desc *desc,
122                 struct param_struct *params, char **cmdline, struct meminfo *mi)
123 {
124         DPRINTK( "%s\n", "START" );
125
126         ROOT_DEV = MKDEV(RAMDISK_MAJOR,0);
127         setup_ramdisk( 1, 0, 0, 8192 );
128         setup_initrd( 0xc0800000, 8*1024*1024 );
129 }
130
131
132 /**
133  *      hackkit_uart_pm - powermgmt callback function for system 3 UART
134  *      @port: uart port structure
135  *      @state: pm state
136  *      @oldstate: old pm state
137  *
138  */
139 static void hackkit_uart_pm(struct uart_port *port, u_int state, u_int oldstate)
140 {
141         /* TODO: switch on/off uart in powersave mode */
142 }
143
144 /*
145  * Note! this can be called from IRQ context.
146  * FIXME: No modem ctrl lines yet.
147  */
148 static void hackkit_set_mctrl(struct uart_port *port, u_int mctrl)
149 {
150 #if 0
151         if (port->mapbase == _Ser1UTCR0) {
152                 u_int set = 0, clear = 0;
153
154                 if (mctrl & TIOCM_RTS)
155                         set |= PT_CTRL2_RS1_RTS;
156                 else
157                         clear |= PT_CTRL2_RS1_RTS;
158
159                 if (mctrl & TIOCM_DTR)
160                         set |= PT_CTRL2_RS1_DTR;
161                 else
162                         clear |= PT_CTRL2_RS1_DTR;
163
164                 PTCTRL2_clear(clear);
165                 PTCTRL2_set(set);
166         }
167 #endif
168 }
169
170 static int hackkit_get_mctrl(struct uart_port *port)
171 {
172         u_int ret = 0;
173 #if 0
174         u_int irqsr = PT_IRQSR;
175
176         /* need 2 reads to read current value */
177         irqsr = PT_IRQSR;
178
179         /* TODO: check IRQ source register for modem/com
180          status lines and set them correctly. */
181 #endif
182
183         ret = TIOCM_CD | TIOCM_CTS | TIOCM_DSR;
184
185         return ret;
186 }
187
188 static int __init hackkit_init(void)
189 {
190         int ret = 0;
191         DPRINTK( "%s\n", "START" );
192
193         if ( !machine_is_hackkit() ) {
194                 ret = -EINVAL;
195                 goto DONE;
196         }
197
198         hackkit_init_irq();
199
200         ret = 0;
201 DONE:
202         DPRINTK( "ret=%d\n", ret );
203         return ret;
204 }
205
206 /**********************************************************************
207  *  Exported Functions
208  */
209
210 /**********************************************************************
211  *  kernel magic macros
212  */
213 __initcall(hackkit_init);
214
215 MACHINE_START(HACKKIT, "HackKit Cpu Board")
216         BOOT_MEM(0xc0000000, 0x80000000, 0xf8000000)
217         BOOT_PARAMS(0xc0000100)
218         FIXUP(fixup_hackkit)
219         MAPIO(hackkit_map_io)
220         INITIRQ(sa1100_init_irq)
221 MACHINE_END