#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/platform_device.h>
#include <linux/slab.h>
#include <linux/mutex.h>
#include <linux/string.h>
#include <linux/power_supply.h>
#include <linux/mfd/88pm860x.h>
#include <linux/delay.h>
#define STATUS2_CHG …
#define STATUS2_BAT …
#define STATUS2_VBUS …
#define MEAS1_TINT …
#define MEAS1_GP1 …
#define MEAS3_IBAT …
#define MEAS3_BAT_DET …
#define MEAS3_CC …
#define MEAS_OFF_SLEEP_EN …
#define GPBIAS2_GPADC1_SET …
#define GPBIAS2_GPADC1_UA …
#define GPMISC1_GPADC_EN …
#define CC6_BAT_DET_GPADC1 …
#define CCNT_AVG_SEL …
#define RTC_SOC_5LSB …
#define RTC_SOC_3MSB …
#define BAT_WU_LOG …
#define CCNT_POS1 …
#define CCNT_POS2 …
#define CCNT_NEG1 …
#define CCNT_NEG2 …
#define CCNT_SPOS …
#define CCNT_SNEG …
#define OCV_MODE_ACTIVE …
#define OCV_MODE_SLEEP …
#define LOW_BAT_THRESHOLD …
#define VBATT_RESISTOR_MIN …
#define VBATT_RESISTOR_MAX …
#define PM860X_TEMP_TINT …
#define PM860X_TEMP_TBAT …
#define TBAT_NEG_25D …
#define TBAT_NEG_10D …
#define TBAT_0D …
#define TBAT_10D …
#define TBAT_20D …
#define TBAT_30D …
#define TBAT_40D …
struct pm860x_battery_info { … };
struct ccnt { … };
static int array_soc[][2] = …;
static struct ccnt ccnt_data;
static int measure_12bit_voltage(struct pm860x_battery_info *info,
int offset, int *data)
{ … }
static int measure_vbatt(struct pm860x_battery_info *info, int state,
int *data)
{ … }
static int measure_current(struct pm860x_battery_info *info, int *data)
{ … }
static int set_charger_current(struct pm860x_battery_info *info, int data,
int *old)
{ … }
static int read_ccnt(struct pm860x_battery_info *info, int offset,
int *ccnt)
{ … }
static int calc_ccnt(struct pm860x_battery_info *info, struct ccnt *ccnt)
{ … }
static int clear_ccnt(struct pm860x_battery_info *info, struct ccnt *ccnt)
{ … }
static int calc_ocv(struct pm860x_battery_info *info, int *ocv)
{ … }
static int calc_soc(struct pm860x_battery_info *info, int state, int *soc)
{ … }
static irqreturn_t pm860x_coulomb_handler(int irq, void *data)
{ … }
static irqreturn_t pm860x_batt_handler(int irq, void *data)
{ … }
static void pm860x_init_battery(struct pm860x_battery_info *info)
{ … }
static void set_temp_threshold(struct pm860x_battery_info *info,
int min, int max)
{ … }
static int measure_temp(struct pm860x_battery_info *info, int *data)
{ … }
static int calc_resistor(struct pm860x_battery_info *info)
{ … }
static int calc_capacity(struct pm860x_battery_info *info, int *cap)
{ … }
static void pm860x_external_power_changed(struct power_supply *psy)
{ … }
static int pm860x_batt_get_prop(struct power_supply *psy,
enum power_supply_property psp,
union power_supply_propval *val)
{ … }
static int pm860x_batt_set_prop(struct power_supply *psy,
enum power_supply_property psp,
const union power_supply_propval *val)
{ … }
static enum power_supply_property pm860x_batt_props[] = …;
static const struct power_supply_desc pm860x_battery_desc = …;
static int pm860x_battery_probe(struct platform_device *pdev)
{ … }
#ifdef CONFIG_PM_SLEEP
static int pm860x_battery_suspend(struct device *dev)
{ … }
static int pm860x_battery_resume(struct device *dev)
{ … }
#endif
static SIMPLE_DEV_PM_OPS(pm860x_battery_pm_ops,
pm860x_battery_suspend, pm860x_battery_resume);
static struct platform_driver pm860x_battery_driver = …;
module_platform_driver(…) …;
MODULE_DESCRIPTION(…) …;
MODULE_LICENSE(…) …;