#include <linux/module.h>
#include <linux/interrupt.h>
#include <linux/delay.h>
#include <linux/of.h>
#include <linux/pm_runtime.h>
#include <linux/power_supply.h>
#include <linux/i2c.h>
#include <linux/acpi.h>
#include <linux/usb/phy.h>
#include <linux/regmap.h>
#define RT9455_MANUFACTURER …
#define RT9455_MODEL_NAME …
#define RT9455_DRIVER_NAME …
#define RT9455_IRQ_NAME …
#define RT9455_PWR_RDY_DELAY …
#define RT9455_MAX_CHARGING_TIME …
#define RT9455_BATT_PRESENCE_DELAY …
#define RT9455_CHARGE_MODE …
#define RT9455_BOOST_MODE …
#define RT9455_FAULT …
#define RT9455_IAICR_100MA …
#define RT9455_IAICR_500MA …
#define RT9455_IAICR_NO_LIMIT …
#define RT9455_CHARGE_DISABLE …
#define RT9455_CHARGE_ENABLE …
#define RT9455_PWR_FAULT …
#define RT9455_PWR_GOOD …
#define RT9455_REG_CTRL1 …
#define RT9455_REG_CTRL2 …
#define RT9455_REG_CTRL3 …
#define RT9455_REG_DEV_ID …
#define RT9455_REG_CTRL4 …
#define RT9455_REG_CTRL5 …
#define RT9455_REG_CTRL6 …
#define RT9455_REG_CTRL7 …
#define RT9455_REG_IRQ1 …
#define RT9455_REG_IRQ2 …
#define RT9455_REG_IRQ3 …
#define RT9455_REG_MASK1 …
#define RT9455_REG_MASK2 …
#define RT9455_REG_MASK3 …
enum rt9455_fields { … };
static const struct reg_field rt9455_reg_fields[] = …;
#define GET_MASK(fid) …
static const int rt9455_ichrg_values[] = …;
static const int rt9455_voreg_values[] = …;
#if IS_ENABLED(CONFIG_USB_PHY)
static const int rt9455_boost_voltage_values[] = …;
#endif
static const int rt9455_vmreg_values[] = …;
static const int rt9455_ieoc_percentage_values[] = …;
static const int rt9455_mivr_values[] = …;
static const int rt9455_iaicr_values[] = …;
struct rt9455_info { … };
static unsigned int rt9455_find_idx(const int tbl[], int tbl_size, int v)
{ … }
static int rt9455_get_field_val(struct rt9455_info *info,
enum rt9455_fields field,
const int tbl[], int tbl_size, int *val)
{ … }
static int rt9455_set_field_val(struct rt9455_info *info,
enum rt9455_fields field,
const int tbl[], int tbl_size, int val)
{ … }
static int rt9455_register_reset(struct rt9455_info *info)
{ … }
static enum power_supply_property rt9455_charger_properties[] = …;
static char *rt9455_charger_supplied_to[] = …;
static int rt9455_charger_get_status(struct rt9455_info *info,
union power_supply_propval *val)
{ … }
static int rt9455_charger_get_health(struct rt9455_info *info,
union power_supply_propval *val)
{ … }
static int rt9455_charger_get_battery_presence(struct rt9455_info *info,
union power_supply_propval *val)
{ … }
static int rt9455_charger_get_online(struct rt9455_info *info,
union power_supply_propval *val)
{ … }
static int rt9455_charger_get_current(struct rt9455_info *info,
union power_supply_propval *val)
{ … }
static int rt9455_charger_get_current_max(struct rt9455_info *info,
union power_supply_propval *val)
{ … }
static int rt9455_charger_get_voltage(struct rt9455_info *info,
union power_supply_propval *val)
{ … }
static int rt9455_charger_get_voltage_max(struct rt9455_info *info,
union power_supply_propval *val)
{ … }
static int rt9455_charger_get_term_current(struct rt9455_info *info,
union power_supply_propval *val)
{ … }
static int rt9455_charger_get_property(struct power_supply *psy,
enum power_supply_property psp,
union power_supply_propval *val)
{ … }
static int rt9455_hw_init(struct rt9455_info *info, u32 ichrg,
u32 ieoc_percentage,
u32 mivr, u32 iaicr)
{ … }
#if IS_ENABLED(CONFIG_USB_PHY)
static int rt9455_set_boost_voltage_before_boost_mode(struct rt9455_info *info)
{ … }
#endif
static int rt9455_set_voreg_before_charge_mode(struct rt9455_info *info)
{ … }
static int rt9455_irq_handler_check_irq1_register(struct rt9455_info *info,
bool *_is_battery_absent,
bool *_alert_userspace)
{ … }
static int rt9455_irq_handler_check_irq2_register(struct rt9455_info *info,
bool is_battery_absent,
bool *_alert_userspace)
{ … }
static int rt9455_irq_handler_check_irq3_register(struct rt9455_info *info,
bool *_alert_userspace)
{ … }
static irqreturn_t rt9455_irq_handler_thread(int irq, void *data)
{ … }
static int rt9455_discover_charger(struct rt9455_info *info, u32 *ichrg,
u32 *ieoc_percentage,
u32 *mivr, u32 *iaicr)
{ … }
#if IS_ENABLED(CONFIG_USB_PHY)
static int rt9455_usb_event_none(struct rt9455_info *info,
u8 opa_mode, u8 iaicr)
{ … }
static int rt9455_usb_event_vbus(struct rt9455_info *info,
u8 opa_mode, u8 iaicr)
{ … }
static int rt9455_usb_event_id(struct rt9455_info *info,
u8 opa_mode, u8 iaicr)
{ … }
static int rt9455_usb_event_charger(struct rt9455_info *info,
u8 opa_mode, u8 iaicr)
{ … }
static int rt9455_usb_event(struct notifier_block *nb,
unsigned long event, void *power)
{ … }
#endif
static void rt9455_pwr_rdy_work_callback(struct work_struct *work)
{ … }
static void rt9455_max_charging_time_work_callback(struct work_struct *work)
{ … }
static void rt9455_batt_presence_work_callback(struct work_struct *work)
{ … }
static const struct power_supply_desc rt9455_charger_desc = …;
static bool rt9455_is_writeable_reg(struct device *dev, unsigned int reg)
{ … }
static bool rt9455_is_volatile_reg(struct device *dev, unsigned int reg)
{ … }
static const struct regmap_config rt9455_regmap_config = …;
static int rt9455_probe(struct i2c_client *client)
{ … }
static void rt9455_remove(struct i2c_client *client)
{ … }
static const struct i2c_device_id rt9455_i2c_id_table[] = …;
MODULE_DEVICE_TABLE(i2c, rt9455_i2c_id_table);
static const struct of_device_id rt9455_of_match[] __maybe_unused = …;
MODULE_DEVICE_TABLE(of, rt9455_of_match);
#ifdef CONFIG_ACPI
static const struct acpi_device_id rt9455_i2c_acpi_match[] = …;
MODULE_DEVICE_TABLE(acpi, rt9455_i2c_acpi_match);
#endif
static struct i2c_driver rt9455_driver = …;
module_i2c_driver(…) …;
MODULE_LICENSE(…) …;
MODULE_AUTHOR(…) …;
MODULE_DESCRIPTION(…) …;