aboutsummaryrefslogtreecommitdiffstats
path: root/arch/arm
diff options
context:
space:
mode:
authorPhilipp Zabel <philipp.zabel@gmail.com>2009-01-31 06:13:57 -0500
committerEric Miao <eric.miao@marvell.com>2009-04-03 20:24:38 -0400
commiteb650b9ed0f69be075a5a86ef9c4fc2cf7915293 (patch)
treee616530198070f60581f093b64543e062b7981f4 /arch/arm
parent20bec8ab1458c24bed0d5492ee15d87807fc415a (diff)
[ARM] pxa/magician: Enable bq24022 regulator for gpio_vbus and pda_power
With this patch, the bq24022 battery charger is controlled by the USB gadget framework (via gpio_vbus) when connected to USB. To compile, this patch depends on the "regulator: Allow init data to be supplied for bq24022" patch (queued for next in the regulator tree) to add the init_data field to struct bq24022_mach_info. It also depends on the "add optional OTG transceiver and voltage regulator support to pda_power" patch (queued for next in the power supply tree) to enable charging when connected to the AC charger. Signed-off-by: Philipp Zabel <philipp.zabel@gmail.com> Signed-off-by: Eric Miao <eric.miao@marvell.com>
Diffstat (limited to 'arch/arm')
-rw-r--r--arch/arm/configs/magician_defconfig6
-rw-r--r--arch/arm/mach-pxa/include/mach/magician.h4
-rw-r--r--arch/arm/mach-pxa/magician.c84
3 files changed, 48 insertions, 46 deletions
diff --git a/arch/arm/configs/magician_defconfig b/arch/arm/configs/magician_defconfig
index 82428c2f234..f56837f69ca 100644
--- a/arch/arm/configs/magician_defconfig
+++ b/arch/arm/configs/magician_defconfig
@@ -1183,7 +1183,11 @@ CONFIG_RTC_INTF_DEV=y
1183CONFIG_RTC_DRV_SA1100=y 1183CONFIG_RTC_DRV_SA1100=y
1184# CONFIG_RTC_DRV_PXA is not set 1184# CONFIG_RTC_DRV_PXA is not set
1185# CONFIG_DMADEVICES is not set 1185# CONFIG_DMADEVICES is not set
1186# CONFIG_REGULATOR is not set 1186CONFIG_REGULATOR=y
1187# CONFIG_REGULATOR_DEBUG is not set
1188# CONFIG_REGULATOR_FIXED_VOLTAGE is not set
1189# CONFIG_REGULATOR_VIRTUAL_CONSUMER is not set
1190CONFIG_REGULATOR_BQ24022=y
1187# CONFIG_UIO is not set 1191# CONFIG_UIO is not set
1188# CONFIG_STAGING is not set 1192# CONFIG_STAGING is not set
1189 1193
diff --git a/arch/arm/mach-pxa/include/mach/magician.h b/arch/arm/mach-pxa/include/mach/magician.h
index 82a399f3f9f..20ef37d4a9a 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 d46b36746be..2f753874f6b 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,