power: supply: qti_battery_charger: Import xiaomi changes

From mayfly-s-oss and moved new attributes to qti_battery_charger_xiaomi

Change-Id: I5de84bc9274c113d39051943d4caf5701c3d65cf
This commit is contained in:
Arian 2023-03-07 18:12:51 +01:00 committed by Jens Reidel
parent ee5b81f970
commit a42be96103
No known key found for this signature in database
GPG Key ID: 23C1E5F512C12303
5 changed files with 5169 additions and 67 deletions

View File

@ -823,6 +823,36 @@ config CHARGER_BQ256XX
charge management and system power path management devices for single
cell Li-ion and Li-polymer batteries.
config BQ_FG_2S
tristate "2s battery fuel gauge support"
help
Say Y here to have support for 2s battery fuel gauge.
config MI_WIRELESS
tristate "mi wirless config"
help
Say Y here to enable mi wireless
config BQ_FUEL_GAUGE
tristate "BQ fuel gauge config"
help
Say y here to enable Bq fuel gauge
config BQ_CLOUD_AUTHENTICATION
tristate "BQ cloud thentication config"
help
Say Y here to enable Bq cloud thentication
config DUAL_FUEL_GAUGE
tristate "BQ fuel gauge config"
help
Say y here to enable Bq fuel gauge
config BQ_FG_UPDATE
tristate "BQ fuel gauge config"
help
Say y here to enable Bq fuel gauge
source "drivers/power/supply/qcom/Kconfig"
endif # POWER_SUPPLY

View File

@ -98,7 +98,7 @@ obj-$(CONFIG_CHARGER_BD70528) += bd70528-charger.o
obj-$(CONFIG_CHARGER_BD99954) += bd99954-charger.o
obj-$(CONFIG_CHARGER_WILCO) += wilco-charger.o
obj-$(CONFIG_QTI_BATTERY_CHARGER) += qti_battery_charger_main.o
qti_battery_charger_main-y += qti_battery_charger.o qti_typec_class.o
qti_battery_charger_main-y += qti_battery_charger.o qti_battery_charger_xiaomi.o qti_typec_class.o
obj-$(CONFIG_RN5T618_POWER) += rn5t618_power.o
obj-$(CONFIG_SCHGM_FLASH) += schgm-flash.o
obj-$(CONFIG_CHARGER_BQ256XX) += bq256xx_charger.o

File diff suppressed because it is too large Load Diff

View File

@ -20,6 +20,7 @@
#define BC_WLS_STATUS_GET 0x34
#define BC_WLS_STATUS_SET 0x35
#define BC_SHIP_MODE_REQ_SET 0x36
#define BC_SHUTDOWN_REQ_SET 0x37
#define BC_WLS_FW_CHECK_UPDATE 0x40
#define BC_WLS_FW_PUSH_BUF_REQ 0x41
#define BC_WLS_FW_UPDATE_STATUS_RESP 0x42
@ -28,6 +29,8 @@
#define BC_SHUTDOWN_NOTIFY 0x47
#define BC_HBOOST_VMAX_CLAMP_NOTIFY 0x79
#define BC_GENERIC_NOTIFY 0x80
#define BC_XM_STATUS_GET 0x50
#define BC_XM_STATUS_SET 0x51
/* Generic definitions */
#define MAX_STR_LEN 128
@ -43,10 +46,34 @@ enum usb_connector_type {
USB_CONNECTOR_TYPE_MICRO_USB,
};
#if defined(CONFIG_BQ_FG_2S)
#define BATTERY_DIGEST_LEN 20
#else
#define BATTERY_DIGEST_LEN 32
#endif
#define BATTERY_SS_AUTH_DATA_LEN 4
#define USBPD_UVDM_SS_LEN 4
#define USBPD_UVDM_VERIFIED_LEN 1
#define MAX_THERMAL_LEVEL 16
enum uvdm_state {
USBPD_UVDM_DISCONNECT,
USBPD_UVDM_CHARGER_VERSION,
USBPD_UVDM_CHARGER_VOLTAGE,
USBPD_UVDM_CHARGER_TEMP,
USBPD_UVDM_SESSION_SEED,
USBPD_UVDM_AUTHENTICATION,
USBPD_UVDM_VERIFIED,
USBPD_UVDM_REMOVE_COMPENSATION,
USBPD_UVDM_REVERSE_AUTHEN,
USBPD_UVDM_CONNECT,
};
enum psy_type {
PSY_TYPE_BATTERY,
PSY_TYPE_USB,
PSY_TYPE_WLS,
PSY_TYPE_XM,
PSY_TYPE_MAX,
};
@ -69,6 +96,7 @@ enum battery_property_id {
BATT_CURR_NOW,
BATT_CHG_CTRL_LIM,
BATT_CHG_CTRL_LIM_MAX,
BATT_CONSTANT_CURRENT,
BATT_TEMP,
BATT_TECHNOLOGY,
BATT_CHG_COUNTER,
@ -115,10 +143,200 @@ enum wireless_property_id {
WLS_PROP_MAX,
};
enum xm_property_id {
XM_PROP_RESISTANCE_ID,
XM_PROP_VERIFY_DIGEST,
XM_PROP_CONNECTOR_TEMP,
XM_PROP_AUTHENTIC,
XM_PROP_CHIP_OK,
XM_PROP_VBUS_DISABLE,
XM_PROP_REAL_TYPE,
/*used for pd authentic*/
XM_PROP_VERIFY_PROCESS,
XM_PROP_VDM_CMD_CHARGER_VERSION,
XM_PROP_VDM_CMD_CHARGER_VOLTAGE,
XM_PROP_VDM_CMD_CHARGER_TEMP,
XM_PROP_VDM_CMD_SESSION_SEED,
XM_PROP_VDM_CMD_AUTHENTICATION,
XM_PROP_VDM_CMD_VERIFIED,
XM_PROP_VDM_CMD_REMOVE_COMPENSATION,
XM_PROP_VDM_CMD_REVERSE_AUTHEN,
XM_PROP_CURRENT_STATE,
XM_PROP_ADAPTER_ID,
XM_PROP_ADAPTER_SVID,
XM_PROP_PD_VERIFED,
XM_PROP_PDO2,
XM_PROP_UVDM_STATE,
/*charger_pump sys node*/
XM_PROP_BQ2597X_CHIP_OK,
XM_PROP_BQ2597X_SLAVE_CHIP_OK,
XM_PROP_BQ2597X_BUS_CURRENT,
XM_PROP_BQ2597X_SLAVE_BUS_CURRENT,
XM_PROP_BQ2597X_BUS_DELTA,
XM_PROP_BQ2597X_BUS_VOLTAGE,
XM_PROP_BQ2597X_BATTERY_PRESENT,
XM_PROP_BQ2597X_SLAVE_BATTERY_PRESENT,
XM_PROP_BQ2597X_BATTERY_VOLTAGE,
XM_PROP_MASTER_SMB1396_ONLINE,
XM_PROP_MASTER_SMB1396_IIN,
XM_PROP_SLAVE_SMB1396_ONLINE,
XM_PROP_SLAVE_SMB1396_IIN,
XM_PROP_SMB_IIN_DIFF,
XM_PROP_CC_ORIENTATION,
XM_PROP_INPUT_SUSPEND,
XM_PROP_FASTCHGMODE,
XM_PROP_NIGHT_CHARGING,
XM_PROP_SOC_DECIMAL,
XM_PROP_SOC_DECIMAL_RATE,
XM_PROP_QUICK_CHARGE_TYPE,
XM_PROP_APDO_MAX,
XM_PROP_DIE_TEMPERATURE,
XM_PROP_SLAVE_DIE_TEMPERATURE,
/* wireless charge infor */
XM_PROP_WLS_START = 50,
XM_PROP_TX_MACL,
XM_PROP_TX_MACH,
XM_PROP_RX_CRL,
XM_PROP_RX_CRH,
XM_PROP_RX_CEP,
XM_PROP_BT_STATE,
XM_PROP_REVERSE_CHG_MODE,
XM_PROP_REVERSE_CHG_STATE,
XM_PROP_RX_VOUT,
XM_PROP_RX_VRECT,
XM_PROP_RX_IOUT,
XM_PROP_TX_ADAPTER,
XM_PROP_OP_MODE,
XM_PROP_WLS_DIE_TEMP,
XM_PROP_WLS_BIN,
XM_PROP_WLSCHARGE_CONTROL_LIMIT,
XM_PROP_FW_VER,
XM_PROP_WLS_THERMAL_REMOVE,
XM_PROP_WLS_DEBUG,
XM_PROP_WLS_FW_STATE,
XM_PROP_WLS_CAR_ADAPTER,
XM_PROP_WLS_TX_SPEED,
XM_PROP_WLS_FC_FLAG,
XM_PROP_WLS_END = 80,
/**********************/
XM_PROP_SHUTDOWN_DELAY,
XM_PROP_FAKE_TEMP,
XM_PROP_THERMAL_REMOVE,
XM_PROP_TYPEC_MODE,
XM_PROP_MTBF_CURRENT,
XM_PROP_THERMAL_TEMP,
XM_PROP_FB_BLANK_STATE,
XM_PROP_SMART_BATT,
XM_PROP_SHIPMODE_COUNT_RESET,
XM_PROP_SPORT_MODE,
XM_PROP_BATT_CONNT_ONLINE,
XM_PROP_FAKE_CYCLE,
XM_PROP_FAKE_SOH,
/*********nvt fuelgauge feature*********/
XM_PROP_NVTFG_MONITOR_ISC,
XM_PROP_NVTFG_MONITOR_SOA,
XM_PROP_OVER_PEAK_FLAG,
XM_PROP_CURRENT_DEVIATION,
XM_PROP_POWER_DEVIATION,
XM_PROP_AVERAGE_CURRENT,
XM_PROP_AVERAGE_TEMPERATURE,
XM_PROP_START_LEARNING,
XM_PROP_STOP_LEARNING,
XM_PROP_SET_LEARNING_POWER,
XM_PROP_GET_LEARNING_POWER,
XM_PROP_GET_LEARNING_POWER_DEV,
XM_PROP_GET_LEARNING_TIME_DEV,
XM_PROP_SET_CONSTANT_POWER,
XM_PROP_GET_REMAINING_TIME,
XM_PROP_SET_REFERANCE_POWER,
XM_PROP_GET_REFERANCE_CURRENT,
XM_PROP_GET_REFERANCE_POWER,
XM_PROP_START_LEARNING_B,
XM_PROP_STOP_LEARNING_B,
XM_PROP_SET_LEARNING_POWER_B,
XM_PROP_GET_LEARNING_POWER_B,
XM_PROP_GET_LEARNING_POWER_DEV_B,
/*********nvt fuelgauge feature*********/
/*fuelgauge test node*/
XM_PROP_FG1_QMAX,
XM_PROP_FG1_RM,
XM_PROP_FG1_FCC,
XM_PROP_FG1_SOH,
XM_PROP_FG1_FCC_SOH,
XM_PROP_FG1_CYCLE,
XM_PROP_FG1_FAST_CHARGE,
XM_PROP_FG1_CURRENT_MAX,
XM_PROP_FG1_VOL_MAX,
XM_PROP_FG1_TSIM,
XM_PROP_FG1_TAMBIENT,
XM_PROP_FG1_TREMQ,
XM_PROP_FG1_TFULLQ,
XM_PROP_FG1_RSOC,
XM_PROP_FG1_AI,
XM_PROP_FG1_CELL1_VOL,
XM_PROP_FG1_CELL2_VOL,
/* dual fuelgauge test node only for L18*/
XM_PROP_SLAVE_CHIP_OK,
XM_PROP_SLAVE_AUTHENTIC,
XM_PROP_FG1_VOL,
XM_PROP_FG1_SOC,
XM_PROP_FG1_TEMP,
XM_PROP_FG1_IBATT,
XM_PROP_FG1_ChargingStatus,
XM_PROP_FG1_GaugingStatus,
XM_PROP_FG1_FullChargeFlag,
XM_PROP_FG2_VOL,
XM_PROP_FG2_SOC,
XM_PROP_FG2_TEMP,
XM_PROP_FG2_IBATT,
XM_PROP_FG2_QMAX,
XM_PROP_FG2_RM,
XM_PROP_FG2_FCC,
XM_PROP_FG2_SOH,
XM_PROP_FG2_FCC_SOH,
XM_PROP_FG2_CYCLE,
XM_PROP_FG2_FAST_CHARGE,
XM_PROP_FG2_CURRENT_MAX,
XM_PROP_FG2_VOL_MAX,
XM_PROP_FG2_TSIM,
XM_PROP_FG2_TAMBIENT,
XM_PROP_FG2_TREMQ,
XM_PROP_FG2_TFULLQ,
XM_PROP_FG2_ChargingStatus,
XM_PROP_FG2_GaugingStatus,
XM_PROP_FG2_FullChargeFlag,
XM_PROP_FG2_RSOC,
XM_PROP_FG_VENDOR_ID,
/*begin dual fuel high temperature intercept feature */
XM_PROP_FG_VOLTAGE_MAX,
XM_PROP_FG_Charge_Current_MAX,
XM_PROP_FG_Discharge_Current_MAX,
XM_PROP_FG_TEMP_MAX,
XM_PROP_FG_TEMP_MIN,
XM_PROP_FG_TIME_HT,
XM_PROP_FG_TIME_OT,
XM_PROP_FG_TIME_UT,
XM_PROP_FG_TIME_LT,
XM_PROP_FG_SEAL_SET,
XM_PROP_FG1_SEAL_STATE,
XM_PROP_FG1_DF_CHECK,
XM_PROP_FG2_SEAL_STATE,
XM_PROP_FG2_DF_CHECK,
/*end dual fuel high temperature intercept feature*/
#if defined(CONFIG_BQ_CLOUD_AUTHENTICATION)
XM_PROP_SERVER_SN,
XM_PROP_SERVER_RESULT,
XM_PROP_ADSP_RESULT,
#endif
XM_PROP_MAX,
};
enum {
QTI_POWER_SUPPLY_USB_TYPE_HVDCP = 0x80,
QTI_POWER_SUPPLY_USB_TYPE_HVDCP_3,
QTI_POWER_SUPPLY_USB_TYPE_HVDCP_3P5,
QTI_POWER_SUPPLY_USB_TYPE_USB_FLOAT,
QTI_POWER_SUPPLY_USB_TYPE_HVDCP_3_CLASSB,
};
struct battery_charger_set_notify_msg {
@ -148,12 +366,34 @@ struct battery_charger_resp_msg {
u32 ret_code;
};
struct wls_fw_resp_msg {
struct pmic_glink_hdr hdr;
u32 property_id;
u32 value;
char version[MAX_STR_LEN - 32];
};
struct wls_debug_msg {
struct pmic_glink_hdr hdr;
u32 property_id;
char data[MAX_STR_LEN];
};
struct battery_model_resp_msg {
struct pmic_glink_hdr hdr;
u32 property_id;
char model[MAX_STR_LEN];
};
struct xm_set_wls_bin_req_msg {
struct pmic_glink_hdr hdr;
u32 property_id;
u16 total_length;
u8 serial_number;
u8 fw_area;
u8 wls_fw_bin[MAX_STR_LEN];
}; /* Message */
struct wireless_fw_check_req {
struct pmic_glink_hdr hdr;
u32 fw_version;
@ -196,9 +436,28 @@ struct battery_charger_ship_mode_req_msg {
u32 ship_mode_type;
};
struct xm_verify_digest_resp_msg {
struct pmic_glink_hdr hdr;
u32 property_id;
u8 digest[BATTERY_DIGEST_LEN];
/*dual battery master and slave flag*/
bool slave_fg;
};
struct battery_charger_shutdown_req_msg {
struct pmic_glink_hdr hdr;
};
struct xm_ss_auth_resp_msg {
struct pmic_glink_hdr hdr;
u32 property_id;
u32 data[BATTERY_SS_AUTH_DATA_LEN];
};
struct psy_state {
struct power_supply *psy;
char *model;
char *version;
const int *map;
u32 *prop;
u32 prop_count;
@ -224,22 +483,26 @@ struct battery_chg_dev {
u32 *thermal_levels;
const char *wls_fw_name;
int curr_thermal_level;
int curr_wlsthermal_level;
int num_thermal_levels;
int shutdown_volt_mv;
atomic_t state;
struct work_struct subsys_up_work;
struct work_struct usb_type_work;
struct work_struct battery_check_work;
struct work_struct notify_blankstate_work;
int fake_soc;
bool block_tx;
bool ship_mode_en;
bool debug_battery_detected;
bool wls_not_supported;
bool wls_fw_update_reqd;
bool debug_work_en;
u32 wls_fw_version;
u16 wls_fw_crc;
u32 wls_fw_update_time_ms;
struct notifier_block reboot_notifier;
struct notifier_block shutdown_notifier;
u32 thermal_fcc_ua;
u32 restrict_fcc_ua;
u32 last_fcc_ua;
@ -247,9 +510,36 @@ struct battery_chg_dev {
u32 thermal_fcc_step;
u32 connector_type;
u32 usb_prev_mode;
u32 reverse_chg_flag;
u32 boost_mode;
bool restrict_chg_en;
struct delayed_work xm_prop_change_work;
struct delayed_work charger_debug_info_print_work;
#if defined(CONFIG_BQ_FG_UPDATE)
struct delayed_work batt_update_work;
#endif
struct delayed_work panel_notify_register_work;
struct delayed_work panel_sec_notify_register_work;
/* To track the driver initialization status */
bool initialized;
bool notify_en;
bool error_prop;
u8 *digest;
u32 *ss_auth_data;
char wls_debug_data[MAX_STR_LEN];
/*shutdown delay is supported*/
bool shutdown_delay_en;
bool support_2s_charging;
bool report_power_absent;
bool support_dual_panel;
/*dual battery authentic flag*/
bool slave_fg_verify_flag;
/*soc update flag*/
bool support_soc_update;
/*battery auth check for ssr*/
bool battery_auth;
bool slave_battery_auth;
int mtbf_current;
};

File diff suppressed because it is too large Load Diff