diff --git a/asoc/codecs/wcd-mbhc-v2.c b/asoc/codecs/wcd-mbhc-v2.c index 34a3d10aee..fd63502537 100644 --- a/asoc/codecs/wcd-mbhc-v2.c +++ b/asoc/codecs/wcd-mbhc-v2.c @@ -1733,7 +1733,7 @@ static int wcd_mbhc_usbc_ana_event_handler(struct notifier_block *nb, mbhc->mbhc_cb->lock_sleep(mbhc, false); } #endif - } else { + } else if (mode < TYPEC_MAX_ACCESSORY) { #if IS_ENABLED(CONFIG_QCOM_WCD_USBSS_I2C) WCD_MBHC_REG_READ(WCD_MBHC_L_DET_EN, l_det_en); WCD_MBHC_REG_READ(WCD_MBHC_MECH_DETECTION_TYPE, detection_type); @@ -1748,6 +1748,9 @@ static int wcd_mbhc_usbc_ana_event_handler(struct notifier_block *nb, dev_dbg(mbhc->component->dev, "leave, %s: mode = %lu\n", __func__, mode); } #endif + } else if (mode == TYPEC_MAX_ACCESSORY) { + if (mbhc->mbhc_cb->surge_reset_routine) + mbhc->mbhc_cb->surge_reset_routine(mbhc); } return 0; } diff --git a/asoc/codecs/wcd939x/wcd939x-mbhc.c b/asoc/codecs/wcd939x/wcd939x-mbhc.c index cfa89bf0e4..1953126453 100644 --- a/asoc/codecs/wcd939x/wcd939x-mbhc.c +++ b/asoc/codecs/wcd939x/wcd939x-mbhc.c @@ -1,7 +1,7 @@ // SPDX-License-Identifier: GPL-2.0-only /* * Copyright (c) 2018-2019, The Linux Foundation. All rights reserved. - * Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved. + * Copyright (c) 2022-2023, Qualcomm Innovation Center, Inc. All rights reserved. */ #include #include @@ -808,6 +808,14 @@ static void wcd939x_mbhc_bcs_enable(struct wcd_mbhc *mbhc, wcd939x_disable_bcs_before_slow_insert(mbhc->component, true); } +static void wcd939x_surge_reset_routine(struct wcd_mbhc *mbhc) +{ + struct wcd939x_priv *wcd939x = snd_soc_component_get_drvdata(mbhc->component); + + regcache_mark_dirty(wcd939x->regmap); + regcache_sync(wcd939x->regmap); +} + static const struct wcd_mbhc_cb mbhc_cb = { .request_irq = wcd939x_mbhc_request_irq, .irq_control = wcd939x_mbhc_irq_control, @@ -833,6 +841,7 @@ static const struct wcd_mbhc_cb mbhc_cb = { .mbhc_moisture_polling_ctrl = wcd939x_mbhc_moisture_polling_ctrl, .mbhc_moisture_detect_en = wcd939x_mbhc_moisture_detect_en, .bcs_enable = wcd939x_mbhc_bcs_enable, + .surge_reset_routine = wcd939x_surge_reset_routine, }; static int wcd939x_get_hph_type(struct snd_kcontrol *kcontrol, diff --git a/include/asoc/wcd-mbhc-v2.h b/include/asoc/wcd-mbhc-v2.h index 7c39fc8e56..d47f80cf71 100644 --- a/include/asoc/wcd-mbhc-v2.h +++ b/include/asoc/wcd-mbhc-v2.h @@ -530,6 +530,7 @@ struct wcd_mbhc_cb { bool (*mbhc_get_moisture_status)(struct wcd_mbhc *mbhc); void (*mbhc_moisture_polling_ctrl)(struct wcd_mbhc *mbhc, bool enable); void (*mbhc_moisture_detect_en)(struct wcd_mbhc *mbhc, bool enable); + void (*surge_reset_routine)(struct wcd_mbhc *mbhc); }; struct wcd_mbhc_fn {