#include <linux/delay.h>
#include <linux/err.h>
#include <linux/interrupt.h>
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/of.h>
#include <linux/platform_device.h>
#include <linux/power_supply.h>
#include <linux/reboot.h>
#include <linux/regmap.h>
#include <linux/nvmem-consumer.h>
#include <linux/moduleparam.h>
#include <linux/iio/consumer.h>
#include <linux/iio/types.h>
#include <linux/mfd/motorola-cpcap.h>
#define CPCAP_REG_BPEOL_BIT_EOL9 …
#define CPCAP_REG_BPEOL_BIT_EOL8 …
#define CPCAP_REG_BPEOL_BIT_UNKNOWN7 …
#define CPCAP_REG_BPEOL_BIT_UNKNOWN6 …
#define CPCAP_REG_BPEOL_BIT_UNKNOWN5 …
#define CPCAP_REG_BPEOL_BIT_EOL_MULTI …
#define CPCAP_REG_BPEOL_BIT_UNKNOWN3 …
#define CPCAP_REG_BPEOL_BIT_UNKNOWN2 …
#define CPCAP_REG_BPEOL_BIT_BATTDETEN …
#define CPCAP_REG_BPEOL_BIT_EOLSEL …
#define CPCAP_REG_CCC1_ACTIVE_MODE1 …
#define CPCAP_REG_CCC1_ACTIVE_MODE0 …
#define CPCAP_REG_CCC1_AUTOCLEAR …
#define CPCAP_REG_CCC1_CAL_EN …
#define CPCAP_REG_CCC1_PAUSE …
#define CPCAP_REG_CCC1_RESET_MASK …
#define CPCAP_REG_CCCC2_RATE1 …
#define CPCAP_REG_CCCC2_RATE0 …
#define CPCAP_REG_CCCC2_ENABLE …
#define CPCAP_BATTERY_CC_SAMPLE_PERIOD_MS …
#define CPCAP_BATTERY_EB41_HW4X_ID …
#define CPCAP_BATTERY_BW8X_ID …
enum { … };
enum cpcap_battery_irq_action { … };
struct cpcap_interrupt_desc { … };
struct cpcap_battery_config { … };
struct cpcap_coulomb_counter_data { … };
enum cpcap_battery_state { … };
struct cpcap_battery_state_data { … };
struct cpcap_battery_ddata { … };
#define CPCAP_NO_BATTERY …
static bool ignore_temperature_probe;
module_param(ignore_temperature_probe, bool, 0660);
static struct cpcap_battery_state_data *
cpcap_battery_get_state(struct cpcap_battery_ddata *ddata,
enum cpcap_battery_state state)
{ … }
static struct cpcap_battery_state_data *
cpcap_battery_latest(struct cpcap_battery_ddata *ddata)
{ … }
static struct cpcap_battery_state_data *
cpcap_battery_previous(struct cpcap_battery_ddata *ddata)
{ … }
static struct cpcap_battery_state_data *
cpcap_battery_get_empty(struct cpcap_battery_ddata *ddata)
{ … }
static struct cpcap_battery_state_data *
cpcap_battery_get_full(struct cpcap_battery_ddata *ddata)
{ … }
static int cpcap_charger_battery_temperature(struct cpcap_battery_ddata *ddata,
int *value)
{ … }
static int cpcap_battery_get_voltage(struct cpcap_battery_ddata *ddata)
{ … }
static int cpcap_battery_get_current(struct cpcap_battery_ddata *ddata)
{ … }
static int cpcap_battery_cc_raw_div(struct cpcap_battery_ddata *ddata,
s32 sample, s32 accumulator,
s16 offset, u32 divider)
{ … }
static int cpcap_battery_cc_to_uah(struct cpcap_battery_ddata *ddata,
s32 sample, s32 accumulator,
s16 offset)
{ … }
static int cpcap_battery_cc_to_ua(struct cpcap_battery_ddata *ddata,
s32 sample, s32 accumulator,
s16 offset)
{ … }
static int
cpcap_battery_read_accumulated(struct cpcap_battery_ddata *ddata,
struct cpcap_coulomb_counter_data *ccd)
{ … }
static const struct cpcap_battery_config cpcap_battery_eb41_data = …;
static const struct cpcap_battery_config cpcap_battery_bw8x_data = …;
static const struct cpcap_battery_config cpcap_battery_unkown_data = …;
static int cpcap_battery_match_nvmem(struct device *dev, const void *data)
{ … }
static void cpcap_battery_detect_battery_type(struct cpcap_battery_ddata *ddata)
{ … }
static int cpcap_battery_cc_get_avg_current(struct cpcap_battery_ddata *ddata)
{ … }
static int cpcap_battery_get_charger_status(struct cpcap_battery_ddata *ddata,
int *val)
{ … }
static bool cpcap_battery_full(struct cpcap_battery_ddata *ddata)
{ … }
static bool cpcap_battery_low(struct cpcap_battery_ddata *ddata)
{ … }
static int cpcap_battery_update_status(struct cpcap_battery_ddata *ddata)
{ … }
static void cpcap_battery_external_power_changed(struct power_supply *psy)
{ … }
static enum power_supply_property cpcap_battery_props[] = …;
static int cpcap_battery_get_property(struct power_supply *psy,
enum power_supply_property psp,
union power_supply_propval *val)
{ … }
static int cpcap_battery_update_charger(struct cpcap_battery_ddata *ddata,
int const_charge_voltage)
{ … }
static int cpcap_battery_set_property(struct power_supply *psy,
enum power_supply_property psp,
const union power_supply_propval *val)
{ … }
static int cpcap_battery_property_is_writeable(struct power_supply *psy,
enum power_supply_property psp)
{ … }
static irqreturn_t cpcap_battery_irq_thread(int irq, void *data)
{ … }
static int cpcap_battery_init_irq(struct platform_device *pdev,
struct cpcap_battery_ddata *ddata,
const char *name)
{ … }
static int cpcap_battery_init_interrupts(struct platform_device *pdev,
struct cpcap_battery_ddata *ddata)
{ … }
static int cpcap_battery_init_iio(struct cpcap_battery_ddata *ddata)
{ … }
static int cpcap_battery_calibrate(struct cpcap_battery_ddata *ddata)
{ … }
#ifdef CONFIG_OF
static const struct of_device_id cpcap_battery_id_table[] = …;
MODULE_DEVICE_TABLE(of, cpcap_battery_id_table);
#endif
static const struct power_supply_desc cpcap_charger_battery_desc = …;
static int cpcap_battery_probe(struct platform_device *pdev)
{ … }
static void cpcap_battery_remove(struct platform_device *pdev)
{ … }
static struct platform_driver cpcap_battery_driver = …;
module_platform_driver(…) …;
MODULE_LICENSE(…) …;
MODULE_AUTHOR(…) …;
MODULE_DESCRIPTION(…) …;