aboutsummaryrefslogtreecommitdiffstats
path: root/arch/arm/mach-sa1100/h3xxx.c
diff options
context:
space:
mode:
Diffstat (limited to 'arch/arm/mach-sa1100/h3xxx.c')
-rw-r--r--arch/arm/mach-sa1100/h3xxx.c292
1 files changed, 292 insertions, 0 deletions
diff --git a/arch/arm/mach-sa1100/h3xxx.c b/arch/arm/mach-sa1100/h3xxx.c
new file mode 100644
index 00000000000..bb608d437ff
--- /dev/null
+++ b/arch/arm/mach-sa1100/h3xxx.c
@@ -0,0 +1,292 @@
1/*
2 * Hardware definitions for Compaq iPAQ H3xxx Handheld Computers
3 *
4 * Copyright 2000,1 Compaq Computer Corporation.
5 *
6 * Use consistent with the GNU GPL is permitted,
7 * provided that this copyright notice is
8 * preserved in its entirety in all copies and derived works.
9 *
10 * COMPAQ COMPUTER CORPORATION MAKES NO WARRANTIES, EXPRESSED OR IMPLIED,
11 * AS TO THE USEFULNESS OR CORRECTNESS OF THIS CODE OR ITS
12 * FITNESS FOR ANY PARTICULAR PURPOSE.
13 *
14 * Author: Jamey Hicks.
15 *
16 * History:
17 *
18 * 2001-10-?? Andrew Christian Added support for iPAQ H3800
19 * and abstracted EGPIO interface.
20 *
21 */
22#include <linux/module.h>
23#include <linux/init.h>
24#include <linux/kernel.h>
25#include <linux/tty.h>
26#include <linux/pm.h>
27#include <linux/device.h>
28#include <linux/mfd/htc-egpio.h>
29#include <linux/mtd/mtd.h>
30#include <linux/mtd/partitions.h>
31#include <linux/serial_core.h>
32#include <linux/gpio.h>
33#include <linux/platform_device.h>
34
35#include <asm/irq.h>
36#include <mach/hardware.h>
37#include <asm/mach-types.h>
38#include <asm/setup.h>
39
40#include <asm/mach/irq.h>
41#include <asm/mach/arch.h>
42#include <asm/mach/flash.h>
43#include <asm/mach/irda.h>
44#include <asm/mach/map.h>
45#include <asm/mach/serial_sa1100.h>
46
47#include <mach/h3xxx.h>
48
49#include "generic.h"
50
51void h3xxx_init_gpio(struct gpio_default_state *s, size_t n)
52{
53 while (n--) {
54 const char *name = s->name;
55 int err;
56
57 if (!name)
58 name = "[init]";
59 err = gpio_request(s->gpio, name);
60 if (err) {
61 printk(KERN_ERR "gpio%u: unable to request: %d\n",
62 s->gpio, err);
63 continue;
64 }
65 if (s->mode >= 0) {
66 err = gpio_direction_output(s->gpio, s->mode);
67 } else {
68 err = gpio_direction_input(s->gpio);
69 }
70 if (err) {
71 printk(KERN_ERR "gpio%u: unable to set direction: %d\n",
72 s->gpio, err);
73 continue;
74 }
75 if (!s->name)
76 gpio_free(s->gpio);
77 s++;
78 }
79}
80
81
82/*
83 * H3xxx flash support
84 */
85static struct mtd_partition h3xxx_partitions[] = {
86 {
87 .name = "H3XXX boot firmware",
88 .size = 0x00040000,
89 .offset = 0,
90 .mask_flags = MTD_WRITEABLE, /* force read-only */
91 }, {
92 .name = "H3XXX rootfs",
93 .size = MTDPART_SIZ_FULL,
94 .offset = 0x00040000,
95 }
96};
97
98static void h3xxx_set_vpp(int vpp)
99{
100 gpio_set_value(H3XXX_EGPIO_VPP_ON, vpp);
101}
102
103static int h3xxx_flash_init(void)
104{
105 int err = gpio_request(H3XXX_EGPIO_VPP_ON, "Flash Vpp");
106 if (err)
107 return err;
108
109 err = gpio_direction_output(H3XXX_EGPIO_VPP_ON, 0);
110 if (err)
111 gpio_free(H3XXX_EGPIO_VPP_ON);
112
113 return err;
114}
115
116static void h3xxx_flash_exit(void)
117{
118 gpio_free(H3XXX_EGPIO_VPP_ON);
119}
120
121static struct flash_platform_data h3xxx_flash_data = {
122 .map_name = "cfi_probe",
123 .set_vpp = h3xxx_set_vpp,
124 .init = h3xxx_flash_init,
125 .exit = h3xxx_flash_exit,
126 .parts = h3xxx_partitions,
127 .nr_parts = ARRAY_SIZE(h3xxx_partitions),
128};
129
130static struct resource h3xxx_flash_resource = {
131 .start = SA1100_CS0_PHYS,
132 .end = SA1100_CS0_PHYS + SZ_32M - 1,
133 .flags = IORESOURCE_MEM,
134};
135
136
137/*
138 * H3xxx uart support
139 */
140static void h3xxx_uart_set_mctrl(struct uart_port *port, u_int mctrl)
141{
142 if (port->mapbase == _Ser3UTCR0) {
143 gpio_set_value(H3XXX_GPIO_COM_RTS, !(mctrl & TIOCM_RTS));
144 }
145}
146
147static u_int h3xxx_uart_get_mctrl(struct uart_port *port)
148{
149 u_int ret = TIOCM_CD | TIOCM_CTS | TIOCM_DSR;
150
151 if (port->mapbase == _Ser3UTCR0) {
152 /*
153 * DCD and CTS bits are inverted in GPLR by RS232 transceiver
154 */
155 if (gpio_get_value(H3XXX_GPIO_COM_DCD))
156 ret &= ~TIOCM_CD;
157 if (gpio_get_value(H3XXX_GPIO_COM_CTS))
158 ret &= ~TIOCM_CTS;
159 }
160
161 return ret;
162}
163
164static void h3xxx_uart_pm(struct uart_port *port, u_int state, u_int oldstate)
165{
166 if (port->mapbase == _Ser3UTCR0)
167 if (!gpio_request(H3XXX_EGPIO_RS232_ON, "RS232 transceiver")) {
168 gpio_direction_output(H3XXX_EGPIO_RS232_ON, !state);
169 gpio_free(H3XXX_EGPIO_RS232_ON);
170 }
171}
172
173/*
174 * Enable/Disable wake up events for this serial port.
175 * Obviously, we only support this on the normal COM port.
176 */
177static int h3xxx_uart_set_wake(struct uart_port *port, u_int enable)
178{
179 int err = -EINVAL;
180
181 if (port->mapbase == _Ser3UTCR0) {
182 if (enable)
183 PWER |= PWER_GPIO23 | PWER_GPIO25; /* DCD and CTS */
184 else
185 PWER &= ~(PWER_GPIO23 | PWER_GPIO25); /* DCD and CTS */
186 err = 0;
187 }
188 return err;
189}
190
191static struct sa1100_port_fns h3xxx_port_fns __initdata = {
192 .set_mctrl = h3xxx_uart_set_mctrl,
193 .get_mctrl = h3xxx_uart_get_mctrl,
194 .pm = h3xxx_uart_pm,
195 .set_wake = h3xxx_uart_set_wake,
196};
197
198/*
199 * EGPIO
200 */
201
202static struct resource egpio_resources[] = {
203 [0] = {
204 .start = H3600_EGPIO_PHYS,
205 .end = H3600_EGPIO_PHYS + 0x4 - 1,
206 .flags = IORESOURCE_MEM,
207 },
208};
209
210static struct htc_egpio_chip egpio_chips[] = {
211 [0] = {
212 .reg_start = 0,
213 .gpio_base = H3XXX_EGPIO_BASE,
214 .num_gpios = 16,
215 .direction = HTC_EGPIO_OUTPUT,
216 .initial_values = 0x0080, /* H3XXX_EGPIO_RS232_ON */
217 },
218};
219
220static struct htc_egpio_platform_data egpio_info = {
221 .reg_width = 16,
222 .bus_width = 16,
223 .chip = egpio_chips,
224 .num_chips = ARRAY_SIZE(egpio_chips),
225};
226
227static struct platform_device h3xxx_egpio = {
228 .name = "htc-egpio",
229 .id = -1,
230 .resource = egpio_resources,
231 .num_resources = ARRAY_SIZE(egpio_resources),
232 .dev = {
233 .platform_data = &egpio_info,
234 },
235};
236
237static struct platform_device *h3xxx_devices[] = {
238 &h3xxx_egpio,
239};
240
241void __init h3xxx_mach_init(void)
242{
243 sa1100_register_uart_fns(&h3xxx_port_fns);
244 sa11x0_register_mtd(&h3xxx_flash_data, &h3xxx_flash_resource, 1);
245 platform_add_devices(h3xxx_devices, ARRAY_SIZE(h3xxx_devices));
246}
247
248static struct map_desc h3600_io_desc[] __initdata = {
249 { /* static memory bank 2 CS#2 */
250 .virtual = H3600_BANK_2_VIRT,
251 .pfn = __phys_to_pfn(SA1100_CS2_PHYS),
252 .length = 0x02800000,
253 .type = MT_DEVICE
254 }, { /* static memory bank 4 CS#4 */
255 .virtual = H3600_BANK_4_VIRT,
256 .pfn = __phys_to_pfn(SA1100_CS4_PHYS),
257 .length = 0x00800000,
258 .type = MT_DEVICE
259 }, { /* EGPIO 0 CS#5 */
260 .virtual = H3600_EGPIO_VIRT,
261 .pfn = __phys_to_pfn(H3600_EGPIO_PHYS),
262 .length = 0x01000000,
263 .type = MT_DEVICE
264 }
265};
266
267/*
268 * Common map_io initialization
269 */
270
271void __init h3xxx_map_io(void)
272{
273 sa1100_map_io();
274 iotable_init(h3600_io_desc, ARRAY_SIZE(h3600_io_desc));
275
276 sa1100_register_uart(0, 3); /* Common serial port */
277// sa1100_register_uart(1, 1); /* Microcontroller on 3100/3600 */
278
279 /* Ensure those pins are outputs and driving low */
280 PPDR |= PPC_TXD4 | PPC_SCLK | PPC_SFRM;
281 PPSR &= ~(PPC_TXD4 | PPC_SCLK | PPC_SFRM);
282
283 /* Configure suspend conditions */
284 PGSR = 0;
285 PWER = PWER_GPIO0;
286 PCFR = PCFR_OPDE;
287 PSDR = 0;
288
289 GPCR = 0x0fffffff; /* All outputs are set low by default */
290 GPDR = 0; /* Configure all GPIOs as input */
291}
292