diff --git a/asoc/codecs/wcd938x/wcd938x-mbhc.c b/asoc/codecs/wcd938x/wcd938x-mbhc.c index 6d9f500378..2516943ded 100644 --- a/asoc/codecs/wcd938x/wcd938x-mbhc.c +++ b/asoc/codecs/wcd938x/wcd938x-mbhc.c @@ -1,6 +1,6 @@ // SPDX-License-Identifier: GPL-2.0-only /* - * Copyright (c) 2018, The Linux Foundation. All rights reserved. + * Copyright (c) 2018-2019, The Linux Foundation. All rights reserved. */ #include #include @@ -956,6 +956,31 @@ void wcd938x_mbhc_hs_detect_exit(struct snd_soc_component *component) } EXPORT_SYMBOL(wcd938x_mbhc_hs_detect_exit); +/* + * wcd938x_mbhc_ssr_down: stop mbhc during + * wcd938x subsystem restart + * mbhc: pointer to wcd937x_mbhc structure + * component: handle to snd_soc_component * + */ +void wcd938x_mbhc_ssr_down(struct wcd938x_mbhc *mbhc, + struct snd_soc_component *component) +{ + struct wcd_mbhc *wcd_mbhc = NULL; + + if (!mbhc || !component) + return; + + wcd_mbhc = &mbhc->wcd_mbhc; + if (!wcd_mbhc) { + dev_err(component->dev, "%s: wcd_mbhc is NULL\n", __func__); + return; + } + + wcd938x_mbhc_hs_detect_exit(component); + wcd_mbhc_deinit(wcd_mbhc); +} +EXPORT_SYMBOL(wcd938x_mbhc_ssr_down); + /* * wcd938x_mbhc_post_ssr_init: initialize mbhc for * wcd938x post subsystem restart @@ -979,7 +1004,6 @@ int wcd938x_mbhc_post_ssr_init(struct wcd938x_mbhc *mbhc, return -EINVAL; } - wcd_mbhc_deinit(wcd_mbhc); ret = wcd_mbhc_init(wcd_mbhc, component, &mbhc_cb, &intr_ids, wcd_mbhc_registers, WCD938X_ZDET_SUPPORTED); if (ret) { diff --git a/asoc/codecs/wcd938x/wcd938x-mbhc.h b/asoc/codecs/wcd938x/wcd938x-mbhc.h index cf4c60e0ae..e33a92c20e 100644 --- a/asoc/codecs/wcd938x/wcd938x-mbhc.h +++ b/asoc/codecs/wcd938x/wcd938x-mbhc.h @@ -1,6 +1,6 @@ /* SPDX-License-Identifier: GPL-2.0-only */ /* - * Copyright (c) 2018, The Linux Foundation. All rights reserved. + * Copyright (c) 2018-2019, The Linux Foundation. All rights reserved. */ #ifndef __WCD938X_MBHC_H__ #define __WCD938X_MBHC_H__ @@ -20,6 +20,8 @@ extern void wcd938x_mbhc_hs_detect_exit(struct snd_soc_component *component); extern int wcd938x_mbhc_hs_detect(struct snd_soc_component *component, struct wcd_mbhc_config *mbhc_cfg); extern void wcd938x_mbhc_deinit(struct snd_soc_component *component); +extern void wcd938x_mbhc_ssr_down(struct wcd938x_mbhc *mbhc, + struct snd_soc_component *component); extern int wcd938x_mbhc_post_ssr_init(struct wcd938x_mbhc *mbhc, struct snd_soc_component *component); extern int wcd938x_mbhc_get_impedance(struct wcd938x_mbhc *wcd938x_mbhc, @@ -43,6 +45,10 @@ static inline int wcd938x_mbhc_hs_detect(struct snd_soc_component *component, static inline void wcd938x_mbhc_deinit(struct snd_soc_component *component) { } +static inline void wcd938x_mbhc_ssr_down(struct wcd938x_mbhc *mbhc, + struct snd_soc_component *component) +{ +} static inline int wcd938x_mbhc_post_ssr_init(struct wcd938x_mbhc *mbhc, struct snd_soc_component *component) { diff --git a/asoc/codecs/wcd938x/wcd938x.c b/asoc/codecs/wcd938x/wcd938x.c index 882feff26b..4e8ab32e9e 100644 --- a/asoc/codecs/wcd938x/wcd938x.c +++ b/asoc/codecs/wcd938x/wcd938x.c @@ -1516,6 +1516,8 @@ static int wcd938x_event_notify(struct notifier_block *block, 0x80, 0x00); break; case BOLERO_WCD_EVT_SSR_DOWN: + mbhc = &wcd938x->mbhc->wcd_mbhc; + wcd938x_mbhc_ssr_down(wcd938x->mbhc, component); wcd938x_reset_low(wcd938x->dev); break; case BOLERO_WCD_EVT_SSR_UP: