hwmon: (w83795) Use standard attributes for chassis intrusion
[linux-2.6/linux-acpi-2.6/ibm-acpi-2.6.git] / arch / arm / mach-pxa / palmtreo.c
blob00e2d7ba84ed47c5d93c16bd699c62cdff400269
1 /*
2 * Hardware definitions for Palm Treo smartphones
4 * currently supported:
5 * Palm Treo 680 (GSM)
6 * Palm Centro 685 (GSM)
8 * Author: Tomas Cech <sleep_walker@suse.cz>
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License version 2 as
12 * published by the Free Software Foundation.
14 * (find more info at www.hackndev.com)
18 #include <linux/platform_device.h>
19 #include <linux/delay.h>
20 #include <linux/irq.h>
21 #include <linux/gpio_keys.h>
22 #include <linux/input.h>
23 #include <linux/memblock.h>
24 #include <linux/pda_power.h>
25 #include <linux/pwm_backlight.h>
26 #include <linux/gpio.h>
27 #include <linux/power_supply.h>
28 #include <linux/sysdev.h>
29 #include <linux/w1-gpio.h>
31 #include <asm/mach-types.h>
32 #include <asm/mach/arch.h>
33 #include <asm/mach/map.h>
35 #include <mach/pxa27x.h>
36 #include <mach/pxa27x-udc.h>
37 #include <mach/audio.h>
38 #include <mach/palmtreo.h>
39 #include <mach/mmc.h>
40 #include <mach/pxafb.h>
41 #include <mach/irda.h>
42 #include <plat/pxa27x_keypad.h>
43 #include <mach/udc.h>
44 #include <mach/ohci.h>
45 #include <mach/pxa2xx-regs.h>
46 #include <mach/palmasoc.h>
47 #include <mach/camera.h>
48 #include <mach/palm27x.h>
50 #include <sound/pxa2xx-lib.h>
52 #include "generic.h"
53 #include "devices.h"
55 /******************************************************************************
56 * Pin configuration
57 ******************************************************************************/
58 static unsigned long treo_pin_config[] __initdata = {
59 /* MMC */
60 GPIO32_MMC_CLK,
61 GPIO92_MMC_DAT_0,
62 GPIO109_MMC_DAT_1,
63 GPIO110_MMC_DAT_2,
64 GPIO111_MMC_DAT_3,
65 GPIO112_MMC_CMD,
66 GPIO113_GPIO, /* SD detect */
68 /* AC97 */
69 GPIO28_AC97_BITCLK,
70 GPIO29_AC97_SDATA_IN_0,
71 GPIO30_AC97_SDATA_OUT,
72 GPIO31_AC97_SYNC,
73 GPIO89_AC97_SYSCLK,
74 GPIO95_AC97_nRESET,
76 /* IrDA */
77 GPIO46_FICP_RXD,
78 GPIO47_FICP_TXD,
80 /* PWM */
81 GPIO16_PWM0_OUT,
83 /* USB */
84 GPIO1_GPIO | WAKEUP_ON_EDGE_BOTH, /* usb detect */
86 /* MATRIX KEYPAD */
87 GPIO101_KP_MKIN_1,
88 GPIO102_KP_MKIN_2,
89 GPIO97_KP_MKIN_3,
90 GPIO98_KP_MKIN_4,
91 GPIO91_KP_MKIN_6,
92 GPIO13_KP_MKIN_7,
93 GPIO103_KP_MKOUT_0 | MFP_LPM_DRIVE_HIGH,
94 GPIO104_KP_MKOUT_1,
95 GPIO105_KP_MKOUT_2,
96 GPIO106_KP_MKOUT_3,
97 GPIO107_KP_MKOUT_4,
98 GPIO108_KP_MKOUT_5,
99 GPIO96_KP_MKOUT_6,
100 GPIO93_KP_DKIN_0 | WAKEUP_ON_LEVEL_HIGH, /* Hotsync button */
102 /* LCD */
103 GPIOxx_LCD_TFT_16BPP,
105 /* Quick Capture Interface */
106 GPIO84_CIF_FV,
107 GPIO85_CIF_LV,
108 GPIO53_CIF_MCLK,
109 GPIO54_CIF_PCLK,
110 GPIO81_CIF_DD_0,
111 GPIO55_CIF_DD_1,
112 GPIO51_CIF_DD_2,
113 GPIO50_CIF_DD_3,
114 GPIO52_CIF_DD_4,
115 GPIO48_CIF_DD_5,
116 GPIO17_CIF_DD_6,
117 GPIO12_CIF_DD_7,
119 /* I2C */
120 GPIO117_I2C_SCL,
121 GPIO118_I2C_SDA,
123 /* GSM */
124 GPIO14_GPIO | WAKEUP_ON_EDGE_BOTH, /* GSM host wake up */
125 GPIO34_FFUART_RXD,
126 GPIO35_FFUART_CTS,
127 GPIO39_FFUART_TXD,
128 GPIO41_FFUART_RTS,
130 /* MISC. */
131 GPIO0_GPIO | WAKEUP_ON_EDGE_BOTH, /* external power detect */
132 GPIO15_GPIO | WAKEUP_ON_EDGE_BOTH, /* silent switch */
133 GPIO116_GPIO, /* headphone detect */
134 GPIO11_GPIO | WAKEUP_ON_EDGE_BOTH, /* bluetooth host wake up */
137 #ifdef CONFIG_MACH_TREO680
138 static unsigned long treo680_pin_config[] __initdata = {
139 GPIO33_GPIO, /* SD read only */
141 /* MATRIX KEYPAD - different wake up source */
142 GPIO100_KP_MKIN_0 | WAKEUP_ON_LEVEL_HIGH,
143 GPIO99_KP_MKIN_5,
145 #endif /* CONFIG_MACH_TREO680 */
147 #ifdef CONFIG_MACH_CENTRO
148 static unsigned long centro685_pin_config[] __initdata = {
149 /* Bluetooth attached to BT UART*/
150 MFP_CFG_OUT(GPIO80, AF0, DRIVE_LOW), /* power: LOW = off */
151 GPIO42_BTUART_RXD,
152 GPIO43_BTUART_TXD,
153 GPIO44_BTUART_CTS,
154 GPIO45_BTUART_RTS,
156 /* MATRIX KEYPAD - different wake up source */
157 GPIO100_KP_MKIN_0,
158 GPIO99_KP_MKIN_5 | WAKEUP_ON_LEVEL_HIGH,
160 #endif /* CONFIG_MACH_CENTRO */
162 /******************************************************************************
163 * GPIO keyboard
164 ******************************************************************************/
165 #if defined(CONFIG_KEYBOARD_PXA27x) || defined(CONFIG_KEYBOARD_PXA27x_MODULE)
166 static unsigned int treo680_matrix_keys[] = {
167 KEY(0, 0, KEY_F8), /* Red/Off/Power */
168 KEY(0, 1, KEY_LEFT),
169 KEY(0, 2, KEY_LEFTCTRL), /* Alternate */
170 KEY(0, 3, KEY_L),
171 KEY(0, 4, KEY_A),
172 KEY(0, 5, KEY_Q),
173 KEY(0, 6, KEY_P),
175 KEY(1, 0, KEY_RIGHTCTRL), /* Menu */
176 KEY(1, 1, KEY_RIGHT),
177 KEY(1, 2, KEY_LEFTSHIFT), /* Left shift */
178 KEY(1, 3, KEY_Z),
179 KEY(1, 4, KEY_S),
180 KEY(1, 5, KEY_W),
182 KEY(2, 0, KEY_F1), /* Phone */
183 KEY(2, 1, KEY_UP),
184 KEY(2, 2, KEY_0),
185 KEY(2, 3, KEY_X),
186 KEY(2, 4, KEY_D),
187 KEY(2, 5, KEY_E),
189 KEY(3, 0, KEY_F10), /* Calendar */
190 KEY(3, 1, KEY_DOWN),
191 KEY(3, 2, KEY_SPACE),
192 KEY(3, 3, KEY_C),
193 KEY(3, 4, KEY_F),
194 KEY(3, 5, KEY_R),
196 KEY(4, 0, KEY_F12), /* Mail */
197 KEY(4, 1, KEY_KPENTER),
198 KEY(4, 2, KEY_RIGHTALT), /* Alt */
199 KEY(4, 3, KEY_V),
200 KEY(4, 4, KEY_G),
201 KEY(4, 5, KEY_T),
203 KEY(5, 0, KEY_F9), /* Home */
204 KEY(5, 1, KEY_PAGEUP), /* Side up */
205 KEY(5, 2, KEY_DOT),
206 KEY(5, 3, KEY_B),
207 KEY(5, 4, KEY_H),
208 KEY(5, 5, KEY_Y),
210 KEY(6, 0, KEY_TAB), /* Side Activate */
211 KEY(6, 1, KEY_PAGEDOWN), /* Side down */
212 KEY(6, 2, KEY_ENTER),
213 KEY(6, 3, KEY_N),
214 KEY(6, 4, KEY_J),
215 KEY(6, 5, KEY_U),
217 KEY(7, 0, KEY_F6), /* Green/Call */
218 KEY(7, 1, KEY_O),
219 KEY(7, 2, KEY_BACKSPACE),
220 KEY(7, 3, KEY_M),
221 KEY(7, 4, KEY_K),
222 KEY(7, 5, KEY_I),
225 static unsigned int centro_matrix_keys[] = {
226 KEY(0, 0, KEY_F9), /* Home */
227 KEY(0, 1, KEY_LEFT),
228 KEY(0, 2, KEY_LEFTCTRL), /* Alternate */
229 KEY(0, 3, KEY_L),
230 KEY(0, 4, KEY_A),
231 KEY(0, 5, KEY_Q),
232 KEY(0, 6, KEY_P),
234 KEY(1, 0, KEY_RIGHTCTRL), /* Menu */
235 KEY(1, 1, KEY_RIGHT),
236 KEY(1, 2, KEY_LEFTSHIFT), /* Left shift */
237 KEY(1, 3, KEY_Z),
238 KEY(1, 4, KEY_S),
239 KEY(1, 5, KEY_W),
241 KEY(2, 0, KEY_F1), /* Phone */
242 KEY(2, 1, KEY_UP),
243 KEY(2, 2, KEY_0),
244 KEY(2, 3, KEY_X),
245 KEY(2, 4, KEY_D),
246 KEY(2, 5, KEY_E),
248 KEY(3, 0, KEY_F10), /* Calendar */
249 KEY(3, 1, KEY_DOWN),
250 KEY(3, 2, KEY_SPACE),
251 KEY(3, 3, KEY_C),
252 KEY(3, 4, KEY_F),
253 KEY(3, 5, KEY_R),
255 KEY(4, 0, KEY_F12), /* Mail */
256 KEY(4, 1, KEY_KPENTER),
257 KEY(4, 2, KEY_RIGHTALT), /* Alt */
258 KEY(4, 3, KEY_V),
259 KEY(4, 4, KEY_G),
260 KEY(4, 5, KEY_T),
262 KEY(5, 0, KEY_F8), /* Red/Off/Power */
263 KEY(5, 1, KEY_PAGEUP), /* Side up */
264 KEY(5, 2, KEY_DOT),
265 KEY(5, 3, KEY_B),
266 KEY(5, 4, KEY_H),
267 KEY(5, 5, KEY_Y),
269 KEY(6, 0, KEY_TAB), /* Side Activate */
270 KEY(6, 1, KEY_PAGEDOWN), /* Side down */
271 KEY(6, 2, KEY_ENTER),
272 KEY(6, 3, KEY_N),
273 KEY(6, 4, KEY_J),
274 KEY(6, 5, KEY_U),
276 KEY(7, 0, KEY_F6), /* Green/Call */
277 KEY(7, 1, KEY_O),
278 KEY(7, 2, KEY_BACKSPACE),
279 KEY(7, 3, KEY_M),
280 KEY(7, 4, KEY_K),
281 KEY(7, 5, KEY_I),
284 static struct pxa27x_keypad_platform_data treo680_keypad_pdata = {
285 .matrix_key_rows = 8,
286 .matrix_key_cols = 7,
287 .matrix_key_map = treo680_matrix_keys,
288 .matrix_key_map_size = ARRAY_SIZE(treo680_matrix_keys),
289 .direct_key_map = { KEY_CONNECT },
290 .direct_key_num = 1,
292 .debounce_interval = 30,
295 static void __init palmtreo_kpc_init(void)
297 static struct pxa27x_keypad_platform_data *data = &treo680_keypad_pdata;
299 if (machine_is_centro()) {
300 data->matrix_key_map = centro_matrix_keys;
301 data->matrix_key_map_size = ARRAY_SIZE(centro_matrix_keys);
304 pxa_set_keypad_info(&treo680_keypad_pdata);
306 #else
307 static inline void palmtreo_kpc_init(void) {}
308 #endif
310 /******************************************************************************
311 * USB host
312 ******************************************************************************/
313 #if defined(CONFIG_USB_OHCI_HCD) || defined(CONFIG_USB_OHCI_HCD_MODULE)
314 static struct pxaohci_platform_data treo680_ohci_info = {
315 .port_mode = PMM_PERPORT_MODE,
316 .flags = ENABLE_PORT1 | ENABLE_PORT3,
317 .power_budget = 0,
320 static void __init palmtreo_uhc_init(void)
322 if (machine_is_treo680())
323 pxa_set_ohci_info(&treo680_ohci_info);
325 #else
326 static inline void palmtreo_uhc_init(void) {}
327 #endif
329 /******************************************************************************
330 * Vibra and LEDs
331 ******************************************************************************/
332 #ifdef CONFIG_MACH_TREO680
333 static struct gpio_led treo680_gpio_leds[] = {
335 .name = "treo680:vibra:vibra",
336 .default_trigger = "none",
337 .gpio = GPIO_NR_TREO680_VIBRATE_EN,
340 .name = "treo680:green:led",
341 .default_trigger = "mmc0",
342 .gpio = GPIO_NR_TREO_GREEN_LED,
345 .name = "treo680:white:keybbl",
346 .default_trigger = "none",
347 .gpio = GPIO_NR_TREO680_KEYB_BL,
351 static struct gpio_led_platform_data treo680_gpio_led_info = {
352 .leds = treo680_gpio_leds,
353 .num_leds = ARRAY_SIZE(treo680_gpio_leds),
356 static struct gpio_led centro_gpio_leds[] = {
358 .name = "centro:vibra:vibra",
359 .default_trigger = "none",
360 .gpio = GPIO_NR_CENTRO_VIBRATE_EN,
363 .name = "centro:green:led",
364 .default_trigger = "mmc0",
365 .gpio = GPIO_NR_TREO_GREEN_LED,
368 .name = "centro:white:keybbl",
369 .default_trigger = "none",
370 .active_low = 1,
371 .gpio = GPIO_NR_CENTRO_KEYB_BL,
375 static struct gpio_led_platform_data centro_gpio_led_info = {
376 .leds = centro_gpio_leds,
377 .num_leds = ARRAY_SIZE(centro_gpio_leds),
380 static struct platform_device palmtreo_leds = {
381 .name = "leds-gpio",
382 .id = -1,
383 .dev = {
384 .platform_data = &treo680_gpio_led_info,
388 static void __init palmtreo_leds_init(void)
390 if (machine_is_centro())
391 palmtreo_leds.dev.platform_data = &centro_gpio_led_info;
393 platform_device_register(&palmtreo_leds);
395 #else
396 static inline void palmtreo_leds_init(void) {}
397 #endif
399 /******************************************************************************
400 * Machine init
401 ******************************************************************************/
402 static void __init treo_reserve(void)
404 memblock_reserve(0xa0000000, 0x1000);
405 memblock_reserve(0xa2000000, 0x1000);
408 static void __init palmphone_common_init(void)
410 pxa2xx_mfp_config(ARRAY_AND_SIZE(treo_pin_config));
411 pxa_set_ffuart_info(NULL);
412 pxa_set_btuart_info(NULL);
413 pxa_set_stuart_info(NULL);
414 palm27x_pm_init(TREO_STR_BASE);
415 palm27x_lcd_init(GPIO_NR_TREO_BL_POWER, &palm_320x320_new_lcd_mode);
416 palm27x_udc_init(GPIO_NR_TREO_USB_DETECT, GPIO_NR_TREO_USB_PULLUP, 1);
417 palm27x_irda_init(GPIO_NR_TREO_IR_EN);
418 palm27x_ac97_init(-1, -1, -1, 95);
419 palm27x_pwm_init(GPIO_NR_TREO_BL_POWER, -1);
420 palm27x_power_init(GPIO_NR_TREO_POWER_DETECT, -1);
421 palm27x_pmic_init();
422 palmtreo_kpc_init();
423 palmtreo_uhc_init();
424 palmtreo_leds_init();
427 static void __init treo680_init(void)
429 pxa2xx_mfp_config(ARRAY_AND_SIZE(treo680_pin_config));
430 palmphone_common_init();
431 palm27x_mmc_init(GPIO_NR_TREO_SD_DETECT_N, GPIO_NR_TREO680_SD_READONLY,
432 GPIO_NR_TREO680_SD_POWER, 0);
435 static void __init centro_init(void)
437 pxa2xx_mfp_config(ARRAY_AND_SIZE(centro685_pin_config));
438 palmphone_common_init();
439 palm27x_mmc_init(GPIO_NR_TREO_SD_DETECT_N, -1,
440 GPIO_NR_CENTRO_SD_POWER, 1);
443 MACHINE_START(TREO680, "Palm Treo 680")
444 .boot_params = 0xa0000100,
445 .map_io = pxa_map_io,
446 .reserve = treo_reserve,
447 .init_irq = pxa27x_init_irq,
448 .timer = &pxa_timer,
449 .init_machine = treo680_init,
450 MACHINE_END
452 MACHINE_START(CENTRO, "Palm Centro 685")
453 .boot_params = 0xa0000100,
454 .map_io = pxa_map_io,
455 .reserve = treo_reserve,
456 .init_irq = pxa27x_init_irq,
457 .timer = &pxa_timer,
458 .init_machine = centro_init,
459 MACHINE_END