#include <linux/bits.h>
#include <linux/delay.h>
#include <linux/devm-helpers.h>
#include <linux/err.h>
#include <linux/gpio/consumer.h>
#include <linux/i2c.h>
#include <linux/init.h>
#include <linux/interrupt.h>
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/property.h>
#include <linux/of.h>
#include <linux/power/sbs-battery.h>
#include <linux/power_supply.h>
#include <linux/slab.h>
#include <linux/stat.h>
enum { … };
#define REG_ADDR_SPEC_INFO …
#define SPEC_INFO_VERSION_MASK …
#define SPEC_INFO_VERSION_SHIFT …
#define SBS_VERSION_1_0 …
#define SBS_VERSION_1_1 …
#define SBS_VERSION_1_1_WITH_PEC …
#define REG_ADDR_MANUFACTURE_DATE …
#define BATTERY_MODE_OFFSET …
#define BATTERY_MODE_CAPACITY_MASK …
enum sbs_capacity_mode { … };
#define BATTERY_MODE_CHARGER_MASK …
#define MANUFACTURER_ACCESS_STATUS …
#define MANUFACTURER_ACCESS_SLEEP …
#define BATTERY_INITIALIZED …
#define BATTERY_DISCHARGING …
#define BATTERY_FULL_CHARGED …
#define BATTERY_FULL_DISCHARGED …
#define SBS_DATA(_psp, _addr, _min_value, _max_value) …
static const struct chip_data { … } sbs_data[] = …;
static const enum power_supply_property sbs_properties[] = …;
#define SBS_FLAGS_TI_BQ20ZX5 …
static const enum power_supply_property string_properties[] = …;
#define NR_STRING_BUFFERS …
struct sbs_info { … };
static char *sbs_get_string_buf(struct sbs_info *chip,
enum power_supply_property psp)
{ … }
static void sbs_invalidate_cached_props(struct sbs_info *chip)
{ … }
static bool force_load;
static int sbs_read_word_data(struct i2c_client *client, u8 address);
static int sbs_write_word_data(struct i2c_client *client, u8 address, u16 value);
static void sbs_disable_charger_broadcasts(struct sbs_info *chip)
{ … }
static int sbs_update_presence(struct sbs_info *chip, bool is_present)
{ … }
static int sbs_read_word_data(struct i2c_client *client, u8 address)
{ … }
static int sbs_read_string_data_fallback(struct i2c_client *client, u8 address, char *values)
{ … }
static int sbs_read_string_data(struct i2c_client *client, u8 address, char *values)
{ … }
static int sbs_write_word_data(struct i2c_client *client, u8 address,
u16 value)
{ … }
static int sbs_status_correct(struct i2c_client *client, int *intval)
{ … }
static bool sbs_bat_needs_calibration(struct i2c_client *client)
{ … }
static int sbs_get_ti_battery_presence_and_health(
struct i2c_client *client, enum power_supply_property psp,
union power_supply_propval *val)
{ … }
static int sbs_get_battery_presence_and_health(
struct i2c_client *client, enum power_supply_property psp,
union power_supply_propval *val)
{ … }
static int sbs_get_battery_property(struct i2c_client *client,
int reg_offset, enum power_supply_property psp,
union power_supply_propval *val)
{ … }
static int sbs_get_property_index(struct i2c_client *client,
enum power_supply_property psp)
{ … }
static const char *sbs_get_constant_string(struct sbs_info *chip,
enum power_supply_property psp)
{ … }
static void sbs_unit_adjustment(struct i2c_client *client,
enum power_supply_property psp, union power_supply_propval *val)
{ … }
static enum sbs_capacity_mode sbs_set_capacity_mode(struct i2c_client *client,
enum sbs_capacity_mode mode)
{ … }
static int sbs_get_battery_capacity(struct i2c_client *client,
int reg_offset, enum power_supply_property psp,
union power_supply_propval *val)
{ … }
static char sbs_serial[5];
static int sbs_get_battery_serial_number(struct i2c_client *client,
union power_supply_propval *val)
{ … }
static int sbs_get_chemistry(struct sbs_info *chip,
union power_supply_propval *val)
{ … }
static int sbs_get_battery_manufacture_date(struct i2c_client *client,
enum power_supply_property psp,
union power_supply_propval *val)
{ … }
static int sbs_get_property(struct power_supply *psy,
enum power_supply_property psp,
union power_supply_propval *val)
{ … }
static void sbs_supply_changed(struct sbs_info *chip)
{ … }
static irqreturn_t sbs_irq(int irq, void *devid)
{ … }
static void sbs_alert(struct i2c_client *client, enum i2c_alert_protocol prot,
unsigned int data)
{ … }
static void sbs_external_power_changed(struct power_supply *psy)
{ … }
static void sbs_delayed_work(struct work_struct *work)
{ … }
static const struct power_supply_desc sbs_default_desc = …;
static int sbs_probe(struct i2c_client *client)
{ … }
#if defined CONFIG_PM_SLEEP
static int sbs_suspend(struct device *dev)
{ … }
static SIMPLE_DEV_PM_OPS(sbs_pm_ops, sbs_suspend, NULL);
#define SBS_PM_OPS …
#else
#define SBS_PM_OPS …
#endif
static const struct i2c_device_id sbs_id[] = …;
MODULE_DEVICE_TABLE(i2c, sbs_id);
static const struct of_device_id sbs_dt_ids[] = …;
MODULE_DEVICE_TABLE(of, sbs_dt_ids);
static struct i2c_driver sbs_battery_driver = …;
module_i2c_driver(…) …;
MODULE_DESCRIPTION(…) …;
MODULE_LICENSE(…) …;
module_param(force_load, bool, 0444);
MODULE_PARM_DESC(…) …;