Merge "power: smb5-lib: Add sysfs entry to enable/disable moisture detection"
This commit is contained in:
commit
45e179b3b1
@ -1,6 +1,6 @@
|
||||
// SPDX-License-Identifier: GPL-2.0-only
|
||||
/*
|
||||
* Copyright (c) 2020 The Linux Foundation. All rights reserved.
|
||||
* Copyright (c) 2020-2021 The Linux Foundation. All rights reserved.
|
||||
*/
|
||||
|
||||
#include <linux/delay.h>
|
||||
@ -99,6 +99,9 @@ int smb5_iio_get_prop(struct smb_charger *chg, int channel, int *val)
|
||||
case PSY_IIO_MOISTURE_DETECTED:
|
||||
*val = chg->moisture_present;
|
||||
break;
|
||||
case PSY_IIO_MOISTURE_DETECTION_EN:
|
||||
*val = !chg->lpd_disabled;
|
||||
break;
|
||||
case PSY_IIO_HVDCP_OPTI_ALLOWED:
|
||||
*val = !chg->flash_active;
|
||||
break;
|
||||
@ -349,6 +352,9 @@ int smb5_iio_set_prop(struct smb_charger *chg, int channel, int val)
|
||||
chg->apsd_ext_timeout = false;
|
||||
smblib_rerun_apsd(chg);
|
||||
break;
|
||||
case PSY_IIO_MOISTURE_DETECTION_EN:
|
||||
smblib_moisture_detection_enable(chg, val);
|
||||
break;
|
||||
/* MAIN */
|
||||
case PSY_IIO_FLASH_ACTIVE:
|
||||
if ((chg->chg_param.smb_version == PMI632)
|
||||
|
@ -1,6 +1,6 @@
|
||||
/* SPDX-License-Identifier: GPL-2.0-only */
|
||||
/*
|
||||
* Copyright (c) 2020 The Linux Foundation. All rights reserved.
|
||||
* Copyright (c) 2020-2021 The Linux Foundation. All rights reserved.
|
||||
*/
|
||||
|
||||
#ifndef __SMB5_IIO_H
|
||||
@ -151,6 +151,7 @@ static const struct smb5_iio_prop_channels smb5_chans_pmic[] = {
|
||||
SMB5_CHAN_INDEX("usb_smb_en_reason", SMB_EN_REASON)
|
||||
SMB5_CHAN_INDEX("usb_adapter_cc_mode", ADAPTER_CC_MODE)
|
||||
SMB5_CHAN_INDEX("usb_moisture_detected", MOISTURE_DETECTED)
|
||||
SMB5_CHAN_INDEX("usb_moisture_detection_en", MOISTURE_DETECTION_EN)
|
||||
SMB5_CHAN_INDEX("usb_hvdcp_opti_allowed", HVDCP_OPTI_ALLOWED)
|
||||
SMB5_CHAN_ACTIVITY("usb_qc_opti_disable", QC_OPTI_DISABLE)
|
||||
SMB5_CHAN_VOLT("usb_voltage_vph", VOLTAGE_VPH)
|
||||
|
@ -7958,6 +7958,49 @@ out:
|
||||
chg->jeita_configured = JEITA_CFG_FAILURE;
|
||||
}
|
||||
|
||||
void smblib_moisture_detection_enable(struct smb_charger *chg, int pval)
|
||||
{
|
||||
int rc, input_present, val;
|
||||
|
||||
if (chg->pd_disabled)
|
||||
return;
|
||||
|
||||
smblib_is_input_present(chg, &input_present);
|
||||
|
||||
if (pval) {
|
||||
chg->lpd_disabled = false;
|
||||
pr_debug("Moisture detection enabled\n");
|
||||
if (input_present)
|
||||
schedule_delayed_work(&chg->lpd_ra_open_work,
|
||||
msecs_to_jiffies(300));
|
||||
return;
|
||||
}
|
||||
|
||||
chg->lpd_disabled = true;
|
||||
|
||||
if (!is_client_vote_enabled(chg->usb_icl_votable, LPD_VOTER))
|
||||
goto done;
|
||||
|
||||
cancel_delayed_work_sync(&chg->lpd_ra_open_work);
|
||||
|
||||
alarm_cancel(&chg->lpd_recheck_timer);
|
||||
|
||||
vote(chg->usb_icl_votable, LPD_VOTER, false, 0);
|
||||
/* restore DRP mode */
|
||||
val = QTI_POWER_SUPPLY_TYPEC_PR_DUAL;
|
||||
rc = smblib_set_prop_typec_power_role(chg, val);
|
||||
if (rc < 0) {
|
||||
smblib_err(chg, "Failed to set power-role to DRP rc=%d\n",
|
||||
rc);
|
||||
return;
|
||||
}
|
||||
|
||||
chg->lpd_reason = LPD_NONE;
|
||||
chg->lpd_stage = LPD_STAGE_NONE;
|
||||
done:
|
||||
pr_debug("Moisture detection disabled\n");
|
||||
}
|
||||
|
||||
static void smblib_lpd_ra_open_work(struct work_struct *work)
|
||||
{
|
||||
struct smb_charger *chg = container_of(work, struct smb_charger,
|
||||
@ -7965,7 +8008,7 @@ static void smblib_lpd_ra_open_work(struct work_struct *work)
|
||||
u8 stat;
|
||||
int rc, val;
|
||||
|
||||
if (chg->pr_swap_in_progress || chg->pd_hard_reset) {
|
||||
if (chg->pr_swap_in_progress || chg->pd_hard_reset || chg->lpd_disabled) {
|
||||
chg->lpd_stage = LPD_STAGE_NONE;
|
||||
goto out;
|
||||
}
|
||||
|
@ -844,4 +844,5 @@ int smblib_get_prop_voltage_wls_output(struct smb_charger *chg,
|
||||
int smblib_get_prop_dc_voltage_now(struct smb_charger *chg,
|
||||
union power_supply_propval *val);
|
||||
|
||||
void smblib_moisture_detection_enable(struct smb_charger *chg, int pval);
|
||||
#endif /* __SMB5_CHARGER_H */
|
||||
|
@ -1,6 +1,6 @@
|
||||
/* SPDX-License-Identifier: GPL-2.0-only */
|
||||
/*
|
||||
* Copyright (c) 2020 The Linux Foundation. All rights reserved.
|
||||
* Copyright (c) 2020-2021 The Linux Foundation. All rights reserved.
|
||||
*/
|
||||
|
||||
#ifndef __QTI_POWER_SUPPLY_IIO_H__
|
||||
@ -148,4 +148,7 @@
|
||||
#define PSY_IIO_INPUT_SUSPEND 0x78
|
||||
#define PSY_IIO_PARALLEL_BATFET_MODE 0x79
|
||||
#define PSY_IIO_PARALLEL_FCC_MAX 0x7a
|
||||
|
||||
/* USB */
|
||||
#define PSY_IIO_MOISTURE_DETECTION_EN 0x7b
|
||||
#endif /* __QTI_POWER_SUPPLY_IIO_H__ */
|
||||
|
Loading…
Reference in New Issue
Block a user