import of upstream 2.4.34.4 from kernel.org
[linux-2.4.git] / arch / arm / mach-sa1100 / flexanet.c
1 /*
2  * linux/arch/arm/mach-sa1100/flexanet.c
3  *
4  * Author: Jordi Colomer <jco@ict.es>
5  *
6  * This file contains all FlexaNet-specific tweaks.
7  *
8  * This program is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License version 2 as
10  * published by the Free Software Foundation.
11  */
12 #include <linux/init.h>
13 #include <linux/kernel.h>
14 #include <linux/sched.h>
15 #include <linux/tty.h>
16 #include <linux/module.h>
17 #include <linux/errno.h>
18 #include <linux/delay.h>
19
20 #include <asm/hardware.h>
21 #include <asm/setup.h>
22 #include <asm/page.h>
23 #include <asm/pgtable.h>
24
25 #include <asm/mach/arch.h>
26 #include <asm/mach/map.h>
27 #include <asm/mach/serial_sa1100.h>
28 #include <linux/serial_core.h>
29 #include <asm/arch/flexanet.h>
30
31 #include "generic.h"
32
33
34 unsigned long flexanet_BCR = FHH_BCR_POWERUP;
35
36 EXPORT_SYMBOL(flexanet_BCR);
37
38 /* physical addresses */
39 #define _RCNR        0x90010004
40 #define _GPLR        0x90040000
41 #define _Ser4SSCR0   0x80070060
42
43 /*
44  * Get the modem-control register of the UARTs
45  *
46  */
47 static int flexanet_get_mctrl(struct uart_port *port)
48 {
49         int            stat = 0;
50         unsigned long  bsr;
51
52         /* only DSR and CTS are implemented in UART1 & 3 */
53         if (port->membase == (void *)&Ser1UTCR0)
54         {
55                 bsr = FHH_BSR;
56
57                 if ((bsr & FHH_BSR_DSR1) != 0)
58                         stat |= TIOCM_DSR;
59                 if ((bsr & FHH_BSR_CTS1) != 0)
60                         stat |= TIOCM_CTS;
61         }
62         else if (port->membase == (void *)&Ser3UTCR0)
63         {
64                 bsr = FHH_BSR;
65
66                 if ((bsr & FHH_BSR_DSR3) != 0)
67                         stat |= TIOCM_DSR;
68                 if ((bsr & FHH_BSR_CTS3) != 0)
69                         stat |= TIOCM_CTS;
70         }
71
72         return stat;
73 }
74
75 /*
76  * Set the modem-control register of the UARTs
77  *
78  */
79 static void flexanet_set_mctrl(struct uart_port *port, u_int mctrl)
80 {
81         unsigned long   flags;
82
83         /* only the RTS signal is implemented in UART1 & 3 */
84         if (port->membase == (void *)&Ser1UTCR0)
85         {
86                 local_irq_save(flags);
87
88                 if (mctrl & TIOCM_RTS)
89                         flexanet_BCR |= FHH_BCR_RTS1;
90                 else
91                         flexanet_BCR &= ~FHH_BCR_RTS1;
92
93                 FHH_BCR = flexanet_BCR;
94                 local_irq_restore(flags);
95         }
96         else if (port->membase == (void *)&Ser3UTCR0)
97         {
98                 local_irq_save(flags);
99
100                 if (mctrl & TIOCM_RTS)
101                         flexanet_BCR |= FHH_BCR_RTS3;
102                 else
103                         flexanet_BCR &= ~FHH_BCR_RTS3;
104
105                 FHH_BCR = flexanet_BCR;
106                 local_irq_restore(flags);
107         }
108 }
109
110 /*
111  * machine-specific serial port functions
112  *
113  * get_mctrl : set state of modem control lines
114  * set_mctrl : set the modem control lines
115  * pm        : power-management. Turn device on/off.
116  *
117  */
118 static struct sa1100_port_fns   flexanet_port_fns __initdata =
119 {
120         set_mctrl : flexanet_set_mctrl,
121         get_mctrl : flexanet_get_mctrl,
122         pm        : NULL,
123 };
124
125
126 /*
127  * Initialization and serial port mapping
128  *
129  */
130
131 static int flexanet_serial_init(void)
132 {
133         /* register low-level functions */
134         sa1100_register_uart_fns(&flexanet_port_fns);
135
136         /* UART port number mapping */
137         sa1100_register_uart(0, 1); /* RS232 */
138         sa1100_register_uart(1, 3); /* Radio */
139
140         /* Select UART function in Serial port 1 */
141         Ser1SDCR0 |= SDCR0_UART;
142
143         return 0;
144 }
145
146
147 static int __init flexanet_init(void)
148 {
149         /* Set IRQ edges */
150         set_GPIO_IRQ_edge(GPIO_GUI_IRQ, GPIO_RISING_EDGE);
151
152         /* deassert the GUI reset */
153         FLEXANET_BCR_set(FHH_BCR_GUI_NRST);
154         return 0;
155 }
156
157 __initcall(flexanet_init);
158
159
160 static void __init
161 fixup_flexanet(struct machine_desc *desc, struct param_struct *params,
162               char **cmdline, struct meminfo *mi)
163 {
164         /* fixed RAM size, by now (64MB) */
165         SET_BANK( 0, 0xc0000000, 64*1024*1024 );
166         mi->nr_banks = 1;
167
168         /* setup ramdisk */
169         ROOT_DEV = MKDEV(RAMDISK_MAJOR,0);
170         setup_ramdisk( 1, 0, 0, 8192 );
171         setup_initrd( 0xc0800000, 3*1024*1024 );
172 }
173
174
175 static struct map_desc flexanet_io_desc[] __initdata = {
176  /* virtual     physical    length      domain     r  w  c  b */
177   { 0xe8000000, 0x00000000, 0x02000000, DOMAIN_IO, 0, 1, 0, 0 }, /* Flash bank 0 */
178   { 0xf0000000, 0x10000000, 0x00001000, DOMAIN_IO, 0, 1, 0, 0 }, /* Board Control Register */
179   { 0xf1000000, 0x18000000, 0x01000000, DOMAIN_IO, 0, 1, 0, 0 }, /* Ethernet controller */
180   { 0xD0000000, 0x40000000, 0x04000000, DOMAIN_IO, 0, 1, 0, 0 }, /* Instrument boards */
181   { 0xD8000000, 0x48000000, 0x01000000, DOMAIN_IO, 0, 1, 0, 0 }, /* External peripherals */
182   LAST_DESC
183 };
184
185 static void __init flexanet_map_io(void)
186 {
187         sa1100_map_io();
188         iotable_init(flexanet_io_desc);
189         flexanet_serial_init();
190
191         /* wakeup source is GPIO-0 only */
192         PWER = PWER_GPIO0;
193
194         /* GPIOs set to zero during sleep */
195         PGSR = 0;
196
197         /*
198          * stop the 3.68 MHz oscillator and float control busses
199          * during sleep, since peripherals are powered off.
200          */
201         PCFR = PCFR_OPDE | PCFR_FP | PCFR_FS;
202
203 }
204
205
206 MACHINE_START(FLEXANET, "FlexaNet")
207         BOOT_MEM(0xc0000000, 0x80000000, 0xf8000000)
208         BOOT_PARAMS(0xc0000100)
209         FIXUP(fixup_flexanet)
210         MAPIO(flexanet_map_io)
211         INITIRQ(sa1100_init_irq)
212 MACHINE_END
213