diff options
| -rw-r--r-- | arch/arm/mach-davinci/board-da850-evm.c | 187 |
1 files changed, 187 insertions, 0 deletions
diff --git a/arch/arm/mach-davinci/board-da850-evm.c b/arch/arm/mach-davinci/board-da850-evm.c index f9969dead63b..2139ce8606cf 100644 --- a/arch/arm/mach-davinci/board-da850-evm.c +++ b/arch/arm/mach-davinci/board-da850-evm.c | |||
| @@ -430,6 +430,182 @@ static int da850_evm_ui_expander_teardown(struct i2c_client *client, | |||
| 430 | return 0; | 430 | return 0; |
| 431 | } | 431 | } |
| 432 | 432 | ||
| 433 | /* assign the baseboard expander's GPIOs after the UI board's */ | ||
| 434 | #define DA850_UI_EXPANDER_N_GPIOS ARRAY_SIZE(da850_evm_ui_exp) | ||
| 435 | #define DA850_BB_EXPANDER_GPIO_BASE (DAVINCI_N_GPIO + DA850_UI_EXPANDER_N_GPIOS) | ||
| 436 | |||
| 437 | enum da850_evm_bb_exp_pins { | ||
| 438 | DA850_EVM_BB_EXP_DEEP_SLEEP_EN = 0, | ||
| 439 | DA850_EVM_BB_EXP_SW_RST, | ||
| 440 | DA850_EVM_BB_EXP_TP_23, | ||
| 441 | DA850_EVM_BB_EXP_TP_22, | ||
| 442 | DA850_EVM_BB_EXP_TP_21, | ||
| 443 | DA850_EVM_BB_EXP_USER_PB1, | ||
| 444 | DA850_EVM_BB_EXP_USER_LED2, | ||
| 445 | DA850_EVM_BB_EXP_USER_LED1, | ||
| 446 | DA850_EVM_BB_EXP_USER_SW1, | ||
| 447 | DA850_EVM_BB_EXP_USER_SW2, | ||
| 448 | DA850_EVM_BB_EXP_USER_SW3, | ||
| 449 | DA850_EVM_BB_EXP_USER_SW4, | ||
| 450 | DA850_EVM_BB_EXP_USER_SW5, | ||
| 451 | DA850_EVM_BB_EXP_USER_SW6, | ||
| 452 | DA850_EVM_BB_EXP_USER_SW7, | ||
| 453 | DA850_EVM_BB_EXP_USER_SW8 | ||
| 454 | }; | ||
| 455 | |||
| 456 | static const char const *da850_evm_bb_exp[] = { | ||
| 457 | [DA850_EVM_BB_EXP_DEEP_SLEEP_EN] = "deep_sleep_en", | ||
| 458 | [DA850_EVM_BB_EXP_SW_RST] = "sw_rst", | ||
| 459 | [DA850_EVM_BB_EXP_TP_23] = "tp_23", | ||
| 460 | [DA850_EVM_BB_EXP_TP_22] = "tp_22", | ||
| 461 | [DA850_EVM_BB_EXP_TP_21] = "tp_21", | ||
| 462 | [DA850_EVM_BB_EXP_USER_PB1] = "user_pb1", | ||
| 463 | [DA850_EVM_BB_EXP_USER_LED2] = "user_led2", | ||
| 464 | [DA850_EVM_BB_EXP_USER_LED1] = "user_led1", | ||
| 465 | [DA850_EVM_BB_EXP_USER_SW1] = "user_sw1", | ||
| 466 | [DA850_EVM_BB_EXP_USER_SW2] = "user_sw2", | ||
| 467 | [DA850_EVM_BB_EXP_USER_SW3] = "user_sw3", | ||
| 468 | [DA850_EVM_BB_EXP_USER_SW4] = "user_sw4", | ||
| 469 | [DA850_EVM_BB_EXP_USER_SW5] = "user_sw5", | ||
| 470 | [DA850_EVM_BB_EXP_USER_SW6] = "user_sw6", | ||
| 471 | [DA850_EVM_BB_EXP_USER_SW7] = "user_sw7", | ||
| 472 | [DA850_EVM_BB_EXP_USER_SW8] = "user_sw8", | ||
| 473 | }; | ||
| 474 | |||
| 475 | #define DA850_N_BB_USER_SW 8 | ||
| 476 | |||
| 477 | static struct gpio_keys_button da850_evm_bb_keys[] = { | ||
| 478 | [0] = { | ||
| 479 | .type = EV_KEY, | ||
| 480 | .active_low = 1, | ||
| 481 | .wakeup = 0, | ||
| 482 | .debounce_interval = DA850_KEYS_DEBOUNCE_MS, | ||
| 483 | .code = KEY_PROG1, | ||
| 484 | .desc = NULL, /* assigned at runtime */ | ||
| 485 | .gpio = -1, /* assigned at runtime */ | ||
| 486 | }, | ||
| 487 | [1 ... DA850_N_BB_USER_SW] = { | ||
| 488 | .type = EV_SW, | ||
| 489 | .active_low = 1, | ||
| 490 | .wakeup = 0, | ||
| 491 | .debounce_interval = DA850_KEYS_DEBOUNCE_MS, | ||
| 492 | .code = -1, /* assigned at runtime */ | ||
| 493 | .desc = NULL, /* assigned at runtime */ | ||
| 494 | .gpio = -1, /* assigned at runtime */ | ||
| 495 | }, | ||
| 496 | }; | ||
| 497 | |||
| 498 | static struct gpio_keys_platform_data da850_evm_bb_keys_pdata = { | ||
| 499 | .buttons = da850_evm_bb_keys, | ||
| 500 | .nbuttons = ARRAY_SIZE(da850_evm_bb_keys), | ||
| 501 | .poll_interval = DA850_GPIO_KEYS_POLL_MS, | ||
| 502 | }; | ||
| 503 | |||
| 504 | static struct platform_device da850_evm_bb_keys_device = { | ||
| 505 | .name = "gpio-keys-polled", | ||
| 506 | .id = 1, | ||
| 507 | .dev = { | ||
| 508 | .platform_data = &da850_evm_bb_keys_pdata | ||
| 509 | }, | ||
| 510 | }; | ||
| 511 | |||
| 512 | static void da850_evm_bb_keys_init(unsigned gpio) | ||
| 513 | { | ||
| 514 | int i; | ||
| 515 | struct gpio_keys_button *button; | ||
| 516 | |||
| 517 | button = &da850_evm_bb_keys[0]; | ||
| 518 | button->desc = (char *) | ||
| 519 | da850_evm_bb_exp[DA850_EVM_BB_EXP_USER_PB1]; | ||
| 520 | button->gpio = gpio + DA850_EVM_BB_EXP_USER_PB1; | ||
| 521 | |||
| 522 | for (i = 0; i < DA850_N_BB_USER_SW; i++) { | ||
| 523 | button = &da850_evm_bb_keys[i + 1]; | ||
| 524 | button->code = SW_LID + i; | ||
| 525 | button->desc = (char *) | ||
| 526 | da850_evm_bb_exp[DA850_EVM_BB_EXP_USER_SW1 + i]; | ||
| 527 | button->gpio = gpio + DA850_EVM_BB_EXP_USER_SW1 + i; | ||
| 528 | } | ||
| 529 | } | ||
| 530 | |||
| 531 | #define DA850_N_BB_USER_LED 2 | ||
| 532 | |||
| 533 | static struct gpio_led da850_evm_bb_leds[] = { | ||
| 534 | [0 ... DA850_N_BB_USER_LED - 1] = { | ||
| 535 | .active_low = 1, | ||
| 536 | .gpio = -1, /* assigned at runtime */ | ||
| 537 | .name = NULL, /* assigned at runtime */ | ||
| 538 | }, | ||
| 539 | }; | ||
| 540 | |||
| 541 | static struct gpio_led_platform_data da850_evm_bb_leds_pdata = { | ||
| 542 | .leds = da850_evm_bb_leds, | ||
| 543 | .num_leds = ARRAY_SIZE(da850_evm_bb_leds), | ||
| 544 | }; | ||
| 545 | |||
| 546 | static struct platform_device da850_evm_bb_leds_device = { | ||
| 547 | .name = "leds-gpio", | ||
| 548 | .id = -1, | ||
| 549 | .dev = { | ||
| 550 | .platform_data = &da850_evm_bb_leds_pdata | ||
| 551 | } | ||
| 552 | }; | ||
| 553 | |||
| 554 | static void da850_evm_bb_leds_init(unsigned gpio) | ||
| 555 | { | ||
| 556 | int i; | ||
| 557 | struct gpio_led *led; | ||
| 558 | |||
| 559 | for (i = 0; i < DA850_N_BB_USER_LED; i++) { | ||
| 560 | led = &da850_evm_bb_leds[i]; | ||
| 561 | |||
| 562 | led->gpio = gpio + DA850_EVM_BB_EXP_USER_LED2 + i; | ||
| 563 | led->name = | ||
| 564 | da850_evm_bb_exp[DA850_EVM_BB_EXP_USER_LED2 + i]; | ||
| 565 | } | ||
| 566 | } | ||
| 567 | |||
| 568 | static int da850_evm_bb_expander_setup(struct i2c_client *client, | ||
| 569 | unsigned gpio, unsigned ngpio, | ||
| 570 | void *c) | ||
| 571 | { | ||
| 572 | int ret; | ||
| 573 | |||
| 574 | /* | ||
| 575 | * Register the switches and pushbutton on the baseboard as a gpio-keys | ||
| 576 | * device. | ||
| 577 | */ | ||
| 578 | da850_evm_bb_keys_init(gpio); | ||
| 579 | ret = platform_device_register(&da850_evm_bb_keys_device); | ||
| 580 | if (ret) { | ||
| 581 | pr_warning("Could not register baseboard GPIO expander keys"); | ||
| 582 | goto io_exp_setup_sw_fail; | ||
| 583 | } | ||
| 584 | |||
| 585 | da850_evm_bb_leds_init(gpio); | ||
| 586 | ret = platform_device_register(&da850_evm_bb_leds_device); | ||
| 587 | if (ret) { | ||
| 588 | pr_warning("Could not register baseboard GPIO expander LEDS"); | ||
| 589 | goto io_exp_setup_leds_fail; | ||
| 590 | } | ||
| 591 | |||
| 592 | return 0; | ||
| 593 | |||
| 594 | io_exp_setup_leds_fail: | ||
| 595 | platform_device_unregister(&da850_evm_bb_keys_device); | ||
| 596 | io_exp_setup_sw_fail: | ||
| 597 | return ret; | ||
| 598 | } | ||
| 599 | |||
| 600 | static int da850_evm_bb_expander_teardown(struct i2c_client *client, | ||
| 601 | unsigned gpio, unsigned ngpio, void *c) | ||
| 602 | { | ||
| 603 | platform_device_unregister(&da850_evm_bb_leds_device); | ||
| 604 | platform_device_unregister(&da850_evm_bb_keys_device); | ||
| 605 | |||
| 606 | return 0; | ||
| 607 | } | ||
| 608 | |||
| 433 | static struct pca953x_platform_data da850_evm_ui_expander_info = { | 609 | static struct pca953x_platform_data da850_evm_ui_expander_info = { |
| 434 | .gpio_base = DAVINCI_N_GPIO, | 610 | .gpio_base = DAVINCI_N_GPIO, |
| 435 | .setup = da850_evm_ui_expander_setup, | 611 | .setup = da850_evm_ui_expander_setup, |
| @@ -437,6 +613,13 @@ static struct pca953x_platform_data da850_evm_ui_expander_info = { | |||
| 437 | .names = da850_evm_ui_exp, | 613 | .names = da850_evm_ui_exp, |
| 438 | }; | 614 | }; |
| 439 | 615 | ||
| 616 | static struct pca953x_platform_data da850_evm_bb_expander_info = { | ||
| 617 | .gpio_base = DA850_BB_EXPANDER_GPIO_BASE, | ||
| 618 | .setup = da850_evm_bb_expander_setup, | ||
| 619 | .teardown = da850_evm_bb_expander_teardown, | ||
| 620 | .names = da850_evm_bb_exp, | ||
| 621 | }; | ||
| 622 | |||
| 440 | static struct i2c_board_info __initdata da850_evm_i2c_devices[] = { | 623 | static struct i2c_board_info __initdata da850_evm_i2c_devices[] = { |
| 441 | { | 624 | { |
| 442 | I2C_BOARD_INFO("tlv320aic3x", 0x18), | 625 | I2C_BOARD_INFO("tlv320aic3x", 0x18), |
| @@ -445,6 +628,10 @@ static struct i2c_board_info __initdata da850_evm_i2c_devices[] = { | |||
| 445 | I2C_BOARD_INFO("tca6416", 0x20), | 628 | I2C_BOARD_INFO("tca6416", 0x20), |
| 446 | .platform_data = &da850_evm_ui_expander_info, | 629 | .platform_data = &da850_evm_ui_expander_info, |
| 447 | }, | 630 | }, |
| 631 | { | ||
| 632 | I2C_BOARD_INFO("tca6416", 0x21), | ||
| 633 | .platform_data = &da850_evm_bb_expander_info, | ||
| 634 | }, | ||
| 448 | }; | 635 | }; |
| 449 | 636 | ||
| 450 | static struct davinci_i2c_platform_data da850_evm_i2c_0_pdata = { | 637 | static struct davinci_i2c_platform_data da850_evm_i2c_0_pdata = { |
