Unverified Commit da2495fb authored by Mark Brown's avatar Mark Brown
Browse files

Merge remote-tracking branches 'asoc/topic/rt5670', 'asoc/topic/sgtl5000',...

Merge remote-tracking branches 'asoc/topic/rt5670', 'asoc/topic/sgtl5000', 'asoc/topic/si476x' and 'asoc/topic/sirf' into asoc-next
Loading
Loading
Loading
Loading
+3 −0
Original line number Original line Diff line number Diff line
@@ -5,6 +5,8 @@ Required properties:


- reg : the I2C address of the device
- reg : the I2C address of the device


- #sound-dai-cells: must be equal to 0

- clocks : the clock provider of SYS_MCLK
- clocks : the clock provider of SYS_MCLK


- VDDA-supply : the regulator provider of VDDA
- VDDA-supply : the regulator provider of VDDA
@@ -40,6 +42,7 @@ Example:
codec: sgtl5000@a {
codec: sgtl5000@a {
	compatible = "fsl,sgtl5000";
	compatible = "fsl,sgtl5000";
	reg = <0x0a>;
	reg = <0x0a>;
	#sound-dai-cells = <0>;
	clocks = <&clks 150>;
	clocks = <&clks 150>;
	micbias-resistor-k-ohms = <2>;
	micbias-resistor-k-ohms = <2>;
	micbias-voltage-m-volts = <2250>;
	micbias-voltage-m-volts = <2250>;
+147 −148

File changed.

Preview size limit exceeded, changes collapsed.

+5 −5
Original line number Original line Diff line number Diff line
@@ -1986,11 +1986,11 @@ enum {
	RT5670_DOWN_RATE_FILTER = (0x1 << 7),
	RT5670_DOWN_RATE_FILTER = (0x1 << 7),
};
};


int rt5670_sel_asrc_clk_src(struct snd_soc_codec *codec,
int rt5670_sel_asrc_clk_src(struct snd_soc_component *component,
			    unsigned int filter_mask, unsigned int clk_src);
			    unsigned int filter_mask, unsigned int clk_src);


struct rt5670_priv {
struct rt5670_priv {
	struct snd_soc_codec *codec;
	struct snd_soc_component *component;
	struct rt5670_platform_data pdata;
	struct rt5670_platform_data pdata;
	struct regmap *regmap;
	struct regmap *regmap;
	struct snd_soc_jack *jack;
	struct snd_soc_jack *jack;
@@ -2012,8 +2012,8 @@ struct rt5670_priv {
	int jack_type_saved;
	int jack_type_saved;
};
};


void rt5670_jack_suspend(struct snd_soc_codec *codec);
void rt5670_jack_suspend(struct snd_soc_component *component);
void rt5670_jack_resume(struct snd_soc_codec *codec);
void rt5670_jack_resume(struct snd_soc_component *component);
int rt5670_set_jack_detect(struct snd_soc_codec *codec,
int rt5670_set_jack_detect(struct snd_soc_component *component,
	struct snd_soc_jack *jack);
	struct snd_soc_jack *jack);
#endif /* __RT5670_H__ */
#endif /* __RT5670_H__ */
+172 −103
Original line number Original line Diff line number Diff line
@@ -147,19 +147,19 @@ struct sgtl5000_priv {
static int mic_bias_event(struct snd_soc_dapm_widget *w,
static int mic_bias_event(struct snd_soc_dapm_widget *w,
	struct snd_kcontrol *kcontrol, int event)
	struct snd_kcontrol *kcontrol, int event)
{
{
	struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
	struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm);
	struct sgtl5000_priv *sgtl5000 = snd_soc_codec_get_drvdata(codec);
	struct sgtl5000_priv *sgtl5000 = snd_soc_component_get_drvdata(component);


	switch (event) {
	switch (event) {
	case SND_SOC_DAPM_POST_PMU:
	case SND_SOC_DAPM_POST_PMU:
		/* change mic bias resistor */
		/* change mic bias resistor */
		snd_soc_update_bits(codec, SGTL5000_CHIP_MIC_CTRL,
		snd_soc_component_update_bits(component, SGTL5000_CHIP_MIC_CTRL,
			SGTL5000_BIAS_R_MASK,
			SGTL5000_BIAS_R_MASK,
			sgtl5000->micbias_resistor << SGTL5000_BIAS_R_SHIFT);
			sgtl5000->micbias_resistor << SGTL5000_BIAS_R_SHIFT);
		break;
		break;


	case SND_SOC_DAPM_PRE_PMD:
	case SND_SOC_DAPM_PRE_PMD:
		snd_soc_update_bits(codec, SGTL5000_CHIP_MIC_CTRL,
		snd_soc_component_update_bits(component, SGTL5000_CHIP_MIC_CTRL,
				SGTL5000_BIAS_R_MASK, 0);
				SGTL5000_BIAS_R_MASK, 0);
		break;
		break;
	}
	}
@@ -174,12 +174,12 @@ static int mic_bias_event(struct snd_soc_dapm_widget *w,
static int power_vag_event(struct snd_soc_dapm_widget *w,
static int power_vag_event(struct snd_soc_dapm_widget *w,
	struct snd_kcontrol *kcontrol, int event)
	struct snd_kcontrol *kcontrol, int event)
{
{
	struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
	struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm);
	const u32 mask = SGTL5000_DAC_POWERUP | SGTL5000_ADC_POWERUP;
	const u32 mask = SGTL5000_DAC_POWERUP | SGTL5000_ADC_POWERUP;


	switch (event) {
	switch (event) {
	case SND_SOC_DAPM_POST_PMU:
	case SND_SOC_DAPM_POST_PMU:
		snd_soc_update_bits(codec, SGTL5000_CHIP_ANA_POWER,
		snd_soc_component_update_bits(component, SGTL5000_CHIP_ANA_POWER,
			SGTL5000_VAG_POWERUP, SGTL5000_VAG_POWERUP);
			SGTL5000_VAG_POWERUP, SGTL5000_VAG_POWERUP);
		msleep(400);
		msleep(400);
		break;
		break;
@@ -190,9 +190,9 @@ static int power_vag_event(struct snd_soc_dapm_widget *w,
		 * operational to prevent inadvertently starving the
		 * operational to prevent inadvertently starving the
		 * other one of them.
		 * other one of them.
		 */
		 */
		if ((snd_soc_read(codec, SGTL5000_CHIP_ANA_POWER) &
		if ((snd_soc_component_read32(component, SGTL5000_CHIP_ANA_POWER) &
				mask) != mask) {
				mask) != mask) {
			snd_soc_update_bits(codec, SGTL5000_CHIP_ANA_POWER,
			snd_soc_component_update_bits(component, SGTL5000_CHIP_ANA_POWER,
				SGTL5000_VAG_POWERUP, 0);
				SGTL5000_VAG_POWERUP, 0);
			msleep(400);
			msleep(400);
		}
		}
@@ -216,17 +216,54 @@ static SOC_ENUM_SINGLE_DECL(adc_enum,
static const struct snd_kcontrol_new adc_mux =
static const struct snd_kcontrol_new adc_mux =
SOC_DAPM_ENUM("Capture Mux", adc_enum);
SOC_DAPM_ENUM("Capture Mux", adc_enum);


/* input sources for headphone */
static const char *hp_mux_text[] = {
	"DAC", "LINE_IN"
};

static SOC_ENUM_SINGLE_DECL(hp_enum,
			    SGTL5000_CHIP_ANA_CTRL, 6,
			    hp_mux_text);

static const struct snd_kcontrol_new hp_mux =
SOC_DAPM_ENUM("Headphone Mux", hp_enum);

/* input sources for DAC */
/* input sources for DAC */
static const char *dac_mux_text[] = {
static const char *dac_mux_text[] = {
	"DAC", "LINE_IN"
	"ADC", "I2S", "Rsvrd", "DAP"
};
};


static SOC_ENUM_SINGLE_DECL(dac_enum,
static SOC_ENUM_SINGLE_DECL(dac_enum,
			    SGTL5000_CHIP_ANA_CTRL, 6,
			    SGTL5000_CHIP_SSS_CTRL, SGTL5000_DAC_SEL_SHIFT,
			    dac_mux_text);
			    dac_mux_text);


static const struct snd_kcontrol_new dac_mux =
static const struct snd_kcontrol_new dac_mux =
SOC_DAPM_ENUM("Headphone Mux", dac_enum);
SOC_DAPM_ENUM("Digital Input Mux", dac_enum);

/* input sources for DAP */
static const char *dap_mux_text[] = {
	"ADC", "I2S"
};

static SOC_ENUM_SINGLE_DECL(dap_enum,
			    SGTL5000_CHIP_SSS_CTRL, SGTL5000_DAP_SEL_SHIFT,
			    dap_mux_text);

static const struct snd_kcontrol_new dap_mux =
SOC_DAPM_ENUM("DAP Mux", dap_enum);

/* input sources for DAP mix */
static const char *dapmix_mux_text[] = {
	"ADC", "I2S"
};

static SOC_ENUM_SINGLE_DECL(dapmix_enum,
			    SGTL5000_CHIP_SSS_CTRL, SGTL5000_DAP_MIX_SEL_SHIFT,
			    dapmix_mux_text);

static const struct snd_kcontrol_new dapmix_mux =
SOC_DAPM_ENUM("DAP MIX Mux", dapmix_enum);



static const struct snd_soc_dapm_widget sgtl5000_dapm_widgets[] = {
static const struct snd_soc_dapm_widget sgtl5000_dapm_widgets[] = {
	SND_SOC_DAPM_INPUT("LINE_IN"),
	SND_SOC_DAPM_INPUT("LINE_IN"),
@@ -243,7 +280,12 @@ static const struct snd_soc_dapm_widget sgtl5000_dapm_widgets[] = {
	SND_SOC_DAPM_PGA("LO", SGTL5000_CHIP_ANA_POWER, 0, 0, NULL, 0),
	SND_SOC_DAPM_PGA("LO", SGTL5000_CHIP_ANA_POWER, 0, 0, NULL, 0),


	SND_SOC_DAPM_MUX("Capture Mux", SND_SOC_NOPM, 0, 0, &adc_mux),
	SND_SOC_DAPM_MUX("Capture Mux", SND_SOC_NOPM, 0, 0, &adc_mux),
	SND_SOC_DAPM_MUX("Headphone Mux", SND_SOC_NOPM, 0, 0, &dac_mux),
	SND_SOC_DAPM_MUX("Headphone Mux", SND_SOC_NOPM, 0, 0, &hp_mux),
	SND_SOC_DAPM_MUX("Digital Input Mux", SND_SOC_NOPM, 0, 0, &dac_mux),
	SND_SOC_DAPM_MUX("DAP Mux", SGTL5000_DAP_CTRL, 0, 0, &dap_mux),
	SND_SOC_DAPM_MUX("DAP MIX Mux", SGTL5000_DAP_CTRL, 4, 0, &dapmix_mux),
	SND_SOC_DAPM_MIXER("DAP", SGTL5000_CHIP_DIG_POWER, 4, 0, NULL, 0),



	/* aif for i2s input */
	/* aif for i2s input */
	SND_SOC_DAPM_AIF_IN("AIFIN", "Playback",
	SND_SOC_DAPM_AIF_IN("AIFIN", "Playback",
@@ -270,7 +312,19 @@ static const struct snd_soc_dapm_route sgtl5000_dapm_routes[] = {
	{"ADC", NULL, "Capture Mux"},		/* adc_mux --> adc */
	{"ADC", NULL, "Capture Mux"},		/* adc_mux --> adc */
	{"AIFOUT", NULL, "ADC"},		/* adc --> i2s_out */
	{"AIFOUT", NULL, "ADC"},		/* adc --> i2s_out */


	{"DAC", NULL, "AIFIN"},			/* i2s-->dac,skip audio mux */
	{"DAP Mux", "ADC", "ADC"},		/* adc --> DAP mux */
	{"DAP Mux", NULL, "AIFIN"},		/* i2s --> DAP mux */
	{"DAP", NULL, "DAP Mux"},		/* DAP mux --> dap */

	{"DAP MIX Mux", "ADC", "ADC"},		/* adc --> DAP MIX mux */
	{"DAP MIX Mux", NULL, "AIFIN"},		/* i2s --> DAP MIX mux */
	{"DAP", NULL, "DAP MIX Mux"},		/* DAP MIX mux --> dap */

	{"Digital Input Mux", "ADC", "ADC"},	/* adc --> audio mux */
	{"Digital Input Mux", NULL, "AIFIN"},	/* i2s --> audio mux */
	{"Digital Input Mux", NULL, "DAP"},	/* dap --> audio mux */
	{"DAC", NULL, "Digital Input Mux"},	/* audio mux --> dac */

	{"Headphone Mux", "DAC", "DAC"},	/* dac --> hp_mux */
	{"Headphone Mux", "DAC", "DAC"},	/* dac --> hp_mux */
	{"LO", NULL, "DAC"},			/* dac --> line_out */
	{"LO", NULL, "DAC"},			/* dac --> line_out */


@@ -318,12 +372,12 @@ static int dac_info_volsw(struct snd_kcontrol *kcontrol,
static int dac_get_volsw(struct snd_kcontrol *kcontrol,
static int dac_get_volsw(struct snd_kcontrol *kcontrol,
			 struct snd_ctl_elem_value *ucontrol)
			 struct snd_ctl_elem_value *ucontrol)
{
{
	struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
	struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol);
	int reg;
	int reg;
	int l;
	int l;
	int r;
	int r;


	reg = snd_soc_read(codec, SGTL5000_CHIP_DAC_VOL);
	reg = snd_soc_component_read32(component, SGTL5000_CHIP_DAC_VOL);


	/* get left channel volume */
	/* get left channel volume */
	l = (reg & SGTL5000_DAC_VOL_LEFT_MASK) >> SGTL5000_DAC_VOL_LEFT_SHIFT;
	l = (reg & SGTL5000_DAC_VOL_LEFT_MASK) >> SGTL5000_DAC_VOL_LEFT_SHIFT;
@@ -371,7 +425,7 @@ static int dac_get_volsw(struct snd_kcontrol *kcontrol,
static int dac_put_volsw(struct snd_kcontrol *kcontrol,
static int dac_put_volsw(struct snd_kcontrol *kcontrol,
			 struct snd_ctl_elem_value *ucontrol)
			 struct snd_ctl_elem_value *ucontrol)
{
{
	struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
	struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol);
	int reg;
	int reg;
	int l;
	int l;
	int r;
	int r;
@@ -391,7 +445,7 @@ static int dac_put_volsw(struct snd_kcontrol *kcontrol,
	reg = l << SGTL5000_DAC_VOL_LEFT_SHIFT |
	reg = l << SGTL5000_DAC_VOL_LEFT_SHIFT |
		r << SGTL5000_DAC_VOL_RIGHT_SHIFT;
		r << SGTL5000_DAC_VOL_RIGHT_SHIFT;


	snd_soc_write(codec, SGTL5000_CHIP_DAC_VOL, reg);
	snd_soc_component_write(component, SGTL5000_CHIP_DAC_VOL, reg);


	return 0;
	return 0;
}
}
@@ -409,9 +463,9 @@ static int dac_put_volsw(struct snd_kcontrol *kcontrol,
static int avc_get_threshold(struct snd_kcontrol *kcontrol,
static int avc_get_threshold(struct snd_kcontrol *kcontrol,
			     struct snd_ctl_elem_value *ucontrol)
			     struct snd_ctl_elem_value *ucontrol)
{
{
	struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
	struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol);
	int db, i;
	int db, i;
	u16 reg = snd_soc_read(codec, SGTL5000_DAP_AVC_THRESHOLD);
	u16 reg = snd_soc_component_read32(component, SGTL5000_DAP_AVC_THRESHOLD);


	/* register value 0 => -96dB */
	/* register value 0 => -96dB */
	if (!reg) {
	if (!reg) {
@@ -442,7 +496,7 @@ static int avc_get_threshold(struct snd_kcontrol *kcontrol,
static int avc_put_threshold(struct snd_kcontrol *kcontrol,
static int avc_put_threshold(struct snd_kcontrol *kcontrol,
			     struct snd_ctl_elem_value *ucontrol)
			     struct snd_ctl_elem_value *ucontrol)
{
{
	struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
	struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol);
	int db;
	int db;
	u16 reg;
	u16 reg;


@@ -450,7 +504,7 @@ static int avc_put_threshold(struct snd_kcontrol *kcontrol,
	if (db < 0 || db > 96)
	if (db < 0 || db > 96)
		return -EINVAL;
		return -EINVAL;
	reg = avc_thr_db2reg[db];
	reg = avc_thr_db2reg[db];
	snd_soc_write(codec, SGTL5000_DAP_AVC_THRESHOLD, reg);
	snd_soc_component_write(component, SGTL5000_DAP_AVC_THRESHOLD, reg);


	return 0;
	return 0;
}
}
@@ -463,6 +517,12 @@ static const DECLARE_TLV_DB_RANGE(mic_gain_tlv,
	1, 3, TLV_DB_SCALE_ITEM(2000, 1000, 0)
	1, 3, TLV_DB_SCALE_ITEM(2000, 1000, 0)
);
);


/* tlv for DAP channels, 0% - 100% - 200% */
static const DECLARE_TLV_DB_SCALE(dap_volume, 0, 1, 0);

/* tlv for bass bands, -11.75db to 12.0db, step .25db */
static const DECLARE_TLV_DB_SCALE(bass_band, -1175, 25, 0);

/* tlv for hp volume, -51.5db to 12.0db, step .5db */
/* tlv for hp volume, -51.5db to 12.0db, step .5db */
static const DECLARE_TLV_DB_SCALE(headphone_volume, -5150, 50, 0);
static const DECLARE_TLV_DB_SCALE(headphone_volume, -5150, 50, 0);


@@ -514,6 +574,11 @@ static const struct snd_kcontrol_new sgtl5000_snd_controls[] = {
			lineout_volume),
			lineout_volume),
	SOC_SINGLE("Lineout Playback Switch", SGTL5000_CHIP_ANA_CTRL, 8, 1, 1),
	SOC_SINGLE("Lineout Playback Switch", SGTL5000_CHIP_ANA_CTRL, 8, 1, 1),


	SOC_SINGLE_TLV("DAP Main channel", SGTL5000_DAP_MAIN_CHAN,
	0, 0xffff, 0, dap_volume),

	SOC_SINGLE_TLV("DAP Mix channel", SGTL5000_DAP_MIX_CHAN,
	0, 0xffff, 0, dap_volume),
	/* Automatic Volume Control (DAP AVC) */
	/* Automatic Volume Control (DAP AVC) */
	SOC_SINGLE("AVC Switch", SGTL5000_DAP_AVC_CTRL, 0, 1, 0),
	SOC_SINGLE("AVC Switch", SGTL5000_DAP_AVC_CTRL, 0, 1, 0),
	SOC_SINGLE("AVC Hard Limiter Switch", SGTL5000_DAP_AVC_CTRL, 5, 1, 0),
	SOC_SINGLE("AVC Hard Limiter Switch", SGTL5000_DAP_AVC_CTRL, 5, 1, 0),
@@ -523,12 +588,27 @@ static const struct snd_kcontrol_new sgtl5000_snd_controls[] = {
	SOC_SINGLE_EXT_TLV("AVC Threshold Volume", SGTL5000_DAP_AVC_THRESHOLD,
	SOC_SINGLE_EXT_TLV("AVC Threshold Volume", SGTL5000_DAP_AVC_THRESHOLD,
			0, 96, 0, avc_get_threshold, avc_put_threshold,
			0, 96, 0, avc_get_threshold, avc_put_threshold,
			avc_threshold),
			avc_threshold),

	SOC_SINGLE_TLV("BASS 0", SGTL5000_DAP_EQ_BASS_BAND0,
	0, 0x5F, 0, bass_band),

	SOC_SINGLE_TLV("BASS 1", SGTL5000_DAP_EQ_BASS_BAND1,
	0, 0x5F, 0, bass_band),

	SOC_SINGLE_TLV("BASS 2", SGTL5000_DAP_EQ_BASS_BAND2,
	0, 0x5F, 0, bass_band),

	SOC_SINGLE_TLV("BASS 3", SGTL5000_DAP_EQ_BASS_BAND3,
	0, 0x5F, 0, bass_band),

	SOC_SINGLE_TLV("BASS 4", SGTL5000_DAP_EQ_BASS_BAND4,
	0, 0x5F, 0, bass_band),
};
};


/* mute the codec used by alsa core */
/* mute the codec used by alsa core */
static int sgtl5000_digital_mute(struct snd_soc_dai *codec_dai, int mute)
static int sgtl5000_digital_mute(struct snd_soc_dai *codec_dai, int mute)
{
{
	struct snd_soc_codec *codec = codec_dai->codec;
	struct snd_soc_component *component = codec_dai->component;
	u16 i2s_pwr = SGTL5000_I2S_IN_POWERUP;
	u16 i2s_pwr = SGTL5000_I2S_IN_POWERUP;


	/*
	/*
@@ -536,7 +616,7 @@ static int sgtl5000_digital_mute(struct snd_soc_dai *codec_dai, int mute)
	 * because LINE_IN would be muted aswell. We want to mute
	 * because LINE_IN would be muted aswell. We want to mute
	 * only I2S block - this can be done by powering it off
	 * only I2S block - this can be done by powering it off
	 */
	 */
	snd_soc_update_bits(codec, SGTL5000_CHIP_DIG_POWER,
	snd_soc_component_update_bits(component, SGTL5000_CHIP_DIG_POWER,
			i2s_pwr, mute ? 0 : i2s_pwr);
			i2s_pwr, mute ? 0 : i2s_pwr);


	return 0;
	return 0;
@@ -545,8 +625,8 @@ static int sgtl5000_digital_mute(struct snd_soc_dai *codec_dai, int mute)
/* set codec format */
/* set codec format */
static int sgtl5000_set_dai_fmt(struct snd_soc_dai *codec_dai, unsigned int fmt)
static int sgtl5000_set_dai_fmt(struct snd_soc_dai *codec_dai, unsigned int fmt)
{
{
	struct snd_soc_codec *codec = codec_dai->codec;
	struct snd_soc_component *component = codec_dai->component;
	struct sgtl5000_priv *sgtl5000 = snd_soc_codec_get_drvdata(codec);
	struct sgtl5000_priv *sgtl5000 = snd_soc_component_get_drvdata(component);
	u16 i2sctl = 0;
	u16 i2sctl = 0;


	sgtl5000->master = 0;
	sgtl5000->master = 0;
@@ -604,7 +684,7 @@ static int sgtl5000_set_dai_fmt(struct snd_soc_dai *codec_dai, unsigned int fmt)
		return -EINVAL;
		return -EINVAL;
	}
	}


	snd_soc_write(codec, SGTL5000_CHIP_I2S_CTRL, i2sctl);
	snd_soc_component_write(component, SGTL5000_CHIP_I2S_CTRL, i2sctl);


	return 0;
	return 0;
}
}
@@ -613,8 +693,8 @@ static int sgtl5000_set_dai_fmt(struct snd_soc_dai *codec_dai, unsigned int fmt)
static int sgtl5000_set_dai_sysclk(struct snd_soc_dai *codec_dai,
static int sgtl5000_set_dai_sysclk(struct snd_soc_dai *codec_dai,
				   int clk_id, unsigned int freq, int dir)
				   int clk_id, unsigned int freq, int dir)
{
{
	struct snd_soc_codec *codec = codec_dai->codec;
	struct snd_soc_component *component = codec_dai->component;
	struct sgtl5000_priv *sgtl5000 = snd_soc_codec_get_drvdata(codec);
	struct sgtl5000_priv *sgtl5000 = snd_soc_component_get_drvdata(component);


	switch (clk_id) {
	switch (clk_id) {
	case SGTL5000_SYSCLK:
	case SGTL5000_SYSCLK:
@@ -640,9 +720,9 @@ static int sgtl5000_set_dai_sysclk(struct snd_soc_dai *codec_dai,
 * and above.
 * and above.
 * 3. usage of sys_mclk is preferred over pll to save power.
 * 3. usage of sys_mclk is preferred over pll to save power.
 */
 */
static int sgtl5000_set_clock(struct snd_soc_codec *codec, int frame_rate)
static int sgtl5000_set_clock(struct snd_soc_component *component, int frame_rate)
{
{
	struct sgtl5000_priv *sgtl5000 = snd_soc_codec_get_drvdata(codec);
	struct sgtl5000_priv *sgtl5000 = snd_soc_component_get_drvdata(component);
	int clk_ctl = 0;
	int clk_ctl = 0;
	int sys_fs;	/* sample freq */
	int sys_fs;	/* sample freq */


@@ -695,7 +775,7 @@ static int sgtl5000_set_clock(struct snd_soc_codec *codec, int frame_rate)
		clk_ctl |= SGTL5000_SYS_FS_96k << SGTL5000_SYS_FS_SHIFT;
		clk_ctl |= SGTL5000_SYS_FS_96k << SGTL5000_SYS_FS_SHIFT;
		break;
		break;
	default:
	default:
		dev_err(codec->dev, "frame rate %d not supported\n",
		dev_err(component->dev, "frame rate %d not supported\n",
			frame_rate);
			frame_rate);
		return -EINVAL;
		return -EINVAL;
	}
	}
@@ -724,9 +804,9 @@ static int sgtl5000_set_clock(struct snd_soc_codec *codec, int frame_rate)
			clk_ctl |= SGTL5000_MCLK_FREQ_PLL <<
			clk_ctl |= SGTL5000_MCLK_FREQ_PLL <<
				SGTL5000_MCLK_FREQ_SHIFT;
				SGTL5000_MCLK_FREQ_SHIFT;
		} else {
		} else {
			dev_err(codec->dev,
			dev_err(component->dev,
				"PLL not supported in slave mode\n");
				"PLL not supported in slave mode\n");
			dev_err(codec->dev, "%d ratio is not supported. "
			dev_err(component->dev, "%d ratio is not supported. "
				"SYS_MCLK needs to be 256, 384 or 512 * fs\n",
				"SYS_MCLK needs to be 256, 384 or 512 * fs\n",
				sgtl5000->sysclk / frame_rate);
				sgtl5000->sysclk / frame_rate);
			return -EINVAL;
			return -EINVAL;
@@ -759,31 +839,31 @@ static int sgtl5000_set_clock(struct snd_soc_codec *codec, int frame_rate)
		pll_ctl = int_div << SGTL5000_PLL_INT_DIV_SHIFT |
		pll_ctl = int_div << SGTL5000_PLL_INT_DIV_SHIFT |
		    frac_div << SGTL5000_PLL_FRAC_DIV_SHIFT;
		    frac_div << SGTL5000_PLL_FRAC_DIV_SHIFT;


		snd_soc_write(codec, SGTL5000_CHIP_PLL_CTRL, pll_ctl);
		snd_soc_component_write(component, SGTL5000_CHIP_PLL_CTRL, pll_ctl);
		if (div2)
		if (div2)
			snd_soc_update_bits(codec,
			snd_soc_component_update_bits(component,
				SGTL5000_CHIP_CLK_TOP_CTRL,
				SGTL5000_CHIP_CLK_TOP_CTRL,
				SGTL5000_INPUT_FREQ_DIV2,
				SGTL5000_INPUT_FREQ_DIV2,
				SGTL5000_INPUT_FREQ_DIV2);
				SGTL5000_INPUT_FREQ_DIV2);
		else
		else
			snd_soc_update_bits(codec,
			snd_soc_component_update_bits(component,
				SGTL5000_CHIP_CLK_TOP_CTRL,
				SGTL5000_CHIP_CLK_TOP_CTRL,
				SGTL5000_INPUT_FREQ_DIV2,
				SGTL5000_INPUT_FREQ_DIV2,
				0);
				0);


		/* power up pll */
		/* power up pll */
		snd_soc_update_bits(codec, SGTL5000_CHIP_ANA_POWER,
		snd_soc_component_update_bits(component, SGTL5000_CHIP_ANA_POWER,
			SGTL5000_PLL_POWERUP | SGTL5000_VCOAMP_POWERUP,
			SGTL5000_PLL_POWERUP | SGTL5000_VCOAMP_POWERUP,
			SGTL5000_PLL_POWERUP | SGTL5000_VCOAMP_POWERUP);
			SGTL5000_PLL_POWERUP | SGTL5000_VCOAMP_POWERUP);


		/* if using pll, clk_ctrl must be set after pll power up */
		/* if using pll, clk_ctrl must be set after pll power up */
		snd_soc_write(codec, SGTL5000_CHIP_CLK_CTRL, clk_ctl);
		snd_soc_component_write(component, SGTL5000_CHIP_CLK_CTRL, clk_ctl);
	} else {
	} else {
		/* otherwise, clk_ctrl must be set before pll power down */
		/* otherwise, clk_ctrl must be set before pll power down */
		snd_soc_write(codec, SGTL5000_CHIP_CLK_CTRL, clk_ctl);
		snd_soc_component_write(component, SGTL5000_CHIP_CLK_CTRL, clk_ctl);


		/* power down pll */
		/* power down pll */
		snd_soc_update_bits(codec, SGTL5000_CHIP_ANA_POWER,
		snd_soc_component_update_bits(component, SGTL5000_CHIP_ANA_POWER,
			SGTL5000_PLL_POWERUP | SGTL5000_VCOAMP_POWERUP,
			SGTL5000_PLL_POWERUP | SGTL5000_VCOAMP_POWERUP,
			0);
			0);
	}
	}
@@ -799,8 +879,8 @@ static int sgtl5000_pcm_hw_params(struct snd_pcm_substream *substream,
				  struct snd_pcm_hw_params *params,
				  struct snd_pcm_hw_params *params,
				  struct snd_soc_dai *dai)
				  struct snd_soc_dai *dai)
{
{
	struct snd_soc_codec *codec = dai->codec;
	struct snd_soc_component *component = dai->component;
	struct sgtl5000_priv *sgtl5000 = snd_soc_codec_get_drvdata(codec);
	struct sgtl5000_priv *sgtl5000 = snd_soc_component_get_drvdata(component);
	int channels = params_channels(params);
	int channels = params_channels(params);
	int i2s_ctl = 0;
	int i2s_ctl = 0;
	int stereo;
	int stereo;
@@ -808,7 +888,7 @@ static int sgtl5000_pcm_hw_params(struct snd_pcm_substream *substream,


	/* sysclk should already set */
	/* sysclk should already set */
	if (!sgtl5000->sysclk) {
	if (!sgtl5000->sysclk) {
		dev_err(codec->dev, "%s: set sysclk first!\n", __func__);
		dev_err(component->dev, "%s: set sysclk first!\n", __func__);
		return -EFAULT;
		return -EFAULT;
	}
	}


@@ -818,11 +898,11 @@ static int sgtl5000_pcm_hw_params(struct snd_pcm_substream *substream,
		stereo = SGTL5000_ADC_STEREO;
		stereo = SGTL5000_ADC_STEREO;


	/* set mono to save power */
	/* set mono to save power */
	snd_soc_update_bits(codec, SGTL5000_CHIP_ANA_POWER, stereo,
	snd_soc_component_update_bits(component, SGTL5000_CHIP_ANA_POWER, stereo,
			channels == 1 ? 0 : stereo);
			channels == 1 ? 0 : stereo);


	/* set codec clock base on lrclk */
	/* set codec clock base on lrclk */
	ret = sgtl5000_set_clock(codec, params_rate(params));
	ret = sgtl5000_set_clock(component, params_rate(params));
	if (ret)
	if (ret)
		return ret;
		return ret;


@@ -856,7 +936,7 @@ static int sgtl5000_pcm_hw_params(struct snd_pcm_substream *substream,
		return -EINVAL;
		return -EINVAL;
	}
	}


	snd_soc_update_bits(codec, SGTL5000_CHIP_I2S_CTRL,
	snd_soc_component_update_bits(component, SGTL5000_CHIP_I2S_CTRL,
			    SGTL5000_I2S_DLEN_MASK | SGTL5000_I2S_SCLKFREQ_MASK,
			    SGTL5000_I2S_DLEN_MASK | SGTL5000_I2S_SCLKFREQ_MASK,
			    i2s_ctl);
			    i2s_ctl);


@@ -873,10 +953,10 @@ static int sgtl5000_pcm_hw_params(struct snd_pcm_substream *substream,
 * stop:
 * stop:
 * on --> prepare --> standby
 * on --> prepare --> standby
 */
 */
static int sgtl5000_set_bias_level(struct snd_soc_codec *codec,
static int sgtl5000_set_bias_level(struct snd_soc_component *component,
				   enum snd_soc_bias_level level)
				   enum snd_soc_bias_level level)
{
{
	struct sgtl5000_priv *sgtl = snd_soc_codec_get_drvdata(codec);
	struct sgtl5000_priv *sgtl = snd_soc_component_get_drvdata(component);
	int ret;
	int ret;


	switch (level) {
	switch (level) {
@@ -890,13 +970,13 @@ static int sgtl5000_set_bias_level(struct snd_soc_codec *codec,
			return ret;
			return ret;
		}
		}


		snd_soc_update_bits(codec, SGTL5000_CHIP_ANA_POWER,
		snd_soc_component_update_bits(component, SGTL5000_CHIP_ANA_POWER,
				    SGTL5000_REFTOP_POWERUP,
				    SGTL5000_REFTOP_POWERUP,
				    SGTL5000_REFTOP_POWERUP);
				    SGTL5000_REFTOP_POWERUP);
		break;
		break;
	case SND_SOC_BIAS_OFF:
	case SND_SOC_BIAS_OFF:
		regcache_cache_only(sgtl->regmap, true);
		regcache_cache_only(sgtl->regmap, true);
		snd_soc_update_bits(codec, SGTL5000_CHIP_ANA_POWER,
		snd_soc_component_update_bits(component, SGTL5000_CHIP_ANA_POWER,
				    SGTL5000_REFTOP_POWERUP, 0);
				    SGTL5000_REFTOP_POWERUP, 0);
		break;
		break;
	}
	}
@@ -1036,7 +1116,7 @@ static const u8 vol_quot_table[] = {
 * 1. vddd provided by external or not
 * 1. vddd provided by external or not
 * 2. vdda and vddio voltage value. > 3.1v or not
 * 2. vdda and vddio voltage value. > 3.1v or not
 */
 */
static int sgtl5000_set_power_regs(struct snd_soc_codec *codec)
static int sgtl5000_set_power_regs(struct snd_soc_component *component)
{
{
	int vddd;
	int vddd;
	int vdda;
	int vdda;
@@ -1048,7 +1128,7 @@ static int sgtl5000_set_power_regs(struct snd_soc_codec *codec)
	int vol_quot;
	int vol_quot;
	int lo_vol;
	int lo_vol;
	size_t i;
	size_t i;
	struct sgtl5000_priv *sgtl5000 = snd_soc_codec_get_drvdata(codec);
	struct sgtl5000_priv *sgtl5000 = snd_soc_component_get_drvdata(component);


	vdda  = regulator_get_voltage(sgtl5000->supplies[VDDA].consumer);
	vdda  = regulator_get_voltage(sgtl5000->supplies[VDDA].consumer);
	vddio = regulator_get_voltage(sgtl5000->supplies[VDDIO].consumer);
	vddio = regulator_get_voltage(sgtl5000->supplies[VDDIO].consumer);
@@ -1061,14 +1141,14 @@ static int sgtl5000_set_power_regs(struct snd_soc_codec *codec)
	vddd  = vddd / 1000;
	vddd  = vddd / 1000;


	if (vdda <= 0 || vddio <= 0 || vddd < 0) {
	if (vdda <= 0 || vddio <= 0 || vddd < 0) {
		dev_err(codec->dev, "regulator voltage not set correctly\n");
		dev_err(component->dev, "regulator voltage not set correctly\n");


		return -EINVAL;
		return -EINVAL;
	}
	}


	/* according to datasheet, maximum voltage of supplies */
	/* according to datasheet, maximum voltage of supplies */
	if (vdda > 3600 || vddio > 3600 || vddd > 1980) {
	if (vdda > 3600 || vddio > 3600 || vddd > 1980) {
		dev_err(codec->dev,
		dev_err(component->dev,
			"exceed max voltage vdda %dmV vddio %dmV vddd %dmV\n",
			"exceed max voltage vdda %dmV vddio %dmV vddd %dmV\n",
			vdda, vddio, vddd);
			vdda, vddio, vddd);


@@ -1076,15 +1156,15 @@ static int sgtl5000_set_power_regs(struct snd_soc_codec *codec)
	}
	}


	/* reset value */
	/* reset value */
	ana_pwr = snd_soc_read(codec, SGTL5000_CHIP_ANA_POWER);
	ana_pwr = snd_soc_component_read32(component, SGTL5000_CHIP_ANA_POWER);
	ana_pwr |= SGTL5000_DAC_STEREO |
	ana_pwr |= SGTL5000_DAC_STEREO |
			SGTL5000_ADC_STEREO |
			SGTL5000_ADC_STEREO |
			SGTL5000_REFTOP_POWERUP;
			SGTL5000_REFTOP_POWERUP;
	lreg_ctrl = snd_soc_read(codec, SGTL5000_CHIP_LINREG_CTRL);
	lreg_ctrl = snd_soc_component_read32(component, SGTL5000_CHIP_LINREG_CTRL);


	if (vddio < 3100 && vdda < 3100) {
	if (vddio < 3100 && vdda < 3100) {
		/* enable internal oscillator used for charge pump */
		/* enable internal oscillator used for charge pump */
		snd_soc_update_bits(codec, SGTL5000_CHIP_CLK_TOP_CTRL,
		snd_soc_component_update_bits(component, SGTL5000_CHIP_CLK_TOP_CTRL,
					SGTL5000_INT_OSC_EN,
					SGTL5000_INT_OSC_EN,
					SGTL5000_INT_OSC_EN);
					SGTL5000_INT_OSC_EN);
		/* Enable VDDC charge pump */
		/* Enable VDDC charge pump */
@@ -1097,9 +1177,9 @@ static int sgtl5000_set_power_regs(struct snd_soc_codec *codec)
			    SGTL5000_VDDC_MAN_ASSN_SHIFT;
			    SGTL5000_VDDC_MAN_ASSN_SHIFT;
	}
	}


	snd_soc_write(codec, SGTL5000_CHIP_LINREG_CTRL, lreg_ctrl);
	snd_soc_component_write(component, SGTL5000_CHIP_LINREG_CTRL, lreg_ctrl);


	snd_soc_write(codec, SGTL5000_CHIP_ANA_POWER, ana_pwr);
	snd_soc_component_write(component, SGTL5000_CHIP_ANA_POWER, ana_pwr);


	/*
	/*
	 * set ADC/DAC VAG to vdda / 2,
	 * set ADC/DAC VAG to vdda / 2,
@@ -1114,7 +1194,7 @@ static int sgtl5000_set_power_regs(struct snd_soc_codec *codec)
	else
	else
		vag = (vag - SGTL5000_ANA_GND_BASE) / SGTL5000_ANA_GND_STP;
		vag = (vag - SGTL5000_ANA_GND_BASE) / SGTL5000_ANA_GND_STP;


	snd_soc_update_bits(codec, SGTL5000_CHIP_REF_CTRL,
	snd_soc_component_update_bits(component, SGTL5000_CHIP_REF_CTRL,
			SGTL5000_ANA_GND_MASK, vag << SGTL5000_ANA_GND_SHIFT);
			SGTL5000_ANA_GND_MASK, vag << SGTL5000_ANA_GND_SHIFT);


	/* set line out VAG to vddio / 2, in range (0.8v, 1.675v) */
	/* set line out VAG to vddio / 2, in range (0.8v, 1.675v) */
@@ -1128,7 +1208,7 @@ static int sgtl5000_set_power_regs(struct snd_soc_codec *codec)
		lo_vag = (lo_vag - SGTL5000_LINE_OUT_GND_BASE) /
		lo_vag = (lo_vag - SGTL5000_LINE_OUT_GND_BASE) /
		    SGTL5000_LINE_OUT_GND_STP;
		    SGTL5000_LINE_OUT_GND_STP;


	snd_soc_update_bits(codec, SGTL5000_CHIP_LINE_OUT_CTRL,
	snd_soc_component_update_bits(component, SGTL5000_CHIP_LINE_OUT_CTRL,
			SGTL5000_LINE_OUT_CURRENT_MASK |
			SGTL5000_LINE_OUT_CURRENT_MASK |
			SGTL5000_LINE_OUT_GND_MASK,
			SGTL5000_LINE_OUT_GND_MASK,
			lo_vag << SGTL5000_LINE_OUT_GND_SHIFT |
			lo_vag << SGTL5000_LINE_OUT_GND_SHIFT |
@@ -1151,7 +1231,7 @@ static int sgtl5000_set_power_regs(struct snd_soc_codec *codec)
			break;
			break;
	}
	}


	snd_soc_update_bits(codec, SGTL5000_CHIP_LINE_OUT_VOL,
	snd_soc_component_update_bits(component, SGTL5000_CHIP_LINE_OUT_VOL,
		SGTL5000_LINE_OUT_VOL_RIGHT_MASK |
		SGTL5000_LINE_OUT_VOL_RIGHT_MASK |
		SGTL5000_LINE_OUT_VOL_LEFT_MASK,
		SGTL5000_LINE_OUT_VOL_LEFT_MASK,
		lo_vol << SGTL5000_LINE_OUT_VOL_RIGHT_SHIFT |
		lo_vol << SGTL5000_LINE_OUT_VOL_RIGHT_SHIFT |
@@ -1199,62 +1279,56 @@ static int sgtl5000_enable_regulators(struct i2c_client *client)
	return ret;
	return ret;
}
}


static int sgtl5000_probe(struct snd_soc_codec *codec)
static int sgtl5000_probe(struct snd_soc_component *component)
{
{
	int ret;
	int ret;
	u16 reg;
	u16 reg;
	struct sgtl5000_priv *sgtl5000 = snd_soc_codec_get_drvdata(codec);
	struct sgtl5000_priv *sgtl5000 = snd_soc_component_get_drvdata(component);


	/* power up sgtl5000 */
	/* power up sgtl5000 */
	ret = sgtl5000_set_power_regs(codec);
	ret = sgtl5000_set_power_regs(component);
	if (ret)
	if (ret)
		goto err;
		goto err;


	/* enable small pop, introduce 400ms delay in turning off */
	/* enable small pop, introduce 400ms delay in turning off */
	snd_soc_update_bits(codec, SGTL5000_CHIP_REF_CTRL,
	snd_soc_component_update_bits(component, SGTL5000_CHIP_REF_CTRL,
				SGTL5000_SMALL_POP, 1);
				SGTL5000_SMALL_POP, 1);


	/* disable short cut detector */
	/* disable short cut detector */
	snd_soc_write(codec, SGTL5000_CHIP_SHORT_CTRL, 0);
	snd_soc_component_write(component, SGTL5000_CHIP_SHORT_CTRL, 0);


	/*
	snd_soc_component_write(component, SGTL5000_CHIP_DIG_POWER,
	 * set i2s as default input of sound switch
	 * TODO: add sound switch to control and dapm widge.
	 */
	snd_soc_write(codec, SGTL5000_CHIP_SSS_CTRL,
			SGTL5000_DAC_SEL_I2S_IN << SGTL5000_DAC_SEL_SHIFT);
	snd_soc_write(codec, SGTL5000_CHIP_DIG_POWER,
			SGTL5000_ADC_EN | SGTL5000_DAC_EN);
			SGTL5000_ADC_EN | SGTL5000_DAC_EN);


	/* enable dac volume ramp by default */
	/* enable dac volume ramp by default */
	snd_soc_write(codec, SGTL5000_CHIP_ADCDAC_CTRL,
	snd_soc_component_write(component, SGTL5000_CHIP_ADCDAC_CTRL,
			SGTL5000_DAC_VOL_RAMP_EN |
			SGTL5000_DAC_VOL_RAMP_EN |
			SGTL5000_DAC_MUTE_RIGHT |
			SGTL5000_DAC_MUTE_RIGHT |
			SGTL5000_DAC_MUTE_LEFT);
			SGTL5000_DAC_MUTE_LEFT);


	reg = ((sgtl5000->lrclk_strength) << SGTL5000_PAD_I2S_LRCLK_SHIFT | 0x5f);
	reg = ((sgtl5000->lrclk_strength) << SGTL5000_PAD_I2S_LRCLK_SHIFT | 0x5f);
	snd_soc_write(codec, SGTL5000_CHIP_PAD_STRENGTH, reg);
	snd_soc_component_write(component, SGTL5000_CHIP_PAD_STRENGTH, reg);


	snd_soc_write(codec, SGTL5000_CHIP_ANA_CTRL,
	snd_soc_component_write(component, SGTL5000_CHIP_ANA_CTRL,
			SGTL5000_HP_ZCD_EN |
			SGTL5000_HP_ZCD_EN |
			SGTL5000_ADC_ZCD_EN);
			SGTL5000_ADC_ZCD_EN);


	snd_soc_update_bits(codec, SGTL5000_CHIP_MIC_CTRL,
	snd_soc_component_update_bits(component, SGTL5000_CHIP_MIC_CTRL,
			SGTL5000_BIAS_R_MASK,
			SGTL5000_BIAS_R_MASK,
			sgtl5000->micbias_resistor << SGTL5000_BIAS_R_SHIFT);
			sgtl5000->micbias_resistor << SGTL5000_BIAS_R_SHIFT);


	snd_soc_update_bits(codec, SGTL5000_CHIP_MIC_CTRL,
	snd_soc_component_update_bits(component, SGTL5000_CHIP_MIC_CTRL,
			SGTL5000_BIAS_VOLT_MASK,
			SGTL5000_BIAS_VOLT_MASK,
			sgtl5000->micbias_voltage << SGTL5000_BIAS_VOLT_SHIFT);
			sgtl5000->micbias_voltage << SGTL5000_BIAS_VOLT_SHIFT);
	/*
	/*
	 * disable DAP
	 * enable DAP Graphic EQ
	 * TODO:
	 * TODO:
	 * Enable DAP in kcontrol and dapm.
	 * Add control for changing between PEQ/Tone Control/GEQ
	 */
	 */
	snd_soc_write(codec, SGTL5000_DAP_CTRL, 0);
	snd_soc_component_write(component, SGTL5000_DAP_AUDIO_EQ, SGTL5000_DAP_SEL_GEQ);


	/* Unmute DAC after start */
	/* Unmute DAC after start */
	snd_soc_update_bits(codec, SGTL5000_CHIP_ADCDAC_CTRL,
	snd_soc_component_update_bits(component, SGTL5000_CHIP_ADCDAC_CTRL,
		SGTL5000_DAC_MUTE_LEFT | SGTL5000_DAC_MUTE_RIGHT, 0);
		SGTL5000_DAC_MUTE_LEFT | SGTL5000_DAC_MUTE_RIGHT, 0);


	return 0;
	return 0;
@@ -1263,24 +1337,20 @@ err:
	return ret;
	return ret;
}
}


static int sgtl5000_remove(struct snd_soc_codec *codec)
static const struct snd_soc_component_driver sgtl5000_driver = {
{
	return 0;
}

static const struct snd_soc_codec_driver sgtl5000_driver = {
	.probe			= sgtl5000_probe,
	.probe			= sgtl5000_probe,
	.remove = sgtl5000_remove,
	.set_bias_level		= sgtl5000_set_bias_level,
	.set_bias_level		= sgtl5000_set_bias_level,
	.suspend_bias_off = true,
	.component_driver = {
	.controls		= sgtl5000_snd_controls,
	.controls		= sgtl5000_snd_controls,
	.num_controls		= ARRAY_SIZE(sgtl5000_snd_controls),
	.num_controls		= ARRAY_SIZE(sgtl5000_snd_controls),
	.dapm_widgets		= sgtl5000_dapm_widgets,
	.dapm_widgets		= sgtl5000_dapm_widgets,
	.num_dapm_widgets	= ARRAY_SIZE(sgtl5000_dapm_widgets),
	.num_dapm_widgets	= ARRAY_SIZE(sgtl5000_dapm_widgets),
	.dapm_routes		= sgtl5000_dapm_routes,
	.dapm_routes		= sgtl5000_dapm_routes,
	.num_dapm_routes	= ARRAY_SIZE(sgtl5000_dapm_routes),
	.num_dapm_routes	= ARRAY_SIZE(sgtl5000_dapm_routes),
	},
	.suspend_bias_off	= 1,
	.idle_bias_on		= 1,
	.use_pmdown_time	= 1,
	.endianness		= 1,
	.non_legacy_dai_naming	= 1,
};
};


static const struct regmap_config sgtl5000_regmap = {
static const struct regmap_config sgtl5000_regmap = {
@@ -1479,7 +1549,7 @@ static int sgtl5000_i2c_probe(struct i2c_client *client,
	/* Ensure sgtl5000 will start with sane register values */
	/* Ensure sgtl5000 will start with sane register values */
	sgtl5000_fill_defaults(client);
	sgtl5000_fill_defaults(client);


	ret = snd_soc_register_codec(&client->dev,
	ret = devm_snd_soc_register_component(&client->dev,
			&sgtl5000_driver, &sgtl5000_dai, 1);
			&sgtl5000_driver, &sgtl5000_dai, 1);
	if (ret)
	if (ret)
		goto disable_clk;
		goto disable_clk;
@@ -1500,7 +1570,6 @@ static int sgtl5000_i2c_remove(struct i2c_client *client)
{
{
	struct sgtl5000_priv *sgtl5000 = i2c_get_clientdata(client);
	struct sgtl5000_priv *sgtl5000 = i2c_get_clientdata(client);


	snd_soc_unregister_codec(&client->dev);
	clk_disable_unprepare(sgtl5000->mclk);
	clk_disable_unprepare(sgtl5000->mclk);
	regulator_bulk_disable(sgtl5000->num_supplies, sgtl5000->supplies);
	regulator_bulk_disable(sgtl5000->num_supplies, sgtl5000->supplies);
	regulator_bulk_free(sgtl5000->num_supplies, sgtl5000->supplies);
	regulator_bulk_free(sgtl5000->num_supplies, sgtl5000->supplies);
+7 −0
Original line number Original line Diff line number Diff line
@@ -399,4 +399,11 @@
#define SGTL5000_SYSCLK				0x00
#define SGTL5000_SYSCLK				0x00
#define SGTL5000_LRCLK				0x01
#define SGTL5000_LRCLK				0x01


/*
 * SGTL5000_DAP_AUDIO_EQ
 */
#define SGTL5000_DAP_SEL_PEQ			1
#define SGTL5000_DAP_SEL_TONE_CTRL		2
#define SGTL5000_DAP_SEL_GEQ			3

#endif
#endif
Loading