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