Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 5cde2af6 authored by Soumya Managoli's avatar Soumya Managoli
Browse files

ASoC: Retrieve machine specific data from digital codec



Analog codec driver is common for sdm660 and msm8953 targets.
Inclusion of asoc_mach_data defined in sdm660 leads to
incorrect data updates in case of msm8953.
Hence retrieve the micbias cap mode settings from the digital
codec driver to access the appropriate asoc_mach_data struct.
Also reset int_mclk0_enable flag in SSR_DOWN event of digital
codec so that flag is updated appropriately.

CRs-Fixed: 2201385
Change-Id: Idd2476c91a57df77c41962d31f643440a3daf67b
Signed-off-by: default avatarSoumya Managoli <smanag@codeaurora.org>
parent d2b72e93
Loading
Loading
Loading
Loading
+8 −19
Original line number Diff line number Diff line
@@ -31,7 +31,6 @@
#include "msm-cdc-common.h"
#include "sdm660-cdc-irq.h"
#include "msm-analog-cdc-regmap.h"
#include "../../sdm660-common.h"
#include "../wcd-mbhc-v2-api.h"

#define DRV_NAME "pmic_analog_codec"
@@ -1464,9 +1463,6 @@ static int msm_anlg_cdc_codec_enable_on_demand_supply(
static int msm_anlg_cdc_codec_enable_clock_block(struct snd_soc_codec *codec,
						 int enable)
{
	struct msm_asoc_mach_data *pdata = NULL;

	pdata = snd_soc_card_get_drvdata(codec->component.card);
	if (enable) {
		snd_soc_update_bits(codec,
			MSM89XX_PMIC_ANALOG_MASTER_BIAS_CTL, 0x30, 0x30);
@@ -2348,9 +2344,6 @@ static int msm_anlg_cdc_codec_enable_dig_clk(struct snd_soc_dapm_widget *w,
	struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
	struct sdm660_cdc_priv *sdm660_cdc =
					snd_soc_codec_get_drvdata(codec);
	struct msm_asoc_mach_data *pdata = NULL;

	pdata = snd_soc_card_get_drvdata(codec->component.card);

	dev_dbg(codec->dev, "%s event %d w->name %s\n", __func__,
			event, w->name);
@@ -3705,13 +3698,11 @@ static void msm_anlg_cdc_update_micbias_regulator(

static int msm_anlg_cdc_device_down(struct snd_soc_codec *codec)
{
	struct msm_asoc_mach_data *pdata = NULL;
	struct sdm660_cdc_priv *sdm660_cdc_priv =
		snd_soc_codec_get_drvdata(codec);
	unsigned int tx_1_en;
	unsigned int tx_2_en;

	pdata = snd_soc_card_get_drvdata(codec->component.card);
	dev_dbg(codec->dev, "%s: device down!\n", __func__);

	tx_1_en = snd_soc_read(codec, MSM89XX_PMIC_ANALOG_TX_1_EN);
@@ -3779,7 +3770,6 @@ static int msm_anlg_cdc_device_down(struct snd_soc_codec *codec)
		MSM89XX_PMIC_ANALOG_SPKR_DAC_CTL, 0x93);

	msm_anlg_cdc_dig_notifier_call(codec, DIG_CDC_EVENT_SSR_DOWN);
	atomic_set(&pdata->int_mclk0_enabled, false);
	set_bit(BUS_DOWN, &sdm660_cdc_priv->status_mask);
	snd_soc_card_change_online_state(codec->component.card, 0);

@@ -3931,17 +3921,18 @@ static void msm_anlg_cdc_set_boost_v(struct snd_soc_codec *codec)
static void msm_anlg_cdc_configure_cap(struct snd_soc_codec *codec,
				       bool micbias1, bool micbias2)
{
	struct sdm660_cdc_priv *sdm660_cdc = snd_soc_codec_get_drvdata(codec);
	struct msm_cap_mode *cap_mode = &sdm660_cdc->cap_mode;

	struct msm_asoc_mach_data *pdata = NULL;

	pdata = snd_soc_card_get_drvdata(codec->component.card);
	blocking_notifier_call_chain(&sdm660_cdc->notifier,
		 DIG_CDC_EVENT_CAP_CONFIGURE, cap_mode);

	pr_debug("\n %s: micbias1 %x micbias2 = %d\n", __func__, micbias1,
			micbias2);
	if (micbias1 && micbias2) {
		if ((pdata->micbias1_cap_mode
		if ((cap_mode->micbias1_cap_mode
		     == MICBIAS_EXT_BYP_CAP) ||
		    (pdata->micbias2_cap_mode
		    (cap_mode->micbias2_cap_mode
		     == MICBIAS_EXT_BYP_CAP))
			snd_soc_update_bits(codec,
				MSM89XX_PMIC_ANALOG_MICB_1_EN,
@@ -3952,10 +3943,10 @@ static void msm_anlg_cdc_configure_cap(struct snd_soc_codec *codec,
				0x40, (MICBIAS_NO_EXT_BYP_CAP << 6));
	} else if (micbias2) {
		snd_soc_update_bits(codec, MSM89XX_PMIC_ANALOG_MICB_1_EN,
				0x40, (pdata->micbias2_cap_mode << 6));
				0x40, (cap_mode->micbias2_cap_mode << 6));
	} else if (micbias1) {
		snd_soc_update_bits(codec, MSM89XX_PMIC_ANALOG_MICB_1_EN,
				0x40, (pdata->micbias1_cap_mode << 6));
				0x40, (cap_mode->micbias1_cap_mode << 6));
	} else {
		snd_soc_update_bits(codec, MSM89XX_PMIC_ANALOG_MICB_1_EN,
				0x40, 0x00);
@@ -4275,12 +4266,10 @@ static int msm_anlg_cdc_suspend(struct snd_soc_codec *codec)

static int msm_anlg_cdc_resume(struct snd_soc_codec *codec)
{
	struct msm_asoc_mach_data *pdata = NULL;
	struct sdm660_cdc_priv *sdm660_cdc = snd_soc_codec_get_drvdata(codec);
	struct sdm660_cdc_pdata *sdm660_cdc_pdata =
					sdm660_cdc->dev->platform_data;

	pdata = snd_soc_card_get_drvdata(codec->component.card);
	msm_anlg_cdc_enable_static_supplies_to_optimum(sdm660_cdc,
						       sdm660_cdc_pdata);
	return 0;
+2 −0
Original line number Diff line number Diff line
@@ -18,6 +18,7 @@
#include "../wcd-mbhc-v2.h"
#include "../wcdcal-hwdep.h"
#include "sdm660-cdc-registers.h"
#include "msm-digital-cdc.h"

#define MICBIAS_EXT_BYP_CAP 0x00
#define MICBIAS_NO_EXT_BYP_CAP 0x01
@@ -219,6 +220,7 @@ struct sdm660_cdc_priv {
	struct platform_device *pdev_child_devices
		[ANLG_CDC_CHILD_DEVICES_MAX];
	int child_count;
	struct msm_cap_mode cap_mode;
};

struct sdm660_cdc_pdata {
+2 −1
Original line number Diff line number Diff line
/* Copyright (c) 2016-2017, The Linux Foundation. All rights reserved.
/* Copyright (c) 2016-2018, The Linux Foundation. All rights reserved.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 and
@@ -63,5 +63,6 @@ enum dig_cdc_notify_event {
	DIG_CDC_EVENT_POST_RX2_INT_OFF,
	DIG_CDC_EVENT_SSR_DOWN,
	DIG_CDC_EVENT_SSR_UP,
	DIG_CDC_EVENT_CAP_CONFIGURE,
	DIG_CDC_EVENT_LAST,
};
+9 −0
Original line number Diff line number Diff line
@@ -1022,6 +1022,7 @@ static int msm_dig_cdc_event_notify(struct notifier_block *block,
	struct msm_dig_priv *msm_dig_cdc = snd_soc_codec_get_drvdata(codec);
	struct msm_asoc_mach_data *pdata = NULL;
	int ret = -EINVAL;
	struct msm_cap_mode *capmode = NULL;

	pdata = snd_soc_card_get_drvdata(codec->component.card);

@@ -1105,6 +1106,9 @@ static int msm_dig_cdc_event_notify(struct notifier_block *block,
		break;
	case DIG_CDC_EVENT_SSR_DOWN:
		regcache_cache_only(msm_dig_cdc->regmap, true);
		mutex_lock(&pdata->cdc_int_mclk0_mutex);
		atomic_set(&pdata->int_mclk0_enabled, false);
		mutex_unlock(&pdata->cdc_int_mclk0_mutex);
		break;
	case DIG_CDC_EVENT_SSR_UP:
		regcache_cache_only(msm_dig_cdc->regmap, false);
@@ -1132,6 +1136,11 @@ static int msm_dig_cdc_event_notify(struct notifier_block *block,
				&pdata->digital_cdc_core_clk);
		mutex_unlock(&pdata->cdc_int_mclk0_mutex);
		break;
	case DIG_CDC_EVENT_CAP_CONFIGURE:
		capmode = (struct msm_cap_mode *)data;
		capmode->micbias1_cap_mode = pdata->micbias1_cap_mode;
		capmode->micbias2_cap_mode = pdata->micbias2_cap_mode;
		break;
	case DIG_CDC_EVENT_INVALID:
	default:
		break;
+10 −1
Original line number Diff line number Diff line
/* Copyright (c) 2015-2017, The Linux Foundation. All rights reserved.
/* Copyright (c) 2015-2018, The Linux Foundation. All rights reserved.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 and
@@ -1019,6 +1019,7 @@ static int msm_dig_cdc_event_notify(struct notifier_block *block,
	struct snd_soc_codec *codec = registered_digcodec;
	struct msm_dig_priv *msm_dig_cdc = snd_soc_codec_get_drvdata(codec);
	struct msm_asoc_mach_data *pdata = NULL;
	struct msm_cap_mode *capmode;
	int ret = -EINVAL;

	pdata = snd_soc_card_get_drvdata(codec->component.card);
@@ -1107,6 +1108,9 @@ static int msm_dig_cdc_event_notify(struct notifier_block *block,
		break;
	case DIG_CDC_EVENT_SSR_DOWN:
		regcache_cache_only(msm_dig_cdc->regmap, true);
		mutex_lock(&pdata->cdc_int_mclk0_mutex);
		atomic_set(&pdata->int_mclk0_enabled, false);
		mutex_unlock(&pdata->cdc_int_mclk0_mutex);
		break;
	case DIG_CDC_EVENT_SSR_UP:
		regcache_cache_only(msm_dig_cdc->regmap, false);
@@ -1134,6 +1138,11 @@ static int msm_dig_cdc_event_notify(struct notifier_block *block,
				&pdata->digital_cdc_core_clk);
		mutex_unlock(&pdata->cdc_int_mclk0_mutex);
		break;
	case DIG_CDC_EVENT_CAP_CONFIGURE:
		capmode = (struct msm_cap_mode *)data;
		capmode->micbias1_cap_mode = pdata->micbias1_cap_mode;
		capmode->micbias2_cap_mode = pdata->micbias2_cap_mode;
		break;
	case DIG_CDC_EVENT_INVALID:
	default:
		break;
Loading