aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFalong Li2017-12-08 02:50:49 -0600
committerFalong Li2017-12-08 02:50:49 -0600
commit8ab925a06e1bd0ce1aa4e71b7af1eb9f97d1add5 (patch)
treee36d2b4dc7367804c9ed4f9a0496770e1a49186b
parentfc094a0da2558f75c06b7170a4b31b334afcb35c (diff)
downloadbms-kernel-3-18-pmic-soc-smooth.tar.gz
bms-kernel-3-18-pmic-soc-smooth.tar.xz
bms-kernel-3-18-pmic-soc-smooth.zip
soc smooth verified okpmic-soc-smooth
-rw-r--r--arch/arm/boot/dts/qcom/apq8096-dragonboard.dtsi2
-rw-r--r--arch/arm/boot/dts/qcom/msm-pm8994.dtsi6
-rw-r--r--arch/arm/boot/dts/qcom/msm8996-pinctrl.dtsi4
-rw-r--r--drivers/platform/msm/qpnp-power-on.c4
-rw-r--r--drivers/power/Kconfig2
-rw-r--r--drivers/power/bq27426_fg.c135
6 files changed, 103 insertions, 50 deletions
diff --git a/arch/arm/boot/dts/qcom/apq8096-dragonboard.dtsi b/arch/arm/boot/dts/qcom/apq8096-dragonboard.dtsi
index 8eda6354..e2b282be 100644
--- a/arch/arm/boot/dts/qcom/apq8096-dragonboard.dtsi
+++ b/arch/arm/boot/dts/qcom/apq8096-dragonboard.dtsi
@@ -558,7 +558,7 @@
558 compatible = "ti,bq27426"; 558 compatible = "ti,bq27426";
559 reg = <0x55>; 559 reg = <0x55>;
560 interrupt-parent = <&tlmm>; 560 interrupt-parent = <&tlmm>;
561 interrupts = <1 2>; 561 interrupts = <0 2>;
562 pinctrl-names = "default"; 562 pinctrl-names = "default";
563 pinctrl-0 = <&bq27426_int_default>; 563 pinctrl-0 = <&bq27426_int_default>;
564 564
diff --git a/arch/arm/boot/dts/qcom/msm-pm8994.dtsi b/arch/arm/boot/dts/qcom/msm-pm8994.dtsi
index 3a9b91cc..1b607031 100644
--- a/arch/arm/boot/dts/qcom/msm-pm8994.dtsi
+++ b/arch/arm/boot/dts/qcom/msm-pm8994.dtsi
@@ -42,11 +42,9 @@
42 reg = <0x800 0x100>; 42 reg = <0x800 0x100>;
43 interrupts = <0x0 0x8 0x0>, 43 interrupts = <0x0 0x8 0x0>,
44 <0x0 0x8 0x1>, 44 <0x0 0x8 0x1>,
45 <0x0 0x8 0x2>,
46 <0x0 0x8 0x4>, 45 <0x0 0x8 0x4>,
47 <0x0 0x8 0x5>; 46 <0x0 0x8 0x5>;
48 interrupt-names = "kpdpwr", "resin", 47 interrupt-names = "kpdpwr", "resin",
49 "cblpwr",
50 "resin-bark", "kpdpwr-resin-bark"; 48 "resin-bark", "kpdpwr-resin-bark";
51 qcom,pon-dbc-delay = <15625>; 49 qcom,pon-dbc-delay = <15625>;
52 qcom,system-reset; 50 qcom,system-reset;
@@ -78,10 +76,6 @@
78 qcom,use-bark; 76 qcom,use-bark;
79 }; 77 };
80 78
81 qcom,pon_4 {
82 qcom,pon-type = <2>;
83 qcom,pull-up = <1>;
84 };
85 }; 79 };
86 80
87 pm8994_gpios: gpios { 81 pm8994_gpios: gpios {
diff --git a/arch/arm/boot/dts/qcom/msm8996-pinctrl.dtsi b/arch/arm/boot/dts/qcom/msm8996-pinctrl.dtsi
index 1630c2f9..7a2b247e 100644
--- a/arch/arm/boot/dts/qcom/msm8996-pinctrl.dtsi
+++ b/arch/arm/boot/dts/qcom/msm8996-pinctrl.dtsi
@@ -864,11 +864,11 @@
864 }; 864 };
865 bq27426_int_default: bq27426_int_default { 865 bq27426_int_default: bq27426_int_default {
866 muex { 866 muex {
867 pins = "gpio1"; 867 pins = "gpio0";
868 function = "gpio"; 868 function = "gpio";
869 }; 869 };
870 config { 870 config {
871 pins = "gpio1"; 871 pins = "gpio0";
872 drive-strength = <2>; 872 drive-strength = <2>;
873 bias-pull-up; 873 bias-pull-up;
874 }; 874 };
diff --git a/drivers/platform/msm/qpnp-power-on.c b/drivers/platform/msm/qpnp-power-on.c
index e62204ca..81863346 100644
--- a/drivers/platform/msm/qpnp-power-on.c
+++ b/drivers/platform/msm/qpnp-power-on.c
@@ -867,7 +867,6 @@ static irqreturn_t qpnp_kpdpwr_resin_bark_irq(int irq, void *_pon)
867 return IRQ_HANDLED; 867 return IRQ_HANDLED;
868} 868}
869 869
870void bq2415x_cblpwr_changed(void);
871static irqreturn_t qpnp_cblpwr_irq(int irq, void *_pon) 870static irqreturn_t qpnp_cblpwr_irq(int irq, void *_pon)
872{ 871{
873 int rc; 872 int rc;
@@ -877,8 +876,6 @@ static irqreturn_t qpnp_cblpwr_irq(int irq, void *_pon)
877 if (rc) 876 if (rc)
878 dev_err(&pon->spmi->dev, "Unable to send input event\n"); 877 dev_err(&pon->spmi->dev, "Unable to send input event\n");
879 878
880 bq2415x_cblpwr_changed();
881
882 return IRQ_HANDLED; 879 return IRQ_HANDLED;
883} 880}
884 881
@@ -1190,7 +1187,6 @@ qpnp_pon_request_irqs(struct qpnp_pon *pon, struct qpnp_pon_config *cfg)
1190 cfg->state_irq); 1187 cfg->state_irq);
1191 return rc; 1188 return rc;
1192 } 1189 }
1193 enable_irq_wake(cfg->state_irq);
1194 break; 1190 break;
1195 case PON_KPDPWR_RESIN: 1191 case PON_KPDPWR_RESIN:
1196 if (cfg->use_bark) { 1192 if (cfg->use_bark) {
diff --git a/drivers/power/Kconfig b/drivers/power/Kconfig
index f4061da6..79055528 100644
--- a/drivers/power/Kconfig
+++ b/drivers/power/Kconfig
@@ -371,7 +371,7 @@ config CHARGER_BQ24735
371config CHARGER_BQ2560X 371config CHARGER_BQ2560X
372 tristate "TI BQ2560x battery charger driver" 372 tristate "TI BQ2560x battery charger driver"
373 depends on I2C 373 depends on I2C
374 default y 374 default n
375 help 375 help
376 Say Y to enable support for the TI BQ2560x battery charger. 376 Say Y to enable support for the TI BQ2560x battery charger.
377 377
diff --git a/drivers/power/bq27426_fg.c b/drivers/power/bq27426_fg.c
index 2245518b..d61da48d 100644
--- a/drivers/power/bq27426_fg.c
+++ b/drivers/power/bq27426_fg.c
@@ -56,6 +56,9 @@
56#define pr_info pr_debug 56#define pr_info pr_debug
57#endif 57#endif
58 58
59#define USE_UPDATE_BQFS
60#undef USE_UPDATE_BQFS
61
59#define MONITOR_ALARM_CHECK_NS 5000000000 62#define MONITOR_ALARM_CHECK_NS 5000000000
60#define INVALID_REG_ADDR 0xFF 63#define INVALID_REG_ADDR 0xFF
61#define BQFS_UPDATE_KEY 0x8F91 64#define BQFS_UPDATE_KEY 0x8F91
@@ -915,6 +918,9 @@ static int fg_read_rsoc(struct bq_fg_chip *bq)
915{ 918{
916 int ret; 919 int ret;
917 u16 soc = 0; 920 u16 soc = 0;
921
922 if (bq->fake_soc >= 0)
923 return bq->fake_soc;
918 924
919 ret = fg_read_word(bq, bq->regs[BQ_FG_REG_SOC], &soc); 925 ret = fg_read_word(bq, bq->regs[BQ_FG_REG_SOC], &soc);
920 if (ret < 0) { 926 if (ret < 0) {
@@ -1149,6 +1155,19 @@ static int fg_read_batt_prop(enum power_supply_property psp, int *retval)
1149 return ret; 1155 return ret;
1150} 1156}
1151 1157
1158static void fg_smooth_soc_changed(void)
1159{
1160 static struct power_supply *batt_psy;
1161
1162 if (!batt_psy)
1163 batt_psy = power_supply_get_by_name("battery");
1164 if (!batt_psy)
1165 return ;
1166
1167 power_supply_changed(batt_psy);
1168}
1169
1170
1152#define BATT_LOW_VOLT 3500 1171#define BATT_LOW_VOLT 3500
1153#define BATT_LOW_RSOC 8 1172#define BATT_LOW_RSOC 8
1154static void fg_smooth_soc(struct bq_fg_chip *bq, bool smooth, int soc_fg, int batt_status) 1173static void fg_smooth_soc(struct bq_fg_chip *bq, bool smooth, int soc_fg, int batt_status)
@@ -1157,23 +1176,34 @@ static void fg_smooth_soc(struct bq_fg_chip *bq, bool smooth, int soc_fg, int ba
1157 static unsigned long jiffies_last = -EINVAL; 1176 static unsigned long jiffies_last = -EINVAL;
1158 static unsigned long jiffies_sm_reverse; 1177 static unsigned long jiffies_sm_reverse;
1159 static int sm_reverse; 1178 static int sm_reverse;
1179 static int soc_gap_last;
1180 static int sm_interval;
1181 static int sm_done;
1182 //static int gap_keep_counter;
1160 1183
1184 bool soc_changed = false;
1161 int batt_volt; 1185 int batt_volt;
1162 int sm_interval; 1186 int soc_gap;
1163 int ret; 1187 int ret;
1164 1188
1165 if (jiffies_last == -EINVAL || batt_status == -EINVAL) { 1189 if (jiffies_last == -EINVAL || batt_status_last == -EINVAL) {
1190
1166 jiffies_last = jiffies; 1191 jiffies_last = jiffies;
1167 batt_status_last = batt_status; 1192 batt_status_last = batt_status;
1168 } 1193 }
1169 1194
1170 if (!smooth) { 1195 if (!smooth) {
1171 bq->soc_smoothed = soc_fg; 1196 if ((batt_status == POWER_SUPPLY_STATUS_CHARGING && soc_fg > bq->soc_smoothed)
1197 || (batt_status == POWER_SUPPLY_STATUS_DISCHARGING && soc_fg < bq->soc_smoothed))
1198 bq->soc_smoothed = soc_fg;
1199
1172 jiffies_last = jiffies; 1200 jiffies_last = jiffies;
1173 batt_status_last = batt_status; 1201 batt_status_last = batt_status;
1202 sm_done = 1;
1174 return; 1203 return;
1175 } 1204 }
1176 1205
1206
1177 if (batt_status != batt_status_last) { 1207 if (batt_status != batt_status_last) {
1178 batt_status_last = batt_status; 1208 batt_status_last = batt_status;
1179 return; 1209 return;
@@ -1184,47 +1214,75 @@ static void fg_smooth_soc(struct bq_fg_chip *bq, bool smooth, int soc_fg, int ba
1184 if (ret < 0) 1214 if (ret < 0)
1185 return; 1215 return;
1186 1216
1187 if (batt_volt < BATT_LOW_VOLT || bq->soc_smoothed < BATT_LOW_RSOC 1217 soc_gap = abs(soc_fg - bq->soc_smoothed);
1188 || batt_status == POWER_SUPPLY_STATUS_FULL) 1218
1219 if (sm_done || !soc_gap_last) {
1220 soc_gap_last = soc_gap;
1221 sm_done = 0;
1222 }
1223
1224 if (soc_gap > soc_gap_last) {
1225 sm_interval = max(sm_interval - 1, 1);
1226 } else if (batt_volt < BATT_LOW_VOLT || bq->soc_smoothed < BATT_LOW_RSOC
1227 || batt_status == POWER_SUPPLY_STATUS_FULL || soc_gap > 5) {
1228 sm_interval = 5;
1229 } else {
1189 sm_interval = 10; 1230 sm_interval = 10;
1190 else 1231 }
1191 sm_interval = 30;
1192 1232
1193 if (time_before(jiffies, jiffies_last + sm_interval * HZ)) 1233 if (time_before(jiffies, jiffies_last + sm_interval * HZ))
1194 return; 1234 return;
1195 1235
1196 pr_debug("sm_interval = %ds\n", sm_interval); 1236 pr_debug("sm_interval = %ds\n", sm_interval);
1197 1237
1198 if (batt_status == POWER_SUPPLY_STATUS_CHARGING || 1238 soc_gap_last = soc_gap;
1199 batt_status == POWER_SUPPLY_STATUS_FULL) { 1239
1240 if (batt_status == POWER_SUPPLY_STATUS_CHARGING
1241 || batt_status == POWER_SUPPLY_STATUS_FULL) {
1200 if (bq->soc_smoothed < soc_fg) { 1242 if (bq->soc_smoothed < soc_fg) {
1201 bq->soc_smoothed++; 1243 bq->soc_smoothed++;
1202 sm_reverse = 0; 1244 sm_reverse = 0;
1245 soc_changed = true;
1203 } else { /*rsoc jump followed by status change*/ 1246 } else { /*rsoc jump followed by status change*/
1247
1204 if (sm_reverse != 1) { 1248 if (sm_reverse != 1) {
1205 jiffies_sm_reverse = jiffies; 1249 jiffies_sm_reverse = jiffies;
1206 sm_reverse = 1; 1250 sm_reverse = 1;
1251 pr_debug("sm_reverse = %d\n", sm_reverse);
1207 } 1252 }
1208 } 1253 }
1209 1254
1210 } else if (batt_status == POWER_SUPPLY_STATUS_DISCHARGING) { 1255 } else if (batt_status == POWER_SUPPLY_STATUS_DISCHARGING) {
1256
1211 if (bq->soc_smoothed > soc_fg) { 1257 if (bq->soc_smoothed > soc_fg) {
1212 bq->soc_smoothed--; 1258 bq->soc_smoothed--;
1213 sm_reverse = 0; 1259 sm_reverse = 0;
1260 soc_changed = true;
1214 } else {/*rsoc jump followed by status change*/ 1261 } else {/*rsoc jump followed by status change*/
1215 1262
1216 if (sm_reverse != -1) { 1263 if (sm_reverse != -1) {
1217 jiffies_sm_reverse = jiffies; 1264 jiffies_sm_reverse = jiffies;
1218 sm_reverse = -1; 1265 sm_reverse = -1;
1266 pr_debug("sm_reverse = %d\n", sm_reverse);
1219 } 1267 }
1220 } 1268 }
1221 } 1269 }
1222 1270#if 0
1223 if (sm_reverse 1271 /* assume RSOC jump from 97 to 100, bq->soc_smoothed = 98 now,
1224 && time_after(jiffies, jiffies_sm_reverse + 300 * HZ)) { 1272 * then system switch to discharging state,bq->soc_smoothed < fg_soc,
1273 * it will stay unchanged til fg_soc is coming with same value.
1274 * to avoid bq->soc_smoothed keeping unchange for longer time,
1275 * bq->soc_smoothed can reduce slowly, following code serve this*/
1276
1277 if (sm_reverse && (batt_status == POWER_SUPPLY_STATUS_CHARGING ||
1278 batt_status == POWER_SUPPLY_STATUS_DISCHARGING)
1279 && time_after(jiffies, jiffies_sm_reverse + 600 * HZ)) {
1225 bq->soc_smoothed += sm_reverse; 1280 bq->soc_smoothed += sm_reverse;
1226 jiffies_sm_reverse = jiffies; 1281 jiffies_sm_reverse = jiffies;
1227 } 1282 }
1283#endif
1284 if (soc_changed)
1285 fg_smooth_soc_changed();
1228 1286
1229 jiffies_last = jiffies; 1287 jiffies_last = jiffies;
1230} 1288}
@@ -1238,10 +1296,10 @@ static void bq_fg_soc_smooth_workfunc(struct work_struct *work)
1238 int ret; 1296 int ret;
1239 int soc_fg; 1297 int soc_fg;
1240 int soc_gap; 1298 int soc_gap;
1241 static bool pct99_timer_running; 1299 static bool pct99_timer_running = false;
1242 static bool pct99_timeout; 1300 static bool pct99_timeout = false;
1243 unsigned long pct99_start_jiffies; 1301 static unsigned long pct99_start_jiffies;
1244 int batt_status_now; 1302 int batt_status;
1245 1303
1246 soc_fg = fg_read_rsoc(bq); 1304 soc_fg = fg_read_rsoc(bq);
1247 if (soc_fg < 0) 1305 if (soc_fg < 0)
@@ -1250,18 +1308,18 @@ static void bq_fg_soc_smooth_workfunc(struct work_struct *work)
1250 if (bq->soc_smoothed == -EINVAL) 1308 if (bq->soc_smoothed == -EINVAL)
1251 bq->soc_smoothed = soc_fg; 1309 bq->soc_smoothed = soc_fg;
1252 1310
1253 ret = fg_read_batt_prop(POWER_SUPPLY_PROP_STATUS, &batt_status_now); 1311 ret = fg_read_batt_prop(POWER_SUPPLY_PROP_STATUS, &batt_status);
1254 if(ret < 0) 1312 if(ret < 0)
1255 return; 1313 return;
1256 1314
1257 if (soc_fg == 99 && !pct99_timer_running 1315 if (soc_fg == 99 && bq->soc_smoothed != 100 && !pct99_timer_running
1258 && batt_status_now == POWER_SUPPLY_STATUS_CHARGING ) { 1316 && batt_status == POWER_SUPPLY_STATUS_CHARGING ) {
1259 pct99_timer_running = true; 1317 pct99_timer_running = true;
1260 pct99_timeout = false; 1318 pct99_timeout = false;
1261 pct99_start_jiffies = jiffies; 1319 pct99_start_jiffies = jiffies;
1262 pr_debug("pct99 hold timer started\n"); 1320 pr_debug("pct99 hold timer started\n");
1263 } else if (soc_fg != 99 1321 } else if (pct99_timer_running && (soc_fg != 99
1264 || batt_status_now != POWER_SUPPLY_STATUS_CHARGING) { 1322 || batt_status != POWER_SUPPLY_STATUS_CHARGING)) {
1265 pct99_timeout = false; 1323 pct99_timeout = false;
1266 pct99_timer_running = false; 1324 pct99_timer_running = false;
1267 pr_debug("pct99 hold timer cleared\n"); 1325 pr_debug("pct99 hold timer cleared\n");
@@ -1270,25 +1328,23 @@ static void bq_fg_soc_smooth_workfunc(struct work_struct *work)
1270 if (pct99_timer_running && !pct99_timeout 1328 if (pct99_timer_running && !pct99_timeout
1271 && time_after(jiffies, pct99_start_jiffies + PCT99_HOLD_MAX_TIME * HZ)) { 1329 && time_after(jiffies, pct99_start_jiffies + PCT99_HOLD_MAX_TIME * HZ)) {
1272 pct99_timeout = true; 1330 pct99_timeout = true;
1273 pct99_timer_running = false;
1274 bq->soc_smoothed = 100; 1331 bq->soc_smoothed = 100;
1332 fg_smooth_soc_changed();
1275 pr_debug("pct99 hold timer timeout\n"); 1333 pr_debug("pct99 hold timer timeout\n");
1276 } 1334 }
1277 1335
1278 soc_gap = bq->soc_smoothed - soc_fg; 1336 soc_gap = bq->soc_smoothed - soc_fg;
1279 pr_debug("soc gap before smooth:%d\n", soc_gap);
1280 /* if pct99 timer is expired, bq->soc_smoothed is forced to be 100 1337 /* if pct99 timer is expired, bq->soc_smoothed is forced to be 100
1281 * which might be greater than soc_fg, don't set it back 1338 * which might be greater than soc_fg, don't set it back
1282 */ 1339 */
1283 if (abs(soc_gap) <= 1 && !pct99_timeout) 1340 if (abs(soc_gap) <= 1 && !pct99_timeout)
1284 fg_smooth_soc(bq, false, soc_fg, batt_status_now); 1341 fg_smooth_soc(bq, false, soc_fg, batt_status);
1285 else if (abs(soc_gap) > 1) 1342 else if (abs(soc_gap) > 1)
1286 fg_smooth_soc(bq, true, soc_fg, batt_status_now); 1343 fg_smooth_soc(bq, true, soc_fg, batt_status);
1287 1344
1288 pr_debug("soc_gap after smooth:%d\n", (int)abs(soc_fg - bq->soc_smoothed)); 1345 pr_debug("soc_fg=%d, soc_smoothed=%d\n", soc_fg, bq->soc_smoothed);
1289 pr_debug("soc_fg=%d\n, soc_smoothed=%d\n", soc_fg, bq->soc_smoothed);
1290 1346
1291 schedule_delayed_work(&bq->soc_smooth_work, 10 * HZ); 1347 schedule_delayed_work(&bq->soc_smooth_work, 5 * HZ);
1292} 1348}
1293 1349
1294static enum power_supply_property fg_props[] = { 1350static enum power_supply_property fg_props[] = {
@@ -1341,13 +1397,13 @@ static int fg_get_property(struct power_supply *psy, enum power_supply_property
1341 break; 1397 break;
1342 1398
1343 case POWER_SUPPLY_PROP_CAPACITY: 1399 case POWER_SUPPLY_PROP_CAPACITY:
1400#if 0
1344 if (bq->fake_soc >= 0) { 1401 if (bq->fake_soc >= 0) {
1345 val->intval = bq->fake_soc; 1402 val->intval = bq->fake_soc;
1346 break; 1403 break;
1347 } 1404 }
1405#endif
1348 if (bq->soc_smooth_enabled) { 1406 if (bq->soc_smooth_enabled) {
1349 cancel_delayed_work(&bq->soc_smooth_work);
1350 schedule_delayed_work(&bq->soc_smooth_work, 0);
1351 if (bq->soc_smoothed != -EINVAL) 1407 if (bq->soc_smoothed != -EINVAL)
1352 ret = bq->soc_smoothed; 1408 ret = bq->soc_smoothed;
1353 else 1409 else
@@ -1501,8 +1557,8 @@ static int fg_psy_register(struct bq_fg_chip *bq)
1501{ 1557{
1502 int ret; 1558 int ret;
1503 1559
1504 bq->fg_psy.name = "bms"; 1560 bq->fg_psy.name = "battery";
1505 bq->fg_psy.type = POWER_SUPPLY_TYPE_BMS; 1561 bq->fg_psy.type = POWER_SUPPLY_TYPE_BATTERY;
1506 bq->fg_psy.properties = fg_props; 1562 bq->fg_psy.properties = fg_props;
1507 bq->fg_psy.num_properties = ARRAY_SIZE(fg_props); 1563 bq->fg_psy.num_properties = ARRAY_SIZE(fg_props);
1508 bq->fg_psy.get_property = fg_get_property; 1564 bq->fg_psy.get_property = fg_get_property;
@@ -1598,6 +1654,7 @@ static int fg_change_chem_id(struct bq_fg_chip *bq, u16 new_id)
1598} 1654}
1599EXPORT_SYMBOL_GPL(fg_change_chem_id); 1655EXPORT_SYMBOL_GPL(fg_change_chem_id);
1600 1656
1657
1601static int fg_check_update_necessary(struct bq_fg_chip *bq) 1658static int fg_check_update_necessary(struct bq_fg_chip *bq)
1602{ 1659{
1603 int ret; 1660 int ret;
@@ -2010,6 +2067,8 @@ static void determine_initial_status(struct bq_fg_chip *bq)
2010{ 2067{
2011 fg_irq_thread(bq->client->irq, bq); 2068 fg_irq_thread(bq->client->irq, bq);
2012} 2069}
2070
2071#ifdef USE_UPDATE_BQFS
2013static void convert_rid2battid(struct bq_fg_chip *bq) 2072static void convert_rid2battid(struct bq_fg_chip *bq)
2014{ 2073{
2015 //TODO: here is just an example, modify it accordingly 2074 //TODO: here is just an example, modify it accordingly
@@ -2033,6 +2092,7 @@ static void convert_rid2battid(struct bq_fg_chip *bq)
2033 2092
2034#define SMB_VTG_MIN_UV 1800000 2093#define SMB_VTG_MIN_UV 1800000
2035#define SMB_VTG_MAX_UV 1800000 2094#define SMB_VTG_MAX_UV 1800000
2095
2036static int fg_parse_batt_id(struct bq_fg_chip *bq) 2096static int fg_parse_batt_id(struct bq_fg_chip *bq)
2037{ 2097{
2038 int rc = 0, rpull = 0, vref = 0; 2098 int rc = 0, rpull = 0, vref = 0;
@@ -2109,6 +2169,7 @@ static int fg_parse_batt_id(struct bq_fg_chip *bq)
2109 2169
2110 return 0; 2170 return 0;
2111} 2171}
2172#endif
2112 2173
2113static int bq_parse_dt(struct bq_fg_chip *bq) 2174static int bq_parse_dt(struct bq_fg_chip *bq)
2114{ 2175{
@@ -2145,7 +2206,8 @@ static int bq_fg_probe(struct i2c_client *client,
2145 2206
2146 bq->fake_soc = -EINVAL; 2207 bq->fake_soc = -EINVAL;
2147 bq->fake_temp = -EINVAL; 2208 bq->fake_temp = -EINVAL;
2148 2209 bq->soc_smoothed = -EINVAL;
2210
2149 if (bq->chip == BQ27426) { 2211 if (bq->chip == BQ27426) {
2150 regs = bq27426_regs; 2212 regs = bq27426_regs;
2151 } else { 2213 } else {
@@ -2164,7 +2226,7 @@ static int bq_fg_probe(struct i2c_client *client,
2164 2226
2165 bq->resume_completed = true; 2227 bq->resume_completed = true;
2166 bq->irq_waiting = false; 2228 bq->irq_waiting = false;
2167 2229#if 0
2168 bq->vadc_dev = qpnp_get_vadc(bq->dev, "batt_id"); 2230 bq->vadc_dev = qpnp_get_vadc(bq->dev, "batt_id");
2169 if (IS_ERR(bq->vadc_dev)) { 2231 if (IS_ERR(bq->vadc_dev)) {
2170 ret = PTR_ERR(bq->vadc_dev); 2232 ret = PTR_ERR(bq->vadc_dev);
@@ -2175,17 +2237,18 @@ static int bq_fg_probe(struct i2c_client *client,
2175 2237
2176 return ret; 2238 return ret;
2177 } 2239 }
2240#endif
2178 ret = bq_parse_dt(bq); 2241 ret = bq_parse_dt(bq);
2179 if (ret < 0) { 2242 if (ret < 0) {
2180 dev_err(&client->dev, "Unable to parse DT nodes\n"); 2243 dev_err(&client->dev, "Unable to parse DT nodes\n");
2181 //goto destroy_mutex; 2244 //goto destroy_mutex;
2182 } 2245 }
2183 INIT_WORK(&bq->update_work, fg_update_bqfs_workfunc); 2246 INIT_WORK(&bq->update_work, fg_update_bqfs_workfunc);
2184 2247#ifdef USE_UPDATE_BQFS
2185 fg_parse_batt_id(bq); 2248 fg_parse_batt_id(bq);
2186 2249
2187 fg_update_bqfs(bq); 2250 fg_update_bqfs(bq);
2188 2251#endif
2189 if (client->irq) { 2252 if (client->irq) {
2190 ret = devm_request_threaded_irq(&client->dev, client->irq, NULL, 2253 ret = devm_request_threaded_irq(&client->dev, client->irq, NULL,
2191 fg_irq_thread, 2254 fg_irq_thread,