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.c357
1 files changed, 61 insertions, 296 deletions
diff --git a/arch/arm/mach-pxa/palmtreo.c b/arch/arm/mach-pxa/palmtreo.c
index d8b4469607a1..52defd5e42e5 100644
--- a/arch/arm/mach-pxa/palmtreo.c
+++ b/arch/arm/mach-pxa/palmtreo.c
@@ -20,10 +20,10 @@
20#include <linux/irq.h> 20#include <linux/irq.h>
21#include <linux/gpio_keys.h> 21#include <linux/gpio_keys.h>
22#include <linux/input.h> 22#include <linux/input.h>
23#include <linux/memblock.h>
23#include <linux/pda_power.h> 24#include <linux/pda_power.h>
24#include <linux/pwm_backlight.h> 25#include <linux/pwm_backlight.h>
25#include <linux/gpio.h> 26#include <linux/gpio.h>
26#include <linux/wm97xx_batt.h>
27#include <linux/power_supply.h> 27#include <linux/power_supply.h>
28#include <linux/sysdev.h> 28#include <linux/sysdev.h>
29#include <linux/w1-gpio.h> 29#include <linux/w1-gpio.h>
@@ -45,6 +45,7 @@
45#include <mach/pxa2xx-regs.h> 45#include <mach/pxa2xx-regs.h>
46#include <mach/palmasoc.h> 46#include <mach/palmasoc.h>
47#include <mach/camera.h> 47#include <mach/camera.h>
48#include <mach/palm27x.h>
48 49
49#include <sound/pxa2xx-lib.h> 50#include <sound/pxa2xx-lib.h>
50 51
@@ -159,31 +160,9 @@ static unsigned long centro685_pin_config[] __initdata = {
159#endif /* CONFIG_MACH_CENTRO */ 160#endif /* CONFIG_MACH_CENTRO */
160 161
161/****************************************************************************** 162/******************************************************************************
162 * SD/MMC card controller
163 ******************************************************************************/
164#ifdef CONFIG_MACH_TREO680
165static struct pxamci_platform_data treo680_mci_platform_data = {
166 .ocr_mask = MMC_VDD_32_33 | MMC_VDD_33_34,
167 .gpio_card_detect = GPIO_NR_TREO_SD_DETECT_N,
168 .gpio_card_ro = GPIO_NR_TREO680_SD_READONLY,
169 .gpio_power = GPIO_NR_TREO680_SD_POWER,
170};
171#endif /* CONFIG_MACH_TREO680 */
172
173#ifdef CONFIG_MACH_CENTRO
174static struct pxamci_platform_data centro_mci_platform_data = {
175 .ocr_mask = MMC_VDD_32_33 | MMC_VDD_33_34,
176 .gpio_card_detect = GPIO_NR_TREO_SD_DETECT_N,
177 .gpio_card_ro = -1,
178 .gpio_power = GPIO_NR_CENTRO_SD_POWER,
179 .gpio_power_invert = 1,
180};
181#endif /* CONFIG_MACH_CENTRO */
182
183/******************************************************************************
184 * GPIO keyboard 163 * GPIO keyboard
185 ******************************************************************************/ 164 ******************************************************************************/
186#ifdef CONFIG_MACH_TREO680 165#if defined(CONFIG_KEYBOARD_PXA27x) || defined(CONFIG_KEYBOARD_PXA27x_MODULE)
187static unsigned int treo680_matrix_keys[] = { 166static unsigned int treo680_matrix_keys[] = {
188 KEY(0, 0, KEY_F8), /* Red/Off/Power */ 167 KEY(0, 0, KEY_F8), /* Red/Off/Power */
189 KEY(0, 1, KEY_LEFT), 168 KEY(0, 1, KEY_LEFT),
@@ -243,19 +222,6 @@ static unsigned int treo680_matrix_keys[] = {
243 KEY(7, 5, KEY_I), 222 KEY(7, 5, KEY_I),
244}; 223};
245 224
246static struct pxa27x_keypad_platform_data treo680_keypad_platform_data = {
247 .matrix_key_rows = 8,
248 .matrix_key_cols = 7,
249 .matrix_key_map = treo680_matrix_keys,
250 .matrix_key_map_size = ARRAY_SIZE(treo680_matrix_keys),
251 .direct_key_map = { KEY_CONNECT },
252 .direct_key_num = 1,
253
254 .debounce_interval = 30,
255};
256#endif /* CONFIG_MACH_TREO680 */
257
258#ifdef CONFIG_MACH_CENTRO
259static unsigned int centro_matrix_keys[] = { 225static unsigned int centro_matrix_keys[] = {
260 KEY(0, 0, KEY_F9), /* Home */ 226 KEY(0, 0, KEY_F9), /* Home */
261 KEY(0, 1, KEY_LEFT), 227 KEY(0, 1, KEY_LEFT),
@@ -315,157 +281,50 @@ static unsigned int centro_matrix_keys[] = {
315 KEY(7, 5, KEY_I), 281 KEY(7, 5, KEY_I),
316}; 282};
317 283
318static struct pxa27x_keypad_platform_data centro_keypad_platform_data = { 284static struct pxa27x_keypad_platform_data treo680_keypad_pdata = {
319 .matrix_key_rows = 8, 285 .matrix_key_rows = 8,
320 .matrix_key_cols = 7, 286 .matrix_key_cols = 7,
321 .matrix_key_map = centro_matrix_keys, 287 .matrix_key_map = treo680_matrix_keys,
322 .matrix_key_map_size = ARRAY_SIZE(centro_matrix_keys), 288 .matrix_key_map_size = ARRAY_SIZE(treo680_matrix_keys),
323 .direct_key_map = { KEY_CONNECT }, 289 .direct_key_map = { KEY_CONNECT },
324 .direct_key_num = 1, 290 .direct_key_num = 1,
325 291
326 .debounce_interval = 30, 292 .debounce_interval = 30,
327}; 293};
328#endif /* CONFIG_MACH_CENTRO */
329 294
330/****************************************************************************** 295static void __init palmtreo_kpc_init(void)
331 * aSoC audio
332 ******************************************************************************/
333
334static pxa2xx_audio_ops_t treo_ac97_pdata = {
335 .reset_gpio = 95,
336};
337
338/******************************************************************************
339 * Backlight
340 ******************************************************************************/
341static int treo_backlight_init(struct device *dev)
342{ 296{
343 int ret; 297 static struct pxa27x_keypad_platform_data *data = &treo680_keypad_pdata;
344
345 ret = gpio_request(GPIO_NR_TREO_BL_POWER, "BL POWER");
346 if (ret)
347 goto err;
348 ret = gpio_direction_output(GPIO_NR_TREO_BL_POWER, 0);
349 if (ret)
350 goto err2;
351 298
352 return 0; 299 if (machine_is_centro()) {
353 300 data->matrix_key_map = centro_matrix_keys;
354err2: 301 data->matrix_key_map_size = ARRAY_SIZE(centro_matrix_keys);
355 gpio_free(GPIO_NR_TREO_BL_POWER); 302 }
356err:
357 return ret;
358}
359
360static int treo_backlight_notify(struct device *dev, int brightness)
361{
362 gpio_set_value(GPIO_NR_TREO_BL_POWER, brightness);
363 return TREO_MAX_INTENSITY - brightness;
364};
365 303
366static void treo_backlight_exit(struct device *dev) 304 pxa_set_keypad_info(&treo680_keypad_pdata);
367{
368 gpio_free(GPIO_NR_TREO_BL_POWER);
369} 305}
370 306#else
371static struct platform_pwm_backlight_data treo_backlight_data = { 307static inline void palmtreo_kpc_init(void) {}
372 .pwm_id = 0, 308#endif
373 .max_brightness = TREO_MAX_INTENSITY,
374 .dft_brightness = TREO_DEFAULT_INTENSITY,
375 .pwm_period_ns = TREO_PERIOD_NS,
376 .init = treo_backlight_init,
377 .notify = treo_backlight_notify,
378 .exit = treo_backlight_exit,
379};
380
381static struct platform_device treo_backlight = {
382 .name = "pwm-backlight",
383 .dev = {
384 .parent = &pxa27x_device_pwm0.dev,
385 .platform_data = &treo_backlight_data,
386 },
387};
388
389/******************************************************************************
390 * IrDA
391 ******************************************************************************/
392static struct pxaficp_platform_data treo_ficp_info = {
393 .gpio_pwdown = GPIO_NR_TREO_IR_EN,
394 .transceiver_cap = IR_SIRMODE | IR_OFF,
395};
396
397/******************************************************************************
398 * UDC
399 ******************************************************************************/
400static struct pxa2xx_udc_mach_info treo_udc_info __initdata = {
401 .gpio_vbus = GPIO_NR_TREO_USB_DETECT,
402 .gpio_vbus_inverted = 1,
403 .gpio_pullup = GPIO_NR_TREO_USB_PULLUP,
404};
405
406 309
407/****************************************************************************** 310/******************************************************************************
408 * USB host 311 * USB host
409 ******************************************************************************/ 312 ******************************************************************************/
410#ifdef CONFIG_MACH_TREO680 313#if defined(CONFIG_USB_OHCI_HCD) || defined(CONFIG_USB_OHCI_HCD_MODULE)
411static struct pxaohci_platform_data treo680_ohci_info = { 314static struct pxaohci_platform_data treo680_ohci_info = {
412 .port_mode = PMM_PERPORT_MODE, 315 .port_mode = PMM_PERPORT_MODE,
413 .flags = ENABLE_PORT1 | ENABLE_PORT3, 316 .flags = ENABLE_PORT1 | ENABLE_PORT3,
414 .power_budget = 0, 317 .power_budget = 0,
415}; 318};
416#endif /* CONFIG_MACH_TREO680 */
417
418/******************************************************************************
419 * Power supply
420 ******************************************************************************/
421static int power_supply_init(struct device *dev)
422{
423 int ret;
424
425 ret = gpio_request(GPIO_NR_TREO_POWER_DETECT, "CABLE_STATE_AC");
426 if (ret)
427 goto err1;
428 ret = gpio_direction_input(GPIO_NR_TREO_POWER_DETECT);
429 if (ret)
430 goto err2;
431
432 return 0;
433
434err2:
435 gpio_free(GPIO_NR_TREO_POWER_DETECT);
436err1:
437 return ret;
438}
439
440static int treo_is_ac_online(void)
441{
442 return gpio_get_value(GPIO_NR_TREO_POWER_DETECT);
443}
444 319
445static void power_supply_exit(struct device *dev) 320static void __init palmtreo_uhc_init(void)
446{ 321{
447 gpio_free(GPIO_NR_TREO_POWER_DETECT); 322 if (machine_is_treo680())
323 pxa_set_ohci_info(&treo680_ohci_info);
448} 324}
449 325#else
450static char *treo_supplicants[] = { 326static inline void palmtreo_uhc_init(void) {}
451 "main-battery", 327#endif
452};
453
454static struct pda_power_pdata power_supply_info = {
455 .init = power_supply_init,
456 .is_ac_online = treo_is_ac_online,
457 .exit = power_supply_exit,
458 .supplied_to = treo_supplicants,
459 .num_supplicants = ARRAY_SIZE(treo_supplicants),
460};
461
462static struct platform_device power_supply = {
463 .name = "pda-power",
464 .id = -1,
465 .dev = {
466 .platform_data = &power_supply_info,
467 },
468};
469 328
470/****************************************************************************** 329/******************************************************************************
471 * Vibra and LEDs 330 * Vibra and LEDs
@@ -494,16 +353,6 @@ static struct gpio_led_platform_data treo680_gpio_led_info = {
494 .num_leds = ARRAY_SIZE(treo680_gpio_leds), 353 .num_leds = ARRAY_SIZE(treo680_gpio_leds),
495}; 354};
496 355
497static struct platform_device treo680_leds = {
498 .name = "leds-gpio",
499 .id = -1,
500 .dev = {
501 .platform_data = &treo680_gpio_led_info,
502 }
503};
504#endif /* CONFIG_MACH_TREO680 */
505
506#ifdef CONFIG_MACH_CENTRO
507static struct gpio_led centro_gpio_leds[] = { 356static struct gpio_led centro_gpio_leds[] = {
508 { 357 {
509 .name = "centro:vibra:vibra", 358 .name = "centro:vibra:vibra",
@@ -528,139 +377,67 @@ static struct gpio_led_platform_data centro_gpio_led_info = {
528 .num_leds = ARRAY_SIZE(centro_gpio_leds), 377 .num_leds = ARRAY_SIZE(centro_gpio_leds),
529}; 378};
530 379
531static struct platform_device centro_leds = { 380static struct platform_device palmtreo_leds = {
532 .name = "leds-gpio", 381 .name = "leds-gpio",
533 .id = -1, 382 .id = -1,
534 .dev = { 383 .dev = {
535 .platform_data = &centro_gpio_led_info, 384 .platform_data = &treo680_gpio_led_info,
536 } 385 }
537}; 386};
538#endif /* CONFIG_MACH_CENTRO */
539 387
540/****************************************************************************** 388static void __init palmtreo_leds_init(void)
541 * Framebuffer
542 ******************************************************************************/
543/* TODO: add support for 324x324 */
544static struct pxafb_mode_info treo_lcd_modes[] = {
545{ 389{
546 .pixclock = 86538, 390 if (machine_is_centro())
547 .xres = 320, 391 palmtreo_leds.dev.platform_data = &centro_gpio_led_info;
548 .yres = 320,
549 .bpp = 16,
550
551 .left_margin = 20,
552 .right_margin = 8,
553 .upper_margin = 8,
554 .lower_margin = 5,
555
556 .hsync_len = 4,
557 .vsync_len = 1,
558},
559};
560 392
561static void treo_lcd_power(int on, struct fb_var_screeninfo *info) 393 platform_device_register(&palmtreo_leds);
562{
563 gpio_set_value(GPIO_NR_TREO_BL_POWER, on);
564}
565
566static struct pxafb_mach_info treo_lcd_screen = {
567 .modes = treo_lcd_modes,
568 .num_modes = ARRAY_SIZE(treo_lcd_modes),
569 .lcd_conn = LCD_COLOR_TFT_16BPP | LCD_PCLK_EDGE_FALL,
570};
571
572/******************************************************************************
573 * Power management - standby
574 ******************************************************************************/
575static void __init treo_pm_init(void)
576{
577 static u32 resume[] = {
578 0xe3a00101, /* mov r0, #0x40000000 */
579 0xe380060f, /* orr r0, r0, #0x00f00000 */
580 0xe590f008, /* ldr pc, [r0, #0x08] */
581 };
582
583 /* this is where the bootloader jumps */
584 memcpy(phys_to_virt(TREO_STR_BASE), resume, sizeof(resume));
585} 394}
395#else
396static inline void palmtreo_leds_init(void) {}
397#endif
586 398
587/****************************************************************************** 399/******************************************************************************
588 * Machine init 400 * Machine init
589 ******************************************************************************/ 401 ******************************************************************************/
590static struct platform_device *treo_devices[] __initdata = { 402static void __init treo_reserve(void)
591 &treo_backlight,
592 &power_supply,
593};
594
595#ifdef CONFIG_MACH_TREO680
596static struct platform_device *treo680_devices[] __initdata = {
597 &treo680_leds,
598};
599#endif /* CONFIG_MACH_TREO680 */
600
601#ifdef CONFIG_MACH_CENTRO
602static struct platform_device *centro_devices[] __initdata = {
603 &centro_leds,
604};
605#endif /* CONFIG_MACH_CENTRO */
606
607/* setup udc GPIOs initial state */
608static void __init treo_udc_init(void)
609{ 403{
610 if (!gpio_request(GPIO_NR_TREO_USB_PULLUP, "UDC Vbus")) { 404 memblock_reserve(0xa0000000, 0x1000);
611 gpio_direction_output(GPIO_NR_TREO_USB_PULLUP, 1); 405 memblock_reserve(0xa2000000, 0x1000);
612 gpio_free(GPIO_NR_TREO_USB_PULLUP);
613 }
614} 406}
615 407
616static void __init treo_lcd_power_init(void) 408static void __init palmphone_common_init(void)
617{
618 int ret;
619
620 ret = gpio_request(GPIO_NR_TREO_LCD_POWER, "LCD POWER");
621 if (ret) {
622 pr_err("Treo680: LCD power GPIO request failed!\n");
623 return;
624 }
625
626 ret = gpio_direction_output(GPIO_NR_TREO_LCD_POWER, 0);
627 if (ret) {
628 pr_err("Treo680: setting LCD power GPIO direction failed!\n");
629 gpio_free(GPIO_NR_TREO_LCD_POWER);
630 return;
631 }
632
633 treo_lcd_screen.pxafb_lcd_power = treo_lcd_power;
634}
635
636static void __init treo_init(void)
637{ 409{
410 pxa2xx_mfp_config(ARRAY_AND_SIZE(treo_pin_config));
638 pxa_set_ffuart_info(NULL); 411 pxa_set_ffuart_info(NULL);
639 pxa_set_btuart_info(NULL); 412 pxa_set_btuart_info(NULL);
640 pxa_set_stuart_info(NULL); 413 pxa_set_stuart_info(NULL);
641 414 palm27x_pm_init(TREO_STR_BASE);
642 treo_pm_init(); 415 palm27x_lcd_init(GPIO_NR_TREO_BL_POWER, &palm_320x320_new_lcd_mode);
643 pxa2xx_mfp_config(ARRAY_AND_SIZE(treo_pin_config)); 416 palm27x_udc_init(GPIO_NR_TREO_USB_DETECT, GPIO_NR_TREO_USB_PULLUP, 1);
644 treo_lcd_power_init(); 417 palm27x_irda_init(GPIO_NR_TREO_IR_EN);
645 set_pxa_fb_info(&treo_lcd_screen); 418 palm27x_ac97_init(-1, -1, -1, 95);
646 treo_udc_init(); 419 palm27x_pwm_init(GPIO_NR_TREO_BL_POWER, -1);
647 pxa_set_udc_info(&treo_udc_info); 420 palm27x_power_init(GPIO_NR_TREO_POWER_DETECT, -1);
648 pxa_set_ac97_info(&treo_ac97_pdata); 421 palm27x_pmic_init();
649 pxa_set_ficp_info(&treo_ficp_info); 422 palmtreo_kpc_init();
650 423 palmtreo_uhc_init();
651 platform_add_devices(ARRAY_AND_SIZE(treo_devices)); 424 palmtreo_leds_init();
652} 425}
653 426
654#ifdef CONFIG_MACH_TREO680
655static void __init treo680_init(void) 427static void __init treo680_init(void)
656{ 428{
657 treo_init();
658 pxa2xx_mfp_config(ARRAY_AND_SIZE(treo680_pin_config)); 429 pxa2xx_mfp_config(ARRAY_AND_SIZE(treo680_pin_config));
659 pxa_set_mci_info(&treo680_mci_platform_data); 430 palmphone_common_init();
660 pxa_set_keypad_info(&treo680_keypad_platform_data); 431 palm27x_mmc_init(GPIO_NR_TREO_SD_DETECT_N, GPIO_NR_TREO680_SD_READONLY,
661 pxa_set_ohci_info(&treo680_ohci_info); 432 GPIO_NR_TREO680_SD_POWER, 0);
433}
662 434
663 platform_add_devices(ARRAY_AND_SIZE(treo680_devices)); 435static void __init centro_init(void)
436{
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);
664} 441}
665 442
666MACHINE_START(TREO680, "Palm Treo 680") 443MACHINE_START(TREO680, "Palm Treo 680")
@@ -668,31 +445,19 @@ MACHINE_START(TREO680, "Palm Treo 680")
668 .io_pg_offst = io_p2v(0x40000000), 445 .io_pg_offst = io_p2v(0x40000000),
669 .boot_params = 0xa0000100, 446 .boot_params = 0xa0000100,
670 .map_io = pxa_map_io, 447 .map_io = pxa_map_io,
448 .reserve = treo_reserve,
671 .init_irq = pxa27x_init_irq, 449 .init_irq = pxa27x_init_irq,
672 .timer = &pxa_timer, 450 .timer = &pxa_timer,
673 .init_machine = treo680_init, 451 .init_machine = treo680_init,
674MACHINE_END 452MACHINE_END
675#endif /* CONFIG_MACH_TREO680 */
676
677#ifdef CONFIG_MACH_CENTRO
678static void __init centro_init(void)
679{
680 treo_init();
681 pxa2xx_mfp_config(ARRAY_AND_SIZE(centro685_pin_config));
682 pxa_set_mci_info(&centro_mci_platform_data);
683
684 pxa_set_keypad_info(&centro_keypad_platform_data);
685
686 platform_add_devices(ARRAY_AND_SIZE(centro_devices));
687}
688 453
689MACHINE_START(CENTRO, "Palm Centro 685") 454MACHINE_START(CENTRO, "Palm Centro 685")
690 .phys_io = TREO_PHYS_IO_START, 455 .phys_io = TREO_PHYS_IO_START,
691 .io_pg_offst = io_p2v(0x40000000), 456 .io_pg_offst = io_p2v(0x40000000),
692 .boot_params = 0xa0000100, 457 .boot_params = 0xa0000100,
693 .map_io = pxa_map_io, 458 .map_io = pxa_map_io,
459 .reserve = treo_reserve,
694 .init_irq = pxa27x_init_irq, 460 .init_irq = pxa27x_init_irq,
695 .timer = &pxa_timer, 461 .timer = &pxa_timer,
696 .init_machine = centro_init, 462 .init_machine = centro_init,
697MACHINE_END 463MACHINE_END
698#endif /* CONFIG_MACH_CENTRO */