diff options
Diffstat (limited to 'arch/arm/mach-pxa/magician.c')
| -rw-r--r-- | arch/arm/mach-pxa/magician.c | 84 |
1 files changed, 41 insertions, 43 deletions
diff --git a/arch/arm/mach-pxa/magician.c b/arch/arm/mach-pxa/magician.c index deeea1c2782b..c899bbd94dc0 100644 --- a/arch/arm/mach-pxa/magician.c +++ b/arch/arm/mach-pxa/magician.c | |||
| @@ -25,6 +25,8 @@ | |||
| 25 | #include <linux/mtd/physmap.h> | 25 | #include <linux/mtd/physmap.h> |
| 26 | #include <linux/pda_power.h> | 26 | #include <linux/pda_power.h> |
| 27 | #include <linux/pwm_backlight.h> | 27 | #include <linux/pwm_backlight.h> |
| 28 | #include <linux/regulator/bq24022.h> | ||
| 29 | #include <linux/regulator/machine.h> | ||
| 28 | #include <linux/usb/gpio_vbus.h> | 30 | #include <linux/usb/gpio_vbus.h> |
| 29 | 31 | ||
| 30 | #include <mach/hardware.h> | 32 | #include <mach/hardware.h> |
| @@ -552,33 +554,7 @@ static struct platform_device gpio_vbus = { | |||
| 552 | 554 | ||
| 553 | static int power_supply_init(struct device *dev) | 555 | static int power_supply_init(struct device *dev) |
| 554 | { | 556 | { |
| 555 | int ret; | 557 | return gpio_request(EGPIO_MAGICIAN_CABLE_STATE_AC, "CABLE_STATE_AC"); |
| 556 | |||
| 557 | ret = gpio_request(EGPIO_MAGICIAN_CABLE_STATE_AC, "CABLE_STATE_AC"); | ||
| 558 | if (ret) | ||
| 559 | goto err_cs_ac; | ||
| 560 | ret = gpio_request(EGPIO_MAGICIAN_CABLE_STATE_USB, "CABLE_STATE_USB"); | ||
| 561 | if (ret) | ||
| 562 | goto err_cs_usb; | ||
| 563 | ret = gpio_request(EGPIO_MAGICIAN_CHARGE_EN, "CHARGE_EN"); | ||
| 564 | if (ret) | ||
| 565 | goto err_chg_en; | ||
| 566 | ret = gpio_request(GPIO30_MAGICIAN_nCHARGE_EN, "nCHARGE_EN"); | ||
| 567 | if (!ret) | ||
| 568 | ret = gpio_direction_output(GPIO30_MAGICIAN_nCHARGE_EN, 0); | ||
| 569 | if (ret) | ||
| 570 | goto err_nchg_en; | ||
| 571 | |||
| 572 | return 0; | ||
| 573 | |||
| 574 | err_nchg_en: | ||
| 575 | gpio_free(EGPIO_MAGICIAN_CHARGE_EN); | ||
| 576 | err_chg_en: | ||
| 577 | gpio_free(EGPIO_MAGICIAN_CABLE_STATE_USB); | ||
| 578 | err_cs_usb: | ||
| 579 | gpio_free(EGPIO_MAGICIAN_CABLE_STATE_AC); | ||
| 580 | err_cs_ac: | ||
| 581 | return ret; | ||
| 582 | } | 558 | } |
| 583 | 559 | ||
| 584 | static int magician_is_ac_online(void) | 560 | static int magician_is_ac_online(void) |
| @@ -586,22 +562,8 @@ static int magician_is_ac_online(void) | |||
| 586 | return gpio_get_value(EGPIO_MAGICIAN_CABLE_STATE_AC); | 562 | return gpio_get_value(EGPIO_MAGICIAN_CABLE_STATE_AC); |
| 587 | } | 563 | } |
| 588 | 564 | ||
| 589 | static int magician_is_usb_online(void) | ||
| 590 | { | ||
| 591 | return gpio_get_value(EGPIO_MAGICIAN_CABLE_STATE_USB); | ||
| 592 | } | ||
| 593 | |||
| 594 | static void magician_set_charge(int flags) | ||
| 595 | { | ||
| 596 | gpio_set_value(GPIO30_MAGICIAN_nCHARGE_EN, !flags); | ||
| 597 | gpio_set_value(EGPIO_MAGICIAN_CHARGE_EN, flags); | ||
| 598 | } | ||
| 599 | |||
| 600 | static void power_supply_exit(struct device *dev) | 565 | static void power_supply_exit(struct device *dev) |
| 601 | { | 566 | { |
| 602 | gpio_free(GPIO30_MAGICIAN_nCHARGE_EN); | ||
| 603 | gpio_free(EGPIO_MAGICIAN_CHARGE_EN); | ||
| 604 | gpio_free(EGPIO_MAGICIAN_CABLE_STATE_USB); | ||
| 605 | gpio_free(EGPIO_MAGICIAN_CABLE_STATE_AC); | 567 | gpio_free(EGPIO_MAGICIAN_CABLE_STATE_AC); |
| 606 | } | 568 | } |
| 607 | 569 | ||
| @@ -612,8 +574,6 @@ static char *magician_supplicants[] = { | |||
| 612 | static struct pda_power_pdata power_supply_info = { | 574 | static struct pda_power_pdata power_supply_info = { |
| 613 | .init = power_supply_init, | 575 | .init = power_supply_init, |
| 614 | .is_ac_online = magician_is_ac_online, | 576 | .is_ac_online = magician_is_ac_online, |
| 615 | .is_usb_online = magician_is_usb_online, | ||
| 616 | .set_charge = magician_set_charge, | ||
| 617 | .exit = power_supply_exit, | 577 | .exit = power_supply_exit, |
| 618 | .supplied_to = magician_supplicants, | 578 | .supplied_to = magician_supplicants, |
| 619 | .num_supplicants = ARRAY_SIZE(magician_supplicants), | 579 | .num_supplicants = ARRAY_SIZE(magician_supplicants), |
| @@ -646,6 +606,43 @@ static struct platform_device power_supply = { | |||
| 646 | .num_resources = ARRAY_SIZE(power_supply_resources), | 606 | .num_resources = ARRAY_SIZE(power_supply_resources), |
| 647 | }; | 607 | }; |
| 648 | 608 | ||
| 609 | /* | ||
| 610 | * Battery charger | ||
| 611 | */ | ||
| 612 | |||
| 613 | static struct regulator_consumer_supply bq24022_consumers[] = { | ||
| 614 | { | ||
| 615 | .dev = &gpio_vbus.dev, | ||
| 616 | .supply = "vbus_draw", | ||
| 617 | }, | ||
| 618 | { | ||
| 619 | .dev = &power_supply.dev, | ||
| 620 | .supply = "ac_draw", | ||
| 621 | }, | ||
| 622 | }; | ||
| 623 | |||
| 624 | static struct regulator_init_data bq24022_init_data = { | ||
| 625 | .constraints = { | ||
| 626 | .max_uA = 500000, | ||
| 627 | .valid_ops_mask = REGULATOR_CHANGE_CURRENT, | ||
| 628 | }, | ||
| 629 | .num_consumer_supplies = ARRAY_SIZE(bq24022_consumers), | ||
| 630 | .consumer_supplies = bq24022_consumers, | ||
| 631 | }; | ||
| 632 | |||
| 633 | static struct bq24022_mach_info bq24022_info = { | ||
| 634 | .gpio_nce = GPIO30_MAGICIAN_BQ24022_nCHARGE_EN, | ||
| 635 | .gpio_iset2 = EGPIO_MAGICIAN_BQ24022_ISET2, | ||
| 636 | .init_data = &bq24022_init_data, | ||
| 637 | }; | ||
| 638 | |||
| 639 | static struct platform_device bq24022 = { | ||
| 640 | .name = "bq24022", | ||
| 641 | .id = -1, | ||
| 642 | .dev = { | ||
| 643 | .platform_data = &bq24022_info, | ||
| 644 | }, | ||
| 645 | }; | ||
| 649 | 646 | ||
| 650 | /* | 647 | /* |
| 651 | * MMC/SD | 648 | * MMC/SD |
| @@ -756,6 +753,7 @@ static struct platform_device *devices[] __initdata = { | |||
| 756 | &egpio, | 753 | &egpio, |
| 757 | &backlight, | 754 | &backlight, |
| 758 | &pasic3, | 755 | &pasic3, |
| 756 | &bq24022, | ||
| 759 | &gpio_vbus, | 757 | &gpio_vbus, |
| 760 | &power_supply, | 758 | &power_supply, |
| 761 | &strataflash, | 759 | &strataflash, |
