#include <linux/bits.h>
#include <linux/devm-helpers.h>
#include <linux/iio/consumer.h>
#include <linux/interrupt.h>
#include <linux/kernel.h>
#include <linux/minmax.h>
#include <linux/module.h>
#include <linux/platform_device.h>
#include <linux/pm_wakeirq.h>
#include <linux/of.h>
#include <linux/power_supply.h>
#include <linux/regmap.h>
#include <linux/types.h>
#include <linux/workqueue.h>
#define BATTERY_CHARGER_STATUS_1 …
#define BVR_INITIAL_RAMP_BIT …
#define CC_SOFT_TERMINATE_BIT …
#define STEP_CHARGING_STATUS_SHIFT …
#define STEP_CHARGING_STATUS_MASK …
#define BATTERY_CHARGER_STATUS_MASK …
#define BATTERY_CHARGER_STATUS_2 …
#define INPUT_CURRENT_LIMITED_BIT …
#define CHARGER_ERROR_STATUS_SFT_EXPIRE_BIT …
#define CHARGER_ERROR_STATUS_BAT_OV_BIT …
#define CHARGER_ERROR_STATUS_BAT_TERM_MISSING_BIT …
#define BAT_TEMP_STATUS_MASK …
#define BAT_TEMP_STATUS_SOFT_LIMIT_MASK …
#define BAT_TEMP_STATUS_HOT_SOFT_LIMIT_BIT …
#define BAT_TEMP_STATUS_COLD_SOFT_LIMIT_BIT …
#define BAT_TEMP_STATUS_TOO_HOT_BIT …
#define BAT_TEMP_STATUS_TOO_COLD_BIT …
#define BATTERY_CHARGER_STATUS_4 …
#define CHARGE_CURRENT_POST_JEITA_MASK …
#define BATTERY_CHARGER_STATUS_7 …
#define ENABLE_TRICKLE_BIT …
#define ENABLE_PRE_CHARGING_BIT …
#define ENABLE_FAST_CHARGING_BIT …
#define ENABLE_FULLON_MODE_BIT …
#define TOO_COLD_ADC_BIT …
#define TOO_HOT_ADC_BIT …
#define HOT_SL_ADC_BIT …
#define COLD_SL_ADC_BIT …
#define CHARGING_ENABLE_CMD …
#define CHARGING_ENABLE_CMD_BIT …
#define CHGR_CFG2 …
#define CHG_EN_SRC_BIT …
#define CHG_EN_POLARITY_BIT …
#define PRETOFAST_TRANSITION_CFG_BIT …
#define BAT_OV_ECC_BIT …
#define I_TERM_BIT …
#define AUTO_RECHG_BIT …
#define EN_ANALOG_DROP_IN_VBATT_BIT …
#define CHARGER_INHIBIT_BIT …
#define PRE_CHARGE_CURRENT_CFG …
#define PRE_CHARGE_CURRENT_SETTING_MASK …
#define FAST_CHARGE_CURRENT_CFG …
#define FAST_CHARGE_CURRENT_SETTING_MASK …
#define FLOAT_VOLTAGE_CFG …
#define FLOAT_VOLTAGE_SETTING_MASK …
#define FG_UPDATE_CFG_2_SEL …
#define SOC_LT_OTG_THRESH_SEL_BIT …
#define SOC_LT_CHG_RECHARGE_THRESH_SEL_BIT …
#define VBT_LT_CHG_RECHARGE_THRESH_SEL_BIT …
#define IBT_LT_CHG_TERM_THRESH_SEL_BIT …
#define JEITA_EN_CFG …
#define JEITA_EN_HARDLIMIT_BIT …
#define JEITA_EN_HOT_SL_FCV_BIT …
#define JEITA_EN_COLD_SL_FCV_BIT …
#define JEITA_EN_HOT_SL_CCC_BIT …
#define JEITA_EN_COLD_SL_CCC_BIT …
#define INT_RT_STS …
#define TYPE_C_CHANGE_RT_STS_BIT …
#define USBIN_ICL_CHANGE_RT_STS_BIT …
#define USBIN_SOURCE_CHANGE_RT_STS_BIT …
#define USBIN_PLUGIN_RT_STS_BIT …
#define USBIN_OV_RT_STS_BIT …
#define USBIN_UV_RT_STS_BIT …
#define USBIN_LT_3P6V_RT_STS_BIT …
#define USBIN_COLLAPSE_RT_STS_BIT …
#define OTG_CFG …
#define OTG_RESERVED_MASK …
#define DIS_OTG_ON_TLIM_BIT …
#define QUICKSTART_OTG_FASTROLESWAP_BIT …
#define INCREASE_DFP_TIME_BIT …
#define ENABLE_OTG_IN_DEBUG_MODE_BIT …
#define OTG_EN_SRC_CFG_BIT …
#define CONCURRENT_MODE_CFG_BIT …
#define OTG_ENG_OTG_CFG …
#define ENG_BUCKBOOST_HALT1_8_MODE_BIT …
#define APSD_STATUS …
#define APSD_STATUS_7_BIT …
#define HVDCP_CHECK_TIMEOUT_BIT …
#define SLOW_PLUGIN_TIMEOUT_BIT …
#define ENUMERATION_DONE_BIT …
#define VADP_CHANGE_DONE_AFTER_AUTH_BIT …
#define QC_AUTH_DONE_STATUS_BIT …
#define QC_CHARGER_BIT …
#define APSD_DTC_STATUS_DONE_BIT …
#define APSD_RESULT_STATUS …
#define ICL_OVERRIDE_LATCH_BIT …
#define APSD_RESULT_STATUS_MASK …
#define QC_3P0_BIT …
#define QC_2P0_BIT …
#define FLOAT_CHARGER_BIT …
#define DCP_CHARGER_BIT …
#define CDP_CHARGER_BIT …
#define OCP_CHARGER_BIT …
#define SDP_CHARGER_BIT …
#define TYPE_C_STATUS_1 …
#define UFP_TYPEC_MASK …
#define UFP_TYPEC_RDSTD_BIT …
#define UFP_TYPEC_RD1P5_BIT …
#define UFP_TYPEC_RD3P0_BIT …
#define UFP_TYPEC_FMB_255K_BIT …
#define UFP_TYPEC_FMB_301K_BIT …
#define UFP_TYPEC_FMB_523K_BIT …
#define UFP_TYPEC_FMB_619K_BIT …
#define UFP_TYPEC_OPEN_OPEN_BIT …
#define TYPE_C_STATUS_2 …
#define DFP_RA_OPEN_BIT …
#define TIMER_STAGE_BIT …
#define EXIT_UFP_MODE_BIT …
#define EXIT_DFP_MODE_BIT …
#define DFP_TYPEC_MASK …
#define DFP_RD_OPEN_BIT …
#define DFP_RD_RA_VCONN_BIT …
#define DFP_RD_RD_BIT …
#define DFP_RA_RA_BIT …
#define TYPE_C_STATUS_3 …
#define ENABLE_BANDGAP_BIT …
#define U_USB_GND_NOVBUS_BIT …
#define U_USB_FLOAT_NOVBUS_BIT …
#define U_USB_GND_BIT …
#define U_USB_FMB1_BIT …
#define U_USB_FLOAT1_BIT …
#define U_USB_FMB2_BIT …
#define U_USB_FLOAT2_BIT …
#define TYPE_C_STATUS_4 …
#define UFP_DFP_MODE_STATUS_BIT …
#define TYPEC_VBUS_STATUS_BIT …
#define TYPEC_VBUS_ERROR_STATUS_BIT …
#define TYPEC_DEBOUNCE_DONE_STATUS_BIT …
#define TYPEC_UFP_AUDIO_ADAPT_STATUS_BIT …
#define TYPEC_VCONN_OVERCURR_STATUS_BIT …
#define CC_ORIENTATION_BIT …
#define CC_ATTACHED_BIT …
#define TYPE_C_STATUS_5 …
#define TRY_SOURCE_FAILED_BIT …
#define TRY_SINK_FAILED_BIT …
#define TIMER_STAGE_2_BIT …
#define TYPEC_LEGACY_CABLE_STATUS_BIT …
#define TYPEC_NONCOMP_LEGACY_CABLE_STATUS_BIT …
#define TYPEC_TRYSOURCE_DETECT_STATUS_BIT …
#define TYPEC_TRYSINK_DETECT_STATUS_BIT …
#define CMD_APSD …
#define ICL_OVERRIDE_BIT …
#define APSD_RERUN_BIT …
#define TYPE_C_CFG …
#define APSD_START_ON_CC_BIT …
#define WAIT_FOR_APSD_BIT …
#define FACTORY_MODE_DETECTION_EN_BIT …
#define FACTORY_MODE_ICL_3A_4A_BIT …
#define FACTORY_MODE_DIS_CHGING_CFG_BIT …
#define SUSPEND_NON_COMPLIANT_CFG_BIT …
#define VCONN_OC_CFG_BIT …
#define TYPE_C_OR_U_USB_BIT …
#define TYPE_C_CFG_2 …
#define TYPE_C_DFP_CURRSRC_MODE_BIT …
#define DFP_CC_1P4V_OR_1P6V_BIT …
#define VCONN_SOFTSTART_CFG_MASK …
#define EN_TRY_SOURCE_MODE_BIT …
#define USB_FACTORY_MODE_ENABLE_BIT …
#define TYPE_C_UFP_MODE_BIT …
#define EN_80UA_180UA_CUR_SOURCE_BIT …
#define TYPE_C_CFG_3 …
#define TVBUS_DEBOUNCE_BIT …
#define TYPEC_LEGACY_CABLE_INT_EN_BIT …
#define TYPEC_NONCOMPLIANT_LEGACY_CABLE_INT_EN_B …
#define TYPEC_TRYSOURCE_DETECT_INT_EN_BIT …
#define TYPEC_TRYSINK_DETECT_INT_EN_BIT …
#define EN_TRYSINK_MODE_BIT …
#define EN_LEGACY_CABLE_DETECTION_BIT …
#define ALLOW_PD_DRING_UFP_TCCDB_BIT …
#define USBIN_OPTIONS_1_CFG …
#define CABLE_R_SEL_BIT …
#define HVDCP_AUTH_ALG_EN_CFG_BIT …
#define HVDCP_AUTONOMOUS_MODE_EN_CFG_BIT …
#define INPUT_PRIORITY_BIT …
#define AUTO_SRC_DETECT_BIT …
#define HVDCP_EN_BIT …
#define VADP_INCREMENT_VOLTAGE_LIMIT_BIT …
#define VADP_TAPER_TIMER_EN_BIT …
#define USBIN_OPTIONS_2_CFG …
#define WIPWR_RST_EUD_CFG_BIT …
#define SWITCHER_START_CFG_BIT …
#define DCD_TIMEOUT_SEL_BIT …
#define OCD_CURRENT_SEL_BIT …
#define SLOW_PLUGIN_TIMER_EN_CFG_BIT …
#define FLOAT_OPTIONS_MASK …
#define FLOAT_DIS_CHGING_CFG_BIT …
#define SUSPEND_FLOAT_CFG_BIT …
#define FORCE_FLOAT_SDP_CFG_BIT …
#define TAPER_TIMER_SEL_CFG …
#define TYPEC_SPARE_CFG_BIT …
#define TYPEC_DRP_DFP_TIME_CFG_BIT …
#define TAPER_TIMER_SEL_MASK …
#define USBIN_LOAD_CFG …
#define USBIN_OV_CH_LOAD_OPTION_BIT …
#define ICL_OVERRIDE_AFTER_APSD_BIT …
#define USBIN_ICL_OPTIONS …
#define CFG_USB3P0_SEL_BIT …
#define USB51_MODE_BIT …
#define USBIN_MODE_CHG_BIT …
#define TYPE_C_INTRPT_ENB_SOFTWARE_CTRL …
#define EXIT_SNK_BASED_ON_CC_BIT …
#define VCONN_EN_ORIENTATION_BIT …
#define TYPEC_VCONN_OVERCURR_INT_EN_BIT …
#define VCONN_EN_SRC_BIT …
#define VCONN_EN_VALUE_BIT …
#define TYPEC_POWER_ROLE_CMD_MASK …
#define UFP_EN_CMD_BIT …
#define DFP_EN_CMD_BIT …
#define TYPEC_DISABLE_CMD_BIT …
#define USBIN_CURRENT_LIMIT_CFG …
#define USBIN_CURRENT_LIMIT_MASK …
#define USBIN_AICL_OPTIONS_CFG …
#define SUSPEND_ON_COLLAPSE_USBIN_BIT …
#define USBIN_AICL_HDC_EN_BIT …
#define USBIN_AICL_START_AT_MAX_BIT …
#define USBIN_AICL_RERUN_EN_BIT …
#define USBIN_AICL_ADC_EN_BIT …
#define USBIN_AICL_EN_BIT …
#define USBIN_HV_COLLAPSE_RESPONSE_BIT …
#define USBIN_LV_COLLAPSE_RESPONSE_BIT …
#define USBIN_5V_AICL_THRESHOLD_CFG …
#define USBIN_5V_AICL_THRESHOLD_CFG_MASK …
#define USBIN_CONT_AICL_THRESHOLD_CFG …
#define USBIN_CONT_AICL_THRESHOLD_CFG_MASK …
#define DC_ENG_SSUPPLY_CFG2 …
#define ENG_SSUPPLY_IVREF_OTG_SS_MASK …
#define OTG_SS_SLOW …
#define DCIN_AICL_REF_SEL_CFG …
#define DCIN_CONT_AICL_THRESHOLD_CFG_MASK …
#define WI_PWR_OPTIONS …
#define CHG_OK_BIT …
#define WIPWR_UVLO_IRQ_OPT_BIT …
#define BUCK_HOLDOFF_ENABLE_BIT …
#define CHG_OK_HW_SW_SELECT_BIT …
#define WIPWR_RST_ENABLE_BIT …
#define DCIN_WIPWR_IRQ_SELECT_BIT …
#define AICL_SWITCH_ENABLE_BIT …
#define ZIN_ICL_ENABLE_BIT …
#define ICL_STATUS …
#define INPUT_CURRENT_LIMIT_MASK …
#define POWER_PATH_STATUS …
#define P_PATH_INPUT_SS_DONE_BIT …
#define P_PATH_USBIN_SUSPEND_STS_BIT …
#define P_PATH_DCIN_SUSPEND_STS_BIT …
#define P_PATH_USE_USBIN_BIT …
#define P_PATH_USE_DCIN_BIT …
#define P_PATH_POWER_PATH_MASK …
#define P_PATH_VALID_INPUT_POWER_SOURCE_STS_BIT …
#define BARK_BITE_WDOG_PET …
#define BARK_BITE_WDOG_PET_BIT …
#define WD_CFG …
#define WATCHDOG_TRIGGER_AFP_EN_BIT …
#define BARK_WDOG_INT_EN_BIT …
#define BITE_WDOG_INT_EN_BIT …
#define SFT_AFTER_WDOG_IRQ_MASK …
#define WDOG_IRQ_SFT_BIT …
#define WDOG_TIMER_EN_ON_PLUGIN_BIT …
#define WDOG_TIMER_EN_BIT …
#define SNARL_BARK_BITE_WD_CFG …
#define BITE_WDOG_DISABLE_CHARGING_CFG_BIT …
#define SNARL_WDOG_TIMEOUT_MASK …
#define BARK_WDOG_TIMEOUT_MASK …
#define BITE_WDOG_TIMEOUT_MASK …
#define AICL_RERUN_TIME_CFG …
#define AICL_RERUN_TIME_MASK …
#define STAT_CFG …
#define STAT_SW_OVERRIDE_VALUE_BIT …
#define STAT_SW_OVERRIDE_CFG_BIT …
#define STAT_PARALLEL_OFF_DG_CFG_MASK …
#define STAT_POLARITY_CFG_BIT …
#define STAT_PARALLEL_CFG_BIT …
#define STAT_FUNCTION_CFG_BIT …
#define STAT_IRQ_PULSING_EN_BIT …
#define SDP_CURRENT_UA …
#define CDP_CURRENT_UA …
#define DCP_CURRENT_UA …
#define CURRENT_MAX_UA …
#define CURRENT_SCALE_FACTOR …
enum charger_status { … };
struct smb2_register { … };
struct smb2_chip { … };
static enum power_supply_property smb2_properties[] = …;
static enum power_supply_usb_type smb2_usb_types[] = …;
static int smb2_get_prop_usb_online(struct smb2_chip *chip, int *val)
{ … }
static int smb2_apsd_get_charger_type(struct smb2_chip *chip, int *val)
{ … }
static int smb2_get_prop_status(struct smb2_chip *chip, int *val)
{ … }
static inline int smb2_get_current_limit(struct smb2_chip *chip,
unsigned int *val)
{ … }
static int smb2_set_current_limit(struct smb2_chip *chip, unsigned int val)
{ … }
static void smb2_status_change_work(struct work_struct *work)
{ … }
static int smb2_get_iio_chan(struct smb2_chip *chip, struct iio_channel *chan,
int *val)
{ … }
static int smb2_get_prop_health(struct smb2_chip *chip, int *val)
{ … }
static int smb2_get_property(struct power_supply *psy,
enum power_supply_property psp,
union power_supply_propval *val)
{ … }
static int smb2_set_property(struct power_supply *psy,
enum power_supply_property psp,
const union power_supply_propval *val)
{ … }
static int smb2_property_is_writable(struct power_supply *psy,
enum power_supply_property psp)
{ … }
static irqreturn_t smb2_handle_batt_overvoltage(int irq, void *data)
{ … }
static irqreturn_t smb2_handle_usb_plugin(int irq, void *data)
{ … }
static irqreturn_t smb2_handle_usb_icl_change(int irq, void *data)
{ … }
static irqreturn_t smb2_handle_wdog_bark(int irq, void *data)
{ … }
static const struct power_supply_desc smb2_psy_desc = …;
static const struct smb2_register smb2_init_seq[] = …;
static int smb2_init_hw(struct smb2_chip *chip)
{ … }
static int smb2_init_irq(struct smb2_chip *chip, int *irq, const char *name,
irqreturn_t (*handler)(int irq, void *data))
{ … }
static int smb2_probe(struct platform_device *pdev)
{ … }
static const struct of_device_id smb2_match_id_table[] = …;
MODULE_DEVICE_TABLE(of, smb2_match_id_table);
static struct platform_driver qcom_spmi_smb2 = …;
module_platform_driver(…) …;
MODULE_AUTHOR(…) …;
MODULE_DESCRIPTION(…) …;
MODULE_LICENSE(…) …;