blob: 5e6011ce36ee820463dadde212a2ffd3c5054aa8 [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>
Dmitry Artamonow2eec62d2009-11-27 12:00:00 +010028#include <linux/mfd/htc-egpio.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070029#include <linux/mtd/mtd.h>
30#include <linux/mtd/partitions.h>
31#include <linux/serial_core.h>
Russell King0831e3e2009-10-06 14:35:16 +010032#include <linux/gpio.h>
Dmitry Artamonow2eec62d2009-11-27 12:00:00 +010033#include <linux/platform_device.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070034
35#include <asm/irq.h>
Russell Kinga09e64f2008-08-05 16:14:15 +010036#include <mach/hardware.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070037#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
Russell Kinga09e64f2008-08-05 16:14:15 +010047#include <mach/h3600.h>
Russell Kinga09e64f2008-08-05 16:14:15 +010048#include <mach/h3600_gpio.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070049
50#include "generic.h"
51
Dmitry Artamonow607b0672009-03-15 19:14:27 +010052void (*assign_h3600_egpio)(enum ipaq_egpio_type x, int level);
53EXPORT_SYMBOL(assign_h3600_egpio);
Linus Torvalds1da177e2005-04-16 15:20:36 -070054
Russell King0831e3e2009-10-06 14:35:16 +010055struct gpio_default_state {
56 int gpio;
57 int mode;
58 const char *name;
59};
60
61#define GPIO_MODE_IN -1
62#define GPIO_MODE_OUT0 0
63#define GPIO_MODE_OUT1 1
64
65static void h3xxx_init_gpio(struct gpio_default_state *s, size_t n)
66{
67 while (n--) {
68 const char *name = s->name;
69 int err;
70
71 if (!name)
72 name = "[init]";
73 err = gpio_request(s->gpio, name);
74 if (err) {
75 printk(KERN_ERR "gpio%u: unable to request: %d\n",
76 s->gpio, err);
77 continue;
78 }
79 if (s->mode >= 0) {
80 err = gpio_direction_output(s->gpio, s->mode);
81 } else {
82 err = gpio_direction_input(s->gpio);
83 }
84 if (err) {
85 printk(KERN_ERR "gpio%u: unable to set direction: %d\n",
86 s->gpio, err);
87 continue;
88 }
89 if (!s->name)
90 gpio_free(s->gpio);
91 s++;
92 }
93}
94
95
Russell King6e21ee62009-10-06 15:16:27 +010096/*
97 * H3xxx flash support
98 */
Linus Torvalds1da177e2005-04-16 15:20:36 -070099static struct mtd_partition h3xxx_partitions[] = {
100 {
101 .name = "H3XXX boot firmware",
102 .size = 0x00040000,
103 .offset = 0,
104 .mask_flags = MTD_WRITEABLE, /* force read-only */
105 }, {
Dmitry Artamonowf110b3f2009-03-15 19:09:50 +0100106 .name = "H3XXX rootfs",
Linus Torvalds1da177e2005-04-16 15:20:36 -0700107 .size = MTDPART_SIZ_FULL,
108 .offset = 0x00040000,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700109 }
110};
111
112static void h3xxx_set_vpp(int vpp)
113{
Dmitry Artamonow22f97402009-11-27 12:02:28 +0100114 gpio_set_value(H3XXX_EGPIO_VPP_ON, vpp);
115}
116
117static int h3xxx_flash_init(void)
118{
119 int err = gpio_request(H3XXX_EGPIO_VPP_ON, "Flash Vpp");
120 if (err)
121 return err;
122
123 err = gpio_direction_output(H3XXX_EGPIO_VPP_ON, 0);
124 if (err)
125 gpio_free(H3XXX_EGPIO_VPP_ON);
126
127 return err;
128}
129
130static void h3xxx_flash_exit(void)
131{
132 gpio_free(H3XXX_EGPIO_VPP_ON);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700133}
134
135static struct flash_platform_data h3xxx_flash_data = {
136 .map_name = "cfi_probe",
137 .set_vpp = h3xxx_set_vpp,
Dmitry Artamonow22f97402009-11-27 12:02:28 +0100138 .init = h3xxx_flash_init,
139 .exit = h3xxx_flash_exit,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700140 .parts = h3xxx_partitions,
141 .nr_parts = ARRAY_SIZE(h3xxx_partitions),
142};
143
144static struct resource h3xxx_flash_resource = {
145 .start = SA1100_CS0_PHYS,
146 .end = SA1100_CS0_PHYS + SZ_32M - 1,
147 .flags = IORESOURCE_MEM,
148};
149
Linus Torvalds1da177e2005-04-16 15:20:36 -0700150
151/*
Russell King6e21ee62009-10-06 15:16:27 +0100152 * H3xxx uart support
Linus Torvalds1da177e2005-04-16 15:20:36 -0700153 */
Russell King6e21ee62009-10-06 15:16:27 +0100154static void h3xxx_uart_set_mctrl(struct uart_port *port, u_int mctrl)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700155{
156 if (port->mapbase == _Ser3UTCR0) {
Russell King6e21ee62009-10-06 15:16:27 +0100157 gpio_set_value(H3XXX_GPIO_COM_RTS, !(mctrl & TIOCM_RTS));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700158 }
159}
160
Russell King6e21ee62009-10-06 15:16:27 +0100161static u_int h3xxx_uart_get_mctrl(struct uart_port *port)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700162{
163 u_int ret = TIOCM_CD | TIOCM_CTS | TIOCM_DSR;
164
165 if (port->mapbase == _Ser3UTCR0) {
Russell King6e21ee62009-10-06 15:16:27 +0100166 /*
167 * DCD and CTS bits are inverted in GPLR by RS232 transceiver
168 */
169 if (gpio_get_value(H3XXX_GPIO_COM_DCD))
Linus Torvalds1da177e2005-04-16 15:20:36 -0700170 ret &= ~TIOCM_CD;
Russell King6e21ee62009-10-06 15:16:27 +0100171 if (gpio_get_value(H3XXX_GPIO_COM_CTS))
Linus Torvalds1da177e2005-04-16 15:20:36 -0700172 ret &= ~TIOCM_CTS;
173 }
174
175 return ret;
176}
177
Russell King6e21ee62009-10-06 15:16:27 +0100178static void h3xxx_uart_pm(struct uart_port *port, u_int state, u_int oldstate)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700179{
Dmitry Artamonow2a151a02009-11-27 11:10:58 +0100180 if (port->mapbase == _Ser3UTCR0)
Dmitry Artamonow22f97402009-11-27 12:02:28 +0100181 if (!gpio_request(H3XXX_EGPIO_RS232_ON, "RS232 transceiver")) {
182 gpio_direction_output(H3XXX_EGPIO_RS232_ON, !state);
183 gpio_free(H3XXX_EGPIO_RS232_ON);
184 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700185}
186
187/*
188 * Enable/Disable wake up events for this serial port.
189 * Obviously, we only support this on the normal COM port.
190 */
Russell King6e21ee62009-10-06 15:16:27 +0100191static int h3xxx_uart_set_wake(struct uart_port *port, u_int enable)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700192{
193 int err = -EINVAL;
194
195 if (port->mapbase == _Ser3UTCR0) {
196 if (enable)
197 PWER |= PWER_GPIO23 | PWER_GPIO25; /* DCD and CTS */
198 else
199 PWER &= ~(PWER_GPIO23 | PWER_GPIO25); /* DCD and CTS */
200 err = 0;
201 }
202 return err;
203}
204
Russell King6e21ee62009-10-06 15:16:27 +0100205static struct sa1100_port_fns h3xxx_port_fns __initdata = {
206 .set_mctrl = h3xxx_uart_set_mctrl,
207 .get_mctrl = h3xxx_uart_get_mctrl,
208 .pm = h3xxx_uart_pm,
209 .set_wake = h3xxx_uart_set_wake,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700210};
211
Dmitry Artamonow2eec62d2009-11-27 12:00:00 +0100212/*
213 * EGPIO
214 */
215
216static struct resource egpio_resources[] = {
217 [0] = {
218 .start = H3600_EGPIO_PHYS,
219 .end = H3600_EGPIO_PHYS + 0x4 - 1,
220 .flags = IORESOURCE_MEM,
221 },
222};
223
224static struct htc_egpio_chip egpio_chips[] = {
225 [0] = {
226 .reg_start = 0,
227 .gpio_base = H3XXX_EGPIO_BASE,
228 .num_gpios = 16,
229 .direction = HTC_EGPIO_OUTPUT,
230 .initial_values = 0x0080, /* H3XXX_EGPIO_RS232_ON */
231 },
232};
233
234static struct htc_egpio_platform_data egpio_info = {
235 .reg_width = 16,
236 .bus_width = 16,
237 .chip = egpio_chips,
238 .num_chips = ARRAY_SIZE(egpio_chips),
239};
240
241static struct platform_device h3xxx_egpio = {
242 .name = "htc-egpio",
243 .id = -1,
244 .resource = egpio_resources,
245 .num_resources = ARRAY_SIZE(egpio_resources),
246 .dev = {
247 .platform_data = &egpio_info,
248 },
249};
250
251static struct platform_device *h3xxx_devices[] = {
252 &h3xxx_egpio,
253};
Russell King6e21ee62009-10-06 15:16:27 +0100254
Dmitry Artamonowe55b20e2009-11-27 11:06:46 +0100255static void __init h3xxx_mach_init(void)
Russell King6e21ee62009-10-06 15:16:27 +0100256{
257 sa1100_register_uart_fns(&h3xxx_port_fns);
258 sa11x0_register_mtd(&h3xxx_flash_data, &h3xxx_flash_resource, 1);
Dmitry Artamonow2eec62d2009-11-27 12:00:00 +0100259 platform_add_devices(h3xxx_devices, ARRAY_SIZE(h3xxx_devices));
Russell King6e21ee62009-10-06 15:16:27 +0100260}
261
Linus Torvalds1da177e2005-04-16 15:20:36 -0700262static struct map_desc h3600_io_desc[] __initdata = {
Deepak Saxena92519d82005-10-28 15:19:04 +0100263 { /* static memory bank 2 CS#2 */
264 .virtual = H3600_BANK_2_VIRT,
265 .pfn = __phys_to_pfn(SA1100_CS2_PHYS),
266 .length = 0x02800000,
267 .type = MT_DEVICE
268 }, { /* static memory bank 4 CS#4 */
269 .virtual = H3600_BANK_4_VIRT,
270 .pfn = __phys_to_pfn(SA1100_CS4_PHYS),
271 .length = 0x00800000,
272 .type = MT_DEVICE
273 }, { /* EGPIO 0 CS#5 */
274 .virtual = H3600_EGPIO_VIRT,
275 .pfn = __phys_to_pfn(H3600_EGPIO_PHYS),
276 .length = 0x01000000,
277 .type = MT_DEVICE
278 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700279};
280
281/*
282 * Common map_io initialization
283 */
284
285static void __init h3xxx_map_io(void)
286{
287 sa1100_map_io();
288 iotable_init(h3600_io_desc, ARRAY_SIZE(h3600_io_desc));
289
Linus Torvalds1da177e2005-04-16 15:20:36 -0700290 sa1100_register_uart(0, 3); /* Common serial port */
291// sa1100_register_uart(1, 1); /* Microcontroller on 3100/3600 */
292
293 /* Ensure those pins are outputs and driving low */
294 PPDR |= PPC_TXD4 | PPC_SCLK | PPC_SFRM;
295 PPSR &= ~(PPC_TXD4 | PPC_SCLK | PPC_SFRM);
296
297 /* Configure suspend conditions */
298 PGSR = 0;
Russell King0fb85a52009-10-06 16:40:24 +0100299 PWER = PWER_GPIO0;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700300 PCFR = PCFR_OPDE;
301 PSDR = 0;
302
Linus Torvalds1da177e2005-04-16 15:20:36 -0700303}
304
Linus Torvalds1da177e2005-04-16 15:20:36 -0700305/************************* H3100 *************************/
306
307#ifdef CONFIG_SA1100_H3100
308
309#define H3100_EGPIO (*(volatile unsigned int *)H3600_EGPIO_VIRT)
310static unsigned int h3100_egpio = 0;
311
312static void h3100_control_egpio(enum ipaq_egpio_type x, int setp)
313{
314 unsigned int egpio = 0;
315 long gpio = 0;
316 unsigned long flags;
317
318 switch (x) {
319 case IPAQ_EGPIO_LCD_POWER:
320 egpio |= EGPIO_H3600_LCD_ON;
321 gpio |= GPIO_H3100_LCD_3V_ON;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700322 break;
323 case IPAQ_EGPIO_LCD_ENABLE:
324 break;
325 case IPAQ_EGPIO_CODEC_NRESET:
326 egpio |= EGPIO_H3600_CODEC_NRESET;
327 break;
328 case IPAQ_EGPIO_AUDIO_ON:
329 gpio |= GPIO_H3100_AUD_PWR_ON
330 | GPIO_H3100_AUD_ON;
331 break;
332 case IPAQ_EGPIO_QMUTE:
333 gpio |= GPIO_H3100_QMUTE;
334 break;
335 case IPAQ_EGPIO_OPT_NVRAM_ON:
336 egpio |= EGPIO_H3600_OPT_NVRAM_ON;
337 break;
338 case IPAQ_EGPIO_OPT_ON:
339 egpio |= EGPIO_H3600_OPT_ON;
340 break;
341 case IPAQ_EGPIO_CARD_RESET:
342 egpio |= EGPIO_H3600_CARD_RESET;
343 break;
344 case IPAQ_EGPIO_OPT_RESET:
345 egpio |= EGPIO_H3600_OPT_RESET;
346 break;
347 case IPAQ_EGPIO_IR_ON:
348 gpio |= GPIO_H3100_IR_ON;
349 break;
350 case IPAQ_EGPIO_IR_FSEL:
351 gpio |= GPIO_H3100_IR_FSEL;
352 break;
353 case IPAQ_EGPIO_RS232_ON:
354 egpio |= EGPIO_H3600_RS232_ON;
355 break;
356 case IPAQ_EGPIO_VPP_ON:
357 egpio |= EGPIO_H3600_VPP_ON;
358 break;
359 }
360
361 if (egpio || gpio) {
362 local_irq_save(flags);
363 if (setp) {
364 h3100_egpio |= egpio;
365 GPSR = gpio;
366 } else {
367 h3100_egpio &= ~egpio;
368 GPCR = gpio;
369 }
370 H3100_EGPIO = h3100_egpio;
371 local_irq_restore(flags);
372 }
373}
374
Linus Torvalds1da177e2005-04-16 15:20:36 -0700375#define H3100_DIRECT_EGPIO (GPIO_H3100_BT_ON \
376 | GPIO_H3100_GPIO3 \
377 | GPIO_H3100_QMUTE \
378 | GPIO_H3100_LCD_3V_ON \
379 | GPIO_H3100_AUD_ON \
380 | GPIO_H3100_AUD_PWR_ON \
381 | GPIO_H3100_IR_ON \
382 | GPIO_H3100_IR_FSEL)
Dmitry Artamonowcf5a87d2009-11-27 11:58:35 +0100383/*
384 * helper for sa1100fb
385 */
386static void h3100_lcd_power(int enable)
387{
Dmitry Artamonow22f97402009-11-27 12:02:28 +0100388 if (!gpio_request(H3XXX_EGPIO_LCD_ON, "LCD ON")) {
389 gpio_set_value(H3100_GPIO_LCD_3V_ON, enable);
390 gpio_direction_output(H3XXX_EGPIO_LCD_ON, enable);
391 gpio_free(H3XXX_EGPIO_LCD_ON);
392 }
Dmitry Artamonowcf5a87d2009-11-27 11:58:35 +0100393}
394
Linus Torvalds1da177e2005-04-16 15:20:36 -0700395
396static void __init h3100_map_io(void)
397{
398 h3xxx_map_io();
399
Dmitry Artamonowcf5a87d2009-11-27 11:58:35 +0100400 sa1100fb_lcd_power = h3100_lcd_power;
401
Linus Torvalds1da177e2005-04-16 15:20:36 -0700402 /* Initialize h3100-specific values here */
403 GPCR = 0x0fffffff; /* All outputs are set low by default */
Russell King6e21ee62009-10-06 15:16:27 +0100404 GPDR = GPIO_H3600_L3_CLOCK |
Linus Torvalds1da177e2005-04-16 15:20:36 -0700405 GPIO_H3600_L3_MODE | GPIO_H3600_L3_DATA |
406 GPIO_H3600_CLK_SET1 | GPIO_H3600_CLK_SET0 |
407 H3100_DIRECT_EGPIO;
408
409 /* Older bootldrs put GPIO2-9 in alternate mode on the
410 assumption that they are used for video */
411 GAFR &= ~H3100_DIRECT_EGPIO;
412
413 H3100_EGPIO = h3100_egpio;
Dmitry Artamonow607b0672009-03-15 19:14:27 +0100414 assign_h3600_egpio = h3100_control_egpio;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700415}
416
Russell Kinga5d176a2009-10-06 14:22:23 +0100417/*
418 * This turns the IRDA power on or off on the Compaq H3100
419 */
420static int h3100_irda_set_power(struct device *dev, unsigned int state)
421{
Russell King9c196f02009-10-06 14:36:05 +0100422 gpio_set_value(H3100_GPIO_IR_ON, state);
Russell Kinga5d176a2009-10-06 14:22:23 +0100423 return 0;
424}
425
426static void h3100_irda_set_speed(struct device *dev, unsigned int speed)
427{
Russell King9c196f02009-10-06 14:36:05 +0100428 gpio_set_value(H3100_GPIO_IR_FSEL, !(speed < 4000000));
Russell Kinga5d176a2009-10-06 14:22:23 +0100429}
430
431static struct irda_platform_data h3100_irda_data = {
432 .set_power = h3100_irda_set_power,
433 .set_speed = h3100_irda_set_speed,
434};
435
Russell King9c196f02009-10-06 14:36:05 +0100436static struct gpio_default_state h3100_default_gpio[] = {
437 { H3100_GPIO_IR_ON, GPIO_MODE_OUT0, "IrDA power" },
438 { H3100_GPIO_IR_FSEL, GPIO_MODE_OUT0, "IrDA fsel" },
Russell King6e21ee62009-10-06 15:16:27 +0100439 { H3XXX_GPIO_COM_DCD, GPIO_MODE_IN, "COM DCD" },
440 { H3XXX_GPIO_COM_CTS, GPIO_MODE_IN, "COM CTS" },
441 { H3XXX_GPIO_COM_RTS, GPIO_MODE_OUT0, "COM RTS" },
Dmitry Artamonow22f97402009-11-27 12:02:28 +0100442 { H3100_GPIO_LCD_3V_ON, GPIO_MODE_OUT0, "LCD 3v" },
Russell King9c196f02009-10-06 14:36:05 +0100443};
444
Dmitry Artamonowe55b20e2009-11-27 11:06:46 +0100445static void __init h3100_mach_init(void)
Russell King898e8102009-10-06 14:19:44 +0100446{
Russell King9c196f02009-10-06 14:36:05 +0100447 h3xxx_init_gpio(h3100_default_gpio, ARRAY_SIZE(h3100_default_gpio));
Russell King898e8102009-10-06 14:19:44 +0100448 h3xxx_mach_init();
Russell Kinga5d176a2009-10-06 14:22:23 +0100449 sa11x0_register_irda(&h3100_irda_data);
Russell King898e8102009-10-06 14:19:44 +0100450}
451
Linus Torvalds1da177e2005-04-16 15:20:36 -0700452MACHINE_START(H3100, "Compaq iPAQ H3100")
Russell Kinge9dea0c2005-07-03 17:38:58 +0100453 .phys_io = 0x80000000,
454 .io_pg_offst = ((0xf8000000) >> 18) & 0xfffc,
455 .boot_params = 0xc0000100,
456 .map_io = h3100_map_io,
457 .init_irq = sa1100_init_irq,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700458 .timer = &sa1100_timer,
Russell King898e8102009-10-06 14:19:44 +0100459 .init_machine = h3100_mach_init,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700460MACHINE_END
461
462#endif /* CONFIG_SA1100_H3100 */
463
464/************************* H3600 *************************/
465
466#ifdef CONFIG_SA1100_H3600
467
468#define H3600_EGPIO (*(volatile unsigned int *)H3600_EGPIO_VIRT)
469static unsigned int h3600_egpio = EGPIO_H3600_RS232_ON;
470
471static void h3600_control_egpio(enum ipaq_egpio_type x, int setp)
472{
473 unsigned int egpio = 0;
474 unsigned long flags;
475
476 switch (x) {
477 case IPAQ_EGPIO_LCD_POWER:
478 egpio |= EGPIO_H3600_LCD_ON |
479 EGPIO_H3600_LCD_PCI |
480 EGPIO_H3600_LCD_5V_ON |
481 EGPIO_H3600_LVDD_ON;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700482 break;
483 case IPAQ_EGPIO_LCD_ENABLE:
484 break;
485 case IPAQ_EGPIO_CODEC_NRESET:
486 egpio |= EGPIO_H3600_CODEC_NRESET;
487 break;
488 case IPAQ_EGPIO_AUDIO_ON:
489 egpio |= EGPIO_H3600_AUD_AMP_ON |
490 EGPIO_H3600_AUD_PWR_ON;
491 break;
492 case IPAQ_EGPIO_QMUTE:
493 egpio |= EGPIO_H3600_QMUTE;
494 break;
495 case IPAQ_EGPIO_OPT_NVRAM_ON:
496 egpio |= EGPIO_H3600_OPT_NVRAM_ON;
497 break;
498 case IPAQ_EGPIO_OPT_ON:
499 egpio |= EGPIO_H3600_OPT_ON;
500 break;
501 case IPAQ_EGPIO_CARD_RESET:
502 egpio |= EGPIO_H3600_CARD_RESET;
503 break;
504 case IPAQ_EGPIO_OPT_RESET:
505 egpio |= EGPIO_H3600_OPT_RESET;
506 break;
507 case IPAQ_EGPIO_IR_ON:
508 egpio |= EGPIO_H3600_IR_ON;
509 break;
510 case IPAQ_EGPIO_IR_FSEL:
511 egpio |= EGPIO_H3600_IR_FSEL;
512 break;
513 case IPAQ_EGPIO_RS232_ON:
514 egpio |= EGPIO_H3600_RS232_ON;
515 break;
516 case IPAQ_EGPIO_VPP_ON:
517 egpio |= EGPIO_H3600_VPP_ON;
518 break;
519 }
520
521 if (egpio) {
522 local_irq_save(flags);
523 if (setp)
524 h3600_egpio |= egpio;
525 else
526 h3600_egpio &= ~egpio;
527 H3600_EGPIO = h3600_egpio;
528 local_irq_restore(flags);
529 }
530}
531
Dmitry Artamonowcf5a87d2009-11-27 11:58:35 +0100532/*
533 * helper for sa1100fb
534 */
535static void h3600_lcd_power(int enable)
536{
Dmitry Artamonow22f97402009-11-27 12:02:28 +0100537 if (gpio_request(H3XXX_EGPIO_LCD_ON, "LCD power"))
538 goto err1;
539 if (gpio_request(H3600_EGPIO_LCD_PCI, "LCD control"))
540 goto err2;
541 if (gpio_request(H3600_EGPIO_LCD_5V_ON, "LCD 5v"))
542 goto err3;
543 if (gpio_request(H3600_EGPIO_LVDD_ON, "LCD 9v/-6.5v"))
544 goto err4;
545
546 gpio_direction_output(H3XXX_EGPIO_LCD_ON, enable);
547 gpio_direction_output(H3600_EGPIO_LCD_PCI, enable);
548 gpio_direction_output(H3600_EGPIO_LCD_5V_ON, enable);
549 gpio_direction_output(H3600_EGPIO_LVDD_ON, enable);
550
551 gpio_free(H3600_EGPIO_LVDD_ON);
552err4: gpio_free(H3600_EGPIO_LCD_5V_ON);
553err3: gpio_free(H3600_EGPIO_LCD_PCI);
554err2: gpio_free(H3XXX_EGPIO_LCD_ON);
555err1: return;
Dmitry Artamonowcf5a87d2009-11-27 11:58:35 +0100556}
557
Linus Torvalds1da177e2005-04-16 15:20:36 -0700558static void __init h3600_map_io(void)
559{
560 h3xxx_map_io();
561
Dmitry Artamonowcf5a87d2009-11-27 11:58:35 +0100562 sa1100fb_lcd_power = h3600_lcd_power;
563
Linus Torvalds1da177e2005-04-16 15:20:36 -0700564 /* Initialize h3600-specific values here */
565
566 GPCR = 0x0fffffff; /* All outputs are set low by default */
Russell King6e21ee62009-10-06 15:16:27 +0100567 GPDR = GPIO_H3600_L3_CLOCK |
Linus Torvalds1da177e2005-04-16 15:20:36 -0700568 GPIO_H3600_L3_MODE | GPIO_H3600_L3_DATA |
Dmitry Artamonowd0e60412009-11-27 11:11:00 +0100569 GPIO_H3600_CLK_SET1 | GPIO_H3600_CLK_SET0;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700570
571 H3600_EGPIO = h3600_egpio; /* Maintains across sleep? */
Dmitry Artamonow607b0672009-03-15 19:14:27 +0100572 assign_h3600_egpio = h3600_control_egpio;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700573}
574
Russell Kinga5d176a2009-10-06 14:22:23 +0100575/*
576 * This turns the IRDA power on or off on the Compaq H3600
577 */
578static int h3600_irda_set_power(struct device *dev, unsigned int state)
579{
Dmitry Artamonow22f97402009-11-27 12:02:28 +0100580 gpio_set_value(H3600_EGPIO_IR_ON, state);
Russell Kinga5d176a2009-10-06 14:22:23 +0100581 return 0;
582}
583
584static void h3600_irda_set_speed(struct device *dev, unsigned int speed)
585{
Dmitry Artamonow22f97402009-11-27 12:02:28 +0100586 gpio_set_value(H3600_EGPIO_IR_FSEL, !(speed < 4000000));
587}
588
589static int h3600_irda_startup(struct device *dev)
590{
591 int err = gpio_request(H3600_EGPIO_IR_ON, "IrDA power");
592 if (err)
593 goto err1;
594 err = gpio_direction_output(H3600_EGPIO_IR_ON, 0);
595 if (err)
596 goto err2;
597 err = gpio_request(H3600_EGPIO_IR_FSEL, "IrDA fsel");
598 if (err)
599 goto err2;
600 err = gpio_direction_output(H3600_EGPIO_IR_FSEL, 0);
601 if (err)
602 goto err3;
603 return 0;
604
605err3: gpio_free(H3600_EGPIO_IR_FSEL);
606err2: gpio_free(H3600_EGPIO_IR_ON);
607err1: return err;
608}
609
610static void h3600_irda_shutdown(struct device *dev)
611{
612 gpio_free(H3600_EGPIO_IR_ON);
613 gpio_free(H3600_EGPIO_IR_FSEL);
Russell Kinga5d176a2009-10-06 14:22:23 +0100614}
615
616static struct irda_platform_data h3600_irda_data = {
617 .set_power = h3600_irda_set_power,
618 .set_speed = h3600_irda_set_speed,
Dmitry Artamonow22f97402009-11-27 12:02:28 +0100619 .startup = h3600_irda_startup,
620 .shutdown = h3600_irda_shutdown,
Russell Kinga5d176a2009-10-06 14:22:23 +0100621};
622
Russell King6e21ee62009-10-06 15:16:27 +0100623static struct gpio_default_state h3600_default_gpio[] = {
624 { H3XXX_GPIO_COM_DCD, GPIO_MODE_IN, "COM DCD" },
625 { H3XXX_GPIO_COM_CTS, GPIO_MODE_IN, "COM CTS" },
626 { H3XXX_GPIO_COM_RTS, GPIO_MODE_OUT0, "COM RTS" },
627};
628
Dmitry Artamonowe55b20e2009-11-27 11:06:46 +0100629static void __init h3600_mach_init(void)
Russell King898e8102009-10-06 14:19:44 +0100630{
Russell King6e21ee62009-10-06 15:16:27 +0100631 h3xxx_init_gpio(h3600_default_gpio, ARRAY_SIZE(h3600_default_gpio));
Russell King898e8102009-10-06 14:19:44 +0100632 h3xxx_mach_init();
Russell Kinga5d176a2009-10-06 14:22:23 +0100633 sa11x0_register_irda(&h3600_irda_data);
Russell King898e8102009-10-06 14:19:44 +0100634}
635
Linus Torvalds1da177e2005-04-16 15:20:36 -0700636MACHINE_START(H3600, "Compaq iPAQ H3600")
Russell Kinge9dea0c2005-07-03 17:38:58 +0100637 .phys_io = 0x80000000,
638 .io_pg_offst = ((0xf8000000) >> 18) & 0xfffc,
639 .boot_params = 0xc0000100,
640 .map_io = h3600_map_io,
641 .init_irq = sa1100_init_irq,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700642 .timer = &sa1100_timer,
Russell King898e8102009-10-06 14:19:44 +0100643 .init_machine = h3600_mach_init,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700644MACHINE_END
645
646#endif /* CONFIG_SA1100_H3600 */
647