Commit | Line | Data |
---|---|---|
d2912cb1 | 1 | // SPDX-License-Identifier: GPL-2.0-only |
86e5e38c | 2 | /* |
6e23fcb3 | 3 | * Support for Compaq iPAQ H3100 handheld computer |
86e5e38c | 4 | * |
6e23fcb3 DA |
5 | * Copyright (c) 2000,1 Compaq Computer Corporation. (Author: Jamey Hicks) |
6 | * Copyright (c) 2009 Dmitry Artamonow <mad_soft@inbox.ru> | |
86e5e38c | 7 | */ |
6e23fcb3 | 8 | |
86e5e38c DA |
9 | #include <linux/init.h> |
10 | #include <linux/kernel.h> | |
86e5e38c | 11 | #include <linux/gpio.h> |
86e5e38c | 12 | |
e1b7a72a RK |
13 | #include <video/sa1100fb.h> |
14 | ||
86e5e38c | 15 | #include <asm/mach-types.h> |
86e5e38c | 16 | #include <asm/mach/arch.h> |
dd450777 | 17 | #include <linux/platform_data/irda-sa11x0.h> |
86e5e38c DA |
18 | |
19 | #include <mach/h3xxx.h> | |
f314f33b | 20 | #include <mach/irqs.h> |
86e5e38c DA |
21 | |
22 | #include "generic.h" | |
23 | ||
24 | /* | |
25 | * helper for sa1100fb | |
26 | */ | |
5f72d85e DES |
27 | static struct gpio h3100_lcd_gpio[] = { |
28 | { H3100_GPIO_LCD_3V_ON, GPIOF_OUT_INIT_LOW, "LCD 3V" }, | |
29 | { H3XXX_EGPIO_LCD_ON, GPIOF_OUT_INIT_LOW, "LCD ON" }, | |
30 | }; | |
31 | ||
32 | static bool h3100_lcd_request(void) | |
33 | { | |
34 | static bool h3100_lcd_ok; | |
35 | int rc; | |
36 | ||
37 | if (h3100_lcd_ok) | |
38 | return true; | |
39 | ||
40 | rc = gpio_request_array(h3100_lcd_gpio, ARRAY_SIZE(h3100_lcd_gpio)); | |
41 | if (rc) | |
42 | pr_err("%s: can't request GPIOs\n", __func__); | |
43 | else | |
44 | h3100_lcd_ok = true; | |
45 | ||
46 | return h3100_lcd_ok; | |
47 | } | |
48 | ||
86e5e38c DA |
49 | static void h3100_lcd_power(int enable) |
50 | { | |
5f72d85e DES |
51 | if (!h3100_lcd_request()) |
52 | return; | |
53 | ||
54 | gpio_set_value(H3100_GPIO_LCD_3V_ON, enable); | |
55 | gpio_set_value(H3XXX_EGPIO_LCD_ON, enable); | |
86e5e38c DA |
56 | } |
57 | ||
e1b7a72a RK |
58 | static struct sa1100fb_mach_info h3100_lcd_info = { |
59 | .pixclock = 406977, .bpp = 4, | |
60 | .xres = 320, .yres = 240, | |
61 | ||
62 | .hsync_len = 26, .vsync_len = 41, | |
63 | .left_margin = 4, .upper_margin = 0, | |
64 | .right_margin = 4, .lower_margin = 0, | |
65 | ||
66 | .sync = FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT, | |
67 | .cmap_greyscale = 1, | |
68 | .cmap_inverse = 1, | |
69 | ||
70 | .lccr0 = LCCR0_Mono | LCCR0_4PixMono | LCCR0_Sngl | LCCR0_Pas, | |
71 | .lccr3 = LCCR3_OutEnH | LCCR3_PixRsEdg | LCCR3_ACBsDiv(2), | |
086ada54 RK |
72 | |
73 | .lcd_power = h3100_lcd_power, | |
e1b7a72a | 74 | }; |
86e5e38c DA |
75 | |
76 | static void __init h3100_map_io(void) | |
77 | { | |
78 | h3xxx_map_io(); | |
79 | ||
86e5e38c DA |
80 | /* Older bootldrs put GPIO2-9 in alternate mode on the |
81 | assumption that they are used for video */ | |
82 | GAFR &= ~0x000001fb; | |
83 | } | |
84 | ||
85 | /* | |
86 | * This turns the IRDA power on or off on the Compaq H3100 | |
87 | */ | |
d8eec82c DES |
88 | static struct gpio h3100_irda_gpio[] = { |
89 | { H3100_GPIO_IR_ON, GPIOF_OUT_INIT_LOW, "IrDA power" }, | |
90 | { H3100_GPIO_IR_FSEL, GPIOF_OUT_INIT_LOW, "IrDA fsel" }, | |
91 | }; | |
92 | ||
86e5e38c DA |
93 | static int h3100_irda_set_power(struct device *dev, unsigned int state) |
94 | { | |
95 | gpio_set_value(H3100_GPIO_IR_ON, state); | |
96 | return 0; | |
97 | } | |
98 | ||
99 | static void h3100_irda_set_speed(struct device *dev, unsigned int speed) | |
100 | { | |
101 | gpio_set_value(H3100_GPIO_IR_FSEL, !(speed < 4000000)); | |
102 | } | |
103 | ||
d8eec82c DES |
104 | static int h3100_irda_startup(struct device *dev) |
105 | { | |
106 | return gpio_request_array(h3100_irda_gpio, sizeof(h3100_irda_gpio)); | |
107 | } | |
108 | ||
109 | static void h3100_irda_shutdown(struct device *dev) | |
110 | { | |
111 | return gpio_free_array(h3100_irda_gpio, sizeof(h3100_irda_gpio)); | |
112 | } | |
113 | ||
86e5e38c DA |
114 | static struct irda_platform_data h3100_irda_data = { |
115 | .set_power = h3100_irda_set_power, | |
116 | .set_speed = h3100_irda_set_speed, | |
d8eec82c DES |
117 | .startup = h3100_irda_startup, |
118 | .shutdown = h3100_irda_shutdown, | |
86e5e38c DA |
119 | }; |
120 | ||
86e5e38c DA |
121 | static void __init h3100_mach_init(void) |
122 | { | |
86e5e38c | 123 | h3xxx_mach_init(); |
e1b7a72a | 124 | |
d66a2fb8 | 125 | sa11x0_register_pcmcia(-1, NULL); |
e1b7a72a | 126 | sa11x0_register_lcd(&h3100_lcd_info); |
86e5e38c DA |
127 | sa11x0_register_irda(&h3100_irda_data); |
128 | } | |
129 | ||
130 | MACHINE_START(H3100, "Compaq iPAQ H3100") | |
17f4425d | 131 | .atag_offset = 0x100, |
86e5e38c | 132 | .map_io = h3100_map_io, |
f314f33b | 133 | .nr_irqs = SA1100_NR_IRQS, |
86e5e38c | 134 | .init_irq = sa1100_init_irq, |
6bb27d73 | 135 | .init_time = sa1100_timer_init, |
86e5e38c | 136 | .init_machine = h3100_mach_init, |
7fea1ba5 | 137 | .init_late = sa11x0_init_late, |
d9ca5839 | 138 | .restart = sa11x0_restart, |
86e5e38c DA |
139 | MACHINE_END |
140 |