pm2301: Provide u9540 support for the pm2301 charger
AC charger driver for the DB9540 based platforms. Signed-off-by: Rajkumar Kasirajan <rajkumar.kasirajan@stericsson.com> Signed-off-by: Loic Pallardy <loic.pallardy@stericsson.com> Signed-off-by: Lee Jones <lee.jones@linaro.org> Reviewed-by: Michel JAOUEN <michel.jaouen@stericsson.com> Tested-by: Michel JAOUEN <michel.jaouen@stericsson.com>
This commit is contained in:
parent
8fd526fd18
commit
01ec8c5423
7 changed files with 1550 additions and 13 deletions
|
@ -346,6 +346,13 @@ config AB8500_BM
|
|||
help
|
||||
Say Y to include support for AB8500 battery management.
|
||||
|
||||
config CHARGER_PM2301
|
||||
bool "PM2301 Battery Charger Driver"
|
||||
depends on AB8500_BM
|
||||
help
|
||||
Say Y to include support for PM2301 charger driver.
|
||||
Depends on AB8500 battery management core.
|
||||
|
||||
source "drivers/power/reset/Kconfig"
|
||||
|
||||
endif # POWER_SUPPLY
|
||||
|
|
|
@ -46,6 +46,7 @@ obj-$(CONFIG_CHARGER_LP8727) += lp8727_charger.o
|
|||
obj-$(CONFIG_CHARGER_LP8788) += lp8788-charger.o
|
||||
obj-$(CONFIG_CHARGER_GPIO) += gpio-charger.o
|
||||
obj-$(CONFIG_CHARGER_MANAGER) += charger-manager.o
|
||||
obj-$(CONFIG_CHARGER_PM2301) += pm2301_charger.o
|
||||
obj-$(CONFIG_CHARGER_MAX8997) += max8997_charger.o
|
||||
obj-$(CONFIG_CHARGER_MAX8998) += max8998_charger.o
|
||||
obj-$(CONFIG_CHARGER_BQ2415X) += bq2415x_charger.o
|
||||
|
|
|
@ -2830,8 +2830,11 @@ static int ab8500_charger_remove(struct platform_device *pdev)
|
|||
destroy_workqueue(di->charger_wq);
|
||||
|
||||
flush_scheduled_work();
|
||||
power_supply_unregister(&di->usb_chg.psy);
|
||||
power_supply_unregister(&di->ac_chg.psy);
|
||||
if(di->usb_chg.enabled)
|
||||
power_supply_unregister(&di->usb_chg.psy);
|
||||
if(di->ac_chg.enabled)
|
||||
power_supply_unregister(&di->ac_chg.psy);
|
||||
|
||||
platform_set_drvdata(pdev, NULL);
|
||||
|
||||
return 0;
|
||||
|
@ -2899,6 +2902,7 @@ static int ab8500_charger_probe(struct platform_device *pdev)
|
|||
ARRAY_SIZE(ab8500_charger_voltage_map) - 1];
|
||||
di->ac_chg.max_out_curr = ab8500_charger_current_map[
|
||||
ARRAY_SIZE(ab8500_charger_current_map) - 1];
|
||||
di->ac_chg.enabled = di->pdata->ac_enabled;
|
||||
|
||||
/* USB supply */
|
||||
/* power_supply base class */
|
||||
|
@ -2917,7 +2921,7 @@ static int ab8500_charger_probe(struct platform_device *pdev)
|
|||
ARRAY_SIZE(ab8500_charger_voltage_map) - 1];
|
||||
di->usb_chg.max_out_curr = ab8500_charger_current_map[
|
||||
ARRAY_SIZE(ab8500_charger_current_map) - 1];
|
||||
|
||||
di->usb_chg.enabled = di->pdata->usb_enabled;
|
||||
|
||||
/* Create a work queue for the charger */
|
||||
di->charger_wq =
|
||||
|
@ -2995,17 +2999,21 @@ static int ab8500_charger_probe(struct platform_device *pdev)
|
|||
}
|
||||
|
||||
/* Register AC charger class */
|
||||
ret = power_supply_register(di->dev, &di->ac_chg.psy);
|
||||
if (ret) {
|
||||
dev_err(di->dev, "failed to register AC charger\n");
|
||||
goto free_charger_wq;
|
||||
if(di->ac_chg.enabled) {
|
||||
ret = power_supply_register(di->dev, &di->ac_chg.psy);
|
||||
if (ret) {
|
||||
dev_err(di->dev, "failed to register AC charger\n");
|
||||
goto free_charger_wq;
|
||||
}
|
||||
}
|
||||
|
||||
/* Register USB charger class */
|
||||
ret = power_supply_register(di->dev, &di->usb_chg.psy);
|
||||
if (ret) {
|
||||
dev_err(di->dev, "failed to register USB charger\n");
|
||||
goto free_ac;
|
||||
if(di->usb_chg.enabled) {
|
||||
ret = power_supply_register(di->dev, &di->usb_chg.psy);
|
||||
if (ret) {
|
||||
dev_err(di->dev, "failed to register USB charger\n");
|
||||
goto free_ac;
|
||||
}
|
||||
}
|
||||
|
||||
di->usb_phy = usb_get_phy(USB_PHY_TYPE_USB2);
|
||||
|
@ -3085,9 +3093,11 @@ free_irq:
|
|||
put_usb_phy:
|
||||
usb_put_phy(di->usb_phy);
|
||||
free_usb:
|
||||
power_supply_unregister(&di->usb_chg.psy);
|
||||
if(di->usb_chg.enabled)
|
||||
power_supply_unregister(&di->usb_chg.psy);
|
||||
free_ac:
|
||||
power_supply_unregister(&di->ac_chg.psy);
|
||||
if(di->ac_chg.enabled)
|
||||
power_supply_unregister(&di->ac_chg.psy);
|
||||
free_charger_wq:
|
||||
destroy_workqueue(di->charger_wq);
|
||||
return ret;
|
||||
|
|
1455
drivers/power/pm2301_charger.c
Normal file
1455
drivers/power/pm2301_charger.c
Normal file
File diff suppressed because it is too large
Load diff
|
@ -406,6 +406,8 @@ struct ab8500_charger_platform_data {
|
|||
char **supplied_to;
|
||||
size_t num_supplicants;
|
||||
bool autopower_cfg;
|
||||
bool ac_enabled;
|
||||
bool usb_enabled;
|
||||
};
|
||||
|
||||
struct ab8500_btemp_platform_data {
|
||||
|
|
|
@ -27,12 +27,14 @@ struct ux500_charger_ops {
|
|||
* @ops ux500 charger operations
|
||||
* @max_out_volt maximum output charger voltage in mV
|
||||
* @max_out_curr maximum output charger current in mA
|
||||
* @enabled indicates if this charger is used or not
|
||||
*/
|
||||
struct ux500_charger {
|
||||
struct power_supply psy;
|
||||
struct ux500_charger_ops ops;
|
||||
int max_out_volt;
|
||||
int max_out_curr;
|
||||
bool enabled;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
60
include/linux/pm2301_charger.h
Normal file
60
include/linux/pm2301_charger.h
Normal file
|
@ -0,0 +1,60 @@
|
|||
/*
|
||||
* PM2301 charger driver.
|
||||
*
|
||||
* Copyright (C) 2012 ST Ericsson Corporation
|
||||
*
|
||||
* Contact: Olivier LAUNAY (olivier.launay@stericsson.com
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* version 2 as published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
|
||||
* 02110-1301 USA
|
||||
*/
|
||||
|
||||
#ifndef __LINUX_PM2301_H
|
||||
#define __LINUX_PM2301_H
|
||||
|
||||
/**
|
||||
* struct pm2xxx_bm_charger_parameters - Charger specific parameters
|
||||
* @ac_volt_max: maximum allowed AC charger voltage in mV
|
||||
* @ac_curr_max: maximum allowed AC charger current in mA
|
||||
*/
|
||||
struct pm2xxx_bm_charger_parameters {
|
||||
int ac_volt_max;
|
||||
int ac_curr_max;
|
||||
};
|
||||
|
||||
/**
|
||||
* struct pm2xxx_bm_data - pm2xxx battery management data
|
||||
* @enable_overshoot flag to enable VBAT overshoot control
|
||||
* @chg_params charger parameters
|
||||
*/
|
||||
struct pm2xxx_bm_data {
|
||||
bool enable_overshoot;
|
||||
const struct pm2xxx_bm_charger_parameters *chg_params;
|
||||
};
|
||||
|
||||
struct pm2xxx_charger_platform_data {
|
||||
char **supplied_to;
|
||||
size_t num_supplicants;
|
||||
int i2c_bus;
|
||||
const char *label;
|
||||
int irq_number;
|
||||
int irq_type;
|
||||
};
|
||||
|
||||
struct pm2xxx_platform_data {
|
||||
struct pm2xxx_charger_platform_data *wall_charger;
|
||||
struct pm2xxx_bm_data *battery;
|
||||
};
|
||||
|
||||
#endif /* __LINUX_PM2301_H */
|
Loading…
Reference in a new issue