summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLaxman Dewangan <ldewangan@nvidia.com>2012-11-20 01:46:51 -0500
committerDan Willemsen <dwillemsen@nvidia.com>2013-09-14 12:42:50 -0700
commit9149f56e0e37f5c0392f751cf111e275c47ff7d6 (patch)
tree3d71e566b33f6cbcb4a30a2536974f99f2e1d9d0
parent3a434f3c5a8373c703ef5a3f6d806aefe3989fb4 (diff)
rtc: palmas: add battery backup charging support
Add platform data for RTC to select the battery backup charging or not. Change-Id: Ie4010a9c58c89237619017297733320ca646960c Signed-off-by: Laxman Dewangan <ldewangan@nvidia.com> Reviewed-on: http://git-master/r/164937 Reviewed-by: Automatic_Commit_Validation_User
-rw-r--r--drivers/rtc/rtc-palmas.c38
-rw-r--r--include/linux/mfd/palmas.h6
2 files changed, 44 insertions, 0 deletions
diff --git a/drivers/rtc/rtc-palmas.c b/drivers/rtc/rtc-palmas.c
index 52952d41e82e..aed71f5a87e6 100644
--- a/drivers/rtc/rtc-palmas.c
+++ b/drivers/rtc/rtc-palmas.c
@@ -283,6 +283,8 @@ static int __devinit palmas_rtc_probe(struct platform_device *pdev)
{
struct palmas *palmas = NULL;
struct palmas_rtc *palmas_rtc = NULL;
+ struct palmas_platform_data *palmas_pdata;
+ struct palmas_rtc_platform_data *rtc_pdata = NULL;
int ret;
u32 rtc_reg;
@@ -295,7 +297,43 @@ static int __devinit palmas_rtc_probe(struct platform_device *pdev)
return -ENOMEM;
}
+ palmas_pdata = dev_get_platdata(pdev->dev.parent);
+ if (palmas_pdata)
+ rtc_pdata = palmas_pdata->rtc_pdata;
+
palmas->rtc = palmas_rtc;
+ if (rtc_pdata && rtc_pdata->enable_charging) {
+ int slave;
+ unsigned int addr;
+ int reg = 0;
+
+ addr = PALMAS_BASE_TO_REG(PALMAS_PMU_CONTROL_BASE,
+ PALMAS_BACKUP_BATTERY_CTRL);
+ slave = PALMAS_BASE_TO_SLAVE(PALMAS_PMU_CONTROL_BASE);
+
+ if (rtc_pdata->charging_current_ua < 100)
+ reg = PALMAS_BACKUP_BATTERY_CTRL_BBS_BBC_LOW_ICHRG;
+
+ ret = regmap_update_bits(palmas->regmap[slave], addr,
+ PALMAS_BACKUP_BATTERY_CTRL_BBS_BBC_LOW_ICHRG,
+ reg);
+ if (ret < 0) {
+ dev_err(&pdev->dev,
+ "Battery backup control failed, e %d\n", ret);
+ return ret;
+ };
+
+ ret = regmap_update_bits(palmas->regmap[slave], addr,
+ PALMAS_BACKUP_BATTERY_CTRL_BB_CHG_EN,
+ PALMAS_BACKUP_BATTERY_CTRL_BB_CHG_EN);
+ if (ret < 0) {
+ dev_err(&pdev->dev,
+ "Battery backup charging enable failed, e %d\n",
+ ret);
+ return ret;
+ }
+ }
+
/* Clear pending interrupts */
ret = palmas_rtc_read(palmas, PALMAS_RTC_STATUS_REG,
&rtc_reg);
diff --git a/include/linux/mfd/palmas.h b/include/linux/mfd/palmas.h
index 94929d400d64..2f93e253c237 100644
--- a/include/linux/mfd/palmas.h
+++ b/include/linux/mfd/palmas.h
@@ -258,6 +258,11 @@ struct palmas_clk_platform_data {
int clk32kgaudio_mode_sleep;
};
+struct palmas_rtc_platform_data {
+ unsigned enable_charging:1;
+ unsigned charging_current_ua;
+};
+
struct palmas_platform_data {
int irq_flags;
int gpio_base;
@@ -278,6 +283,7 @@ struct palmas_platform_data {
struct palmas_usb_platform_data *usb_pdata;
struct palmas_resource_platform_data *resource_pdata;
struct palmas_clk_platform_data *clk_pdata;
+ struct palmas_rtc_platform_data *rtc_pdata;
struct palmas_clk32k_init_data *clk32k_init_data;
int clk32k_init_data_size;