#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/param.h>
#include <linux/err.h>
#include <linux/workqueue.h>
#include <linux/sysfs.h>
#include <linux/platform_device.h>
#include <linux/power_supply.h>
#include <linux/idr.h>
#include <linux/i2c.h>
#include <linux/slab.h>
#include <linux/acpi.h>
#include <linux/power/bq2415x_charger.h>
#define BQ2415X_TIMER_TIMEOUT …
#define BQ2415X_REG_STATUS …
#define BQ2415X_REG_CONTROL …
#define BQ2415X_REG_VOLTAGE …
#define BQ2415X_REG_VENDER …
#define BQ2415X_REG_CURRENT …
#define BQ2415X_RESET_STATUS …
#define BQ2415X_RESET_CONTROL …
#define BQ2415X_RESET_VOLTAGE …
#define BQ2415X_RESET_CURRENT …
#define BQ2415X_BIT_TMR_RST …
#define BQ2415X_BIT_OTG …
#define BQ2415X_BIT_EN_STAT …
#define BQ2415X_MASK_STAT …
#define BQ2415X_SHIFT_STAT …
#define BQ2415X_BIT_BOOST …
#define BQ2415X_MASK_FAULT …
#define BQ2415X_SHIFT_FAULT …
#define BQ2415X_MASK_LIMIT …
#define BQ2415X_SHIFT_LIMIT …
#define BQ2415X_MASK_VLOWV …
#define BQ2415X_SHIFT_VLOWV …
#define BQ2415X_BIT_TE …
#define BQ2415X_BIT_CE …
#define BQ2415X_BIT_HZ_MODE …
#define BQ2415X_BIT_OPA_MODE …
#define BQ2415X_MASK_VO …
#define BQ2415X_SHIFT_VO …
#define BQ2415X_BIT_OTG_PL …
#define BQ2415X_BIT_OTG_EN …
#define BQ2415X_MASK_VENDER …
#define BQ2415X_SHIFT_VENDER …
#define BQ2415X_MASK_PN …
#define BQ2415X_SHIFT_PN …
#define BQ2415X_MASK_REVISION …
#define BQ2415X_SHIFT_REVISION …
#define BQ2415X_MASK_RESET …
#define BQ2415X_MASK_VI_CHRG …
#define BQ2415X_SHIFT_VI_CHRG …
#define BQ2415X_MASK_VI_TERM …
#define BQ2415X_SHIFT_VI_TERM …
enum bq2415x_command { … };
enum bq2415x_chip { … };
static char *bq2415x_chip_name[] = …;
struct bq2415x_device { … };
static DEFINE_IDR(bq2415x_id);
static DEFINE_MUTEX(bq2415x_id_mutex);
static DEFINE_MUTEX(bq2415x_timer_mutex);
static DEFINE_MUTEX(bq2415x_i2c_mutex);
static int bq2415x_i2c_read(struct bq2415x_device *bq, u8 reg)
{ … }
static int bq2415x_i2c_read_mask(struct bq2415x_device *bq, u8 reg,
u8 mask, u8 shift)
{ … }
static int bq2415x_i2c_read_bit(struct bq2415x_device *bq, u8 reg, u8 bit)
{ … }
static int bq2415x_i2c_write(struct bq2415x_device *bq, u8 reg, u8 val)
{ … }
static int bq2415x_i2c_write_mask(struct bq2415x_device *bq, u8 reg, u8 val,
u8 mask, u8 shift)
{ … }
static int bq2415x_i2c_write_bit(struct bq2415x_device *bq, u8 reg,
bool val, u8 bit)
{ … }
static int bq2415x_exec_command(struct bq2415x_device *bq,
enum bq2415x_command command)
{ … }
static enum bq2415x_chip bq2415x_detect_chip(struct bq2415x_device *bq)
{ … }
static int bq2415x_detect_revision(struct bq2415x_device *bq)
{ … }
static int bq2415x_get_vender_code(struct bq2415x_device *bq)
{ … }
static void bq2415x_reset_chip(struct bq2415x_device *bq)
{ … }
static int bq2415x_set_current_limit(struct bq2415x_device *bq, int mA)
{ … }
static int bq2415x_get_current_limit(struct bq2415x_device *bq)
{ … }
static int bq2415x_set_weak_battery_voltage(struct bq2415x_device *bq, int mV)
{ … }
static int bq2415x_get_weak_battery_voltage(struct bq2415x_device *bq)
{ … }
static int bq2415x_set_battery_regulation_voltage(struct bq2415x_device *bq,
int mV)
{ … }
static int bq2415x_get_battery_regulation_voltage(struct bq2415x_device *bq)
{ … }
static int bq2415x_set_charge_current(struct bq2415x_device *bq, int mA)
{ … }
static int bq2415x_get_charge_current(struct bq2415x_device *bq)
{ … }
static int bq2415x_set_termination_current(struct bq2415x_device *bq, int mA)
{ … }
static int bq2415x_get_termination_current(struct bq2415x_device *bq)
{ … }
#define bq2415x_set_default_value(bq, prop) …
static int bq2415x_set_defaults(struct bq2415x_device *bq)
{ … }
static int bq2415x_set_mode(struct bq2415x_device *bq, enum bq2415x_mode mode)
{ … }
static bool bq2415x_update_reported_mode(struct bq2415x_device *bq, int mA)
{ … }
static int bq2415x_notifier_call(struct notifier_block *nb,
unsigned long val, void *v)
{ … }
static void bq2415x_set_autotimer(struct bq2415x_device *bq, int state)
{ … }
static void bq2415x_timer_error(struct bq2415x_device *bq, const char *msg)
{ … }
static void bq2415x_timer_work(struct work_struct *work)
{ … }
static enum power_supply_property bq2415x_power_supply_props[] = …;
static int bq2415x_power_supply_get_property(struct power_supply *psy,
enum power_supply_property psp,
union power_supply_propval *val)
{ … }
static void bq2415x_power_supply_exit(struct bq2415x_device *bq)
{ … }
static ssize_t bq2415x_sysfs_show_status(struct device *dev,
struct device_attribute *attr,
char *buf)
{ … }
static ssize_t bq2415x_sysfs_set_timer(struct device *dev,
struct device_attribute *attr,
const char *buf,
size_t count)
{ … }
static ssize_t bq2415x_sysfs_show_timer(struct device *dev,
struct device_attribute *attr,
char *buf)
{ … }
static ssize_t bq2415x_sysfs_set_mode(struct device *dev,
struct device_attribute *attr,
const char *buf,
size_t count)
{ … }
static ssize_t bq2415x_sysfs_show_mode(struct device *dev,
struct device_attribute *attr,
char *buf)
{ … }
static ssize_t bq2415x_sysfs_show_reported_mode(struct device *dev,
struct device_attribute *attr,
char *buf)
{ … }
static ssize_t bq2415x_sysfs_set_registers(struct device *dev,
struct device_attribute *attr,
const char *buf,
size_t count)
{ … }
static ssize_t bq2415x_sysfs_print_reg(struct bq2415x_device *bq,
u8 reg,
char *buf)
{ … }
static ssize_t bq2415x_sysfs_show_registers(struct device *dev,
struct device_attribute *attr,
char *buf)
{ … }
static ssize_t bq2415x_sysfs_set_limit(struct device *dev,
struct device_attribute *attr,
const char *buf,
size_t count)
{ … }
static ssize_t bq2415x_sysfs_show_limit(struct device *dev,
struct device_attribute *attr,
char *buf)
{ … }
static ssize_t bq2415x_sysfs_set_enable(struct device *dev,
struct device_attribute *attr,
const char *buf,
size_t count)
{ … }
static ssize_t bq2415x_sysfs_show_enable(struct device *dev,
struct device_attribute *attr,
char *buf)
{ … }
static DEVICE_ATTR(current_limit, S_IWUSR | S_IRUGO,
bq2415x_sysfs_show_limit, bq2415x_sysfs_set_limit);
static DEVICE_ATTR(weak_battery_voltage, S_IWUSR | S_IRUGO,
bq2415x_sysfs_show_limit, bq2415x_sysfs_set_limit);
static DEVICE_ATTR(battery_regulation_voltage, S_IWUSR | S_IRUGO,
bq2415x_sysfs_show_limit, bq2415x_sysfs_set_limit);
static DEVICE_ATTR(charge_current, S_IWUSR | S_IRUGO,
bq2415x_sysfs_show_limit, bq2415x_sysfs_set_limit);
static DEVICE_ATTR(termination_current, S_IWUSR | S_IRUGO,
bq2415x_sysfs_show_limit, bq2415x_sysfs_set_limit);
static DEVICE_ATTR(charge_termination_enable, S_IWUSR | S_IRUGO,
bq2415x_sysfs_show_enable, bq2415x_sysfs_set_enable);
static DEVICE_ATTR(high_impedance_enable, S_IWUSR | S_IRUGO,
bq2415x_sysfs_show_enable, bq2415x_sysfs_set_enable);
static DEVICE_ATTR(otg_pin_enable, S_IWUSR | S_IRUGO,
bq2415x_sysfs_show_enable, bq2415x_sysfs_set_enable);
static DEVICE_ATTR(stat_pin_enable, S_IWUSR | S_IRUGO,
bq2415x_sysfs_show_enable, bq2415x_sysfs_set_enable);
static DEVICE_ATTR(reported_mode, S_IRUGO,
bq2415x_sysfs_show_reported_mode, NULL);
static DEVICE_ATTR(mode, S_IWUSR | S_IRUGO,
bq2415x_sysfs_show_mode, bq2415x_sysfs_set_mode);
static DEVICE_ATTR(timer, S_IWUSR | S_IRUGO,
bq2415x_sysfs_show_timer, bq2415x_sysfs_set_timer);
static DEVICE_ATTR(registers, S_IWUSR | S_IRUGO,
bq2415x_sysfs_show_registers, bq2415x_sysfs_set_registers);
static DEVICE_ATTR(otg_status, S_IRUGO, bq2415x_sysfs_show_status, NULL);
static DEVICE_ATTR(charge_status, S_IRUGO, bq2415x_sysfs_show_status, NULL);
static DEVICE_ATTR(boost_status, S_IRUGO, bq2415x_sysfs_show_status, NULL);
static DEVICE_ATTR(fault_status, S_IRUGO, bq2415x_sysfs_show_status, NULL);
static struct attribute *bq2415x_sysfs_attrs[] = …;
ATTRIBUTE_GROUPS(…);
static int bq2415x_power_supply_init(struct bq2415x_device *bq)
{ … }
static int bq2415x_probe(struct i2c_client *client)
{ … }
static void bq2415x_remove(struct i2c_client *client)
{ … }
static const struct i2c_device_id bq2415x_i2c_id_table[] = …;
MODULE_DEVICE_TABLE(i2c, bq2415x_i2c_id_table);
#ifdef CONFIG_ACPI
static const struct acpi_device_id bq2415x_i2c_acpi_match[] = …;
MODULE_DEVICE_TABLE(acpi, bq2415x_i2c_acpi_match);
#endif
#ifdef CONFIG_OF
static const struct of_device_id bq2415x_of_match_table[] = …;
MODULE_DEVICE_TABLE(of, bq2415x_of_match_table);
#endif
static struct i2c_driver bq2415x_driver = …;
module_i2c_driver(…) …;
MODULE_AUTHOR(…) …;
MODULE_DESCRIPTION(…) …;
MODULE_LICENSE(…) …;