blob: 4920b89d149c7162ea8564d36b27923a8501d73e [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
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 */
Linus Torvalds1da177e2005-04-16 15:20:36 -070022#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/mtd/mtd.h>
29#include <linux/mtd/partitions.h>
30#include <linux/serial_core.h>
31
32#include <asm/irq.h>
Russell Kinga09e64f2008-08-05 16:14:15 +010033#include <mach/hardware.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070034#include <asm/mach-types.h>
35#include <asm/setup.h>
36
37#include <asm/mach/irq.h>
38#include <asm/mach/arch.h>
39#include <asm/mach/flash.h>
40#include <asm/mach/irda.h>
41#include <asm/mach/map.h>
42#include <asm/mach/serial_sa1100.h>
43
Russell Kinga09e64f2008-08-05 16:14:15 +010044#include <mach/h3600.h>
Russell Kinga09e64f2008-08-05 16:14:15 +010045#include <mach/h3600_gpio.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070046
47#include "generic.h"
48
49struct ipaq_model_ops ipaq_model_ops;
50EXPORT_SYMBOL(ipaq_model_ops);
51
52static struct mtd_partition h3xxx_partitions[] = {
53 {
54 .name = "H3XXX boot firmware",
55 .size = 0x00040000,
56 .offset = 0,
57 .mask_flags = MTD_WRITEABLE, /* force read-only */
58 }, {
Dmitry Artamonowf110b3f2009-03-15 19:09:50 +010059 .name = "H3XXX rootfs",
Linus Torvalds1da177e2005-04-16 15:20:36 -070060 .size = MTDPART_SIZ_FULL,
61 .offset = 0x00040000,
Linus Torvalds1da177e2005-04-16 15:20:36 -070062 }
63};
64
65static void h3xxx_set_vpp(int vpp)
66{
67 assign_h3600_egpio(IPAQ_EGPIO_VPP_ON, vpp);
68}
69
70static struct flash_platform_data h3xxx_flash_data = {
71 .map_name = "cfi_probe",
72 .set_vpp = h3xxx_set_vpp,
73 .parts = h3xxx_partitions,
74 .nr_parts = ARRAY_SIZE(h3xxx_partitions),
75};
76
77static struct resource h3xxx_flash_resource = {
78 .start = SA1100_CS0_PHYS,
79 .end = SA1100_CS0_PHYS + SZ_32M - 1,
80 .flags = IORESOURCE_MEM,
81};
82
83/*
84 * This turns the IRDA power on or off on the Compaq H3600
85 */
86static int h3600_irda_set_power(struct device *dev, unsigned int state)
87{
88 assign_h3600_egpio( IPAQ_EGPIO_IR_ON, state );
89
90 return 0;
91}
92
Russell King58c02ec2005-04-17 15:40:46 +010093static void h3600_irda_set_speed(struct device *dev, unsigned int speed)
Linus Torvalds1da177e2005-04-16 15:20:36 -070094{
95 if (speed < 4000000) {
96 clr_h3600_egpio(IPAQ_EGPIO_IR_FSEL);
97 } else {
98 set_h3600_egpio(IPAQ_EGPIO_IR_FSEL);
99 }
100}
101
102static struct irda_platform_data h3600_irda_data = {
103 .set_power = h3600_irda_set_power,
104 .set_speed = h3600_irda_set_speed,
105};
106
107static void h3xxx_mach_init(void)
108{
109 sa11x0_set_flash_data(&h3xxx_flash_data, &h3xxx_flash_resource, 1);
110 sa11x0_set_irda_data(&h3600_irda_data);
111}
112
113/*
114 * low-level UART features
115 */
116
117static void h3600_uart_set_mctrl(struct uart_port *port, u_int mctrl)
118{
119 if (port->mapbase == _Ser3UTCR0) {
120 if (mctrl & TIOCM_RTS)
121 GPCR = GPIO_H3600_COM_RTS;
122 else
123 GPSR = GPIO_H3600_COM_RTS;
124 }
125}
126
127static u_int h3600_uart_get_mctrl(struct uart_port *port)
128{
129 u_int ret = TIOCM_CD | TIOCM_CTS | TIOCM_DSR;
130
131 if (port->mapbase == _Ser3UTCR0) {
132 int gplr = GPLR;
133 /* DCD and CTS bits are inverted in GPLR by RS232 transceiver */
134 if (gplr & GPIO_H3600_COM_DCD)
135 ret &= ~TIOCM_CD;
136 if (gplr & GPIO_H3600_COM_CTS)
137 ret &= ~TIOCM_CTS;
138 }
139
140 return ret;
141}
142
143static void h3600_uart_pm(struct uart_port *port, u_int state, u_int oldstate)
144{
145 if (port->mapbase == _Ser2UTCR0) { /* TODO: REMOVE THIS */
146 assign_h3600_egpio(IPAQ_EGPIO_IR_ON, !state);
147 } else if (port->mapbase == _Ser3UTCR0) {
148 assign_h3600_egpio(IPAQ_EGPIO_RS232_ON, !state);
149 }
150}
151
152/*
153 * Enable/Disable wake up events for this serial port.
154 * Obviously, we only support this on the normal COM port.
155 */
156static int h3600_uart_set_wake(struct uart_port *port, u_int enable)
157{
158 int err = -EINVAL;
159
160 if (port->mapbase == _Ser3UTCR0) {
161 if (enable)
162 PWER |= PWER_GPIO23 | PWER_GPIO25; /* DCD and CTS */
163 else
164 PWER &= ~(PWER_GPIO23 | PWER_GPIO25); /* DCD and CTS */
165 err = 0;
166 }
167 return err;
168}
169
170static struct sa1100_port_fns h3600_port_fns __initdata = {
171 .set_mctrl = h3600_uart_set_mctrl,
172 .get_mctrl = h3600_uart_get_mctrl,
173 .pm = h3600_uart_pm,
174 .set_wake = h3600_uart_set_wake,
175};
176
177/*
178 * helper for sa1100fb
179 */
180static void h3xxx_lcd_power(int enable)
181{
182 assign_h3600_egpio(IPAQ_EGPIO_LCD_POWER, enable);
183}
184
185static struct map_desc h3600_io_desc[] __initdata = {
Deepak Saxena92519d82005-10-28 15:19:04 +0100186 { /* static memory bank 2 CS#2 */
187 .virtual = H3600_BANK_2_VIRT,
188 .pfn = __phys_to_pfn(SA1100_CS2_PHYS),
189 .length = 0x02800000,
190 .type = MT_DEVICE
191 }, { /* static memory bank 4 CS#4 */
192 .virtual = H3600_BANK_4_VIRT,
193 .pfn = __phys_to_pfn(SA1100_CS4_PHYS),
194 .length = 0x00800000,
195 .type = MT_DEVICE
196 }, { /* EGPIO 0 CS#5 */
197 .virtual = H3600_EGPIO_VIRT,
198 .pfn = __phys_to_pfn(H3600_EGPIO_PHYS),
199 .length = 0x01000000,
200 .type = MT_DEVICE
201 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700202};
203
204/*
205 * Common map_io initialization
206 */
207
208static void __init h3xxx_map_io(void)
209{
210 sa1100_map_io();
211 iotable_init(h3600_io_desc, ARRAY_SIZE(h3600_io_desc));
212
213 sa1100_register_uart_fns(&h3600_port_fns);
214 sa1100_register_uart(0, 3); /* Common serial port */
215// sa1100_register_uart(1, 1); /* Microcontroller on 3100/3600 */
216
217 /* Ensure those pins are outputs and driving low */
218 PPDR |= PPC_TXD4 | PPC_SCLK | PPC_SFRM;
219 PPSR &= ~(PPC_TXD4 | PPC_SCLK | PPC_SFRM);
220
221 /* Configure suspend conditions */
222 PGSR = 0;
223 PWER = PWER_GPIO0 | PWER_RTC;
224 PCFR = PCFR_OPDE;
225 PSDR = 0;
226
227 sa1100fb_lcd_power = h3xxx_lcd_power;
228}
229
230static __inline__ void do_blank(int setp)
231{
232 if (ipaq_model_ops.blank_callback)
233 ipaq_model_ops.blank_callback(1-setp);
234}
235
236/************************* H3100 *************************/
237
238#ifdef CONFIG_SA1100_H3100
239
240#define H3100_EGPIO (*(volatile unsigned int *)H3600_EGPIO_VIRT)
241static unsigned int h3100_egpio = 0;
242
243static void h3100_control_egpio(enum ipaq_egpio_type x, int setp)
244{
245 unsigned int egpio = 0;
246 long gpio = 0;
247 unsigned long flags;
248
249 switch (x) {
250 case IPAQ_EGPIO_LCD_POWER:
251 egpio |= EGPIO_H3600_LCD_ON;
252 gpio |= GPIO_H3100_LCD_3V_ON;
253 do_blank(setp);
254 break;
255 case IPAQ_EGPIO_LCD_ENABLE:
256 break;
257 case IPAQ_EGPIO_CODEC_NRESET:
258 egpio |= EGPIO_H3600_CODEC_NRESET;
259 break;
260 case IPAQ_EGPIO_AUDIO_ON:
261 gpio |= GPIO_H3100_AUD_PWR_ON
262 | GPIO_H3100_AUD_ON;
263 break;
264 case IPAQ_EGPIO_QMUTE:
265 gpio |= GPIO_H3100_QMUTE;
266 break;
267 case IPAQ_EGPIO_OPT_NVRAM_ON:
268 egpio |= EGPIO_H3600_OPT_NVRAM_ON;
269 break;
270 case IPAQ_EGPIO_OPT_ON:
271 egpio |= EGPIO_H3600_OPT_ON;
272 break;
273 case IPAQ_EGPIO_CARD_RESET:
274 egpio |= EGPIO_H3600_CARD_RESET;
275 break;
276 case IPAQ_EGPIO_OPT_RESET:
277 egpio |= EGPIO_H3600_OPT_RESET;
278 break;
279 case IPAQ_EGPIO_IR_ON:
280 gpio |= GPIO_H3100_IR_ON;
281 break;
282 case IPAQ_EGPIO_IR_FSEL:
283 gpio |= GPIO_H3100_IR_FSEL;
284 break;
285 case IPAQ_EGPIO_RS232_ON:
286 egpio |= EGPIO_H3600_RS232_ON;
287 break;
288 case IPAQ_EGPIO_VPP_ON:
289 egpio |= EGPIO_H3600_VPP_ON;
290 break;
291 }
292
293 if (egpio || gpio) {
294 local_irq_save(flags);
295 if (setp) {
296 h3100_egpio |= egpio;
297 GPSR = gpio;
298 } else {
299 h3100_egpio &= ~egpio;
300 GPCR = gpio;
301 }
302 H3100_EGPIO = h3100_egpio;
303 local_irq_restore(flags);
304 }
305}
306
307static unsigned long h3100_read_egpio(void)
308{
309 return h3100_egpio;
310}
311
312static int h3100_pm_callback(int req)
313{
314 if (ipaq_model_ops.pm_callback_aux)
315 return ipaq_model_ops.pm_callback_aux(req);
316 return 0;
317}
318
319static struct ipaq_model_ops h3100_model_ops __initdata = {
320 .generic_name = "3100",
321 .control = h3100_control_egpio,
322 .read = h3100_read_egpio,
323 .pm_callback = h3100_pm_callback
324};
325
326#define H3100_DIRECT_EGPIO (GPIO_H3100_BT_ON \
327 | GPIO_H3100_GPIO3 \
328 | GPIO_H3100_QMUTE \
329 | GPIO_H3100_LCD_3V_ON \
330 | GPIO_H3100_AUD_ON \
331 | GPIO_H3100_AUD_PWR_ON \
332 | GPIO_H3100_IR_ON \
333 | GPIO_H3100_IR_FSEL)
334
335static void __init h3100_map_io(void)
336{
337 h3xxx_map_io();
338
339 /* Initialize h3100-specific values here */
340 GPCR = 0x0fffffff; /* All outputs are set low by default */
341 GPDR = GPIO_H3600_COM_RTS | GPIO_H3600_L3_CLOCK |
342 GPIO_H3600_L3_MODE | GPIO_H3600_L3_DATA |
343 GPIO_H3600_CLK_SET1 | GPIO_H3600_CLK_SET0 |
344 H3100_DIRECT_EGPIO;
345
346 /* Older bootldrs put GPIO2-9 in alternate mode on the
347 assumption that they are used for video */
348 GAFR &= ~H3100_DIRECT_EGPIO;
349
350 H3100_EGPIO = h3100_egpio;
351 ipaq_model_ops = h3100_model_ops;
352}
353
354MACHINE_START(H3100, "Compaq iPAQ H3100")
Russell Kinge9dea0c2005-07-03 17:38:58 +0100355 .phys_io = 0x80000000,
356 .io_pg_offst = ((0xf8000000) >> 18) & 0xfffc,
357 .boot_params = 0xc0000100,
358 .map_io = h3100_map_io,
359 .init_irq = sa1100_init_irq,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700360 .timer = &sa1100_timer,
361 .init_machine = h3xxx_mach_init,
362MACHINE_END
363
364#endif /* CONFIG_SA1100_H3100 */
365
366/************************* H3600 *************************/
367
368#ifdef CONFIG_SA1100_H3600
369
370#define H3600_EGPIO (*(volatile unsigned int *)H3600_EGPIO_VIRT)
371static unsigned int h3600_egpio = EGPIO_H3600_RS232_ON;
372
373static void h3600_control_egpio(enum ipaq_egpio_type x, int setp)
374{
375 unsigned int egpio = 0;
376 unsigned long flags;
377
378 switch (x) {
379 case IPAQ_EGPIO_LCD_POWER:
380 egpio |= EGPIO_H3600_LCD_ON |
381 EGPIO_H3600_LCD_PCI |
382 EGPIO_H3600_LCD_5V_ON |
383 EGPIO_H3600_LVDD_ON;
384 do_blank(setp);
385 break;
386 case IPAQ_EGPIO_LCD_ENABLE:
387 break;
388 case IPAQ_EGPIO_CODEC_NRESET:
389 egpio |= EGPIO_H3600_CODEC_NRESET;
390 break;
391 case IPAQ_EGPIO_AUDIO_ON:
392 egpio |= EGPIO_H3600_AUD_AMP_ON |
393 EGPIO_H3600_AUD_PWR_ON;
394 break;
395 case IPAQ_EGPIO_QMUTE:
396 egpio |= EGPIO_H3600_QMUTE;
397 break;
398 case IPAQ_EGPIO_OPT_NVRAM_ON:
399 egpio |= EGPIO_H3600_OPT_NVRAM_ON;
400 break;
401 case IPAQ_EGPIO_OPT_ON:
402 egpio |= EGPIO_H3600_OPT_ON;
403 break;
404 case IPAQ_EGPIO_CARD_RESET:
405 egpio |= EGPIO_H3600_CARD_RESET;
406 break;
407 case IPAQ_EGPIO_OPT_RESET:
408 egpio |= EGPIO_H3600_OPT_RESET;
409 break;
410 case IPAQ_EGPIO_IR_ON:
411 egpio |= EGPIO_H3600_IR_ON;
412 break;
413 case IPAQ_EGPIO_IR_FSEL:
414 egpio |= EGPIO_H3600_IR_FSEL;
415 break;
416 case IPAQ_EGPIO_RS232_ON:
417 egpio |= EGPIO_H3600_RS232_ON;
418 break;
419 case IPAQ_EGPIO_VPP_ON:
420 egpio |= EGPIO_H3600_VPP_ON;
421 break;
422 }
423
424 if (egpio) {
425 local_irq_save(flags);
426 if (setp)
427 h3600_egpio |= egpio;
428 else
429 h3600_egpio &= ~egpio;
430 H3600_EGPIO = h3600_egpio;
431 local_irq_restore(flags);
432 }
433}
434
435static unsigned long h3600_read_egpio(void)
436{
437 return h3600_egpio;
438}
439
440static int h3600_pm_callback(int req)
441{
442 if (ipaq_model_ops.pm_callback_aux)
443 return ipaq_model_ops.pm_callback_aux(req);
444 return 0;
445}
446
447static struct ipaq_model_ops h3600_model_ops __initdata = {
448 .generic_name = "3600",
449 .control = h3600_control_egpio,
450 .read = h3600_read_egpio,
451 .pm_callback = h3600_pm_callback
452};
453
454static void __init h3600_map_io(void)
455{
456 h3xxx_map_io();
457
458 /* Initialize h3600-specific values here */
459
460 GPCR = 0x0fffffff; /* All outputs are set low by default */
461 GPDR = GPIO_H3600_COM_RTS | GPIO_H3600_L3_CLOCK |
462 GPIO_H3600_L3_MODE | GPIO_H3600_L3_DATA |
463 GPIO_H3600_CLK_SET1 | GPIO_H3600_CLK_SET0 |
464 GPIO_LDD15 | GPIO_LDD14 | GPIO_LDD13 | GPIO_LDD12 |
465 GPIO_LDD11 | GPIO_LDD10 | GPIO_LDD9 | GPIO_LDD8;
466
467 H3600_EGPIO = h3600_egpio; /* Maintains across sleep? */
468 ipaq_model_ops = h3600_model_ops;
469}
470
471MACHINE_START(H3600, "Compaq iPAQ H3600")
Russell Kinge9dea0c2005-07-03 17:38:58 +0100472 .phys_io = 0x80000000,
473 .io_pg_offst = ((0xf8000000) >> 18) & 0xfffc,
474 .boot_params = 0xc0000100,
475 .map_io = h3600_map_io,
476 .init_irq = sa1100_init_irq,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700477 .timer = &sa1100_timer,
478 .init_machine = h3xxx_mach_init,
479MACHINE_END
480
481#endif /* CONFIG_SA1100_H3600 */
482