]> bbs.cooldavid.org Git - net-next-2.6.git/blame - arch/arm/mach-pxa/palmld.c
[ARM] pxa/palm: add detect_delay to mmc for PalmTX,T5,LD
[net-next-2.6.git] / arch / arm / mach-pxa / palmld.c
CommitLineData
a645072a
MV
1/*
2 * Hardware definitions for Palm LifeDrive
3 *
4 * Author: Marek Vasut <marek.vasut@gmail.com>
5 *
6 * Based on work of:
7 * Alex Osborne <ato@meshy.org>
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>
81854f82 27#include <linux/sysdev.h>
a645072a
MV
28
29#include <asm/mach-types.h>
30#include <asm/mach/arch.h>
31#include <asm/mach/map.h>
32
51c62982 33#include <mach/pxa27x.h>
a645072a
MV
34#include <mach/audio.h>
35#include <mach/palmld.h>
36#include <mach/mmc.h>
37#include <mach/pxafb.h>
a645072a
MV
38#include <mach/irda.h>
39#include <mach/pxa27x_keypad.h>
40#include <mach/palmasoc.h>
41
42#include "generic.h"
43#include "devices.h"
44
45/******************************************************************************
46 * Pin configuration
47 ******************************************************************************/
48static unsigned long palmld_pin_config[] __initdata = {
49 /* MMC */
50 GPIO32_MMC_CLK,
51 GPIO92_MMC_DAT_0,
52 GPIO109_MMC_DAT_1,
53 GPIO110_MMC_DAT_2,
54 GPIO111_MMC_DAT_3,
55 GPIO112_MMC_CMD,
56 GPIO14_GPIO, /* SD detect */
57 GPIO114_GPIO, /* SD power */
58 GPIO116_GPIO, /* SD r/o switch */
59
60 /* AC97 */
61 GPIO28_AC97_BITCLK,
62 GPIO29_AC97_SDATA_IN_0,
63 GPIO30_AC97_SDATA_OUT,
64 GPIO31_AC97_SYNC,
6ec04f43
MV
65 GPIO89_AC97_SYSCLK,
66 GPIO95_AC97_nRESET,
a645072a
MV
67
68 /* IrDA */
69 GPIO108_GPIO, /* ir disable */
70 GPIO46_FICP_RXD,
71 GPIO47_FICP_TXD,
72
73 /* MATRIX KEYPAD */
81854f82
MV
74 GPIO100_KP_MKIN_0 | WAKEUP_ON_LEVEL_HIGH,
75 GPIO101_KP_MKIN_1 | WAKEUP_ON_LEVEL_HIGH,
76 GPIO102_KP_MKIN_2 | WAKEUP_ON_LEVEL_HIGH,
77 GPIO97_KP_MKIN_3 | WAKEUP_ON_LEVEL_HIGH,
a645072a
MV
78 GPIO103_KP_MKOUT_0,
79 GPIO104_KP_MKOUT_1,
80 GPIO105_KP_MKOUT_2,
81
82 /* LCD */
83 GPIO58_LCD_LDD_0,
84 GPIO59_LCD_LDD_1,
85 GPIO60_LCD_LDD_2,
86 GPIO61_LCD_LDD_3,
87 GPIO62_LCD_LDD_4,
88 GPIO63_LCD_LDD_5,
89 GPIO64_LCD_LDD_6,
90 GPIO65_LCD_LDD_7,
91 GPIO66_LCD_LDD_8,
92 GPIO67_LCD_LDD_9,
93 GPIO68_LCD_LDD_10,
94 GPIO69_LCD_LDD_11,
95 GPIO70_LCD_LDD_12,
96 GPIO71_LCD_LDD_13,
97 GPIO72_LCD_LDD_14,
98 GPIO73_LCD_LDD_15,
99 GPIO74_LCD_FCLK,
100 GPIO75_LCD_LCLK,
101 GPIO76_LCD_PCLK,
102 GPIO77_LCD_BIAS,
103
104 /* PWM */
105 GPIO16_PWM0_OUT,
106
107 /* GPIO KEYS */
108 GPIO10_GPIO, /* hotsync button */
109 GPIO12_GPIO, /* power switch */
110 GPIO15_GPIO, /* lock switch */
111
112 /* LEDs */
113 GPIO52_GPIO, /* green led */
114 GPIO94_GPIO, /* orange led */
115
116 /* PCMCIA */
117 GPIO48_nPOE,
118 GPIO49_nPWE,
119 GPIO50_nPIOR,
120 GPIO51_nPIOW,
121 GPIO85_nPCE_1,
122 GPIO54_nPCE_2,
123 GPIO79_PSKTSEL,
124 GPIO55_nPREG,
125 GPIO56_nPWAIT,
126 GPIO57_nIOIS16,
127 GPIO36_GPIO, /* wifi power */
128 GPIO38_GPIO, /* wifi ready */
129 GPIO81_GPIO, /* wifi reset */
130
ecf763c5
MV
131 /* FFUART */
132 GPIO34_FFUART_RXD,
133 GPIO39_FFUART_TXD,
134
a645072a 135 /* HDD */
5a9d2515 136 GPIO98_GPIO, /* HDD reset */
a645072a
MV
137 GPIO115_GPIO, /* HDD power */
138
139 /* MISC */
140 GPIO13_GPIO, /* earphone detect */
141};
142
143/******************************************************************************
144 * SD/MMC card controller
145 ******************************************************************************/
a645072a 146static struct pxamci_platform_data palmld_mci_platform_data = {
7a648256
RJ
147 .ocr_mask = MMC_VDD_32_33 | MMC_VDD_33_34,
148 .gpio_card_detect = GPIO_NR_PALMLD_SD_DETECT_N,
149 .gpio_card_ro = GPIO_NR_PALMLD_SD_READONLY,
150 .gpio_power = GPIO_NR_PALMLD_SD_POWER,
9845b6b1 151 .detect_delay = 20,
a645072a
MV
152};
153
154/******************************************************************************
155 * GPIO keyboard
156 ******************************************************************************/
157static unsigned int palmld_matrix_keys[] = {
158 KEY(0, 1, KEY_F2),
159 KEY(0, 2, KEY_UP),
160
161 KEY(1, 0, KEY_F3),
162 KEY(1, 1, KEY_F4),
163 KEY(1, 2, KEY_RIGHT),
164
165 KEY(2, 0, KEY_F1),
166 KEY(2, 1, KEY_F5),
167 KEY(2, 2, KEY_DOWN),
168
169 KEY(3, 0, KEY_F6),
170 KEY(3, 1, KEY_ENTER),
171 KEY(3, 2, KEY_LEFT),
172};
173
174static struct pxa27x_keypad_platform_data palmld_keypad_platform_data = {
175 .matrix_key_rows = 4,
176 .matrix_key_cols = 3,
177 .matrix_key_map = palmld_matrix_keys,
178 .matrix_key_map_size = ARRAY_SIZE(palmld_matrix_keys),
179
180 .debounce_interval = 30,
181};
182
183/******************************************************************************
184 * GPIO keys
185 ******************************************************************************/
186static struct gpio_keys_button palmld_pxa_buttons[] = {
187 {KEY_F8, GPIO_NR_PALMLD_HOTSYNC_BUTTON_N, 1, "HotSync Button" },
188 {KEY_F9, GPIO_NR_PALMLD_LOCK_SWITCH, 0, "Lock Switch" },
189 {KEY_POWER, GPIO_NR_PALMLD_POWER_SWITCH, 0, "Power Switch" },
190};
191
192static struct gpio_keys_platform_data palmld_pxa_keys_data = {
193 .buttons = palmld_pxa_buttons,
194 .nbuttons = ARRAY_SIZE(palmld_pxa_buttons),
195};
196
197static struct platform_device palmld_pxa_keys = {
198 .name = "gpio-keys",
199 .id = -1,
200 .dev = {
201 .platform_data = &palmld_pxa_keys_data,
202 },
203};
204
205/******************************************************************************
206 * Backlight
207 ******************************************************************************/
208static int palmld_backlight_init(struct device *dev)
209{
210 int ret;
211
212 ret = gpio_request(GPIO_NR_PALMLD_BL_POWER, "BL POWER");
213 if (ret)
214 goto err;
215 ret = gpio_direction_output(GPIO_NR_PALMLD_BL_POWER, 0);
216 if (ret)
217 goto err2;
218 ret = gpio_request(GPIO_NR_PALMLD_LCD_POWER, "LCD POWER");
219 if (ret)
220 goto err2;
221 ret = gpio_direction_output(GPIO_NR_PALMLD_LCD_POWER, 0);
222 if (ret)
223 goto err3;
224
225 return 0;
226err3:
227 gpio_free(GPIO_NR_PALMLD_LCD_POWER);
228err2:
229 gpio_free(GPIO_NR_PALMLD_BL_POWER);
230err:
231 return ret;
232}
233
234static int palmld_backlight_notify(int brightness)
235{
236 gpio_set_value(GPIO_NR_PALMLD_BL_POWER, brightness);
237 gpio_set_value(GPIO_NR_PALMLD_LCD_POWER, brightness);
238 return brightness;
239}
240
241static void palmld_backlight_exit(struct device *dev)
242{
243 gpio_free(GPIO_NR_PALMLD_BL_POWER);
244 gpio_free(GPIO_NR_PALMLD_LCD_POWER);
245}
246
247static struct platform_pwm_backlight_data palmld_backlight_data = {
248 .pwm_id = 0,
249 .max_brightness = PALMLD_MAX_INTENSITY,
250 .dft_brightness = PALMLD_MAX_INTENSITY,
251 .pwm_period_ns = PALMLD_PERIOD_NS,
252 .init = palmld_backlight_init,
253 .notify = palmld_backlight_notify,
254 .exit = palmld_backlight_exit,
255};
256
257static struct platform_device palmld_backlight = {
258 .name = "pwm-backlight",
259 .dev = {
260 .parent = &pxa27x_device_pwm0.dev,
261 .platform_data = &palmld_backlight_data,
262 },
263};
264
265/******************************************************************************
266 * IrDA
267 ******************************************************************************/
268static int palmld_irda_startup(struct device *dev)
269{
270 int err;
271 err = gpio_request(GPIO_NR_PALMLD_IR_DISABLE, "IR DISABLE");
272 if (err)
273 goto err;
274 err = gpio_direction_output(GPIO_NR_PALMLD_IR_DISABLE, 1);
275 if (err)
276 gpio_free(GPIO_NR_PALMLD_IR_DISABLE);
277err:
278 return err;
279}
280
281static void palmld_irda_shutdown(struct device *dev)
282{
283 gpio_free(GPIO_NR_PALMLD_IR_DISABLE);
284}
285
286static void palmld_irda_transceiver_mode(struct device *dev, int mode)
287{
288 gpio_set_value(GPIO_NR_PALMLD_IR_DISABLE, mode & IR_OFF);
289 pxa2xx_transceiver_mode(dev, mode);
290}
291
292static struct pxaficp_platform_data palmld_ficp_platform_data = {
293 .startup = palmld_irda_startup,
294 .shutdown = palmld_irda_shutdown,
295 .transceiver_cap = IR_SIRMODE | IR_FIRMODE | IR_OFF,
296 .transceiver_mode = palmld_irda_transceiver_mode,
297};
298
299/******************************************************************************
300 * LEDs
301 ******************************************************************************/
302struct gpio_led gpio_leds[] = {
303{
304 .name = "palmld:green:led",
305 .default_trigger = "none",
306 .gpio = GPIO_NR_PALMLD_LED_GREEN,
307}, {
308 .name = "palmld:amber:led",
309 .default_trigger = "none",
310 .gpio = GPIO_NR_PALMLD_LED_AMBER,
311},
312};
313
314static struct gpio_led_platform_data gpio_led_info = {
315 .leds = gpio_leds,
316 .num_leds = ARRAY_SIZE(gpio_leds),
317};
318
319static struct platform_device palmld_leds = {
320 .name = "leds-gpio",
321 .id = -1,
322 .dev = {
323 .platform_data = &gpio_led_info,
324 }
325};
326
327/******************************************************************************
328 * Power supply
329 ******************************************************************************/
330static int power_supply_init(struct device *dev)
331{
332 int ret;
333
334 ret = gpio_request(GPIO_NR_PALMLD_POWER_DETECT, "CABLE_STATE_AC");
335 if (ret)
336 goto err1;
337 ret = gpio_direction_input(GPIO_NR_PALMLD_POWER_DETECT);
338 if (ret)
339 goto err2;
340
341 ret = gpio_request(GPIO_NR_PALMLD_USB_DETECT_N, "CABLE_STATE_USB");
342 if (ret)
343 goto err2;
344 ret = gpio_direction_input(GPIO_NR_PALMLD_USB_DETECT_N);
345 if (ret)
346 goto err3;
347
348 return 0;
349
350err3:
351 gpio_free(GPIO_NR_PALMLD_USB_DETECT_N);
352err2:
353 gpio_free(GPIO_NR_PALMLD_POWER_DETECT);
354err1:
355 return ret;
356}
357
358static int palmld_is_ac_online(void)
359{
360 return gpio_get_value(GPIO_NR_PALMLD_POWER_DETECT);
361}
362
363static int palmld_is_usb_online(void)
364{
365 return !gpio_get_value(GPIO_NR_PALMLD_USB_DETECT_N);
366}
367
368static void power_supply_exit(struct device *dev)
369{
370 gpio_free(GPIO_NR_PALMLD_USB_DETECT_N);
371 gpio_free(GPIO_NR_PALMLD_POWER_DETECT);
372}
373
374static char *palmld_supplicants[] = {
375 "main-battery",
376};
377
378static struct pda_power_pdata power_supply_info = {
379 .init = power_supply_init,
380 .is_ac_online = palmld_is_ac_online,
381 .is_usb_online = palmld_is_usb_online,
382 .exit = power_supply_exit,
383 .supplied_to = palmld_supplicants,
384 .num_supplicants = ARRAY_SIZE(palmld_supplicants),
385};
386
387static struct platform_device power_supply = {
388 .name = "pda-power",
389 .id = -1,
390 .dev = {
391 .platform_data = &power_supply_info,
392 },
393};
394
395/******************************************************************************
396 * WM97xx battery
397 ******************************************************************************/
398static struct wm97xx_batt_info wm97xx_batt_pdata = {
399 .batt_aux = WM97XX_AUX_ID3,
400 .temp_aux = WM97XX_AUX_ID2,
401 .charge_gpio = -1,
402 .max_voltage = PALMLD_BAT_MAX_VOLTAGE,
403 .min_voltage = PALMLD_BAT_MIN_VOLTAGE,
404 .batt_mult = 1000,
405 .batt_div = 414,
406 .temp_mult = 1,
407 .temp_div = 1,
408 .batt_tech = POWER_SUPPLY_TECHNOLOGY_LIPO,
409 .batt_name = "main-batt",
410};
411
412/******************************************************************************
413 * aSoC audio
414 ******************************************************************************/
e91fb913 415static struct palm27x_asoc_info palmld_asoc_pdata = {
a645072a
MV
416 .jack_gpio = GPIO_NR_PALMLD_EARPHONE_DETECT,
417};
418
e91fb913
MV
419static pxa2xx_audio_ops_t palmld_ac97_pdata = {
420 .reset_gpio = 95,
421};
422
423static struct platform_device palmld_asoc = {
424 .name = "palm27x-asoc",
425 .id = -1,
426 .dev = {
427 .platform_data = &palmld_asoc_pdata,
428 },
429};
430
5a9d2515
MV
431/******************************************************************************
432 * HDD
433 ******************************************************************************/
434static struct platform_device palmld_hdd = {
435 .name = "pata_palmld",
436 .id = -1,
437};
438
a645072a
MV
439/******************************************************************************
440 * Framebuffer
441 ******************************************************************************/
442static struct pxafb_mode_info palmld_lcd_modes[] = {
443{
444 .pixclock = 57692,
445 .xres = 320,
446 .yres = 480,
447 .bpp = 16,
448
449 .left_margin = 32,
450 .right_margin = 1,
451 .upper_margin = 7,
452 .lower_margin = 1,
453
454 .hsync_len = 4,
455 .vsync_len = 1,
456},
457};
458
459static struct pxafb_mach_info palmld_lcd_screen = {
460 .modes = palmld_lcd_modes,
461 .num_modes = ARRAY_SIZE(palmld_lcd_modes),
462 .lcd_conn = LCD_COLOR_TFT_16BPP | LCD_PCLK_EDGE_FALL,
463};
464
81854f82
MV
465/******************************************************************************
466 * Power management - standby
467 ******************************************************************************/
fc9c1b6f 468static void __init palmld_pm_init(void)
81854f82 469{
fc9c1b6f
MV
470 static u32 resume[] = {
471 0xe3a00101, /* mov r0, #0x40000000 */
472 0xe380060f, /* orr r0, r0, #0x00f00000 */
473 0xe590f008, /* ldr pc, [r0, #0x08] */
474 };
475
476 /* copy the bootloader */
477 memcpy(phys_to_virt(PALMLD_STR_BASE), resume, sizeof(resume));
81854f82
MV
478}
479
a645072a
MV
480/******************************************************************************
481 * Machine init
482 ******************************************************************************/
483static struct platform_device *devices[] __initdata = {
484#if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)
485 &palmld_pxa_keys,
486#endif
487 &palmld_backlight,
488 &palmld_leds,
489 &power_supply,
e91fb913 490 &palmld_asoc,
5a9d2515 491 &palmld_hdd,
a645072a
MV
492};
493
494static struct map_desc palmld_io_desc[] __initdata = {
495{
496 .virtual = PALMLD_IDE_VIRT,
497 .pfn = __phys_to_pfn(PALMLD_IDE_PHYS),
498 .length = PALMLD_IDE_SIZE,
499 .type = MT_DEVICE
500},
501{
502 .virtual = PALMLD_USB_VIRT,
503 .pfn = __phys_to_pfn(PALMLD_USB_PHYS),
504 .length = PALMLD_USB_SIZE,
505 .type = MT_DEVICE
506},
507};
508
509static void __init palmld_map_io(void)
510{
511 pxa_map_io();
512 iotable_init(palmld_io_desc, ARRAY_SIZE(palmld_io_desc));
513}
514
515static void __init palmld_init(void)
516{
517 pxa2xx_mfp_config(ARRAY_AND_SIZE(palmld_pin_config));
518
fc9c1b6f 519 palmld_pm_init();
a645072a
MV
520 set_pxa_fb_info(&palmld_lcd_screen);
521 pxa_set_mci_info(&palmld_mci_platform_data);
e91fb913 522 pxa_set_ac97_info(&palmld_ac97_pdata);
a645072a
MV
523 pxa_set_ficp_info(&palmld_ficp_platform_data);
524 pxa_set_keypad_info(&palmld_keypad_platform_data);
525 wm97xx_bat_set_pdata(&wm97xx_batt_pdata);
a645072a
MV
526
527 platform_add_devices(devices, ARRAY_SIZE(devices));
528}
529
530MACHINE_START(PALMLD, "Palm LifeDrive")
531 .phys_io = PALMLD_PHYS_IO_START,
532 .io_pg_offst = (io_p2v(0x40000000) >> 18) & 0xfffc,
533 .boot_params = 0xa0000100,
534 .map_io = palmld_map_io,
535 .init_irq = pxa27x_init_irq,
536 .timer = &pxa_timer,
537 .init_machine = palmld_init
538MACHINE_END