power: supply: qti_battery_charger: Create header for defines, enums and structs
These will be used by the xiaomi additions in an upcoming commit Change-Id: I80aaa7c46f7690ebf7c432f0a74cfd24246c29c4
This commit is contained in:
parent
73606279f7
commit
42d3441c27
@ -20,245 +20,10 @@
|
||||
#include <linux/power_supply.h>
|
||||
#include <linux/soc/qcom/pmic_glink.h>
|
||||
#include <linux/soc/qcom/battery_charger.h>
|
||||
|
||||
#include "qti_battery_charger.h"
|
||||
#include "qti_typec_class.h"
|
||||
|
||||
#define MSG_OWNER_BC 32778
|
||||
#define MSG_TYPE_REQ_RESP 1
|
||||
#define MSG_TYPE_NOTIFY 2
|
||||
|
||||
/* opcode for battery charger */
|
||||
#define BC_SET_NOTIFY_REQ 0x04
|
||||
#define BC_NOTIFY_IND 0x07
|
||||
#define BC_BATTERY_STATUS_GET 0x30
|
||||
#define BC_BATTERY_STATUS_SET 0x31
|
||||
#define BC_USB_STATUS_GET 0x32
|
||||
#define BC_USB_STATUS_SET 0x33
|
||||
#define BC_WLS_STATUS_GET 0x34
|
||||
#define BC_WLS_STATUS_SET 0x35
|
||||
#define BC_SHIP_MODE_REQ_SET 0x36
|
||||
#define BC_WLS_FW_CHECK_UPDATE 0x40
|
||||
#define BC_WLS_FW_PUSH_BUF_REQ 0x41
|
||||
#define BC_WLS_FW_UPDATE_STATUS_RESP 0x42
|
||||
#define BC_WLS_FW_PUSH_BUF_RESP 0x43
|
||||
#define BC_WLS_FW_GET_VERSION 0x44
|
||||
#define BC_SHUTDOWN_NOTIFY 0x47
|
||||
#define BC_GENERIC_NOTIFY 0x80
|
||||
|
||||
/* Generic definitions */
|
||||
#define MAX_STR_LEN 128
|
||||
#define BC_WAIT_TIME_MS 1000
|
||||
#define WLS_FW_PREPARE_TIME_MS 300
|
||||
#define WLS_FW_WAIT_TIME_MS 500
|
||||
#define WLS_FW_UPDATE_TIME_MS 1000
|
||||
#define WLS_FW_BUF_SIZE 128
|
||||
#define DEFAULT_RESTRICT_FCC_UA 1000000
|
||||
|
||||
enum usb_connector_type {
|
||||
USB_CONNECTOR_TYPE_TYPEC,
|
||||
USB_CONNECTOR_TYPE_MICRO_USB,
|
||||
};
|
||||
|
||||
enum psy_type {
|
||||
PSY_TYPE_BATTERY,
|
||||
PSY_TYPE_USB,
|
||||
PSY_TYPE_WLS,
|
||||
PSY_TYPE_MAX,
|
||||
};
|
||||
|
||||
enum ship_mode_type {
|
||||
SHIP_MODE_PMIC,
|
||||
SHIP_MODE_PACK_SIDE,
|
||||
};
|
||||
|
||||
/* property ids */
|
||||
enum battery_property_id {
|
||||
BATT_STATUS,
|
||||
BATT_HEALTH,
|
||||
BATT_PRESENT,
|
||||
BATT_CHG_TYPE,
|
||||
BATT_CAPACITY,
|
||||
BATT_SOH,
|
||||
BATT_VOLT_OCV,
|
||||
BATT_VOLT_NOW,
|
||||
BATT_VOLT_MAX,
|
||||
BATT_CURR_NOW,
|
||||
BATT_CHG_CTRL_LIM,
|
||||
BATT_CHG_CTRL_LIM_MAX,
|
||||
BATT_TEMP,
|
||||
BATT_TECHNOLOGY,
|
||||
BATT_CHG_COUNTER,
|
||||
BATT_CYCLE_COUNT,
|
||||
BATT_CHG_FULL_DESIGN,
|
||||
BATT_CHG_FULL,
|
||||
BATT_MODEL_NAME,
|
||||
BATT_TTF_AVG,
|
||||
BATT_TTE_AVG,
|
||||
BATT_RESISTANCE,
|
||||
BATT_POWER_NOW,
|
||||
BATT_POWER_AVG,
|
||||
BATT_PROP_MAX,
|
||||
};
|
||||
|
||||
enum usb_property_id {
|
||||
USB_ONLINE,
|
||||
USB_VOLT_NOW,
|
||||
USB_VOLT_MAX,
|
||||
USB_CURR_NOW,
|
||||
USB_CURR_MAX,
|
||||
USB_INPUT_CURR_LIMIT,
|
||||
USB_TYPE,
|
||||
USB_ADAP_TYPE,
|
||||
USB_MOISTURE_DET_EN,
|
||||
USB_MOISTURE_DET_STS,
|
||||
USB_TEMP,
|
||||
USB_REAL_TYPE,
|
||||
USB_TYPEC_COMPLIANT,
|
||||
USB_SCOPE,
|
||||
USB_CONNECTOR_TYPE,
|
||||
USB_PROP_MAX,
|
||||
};
|
||||
|
||||
enum wireless_property_id {
|
||||
WLS_ONLINE,
|
||||
WLS_VOLT_NOW,
|
||||
WLS_VOLT_MAX,
|
||||
WLS_CURR_NOW,
|
||||
WLS_CURR_MAX,
|
||||
WLS_TYPE,
|
||||
WLS_BOOST_EN,
|
||||
WLS_PROP_MAX,
|
||||
};
|
||||
|
||||
enum {
|
||||
QTI_POWER_SUPPLY_USB_TYPE_HVDCP = 0x80,
|
||||
QTI_POWER_SUPPLY_USB_TYPE_HVDCP_3,
|
||||
QTI_POWER_SUPPLY_USB_TYPE_HVDCP_3P5,
|
||||
};
|
||||
|
||||
struct battery_charger_set_notify_msg {
|
||||
struct pmic_glink_hdr hdr;
|
||||
u32 battery_id;
|
||||
u32 power_state;
|
||||
u32 low_capacity;
|
||||
u32 high_capacity;
|
||||
};
|
||||
|
||||
struct battery_charger_notify_msg {
|
||||
struct pmic_glink_hdr hdr;
|
||||
u32 notification;
|
||||
};
|
||||
|
||||
struct battery_charger_req_msg {
|
||||
struct pmic_glink_hdr hdr;
|
||||
u32 battery_id;
|
||||
u32 property_id;
|
||||
u32 value;
|
||||
};
|
||||
|
||||
struct battery_charger_resp_msg {
|
||||
struct pmic_glink_hdr hdr;
|
||||
u32 property_id;
|
||||
u32 value;
|
||||
u32 ret_code;
|
||||
};
|
||||
|
||||
struct battery_model_resp_msg {
|
||||
struct pmic_glink_hdr hdr;
|
||||
u32 property_id;
|
||||
char model[MAX_STR_LEN];
|
||||
};
|
||||
|
||||
struct wireless_fw_check_req {
|
||||
struct pmic_glink_hdr hdr;
|
||||
u32 fw_version;
|
||||
u32 fw_size;
|
||||
u32 fw_crc;
|
||||
};
|
||||
|
||||
struct wireless_fw_check_resp {
|
||||
struct pmic_glink_hdr hdr;
|
||||
u32 ret_code;
|
||||
};
|
||||
|
||||
struct wireless_fw_push_buf_req {
|
||||
struct pmic_glink_hdr hdr;
|
||||
u8 buf[WLS_FW_BUF_SIZE];
|
||||
u32 fw_chunk_id;
|
||||
};
|
||||
|
||||
struct wireless_fw_push_buf_resp {
|
||||
struct pmic_glink_hdr hdr;
|
||||
u32 fw_update_status;
|
||||
};
|
||||
|
||||
struct wireless_fw_update_status {
|
||||
struct pmic_glink_hdr hdr;
|
||||
u32 fw_update_done;
|
||||
};
|
||||
|
||||
struct wireless_fw_get_version_req {
|
||||
struct pmic_glink_hdr hdr;
|
||||
};
|
||||
|
||||
struct wireless_fw_get_version_resp {
|
||||
struct pmic_glink_hdr hdr;
|
||||
u32 fw_version;
|
||||
};
|
||||
|
||||
struct battery_charger_ship_mode_req_msg {
|
||||
struct pmic_glink_hdr hdr;
|
||||
u32 ship_mode_type;
|
||||
};
|
||||
|
||||
struct psy_state {
|
||||
struct power_supply *psy;
|
||||
char *model;
|
||||
const int *map;
|
||||
u32 *prop;
|
||||
u32 prop_count;
|
||||
u32 opcode_get;
|
||||
u32 opcode_set;
|
||||
};
|
||||
|
||||
struct battery_chg_dev {
|
||||
struct device *dev;
|
||||
struct class battery_class;
|
||||
struct pmic_glink_client *client;
|
||||
struct typec_role_class *typec_class;
|
||||
struct mutex rw_lock;
|
||||
struct completion ack;
|
||||
struct completion fw_buf_ack;
|
||||
struct completion fw_update_ack;
|
||||
struct psy_state psy_list[PSY_TYPE_MAX];
|
||||
struct dentry *debugfs_dir;
|
||||
/* extcon for VBUS/ID notification for USB for micro USB */
|
||||
struct extcon_dev *extcon;
|
||||
u32 *thermal_levels;
|
||||
const char *wls_fw_name;
|
||||
int curr_thermal_level;
|
||||
int num_thermal_levels;
|
||||
atomic_t state;
|
||||
struct work_struct subsys_up_work;
|
||||
struct work_struct usb_type_work;
|
||||
int fake_soc;
|
||||
bool block_tx;
|
||||
bool ship_mode_en;
|
||||
bool debug_battery_detected;
|
||||
bool wls_fw_update_reqd;
|
||||
u32 wls_fw_version;
|
||||
u16 wls_fw_crc;
|
||||
struct notifier_block reboot_notifier;
|
||||
u32 thermal_fcc_ua;
|
||||
u32 restrict_fcc_ua;
|
||||
u32 last_fcc_ua;
|
||||
u32 usb_icl_ua;
|
||||
u32 connector_type;
|
||||
u32 usb_prev_mode;
|
||||
bool restrict_chg_en;
|
||||
/* To track the driver initialization status */
|
||||
bool initialized;
|
||||
};
|
||||
|
||||
static const int battery_prop_map[BATT_PROP_MAX] = {
|
||||
[BATT_STATUS] = POWER_SUPPLY_PROP_STATUS,
|
||||
[BATT_HEALTH] = POWER_SUPPLY_PROP_HEALTH,
|
||||
|
242
drivers/power/supply/qti_battery_charger.h
Normal file
242
drivers/power/supply/qti_battery_charger.h
Normal file
@ -0,0 +1,242 @@
|
||||
// SPDX-License-Identifier: GPL-2.0-only
|
||||
//
|
||||
// Copyright (C) 2019-2021 The Linux Foundation. All rights reserved.
|
||||
// 2022 The LineageOS Project
|
||||
//
|
||||
|
||||
#define MSG_OWNER_BC 32778
|
||||
#define MSG_TYPE_REQ_RESP 1
|
||||
#define MSG_TYPE_NOTIFY 2
|
||||
|
||||
/* opcode for battery charger */
|
||||
#define BC_SET_NOTIFY_REQ 0x04
|
||||
#define BC_NOTIFY_IND 0x07
|
||||
#define BC_BATTERY_STATUS_GET 0x30
|
||||
#define BC_BATTERY_STATUS_SET 0x31
|
||||
#define BC_USB_STATUS_GET 0x32
|
||||
#define BC_USB_STATUS_SET 0x33
|
||||
#define BC_WLS_STATUS_GET 0x34
|
||||
#define BC_WLS_STATUS_SET 0x35
|
||||
#define BC_SHIP_MODE_REQ_SET 0x36
|
||||
#define BC_WLS_FW_CHECK_UPDATE 0x40
|
||||
#define BC_WLS_FW_PUSH_BUF_REQ 0x41
|
||||
#define BC_WLS_FW_UPDATE_STATUS_RESP 0x42
|
||||
#define BC_WLS_FW_PUSH_BUF_RESP 0x43
|
||||
#define BC_WLS_FW_GET_VERSION 0x44
|
||||
#define BC_SHUTDOWN_NOTIFY 0x47
|
||||
#define BC_GENERIC_NOTIFY 0x80
|
||||
|
||||
/* Generic definitions */
|
||||
#define MAX_STR_LEN 128
|
||||
#define BC_WAIT_TIME_MS 1000
|
||||
#define WLS_FW_PREPARE_TIME_MS 300
|
||||
#define WLS_FW_WAIT_TIME_MS 500
|
||||
#define WLS_FW_UPDATE_TIME_MS 1000
|
||||
#define WLS_FW_BUF_SIZE 128
|
||||
#define DEFAULT_RESTRICT_FCC_UA 1000000
|
||||
|
||||
enum usb_connector_type {
|
||||
USB_CONNECTOR_TYPE_TYPEC,
|
||||
USB_CONNECTOR_TYPE_MICRO_USB,
|
||||
};
|
||||
|
||||
enum psy_type {
|
||||
PSY_TYPE_BATTERY,
|
||||
PSY_TYPE_USB,
|
||||
PSY_TYPE_WLS,
|
||||
PSY_TYPE_MAX,
|
||||
};
|
||||
|
||||
enum ship_mode_type {
|
||||
SHIP_MODE_PMIC,
|
||||
SHIP_MODE_PACK_SIDE,
|
||||
};
|
||||
|
||||
/* property ids */
|
||||
enum battery_property_id {
|
||||
BATT_STATUS,
|
||||
BATT_HEALTH,
|
||||
BATT_PRESENT,
|
||||
BATT_CHG_TYPE,
|
||||
BATT_CAPACITY,
|
||||
BATT_SOH,
|
||||
BATT_VOLT_OCV,
|
||||
BATT_VOLT_NOW,
|
||||
BATT_VOLT_MAX,
|
||||
BATT_CURR_NOW,
|
||||
BATT_CHG_CTRL_LIM,
|
||||
BATT_CHG_CTRL_LIM_MAX,
|
||||
BATT_TEMP,
|
||||
BATT_TECHNOLOGY,
|
||||
BATT_CHG_COUNTER,
|
||||
BATT_CYCLE_COUNT,
|
||||
BATT_CHG_FULL_DESIGN,
|
||||
BATT_CHG_FULL,
|
||||
BATT_MODEL_NAME,
|
||||
BATT_TTF_AVG,
|
||||
BATT_TTE_AVG,
|
||||
BATT_RESISTANCE,
|
||||
BATT_POWER_NOW,
|
||||
BATT_POWER_AVG,
|
||||
BATT_PROP_MAX,
|
||||
};
|
||||
|
||||
enum usb_property_id {
|
||||
USB_ONLINE,
|
||||
USB_VOLT_NOW,
|
||||
USB_VOLT_MAX,
|
||||
USB_CURR_NOW,
|
||||
USB_CURR_MAX,
|
||||
USB_INPUT_CURR_LIMIT,
|
||||
USB_TYPE,
|
||||
USB_ADAP_TYPE,
|
||||
USB_MOISTURE_DET_EN,
|
||||
USB_MOISTURE_DET_STS,
|
||||
USB_TEMP,
|
||||
USB_REAL_TYPE,
|
||||
USB_TYPEC_COMPLIANT,
|
||||
USB_SCOPE,
|
||||
USB_CONNECTOR_TYPE,
|
||||
USB_PROP_MAX,
|
||||
};
|
||||
|
||||
enum wireless_property_id {
|
||||
WLS_ONLINE,
|
||||
WLS_VOLT_NOW,
|
||||
WLS_VOLT_MAX,
|
||||
WLS_CURR_NOW,
|
||||
WLS_CURR_MAX,
|
||||
WLS_TYPE,
|
||||
WLS_BOOST_EN,
|
||||
WLS_PROP_MAX,
|
||||
};
|
||||
|
||||
enum {
|
||||
QTI_POWER_SUPPLY_USB_TYPE_HVDCP = 0x80,
|
||||
QTI_POWER_SUPPLY_USB_TYPE_HVDCP_3,
|
||||
QTI_POWER_SUPPLY_USB_TYPE_HVDCP_3P5,
|
||||
};
|
||||
|
||||
struct battery_charger_set_notify_msg {
|
||||
struct pmic_glink_hdr hdr;
|
||||
u32 battery_id;
|
||||
u32 power_state;
|
||||
u32 low_capacity;
|
||||
u32 high_capacity;
|
||||
};
|
||||
|
||||
struct battery_charger_notify_msg {
|
||||
struct pmic_glink_hdr hdr;
|
||||
u32 notification;
|
||||
};
|
||||
|
||||
struct battery_charger_req_msg {
|
||||
struct pmic_glink_hdr hdr;
|
||||
u32 battery_id;
|
||||
u32 property_id;
|
||||
u32 value;
|
||||
};
|
||||
|
||||
struct battery_charger_resp_msg {
|
||||
struct pmic_glink_hdr hdr;
|
||||
u32 property_id;
|
||||
u32 value;
|
||||
u32 ret_code;
|
||||
};
|
||||
|
||||
struct battery_model_resp_msg {
|
||||
struct pmic_glink_hdr hdr;
|
||||
u32 property_id;
|
||||
char model[MAX_STR_LEN];
|
||||
};
|
||||
|
||||
struct wireless_fw_check_req {
|
||||
struct pmic_glink_hdr hdr;
|
||||
u32 fw_version;
|
||||
u32 fw_size;
|
||||
u32 fw_crc;
|
||||
};
|
||||
|
||||
struct wireless_fw_check_resp {
|
||||
struct pmic_glink_hdr hdr;
|
||||
u32 ret_code;
|
||||
};
|
||||
|
||||
struct wireless_fw_push_buf_req {
|
||||
struct pmic_glink_hdr hdr;
|
||||
u8 buf[WLS_FW_BUF_SIZE];
|
||||
u32 fw_chunk_id;
|
||||
};
|
||||
|
||||
struct wireless_fw_push_buf_resp {
|
||||
struct pmic_glink_hdr hdr;
|
||||
u32 fw_update_status;
|
||||
};
|
||||
|
||||
struct wireless_fw_update_status {
|
||||
struct pmic_glink_hdr hdr;
|
||||
u32 fw_update_done;
|
||||
};
|
||||
|
||||
struct wireless_fw_get_version_req {
|
||||
struct pmic_glink_hdr hdr;
|
||||
};
|
||||
|
||||
struct wireless_fw_get_version_resp {
|
||||
struct pmic_glink_hdr hdr;
|
||||
u32 fw_version;
|
||||
};
|
||||
|
||||
struct battery_charger_ship_mode_req_msg {
|
||||
struct pmic_glink_hdr hdr;
|
||||
u32 ship_mode_type;
|
||||
};
|
||||
|
||||
struct psy_state {
|
||||
struct power_supply *psy;
|
||||
char *model;
|
||||
const int *map;
|
||||
u32 *prop;
|
||||
u32 prop_count;
|
||||
u32 opcode_get;
|
||||
u32 opcode_set;
|
||||
};
|
||||
|
||||
struct battery_chg_dev {
|
||||
struct device *dev;
|
||||
struct class battery_class;
|
||||
struct pmic_glink_client *client;
|
||||
struct typec_role_class *typec_class;
|
||||
struct mutex rw_lock;
|
||||
struct completion ack;
|
||||
struct completion fw_buf_ack;
|
||||
struct completion fw_update_ack;
|
||||
struct psy_state psy_list[PSY_TYPE_MAX];
|
||||
struct dentry *debugfs_dir;
|
||||
/* extcon for VBUS/ID notification for USB for micro USB */
|
||||
struct extcon_dev *extcon;
|
||||
u32 *thermal_levels;
|
||||
const char *wls_fw_name;
|
||||
int curr_thermal_level;
|
||||
int num_thermal_levels;
|
||||
atomic_t state;
|
||||
struct work_struct subsys_up_work;
|
||||
struct work_struct usb_type_work;
|
||||
int fake_soc;
|
||||
bool block_tx;
|
||||
bool ship_mode_en;
|
||||
bool debug_battery_detected;
|
||||
bool wls_fw_update_reqd;
|
||||
u32 wls_fw_version;
|
||||
u16 wls_fw_crc;
|
||||
struct notifier_block reboot_notifier;
|
||||
u32 thermal_fcc_ua;
|
||||
u32 restrict_fcc_ua;
|
||||
u32 last_fcc_ua;
|
||||
u32 usb_icl_ua;
|
||||
u32 connector_type;
|
||||
u32 usb_prev_mode;
|
||||
bool restrict_chg_en;
|
||||
/* To track the driver initialization status */
|
||||
bool initialized;
|
||||
};
|
Loading…
Reference in New Issue
Block a user