#include <linux/gpio/consumer.h>
#include <linux/iio/consumer.h>
#include <linux/interrupt.h>
#include <linux/kernel.h>
#include <linux/math64.h>
#include <linux/module.h>
#include <linux/nvmem-consumer.h>
#include <linux/of.h>
#include <linux/platform_device.h>
#include <linux/power_supply.h>
#include <linux/regmap.h>
#include <linux/slab.h>
#define SC27XX_MODULE_EN0 …
#define SC27XX_CLK_EN0 …
#define SC27XX_FGU_EN …
#define SC27XX_FGU_RTC_EN …
#define SC27XX_FGU_START …
#define SC27XX_FGU_CONFIG …
#define SC27XX_FGU_ADC_CONFIG …
#define SC27XX_FGU_STATUS …
#define SC27XX_FGU_INT_EN …
#define SC27XX_FGU_INT_CLR …
#define SC27XX_FGU_INT_STS …
#define SC27XX_FGU_VOLTAGE …
#define SC27XX_FGU_OCV …
#define SC27XX_FGU_POCV …
#define SC27XX_FGU_CURRENT …
#define SC27XX_FGU_LOW_OVERLOAD …
#define SC27XX_FGU_CLBCNT_SETH …
#define SC27XX_FGU_CLBCNT_SETL …
#define SC27XX_FGU_CLBCNT_DELTH …
#define SC27XX_FGU_CLBCNT_DELTL …
#define SC27XX_FGU_CLBCNT_VALH …
#define SC27XX_FGU_CLBCNT_VALL …
#define SC27XX_FGU_CLBCNT_QMAXL …
#define SC27XX_FGU_USER_AREA_SET …
#define SC27XX_FGU_USER_AREA_CLEAR …
#define SC27XX_FGU_USER_AREA_STATUS …
#define SC27XX_FGU_VOLTAGE_BUF …
#define SC27XX_FGU_CURRENT_BUF …
#define SC27XX_WRITE_SELCLB_EN …
#define SC27XX_FGU_CLBCNT_MASK …
#define SC27XX_FGU_CLBCNT_SHIFT …
#define SC27XX_FGU_LOW_OVERLOAD_MASK …
#define SC27XX_FGU_INT_MASK …
#define SC27XX_FGU_LOW_OVERLOAD_INT …
#define SC27XX_FGU_CLBCNT_DELTA_INT …
#define SC27XX_FGU_MODE_AREA_MASK …
#define SC27XX_FGU_CAP_AREA_MASK …
#define SC27XX_FGU_MODE_AREA_SHIFT …
#define SC27XX_FGU_FIRST_POWERTON …
#define SC27XX_FGU_DEFAULT_CAP …
#define SC27XX_FGU_NORMAIL_POWERTON …
#define SC27XX_FGU_CUR_BASIC_ADC …
#define SC27XX_FGU_SAMPLE_HZ …
#define SC27XX_FGU_IDEAL_RESISTANCE …
struct sc27xx_fgu_data { … };
static int sc27xx_fgu_cap_to_clbcnt(struct sc27xx_fgu_data *data, int capacity);
static void sc27xx_fgu_capacity_calibration(struct sc27xx_fgu_data *data,
int cap, bool int_mode);
static void sc27xx_fgu_adjust_cap(struct sc27xx_fgu_data *data, int cap);
static int sc27xx_fgu_get_temp(struct sc27xx_fgu_data *data, int *temp);
static const char * const sc27xx_charger_supply_name[] = …;
static int sc27xx_fgu_adc_to_current(struct sc27xx_fgu_data *data, s64 adc)
{ … }
static int sc27xx_fgu_adc_to_voltage(struct sc27xx_fgu_data *data, s64 adc)
{ … }
static int sc27xx_fgu_voltage_to_adc(struct sc27xx_fgu_data *data, int vol)
{ … }
static bool sc27xx_fgu_is_first_poweron(struct sc27xx_fgu_data *data)
{ … }
static int sc27xx_fgu_save_boot_mode(struct sc27xx_fgu_data *data,
int boot_mode)
{ … }
static int sc27xx_fgu_save_last_cap(struct sc27xx_fgu_data *data, int cap)
{ … }
static int sc27xx_fgu_read_last_cap(struct sc27xx_fgu_data *data, int *cap)
{ … }
static int sc27xx_fgu_get_boot_capacity(struct sc27xx_fgu_data *data, int *cap)
{ … }
static int sc27xx_fgu_set_clbcnt(struct sc27xx_fgu_data *data, int clbcnt)
{ … }
static int sc27xx_fgu_get_clbcnt(struct sc27xx_fgu_data *data, int *clb_cnt)
{ … }
static int sc27xx_fgu_get_vol_now(struct sc27xx_fgu_data *data, int *val)
{ … }
static int sc27xx_fgu_get_cur_now(struct sc27xx_fgu_data *data, int *val)
{ … }
static int sc27xx_fgu_get_capacity(struct sc27xx_fgu_data *data, int *cap)
{ … }
static int sc27xx_fgu_get_vbat_vol(struct sc27xx_fgu_data *data, int *val)
{ … }
static int sc27xx_fgu_get_current(struct sc27xx_fgu_data *data, int *val)
{ … }
static int sc27xx_fgu_get_vbat_ocv(struct sc27xx_fgu_data *data, int *val)
{ … }
static int sc27xx_fgu_get_charge_vol(struct sc27xx_fgu_data *data, int *val)
{ … }
static int sc27xx_fgu_get_temp(struct sc27xx_fgu_data *data, int *temp)
{ … }
static int sc27xx_fgu_get_health(struct sc27xx_fgu_data *data, int *health)
{ … }
static int sc27xx_fgu_get_status(struct sc27xx_fgu_data *data, int *status)
{ … }
static int sc27xx_fgu_get_property(struct power_supply *psy,
enum power_supply_property psp,
union power_supply_propval *val)
{ … }
static int sc27xx_fgu_set_property(struct power_supply *psy,
enum power_supply_property psp,
const union power_supply_propval *val)
{ … }
static int sc27xx_fgu_property_is_writeable(struct power_supply *psy,
enum power_supply_property psp)
{ … }
static enum power_supply_property sc27xx_fgu_props[] = …;
static const struct power_supply_desc sc27xx_fgu_desc = …;
static void sc27xx_fgu_adjust_cap(struct sc27xx_fgu_data *data, int cap)
{ … }
static void sc27xx_fgu_capacity_calibration(struct sc27xx_fgu_data *data,
int cap, bool int_mode)
{ … }
static irqreturn_t sc27xx_fgu_interrupt(int irq, void *dev_id)
{ … }
static irqreturn_t sc27xx_fgu_bat_detection(int irq, void *dev_id)
{ … }
static void sc27xx_fgu_disable(void *_data)
{ … }
static int sc27xx_fgu_cap_to_clbcnt(struct sc27xx_fgu_data *data, int capacity)
{ … }
static int sc27xx_fgu_calibration(struct sc27xx_fgu_data *data)
{ … }
static int sc27xx_fgu_hw_init(struct sc27xx_fgu_data *data)
{ … }
static int sc27xx_fgu_probe(struct platform_device *pdev)
{ … }
#ifdef CONFIG_PM_SLEEP
static int sc27xx_fgu_resume(struct device *dev)
{ … }
static int sc27xx_fgu_suspend(struct device *dev)
{ … }
#endif
static const struct dev_pm_ops sc27xx_fgu_pm_ops = …;
static const struct of_device_id sc27xx_fgu_of_match[] = …;
MODULE_DEVICE_TABLE(of, sc27xx_fgu_of_match);
static struct platform_driver sc27xx_fgu_driver = …;
module_platform_driver(…) …;
MODULE_DESCRIPTION(…) …;
MODULE_LICENSE(…) …;