ASoC: wcd-mbhc: Reduce plug insert/remove pop for USB type-C analog audio

Reduce pop when plug is inserted into USB type-C port through
an adapter by toggling the USB modes to DFP (Downstream Facing
Port) during insert and back to DRP (Dual Role Port) when the
removal is detected.

CRs-Fixed: 1113288
Change-Id: I32a5d551e0f178907010d737e9fd548a82e5d419
Signed-off-by: Phani Kumar Uppalapati <phaniu@codeaurora.org>
This commit is contained in:
Phani Kumar Uppalapati 2017-01-27 12:15:09 -08:00
parent ea4719da1f
commit 76a34ad2ea
2 changed files with 34 additions and 10 deletions

View file

@ -2161,8 +2161,14 @@ static int wcd_mbhc_initialise(struct wcd_mbhc *mbhc)
WCD_MBHC_REG_UPDATE_BITS(WCD_MBHC_HS_L_DET_PULL_UP_COMP_CTRL, 1);
WCD_MBHC_REG_UPDATE_BITS(WCD_MBHC_L_DET_EN, 1);
/* Insertion debounce set to 96ms */
WCD_MBHC_REG_UPDATE_BITS(WCD_MBHC_INSREM_DBNC, 6);
if (mbhc->mbhc_cfg->enable_usbc_analog) {
/* Insertion debounce set to 48ms */
WCD_MBHC_REG_UPDATE_BITS(WCD_MBHC_INSREM_DBNC, 4);
} else {
/* Insertion debounce set to 96ms */
WCD_MBHC_REG_UPDATE_BITS(WCD_MBHC_INSREM_DBNC, 6);
}
/* Button Debounce set to 16ms */
WCD_MBHC_REG_UPDATE_BITS(WCD_MBHC_BTN_DBNC, 2);
@ -2331,22 +2337,28 @@ static int wcd_mbhc_usb_c_analog_setup_gpios(struct wcd_mbhc *mbhc,
int rc = 0;
struct usbc_ana_audio_config *config =
&mbhc->mbhc_cfg->usbc_analog_cfg;
union power_supply_propval pval;
dev_dbg(mbhc->codec->dev, "%s: setting GPIOs active = %d\n",
__func__, active);
memset(&pval, 0, sizeof(pval));
if (active) {
if (config->usbc_en1_gpio_p) {
pval.intval = POWER_SUPPLY_TYPEC_PR_SOURCE;
if (power_supply_set_property(mbhc->usb_psy,
POWER_SUPPLY_PROP_TYPEC_POWER_ROLE, &pval))
dev_info(mbhc->codec->dev, "%s: force PR_SOURCE mode unsuccessful\n",
__func__);
else
mbhc->usbc_force_pr_mode = true;
if (config->usbc_en1_gpio_p)
rc = msm_cdc_pinctrl_select_active_state(
config->usbc_en1_gpio_p);
/* delay required to allow the hw to stabilize */
usleep_range(1000, 1200);
}
if (rc == 0 && config->usbc_en2n_gpio_p) {
if (rc == 0 && config->usbc_en2n_gpio_p)
rc = msm_cdc_pinctrl_select_active_state(
config->usbc_en2n_gpio_p);
/* delay required to allow the hw to stabilize */
usleep_range(1000, 1200);
}
if (rc == 0 && config->usbc_force_gpio_p)
rc = msm_cdc_pinctrl_select_active_state(
config->usbc_force_gpio_p);
@ -2362,6 +2374,17 @@ static int wcd_mbhc_usb_c_analog_setup_gpios(struct wcd_mbhc *mbhc,
if (config->usbc_force_gpio_p)
msm_cdc_pinctrl_select_sleep_state(
config->usbc_force_gpio_p);
if (mbhc->usbc_force_pr_mode) {
pval.intval = POWER_SUPPLY_TYPEC_PR_DUAL;
if (power_supply_set_property(mbhc->usb_psy,
POWER_SUPPLY_PROP_TYPEC_POWER_ROLE, &pval))
dev_info(mbhc->codec->dev, "%s: force PR_DUAL mode unsuccessful\n",
__func__);
mbhc->usbc_force_pr_mode = false;
}
mbhc->usbc_mode = POWER_SUPPLY_TYPEC_NONE;
}

View file

@ -456,6 +456,7 @@ struct wcd_mbhc {
unsigned long intr_status;
bool is_hph_ocp_pending;
bool usbc_force_pr_mode;
int usbc_mode;
struct notifier_block psy_nb;
struct power_supply *usb_psy;