aboutsummaryrefslogtreecommitdiffstats
path: root/arch/arm/mach-sa1100/h3600.c
diff options
context:
space:
mode:
Diffstat (limited to 'arch/arm/mach-sa1100/h3600.c')
-rw-r--r--arch/arm/mach-sa1100/h3600.c454
1 files changed, 79 insertions, 375 deletions
diff --git a/arch/arm/mach-sa1100/h3600.c b/arch/arm/mach-sa1100/h3600.c
index 0eb2f159578b..af3b71459f8d 100644
--- a/arch/arm/mach-sa1100/h3600.c
+++ b/arch/arm/mach-sa1100/h3600.c
@@ -1,421 +1,127 @@
1/* 1/*
2 * Hardware definitions for Compaq iPAQ H3xxx Handheld Computers 2 * Support for Compaq iPAQ H3600 handheld computer
3 * 3 *
4 * Copyright 2000,1 Compaq Computer Corporation. 4 * Copyright (c) 2000,1 Compaq Computer Corporation. (Author: Jamey Hicks)
5 * Copyright (c) 2009 Dmitry Artamonow <mad_soft@inbox.ru>
5 * 6 *
6 * Use consistent with the GNU GPL is permitted, 7 * This program is free software; you can redistribute it and/or modify
7 * provided that this copyright notice is 8 * it under the terms of the GNU General Public License version 2 as
8 * preserved in its entirety in all copies and derived works. 9 * published by the Free Software Foundation.
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 * 10 *
21 */ 11 */
22#include <linux/module.h> 12
23#include <linux/init.h> 13#include <linux/init.h>
24#include <linux/kernel.h> 14#include <linux/kernel.h>
25#include <linux/tty.h> 15#include <linux/gpio.h>
26#include <linux/pm.h>
27#include <linux/device.h>
28#include <linux/mtd/mtd.h>
29#include <linux/mtd/partitions.h>
30#include <linux/serial_core.h>
31 16
32#include <asm/irq.h>
33#include <mach/hardware.h>
34#include <asm/mach-types.h> 17#include <asm/mach-types.h>
35#include <asm/setup.h>
36
37#include <asm/mach/irq.h>
38#include <asm/mach/arch.h> 18#include <asm/mach/arch.h>
39#include <asm/mach/flash.h>
40#include <asm/mach/irda.h> 19#include <asm/mach/irda.h>
41#include <asm/mach/map.h>
42#include <asm/mach/serial_sa1100.h>
43 20
44#include <mach/h3600.h> 21#include <mach/h3xxx.h>
45#include <mach/h3600_gpio.h>
46 22
47#include "generic.h" 23#include "generic.h"
48 24
49void (*assign_h3600_egpio)(enum ipaq_egpio_type x, int level);
50EXPORT_SYMBOL(assign_h3600_egpio);
51
52static struct mtd_partition h3xxx_partitions[] = {
53 {
54 .name = "H3XXX boot firmware",
55 .size = 0x00040000,
56 .offset = 0,
57 .mask_flags = MTD_WRITEABLE, /* force read-only */
58 }, {
59 .name = "H3XXX rootfs",
60 .size = MTDPART_SIZ_FULL,
61 .offset = 0x00040000,
62 }
63};
64
65static void h3xxx_set_vpp(int vpp)
66{
67 assign_h3600_egpio(IPAQ_EGPIO_VPP_ON, vpp);
68}
69
70static struct flash_platform_data h3xxx_flash_data = {
71 .map_name = "cfi_probe",
72 .set_vpp = h3xxx_set_vpp,
73 .parts = h3xxx_partitions,
74 .nr_parts = ARRAY_SIZE(h3xxx_partitions),
75};
76
77static struct resource h3xxx_flash_resource = {
78 .start = SA1100_CS0_PHYS,
79 .end = SA1100_CS0_PHYS + SZ_32M - 1,
80 .flags = IORESOURCE_MEM,
81};
82
83/* 25/*
84 * This turns the IRDA power on or off on the Compaq H3600 26 * helper for sa1100fb
85 */
86static int h3600_irda_set_power(struct device *dev, unsigned int state)
87{
88 assign_h3600_egpio( IPAQ_EGPIO_IR_ON, state );
89
90 return 0;
91}
92
93static void h3600_irda_set_speed(struct device *dev, unsigned int speed)
94{
95 assign_h3600_egpio(IPAQ_EGPIO_IR_FSEL, !(speed < 4000000));
96}
97
98static struct irda_platform_data h3600_irda_data = {
99 .set_power = h3600_irda_set_power,
100 .set_speed = h3600_irda_set_speed,
101};
102
103static void h3xxx_mach_init(void)
104{
105 sa11x0_set_flash_data(&h3xxx_flash_data, &h3xxx_flash_resource, 1);
106 sa11x0_set_irda_data(&h3600_irda_data);
107}
108
109/*
110 * low-level UART features
111 */ 27 */
112 28static void h3600_lcd_power(int enable)
113static void h3600_uart_set_mctrl(struct uart_port *port, u_int mctrl)
114{ 29{
115 if (port->mapbase == _Ser3UTCR0) { 30 if (gpio_request(H3XXX_EGPIO_LCD_ON, "LCD power")) {
116 if (mctrl & TIOCM_RTS) 31 pr_err("%s: can't request H3XXX_EGPIO_LCD_ON\n", __func__);
117 GPCR = GPIO_H3600_COM_RTS; 32 goto err1;
118 else
119 GPSR = GPIO_H3600_COM_RTS;
120 } 33 }
121} 34 if (gpio_request(H3600_EGPIO_LCD_PCI, "LCD control")) {
122 35 pr_err("%s: can't request H3XXX_EGPIO_LCD_PCI\n", __func__);
123static u_int h3600_uart_get_mctrl(struct uart_port *port) 36 goto err2;
124{ 37 }
125 u_int ret = TIOCM_CD | TIOCM_CTS | TIOCM_DSR; 38 if (gpio_request(H3600_EGPIO_LCD_5V_ON, "LCD 5v")) {
126 39 pr_err("%s: can't request H3XXX_EGPIO_LCD_5V_ON\n", __func__);
127 if (port->mapbase == _Ser3UTCR0) { 40 goto err3;
128 int gplr = GPLR; 41 }
129 /* DCD and CTS bits are inverted in GPLR by RS232 transceiver */ 42 if (gpio_request(H3600_EGPIO_LVDD_ON, "LCD 9v/-6.5v")) {
130 if (gplr & GPIO_H3600_COM_DCD) 43 pr_err("%s: can't request H3600_EGPIO_LVDD_ON\n", __func__);
131 ret &= ~TIOCM_CD; 44 goto err4;
132 if (gplr & GPIO_H3600_COM_CTS)
133 ret &= ~TIOCM_CTS;
134 } 45 }
135 46
136 return ret; 47 gpio_direction_output(H3XXX_EGPIO_LCD_ON, enable);
137} 48 gpio_direction_output(H3600_EGPIO_LCD_PCI, enable);
49 gpio_direction_output(H3600_EGPIO_LCD_5V_ON, enable);
50 gpio_direction_output(H3600_EGPIO_LVDD_ON, enable);
138 51
139static void h3600_uart_pm(struct uart_port *port, u_int state, u_int oldstate) 52 gpio_free(H3600_EGPIO_LVDD_ON);
140{ 53err4: gpio_free(H3600_EGPIO_LCD_5V_ON);
141 if (port->mapbase == _Ser2UTCR0) { /* TODO: REMOVE THIS */ 54err3: gpio_free(H3600_EGPIO_LCD_PCI);
142 assign_h3600_egpio(IPAQ_EGPIO_IR_ON, !state); 55err2: gpio_free(H3XXX_EGPIO_LCD_ON);
143 } else if (port->mapbase == _Ser3UTCR0) { 56err1: return;
144 assign_h3600_egpio(IPAQ_EGPIO_RS232_ON, !state);
145 }
146} 57}
147 58
148/* 59static void __init h3600_map_io(void)
149 * Enable/Disable wake up events for this serial port.
150 * Obviously, we only support this on the normal COM port.
151 */
152static int h3600_uart_set_wake(struct uart_port *port, u_int enable)
153{ 60{
154 int err = -EINVAL; 61 h3xxx_map_io();
155 62
156 if (port->mapbase == _Ser3UTCR0) { 63 sa1100fb_lcd_power = h3600_lcd_power;
157 if (enable)
158 PWER |= PWER_GPIO23 | PWER_GPIO25; /* DCD and CTS */
159 else
160 PWER &= ~(PWER_GPIO23 | PWER_GPIO25); /* DCD and CTS */
161 err = 0;
162 }
163 return err;
164} 64}
165 65
166static struct sa1100_port_fns h3600_port_fns __initdata = {
167 .set_mctrl = h3600_uart_set_mctrl,
168 .get_mctrl = h3600_uart_get_mctrl,
169 .pm = h3600_uart_pm,
170 .set_wake = h3600_uart_set_wake,
171};
172
173/* 66/*
174 * helper for sa1100fb 67 * This turns the IRDA power on or off on the Compaq H3600
175 */ 68 */
176static void h3xxx_lcd_power(int enable) 69static int h3600_irda_set_power(struct device *dev, unsigned int state)
177{ 70{
178 assign_h3600_egpio(IPAQ_EGPIO_LCD_POWER, enable); 71 gpio_set_value(H3600_EGPIO_IR_ON, state);
72 return 0;
179} 73}
180 74
181static struct map_desc h3600_io_desc[] __initdata = { 75static void h3600_irda_set_speed(struct device *dev, unsigned int speed)
182 { /* static memory bank 2 CS#2 */
183 .virtual = H3600_BANK_2_VIRT,
184 .pfn = __phys_to_pfn(SA1100_CS2_PHYS),
185 .length = 0x02800000,
186 .type = MT_DEVICE
187 }, { /* static memory bank 4 CS#4 */
188 .virtual = H3600_BANK_4_VIRT,
189 .pfn = __phys_to_pfn(SA1100_CS4_PHYS),
190 .length = 0x00800000,
191 .type = MT_DEVICE
192 }, { /* EGPIO 0 CS#5 */
193 .virtual = H3600_EGPIO_VIRT,
194 .pfn = __phys_to_pfn(H3600_EGPIO_PHYS),
195 .length = 0x01000000,
196 .type = MT_DEVICE
197 }
198};
199
200/*
201 * Common map_io initialization
202 */
203
204static void __init h3xxx_map_io(void)
205{ 76{
206 sa1100_map_io(); 77 gpio_set_value(H3600_EGPIO_IR_FSEL, !(speed < 4000000));
207 iotable_init(h3600_io_desc, ARRAY_SIZE(h3600_io_desc));
208
209 sa1100_register_uart_fns(&h3600_port_fns);
210 sa1100_register_uart(0, 3); /* Common serial port */
211// sa1100_register_uart(1, 1); /* Microcontroller on 3100/3600 */
212
213 /* Ensure those pins are outputs and driving low */
214 PPDR |= PPC_TXD4 | PPC_SCLK | PPC_SFRM;
215 PPSR &= ~(PPC_TXD4 | PPC_SCLK | PPC_SFRM);
216
217 /* Configure suspend conditions */
218 PGSR = 0;
219 PWER = PWER_GPIO0 | PWER_RTC;
220 PCFR = PCFR_OPDE;
221 PSDR = 0;
222
223 sa1100fb_lcd_power = h3xxx_lcd_power;
224} 78}
225 79
226/************************* H3100 *************************/ 80static int h3600_irda_startup(struct device *dev)
227
228#ifdef CONFIG_SA1100_H3100
229
230#define H3100_EGPIO (*(volatile unsigned int *)H3600_EGPIO_VIRT)
231static unsigned int h3100_egpio = 0;
232
233static void h3100_control_egpio(enum ipaq_egpio_type x, int setp)
234{ 81{
235 unsigned int egpio = 0; 82 int err = gpio_request(H3600_EGPIO_IR_ON, "IrDA power");
236 long gpio = 0; 83 if (err)
237 unsigned long flags; 84 goto err1;
238 85 err = gpio_direction_output(H3600_EGPIO_IR_ON, 0);
239 switch (x) { 86 if (err)
240 case IPAQ_EGPIO_LCD_POWER: 87 goto err2;
241 egpio |= EGPIO_H3600_LCD_ON; 88 err = gpio_request(H3600_EGPIO_IR_FSEL, "IrDA fsel");
242 gpio |= GPIO_H3100_LCD_3V_ON; 89 if (err)
243 break; 90 goto err2;
244 case IPAQ_EGPIO_LCD_ENABLE: 91 err = gpio_direction_output(H3600_EGPIO_IR_FSEL, 0);
245 break; 92 if (err)
246 case IPAQ_EGPIO_CODEC_NRESET: 93 goto err3;
247 egpio |= EGPIO_H3600_CODEC_NRESET; 94 return 0;
248 break;
249 case IPAQ_EGPIO_AUDIO_ON:
250 gpio |= GPIO_H3100_AUD_PWR_ON
251 | GPIO_H3100_AUD_ON;
252 break;
253 case IPAQ_EGPIO_QMUTE:
254 gpio |= GPIO_H3100_QMUTE;
255 break;
256 case IPAQ_EGPIO_OPT_NVRAM_ON:
257 egpio |= EGPIO_H3600_OPT_NVRAM_ON;
258 break;
259 case IPAQ_EGPIO_OPT_ON:
260 egpio |= EGPIO_H3600_OPT_ON;
261 break;
262 case IPAQ_EGPIO_CARD_RESET:
263 egpio |= EGPIO_H3600_CARD_RESET;
264 break;
265 case IPAQ_EGPIO_OPT_RESET:
266 egpio |= EGPIO_H3600_OPT_RESET;
267 break;
268 case IPAQ_EGPIO_IR_ON:
269 gpio |= GPIO_H3100_IR_ON;
270 break;
271 case IPAQ_EGPIO_IR_FSEL:
272 gpio |= GPIO_H3100_IR_FSEL;
273 break;
274 case IPAQ_EGPIO_RS232_ON:
275 egpio |= EGPIO_H3600_RS232_ON;
276 break;
277 case IPAQ_EGPIO_VPP_ON:
278 egpio |= EGPIO_H3600_VPP_ON;
279 break;
280 }
281 95
282 if (egpio || gpio) { 96err3: gpio_free(H3600_EGPIO_IR_FSEL);
283 local_irq_save(flags); 97err2: gpio_free(H3600_EGPIO_IR_ON);
284 if (setp) { 98err1: return err;
285 h3100_egpio |= egpio;
286 GPSR = gpio;
287 } else {
288 h3100_egpio &= ~egpio;
289 GPCR = gpio;
290 }
291 H3100_EGPIO = h3100_egpio;
292 local_irq_restore(flags);
293 }
294} 99}
295 100
296#define H3100_DIRECT_EGPIO (GPIO_H3100_BT_ON \ 101static void h3600_irda_shutdown(struct device *dev)
297 | GPIO_H3100_GPIO3 \
298 | GPIO_H3100_QMUTE \
299 | GPIO_H3100_LCD_3V_ON \
300 | GPIO_H3100_AUD_ON \
301 | GPIO_H3100_AUD_PWR_ON \
302 | GPIO_H3100_IR_ON \
303 | GPIO_H3100_IR_FSEL)
304
305static void __init h3100_map_io(void)
306{ 102{
307 h3xxx_map_io(); 103 gpio_free(H3600_EGPIO_IR_ON);
308 104 gpio_free(H3600_EGPIO_IR_FSEL);
309 /* Initialize h3100-specific values here */
310 GPCR = 0x0fffffff; /* All outputs are set low by default */
311 GPDR = GPIO_H3600_COM_RTS | GPIO_H3600_L3_CLOCK |
312 GPIO_H3600_L3_MODE | GPIO_H3600_L3_DATA |
313 GPIO_H3600_CLK_SET1 | GPIO_H3600_CLK_SET0 |
314 H3100_DIRECT_EGPIO;
315
316 /* Older bootldrs put GPIO2-9 in alternate mode on the
317 assumption that they are used for video */
318 GAFR &= ~H3100_DIRECT_EGPIO;
319
320 H3100_EGPIO = h3100_egpio;
321 assign_h3600_egpio = h3100_control_egpio;
322} 105}
323 106
324MACHINE_START(H3100, "Compaq iPAQ H3100") 107static struct irda_platform_data h3600_irda_data = {
325 .phys_io = 0x80000000, 108 .set_power = h3600_irda_set_power,
326 .io_pg_offst = ((0xf8000000) >> 18) & 0xfffc, 109 .set_speed = h3600_irda_set_speed,
327 .boot_params = 0xc0000100, 110 .startup = h3600_irda_startup,
328 .map_io = h3100_map_io, 111 .shutdown = h3600_irda_shutdown,
329 .init_irq = sa1100_init_irq, 112};
330 .timer = &sa1100_timer,
331 .init_machine = h3xxx_mach_init,
332MACHINE_END
333
334#endif /* CONFIG_SA1100_H3100 */
335
336/************************* H3600 *************************/
337
338#ifdef CONFIG_SA1100_H3600
339
340#define H3600_EGPIO (*(volatile unsigned int *)H3600_EGPIO_VIRT)
341static unsigned int h3600_egpio = EGPIO_H3600_RS232_ON;
342
343static void h3600_control_egpio(enum ipaq_egpio_type x, int setp)
344{
345 unsigned int egpio = 0;
346 unsigned long flags;
347
348 switch (x) {
349 case IPAQ_EGPIO_LCD_POWER:
350 egpio |= EGPIO_H3600_LCD_ON |
351 EGPIO_H3600_LCD_PCI |
352 EGPIO_H3600_LCD_5V_ON |
353 EGPIO_H3600_LVDD_ON;
354 break;
355 case IPAQ_EGPIO_LCD_ENABLE:
356 break;
357 case IPAQ_EGPIO_CODEC_NRESET:
358 egpio |= EGPIO_H3600_CODEC_NRESET;
359 break;
360 case IPAQ_EGPIO_AUDIO_ON:
361 egpio |= EGPIO_H3600_AUD_AMP_ON |
362 EGPIO_H3600_AUD_PWR_ON;
363 break;
364 case IPAQ_EGPIO_QMUTE:
365 egpio |= EGPIO_H3600_QMUTE;
366 break;
367 case IPAQ_EGPIO_OPT_NVRAM_ON:
368 egpio |= EGPIO_H3600_OPT_NVRAM_ON;
369 break;
370 case IPAQ_EGPIO_OPT_ON:
371 egpio |= EGPIO_H3600_OPT_ON;
372 break;
373 case IPAQ_EGPIO_CARD_RESET:
374 egpio |= EGPIO_H3600_CARD_RESET;
375 break;
376 case IPAQ_EGPIO_OPT_RESET:
377 egpio |= EGPIO_H3600_OPT_RESET;
378 break;
379 case IPAQ_EGPIO_IR_ON:
380 egpio |= EGPIO_H3600_IR_ON;
381 break;
382 case IPAQ_EGPIO_IR_FSEL:
383 egpio |= EGPIO_H3600_IR_FSEL;
384 break;
385 case IPAQ_EGPIO_RS232_ON:
386 egpio |= EGPIO_H3600_RS232_ON;
387 break;
388 case IPAQ_EGPIO_VPP_ON:
389 egpio |= EGPIO_H3600_VPP_ON;
390 break;
391 }
392 113
393 if (egpio) { 114static struct gpio_default_state h3600_default_gpio[] = {
394 local_irq_save(flags); 115 { H3XXX_GPIO_COM_DCD, GPIO_MODE_IN, "COM DCD" },
395 if (setp) 116 { H3XXX_GPIO_COM_CTS, GPIO_MODE_IN, "COM CTS" },
396 h3600_egpio |= egpio; 117 { H3XXX_GPIO_COM_RTS, GPIO_MODE_OUT0, "COM RTS" },
397 else 118};
398 h3600_egpio &= ~egpio;
399 H3600_EGPIO = h3600_egpio;
400 local_irq_restore(flags);
401 }
402}
403 119
404static void __init h3600_map_io(void) 120static void __init h3600_mach_init(void)
405{ 121{
406 h3xxx_map_io(); 122 h3xxx_init_gpio(h3600_default_gpio, ARRAY_SIZE(h3600_default_gpio));
407 123 h3xxx_mach_init();
408 /* Initialize h3600-specific values here */ 124 sa11x0_register_irda(&h3600_irda_data);
409
410 GPCR = 0x0fffffff; /* All outputs are set low by default */
411 GPDR = GPIO_H3600_COM_RTS | GPIO_H3600_L3_CLOCK |
412 GPIO_H3600_L3_MODE | GPIO_H3600_L3_DATA |
413 GPIO_H3600_CLK_SET1 | GPIO_H3600_CLK_SET0 |
414 GPIO_LDD15 | GPIO_LDD14 | GPIO_LDD13 | GPIO_LDD12 |
415 GPIO_LDD11 | GPIO_LDD10 | GPIO_LDD9 | GPIO_LDD8;
416
417 H3600_EGPIO = h3600_egpio; /* Maintains across sleep? */
418 assign_h3600_egpio = h3600_control_egpio;
419} 125}
420 126
421MACHINE_START(H3600, "Compaq iPAQ H3600") 127MACHINE_START(H3600, "Compaq iPAQ H3600")
@@ -425,8 +131,6 @@ MACHINE_START(H3600, "Compaq iPAQ H3600")
425 .map_io = h3600_map_io, 131 .map_io = h3600_map_io,
426 .init_irq = sa1100_init_irq, 132 .init_irq = sa1100_init_irq,
427 .timer = &sa1100_timer, 133 .timer = &sa1100_timer,
428 .init_machine = h3xxx_mach_init, 134 .init_machine = h3600_mach_init,
429MACHINE_END 135MACHINE_END
430 136
431#endif /* CONFIG_SA1100_H3600 */
432