linux/drivers/power/supply/rt9455_charger.c

// SPDX-License-Identifier: GPL-2.0-or-later
/*
 * Driver for Richtek RT9455WSC battery charger.
 *
 * Copyright (C) 2015 Intel Corporation
 */

#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)

/*
 * Each array initialised below shows the possible real-world values for a
 * group of bits belonging to RT9455 registers. The arrays are sorted in
 * ascending order. The index of each real-world value represents the value
 * that is encoded in the group of bits belonging to RT9455 registers.
 */
/* REG06[6:4] (ICHRG) in uAh */
static const int rt9455_ichrg_values[] =;

/*
 * When the charger is in charge mode, REG02[7:2] represent battery regulation
 * voltage.
 */
/* REG02[7:2] (VOREG) in uV */
static const int rt9455_voreg_values[] =;

#if IS_ENABLED(CONFIG_USB_PHY)
/*
 * When the charger is in boost mode, REG02[7:2] represent boost output
 * voltage.
 */
/* REG02[7:2] (Boost output voltage) in uV */
static const int rt9455_boost_voltage_values[] =;
#endif

/* REG07[3:0] (VMREG) in uV */
static const int rt9455_vmreg_values[] =;

/* REG05[5:4] (IEOC_PERCENTAGE) */
static const int rt9455_ieoc_percentage_values[] =;

/* REG05[1:0] (MIVR) in uV */
static const int rt9455_mivr_values[] =;

/* REG05[1:0] (IAICR) in uA */
static const int rt9455_iaicr_values[] =;

struct rt9455_info {};

/*
 * Iterate through each element of the 'tbl' array until an element whose value
 * is greater than v is found. Return the index of the respective element,
 * or the index of the last element in the array, if no such element is found.
 */
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)
{}

/* Charger power supply property routines */
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)
/*
 * Before setting the charger into boost mode, boost output voltage is
 * set. This is needed because boost output voltage may differ from battery
 * regulation voltage. F_VOREG bits represent either battery regulation voltage
 * or boost output voltage, depending on the mode the charger is. Both battery
 * regulation voltage and boost output voltage are read from DT/ACPI during
 * probe.
 */
static int rt9455_set_boost_voltage_before_boost_mode(struct rt9455_info *info)
{}
#endif

/*
 * Before setting the charger into charge mode, battery regulation voltage is
 * set. This is needed because boost output voltage may differ from battery
 * regulation voltage. F_VOREG bits represent either battery regulation voltage
 * or boost output voltage, depending on the mode the charger is. Both battery
 * regulation voltage and boost output voltage are read from DT/ACPI during
 * probe.
 */
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();