blob: 2feac56ec90d9b3a68328be8b4240c400678ea9b [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/init.h>
14#include <linux/kernel.h>
Russell King0831e3e2009-10-06 14:35:16 +010015#include <linux/gpio.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070016
Russell Kinge1b7a722012-01-14 11:50:04 +000017#include <video/sa1100fb.h>
18
Linus Torvalds1da177e2005-04-16 15:20:36 -070019#include <asm/mach-types.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070020#include <asm/mach/arch.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070021#include <asm/mach/irda.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070022
Dmitry Artamonow8715b292009-11-27 12:09:25 +010023#include <mach/h3xxx.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070024
25#include "generic.h"
26
Dmitry Artamonowcf5a87d2009-11-27 11:58:35 +010027/*
28 * helper for sa1100fb
29 */
30static void h3600_lcd_power(int enable)
31{
Dmitry Artamonow729fae42009-11-27 12:22:32 +010032 if (gpio_request(H3XXX_EGPIO_LCD_ON, "LCD power")) {
33 pr_err("%s: can't request H3XXX_EGPIO_LCD_ON\n", __func__);
Dmitry Artamonow22f97402009-11-27 12:02:28 +010034 goto err1;
Dmitry Artamonow729fae42009-11-27 12:22:32 +010035 }
36 if (gpio_request(H3600_EGPIO_LCD_PCI, "LCD control")) {
37 pr_err("%s: can't request H3XXX_EGPIO_LCD_PCI\n", __func__);
Dmitry Artamonow22f97402009-11-27 12:02:28 +010038 goto err2;
Dmitry Artamonow729fae42009-11-27 12:22:32 +010039 }
40 if (gpio_request(H3600_EGPIO_LCD_5V_ON, "LCD 5v")) {
41 pr_err("%s: can't request H3XXX_EGPIO_LCD_5V_ON\n", __func__);
Dmitry Artamonow22f97402009-11-27 12:02:28 +010042 goto err3;
Dmitry Artamonow729fae42009-11-27 12:22:32 +010043 }
44 if (gpio_request(H3600_EGPIO_LVDD_ON, "LCD 9v/-6.5v")) {
45 pr_err("%s: can't request H3600_EGPIO_LVDD_ON\n", __func__);
Dmitry Artamonow22f97402009-11-27 12:02:28 +010046 goto err4;
Dmitry Artamonow729fae42009-11-27 12:22:32 +010047 }
Dmitry Artamonow22f97402009-11-27 12:02:28 +010048
49 gpio_direction_output(H3XXX_EGPIO_LCD_ON, enable);
50 gpio_direction_output(H3600_EGPIO_LCD_PCI, enable);
51 gpio_direction_output(H3600_EGPIO_LCD_5V_ON, enable);
52 gpio_direction_output(H3600_EGPIO_LVDD_ON, enable);
53
54 gpio_free(H3600_EGPIO_LVDD_ON);
55err4: gpio_free(H3600_EGPIO_LCD_5V_ON);
56err3: gpio_free(H3600_EGPIO_LCD_PCI);
57err2: gpio_free(H3XXX_EGPIO_LCD_ON);
58err1: return;
Dmitry Artamonowcf5a87d2009-11-27 11:58:35 +010059}
60
Russell Kinge1b7a722012-01-14 11:50:04 +000061static const struct sa1100fb_rgb h3600_rgb_16 = {
62 .red = { .offset = 12, .length = 4, },
63 .green = { .offset = 7, .length = 4, },
64 .blue = { .offset = 1, .length = 4, },
65 .transp = { .offset = 0, .length = 0, },
66};
67
68static struct sa1100fb_mach_info h3600_lcd_info = {
69 .pixclock = 174757, .bpp = 16,
70 .xres = 320, .yres = 240,
71
72 .hsync_len = 3, .vsync_len = 3,
73 .left_margin = 12, .upper_margin = 10,
74 .right_margin = 17, .lower_margin = 1,
75
76 .cmap_static = 1,
77
78 .lccr0 = LCCR0_Color | LCCR0_Sngl | LCCR0_Act,
79 .lccr3 = LCCR3_OutEnH | LCCR3_PixRsEdg | LCCR3_ACBsDiv(2),
80
81 .rgb[RGB_16] = &h3600_rgb_16,
Russell King086ada52012-01-14 12:03:22 +000082
83 .lcd_power = h3600_lcd_power,
Russell Kinge1b7a722012-01-14 11:50:04 +000084};
85
86
Linus Torvalds1da177e2005-04-16 15:20:36 -070087static void __init h3600_map_io(void)
88{
89 h3xxx_map_io();
Linus Torvalds1da177e2005-04-16 15:20:36 -070090}
91
Russell Kinga5d176a2009-10-06 14:22:23 +010092/*
93 * This turns the IRDA power on or off on the Compaq H3600
94 */
95static int h3600_irda_set_power(struct device *dev, unsigned int state)
96{
Dmitry Artamonow22f97402009-11-27 12:02:28 +010097 gpio_set_value(H3600_EGPIO_IR_ON, state);
Russell Kinga5d176a2009-10-06 14:22:23 +010098 return 0;
99}
100
101static void h3600_irda_set_speed(struct device *dev, unsigned int speed)
102{
Dmitry Artamonow22f97402009-11-27 12:02:28 +0100103 gpio_set_value(H3600_EGPIO_IR_FSEL, !(speed < 4000000));
104}
105
106static int h3600_irda_startup(struct device *dev)
107{
108 int err = gpio_request(H3600_EGPIO_IR_ON, "IrDA power");
109 if (err)
110 goto err1;
111 err = gpio_direction_output(H3600_EGPIO_IR_ON, 0);
112 if (err)
113 goto err2;
114 err = gpio_request(H3600_EGPIO_IR_FSEL, "IrDA fsel");
115 if (err)
116 goto err2;
117 err = gpio_direction_output(H3600_EGPIO_IR_FSEL, 0);
118 if (err)
119 goto err3;
120 return 0;
121
122err3: gpio_free(H3600_EGPIO_IR_FSEL);
123err2: gpio_free(H3600_EGPIO_IR_ON);
124err1: return err;
125}
126
127static void h3600_irda_shutdown(struct device *dev)
128{
129 gpio_free(H3600_EGPIO_IR_ON);
130 gpio_free(H3600_EGPIO_IR_FSEL);
Russell Kinga5d176a2009-10-06 14:22:23 +0100131}
132
133static struct irda_platform_data h3600_irda_data = {
134 .set_power = h3600_irda_set_power,
135 .set_speed = h3600_irda_set_speed,
Dmitry Artamonow22f97402009-11-27 12:02:28 +0100136 .startup = h3600_irda_startup,
137 .shutdown = h3600_irda_shutdown,
Russell Kinga5d176a2009-10-06 14:22:23 +0100138};
139
Russell King6e21ee62009-10-06 15:16:27 +0100140static struct gpio_default_state h3600_default_gpio[] = {
141 { H3XXX_GPIO_COM_DCD, GPIO_MODE_IN, "COM DCD" },
142 { H3XXX_GPIO_COM_CTS, GPIO_MODE_IN, "COM CTS" },
143 { H3XXX_GPIO_COM_RTS, GPIO_MODE_OUT0, "COM RTS" },
144};
145
Dmitry Artamonowe55b20e2009-11-27 11:06:46 +0100146static void __init h3600_mach_init(void)
Russell King898e8102009-10-06 14:19:44 +0100147{
Russell King6e21ee62009-10-06 15:16:27 +0100148 h3xxx_init_gpio(h3600_default_gpio, ARRAY_SIZE(h3600_default_gpio));
Russell King898e8102009-10-06 14:19:44 +0100149 h3xxx_mach_init();
Russell Kinge1b7a722012-01-14 11:50:04 +0000150
Russell Kinge1b7a722012-01-14 11:50:04 +0000151 sa11x0_register_lcd(&h3600_lcd_info);
Russell Kinga5d176a2009-10-06 14:22:23 +0100152 sa11x0_register_irda(&h3600_irda_data);
Russell King898e8102009-10-06 14:19:44 +0100153}
154
Linus Torvalds1da177e2005-04-16 15:20:36 -0700155MACHINE_START(H3600, "Compaq iPAQ H3600")
Nicolas Pitre17f44252011-07-05 22:38:17 -0400156 .atag_offset = 0x100,
Russell Kinge9dea0c2005-07-03 17:38:58 +0100157 .map_io = h3600_map_io,
158 .init_irq = sa1100_init_irq,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700159 .timer = &sa1100_timer,
Russell King898e8102009-10-06 14:19:44 +0100160 .init_machine = h3600_mach_init,
Russell Kingd9ca5832011-11-05 10:28:50 +0000161 .restart = sa11x0_restart,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700162MACHINE_END
163