aboutsummaryrefslogtreecommitdiffstats
path: root/arch/arm/mach-pxa/palmtreo.c
diff options
context:
space:
mode:
Diffstat (limited to 'arch/arm/mach-pxa/palmtreo.c')
-rw-r--r--arch/arm/mach-pxa/palmtreo.c551
1 files changed, 551 insertions, 0 deletions
diff --git a/arch/arm/mach-pxa/palmtreo.c b/arch/arm/mach-pxa/palmtreo.c
new file mode 100644
index 000000000000..5e66028d2911
--- /dev/null
+++ b/arch/arm/mach-pxa/palmtreo.c
@@ -0,0 +1,551 @@
1/*
2 * Hardware definitions for Palm Treo smartphones
3 *
4 * currently supported:
5 * Palm Treo 680 (GSM)
6 *
7 * Author: Tomas Cech <sleep_walker@suse.cz>
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License version 2 as
11 * published by the Free Software Foundation.
12 *
13 * (find more info at www.hackndev.com)
14 *
15 */
16
17#include <linux/platform_device.h>
18#include <linux/delay.h>
19#include <linux/irq.h>
20#include <linux/gpio_keys.h>
21#include <linux/input.h>
22#include <linux/pda_power.h>
23#include <linux/pwm_backlight.h>
24#include <linux/gpio.h>
25#include <linux/wm97xx_batt.h>
26#include <linux/power_supply.h>
27#include <linux/sysdev.h>
28#include <linux/w1-gpio.h>
29
30#include <asm/mach-types.h>
31#include <asm/mach/arch.h>
32#include <asm/mach/map.h>
33
34#include <mach/pxa27x.h>
35#include <mach/pxa27x-udc.h>
36#include <mach/audio.h>
37#include <mach/palmtreo.h>
38#include <mach/mmc.h>
39#include <mach/pxafb.h>
40#include <mach/irda.h>
41#include <mach/pxa27x_keypad.h>
42#include <mach/udc.h>
43#include <mach/ohci.h>
44#include <mach/pxa2xx-regs.h>
45#include <mach/palmasoc.h>
46#include <mach/camera.h>
47
48#include <sound/pxa2xx-lib.h>
49
50#include "generic.h"
51#include "devices.h"
52
53/******************************************************************************
54 * Pin configuration
55 ******************************************************************************/
56static unsigned long treo_pin_config[] __initdata = {
57 /* MMC */
58 GPIO32_MMC_CLK,
59 GPIO92_MMC_DAT_0,
60 GPIO109_MMC_DAT_1,
61 GPIO110_MMC_DAT_2,
62 GPIO111_MMC_DAT_3,
63 GPIO112_MMC_CMD,
64 GPIO113_GPIO, /* SD detect */
65
66 /* AC97 */
67 GPIO28_AC97_BITCLK,
68 GPIO29_AC97_SDATA_IN_0,
69 GPIO30_AC97_SDATA_OUT,
70 GPIO31_AC97_SYNC,
71 GPIO89_AC97_SYSCLK,
72 GPIO95_AC97_nRESET,
73
74 /* IrDA */
75 GPIO46_FICP_RXD,
76 GPIO47_FICP_TXD,
77
78 /* PWM */
79 GPIO16_PWM0_OUT,
80
81 /* USB */
82 GPIO1_GPIO | WAKEUP_ON_EDGE_BOTH, /* usb detect */
83
84 /* MATRIX KEYPAD */
85 GPIO101_KP_MKIN_1,
86 GPIO102_KP_MKIN_2,
87 GPIO97_KP_MKIN_3,
88 GPIO98_KP_MKIN_4,
89 GPIO91_KP_MKIN_6,
90 GPIO13_KP_MKIN_7,
91 GPIO103_KP_MKOUT_0 | MFP_LPM_DRIVE_HIGH,
92 GPIO104_KP_MKOUT_1,
93 GPIO105_KP_MKOUT_2,
94 GPIO106_KP_MKOUT_3,
95 GPIO107_KP_MKOUT_4,
96 GPIO108_KP_MKOUT_5,
97 GPIO96_KP_MKOUT_6,
98 GPIO93_KP_DKIN_0 | WAKEUP_ON_LEVEL_HIGH, /* Hotsync button */
99
100 /* LCD */
101 GPIO58_LCD_LDD_0,
102 GPIO59_LCD_LDD_1,
103 GPIO60_LCD_LDD_2,
104 GPIO61_LCD_LDD_3,
105 GPIO62_LCD_LDD_4,
106 GPIO63_LCD_LDD_5,
107 GPIO64_LCD_LDD_6,
108 GPIO65_LCD_LDD_7,
109 GPIO66_LCD_LDD_8,
110 GPIO67_LCD_LDD_9,
111 GPIO68_LCD_LDD_10,
112 GPIO69_LCD_LDD_11,
113 GPIO70_LCD_LDD_12,
114 GPIO71_LCD_LDD_13,
115 GPIO72_LCD_LDD_14,
116 GPIO73_LCD_LDD_15,
117 GPIO74_LCD_FCLK,
118 GPIO75_LCD_LCLK,
119 GPIO76_LCD_PCLK,
120
121 /* Quick Capture Interface */
122 GPIO84_CIF_FV,
123 GPIO85_CIF_LV,
124 GPIO53_CIF_MCLK,
125 GPIO54_CIF_PCLK,
126 GPIO81_CIF_DD_0,
127 GPIO55_CIF_DD_1,
128 GPIO51_CIF_DD_2,
129 GPIO50_CIF_DD_3,
130 GPIO52_CIF_DD_4,
131 GPIO48_CIF_DD_5,
132 GPIO17_CIF_DD_6,
133 GPIO12_CIF_DD_7,
134
135 /* I2C */
136 GPIO117_I2C_SCL,
137 GPIO118_I2C_SDA,
138
139 /* GSM */
140 GPIO14_GPIO | WAKEUP_ON_EDGE_BOTH, /* GSM host wake up */
141 GPIO34_FFUART_RXD,
142 GPIO35_FFUART_CTS,
143 GPIO39_FFUART_TXD,
144 GPIO41_FFUART_RTS,
145
146 /* MISC. */
147 GPIO0_GPIO | WAKEUP_ON_EDGE_BOTH, /* external power detect */
148 GPIO15_GPIO | WAKEUP_ON_EDGE_BOTH, /* silent switch */
149 GPIO116_GPIO, /* headphone detect */
150 GPIO11_GPIO | WAKEUP_ON_EDGE_BOTH, /* bluetooth host wake up */
151};
152
153#ifdef CONFIG_MACH_TREO680
154static unsigned long treo680_pin_config[] __initdata = {
155 GPIO33_GPIO, /* SD read only */
156
157 /* MATRIX KEYPAD - different wake up source */
158 GPIO100_KP_MKIN_0 | WAKEUP_ON_LEVEL_HIGH,
159 GPIO99_KP_MKIN_5,
160};
161#endif /* CONFIG_MACH_TREO680 */
162
163/******************************************************************************
164 * SD/MMC card controller
165 ******************************************************************************/
166#ifdef CONFIG_MACH_TREO680
167static struct pxamci_platform_data treo680_mci_platform_data = {
168 .ocr_mask = MMC_VDD_32_33 | MMC_VDD_33_34,
169 .gpio_card_detect = GPIO_NR_TREO_SD_DETECT_N,
170 .gpio_card_ro = GPIO_NR_TREO680_SD_READONLY,
171 .gpio_power = GPIO_NR_TREO680_SD_POWER,
172};
173#endif /* CONFIG_MACH_TREO680 */
174
175/******************************************************************************
176 * GPIO keyboard
177 ******************************************************************************/
178#ifdef CONFIG_MACH_TREO680
179static unsigned int treo680_matrix_keys[] = {
180 KEY(0, 0, KEY_F8), /* Red/Off/Power */
181 KEY(0, 1, KEY_LEFT),
182 KEY(0, 2, KEY_LEFTCTRL), /* Alternate */
183 KEY(0, 3, KEY_L),
184 KEY(0, 4, KEY_A),
185 KEY(0, 5, KEY_Q),
186 KEY(0, 6, KEY_P),
187
188 KEY(1, 0, KEY_RIGHTCTRL), /* Menu */
189 KEY(1, 1, KEY_RIGHT),
190 KEY(1, 2, KEY_LEFTSHIFT), /* Left shift */
191 KEY(1, 3, KEY_Z),
192 KEY(1, 4, KEY_S),
193 KEY(1, 5, KEY_W),
194
195 KEY(2, 0, KEY_F1), /* Phone */
196 KEY(2, 1, KEY_UP),
197 KEY(2, 2, KEY_0),
198 KEY(2, 3, KEY_X),
199 KEY(2, 4, KEY_D),
200 KEY(2, 5, KEY_E),
201
202 KEY(3, 0, KEY_F10), /* Calendar */
203 KEY(3, 1, KEY_DOWN),
204 KEY(3, 2, KEY_SPACE),
205 KEY(3, 3, KEY_C),
206 KEY(3, 4, KEY_F),
207 KEY(3, 5, KEY_R),
208
209 KEY(4, 0, KEY_F12), /* Mail */
210 KEY(4, 1, KEY_KPENTER),
211 KEY(4, 2, KEY_RIGHTALT), /* Alt */
212 KEY(4, 3, KEY_V),
213 KEY(4, 4, KEY_G),
214 KEY(4, 5, KEY_T),
215
216 KEY(5, 0, KEY_F9), /* Home */
217 KEY(5, 1, KEY_PAGEUP), /* Side up */
218 KEY(5, 2, KEY_DOT),
219 KEY(5, 3, KEY_B),
220 KEY(5, 4, KEY_H),
221 KEY(5, 5, KEY_Y),
222
223 KEY(6, 0, KEY_TAB), /* Side Activate */
224 KEY(6, 1, KEY_PAGEDOWN), /* Side down */
225 KEY(6, 2, KEY_ENTER),
226 KEY(6, 3, KEY_N),
227 KEY(6, 4, KEY_J),
228 KEY(6, 5, KEY_U),
229
230 KEY(7, 0, KEY_F6), /* Green/Call */
231 KEY(7, 1, KEY_O),
232 KEY(7, 2, KEY_BACKSPACE),
233 KEY(7, 3, KEY_M),
234 KEY(7, 4, KEY_K),
235 KEY(7, 5, KEY_I),
236};
237
238static struct pxa27x_keypad_platform_data treo680_keypad_platform_data = {
239 .matrix_key_rows = 8,
240 .matrix_key_cols = 7,
241 .matrix_key_map = treo680_matrix_keys,
242 .matrix_key_map_size = ARRAY_SIZE(treo680_matrix_keys),
243 .direct_key_map = { KEY_CONNECT },
244 .direct_key_num = 1,
245
246 .debounce_interval = 30,
247};
248#endif /* CONFIG_MACH_TREO680 */
249
250/******************************************************************************
251 * aSoC audio
252 ******************************************************************************/
253
254static pxa2xx_audio_ops_t treo_ac97_pdata = {
255 .reset_gpio = 95,
256};
257
258/******************************************************************************
259 * Backlight
260 ******************************************************************************/
261static int treo_backlight_init(struct device *dev)
262{
263 int ret;
264
265 ret = gpio_request(GPIO_NR_TREO_BL_POWER, "BL POWER");
266 if (ret)
267 goto err;
268 ret = gpio_direction_output(GPIO_NR_TREO_BL_POWER, 0);
269 if (ret)
270 goto err2;
271
272 return 0;
273
274err2:
275 gpio_free(GPIO_NR_TREO_BL_POWER);
276err:
277 return ret;
278}
279
280static int treo_backlight_notify(int brightness)
281{
282 gpio_set_value(GPIO_NR_TREO_BL_POWER, brightness);
283 return TREO_MAX_INTENSITY - brightness;
284};
285
286static void treo_backlight_exit(struct device *dev)
287{
288 gpio_free(GPIO_NR_TREO_BL_POWER);
289}
290
291static struct platform_pwm_backlight_data treo_backlight_data = {
292 .pwm_id = 0,
293 .max_brightness = TREO_MAX_INTENSITY,
294 .dft_brightness = TREO_DEFAULT_INTENSITY,
295 .pwm_period_ns = TREO_PERIOD_NS,
296 .init = treo_backlight_init,
297 .notify = treo_backlight_notify,
298 .exit = treo_backlight_exit,
299};
300
301static struct platform_device treo_backlight = {
302 .name = "pwm-backlight",
303 .dev = {
304 .parent = &pxa27x_device_pwm0.dev,
305 .platform_data = &treo_backlight_data,
306 },
307};
308
309/******************************************************************************
310 * IrDA
311 ******************************************************************************/
312static struct pxaficp_platform_data treo_ficp_info = {
313 .gpio_pwdown = GPIO_NR_TREO_IR_EN,
314 .transceiver_cap = IR_SIRMODE | IR_OFF,
315};
316
317/******************************************************************************
318 * UDC
319 ******************************************************************************/
320static struct pxa2xx_udc_mach_info treo_udc_info __initdata = {
321 .gpio_vbus = GPIO_NR_TREO_USB_DETECT,
322 .gpio_vbus_inverted = 1,
323 .gpio_pullup = GPIO_NR_TREO_USB_PULLUP,
324};
325
326
327/******************************************************************************
328 * USB host
329 ******************************************************************************/
330#ifdef CONFIG_MACH_TREO680
331static struct pxaohci_platform_data treo680_ohci_info = {
332 .port_mode = PMM_PERPORT_MODE,
333 .flags = ENABLE_PORT1 | ENABLE_PORT3,
334 .power_budget = 0,
335};
336#endif /* CONFIG_MACH_TREO680 */
337
338/******************************************************************************
339 * Power supply
340 ******************************************************************************/
341static int power_supply_init(struct device *dev)
342{
343 int ret;
344
345 ret = gpio_request(GPIO_NR_TREO_POWER_DETECT, "CABLE_STATE_AC");
346 if (ret)
347 goto err1;
348 ret = gpio_direction_input(GPIO_NR_TREO_POWER_DETECT);
349 if (ret)
350 goto err2;
351
352 return 0;
353
354err2:
355 gpio_free(GPIO_NR_TREO_POWER_DETECT);
356err1:
357 return ret;
358}
359
360static int treo_is_ac_online(void)
361{
362 return gpio_get_value(GPIO_NR_TREO_POWER_DETECT);
363}
364
365static void power_supply_exit(struct device *dev)
366{
367 gpio_free(GPIO_NR_TREO_POWER_DETECT);
368}
369
370static char *treo_supplicants[] = {
371 "main-battery",
372};
373
374static struct pda_power_pdata power_supply_info = {
375 .init = power_supply_init,
376 .is_ac_online = treo_is_ac_online,
377 .exit = power_supply_exit,
378 .supplied_to = treo_supplicants,
379 .num_supplicants = ARRAY_SIZE(treo_supplicants),
380};
381
382static struct platform_device power_supply = {
383 .name = "pda-power",
384 .id = -1,
385 .dev = {
386 .platform_data = &power_supply_info,
387 },
388};
389
390/******************************************************************************
391 * Vibra and LEDs
392 ******************************************************************************/
393#ifdef CONFIG_MACH_TREO680
394static struct gpio_led treo680_gpio_leds[] = {
395 {
396 .name = "treo680:vibra:vibra",
397 .default_trigger = "none",
398 .gpio = GPIO_NR_TREO680_VIBRATE_EN,
399 },
400 {
401 .name = "treo680:green:led",
402 .default_trigger = "mmc0",
403 .gpio = GPIO_NR_TREO_GREEN_LED,
404 },
405 {
406 .name = "treo680:white:keybbl",
407 .default_trigger = "none",
408 .gpio = GPIO_NR_TREO680_KEYB_BL,
409 },
410};
411
412static struct gpio_led_platform_data treo680_gpio_led_info = {
413 .leds = treo680_gpio_leds,
414 .num_leds = ARRAY_SIZE(treo680_gpio_leds),
415};
416
417static struct platform_device treo680_leds = {
418 .name = "leds-gpio",
419 .id = -1,
420 .dev = {
421 .platform_data = &treo680_gpio_led_info,
422 }
423};
424#endif /* CONFIG_MACH_TREO680 */
425
426/******************************************************************************
427 * Framebuffer
428 ******************************************************************************/
429/* TODO: add support for 324x324 */
430static struct pxafb_mode_info treo_lcd_modes[] = {
431{
432 .pixclock = 86538,
433 .xres = 320,
434 .yres = 320,
435 .bpp = 16,
436
437 .left_margin = 20,
438 .right_margin = 8,
439 .upper_margin = 8,
440 .lower_margin = 5,
441
442 .hsync_len = 4,
443 .vsync_len = 1,
444},
445};
446
447static void treo_lcd_power(int on, struct fb_var_screeninfo *info)
448{
449 gpio_set_value(GPIO_NR_TREO_BL_POWER, on);
450}
451
452static struct pxafb_mach_info treo_lcd_screen = {
453 .modes = treo_lcd_modes,
454 .num_modes = ARRAY_SIZE(treo_lcd_modes),
455 .lcd_conn = LCD_COLOR_TFT_16BPP | LCD_PCLK_EDGE_FALL,
456};
457
458/******************************************************************************
459 * Power management - standby
460 ******************************************************************************/
461static void __init treo_pm_init(void)
462{
463 static u32 resume[] = {
464 0xe3a00101, /* mov r0, #0x40000000 */
465 0xe380060f, /* orr r0, r0, #0x00f00000 */
466 0xe590f008, /* ldr pc, [r0, #0x08] */
467 };
468
469 /* this is where the bootloader jumps */
470 memcpy(phys_to_virt(TREO_STR_BASE), resume, sizeof(resume));
471}
472
473/******************************************************************************
474 * Machine init
475 ******************************************************************************/
476static struct platform_device *treo_devices[] __initdata = {
477 &treo_backlight,
478 &power_supply,
479};
480
481#ifdef CONFIG_MACH_TREO680
482static struct platform_device *treo680_devices[] __initdata = {
483 &treo680_leds,
484};
485#endif /* CONFIG_MACH_TREO680 */
486
487/* setup udc GPIOs initial state */
488static void __init treo_udc_init(void)
489{
490 if (!gpio_request(GPIO_NR_TREO_USB_PULLUP, "UDC Vbus")) {
491 gpio_direction_output(GPIO_NR_TREO_USB_PULLUP, 1);
492 gpio_free(GPIO_NR_TREO_USB_PULLUP);
493 }
494}
495
496static void __init treo_lcd_power_init(void)
497{
498 int ret;
499
500 ret = gpio_request(GPIO_NR_TREO_LCD_POWER, "LCD POWER");
501 if (ret) {
502 pr_err("Treo680: LCD power GPIO request failed!\n");
503 return;
504 }
505
506 ret = gpio_direction_output(GPIO_NR_TREO_LCD_POWER, 0);
507 if (ret) {
508 pr_err("Treo680: setting LCD power GPIO direction failed!\n");
509 gpio_free(GPIO_NR_TREO_LCD_POWER);
510 return;
511 }
512
513 treo_lcd_screen.pxafb_lcd_power = treo_lcd_power;
514}
515
516static void __init treo_init(void)
517{
518 treo_pm_init();
519 pxa2xx_mfp_config(ARRAY_AND_SIZE(treo_pin_config));
520 treo_lcd_power_init();
521 set_pxa_fb_info(&treo_lcd_screen);
522 treo_udc_init();
523 pxa_set_udc_info(&treo_udc_info);
524 pxa_set_ac97_info(&treo_ac97_pdata);
525 pxa_set_ficp_info(&treo_ficp_info);
526
527 platform_add_devices(ARRAY_AND_SIZE(treo_devices));
528}
529
530#ifdef CONFIG_MACH_TREO680
531static void __init treo680_init(void)
532{
533 treo_init();
534 pxa2xx_mfp_config(ARRAY_AND_SIZE(treo680_pin_config));
535 pxa_set_mci_info(&treo680_mci_platform_data);
536 pxa_set_keypad_info(&treo680_keypad_platform_data);
537 pxa_set_ohci_info(&treo680_ohci_info);
538
539 platform_add_devices(ARRAY_AND_SIZE(treo680_devices));
540}
541
542MACHINE_START(TREO680, "Palm Treo 680")
543 .phys_io = TREO_PHYS_IO_START,
544 .io_pg_offst = io_p2v(0x40000000),
545 .boot_params = 0xa0000100,
546 .map_io = pxa_map_io,
547 .init_irq = pxa27x_init_irq,
548 .timer = &pxa_timer,
549 .init_machine = treo680_init,
550MACHINE_END
551#endif /* CONFIG_MACH_TREO680 */