qcom-charger: smb2: suspend USB path for fake battery or debug board
Add support to identify fake battery/debug board and suspend the USB input path when this is detected. CRs-Fixed: 1107245 Change-Id: Icaa936e4e5b3c9381bc92b6664b32547a820b9c3 Signed-off-by: Ashay Jaiswal <ashayj@codeaurora.org>
This commit is contained in:
parent
bafe291f17
commit
b4fe7907b0
4 changed files with 36 additions and 2 deletions
|
@ -2543,6 +2543,9 @@ static int fg_psy_get_property(struct power_supply *psy,
|
|||
case POWER_SUPPLY_PROP_SOC_REPORTING_READY:
|
||||
pval->intval = chip->soc_reporting_ready;
|
||||
break;
|
||||
case POWER_SUPPLY_PROP_DEBUG_BATTERY:
|
||||
pval->intval = is_debug_batt_id(chip);
|
||||
break;
|
||||
default:
|
||||
pr_err("unsupported property %d\n", psp);
|
||||
rc = -EINVAL;
|
||||
|
@ -2641,6 +2644,7 @@ static enum power_supply_property fg_psy_props[] = {
|
|||
POWER_SUPPLY_PROP_TIME_TO_FULL_AVG,
|
||||
POWER_SUPPLY_PROP_TIME_TO_EMPTY_AVG,
|
||||
POWER_SUPPLY_PROP_SOC_REPORTING_READY,
|
||||
POWER_SUPPLY_PROP_DEBUG_BATTERY,
|
||||
};
|
||||
|
||||
static const struct power_supply_desc fg_psy_desc = {
|
||||
|
@ -2977,6 +2981,9 @@ enable_bmd:
|
|||
if (rc < 0)
|
||||
pr_err("Error in enabling BMD, rc=%d\n", rc);
|
||||
|
||||
if (chip->fg_psy)
|
||||
power_supply_changed(chip->fg_psy);
|
||||
|
||||
return IRQ_HANDLED;
|
||||
}
|
||||
|
||||
|
|
|
@ -1468,7 +1468,10 @@ static int smb2_setup_wa_flags(struct smb2 *chip)
|
|||
static int smb2_determine_initial_status(struct smb2 *chip)
|
||||
{
|
||||
struct smb_irq_data irq_data = {chip, "determine-initial-status"};
|
||||
struct smb_charger *chg = &chip->chg;
|
||||
|
||||
if (chg->bms_psy)
|
||||
smblib_suspend_on_debug_battery(chg);
|
||||
smblib_handle_usb_plugin(0, &irq_data);
|
||||
smblib_handle_usb_typec_change(0, &irq_data);
|
||||
smblib_handle_usb_source_change(0, &irq_data);
|
||||
|
|
|
@ -532,7 +532,7 @@ static int smblib_notifier_call(struct notifier_block *nb,
|
|||
if (!strcmp(psy->desc->name, "bms")) {
|
||||
if (!chg->bms_psy)
|
||||
chg->bms_psy = psy;
|
||||
if (ev == PSY_EVENT_PROP_CHANGED && chg->batt_psy)
|
||||
if (ev == PSY_EVENT_PROP_CHANGED)
|
||||
schedule_work(&chg->bms_update_work);
|
||||
}
|
||||
|
||||
|
@ -642,6 +642,24 @@ static bool smblib_sysok_reason_usbin(struct smb_charger *chg)
|
|||
return stat & SYSOK_REASON_USBIN_BIT;
|
||||
}
|
||||
|
||||
void smblib_suspend_on_debug_battery(struct smb_charger *chg)
|
||||
{
|
||||
int rc;
|
||||
union power_supply_propval val;
|
||||
|
||||
rc = power_supply_get_property(chg->bms_psy,
|
||||
POWER_SUPPLY_PROP_DEBUG_BATTERY, &val);
|
||||
if (rc < 0) {
|
||||
smblib_err(chg, "Couldn't get debug battery prop rc=%d\n", rc);
|
||||
return;
|
||||
}
|
||||
|
||||
vote(chg->usb_suspend_votable, DEBUG_BOARD_VOTER, val.intval, 0);
|
||||
vote(chg->dc_suspend_votable, DEBUG_BOARD_VOTER, val.intval, 0);
|
||||
if (val.intval)
|
||||
pr_info("Input suspended: Fake battery\n");
|
||||
}
|
||||
|
||||
/*********************
|
||||
* VOTABLE CALLBACKS *
|
||||
*********************/
|
||||
|
@ -3299,7 +3317,11 @@ static void bms_update_work(struct work_struct *work)
|
|||
{
|
||||
struct smb_charger *chg = container_of(work, struct smb_charger,
|
||||
bms_update_work);
|
||||
power_supply_changed(chg->batt_psy);
|
||||
|
||||
smblib_suspend_on_debug_battery(chg);
|
||||
|
||||
if (chg->batt_psy)
|
||||
power_supply_changed(chg->batt_psy);
|
||||
}
|
||||
|
||||
static void step_soc_req_work(struct work_struct *work)
|
||||
|
|
|
@ -51,6 +51,7 @@ enum print_reason {
|
|||
#define BOOST_BACK_VOTER "BOOST_BACK_VOTER"
|
||||
#define HVDCP_INDIRECT_VOTER "HVDCP_INDIRECT_VOTER"
|
||||
#define MICRO_USB_VOTER "MICRO_USB_VOTER"
|
||||
#define DEBUG_BOARD_VOTER "DEBUG_BOARD_VOTER"
|
||||
|
||||
#define VCONN_MAX_ATTEMPTS 3
|
||||
#define OTG_MAX_ATTEMPTS 3
|
||||
|
@ -383,6 +384,7 @@ int smblib_get_prop_slave_current_now(struct smb_charger *chg,
|
|||
union power_supply_propval *val);
|
||||
int smblib_set_prop_ship_mode(struct smb_charger *chg,
|
||||
const union power_supply_propval *val);
|
||||
void smblib_suspend_on_debug_battery(struct smb_charger *chg);
|
||||
|
||||
int smblib_init(struct smb_charger *chg);
|
||||
int smblib_deinit(struct smb_charger *chg);
|
||||
|
|
Loading…
Add table
Reference in a new issue