diff --git a/asoc/codecs/wcd937x/wcd937x-mbhc.c b/asoc/codecs/wcd937x/wcd937x-mbhc.c index 54d9f45954..4ad8683a49 100644 --- a/asoc/codecs/wcd937x/wcd937x-mbhc.c +++ b/asoc/codecs/wcd937x/wcd937x-mbhc.c @@ -1,5 +1,5 @@ // 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 @@ -974,6 +974,31 @@ void wcd937x_mbhc_hs_detect_exit(struct snd_soc_component *component) } EXPORT_SYMBOL(wcd937x_mbhc_hs_detect_exit); +/* + * wcd937x_mbhc_ssr_down: stop mbhc during + * wcd937x subsystem restart + * @mbhc: pointer to wcd937x_mbhc structure + * @component: handle to snd_soc_component * + */ +void wcd937x_mbhc_ssr_down(struct wcd937x_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 == NULL) { + dev_err(component->dev, "%s: wcd_mbhc is NULL\n", __func__); + return; + } + + wcd937x_mbhc_hs_detect_exit(component); + wcd_mbhc_deinit(wcd_mbhc); +} +EXPORT_SYMBOL(wcd937x_mbhc_ssr_down); + /* * wcd937x_mbhc_post_ssr_init: initialize mbhc for * wcd937x post subsystem restart @@ -997,8 +1022,6 @@ int wcd937x_mbhc_post_ssr_init(struct wcd937x_mbhc *mbhc, return -EINVAL; } - wcd937x_mbhc_hs_detect_exit(component); - wcd_mbhc_deinit(wcd_mbhc); snd_soc_component_update_bits(component, WCD937X_ANA_MBHC_MECH, 0x20, 0x20); ret = wcd_mbhc_init(wcd_mbhc, component, &mbhc_cb, &intr_ids, diff --git a/asoc/codecs/wcd937x/wcd937x-mbhc.h b/asoc/codecs/wcd937x/wcd937x-mbhc.h index 3c74951659..43d1661895 100644 --- a/asoc/codecs/wcd937x/wcd937x-mbhc.h +++ b/asoc/codecs/wcd937x/wcd937x-mbhc.h @@ -1,5 +1,5 @@ /* 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 __WCD937X_MBHC_H__ #define __WCD937X_MBHC_H__ @@ -21,6 +21,8 @@ extern int wcd937x_mbhc_hs_detect(struct snd_soc_component *component, extern void wcd937x_mbhc_deinit(struct snd_soc_component *component); extern int wcd937x_mbhc_post_ssr_init(struct wcd937x_mbhc *mbhc, struct snd_soc_component *component); +extern void wcd937x_mbhc_ssr_down(struct wcd937x_mbhc *mbhc, + struct snd_soc_component *component); extern int wcd937x_mbhc_get_impedance(struct wcd937x_mbhc *wcd937x_mbhc, uint32_t *zl, uint32_t *zr); #else @@ -47,7 +49,11 @@ static inline int wcd937x_mbhc_post_ssr_init(struct wcd937x_mbhc *mbhc, { return 0; } - +static inline void wcd937x_mbhc_ssr_down(struct wcd937x_mbhc *mbhc, + struct snd_soc_component *component) +{ + return 0; +} static inline int wcd937x_mbhc_get_impedance(struct wcd937x_mbhc *wcd937x_mbhc, uint32_t *zl, uint32_t *zr) { diff --git a/asoc/codecs/wcd937x/wcd937x.c b/asoc/codecs/wcd937x/wcd937x.c index 004ce796c9..24b74c8ba4 100644 --- a/asoc/codecs/wcd937x/wcd937x.c +++ b/asoc/codecs/wcd937x/wcd937x.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 @@ -1422,6 +1422,8 @@ static int wcd937x_event_notify(struct notifier_block *block, 0x80, 0x00); break; case BOLERO_WCD_EVT_SSR_DOWN: + mbhc = &wcd937x->mbhc->wcd_mbhc; + wcd937x_mbhc_ssr_down(wcd937x->mbhc, component); wcd937x_reset_low(wcd937x->dev); break; case BOLERO_WCD_EVT_SSR_UP: