#include <linux/bits.h>
#include <linux/gpio/consumer.h>
#include <linux/i2c.h>
#include <linux/interrupt.h>
#include <linux/kstrtox.h>
#include <linux/linear_range.h>
#include <linux/mod_devicetable.h>
#include <linux/module.h>
#include <linux/mutex.h>
#include <linux/of.h>
#include <linux/power_supply.h>
#include <linux/regmap.h>
#include <linux/regulator/driver.h>
#include <linux/sysfs.h>
#define RT9471_REG_OTGCFG …
#define RT9471_REG_TOP …
#define RT9471_REG_FUNC …
#define RT9471_REG_IBUS …
#define RT9471_REG_VBUS …
#define RT9471_REG_PRECHG …
#define RT9471_REG_VCHG …
#define RT9471_REG_ICHG …
#define RT9471_REG_CHGTMR …
#define RT9471_REG_EOC …
#define RT9471_REG_INFO …
#define RT9471_REG_JEITA …
#define RT9471_REG_PUMP_EXP …
#define RT9471_REG_DPDMDET …
#define RT9471_REG_ICSTAT …
#define RT9471_REG_STAT0 …
#define RT9471_REG_STAT1 …
#define RT9471_REG_STAT2 …
#define RT9471_REG_IRQ0 …
#define RT9471_REG_MASK0 …
#define RT9471_OTGCV_MASK …
#define RT9471_OTGCC_MASK …
#define RT9471_OTGEN_MASK …
#define RT9471_CHGFAULT_MASK …
#define RT9471_NUM_IRQ_REGS …
#define RT9471_OTGCV_MINUV …
#define RT9471_OTGCV_STEPUV …
#define RT9471_NUM_VOTG …
#define RT9471_VCHG_MAXUV …
#define RT9471_ICHG_MAXUA …
#define RT9470_DEVID …
#define RT9470D_DEVID …
#define RT9471_DEVID …
#define RT9471D_DEVID …
#define RT9471_IRQ_BC12_DONE …
#define RT9471_IRQ_DETACH …
#define RT9471_IRQ_RECHG …
#define RT9471_IRQ_CHG_DONE …
#define RT9471_IRQ_BG_CHG …
#define RT9471_IRQ_IE0C …
#define RT9471_IRQ_CHG_RDY …
#define RT9471_IRQ_VBUS_GD …
#define RT9471_IRQ_CHG_BATOV …
#define RT9471_IRQ_CHG_SYSOV …
#define RT9471_IRQ_CHG_TOUT …
#define RT9471_IRQ_CHG_BUSUV …
#define RT9471_IRQ_CHG_THREG …
#define RT9471_IRQ_CHG_AICR …
#define RT9471_IRQ_CHG_MIVR …
#define RT9471_IRQ_SYS_SHORT …
#define RT9471_IRQ_SYS_MIN …
#define RT9471_IRQ_AICC_DONE …
#define RT9471_IRQ_PE_DONE …
#define RT9471_IRQ_JEITA_COLD …
#define RT9471_IRQ_JEITA_COOL …
#define RT9471_IRQ_JEITA_WARM …
#define RT9471_IRQ_JEITA_HOT …
#define RT9471_IRQ_OTG_FAULT …
#define RT9471_IRQ_OTG_LBP …
#define RT9471_IRQ_OTG_CC …
#define RT9471_IRQ_WDT …
#define RT9471_IRQ_VAC_OV …
#define RT9471_IRQ_OTP …
enum rt9471_fields { … };
enum rt9471_ranges { … };
enum { … };
struct rt9471_chip { … };
static const struct reg_field rt9471_reg_fields[F_MAX_FIELDS] = …;
static const struct linear_range rt9471_chg_ranges[RT9471_MAX_RANGES] = …;
static int rt9471_set_value_by_field_range(struct rt9471_chip *chip,
enum rt9471_fields field,
enum rt9471_ranges range, int val)
{ … }
static int rt9471_get_value_by_field_range(struct rt9471_chip *chip,
enum rt9471_fields field,
enum rt9471_ranges range, int *val)
{ … }
static int rt9471_set_ieoc(struct rt9471_chip *chip, int microamp)
{ … }
static int rt9471_get_ieoc(struct rt9471_chip *chip, int *microamp)
{ … }
static int rt9471_get_status(struct rt9471_chip *chip, int *status)
{ … }
static int rt9471_get_vbus_good(struct rt9471_chip *chip, int *stat)
{ … }
static int rt9471_get_usb_type(struct rt9471_chip *chip, int *usb_type)
{ … }
static int rt9471_get_usb_type_current(struct rt9471_chip *chip,
int *microamp)
{ … }
static enum power_supply_property rt9471_charger_properties[] = …;
static enum power_supply_usb_type rt9471_charger_usb_types[] = …;
static int rt9471_charger_property_is_writeable(struct power_supply *psy,
enum power_supply_property psp)
{ … }
static int rt9471_charger_set_property(struct power_supply *psy,
enum power_supply_property psp,
const union power_supply_propval *val)
{ … }
static const char * const rt9471_manufacturer = …;
static const char * const rt9471_model = …;
static int rt9471_charger_get_property(struct power_supply *psy,
enum power_supply_property psp,
union power_supply_propval *val)
{ … }
static irqreturn_t rt9471_vbus_gd_handler(int irqno, void *devid)
{ … }
static irqreturn_t rt9471_detach_handler(int irqno, void *devid)
{ … }
static irqreturn_t rt9471_bc12_done_handler(int irqno, void *devid)
{ … }
static irqreturn_t rt9471_wdt_handler(int irqno, void *devid)
{ … }
static irqreturn_t rt9471_otg_fault_handler(int irqno, void *devid)
{ … }
#define RT9471_IRQ_DESC(_name, _hwirq) …
static int rt9471_register_interrupts(struct rt9471_chip *chip)
{ … }
static const struct regulator_ops rt9471_otg_ops = …;
static const unsigned int rt9471_otg_microamp[] = …;
static const struct regulator_desc rt9471_otg_rdesc = …;
static int rt9471_register_otg_regulator(struct rt9471_chip *chip)
{ … }
static inline struct rt9471_chip *psy_device_to_chip(struct device *dev)
{ … }
static ssize_t sysoff_enable_show(struct device *dev,
struct device_attribute *attr, char *buf)
{ … }
static ssize_t sysoff_enable_store(struct device *dev,
struct device_attribute *attr,
const char *buf, size_t count)
{ … }
static ssize_t port_detect_enable_show(struct device *dev,
struct device_attribute *attr, char *buf)
{ … }
static ssize_t port_detect_enable_store(struct device *dev,
struct device_attribute *attr,
const char *buf, size_t count)
{ … }
static DEVICE_ATTR_RW(sysoff_enable);
static DEVICE_ATTR_RW(port_detect_enable);
static struct attribute *rt9471_sysfs_attrs[] = …;
ATTRIBUTE_GROUPS(…);
static int rt9471_register_psy(struct rt9471_chip *chip)
{ … }
static const struct regmap_irq rt9471_regmap_irqs[] = …;
static const struct regmap_irq_chip rt9471_irq_chip = …;
static const struct reg_sequence rt9471_init_regs[] = …;
static int rt9471_check_devinfo(struct rt9471_chip *chip)
{ … }
static bool rt9471_accessible_reg(struct device *dev, unsigned int reg)
{ … }
static const struct regmap_config rt9471_regmap_config = …;
static int rt9471_probe(struct i2c_client *i2c)
{ … }
static void rt9471_shutdown(struct i2c_client *i2c)
{ … }
static const struct of_device_id rt9471_of_device_id[] = …;
MODULE_DEVICE_TABLE(of, rt9471_of_device_id);
static struct i2c_driver rt9471_driver = …;
module_i2c_driver(…) …;
MODULE_DESCRIPTION(…) …;
MODULE_AUTHOR(…) …;
MODULE_AUTHOR(…) …;
MODULE_LICENSE(…) …;