blob: 118338efd7906ec63ac242af858ff5682ade577f [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>
Dmitry Eremin-Solenikovdd450772014-12-24 01:14:14 +030021#include <linux/platform_data/irda-sa11x0.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070022
Dmitry Artamonow8715b292009-11-27 12:09:25 +010023#include <mach/h3xxx.h>
Rob Herringf314f332012-02-24 00:06:51 +010024#include <mach/irqs.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070025
26#include "generic.h"
27
Dmitry Artamonowcf5a87d2009-11-27 11:58:35 +010028/*
29 * helper for sa1100fb
30 */
Dmitry Eremin-Solenikov8bed5762013-11-26 11:09:49 +010031static struct gpio h3600_lcd_gpio[] = {
32 { H3XXX_EGPIO_LCD_ON, GPIOF_OUT_INIT_LOW, "LCD power" },
33 { H3600_EGPIO_LCD_PCI, GPIOF_OUT_INIT_LOW, "LCD control" },
34 { H3600_EGPIO_LCD_5V_ON, GPIOF_OUT_INIT_LOW, "LCD 5v" },
35 { H3600_EGPIO_LVDD_ON, GPIOF_OUT_INIT_LOW, "LCD 9v/-6.5v" },
36};
37
38static bool h3600_lcd_request(void)
39{
40 static bool h3600_lcd_ok;
41 int rc;
42
43 if (h3600_lcd_ok)
44 return true;
45
46 rc = gpio_request_array(h3600_lcd_gpio, ARRAY_SIZE(h3600_lcd_gpio));
47 if (rc)
48 pr_err("%s: can't request GPIOs\n", __func__);
49 else
50 h3600_lcd_ok = true;
51
52 return h3600_lcd_ok;
53}
54
Dmitry Artamonowcf5a87d2009-11-27 11:58:35 +010055static void h3600_lcd_power(int enable)
56{
Dmitry Eremin-Solenikov8bed5762013-11-26 11:09:49 +010057 if (!h3600_lcd_request())
58 return;
Dmitry Artamonow22f97402009-11-27 12:02:28 +010059
60 gpio_direction_output(H3XXX_EGPIO_LCD_ON, enable);
61 gpio_direction_output(H3600_EGPIO_LCD_PCI, enable);
62 gpio_direction_output(H3600_EGPIO_LCD_5V_ON, enable);
63 gpio_direction_output(H3600_EGPIO_LVDD_ON, enable);
Dmitry Artamonowcf5a87d2009-11-27 11:58:35 +010064}
65
Russell Kinge1b7a722012-01-14 11:50:04 +000066static const struct sa1100fb_rgb h3600_rgb_16 = {
67 .red = { .offset = 12, .length = 4, },
68 .green = { .offset = 7, .length = 4, },
69 .blue = { .offset = 1, .length = 4, },
70 .transp = { .offset = 0, .length = 0, },
71};
72
73static struct sa1100fb_mach_info h3600_lcd_info = {
74 .pixclock = 174757, .bpp = 16,
75 .xres = 320, .yres = 240,
76
77 .hsync_len = 3, .vsync_len = 3,
78 .left_margin = 12, .upper_margin = 10,
79 .right_margin = 17, .lower_margin = 1,
80
81 .cmap_static = 1,
82
83 .lccr0 = LCCR0_Color | LCCR0_Sngl | LCCR0_Act,
84 .lccr3 = LCCR3_OutEnH | LCCR3_PixRsEdg | LCCR3_ACBsDiv(2),
85
86 .rgb[RGB_16] = &h3600_rgb_16,
Russell King086ada52012-01-14 12:03:22 +000087
88 .lcd_power = h3600_lcd_power,
Russell Kinge1b7a722012-01-14 11:50:04 +000089};
90
91
Linus Torvalds1da177e2005-04-16 15:20:36 -070092static void __init h3600_map_io(void)
93{
94 h3xxx_map_io();
Linus Torvalds1da177e2005-04-16 15:20:36 -070095}
96
Russell Kinga5d176a2009-10-06 14:22:23 +010097/*
98 * This turns the IRDA power on or off on the Compaq H3600
99 */
Dmitry Eremin-Solenikov15cc3242013-11-26 11:10:40 +0100100static struct gpio h3600_irda_gpio[] = {
101 { H3600_EGPIO_IR_ON, GPIOF_OUT_INIT_LOW, "IrDA power" },
102 { H3600_EGPIO_IR_FSEL, GPIOF_OUT_INIT_LOW, "IrDA fsel" },
103};
104
Russell Kinga5d176a2009-10-06 14:22:23 +0100105static int h3600_irda_set_power(struct device *dev, unsigned int state)
106{
Dmitry Artamonow22f97402009-11-27 12:02:28 +0100107 gpio_set_value(H3600_EGPIO_IR_ON, state);
Russell Kinga5d176a2009-10-06 14:22:23 +0100108 return 0;
109}
110
111static void h3600_irda_set_speed(struct device *dev, unsigned int speed)
112{
Dmitry Artamonow22f97402009-11-27 12:02:28 +0100113 gpio_set_value(H3600_EGPIO_IR_FSEL, !(speed < 4000000));
114}
115
116static int h3600_irda_startup(struct device *dev)
117{
Dmitry Eremin-Solenikov15cc3242013-11-26 11:10:40 +0100118 return gpio_request_array(h3600_irda_gpio, sizeof(h3600_irda_gpio));
Dmitry Artamonow22f97402009-11-27 12:02:28 +0100119}
120
121static void h3600_irda_shutdown(struct device *dev)
122{
Dmitry Eremin-Solenikov15cc3242013-11-26 11:10:40 +0100123 return gpio_free_array(h3600_irda_gpio, sizeof(h3600_irda_gpio));
Russell Kinga5d176a2009-10-06 14:22:23 +0100124}
125
126static struct irda_platform_data h3600_irda_data = {
127 .set_power = h3600_irda_set_power,
128 .set_speed = h3600_irda_set_speed,
Dmitry Artamonow22f97402009-11-27 12:02:28 +0100129 .startup = h3600_irda_startup,
130 .shutdown = h3600_irda_shutdown,
Russell Kinga5d176a2009-10-06 14:22:23 +0100131};
132
Dmitry Artamonowe55b20e2009-11-27 11:06:46 +0100133static void __init h3600_mach_init(void)
Russell King898e8102009-10-06 14:19:44 +0100134{
135 h3xxx_mach_init();
Russell Kinge1b7a722012-01-14 11:50:04 +0000136
Russell Kinge1b7a722012-01-14 11:50:04 +0000137 sa11x0_register_lcd(&h3600_lcd_info);
Russell Kinga5d176a2009-10-06 14:22:23 +0100138 sa11x0_register_irda(&h3600_irda_data);
Russell King898e8102009-10-06 14:19:44 +0100139}
140
Linus Torvalds1da177e2005-04-16 15:20:36 -0700141MACHINE_START(H3600, "Compaq iPAQ H3600")
Nicolas Pitre17f44252011-07-05 22:38:17 -0400142 .atag_offset = 0x100,
Russell Kinge9dea0c2005-07-03 17:38:58 +0100143 .map_io = h3600_map_io,
Rob Herringf314f332012-02-24 00:06:51 +0100144 .nr_irqs = SA1100_NR_IRQS,
Russell Kinge9dea0c2005-07-03 17:38:58 +0100145 .init_irq = sa1100_init_irq,
Stephen Warren6bb27d72012-11-08 12:40:59 -0700146 .init_time = sa1100_timer_init,
Russell King898e8102009-10-06 14:19:44 +0100147 .init_machine = h3600_mach_init,
Shawn Guo7fea1ba2012-04-26 21:22:45 +0800148 .init_late = sa11x0_init_late,
Russell Kingd9ca5832011-11-05 10:28:50 +0000149 .restart = sa11x0_restart,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700150MACHINE_END
151