msm: power: update power drivers to msm-3.4 tip
This branch is currently very outdated. Cherry pick the following changes in order to bring recent fixes to this branch. Change-Ids Ib99cd49623698d0295bc3c3cf880225495d530cb Ifba2bd1248e8bb47a0700dec4d321d32db4f2066 I0fc1e116c0f5a5648f99df967bdbb41fe5a07cbc I8e3e9068e7b9a3bfd24c07a00bb3953180ce0741 I2bf31a23199f942a9ac843b9940a0f7377256238 I96b47c8603a291c41c5769fab9483d83fefb6084 If3c5f00f4b75d03838ee556235697369fd2e47dd I32d50caf7b7a84db2654b69baafb40a441f46bf0 Ibd1020113de05e8214d41ffb975d4c95d3bb1ccf I67c2ac422b0ba1e5eca11ffccfe7e112c2e65a3d I2c149e6edd7c194e7f31ece95e2003ffde935806 I1f4b65cba149480fb4a8f91667ce45a876dff2f0 I2605afc2d6f9f3569ec783b2d23881f31cc9038a I77b40f9cb8295cff1d4a24dfc7d85b0e57262f6e I8ec5a68cad573218a0b0bd0073277b76978417ff I9eaf7f21c73dd1ceaf97589cbf82b722706c48c2 I089725e20ae20956530e570d918a87b72e59626e Ifa70a4daf01414dfafed7830e3a6a682c42e9364 Iaace5bc1d0611619f11b760ea6986eadb7346da1 I415d7831f15c0d690fd118ff190cd710a31368c6 I1e55bbfe37c7cc6f62581af11280a565ed648c06 I11938c569a25b026ee6b7b5125cec930676ec01d I07577d1aa57bfa4bee40b52c18b5bfcb1cdb7070 Icdb0a28b5f9456135c60badf726c367b02f6d762 I4f14b7419f7a90813650601638f6563422c13ae4 I016a33c358be2e7a2d26202f2e9b168dd54b6d34 I43e26a2932ab3e3d9d79bb5af7daf2364ca133b7 I333c810568cdc656d2e13f0eeb9511857335b834 I830bf2e679e76efe7ed9d8bb30a8d459d8b9a09a I08d8d319d096c050ae53d90eeac293c9b1bab2bf I445676d558e05a6c5e9dd1e76e80ba2f5e8cd6c1 I9f38515f35fcddfbdc34ae4f59ffcfc6682033d4 Ia32e581c11954163bc8ff20a7b32432a843a17b2 I07c346475fb4a294bc8eb8da8c2048cc23394e20 Ic3f2c4e5bafd3a1556412005564fc0b549e6813c Ic68717f4410170814d3e3b141de77b35eca12f7b Ifad79991298e9d779b38a33a270af5197d2fc060 I3060c5ba31b59666aedfafad430e21329c4479d4 I9c87282ba5819a76a6f6697a5e9de6c92d74a665 I8144e2b83748a96ab83ba14894bfa5bd59995895 I8cac84296ddb1e323f28e2476f78d0190f4a1b73 Icef2b7fa70f274f671bd1b9469eb6a333ab462f9 Idc4ceb7973d1a424834f8c2a4bc5916ef7b1e961 I1bc779e5890f6994442c562ee5abf37c06dc6d3d Ib1161d3d8c4a9378eabf44f9de1eae9556d82643 I11a17fc105dea398140abc1a59e6355e9e55b322 I0aa523321f1eed4a0a5461b1a894452f77e6ff99 I827bd74e9892969bb4891b31af1515789fa76c1c I1bb658339e5a6f0adb07fda3ee0bc6c03670cc09 I135261c851067a25b20b30482764b5a61145f186 I4971d605c3475949be64372dc6bd3355ed258527 I08f6a7830c4b9ad44fb96f6d304ce257a899e287 I96886f8d0f3f03905163d93c4f8f3e637d98127f Idf2cf7f40780cf46ba95228764790b818bc72db5 Ib046fd7149d71fc62c8f2df7a9747d6b54e95138 I546ff57d76e50ad86eb5853782fdcc1f348c9f0e I1293ecc2974bae4ad530ecb775cd19072e413c72 I8db5a202a2e63ca0a3e355a6083d426acb7342cb I71482f9a4430a8bbcd02c954a415ff3fab2a0c8f I0c5656798444764b52f4d9d8889f831d674a1610 I2ac4ccd967a7a47284573c9b645055ebeca4635c I93b830d42e7d44435c790832c11d5d38861015e0 If24985f47cc9fcd6c2eb84a73165878559008120 I39b908451f4b678ed63b872ffc46590e2c728b2c If7e5622067c77c4c8d64ee466d1c62e4dcb0e53f If58279329f6c76978223369a2d08d47a7b1e3579 I3621a0a204360343ba684e2217a68a6ef51a7850 I358909c38b0771fe0283386841b6123ddb2931a6 I2e8fcb4a15af3a66331a921d378bfd5d2dfe4533 I0bbad22c5fed8c32dd7de387194e94c8d4b9ad75 I34f51c6202cbaa805c496360e8dbd391890decc6 Iaab82ea254444bba233cd9ebad93d38426154ca4 Ica2565031546a8281820c17edc95d258ad31ba65 Ic282fff7167a8224ec1a1e0f7c247a9c8d73f390 Icdc707a9438adae5c8bb2d9b97af95e65c4bc2a1 I26c4e1fb971f22ec721e1dddcce6b301f5db6608 I8882575084eefa6a23bd59b8d2a54a53d793298e Ic1e7cf4da4d2bf73d889aee7bac6cf260b26d532 I472b9da10e9f45b3c254f8440526f3f9d5116931 I1560e0df1c89be1db1e1d1aeaaeef2e6da5f85c1 Ie2842b28648084d8970329d7c76fcf0d0666a847 I2dccaedb559fc5e9865b137f980024e068bdafa3 I61a3d44f81d829f1ef22fd3044c65e4b3518b92b I0d657c2e0d47af32cc35cd66b902be72952e5438 I22d2dbdae5c9c859d4baca2bdb7bea71da09b85b I8c99fcbbf2f7229728236ae1059f4c9cb8dbb065 I1bb841e463658c8db42eb15ecc1687262df86a2f Change-Id: Ib04f801b0085e7d5da3d73594bbc41c281b06026 Signed-off-by: Xiaozhe Shi <xiaozhes@codeaurora.org>
This commit is contained in:
committed by
Stephen Boyd
parent
2f24cb771c
commit
fae0afd7be
155
include/linux/mfd/pm8xxx/batterydata-lib.h
Normal file
155
include/linux/mfd/pm8xxx/batterydata-lib.h
Normal file
@@ -0,0 +1,155 @@
|
||||
/* Copyright (c) 2012, The Linux Foundation. All rights reserved.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 and
|
||||
* only 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.
|
||||
*/
|
||||
|
||||
#ifndef __PM8XXX_BMS_BATTERYDATA_H
|
||||
#define __PM8XXX_BMS_BATTERYDATA_H
|
||||
|
||||
#include <linux/errno.h>
|
||||
|
||||
#define FCC_CC_COLS 5
|
||||
#define FCC_TEMP_COLS 8
|
||||
|
||||
#define PC_CC_ROWS 29
|
||||
#define PC_CC_COLS 13
|
||||
|
||||
#define PC_TEMP_ROWS 29
|
||||
#define PC_TEMP_COLS 8
|
||||
|
||||
#define MAX_SINGLE_LUT_COLS 20
|
||||
|
||||
struct single_row_lut {
|
||||
int x[MAX_SINGLE_LUT_COLS];
|
||||
int y[MAX_SINGLE_LUT_COLS];
|
||||
int cols;
|
||||
};
|
||||
|
||||
/**
|
||||
* struct sf_lut -
|
||||
* @rows: number of percent charge entries should be <= PC_CC_ROWS
|
||||
* @cols: number of charge cycle entries should be <= PC_CC_COLS
|
||||
* @row_entries: the charge cycles/temperature at which sf data
|
||||
* is available in the table.
|
||||
* The charge cycles must be in increasing order from 0 to rows.
|
||||
* @percent: the percent charge at which sf data is available in the table
|
||||
* The percentcharge must be in decreasing order from 0 to cols.
|
||||
* @sf: the scaling factor data
|
||||
*/
|
||||
struct sf_lut {
|
||||
int rows;
|
||||
int cols;
|
||||
int row_entries[PC_CC_COLS];
|
||||
int percent[PC_CC_ROWS];
|
||||
int sf[PC_CC_ROWS][PC_CC_COLS];
|
||||
};
|
||||
|
||||
/**
|
||||
* struct pc_temp_ocv_lut -
|
||||
* @rows: number of percent charge entries should be <= PC_TEMP_ROWS
|
||||
* @cols: number of temperature entries should be <= PC_TEMP_COLS
|
||||
* @temp: the temperatures at which ocv data is available in the table
|
||||
* The temperatures must be in increasing order from 0 to rows.
|
||||
* @percent: the percent charge at which ocv data is available in the table
|
||||
* The percentcharge must be in decreasing order from 0 to cols.
|
||||
* @ocv: the open circuit voltage
|
||||
*/
|
||||
struct pc_temp_ocv_lut {
|
||||
int rows;
|
||||
int cols;
|
||||
int temp[PC_TEMP_COLS];
|
||||
int percent[PC_TEMP_ROWS];
|
||||
int ocv[PC_TEMP_ROWS][PC_TEMP_COLS];
|
||||
};
|
||||
|
||||
enum battery_type {
|
||||
BATT_UNKNOWN = 0,
|
||||
BATT_PALLADIUM,
|
||||
BATT_DESAY,
|
||||
};
|
||||
|
||||
/**
|
||||
* struct bms_battery_data -
|
||||
* @fcc: full charge capacity (mAmpHour)
|
||||
* @fcc_temp_lut: table to get fcc at a given temp
|
||||
* @pc_temp_ocv_lut: table to get percent charge given batt temp and cycles
|
||||
* @pc_sf_lut: table to get percent charge scaling factor given cycles
|
||||
* and percent charge
|
||||
* @rbatt_sf_lut: table to get battery resistance scaling factor given
|
||||
* temperature and percent charge
|
||||
* @default_rbatt_mohm: the default value of battery resistance to use when
|
||||
* readings from bms are not available.
|
||||
* @delta_rbatt_mohm: the resistance to be added towards lower soc to
|
||||
* compensate for battery capacitance.
|
||||
*/
|
||||
|
||||
struct bms_battery_data {
|
||||
unsigned int fcc;
|
||||
struct single_row_lut *fcc_temp_lut;
|
||||
struct single_row_lut *fcc_sf_lut;
|
||||
struct pc_temp_ocv_lut *pc_temp_ocv_lut;
|
||||
struct sf_lut *pc_sf_lut;
|
||||
struct sf_lut *rbatt_sf_lut;
|
||||
int default_rbatt_mohm;
|
||||
int delta_rbatt_mohm;
|
||||
};
|
||||
|
||||
#if defined(CONFIG_PM8921_BMS) || \
|
||||
defined(CONFIG_PM8921_BMS_MODULE)
|
||||
extern struct bms_battery_data palladium_1500_data;
|
||||
extern struct bms_battery_data desay_5200_data;
|
||||
|
||||
int interpolate_fcc(struct single_row_lut *fcc_temp_lut, int batt_temp);
|
||||
int interpolate_scalingfactor(struct sf_lut *sf_lut, int row_entry, int pc);
|
||||
int interpolate_scalingfactor_fcc(struct single_row_lut *fcc_sf_lut,
|
||||
int cycles);
|
||||
int interpolate_pc(struct pc_temp_ocv_lut *pc_temp_ocv,
|
||||
int batt_temp_degc, int ocv);
|
||||
int interpolate_ocv(struct pc_temp_ocv_lut *pc_temp_ocv,
|
||||
int batt_temp_degc, int pc);
|
||||
int linear_interpolate(int y0, int x0, int y1, int x1, int x);
|
||||
int is_between(int left, int right, int value);
|
||||
#else
|
||||
static inline int interpolate_fcc(struct single_row_lut *fcc_temp_lut,
|
||||
int batt_temp)
|
||||
{
|
||||
return -EINVAL;
|
||||
}
|
||||
static inline int interpolate_scalingfactor(struct sf_lut *sf_lut,
|
||||
int row_entry, int pc)
|
||||
{
|
||||
return -EINVAL;
|
||||
}
|
||||
static inline int interpolate_scalingfactor_fcc(
|
||||
struct single_row_lut *fcc_sf_lut, int cycles)
|
||||
{
|
||||
return -EINVAL;
|
||||
}
|
||||
static inline int interpolate_pc(struct pc_temp_ocv_lut *pc_temp_ocv,
|
||||
int batt_temp_degc, int ocv)
|
||||
{
|
||||
return -EINVAL;
|
||||
}
|
||||
static inline int interpolate_ocv(struct pc_temp_ocv_lut *pc_temp_ocv,
|
||||
int batt_temp_degc, int pc)
|
||||
{
|
||||
return -EINVAL;
|
||||
}
|
||||
static inline int linear_interpolate(int y0, int x0, int y1, int x1, int x)
|
||||
{
|
||||
return -EINVAL;
|
||||
}
|
||||
static inline int is_between(int left, int right, int value)
|
||||
{
|
||||
return -EINVAL;
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -17,14 +17,20 @@
|
||||
|
||||
#define PM8XXX_CCADC_DEV_NAME "pm8xxx-ccadc"
|
||||
|
||||
struct pm8xxx_ccadc_core_data {
|
||||
unsigned int batt_temp_channel;
|
||||
};
|
||||
|
||||
/**
|
||||
* struct pm8xxx_ccadc_platform_data -
|
||||
* @r_sense: sense resistor value in (mOhms)
|
||||
* @ccadc_cdata: core data for the ccadc driver containing channel info
|
||||
* @r_sense_uohm: sense resistor value in (micro Ohms)
|
||||
* @calib_delay_ms: how often should the adc calculate gain and offset
|
||||
*/
|
||||
struct pm8xxx_ccadc_platform_data {
|
||||
int r_sense;
|
||||
unsigned int calib_delay_ms;
|
||||
struct pm8xxx_ccadc_core_data ccadc_cdata;
|
||||
int r_sense_uohm;
|
||||
unsigned int calib_delay_ms;
|
||||
};
|
||||
|
||||
#define CCADC_READING_RESOLUTION_N 542535
|
||||
|
||||
@@ -75,6 +75,27 @@ enum pm8xxx_version {
|
||||
#define PM8XXX_REVISION_8917_TEST 0
|
||||
#define PM8XXX_REVISION_8917_1p0 1
|
||||
|
||||
#define PM8XXX_RESTART_UNKNOWN 0
|
||||
#define PM8XXX_RESTART_CBL 1
|
||||
#define PM8XXX_RESTART_KPD 2
|
||||
#define PM8XXX_RESTART_CHG 3
|
||||
#define PM8XXX_RESTART_SMPL 4
|
||||
#define PM8XXX_RESTART_RTC 5
|
||||
#define PM8XXX_RESTART_HARD_RESET 6
|
||||
#define PM8XXX_RESTART_GEN_PURPOSE 7
|
||||
#define PM8XXX_RESTART_REASON_MASK 0x07
|
||||
|
||||
static const char * const pm8xxx_restart_reason_str[] = {
|
||||
[0] = "Unknown",
|
||||
[1] = "Triggered from CBL (external charger)",
|
||||
[2] = "Triggered from KPD (power key press)",
|
||||
[3] = "Triggered from CHG (usb charger insertion)",
|
||||
[4] = "Triggered from SMPL (sudden momentary power loss)",
|
||||
[5] = "Triggered from RTC (real time clock)",
|
||||
[6] = "Triggered by Hard Reset",
|
||||
[7] = "Triggered by General Purpose Trigger",
|
||||
};
|
||||
|
||||
struct pm8xxx_drvdata {
|
||||
int (*pmic_readb) (const struct device *dev,
|
||||
u16 addr, u8 *val);
|
||||
@@ -88,6 +109,8 @@ struct pm8xxx_drvdata {
|
||||
int irq);
|
||||
enum pm8xxx_version (*pmic_get_version) (const struct device *dev);
|
||||
int (*pmic_get_revision) (const struct device *dev);
|
||||
u8 (*pmic_restart_reason)
|
||||
(const struct device *dev);
|
||||
void *pm_chip_data;
|
||||
};
|
||||
|
||||
@@ -156,4 +179,12 @@ static inline int pm8xxx_get_revision(const struct device *dev)
|
||||
return dd->pmic_get_revision(dev);
|
||||
}
|
||||
|
||||
static inline u8 pm8xxx_restart_reason(const struct device *dev)
|
||||
{
|
||||
struct pm8xxx_drvdata *dd = dev_get_drvdata(dev);
|
||||
|
||||
if (!dd)
|
||||
return -EINVAL;
|
||||
return dd->pmic_restart_reason(dev);
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* Copyright (c) 2011-2012, Code Aurora Forum. All rights reserved.
|
||||
/* Copyright (c) 2011-2013, Code Aurora Forum. All rights reserved.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 and
|
||||
@@ -14,87 +14,10 @@
|
||||
#define __PM8XXX_BMS_H
|
||||
|
||||
#include <linux/errno.h>
|
||||
#include <linux/mfd/pm8xxx/batterydata-lib.h>
|
||||
|
||||
#define PM8921_BMS_DEV_NAME "pm8921-bms"
|
||||
|
||||
#define FCC_CC_COLS 5
|
||||
#define FCC_TEMP_COLS 8
|
||||
|
||||
#define PC_CC_ROWS 29
|
||||
#define PC_CC_COLS 13
|
||||
|
||||
#define PC_TEMP_ROWS 29
|
||||
#define PC_TEMP_COLS 8
|
||||
|
||||
#define MAX_SINGLE_LUT_COLS 20
|
||||
|
||||
struct single_row_lut {
|
||||
int x[MAX_SINGLE_LUT_COLS];
|
||||
int y[MAX_SINGLE_LUT_COLS];
|
||||
int cols;
|
||||
};
|
||||
|
||||
/**
|
||||
* struct sf_lut -
|
||||
* @rows: number of percent charge entries should be <= PC_CC_ROWS
|
||||
* @cols: number of charge cycle entries should be <= PC_CC_COLS
|
||||
* @row_entries: the charge cycles/temperature at which sf data
|
||||
* is available in the table.
|
||||
* The charge cycles must be in increasing order from 0 to rows.
|
||||
* @percent: the percent charge at which sf data is available in the table
|
||||
* The percentcharge must be in decreasing order from 0 to cols.
|
||||
* @sf: the scaling factor data
|
||||
*/
|
||||
struct sf_lut {
|
||||
int rows;
|
||||
int cols;
|
||||
int row_entries[PC_CC_COLS];
|
||||
int percent[PC_CC_ROWS];
|
||||
int sf[PC_CC_ROWS][PC_CC_COLS];
|
||||
};
|
||||
|
||||
/**
|
||||
* struct pc_temp_ocv_lut -
|
||||
* @rows: number of percent charge entries should be <= PC_TEMP_ROWS
|
||||
* @cols: number of temperature entries should be <= PC_TEMP_COLS
|
||||
* @temp: the temperatures at which ocv data is available in the table
|
||||
* The temperatures must be in increasing order from 0 to rows.
|
||||
* @percent: the percent charge at which ocv data is available in the table
|
||||
* The percentcharge must be in decreasing order from 0 to cols.
|
||||
* @ocv: the open circuit voltage
|
||||
*/
|
||||
struct pc_temp_ocv_lut {
|
||||
int rows;
|
||||
int cols;
|
||||
int temp[PC_TEMP_COLS];
|
||||
int percent[PC_TEMP_ROWS];
|
||||
int ocv[PC_TEMP_ROWS][PC_TEMP_COLS];
|
||||
};
|
||||
|
||||
/**
|
||||
* struct pm8921_bms_battery_data -
|
||||
* @fcc: full charge capacity (mAmpHour)
|
||||
* @fcc_temp_lut: table to get fcc at a given temp
|
||||
* @pc_temp_ocv_lut: table to get percent charge given batt temp and cycles
|
||||
* @pc_sf_lut: table to get percent charge scaling factor given cycles
|
||||
* and percent charge
|
||||
* @rbatt_sf_lut: table to get battery resistance scaling factor given
|
||||
* temperature and percent charge
|
||||
* @default_rbatt_mohm: the default value of battery resistance to use when
|
||||
* readings from bms are not available.
|
||||
* @delta_rbatt_mohm: the resistance to be added towards lower soc to
|
||||
* compensate for battery capacitance.
|
||||
*/
|
||||
struct pm8921_bms_battery_data {
|
||||
unsigned int fcc;
|
||||
struct single_row_lut *fcc_temp_lut;
|
||||
struct single_row_lut *fcc_sf_lut;
|
||||
struct pc_temp_ocv_lut *pc_temp_ocv_lut;
|
||||
struct sf_lut *pc_sf_lut;
|
||||
struct sf_lut *rbatt_sf_lut;
|
||||
int default_rbatt_mohm;
|
||||
int delta_rbatt_mohm;
|
||||
};
|
||||
|
||||
struct pm8xxx_bms_core_data {
|
||||
unsigned int batt_temp_channel;
|
||||
@@ -104,27 +27,25 @@ struct pm8xxx_bms_core_data {
|
||||
unsigned int batt_id_channel;
|
||||
};
|
||||
|
||||
enum battery_type {
|
||||
BATT_UNKNOWN = 0,
|
||||
BATT_PALLADIUM,
|
||||
BATT_DESAY,
|
||||
};
|
||||
|
||||
/**
|
||||
* struct pm8921_bms_platform_data -
|
||||
* @batt_type: allows to force chose battery calibration data
|
||||
* @r_sense: sense resistor value in (mOhms)
|
||||
* @r_sense_uohm: sense resistor value in (micro Ohms)
|
||||
* @i_test: current at which the unusable charger cutoff is to be
|
||||
* calculated or the peak system current (mA)
|
||||
* @v_cutoff: the loaded voltage at which the battery
|
||||
* is considered empty(mV)
|
||||
* @enable_fcc_learning: if set the driver will learn full charge
|
||||
* capacity of the battery upon end of charge
|
||||
* @normal_voltage_calc_ms: The period of soc calculation in ms when battery
|
||||
* voltage higher than cutoff voltage
|
||||
* @low_voltage_calc_ms: The period of soc calculation in ms when battery
|
||||
* voltage is near cutoff voltage
|
||||
*/
|
||||
struct pm8921_bms_platform_data {
|
||||
struct pm8xxx_bms_core_data bms_cdata;
|
||||
enum battery_type battery_type;
|
||||
unsigned int r_sense;
|
||||
int r_sense_uohm;
|
||||
unsigned int i_test;
|
||||
unsigned int v_cutoff;
|
||||
unsigned int max_voltage_uv;
|
||||
@@ -134,11 +55,11 @@ struct pm8921_bms_platform_data {
|
||||
int ignore_shutdown_soc;
|
||||
int adjust_soc_low_threshold;
|
||||
int chg_term_ua;
|
||||
int normal_voltage_calc_ms;
|
||||
int low_voltage_calc_ms;
|
||||
};
|
||||
|
||||
#if defined(CONFIG_PM8921_BMS) || defined(CONFIG_PM8921_BMS_MODULE)
|
||||
extern struct pm8921_bms_battery_data palladium_1500_data;
|
||||
extern struct pm8921_bms_battery_data desay_5200_data;
|
||||
/**
|
||||
* pm8921_bms_get_vsense_avg - return the voltage across the sense
|
||||
* resitor in microvolts
|
||||
@@ -202,9 +123,11 @@ void pm8921_bms_calibrate_hkadc(void);
|
||||
int pm8921_bms_get_simultaneous_battery_voltage_and_current(int *ibat_ua,
|
||||
int *vbat_uv);
|
||||
/**
|
||||
* pm8921_bms_get_rbatt - function to get the battery resistance in mOhm.
|
||||
* pm8921_bms_get_current_max
|
||||
* - function to get the max current that can be drawn from
|
||||
* the battery before it dips below the min allowed voltage
|
||||
*/
|
||||
int pm8921_bms_get_rbatt(void);
|
||||
int pm8921_bms_get_current_max(void);
|
||||
/**
|
||||
* pm8921_bms_invalidate_shutdown_soc - function to notify the bms driver that
|
||||
* the battery was replaced between reboot
|
||||
@@ -212,6 +135,15 @@ int pm8921_bms_get_rbatt(void);
|
||||
* soc stored in a coincell backed register
|
||||
*/
|
||||
void pm8921_bms_invalidate_shutdown_soc(void);
|
||||
|
||||
/**
|
||||
* pm8921_bms_cc_uah - function to get the coulomb counter based charge. Note
|
||||
* that the coulomb counter are reset when the current
|
||||
* consumption is low (below 8mA for more than 5 minutes),
|
||||
* This will lead in a very low coulomb counter charge
|
||||
* value upon wakeup from sleep.
|
||||
*/
|
||||
int pm8921_bms_cc_uah(int *cc_uah);
|
||||
#else
|
||||
static inline int pm8921_bms_get_vsense_avg(int *result)
|
||||
{
|
||||
@@ -250,6 +182,14 @@ static inline int pm8921_bms_get_rbatt(void)
|
||||
static inline void pm8921_bms_invalidate_shutdown_soc(void)
|
||||
{
|
||||
}
|
||||
static inline int pm8921_bms_cc_uah(int *cc_uah)
|
||||
{
|
||||
return -ENXIO;
|
||||
}
|
||||
static inline int pm8921_bms_get_current_max(void)
|
||||
{
|
||||
return -ENXIO;
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
@@ -58,19 +58,25 @@ enum pm8921_chg_led_src_config {
|
||||
|
||||
/**
|
||||
* struct pm8921_charger_platform_data -
|
||||
* @safety_time: max charging time in minutes incl. fast and trkl
|
||||
* valid range 4 to 512 min. PON default 120 min
|
||||
* @ttrkl_time: max trckl charging time in minutes
|
||||
* valid range 1 to 64 mins. PON default 15 min
|
||||
* @update_time: how often the userland be updated of the charging (msec)
|
||||
* @alarm_voltage: the voltage (mV) when lower battery alarm is triggered
|
||||
* @alarm_low_mv: the voltage (mV) when low battery alarm is triggered
|
||||
* @alarm_high_mv: the voltage (mV) when high battery alarm is triggered
|
||||
* @max_voltage: the max voltage (mV) the battery should be charged up to
|
||||
* @min_voltage: the voltage (mV) where charging method switches from
|
||||
* trickle to fast. This is also the minimum voltage the
|
||||
* system operates at
|
||||
* @uvd_thresh_voltage: the USB falling UVD threshold (mV) (PM8917 only)
|
||||
* @safe_current_ma: The upper limit of current allowed to be pushed in
|
||||
* battery. This ends up writing in a one time
|
||||
* programmable register.
|
||||
* @resume_voltage_delta: the (mV) drop to wait for before resume charging
|
||||
* after the battery has been fully charged
|
||||
* @resume_charge_percent: the % SOC the charger will drop to after the
|
||||
* battery is fully charged before resuming
|
||||
* charging.
|
||||
* @term_current: the charger current (mA) at which EOC happens
|
||||
* @cool_temp: the temperature (degC) at which the battery is
|
||||
* considered cool charging current and voltage is reduced.
|
||||
@@ -83,6 +89,7 @@ enum pm8921_chg_led_src_config {
|
||||
* area
|
||||
* @max_bat_chg_current: Max charge current of the battery in mA
|
||||
* Usually 70% of full charge capacity
|
||||
* @usb_max_current: Maximum USB current in mA
|
||||
* @cool_bat_chg_current: chg current (mA) when the battery is cool
|
||||
* @warm_bat_chg_current: chg current (mA) when the battery is warm
|
||||
* @cool_bat_voltage: chg voltage (mV) when the battery is cool
|
||||
@@ -90,10 +97,6 @@ enum pm8921_chg_led_src_config {
|
||||
* @get_batt_capacity_percent:
|
||||
* a board specific function to return battery
|
||||
* capacity. If null - a default one will be used
|
||||
* @dc_unplug_check: enables the reverse boosting fix for the DC_IN line
|
||||
* however, this should only be enabled for devices which
|
||||
* control the DC OVP FETs otherwise this option should
|
||||
* remain disabled
|
||||
* @has_dc_supply: report DC online if this bit is set in board file
|
||||
* @trkl_voltage: the trkl voltage in (mV) below which hw controlled
|
||||
* trkl charging happens with linear charger
|
||||
@@ -120,22 +123,44 @@ enum pm8921_chg_led_src_config {
|
||||
* resistance of the pads, connectors, battery terminals
|
||||
* and rsense.
|
||||
* @led_src_config: Power source for anode of charger indicator LED.
|
||||
* @btc_override: disable the comparators for conifugrations where a
|
||||
* suitable voltages don't appear on vbatt therm line
|
||||
* for the charger to detect battery is either cold / hot.
|
||||
* @btc_override_cold_degc: Temperature in degCelcius when the battery is
|
||||
* deemed cold and charging never happens. Used
|
||||
* only if btc_override = 1
|
||||
* @btc_override_hot_degc: Temperature in degCelcius when the battery is
|
||||
* deemed hot and charging never happens. Used
|
||||
* only if btc_override = 1
|
||||
* @btc_delay_ms: Delay in milliseconds to monitor the battery temperature
|
||||
* while charging when btc_override = 1
|
||||
* @btc_panic_if_cant_stop_chg: flag to instruct the driver to panic if the
|
||||
* driver couldn't stop charging when battery
|
||||
* temperature is out of bounds. Used only if
|
||||
* btc_override = 1
|
||||
* stop_chg_upon_expiry: flag to indicate that the charger driver should
|
||||
* stop charging the battery when the safety timer
|
||||
* expires. If not set the charger driver will
|
||||
* restart charging upon expiry.
|
||||
*/
|
||||
struct pm8921_charger_platform_data {
|
||||
struct pm8xxx_charger_core_data charger_cdata;
|
||||
unsigned int safety_time;
|
||||
unsigned int ttrkl_time;
|
||||
unsigned int update_time;
|
||||
unsigned int max_voltage;
|
||||
unsigned int min_voltage;
|
||||
unsigned int uvd_thresh_voltage;
|
||||
unsigned int alarm_voltage;
|
||||
unsigned int safe_current_ma;
|
||||
unsigned int alarm_low_mv;
|
||||
unsigned int alarm_high_mv;
|
||||
unsigned int resume_voltage_delta;
|
||||
int resume_charge_percent;
|
||||
unsigned int term_current;
|
||||
int cool_temp;
|
||||
int warm_temp;
|
||||
unsigned int temp_check_period;
|
||||
unsigned int max_bat_chg_current;
|
||||
unsigned int usb_max_current;
|
||||
unsigned int cool_bat_chg_current;
|
||||
unsigned int warm_bat_chg_current;
|
||||
unsigned int cool_bat_voltage;
|
||||
@@ -144,7 +169,6 @@ struct pm8921_charger_platform_data {
|
||||
int64_t batt_id_min;
|
||||
int64_t batt_id_max;
|
||||
bool keep_btm_on_suspend;
|
||||
bool dc_unplug_check;
|
||||
bool has_dc_supply;
|
||||
int trkl_voltage;
|
||||
int weak_voltage;
|
||||
@@ -157,6 +181,13 @@ struct pm8921_charger_platform_data {
|
||||
enum pm8921_chg_hot_thr hot_thr;
|
||||
int rconn_mohm;
|
||||
enum pm8921_chg_led_src_config led_src_config;
|
||||
int battery_less_hardware;
|
||||
int btc_override;
|
||||
int btc_override_cold_degc;
|
||||
int btc_override_hot_degc;
|
||||
int btc_delay_ms;
|
||||
int btc_panic_if_cant_stop_chg;
|
||||
int stop_chg_upon_expiry;
|
||||
};
|
||||
|
||||
enum pm8921_charger_source {
|
||||
@@ -169,15 +200,6 @@ enum pm8921_charger_source {
|
||||
void pm8921_charger_vbus_draw(unsigned int mA);
|
||||
int pm8921_charger_register_vbus_sn(void (*callback)(int));
|
||||
void pm8921_charger_unregister_vbus_sn(void (*callback)(int));
|
||||
/**
|
||||
* pm8921_charger_enable -
|
||||
*
|
||||
* @enable: 1 means enable charging, 0 means disable
|
||||
*
|
||||
* Enable/Disable battery charging current, the device will still draw current
|
||||
* from the charging source
|
||||
*/
|
||||
int pm8921_charger_enable(bool enable);
|
||||
|
||||
/**
|
||||
* pm8921_is_usb_chg_plugged_in - is usb plugged in
|
||||
@@ -309,10 +331,6 @@ static inline int pm8921_charger_register_vbus_sn(void (*callback)(int))
|
||||
static inline void pm8921_charger_unregister_vbus_sn(void (*callback)(int))
|
||||
{
|
||||
}
|
||||
static inline int pm8921_charger_enable(bool enable)
|
||||
{
|
||||
return -ENXIO;
|
||||
}
|
||||
static inline int pm8921_is_usb_chg_plugged_in(void)
|
||||
{
|
||||
return -ENXIO;
|
||||
|
||||
Reference in New Issue
Block a user