diff options
author | Dmitry Artamonow <mad_soft@inbox.ru> | 2009-11-27 06:10:55 -0500 |
---|---|---|
committer | Russell King <rmk+kernel@arm.linux.org.uk> | 2009-12-06 11:52:56 -0500 |
commit | 86e5e38c46b1d188c897f131d3f015ca73677f03 (patch) | |
tree | 8d2c1a00e5638395baa3cce8ac94afe73b128cad /arch/arm/mach-sa1100 | |
parent | 8715b29db2787f7c70f662b7b4d5b01017c61948 (diff) |
ARM: 5820/1: SA1100: h3100/h3600: split h3600.c
Split common h3600.c into three separate files: h3100.c, h3600.c and
h3xxx.c (the latter contains common code for h3100/h3600)
Copyright boilerplates and #includes are copied intact and will be
cleaned up later.
Signed-off-by: Dmitry Artamonow <mad_soft@inbox.ru>
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
Diffstat (limited to 'arch/arm/mach-sa1100')
-rw-r--r-- | arch/arm/mach-sa1100/Makefile | 4 | ||||
-rw-r--r-- | arch/arm/mach-sa1100/h3100.c | 119 | ||||
-rw-r--r-- | arch/arm/mach-sa1100/h3600.c | 333 | ||||
-rw-r--r-- | arch/arm/mach-sa1100/h3xxx.c | 292 | ||||
-rw-r--r-- | arch/arm/mach-sa1100/include/mach/h3xxx.h | 14 |
5 files changed, 427 insertions, 335 deletions
diff --git a/arch/arm/mach-sa1100/Makefile b/arch/arm/mach-sa1100/Makefile index bb7b8198d0c4..89349c1dd7a6 100644 --- a/arch/arm/mach-sa1100/Makefile +++ b/arch/arm/mach-sa1100/Makefile | |||
@@ -25,8 +25,8 @@ led-$(CONFIG_SA1100_CERF) += leds-cerf.o | |||
25 | 25 | ||
26 | obj-$(CONFIG_SA1100_COLLIE) += collie.o | 26 | obj-$(CONFIG_SA1100_COLLIE) += collie.o |
27 | 27 | ||
28 | obj-$(CONFIG_SA1100_H3100) += h3600.o | 28 | obj-$(CONFIG_SA1100_H3100) += h3100.o h3xxx.o |
29 | obj-$(CONFIG_SA1100_H3600) += h3600.o | 29 | obj-$(CONFIG_SA1100_H3600) += h3600.o h3xxx.o |
30 | 30 | ||
31 | obj-$(CONFIG_SA1100_HACKKIT) += hackkit.o | 31 | obj-$(CONFIG_SA1100_HACKKIT) += hackkit.o |
32 | led-$(CONFIG_SA1100_HACKKIT) += leds-hackkit.o | 32 | led-$(CONFIG_SA1100_HACKKIT) += leds-hackkit.o |
diff --git a/arch/arm/mach-sa1100/h3100.c b/arch/arm/mach-sa1100/h3100.c new file mode 100644 index 000000000000..4c7778ee57aa --- /dev/null +++ b/arch/arm/mach-sa1100/h3100.c | |||
@@ -0,0 +1,119 @@ | |||
1 | /* | ||
2 | * Hardware definitions for Compaq iPAQ H3xxx Handheld Computers | ||
3 | * | ||
4 | * Copyright 2000,1 Compaq Computer Corporation. | ||
5 | * | ||
6 | * Use consistent with the GNU GPL is permitted, | ||
7 | * provided that this copyright notice is | ||
8 | * preserved in its entirety in all copies and derived works. | ||
9 | * | ||
10 | * COMPAQ COMPUTER CORPORATION MAKES NO WARRANTIES, EXPRESSED OR IMPLIED, | ||
11 | * AS TO THE USEFULNESS OR CORRECTNESS OF THIS CODE OR ITS | ||
12 | * FITNESS FOR ANY PARTICULAR PURPOSE. | ||
13 | * | ||
14 | * Author: Jamey Hicks. | ||
15 | * | ||
16 | * History: | ||
17 | * | ||
18 | * 2001-10-?? Andrew Christian Added support for iPAQ H3800 | ||
19 | * and abstracted EGPIO interface. | ||
20 | * | ||
21 | */ | ||
22 | #include <linux/module.h> | ||
23 | #include <linux/init.h> | ||
24 | #include <linux/kernel.h> | ||
25 | #include <linux/tty.h> | ||
26 | #include <linux/pm.h> | ||
27 | #include <linux/device.h> | ||
28 | #include <linux/mfd/htc-egpio.h> | ||
29 | #include <linux/mtd/mtd.h> | ||
30 | #include <linux/mtd/partitions.h> | ||
31 | #include <linux/serial_core.h> | ||
32 | #include <linux/gpio.h> | ||
33 | #include <linux/platform_device.h> | ||
34 | |||
35 | #include <asm/irq.h> | ||
36 | #include <mach/hardware.h> | ||
37 | #include <asm/mach-types.h> | ||
38 | #include <asm/setup.h> | ||
39 | |||
40 | #include <asm/mach/irq.h> | ||
41 | #include <asm/mach/arch.h> | ||
42 | #include <asm/mach/flash.h> | ||
43 | #include <asm/mach/irda.h> | ||
44 | #include <asm/mach/map.h> | ||
45 | #include <asm/mach/serial_sa1100.h> | ||
46 | |||
47 | #include <mach/h3xxx.h> | ||
48 | |||
49 | #include "generic.h" | ||
50 | |||
51 | /* | ||
52 | * helper for sa1100fb | ||
53 | */ | ||
54 | static void h3100_lcd_power(int enable) | ||
55 | { | ||
56 | if (!gpio_request(H3XXX_EGPIO_LCD_ON, "LCD ON")) { | ||
57 | gpio_set_value(H3100_GPIO_LCD_3V_ON, enable); | ||
58 | gpio_direction_output(H3XXX_EGPIO_LCD_ON, enable); | ||
59 | gpio_free(H3XXX_EGPIO_LCD_ON); | ||
60 | } | ||
61 | } | ||
62 | |||
63 | |||
64 | static void __init h3100_map_io(void) | ||
65 | { | ||
66 | h3xxx_map_io(); | ||
67 | |||
68 | sa1100fb_lcd_power = h3100_lcd_power; | ||
69 | |||
70 | /* Older bootldrs put GPIO2-9 in alternate mode on the | ||
71 | assumption that they are used for video */ | ||
72 | GAFR &= ~0x000001fb; | ||
73 | } | ||
74 | |||
75 | /* | ||
76 | * This turns the IRDA power on or off on the Compaq H3100 | ||
77 | */ | ||
78 | static int h3100_irda_set_power(struct device *dev, unsigned int state) | ||
79 | { | ||
80 | gpio_set_value(H3100_GPIO_IR_ON, state); | ||
81 | return 0; | ||
82 | } | ||
83 | |||
84 | static void h3100_irda_set_speed(struct device *dev, unsigned int speed) | ||
85 | { | ||
86 | gpio_set_value(H3100_GPIO_IR_FSEL, !(speed < 4000000)); | ||
87 | } | ||
88 | |||
89 | static struct irda_platform_data h3100_irda_data = { | ||
90 | .set_power = h3100_irda_set_power, | ||
91 | .set_speed = h3100_irda_set_speed, | ||
92 | }; | ||
93 | |||
94 | static struct gpio_default_state h3100_default_gpio[] = { | ||
95 | { H3100_GPIO_IR_ON, GPIO_MODE_OUT0, "IrDA power" }, | ||
96 | { H3100_GPIO_IR_FSEL, GPIO_MODE_OUT0, "IrDA fsel" }, | ||
97 | { H3XXX_GPIO_COM_DCD, GPIO_MODE_IN, "COM DCD" }, | ||
98 | { H3XXX_GPIO_COM_CTS, GPIO_MODE_IN, "COM CTS" }, | ||
99 | { H3XXX_GPIO_COM_RTS, GPIO_MODE_OUT0, "COM RTS" }, | ||
100 | { H3100_GPIO_LCD_3V_ON, GPIO_MODE_OUT0, "LCD 3v" }, | ||
101 | }; | ||
102 | |||
103 | static void __init h3100_mach_init(void) | ||
104 | { | ||
105 | h3xxx_init_gpio(h3100_default_gpio, ARRAY_SIZE(h3100_default_gpio)); | ||
106 | h3xxx_mach_init(); | ||
107 | sa11x0_register_irda(&h3100_irda_data); | ||
108 | } | ||
109 | |||
110 | MACHINE_START(H3100, "Compaq iPAQ H3100") | ||
111 | .phys_io = 0x80000000, | ||
112 | .io_pg_offst = ((0xf8000000) >> 18) & 0xfffc, | ||
113 | .boot_params = 0xc0000100, | ||
114 | .map_io = h3100_map_io, | ||
115 | .init_irq = sa1100_init_irq, | ||
116 | .timer = &sa1100_timer, | ||
117 | .init_machine = h3100_mach_init, | ||
118 | MACHINE_END | ||
119 | |||
diff --git a/arch/arm/mach-sa1100/h3600.c b/arch/arm/mach-sa1100/h3600.c index dd39f90db0db..65ab286a304d 100644 --- a/arch/arm/mach-sa1100/h3600.c +++ b/arch/arm/mach-sa1100/h3600.c | |||
@@ -48,337 +48,6 @@ | |||
48 | 48 | ||
49 | #include "generic.h" | 49 | #include "generic.h" |
50 | 50 | ||
51 | struct gpio_default_state { | ||
52 | int gpio; | ||
53 | int mode; | ||
54 | const char *name; | ||
55 | }; | ||
56 | |||
57 | #define GPIO_MODE_IN -1 | ||
58 | #define GPIO_MODE_OUT0 0 | ||
59 | #define GPIO_MODE_OUT1 1 | ||
60 | |||
61 | static void h3xxx_init_gpio(struct gpio_default_state *s, size_t n) | ||
62 | { | ||
63 | while (n--) { | ||
64 | const char *name = s->name; | ||
65 | int err; | ||
66 | |||
67 | if (!name) | ||
68 | name = "[init]"; | ||
69 | err = gpio_request(s->gpio, name); | ||
70 | if (err) { | ||
71 | printk(KERN_ERR "gpio%u: unable to request: %d\n", | ||
72 | s->gpio, err); | ||
73 | continue; | ||
74 | } | ||
75 | if (s->mode >= 0) { | ||
76 | err = gpio_direction_output(s->gpio, s->mode); | ||
77 | } else { | ||
78 | err = gpio_direction_input(s->gpio); | ||
79 | } | ||
80 | if (err) { | ||
81 | printk(KERN_ERR "gpio%u: unable to set direction: %d\n", | ||
82 | s->gpio, err); | ||
83 | continue; | ||
84 | } | ||
85 | if (!s->name) | ||
86 | gpio_free(s->gpio); | ||
87 | s++; | ||
88 | } | ||
89 | } | ||
90 | |||
91 | |||
92 | /* | ||
93 | * H3xxx flash support | ||
94 | */ | ||
95 | static struct mtd_partition h3xxx_partitions[] = { | ||
96 | { | ||
97 | .name = "H3XXX boot firmware", | ||
98 | .size = 0x00040000, | ||
99 | .offset = 0, | ||
100 | .mask_flags = MTD_WRITEABLE, /* force read-only */ | ||
101 | }, { | ||
102 | .name = "H3XXX rootfs", | ||
103 | .size = MTDPART_SIZ_FULL, | ||
104 | .offset = 0x00040000, | ||
105 | } | ||
106 | }; | ||
107 | |||
108 | static void h3xxx_set_vpp(int vpp) | ||
109 | { | ||
110 | gpio_set_value(H3XXX_EGPIO_VPP_ON, vpp); | ||
111 | } | ||
112 | |||
113 | static int h3xxx_flash_init(void) | ||
114 | { | ||
115 | int err = gpio_request(H3XXX_EGPIO_VPP_ON, "Flash Vpp"); | ||
116 | if (err) | ||
117 | return err; | ||
118 | |||
119 | err = gpio_direction_output(H3XXX_EGPIO_VPP_ON, 0); | ||
120 | if (err) | ||
121 | gpio_free(H3XXX_EGPIO_VPP_ON); | ||
122 | |||
123 | return err; | ||
124 | } | ||
125 | |||
126 | static void h3xxx_flash_exit(void) | ||
127 | { | ||
128 | gpio_free(H3XXX_EGPIO_VPP_ON); | ||
129 | } | ||
130 | |||
131 | static struct flash_platform_data h3xxx_flash_data = { | ||
132 | .map_name = "cfi_probe", | ||
133 | .set_vpp = h3xxx_set_vpp, | ||
134 | .init = h3xxx_flash_init, | ||
135 | .exit = h3xxx_flash_exit, | ||
136 | .parts = h3xxx_partitions, | ||
137 | .nr_parts = ARRAY_SIZE(h3xxx_partitions), | ||
138 | }; | ||
139 | |||
140 | static struct resource h3xxx_flash_resource = { | ||
141 | .start = SA1100_CS0_PHYS, | ||
142 | .end = SA1100_CS0_PHYS + SZ_32M - 1, | ||
143 | .flags = IORESOURCE_MEM, | ||
144 | }; | ||
145 | |||
146 | |||
147 | /* | ||
148 | * H3xxx uart support | ||
149 | */ | ||
150 | static void h3xxx_uart_set_mctrl(struct uart_port *port, u_int mctrl) | ||
151 | { | ||
152 | if (port->mapbase == _Ser3UTCR0) { | ||
153 | gpio_set_value(H3XXX_GPIO_COM_RTS, !(mctrl & TIOCM_RTS)); | ||
154 | } | ||
155 | } | ||
156 | |||
157 | static u_int h3xxx_uart_get_mctrl(struct uart_port *port) | ||
158 | { | ||
159 | u_int ret = TIOCM_CD | TIOCM_CTS | TIOCM_DSR; | ||
160 | |||
161 | if (port->mapbase == _Ser3UTCR0) { | ||
162 | /* | ||
163 | * DCD and CTS bits are inverted in GPLR by RS232 transceiver | ||
164 | */ | ||
165 | if (gpio_get_value(H3XXX_GPIO_COM_DCD)) | ||
166 | ret &= ~TIOCM_CD; | ||
167 | if (gpio_get_value(H3XXX_GPIO_COM_CTS)) | ||
168 | ret &= ~TIOCM_CTS; | ||
169 | } | ||
170 | |||
171 | return ret; | ||
172 | } | ||
173 | |||
174 | static void h3xxx_uart_pm(struct uart_port *port, u_int state, u_int oldstate) | ||
175 | { | ||
176 | if (port->mapbase == _Ser3UTCR0) | ||
177 | if (!gpio_request(H3XXX_EGPIO_RS232_ON, "RS232 transceiver")) { | ||
178 | gpio_direction_output(H3XXX_EGPIO_RS232_ON, !state); | ||
179 | gpio_free(H3XXX_EGPIO_RS232_ON); | ||
180 | } | ||
181 | } | ||
182 | |||
183 | /* | ||
184 | * Enable/Disable wake up events for this serial port. | ||
185 | * Obviously, we only support this on the normal COM port. | ||
186 | */ | ||
187 | static int h3xxx_uart_set_wake(struct uart_port *port, u_int enable) | ||
188 | { | ||
189 | int err = -EINVAL; | ||
190 | |||
191 | if (port->mapbase == _Ser3UTCR0) { | ||
192 | if (enable) | ||
193 | PWER |= PWER_GPIO23 | PWER_GPIO25; /* DCD and CTS */ | ||
194 | else | ||
195 | PWER &= ~(PWER_GPIO23 | PWER_GPIO25); /* DCD and CTS */ | ||
196 | err = 0; | ||
197 | } | ||
198 | return err; | ||
199 | } | ||
200 | |||
201 | static struct sa1100_port_fns h3xxx_port_fns __initdata = { | ||
202 | .set_mctrl = h3xxx_uart_set_mctrl, | ||
203 | .get_mctrl = h3xxx_uart_get_mctrl, | ||
204 | .pm = h3xxx_uart_pm, | ||
205 | .set_wake = h3xxx_uart_set_wake, | ||
206 | }; | ||
207 | |||
208 | /* | ||
209 | * EGPIO | ||
210 | */ | ||
211 | |||
212 | static struct resource egpio_resources[] = { | ||
213 | [0] = { | ||
214 | .start = H3600_EGPIO_PHYS, | ||
215 | .end = H3600_EGPIO_PHYS + 0x4 - 1, | ||
216 | .flags = IORESOURCE_MEM, | ||
217 | }, | ||
218 | }; | ||
219 | |||
220 | static struct htc_egpio_chip egpio_chips[] = { | ||
221 | [0] = { | ||
222 | .reg_start = 0, | ||
223 | .gpio_base = H3XXX_EGPIO_BASE, | ||
224 | .num_gpios = 16, | ||
225 | .direction = HTC_EGPIO_OUTPUT, | ||
226 | .initial_values = 0x0080, /* H3XXX_EGPIO_RS232_ON */ | ||
227 | }, | ||
228 | }; | ||
229 | |||
230 | static struct htc_egpio_platform_data egpio_info = { | ||
231 | .reg_width = 16, | ||
232 | .bus_width = 16, | ||
233 | .chip = egpio_chips, | ||
234 | .num_chips = ARRAY_SIZE(egpio_chips), | ||
235 | }; | ||
236 | |||
237 | static struct platform_device h3xxx_egpio = { | ||
238 | .name = "htc-egpio", | ||
239 | .id = -1, | ||
240 | .resource = egpio_resources, | ||
241 | .num_resources = ARRAY_SIZE(egpio_resources), | ||
242 | .dev = { | ||
243 | .platform_data = &egpio_info, | ||
244 | }, | ||
245 | }; | ||
246 | |||
247 | static struct platform_device *h3xxx_devices[] = { | ||
248 | &h3xxx_egpio, | ||
249 | }; | ||
250 | |||
251 | static void __init h3xxx_mach_init(void) | ||
252 | { | ||
253 | sa1100_register_uart_fns(&h3xxx_port_fns); | ||
254 | sa11x0_register_mtd(&h3xxx_flash_data, &h3xxx_flash_resource, 1); | ||
255 | platform_add_devices(h3xxx_devices, ARRAY_SIZE(h3xxx_devices)); | ||
256 | } | ||
257 | |||
258 | static struct map_desc h3600_io_desc[] __initdata = { | ||
259 | { /* static memory bank 2 CS#2 */ | ||
260 | .virtual = H3600_BANK_2_VIRT, | ||
261 | .pfn = __phys_to_pfn(SA1100_CS2_PHYS), | ||
262 | .length = 0x02800000, | ||
263 | .type = MT_DEVICE | ||
264 | }, { /* static memory bank 4 CS#4 */ | ||
265 | .virtual = H3600_BANK_4_VIRT, | ||
266 | .pfn = __phys_to_pfn(SA1100_CS4_PHYS), | ||
267 | .length = 0x00800000, | ||
268 | .type = MT_DEVICE | ||
269 | }, { /* EGPIO 0 CS#5 */ | ||
270 | .virtual = H3600_EGPIO_VIRT, | ||
271 | .pfn = __phys_to_pfn(H3600_EGPIO_PHYS), | ||
272 | .length = 0x01000000, | ||
273 | .type = MT_DEVICE | ||
274 | } | ||
275 | }; | ||
276 | |||
277 | /* | ||
278 | * Common map_io initialization | ||
279 | */ | ||
280 | |||
281 | static void __init h3xxx_map_io(void) | ||
282 | { | ||
283 | sa1100_map_io(); | ||
284 | iotable_init(h3600_io_desc, ARRAY_SIZE(h3600_io_desc)); | ||
285 | |||
286 | sa1100_register_uart(0, 3); /* Common serial port */ | ||
287 | // sa1100_register_uart(1, 1); /* Microcontroller on 3100/3600 */ | ||
288 | |||
289 | /* Ensure those pins are outputs and driving low */ | ||
290 | PPDR |= PPC_TXD4 | PPC_SCLK | PPC_SFRM; | ||
291 | PPSR &= ~(PPC_TXD4 | PPC_SCLK | PPC_SFRM); | ||
292 | |||
293 | /* Configure suspend conditions */ | ||
294 | PGSR = 0; | ||
295 | PWER = PWER_GPIO0; | ||
296 | PCFR = PCFR_OPDE; | ||
297 | PSDR = 0; | ||
298 | |||
299 | GPCR = 0x0fffffff; /* All outputs are set low by default */ | ||
300 | GPDR = 0; /* Configure all GPIOs as input */ | ||
301 | } | ||
302 | |||
303 | /************************* H3100 *************************/ | ||
304 | |||
305 | #ifdef CONFIG_SA1100_H3100 | ||
306 | |||
307 | /* | ||
308 | * helper for sa1100fb | ||
309 | */ | ||
310 | static void h3100_lcd_power(int enable) | ||
311 | { | ||
312 | if (!gpio_request(H3XXX_EGPIO_LCD_ON, "LCD ON")) { | ||
313 | gpio_set_value(H3100_GPIO_LCD_3V_ON, enable); | ||
314 | gpio_direction_output(H3XXX_EGPIO_LCD_ON, enable); | ||
315 | gpio_free(H3XXX_EGPIO_LCD_ON); | ||
316 | } | ||
317 | } | ||
318 | |||
319 | |||
320 | static void __init h3100_map_io(void) | ||
321 | { | ||
322 | h3xxx_map_io(); | ||
323 | |||
324 | sa1100fb_lcd_power = h3100_lcd_power; | ||
325 | |||
326 | /* Older bootldrs put GPIO2-9 in alternate mode on the | ||
327 | assumption that they are used for video */ | ||
328 | GAFR &= ~0x000001fb; | ||
329 | } | ||
330 | |||
331 | /* | ||
332 | * This turns the IRDA power on or off on the Compaq H3100 | ||
333 | */ | ||
334 | static int h3100_irda_set_power(struct device *dev, unsigned int state) | ||
335 | { | ||
336 | gpio_set_value(H3100_GPIO_IR_ON, state); | ||
337 | return 0; | ||
338 | } | ||
339 | |||
340 | static void h3100_irda_set_speed(struct device *dev, unsigned int speed) | ||
341 | { | ||
342 | gpio_set_value(H3100_GPIO_IR_FSEL, !(speed < 4000000)); | ||
343 | } | ||
344 | |||
345 | static struct irda_platform_data h3100_irda_data = { | ||
346 | .set_power = h3100_irda_set_power, | ||
347 | .set_speed = h3100_irda_set_speed, | ||
348 | }; | ||
349 | |||
350 | static struct gpio_default_state h3100_default_gpio[] = { | ||
351 | { H3100_GPIO_IR_ON, GPIO_MODE_OUT0, "IrDA power" }, | ||
352 | { H3100_GPIO_IR_FSEL, GPIO_MODE_OUT0, "IrDA fsel" }, | ||
353 | { H3XXX_GPIO_COM_DCD, GPIO_MODE_IN, "COM DCD" }, | ||
354 | { H3XXX_GPIO_COM_CTS, GPIO_MODE_IN, "COM CTS" }, | ||
355 | { H3XXX_GPIO_COM_RTS, GPIO_MODE_OUT0, "COM RTS" }, | ||
356 | { H3100_GPIO_LCD_3V_ON, GPIO_MODE_OUT0, "LCD 3v" }, | ||
357 | }; | ||
358 | |||
359 | static void __init h3100_mach_init(void) | ||
360 | { | ||
361 | h3xxx_init_gpio(h3100_default_gpio, ARRAY_SIZE(h3100_default_gpio)); | ||
362 | h3xxx_mach_init(); | ||
363 | sa11x0_register_irda(&h3100_irda_data); | ||
364 | } | ||
365 | |||
366 | MACHINE_START(H3100, "Compaq iPAQ H3100") | ||
367 | .phys_io = 0x80000000, | ||
368 | .io_pg_offst = ((0xf8000000) >> 18) & 0xfffc, | ||
369 | .boot_params = 0xc0000100, | ||
370 | .map_io = h3100_map_io, | ||
371 | .init_irq = sa1100_init_irq, | ||
372 | .timer = &sa1100_timer, | ||
373 | .init_machine = h3100_mach_init, | ||
374 | MACHINE_END | ||
375 | |||
376 | #endif /* CONFIG_SA1100_H3100 */ | ||
377 | |||
378 | /************************* H3600 *************************/ | ||
379 | |||
380 | #ifdef CONFIG_SA1100_H3600 | ||
381 | |||
382 | /* | 51 | /* |
383 | * helper for sa1100fb | 52 | * helper for sa1100fb |
384 | */ | 53 | */ |
@@ -483,5 +152,3 @@ MACHINE_START(H3600, "Compaq iPAQ H3600") | |||
483 | .init_machine = h3600_mach_init, | 152 | .init_machine = h3600_mach_init, |
484 | MACHINE_END | 153 | MACHINE_END |
485 | 154 | ||
486 | #endif /* CONFIG_SA1100_H3600 */ | ||
487 | |||
diff --git a/arch/arm/mach-sa1100/h3xxx.c b/arch/arm/mach-sa1100/h3xxx.c new file mode 100644 index 000000000000..bb608d437ff8 --- /dev/null +++ b/arch/arm/mach-sa1100/h3xxx.c | |||
@@ -0,0 +1,292 @@ | |||
1 | /* | ||
2 | * Hardware definitions for Compaq iPAQ H3xxx Handheld Computers | ||
3 | * | ||
4 | * Copyright 2000,1 Compaq Computer Corporation. | ||
5 | * | ||
6 | * Use consistent with the GNU GPL is permitted, | ||
7 | * provided that this copyright notice is | ||
8 | * preserved in its entirety in all copies and derived works. | ||
9 | * | ||
10 | * COMPAQ COMPUTER CORPORATION MAKES NO WARRANTIES, EXPRESSED OR IMPLIED, | ||
11 | * AS TO THE USEFULNESS OR CORRECTNESS OF THIS CODE OR ITS | ||
12 | * FITNESS FOR ANY PARTICULAR PURPOSE. | ||
13 | * | ||
14 | * Author: Jamey Hicks. | ||
15 | * | ||
16 | * History: | ||
17 | * | ||
18 | * 2001-10-?? Andrew Christian Added support for iPAQ H3800 | ||
19 | * and abstracted EGPIO interface. | ||
20 | * | ||
21 | */ | ||
22 | #include <linux/module.h> | ||
23 | #include <linux/init.h> | ||
24 | #include <linux/kernel.h> | ||
25 | #include <linux/tty.h> | ||
26 | #include <linux/pm.h> | ||
27 | #include <linux/device.h> | ||
28 | #include <linux/mfd/htc-egpio.h> | ||
29 | #include <linux/mtd/mtd.h> | ||
30 | #include <linux/mtd/partitions.h> | ||
31 | #include <linux/serial_core.h> | ||
32 | #include <linux/gpio.h> | ||
33 | #include <linux/platform_device.h> | ||
34 | |||
35 | #include <asm/irq.h> | ||
36 | #include <mach/hardware.h> | ||
37 | #include <asm/mach-types.h> | ||
38 | #include <asm/setup.h> | ||
39 | |||
40 | #include <asm/mach/irq.h> | ||
41 | #include <asm/mach/arch.h> | ||
42 | #include <asm/mach/flash.h> | ||
43 | #include <asm/mach/irda.h> | ||
44 | #include <asm/mach/map.h> | ||
45 | #include <asm/mach/serial_sa1100.h> | ||
46 | |||
47 | #include <mach/h3xxx.h> | ||
48 | |||
49 | #include "generic.h" | ||
50 | |||
51 | void h3xxx_init_gpio(struct gpio_default_state *s, size_t n) | ||
52 | { | ||
53 | while (n--) { | ||
54 | const char *name = s->name; | ||
55 | int err; | ||
56 | |||
57 | if (!name) | ||
58 | name = "[init]"; | ||
59 | err = gpio_request(s->gpio, name); | ||
60 | if (err) { | ||
61 | printk(KERN_ERR "gpio%u: unable to request: %d\n", | ||
62 | s->gpio, err); | ||
63 | continue; | ||
64 | } | ||
65 | if (s->mode >= 0) { | ||
66 | err = gpio_direction_output(s->gpio, s->mode); | ||
67 | } else { | ||
68 | err = gpio_direction_input(s->gpio); | ||
69 | } | ||
70 | if (err) { | ||
71 | printk(KERN_ERR "gpio%u: unable to set direction: %d\n", | ||
72 | s->gpio, err); | ||
73 | continue; | ||
74 | } | ||
75 | if (!s->name) | ||
76 | gpio_free(s->gpio); | ||
77 | s++; | ||
78 | } | ||
79 | } | ||
80 | |||
81 | |||
82 | /* | ||
83 | * H3xxx flash support | ||
84 | */ | ||
85 | static struct mtd_partition h3xxx_partitions[] = { | ||
86 | { | ||
87 | .name = "H3XXX boot firmware", | ||
88 | .size = 0x00040000, | ||
89 | .offset = 0, | ||
90 | .mask_flags = MTD_WRITEABLE, /* force read-only */ | ||
91 | }, { | ||
92 | .name = "H3XXX rootfs", | ||
93 | .size = MTDPART_SIZ_FULL, | ||
94 | .offset = 0x00040000, | ||
95 | } | ||
96 | }; | ||
97 | |||
98 | static void h3xxx_set_vpp(int vpp) | ||
99 | { | ||
100 | gpio_set_value(H3XXX_EGPIO_VPP_ON, vpp); | ||
101 | } | ||
102 | |||
103 | static int h3xxx_flash_init(void) | ||
104 | { | ||
105 | int err = gpio_request(H3XXX_EGPIO_VPP_ON, "Flash Vpp"); | ||
106 | if (err) | ||
107 | return err; | ||
108 | |||
109 | err = gpio_direction_output(H3XXX_EGPIO_VPP_ON, 0); | ||
110 | if (err) | ||
111 | gpio_free(H3XXX_EGPIO_VPP_ON); | ||
112 | |||
113 | return err; | ||
114 | } | ||
115 | |||
116 | static void h3xxx_flash_exit(void) | ||
117 | { | ||
118 | gpio_free(H3XXX_EGPIO_VPP_ON); | ||
119 | } | ||
120 | |||
121 | static struct flash_platform_data h3xxx_flash_data = { | ||
122 | .map_name = "cfi_probe", | ||
123 | .set_vpp = h3xxx_set_vpp, | ||
124 | .init = h3xxx_flash_init, | ||
125 | .exit = h3xxx_flash_exit, | ||
126 | .parts = h3xxx_partitions, | ||
127 | .nr_parts = ARRAY_SIZE(h3xxx_partitions), | ||
128 | }; | ||
129 | |||
130 | static struct resource h3xxx_flash_resource = { | ||
131 | .start = SA1100_CS0_PHYS, | ||
132 | .end = SA1100_CS0_PHYS + SZ_32M - 1, | ||
133 | .flags = IORESOURCE_MEM, | ||
134 | }; | ||
135 | |||
136 | |||
137 | /* | ||
138 | * H3xxx uart support | ||
139 | */ | ||
140 | static void h3xxx_uart_set_mctrl(struct uart_port *port, u_int mctrl) | ||
141 | { | ||
142 | if (port->mapbase == _Ser3UTCR0) { | ||
143 | gpio_set_value(H3XXX_GPIO_COM_RTS, !(mctrl & TIOCM_RTS)); | ||
144 | } | ||
145 | } | ||
146 | |||
147 | static u_int h3xxx_uart_get_mctrl(struct uart_port *port) | ||
148 | { | ||
149 | u_int ret = TIOCM_CD | TIOCM_CTS | TIOCM_DSR; | ||
150 | |||
151 | if (port->mapbase == _Ser3UTCR0) { | ||
152 | /* | ||
153 | * DCD and CTS bits are inverted in GPLR by RS232 transceiver | ||
154 | */ | ||
155 | if (gpio_get_value(H3XXX_GPIO_COM_DCD)) | ||
156 | ret &= ~TIOCM_CD; | ||
157 | if (gpio_get_value(H3XXX_GPIO_COM_CTS)) | ||
158 | ret &= ~TIOCM_CTS; | ||
159 | } | ||
160 | |||
161 | return ret; | ||
162 | } | ||
163 | |||
164 | static void h3xxx_uart_pm(struct uart_port *port, u_int state, u_int oldstate) | ||
165 | { | ||
166 | if (port->mapbase == _Ser3UTCR0) | ||
167 | if (!gpio_request(H3XXX_EGPIO_RS232_ON, "RS232 transceiver")) { | ||
168 | gpio_direction_output(H3XXX_EGPIO_RS232_ON, !state); | ||
169 | gpio_free(H3XXX_EGPIO_RS232_ON); | ||
170 | } | ||
171 | } | ||
172 | |||
173 | /* | ||
174 | * Enable/Disable wake up events for this serial port. | ||
175 | * Obviously, we only support this on the normal COM port. | ||
176 | */ | ||
177 | static int h3xxx_uart_set_wake(struct uart_port *port, u_int enable) | ||
178 | { | ||
179 | int err = -EINVAL; | ||
180 | |||
181 | if (port->mapbase == _Ser3UTCR0) { | ||
182 | if (enable) | ||
183 | PWER |= PWER_GPIO23 | PWER_GPIO25; /* DCD and CTS */ | ||
184 | else | ||
185 | PWER &= ~(PWER_GPIO23 | PWER_GPIO25); /* DCD and CTS */ | ||
186 | err = 0; | ||
187 | } | ||
188 | return err; | ||
189 | } | ||
190 | |||
191 | static struct sa1100_port_fns h3xxx_port_fns __initdata = { | ||
192 | .set_mctrl = h3xxx_uart_set_mctrl, | ||
193 | .get_mctrl = h3xxx_uart_get_mctrl, | ||
194 | .pm = h3xxx_uart_pm, | ||
195 | .set_wake = h3xxx_uart_set_wake, | ||
196 | }; | ||
197 | |||
198 | /* | ||
199 | * EGPIO | ||
200 | */ | ||
201 | |||
202 | static struct resource egpio_resources[] = { | ||
203 | [0] = { | ||
204 | .start = H3600_EGPIO_PHYS, | ||
205 | .end = H3600_EGPIO_PHYS + 0x4 - 1, | ||
206 | .flags = IORESOURCE_MEM, | ||
207 | }, | ||
208 | }; | ||
209 | |||
210 | static struct htc_egpio_chip egpio_chips[] = { | ||
211 | [0] = { | ||
212 | .reg_start = 0, | ||
213 | .gpio_base = H3XXX_EGPIO_BASE, | ||
214 | .num_gpios = 16, | ||
215 | .direction = HTC_EGPIO_OUTPUT, | ||
216 | .initial_values = 0x0080, /* H3XXX_EGPIO_RS232_ON */ | ||
217 | }, | ||
218 | }; | ||
219 | |||
220 | static struct htc_egpio_platform_data egpio_info = { | ||
221 | .reg_width = 16, | ||
222 | .bus_width = 16, | ||
223 | .chip = egpio_chips, | ||
224 | .num_chips = ARRAY_SIZE(egpio_chips), | ||
225 | }; | ||
226 | |||
227 | static struct platform_device h3xxx_egpio = { | ||
228 | .name = "htc-egpio", | ||
229 | .id = -1, | ||
230 | .resource = egpio_resources, | ||
231 | .num_resources = ARRAY_SIZE(egpio_resources), | ||
232 | .dev = { | ||
233 | .platform_data = &egpio_info, | ||
234 | }, | ||
235 | }; | ||
236 | |||
237 | static struct platform_device *h3xxx_devices[] = { | ||
238 | &h3xxx_egpio, | ||
239 | }; | ||
240 | |||
241 | void __init h3xxx_mach_init(void) | ||
242 | { | ||
243 | sa1100_register_uart_fns(&h3xxx_port_fns); | ||
244 | sa11x0_register_mtd(&h3xxx_flash_data, &h3xxx_flash_resource, 1); | ||
245 | platform_add_devices(h3xxx_devices, ARRAY_SIZE(h3xxx_devices)); | ||
246 | } | ||
247 | |||
248 | static struct map_desc h3600_io_desc[] __initdata = { | ||
249 | { /* static memory bank 2 CS#2 */ | ||
250 | .virtual = H3600_BANK_2_VIRT, | ||
251 | .pfn = __phys_to_pfn(SA1100_CS2_PHYS), | ||
252 | .length = 0x02800000, | ||
253 | .type = MT_DEVICE | ||
254 | }, { /* static memory bank 4 CS#4 */ | ||
255 | .virtual = H3600_BANK_4_VIRT, | ||
256 | .pfn = __phys_to_pfn(SA1100_CS4_PHYS), | ||
257 | .length = 0x00800000, | ||
258 | .type = MT_DEVICE | ||
259 | }, { /* EGPIO 0 CS#5 */ | ||
260 | .virtual = H3600_EGPIO_VIRT, | ||
261 | .pfn = __phys_to_pfn(H3600_EGPIO_PHYS), | ||
262 | .length = 0x01000000, | ||
263 | .type = MT_DEVICE | ||
264 | } | ||
265 | }; | ||
266 | |||
267 | /* | ||
268 | * Common map_io initialization | ||
269 | */ | ||
270 | |||
271 | void __init h3xxx_map_io(void) | ||
272 | { | ||
273 | sa1100_map_io(); | ||
274 | iotable_init(h3600_io_desc, ARRAY_SIZE(h3600_io_desc)); | ||
275 | |||
276 | sa1100_register_uart(0, 3); /* Common serial port */ | ||
277 | // sa1100_register_uart(1, 1); /* Microcontroller on 3100/3600 */ | ||
278 | |||
279 | /* Ensure those pins are outputs and driving low */ | ||
280 | PPDR |= PPC_TXD4 | PPC_SCLK | PPC_SFRM; | ||
281 | PPSR &= ~(PPC_TXD4 | PPC_SCLK | PPC_SFRM); | ||
282 | |||
283 | /* Configure suspend conditions */ | ||
284 | PGSR = 0; | ||
285 | PWER = PWER_GPIO0; | ||
286 | PCFR = PCFR_OPDE; | ||
287 | PSDR = 0; | ||
288 | |||
289 | GPCR = 0x0fffffff; /* All outputs are set low by default */ | ||
290 | GPDR = 0; /* Configure all GPIOs as input */ | ||
291 | } | ||
292 | |||
diff --git a/arch/arm/mach-sa1100/include/mach/h3xxx.h b/arch/arm/mach-sa1100/include/mach/h3xxx.h index 7f1e130be949..d8a6e7cee676 100644 --- a/arch/arm/mach-sa1100/include/mach/h3xxx.h +++ b/arch/arm/mach-sa1100/include/mach/h3xxx.h | |||
@@ -87,4 +87,18 @@ | |||
87 | #define H3600_EGPIO_LCD_5V_ON (H3XXX_EGPIO_BASE + 14) /* enable 5V to LCD. active high. */ | 87 | #define H3600_EGPIO_LCD_5V_ON (H3XXX_EGPIO_BASE + 14) /* enable 5V to LCD. active high. */ |
88 | #define H3600_EGPIO_LVDD_ON (H3XXX_EGPIO_BASE + 15) /* enable 9V and -6.5V to LCD. */ | 88 | #define H3600_EGPIO_LVDD_ON (H3XXX_EGPIO_BASE + 15) /* enable 9V and -6.5V to LCD. */ |
89 | 89 | ||
90 | struct gpio_default_state { | ||
91 | int gpio; | ||
92 | int mode; | ||
93 | const char *name; | ||
94 | }; | ||
95 | |||
96 | #define GPIO_MODE_IN -1 | ||
97 | #define GPIO_MODE_OUT0 0 | ||
98 | #define GPIO_MODE_OUT1 1 | ||
99 | |||
100 | void h3xxx_init_gpio(struct gpio_default_state *s, size_t n); | ||
101 | void __init h3xxx_map_io(void); | ||
102 | void __init h3xxx_mach_init(void); | ||
103 | |||
90 | #endif /* _INCLUDE_H3XXX_H_ */ | 104 | #endif /* _INCLUDE_H3XXX_H_ */ |