blob: 25f189b4d7acc055dce8f24054c68b99ff6e5be4 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
Dmitry Artamonow6e23fcb2009-11-27 12:11:48 +01002 * Support for Compaq iPAQ H3600 handheld computer
Linus Torvalds1da177e2005-04-16 15:20:36 -07003 *
Dmitry Artamonow6e23fcb2009-11-27 12:11:48 +01004 * Copyright (c) 2000,1 Compaq Computer Corporation. (Author: Jamey Hicks)
5 * Copyright (c) 2009 Dmitry Artamonow <mad_soft@inbox.ru>
Linus Torvalds1da177e2005-04-16 15:20:36 -07006 *
Dmitry Artamonow6e23fcb2009-11-27 12:11:48 +01007 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 as
9 * published by the Free Software Foundation.
Linus Torvalds1da177e2005-04-16 15:20:36 -070010 *
11 */
Dmitry Artamonow6e23fcb2009-11-27 12:11:48 +010012
Linus Torvalds1da177e2005-04-16 15:20:36 -070013#include <linux/module.h>
14#include <linux/init.h>
15#include <linux/kernel.h>
16#include <linux/tty.h>
17#include <linux/pm.h>
18#include <linux/device.h>
Dmitry Artamonow2eec62d2009-11-27 12:00:00 +010019#include <linux/mfd/htc-egpio.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070020#include <linux/mtd/mtd.h>
21#include <linux/mtd/partitions.h>
22#include <linux/serial_core.h>
Russell King0831e3e2009-10-06 14:35:16 +010023#include <linux/gpio.h>
Dmitry Artamonow2eec62d2009-11-27 12:00:00 +010024#include <linux/platform_device.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070025
26#include <asm/irq.h>
Russell Kinga09e64f2008-08-05 16:14:15 +010027#include <mach/hardware.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070028#include <asm/mach-types.h>
29#include <asm/setup.h>
30
31#include <asm/mach/irq.h>
32#include <asm/mach/arch.h>
33#include <asm/mach/flash.h>
34#include <asm/mach/irda.h>
35#include <asm/mach/map.h>
36#include <asm/mach/serial_sa1100.h>
37
Dmitry Artamonow8715b292009-11-27 12:09:25 +010038#include <mach/h3xxx.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070039
40#include "generic.h"
41
Dmitry Artamonowcf5a87d2009-11-27 11:58:35 +010042/*
43 * helper for sa1100fb
44 */
45static void h3600_lcd_power(int enable)
46{
Dmitry Artamonow22f97402009-11-27 12:02:28 +010047 if (gpio_request(H3XXX_EGPIO_LCD_ON, "LCD power"))
48 goto err1;
49 if (gpio_request(H3600_EGPIO_LCD_PCI, "LCD control"))
50 goto err2;
51 if (gpio_request(H3600_EGPIO_LCD_5V_ON, "LCD 5v"))
52 goto err3;
53 if (gpio_request(H3600_EGPIO_LVDD_ON, "LCD 9v/-6.5v"))
54 goto err4;
55
56 gpio_direction_output(H3XXX_EGPIO_LCD_ON, enable);
57 gpio_direction_output(H3600_EGPIO_LCD_PCI, enable);
58 gpio_direction_output(H3600_EGPIO_LCD_5V_ON, enable);
59 gpio_direction_output(H3600_EGPIO_LVDD_ON, enable);
60
61 gpio_free(H3600_EGPIO_LVDD_ON);
62err4: gpio_free(H3600_EGPIO_LCD_5V_ON);
63err3: gpio_free(H3600_EGPIO_LCD_PCI);
64err2: gpio_free(H3XXX_EGPIO_LCD_ON);
65err1: return;
Dmitry Artamonowcf5a87d2009-11-27 11:58:35 +010066}
67
Linus Torvalds1da177e2005-04-16 15:20:36 -070068static void __init h3600_map_io(void)
69{
70 h3xxx_map_io();
71
Dmitry Artamonowcf5a87d2009-11-27 11:58:35 +010072 sa1100fb_lcd_power = h3600_lcd_power;
Linus Torvalds1da177e2005-04-16 15:20:36 -070073}
74
Russell Kinga5d176a2009-10-06 14:22:23 +010075/*
76 * This turns the IRDA power on or off on the Compaq H3600
77 */
78static int h3600_irda_set_power(struct device *dev, unsigned int state)
79{
Dmitry Artamonow22f97402009-11-27 12:02:28 +010080 gpio_set_value(H3600_EGPIO_IR_ON, state);
Russell Kinga5d176a2009-10-06 14:22:23 +010081 return 0;
82}
83
84static void h3600_irda_set_speed(struct device *dev, unsigned int speed)
85{
Dmitry Artamonow22f97402009-11-27 12:02:28 +010086 gpio_set_value(H3600_EGPIO_IR_FSEL, !(speed < 4000000));
87}
88
89static int h3600_irda_startup(struct device *dev)
90{
91 int err = gpio_request(H3600_EGPIO_IR_ON, "IrDA power");
92 if (err)
93 goto err1;
94 err = gpio_direction_output(H3600_EGPIO_IR_ON, 0);
95 if (err)
96 goto err2;
97 err = gpio_request(H3600_EGPIO_IR_FSEL, "IrDA fsel");
98 if (err)
99 goto err2;
100 err = gpio_direction_output(H3600_EGPIO_IR_FSEL, 0);
101 if (err)
102 goto err3;
103 return 0;
104
105err3: gpio_free(H3600_EGPIO_IR_FSEL);
106err2: gpio_free(H3600_EGPIO_IR_ON);
107err1: return err;
108}
109
110static void h3600_irda_shutdown(struct device *dev)
111{
112 gpio_free(H3600_EGPIO_IR_ON);
113 gpio_free(H3600_EGPIO_IR_FSEL);
Russell Kinga5d176a2009-10-06 14:22:23 +0100114}
115
116static struct irda_platform_data h3600_irda_data = {
117 .set_power = h3600_irda_set_power,
118 .set_speed = h3600_irda_set_speed,
Dmitry Artamonow22f97402009-11-27 12:02:28 +0100119 .startup = h3600_irda_startup,
120 .shutdown = h3600_irda_shutdown,
Russell Kinga5d176a2009-10-06 14:22:23 +0100121};
122
Russell King6e21ee62009-10-06 15:16:27 +0100123static struct gpio_default_state h3600_default_gpio[] = {
124 { H3XXX_GPIO_COM_DCD, GPIO_MODE_IN, "COM DCD" },
125 { H3XXX_GPIO_COM_CTS, GPIO_MODE_IN, "COM CTS" },
126 { H3XXX_GPIO_COM_RTS, GPIO_MODE_OUT0, "COM RTS" },
127};
128
Dmitry Artamonowe55b20e2009-11-27 11:06:46 +0100129static void __init h3600_mach_init(void)
Russell King898e8102009-10-06 14:19:44 +0100130{
Russell King6e21ee62009-10-06 15:16:27 +0100131 h3xxx_init_gpio(h3600_default_gpio, ARRAY_SIZE(h3600_default_gpio));
Russell King898e8102009-10-06 14:19:44 +0100132 h3xxx_mach_init();
Russell Kinga5d176a2009-10-06 14:22:23 +0100133 sa11x0_register_irda(&h3600_irda_data);
Russell King898e8102009-10-06 14:19:44 +0100134}
135
Linus Torvalds1da177e2005-04-16 15:20:36 -0700136MACHINE_START(H3600, "Compaq iPAQ H3600")
Russell Kinge9dea0c2005-07-03 17:38:58 +0100137 .phys_io = 0x80000000,
138 .io_pg_offst = ((0xf8000000) >> 18) & 0xfffc,
139 .boot_params = 0xc0000100,
140 .map_io = h3600_map_io,
141 .init_irq = sa1100_init_irq,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700142 .timer = &sa1100_timer,
Russell King898e8102009-10-06 14:19:44 +0100143 .init_machine = h3600_mach_init,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700144MACHINE_END
145