aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndreas Dannenberg <dannenberg@ti.com>2015-09-28 18:33:58 -0400
committerSebastian Reichel <sre@kernel.org>2015-09-29 10:54:44 -0400
commit138606ffe45511fa774e51df04f6da562ff9c44d (patch)
treed52b1c29b704420d3da7fed941b8e3d47937d071
parentbb2956e8e1976d876a755896f5be287cb7e766b2 (diff)
power: bq24257: Add input DPM voltage threshold setting support
A new optional device property called "ti,in-dpm-voltage" is introduced to allow configuring the input voltage threshold for the devices' dynamic power path management (DPM) feature. In short, it can be used to prevent the input voltage from dropping below a certain value as current is drawn to charge the battery or supply the system. Signed-off-by: Andreas Dannenberg <dannenberg@ti.com> Reviewed-by: Laurentiu Palcu <laurentiu.palcu@intel.com> Reviewed-by: Krzysztof Kozlowski <k.kozlowski@samsung.com> Signed-off-by: Sebastian Reichel <sre@kernel.org>
-rw-r--r--drivers/power/bq24257_charger.c43
1 files changed, 43 insertions, 0 deletions
diff --git a/drivers/power/bq24257_charger.c b/drivers/power/bq24257_charger.c
index b617c3a20652..ebb22f3be487 100644
--- a/drivers/power/bq24257_charger.c
+++ b/drivers/power/bq24257_charger.c
@@ -79,6 +79,7 @@ struct bq24257_init_data {
79 u8 iterm; /* termination current */ 79 u8 iterm; /* termination current */
80 u8 iilimit; /* input current limit */ 80 u8 iilimit; /* input current limit */
81 u8 vovp; /* over voltage protection voltage */ 81 u8 vovp; /* over voltage protection voltage */
82 u8 vindpm; /* VDMP input threshold voltage */
82}; 83};
83 84
84struct bq24257_state { 85struct bq24257_state {
@@ -208,6 +209,13 @@ static const u32 bq24257_vovp_map[] = {
208 209
209#define BQ24257_VOVP_MAP_SIZE ARRAY_SIZE(bq24257_vovp_map) 210#define BQ24257_VOVP_MAP_SIZE ARRAY_SIZE(bq24257_vovp_map)
210 211
212static const u32 bq24257_vindpm_map[] = {
213 4200000, 4280000, 4360000, 4440000, 4520000, 4600000, 4680000,
214 4760000
215};
216
217#define BQ24257_VINDPM_MAP_SIZE ARRAY_SIZE(bq24257_vindpm_map)
218
211static int bq24257_field_read(struct bq24257_device *bq, 219static int bq24257_field_read(struct bq24257_device *bq,
212 enum bq24257_fields field_id) 220 enum bq24257_fields field_id)
213{ 221{
@@ -434,6 +442,17 @@ enum bq24257_vovp {
434 VOVP_10500 442 VOVP_10500
435}; 443};
436 444
445enum bq24257_vindpm {
446 VINDPM_4200,
447 VINDPM_4280,
448 VINDPM_4360,
449 VINDPM_4440,
450 VINDPM_4520,
451 VINDPM_4600,
452 VINDPM_4680,
453 VINDPM_4760
454};
455
437enum bq24257_port_type { 456enum bq24257_port_type {
438 PORT_TYPE_DCP, /* Dedicated Charging Port */ 457 PORT_TYPE_DCP, /* Dedicated Charging Port */
439 PORT_TYPE_CDP, /* Charging Downstream Port */ 458 PORT_TYPE_CDP, /* Charging Downstream Port */
@@ -607,6 +626,7 @@ static int bq24257_hw_init(struct bq24257_device *bq)
607 {F_VBAT, bq->init_data.vbat}, 626 {F_VBAT, bq->init_data.vbat},
608 {F_ITERM, bq->init_data.iterm}, 627 {F_ITERM, bq->init_data.iterm},
609 {F_VOVP, bq->init_data.vovp}, 628 {F_VOVP, bq->init_data.vovp},
629 {F_VINDPM, bq->init_data.vindpm},
610 }; 630 };
611 631
612 /* 632 /*
@@ -687,10 +707,23 @@ static ssize_t bq24257_show_ovp_voltage(struct device *dev,
687 bq24257_vovp_map[bq->init_data.vovp]); 707 bq24257_vovp_map[bq->init_data.vovp]);
688} 708}
689 709
710static ssize_t bq24257_show_in_dpm_voltage(struct device *dev,
711 struct device_attribute *attr,
712 char *buf)
713{
714 struct power_supply *psy = dev_get_drvdata(dev);
715 struct bq24257_device *bq = power_supply_get_drvdata(psy);
716
717 return scnprintf(buf, PAGE_SIZE, "%u\n",
718 bq24257_vindpm_map[bq->init_data.vindpm]);
719}
720
690static DEVICE_ATTR(ovp_voltage, S_IRUGO, bq24257_show_ovp_voltage, NULL); 721static DEVICE_ATTR(ovp_voltage, S_IRUGO, bq24257_show_ovp_voltage, NULL);
722static DEVICE_ATTR(in_dpm_voltage, S_IRUGO, bq24257_show_in_dpm_voltage, NULL);
691 723
692static struct attribute *bq24257_charger_attr[] = { 724static struct attribute *bq24257_charger_attr[] = {
693 &dev_attr_ovp_voltage.attr, 725 &dev_attr_ovp_voltage.attr,
726 &dev_attr_in_dpm_voltage.attr,
694 NULL, 727 NULL,
695}; 728};
696 729
@@ -785,6 +818,16 @@ static int bq24257_fw_probe(struct bq24257_device *bq)
785 bq24257_vovp_map, 818 bq24257_vovp_map,
786 BQ24257_VOVP_MAP_SIZE); 819 BQ24257_VOVP_MAP_SIZE);
787 820
821 ret = device_property_read_u32(bq->dev, "ti,in-dpm-voltage",
822 &property);
823 if (ret < 0)
824 bq->init_data.vindpm = VINDPM_4360;
825 else
826 bq->init_data.vindpm =
827 bq24257_find_idx(property,
828 bq24257_vindpm_map,
829 BQ24257_VINDPM_MAP_SIZE);
830
788 return 0; 831 return 0;
789} 832}
790 833