aboutsummaryrefslogtreecommitdiffstats
path: root/arch/arm/mach-pxa
diff options
context:
space:
mode:
Diffstat (limited to 'arch/arm/mach-pxa')
-rw-r--r--arch/arm/mach-pxa/include/mach/magician.h4
-rw-r--r--arch/arm/mach-pxa/magician.c84
2 files changed, 43 insertions, 45 deletions
diff --git a/arch/arm/mach-pxa/include/mach/magician.h b/arch/arm/mach-pxa/include/mach/magician.h
index 82a399f3f9f2..20ef37d4a9a7 100644
--- a/arch/arm/mach-pxa/include/mach/magician.h
+++ b/arch/arm/mach-pxa/include/mach/magician.h
@@ -27,7 +27,7 @@
27#define GPIO22_MAGICIAN_VIBRA_EN 22 27#define GPIO22_MAGICIAN_VIBRA_EN 22
28#define GPIO26_MAGICIAN_GSM_POWER 26 28#define GPIO26_MAGICIAN_GSM_POWER 26
29#define GPIO27_MAGICIAN_USBC_PUEN 27 29#define GPIO27_MAGICIAN_USBC_PUEN 27
30#define GPIO30_MAGICIAN_nCHARGE_EN 30 30#define GPIO30_MAGICIAN_BQ24022_nCHARGE_EN 30
31#define GPIO37_MAGICIAN_KEY_HANGUP 37 31#define GPIO37_MAGICIAN_KEY_HANGUP 37
32#define GPIO38_MAGICIAN_KEY_CONTACTS 38 32#define GPIO38_MAGICIAN_KEY_CONTACTS 38
33#define GPIO40_MAGICIAN_GSM_OUT2 40 33#define GPIO40_MAGICIAN_GSM_OUT2 40
@@ -98,7 +98,7 @@
98#define EGPIO_MAGICIAN_UNKNOWN_WAVEDEV_DLL MAGICIAN_EGPIO(2, 2) 98#define EGPIO_MAGICIAN_UNKNOWN_WAVEDEV_DLL MAGICIAN_EGPIO(2, 2)
99#define EGPIO_MAGICIAN_FLASH_VPP MAGICIAN_EGPIO(2, 3) 99#define EGPIO_MAGICIAN_FLASH_VPP MAGICIAN_EGPIO(2, 3)
100#define EGPIO_MAGICIAN_BL_POWER2 MAGICIAN_EGPIO(2, 4) 100#define EGPIO_MAGICIAN_BL_POWER2 MAGICIAN_EGPIO(2, 4)
101#define EGPIO_MAGICIAN_CHARGE_EN MAGICIAN_EGPIO(2, 5) 101#define EGPIO_MAGICIAN_BQ24022_ISET2 MAGICIAN_EGPIO(2, 5)
102#define EGPIO_MAGICIAN_GSM_POWER MAGICIAN_EGPIO(2, 7) 102#define EGPIO_MAGICIAN_GSM_POWER MAGICIAN_EGPIO(2, 7)
103 103
104/* input */ 104/* input */
diff --git a/arch/arm/mach-pxa/magician.c b/arch/arm/mach-pxa/magician.c
index d46b36746be2..2f753874f6be 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>
@@ -553,33 +555,7 @@ static struct platform_device gpio_vbus = {
553 555
554static int power_supply_init(struct device *dev) 556static int power_supply_init(struct device *dev)
555{ 557{
556 int ret; 558 return gpio_request(EGPIO_MAGICIAN_CABLE_STATE_AC, "CABLE_STATE_AC");
557
558 ret = gpio_request(EGPIO_MAGICIAN_CABLE_STATE_AC, "CABLE_STATE_AC");
559 if (ret)
560 goto err_cs_ac;
561 ret = gpio_request(EGPIO_MAGICIAN_CABLE_STATE_USB, "CABLE_STATE_USB");
562 if (ret)
563 goto err_cs_usb;
564 ret = gpio_request(EGPIO_MAGICIAN_CHARGE_EN, "CHARGE_EN");
565 if (ret)
566 goto err_chg_en;
567 ret = gpio_request(GPIO30_MAGICIAN_nCHARGE_EN, "nCHARGE_EN");
568 if (!ret)
569 ret = gpio_direction_output(GPIO30_MAGICIAN_nCHARGE_EN, 0);
570 if (ret)
571 goto err_nchg_en;
572
573 return 0;
574
575err_nchg_en:
576 gpio_free(EGPIO_MAGICIAN_CHARGE_EN);
577err_chg_en:
578 gpio_free(EGPIO_MAGICIAN_CABLE_STATE_USB);
579err_cs_usb:
580 gpio_free(EGPIO_MAGICIAN_CABLE_STATE_AC);
581err_cs_ac:
582 return ret;
583} 559}
584 560
585static int magician_is_ac_online(void) 561static int magician_is_ac_online(void)
@@ -587,22 +563,8 @@ static int magician_is_ac_online(void)
587 return gpio_get_value(EGPIO_MAGICIAN_CABLE_STATE_AC); 563 return gpio_get_value(EGPIO_MAGICIAN_CABLE_STATE_AC);
588} 564}
589 565
590static int magician_is_usb_online(void)
591{
592 return gpio_get_value(EGPIO_MAGICIAN_CABLE_STATE_USB);
593}
594
595static void magician_set_charge(int flags)
596{
597 gpio_set_value(GPIO30_MAGICIAN_nCHARGE_EN, !flags);
598 gpio_set_value(EGPIO_MAGICIAN_CHARGE_EN, flags);
599}
600
601static void power_supply_exit(struct device *dev) 566static void power_supply_exit(struct device *dev)
602{ 567{
603 gpio_free(GPIO30_MAGICIAN_nCHARGE_EN);
604 gpio_free(EGPIO_MAGICIAN_CHARGE_EN);
605 gpio_free(EGPIO_MAGICIAN_CABLE_STATE_USB);
606 gpio_free(EGPIO_MAGICIAN_CABLE_STATE_AC); 568 gpio_free(EGPIO_MAGICIAN_CABLE_STATE_AC);
607} 569}
608 570
@@ -613,8 +575,6 @@ static char *magician_supplicants[] = {
613static struct pda_power_pdata power_supply_info = { 575static struct pda_power_pdata power_supply_info = {
614 .init = power_supply_init, 576 .init = power_supply_init,
615 .is_ac_online = magician_is_ac_online, 577 .is_ac_online = magician_is_ac_online,
616 .is_usb_online = magician_is_usb_online,
617 .set_charge = magician_set_charge,
618 .exit = power_supply_exit, 578 .exit = power_supply_exit,
619 .supplied_to = magician_supplicants, 579 .supplied_to = magician_supplicants,
620 .num_supplicants = ARRAY_SIZE(magician_supplicants), 580 .num_supplicants = ARRAY_SIZE(magician_supplicants),
@@ -647,6 +607,43 @@ static struct platform_device power_supply = {
647 .num_resources = ARRAY_SIZE(power_supply_resources), 607 .num_resources = ARRAY_SIZE(power_supply_resources),
648}; 608};
649 609
610/*
611 * Battery charger
612 */
613
614static struct regulator_consumer_supply bq24022_consumers[] = {
615 {
616 .dev = &gpio_vbus.dev,
617 .supply = "vbus_draw",
618 },
619 {
620 .dev = &power_supply.dev,
621 .supply = "ac_draw",
622 },
623};
624
625static struct regulator_init_data bq24022_init_data = {
626 .constraints = {
627 .max_uA = 500000,
628 .valid_ops_mask = REGULATOR_CHANGE_CURRENT,
629 },
630 .num_consumer_supplies = ARRAY_SIZE(bq24022_consumers),
631 .consumer_supplies = bq24022_consumers,
632};
633
634static struct bq24022_mach_info bq24022_info = {
635 .gpio_nce = GPIO30_MAGICIAN_BQ24022_nCHARGE_EN,
636 .gpio_iset2 = EGPIO_MAGICIAN_BQ24022_ISET2,
637 .init_data = &bq24022_init_data,
638};
639
640static struct platform_device bq24022 = {
641 .name = "bq24022",
642 .id = -1,
643 .dev = {
644 .platform_data = &bq24022_info,
645 },
646};
650 647
651/* 648/*
652 * MMC/SD 649 * MMC/SD
@@ -757,6 +754,7 @@ static struct platform_device *devices[] __initdata = {
757 &egpio, 754 &egpio,
758 &backlight, 755 &backlight,
759 &pasic3, 756 &pasic3,
757 &bq24022,
760 &gpio_vbus, 758 &gpio_vbus,
761 &power_supply, 759 &power_supply,
762 &strataflash, 760 &strataflash,