Commit | Line | Data |
---|---|---|
1da177e4 | 1 | /* |
6e23fcb3 | 2 | * Support for Compaq iPAQ H3600 handheld computer |
1da177e4 | 3 | * |
6e23fcb3 DA |
4 | * Copyright (c) 2000,1 Compaq Computer Corporation. (Author: Jamey Hicks) |
5 | * Copyright (c) 2009 Dmitry Artamonow <mad_soft@inbox.ru> | |
1da177e4 | 6 | * |
6e23fcb3 DA |
7 | * 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. | |
1da177e4 LT |
10 | * |
11 | */ | |
6e23fcb3 | 12 | |
1da177e4 LT |
13 | #include <linux/init.h> |
14 | #include <linux/kernel.h> | |
0831e3e4 | 15 | #include <linux/gpio.h> |
1da177e4 | 16 | |
e1b7a72a RK |
17 | #include <video/sa1100fb.h> |
18 | ||
1da177e4 | 19 | #include <asm/mach-types.h> |
1da177e4 | 20 | #include <asm/mach/arch.h> |
dd450777 | 21 | #include <linux/platform_data/irda-sa11x0.h> |
1da177e4 | 22 | |
8715b29d | 23 | #include <mach/h3xxx.h> |
f314f33b | 24 | #include <mach/irqs.h> |
1da177e4 LT |
25 | |
26 | #include "generic.h" | |
27 | ||
cf5a87d8 DA |
28 | /* |
29 | * helper for sa1100fb | |
30 | */ | |
8bed576c DES |
31 | static 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 | ||
38 | static 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 | ||
cf5a87d8 DA |
55 | static void h3600_lcd_power(int enable) |
56 | { | |
8bed576c DES |
57 | if (!h3600_lcd_request()) |
58 | return; | |
22f97405 DA |
59 | |
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); | |
cf5a87d8 DA |
64 | } |
65 | ||
e1b7a72a RK |
66 | static 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 | ||
73 | static 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, | |
086ada54 RK |
87 | |
88 | .lcd_power = h3600_lcd_power, | |
e1b7a72a RK |
89 | }; |
90 | ||
91 | ||
1da177e4 LT |
92 | static void __init h3600_map_io(void) |
93 | { | |
94 | h3xxx_map_io(); | |
1da177e4 LT |
95 | } |
96 | ||
a5d176a1 RK |
97 | /* |
98 | * This turns the IRDA power on or off on the Compaq H3600 | |
99 | */ | |
15cc324a DES |
100 | static 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 | ||
a5d176a1 RK |
105 | static int h3600_irda_set_power(struct device *dev, unsigned int state) |
106 | { | |
22f97405 | 107 | gpio_set_value(H3600_EGPIO_IR_ON, state); |
a5d176a1 RK |
108 | return 0; |
109 | } | |
110 | ||
111 | static void h3600_irda_set_speed(struct device *dev, unsigned int speed) | |
112 | { | |
22f97405 DA |
113 | gpio_set_value(H3600_EGPIO_IR_FSEL, !(speed < 4000000)); |
114 | } | |
115 | ||
116 | static int h3600_irda_startup(struct device *dev) | |
117 | { | |
15cc324a | 118 | return gpio_request_array(h3600_irda_gpio, sizeof(h3600_irda_gpio)); |
22f97405 DA |
119 | } |
120 | ||
121 | static void h3600_irda_shutdown(struct device *dev) | |
122 | { | |
15cc324a | 123 | return gpio_free_array(h3600_irda_gpio, sizeof(h3600_irda_gpio)); |
a5d176a1 RK |
124 | } |
125 | ||
126 | static struct irda_platform_data h3600_irda_data = { | |
127 | .set_power = h3600_irda_set_power, | |
128 | .set_speed = h3600_irda_set_speed, | |
22f97405 DA |
129 | .startup = h3600_irda_startup, |
130 | .shutdown = h3600_irda_shutdown, | |
a5d176a1 RK |
131 | }; |
132 | ||
e55b20e8 | 133 | static void __init h3600_mach_init(void) |
898e810e RK |
134 | { |
135 | h3xxx_mach_init(); | |
e1b7a72a | 136 | |
e1b7a72a | 137 | sa11x0_register_lcd(&h3600_lcd_info); |
a5d176a1 | 138 | sa11x0_register_irda(&h3600_irda_data); |
898e810e RK |
139 | } |
140 | ||
1da177e4 | 141 | MACHINE_START(H3600, "Compaq iPAQ H3600") |
17f4425d | 142 | .atag_offset = 0x100, |
e9dea0c6 | 143 | .map_io = h3600_map_io, |
f314f33b | 144 | .nr_irqs = SA1100_NR_IRQS, |
e9dea0c6 | 145 | .init_irq = sa1100_init_irq, |
6bb27d73 | 146 | .init_time = sa1100_timer_init, |
898e810e | 147 | .init_machine = h3600_mach_init, |
7fea1ba5 | 148 | .init_late = sa11x0_init_late, |
d9ca5839 | 149 | .restart = sa11x0_restart, |
1da177e4 LT |
150 | MACHINE_END |
151 |