|
|
|
@ -30,7 +30,6 @@
|
|
|
|
|
#include <linux/pm.h>
|
|
|
|
|
#include <linux/gpio.h>
|
|
|
|
|
#include <linux/of_gpio.h>
|
|
|
|
|
#include <linux/i2c.h>
|
|
|
|
|
#include <linux/cdev.h>
|
|
|
|
|
#include <linux/slab.h>
|
|
|
|
|
#include <linux/clk.h>
|
|
|
|
@ -160,7 +159,10 @@ static const struct aic32x4_rate_divs aic32x4_divs[] = {
|
|
|
|
|
/* 48k rate */
|
|
|
|
|
{AIC32X4_FREQ_12000000, 48000, 1, 8, 1920, 128, 2, 8, 128, 2, 8, 4},
|
|
|
|
|
{AIC32X4_FREQ_24000000, 48000, 2, 8, 1920, 128, 8, 2, 64, 8, 4, 4},
|
|
|
|
|
{AIC32X4_FREQ_25000000, 48000, 2, 7, 8643, 128, 8, 2, 64, 8, 4, 4}
|
|
|
|
|
{AIC32X4_FREQ_25000000, 48000, 2, 7, 8643, 128, 8, 2, 64, 8, 4, 4},
|
|
|
|
|
|
|
|
|
|
/* 96k rate */
|
|
|
|
|
{AIC32X4_FREQ_25000000, 96000, 2, 7, 8643, 64, 4, 4, 64, 4, 4, 1},
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
static const struct snd_kcontrol_new hpl_output_mixer_controls[] = {
|
|
|
|
@ -181,16 +183,71 @@ static const struct snd_kcontrol_new lor_output_mixer_controls[] = {
|
|
|
|
|
SOC_DAPM_SINGLE("R_DAC Switch", AIC32X4_LORROUTE, 3, 1, 0),
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
static const struct snd_kcontrol_new left_input_mixer_controls[] = {
|
|
|
|
|
SOC_DAPM_SINGLE("IN1_L P Switch", AIC32X4_LMICPGAPIN, 6, 1, 0),
|
|
|
|
|
SOC_DAPM_SINGLE("IN2_L P Switch", AIC32X4_LMICPGAPIN, 4, 1, 0),
|
|
|
|
|
SOC_DAPM_SINGLE("IN3_L P Switch", AIC32X4_LMICPGAPIN, 2, 1, 0),
|
|
|
|
|
static const char * const resistor_text[] = {
|
|
|
|
|
"Off", "10 kOhm", "20 kOhm", "40 kOhm",
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
static const struct snd_kcontrol_new right_input_mixer_controls[] = {
|
|
|
|
|
SOC_DAPM_SINGLE("IN1_R P Switch", AIC32X4_RMICPGAPIN, 6, 1, 0),
|
|
|
|
|
SOC_DAPM_SINGLE("IN2_R P Switch", AIC32X4_RMICPGAPIN, 4, 1, 0),
|
|
|
|
|
SOC_DAPM_SINGLE("IN3_R P Switch", AIC32X4_RMICPGAPIN, 2, 1, 0),
|
|
|
|
|
/* Left mixer pins */
|
|
|
|
|
static SOC_ENUM_SINGLE_DECL(in1l_lpga_p_enum, AIC32X4_LMICPGAPIN, 6, resistor_text);
|
|
|
|
|
static SOC_ENUM_SINGLE_DECL(in2l_lpga_p_enum, AIC32X4_LMICPGAPIN, 4, resistor_text);
|
|
|
|
|
static SOC_ENUM_SINGLE_DECL(in3l_lpga_p_enum, AIC32X4_LMICPGAPIN, 2, resistor_text);
|
|
|
|
|
static SOC_ENUM_SINGLE_DECL(in1r_lpga_p_enum, AIC32X4_LMICPGAPIN, 0, resistor_text);
|
|
|
|
|
|
|
|
|
|
static SOC_ENUM_SINGLE_DECL(cml_lpga_n_enum, AIC32X4_LMICPGANIN, 6, resistor_text);
|
|
|
|
|
static SOC_ENUM_SINGLE_DECL(in2r_lpga_n_enum, AIC32X4_LMICPGANIN, 4, resistor_text);
|
|
|
|
|
static SOC_ENUM_SINGLE_DECL(in3r_lpga_n_enum, AIC32X4_LMICPGANIN, 2, resistor_text);
|
|
|
|
|
|
|
|
|
|
static const struct snd_kcontrol_new in1l_to_lmixer_controls[] = {
|
|
|
|
|
SOC_DAPM_ENUM("IN1_L L+ Switch", in1l_lpga_p_enum),
|
|
|
|
|
};
|
|
|
|
|
static const struct snd_kcontrol_new in2l_to_lmixer_controls[] = {
|
|
|
|
|
SOC_DAPM_ENUM("IN2_L L+ Switch", in2l_lpga_p_enum),
|
|
|
|
|
};
|
|
|
|
|
static const struct snd_kcontrol_new in3l_to_lmixer_controls[] = {
|
|
|
|
|
SOC_DAPM_ENUM("IN3_L L+ Switch", in3l_lpga_p_enum),
|
|
|
|
|
};
|
|
|
|
|
static const struct snd_kcontrol_new in1r_to_lmixer_controls[] = {
|
|
|
|
|
SOC_DAPM_ENUM("IN1_R L+ Switch", in1r_lpga_p_enum),
|
|
|
|
|
};
|
|
|
|
|
static const struct snd_kcontrol_new cml_to_lmixer_controls[] = {
|
|
|
|
|
SOC_DAPM_ENUM("CM_L L- Switch", cml_lpga_n_enum),
|
|
|
|
|
};
|
|
|
|
|
static const struct snd_kcontrol_new in2r_to_lmixer_controls[] = {
|
|
|
|
|
SOC_DAPM_ENUM("IN2_R L- Switch", in2r_lpga_n_enum),
|
|
|
|
|
};
|
|
|
|
|
static const struct snd_kcontrol_new in3r_to_lmixer_controls[] = {
|
|
|
|
|
SOC_DAPM_ENUM("IN3_R L- Switch", in3r_lpga_n_enum),
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/* Right mixer pins */
|
|
|
|
|
static SOC_ENUM_SINGLE_DECL(in1r_rpga_p_enum, AIC32X4_RMICPGAPIN, 6, resistor_text);
|
|
|
|
|
static SOC_ENUM_SINGLE_DECL(in2r_rpga_p_enum, AIC32X4_RMICPGAPIN, 4, resistor_text);
|
|
|
|
|
static SOC_ENUM_SINGLE_DECL(in3r_rpga_p_enum, AIC32X4_RMICPGAPIN, 2, resistor_text);
|
|
|
|
|
static SOC_ENUM_SINGLE_DECL(in2l_rpga_p_enum, AIC32X4_RMICPGAPIN, 0, resistor_text);
|
|
|
|
|
static SOC_ENUM_SINGLE_DECL(cmr_rpga_n_enum, AIC32X4_RMICPGANIN, 6, resistor_text);
|
|
|
|
|
static SOC_ENUM_SINGLE_DECL(in1l_rpga_n_enum, AIC32X4_RMICPGANIN, 4, resistor_text);
|
|
|
|
|
static SOC_ENUM_SINGLE_DECL(in3l_rpga_n_enum, AIC32X4_RMICPGANIN, 2, resistor_text);
|
|
|
|
|
|
|
|
|
|
static const struct snd_kcontrol_new in1r_to_rmixer_controls[] = {
|
|
|
|
|
SOC_DAPM_ENUM("IN1_R R+ Switch", in1r_rpga_p_enum),
|
|
|
|
|
};
|
|
|
|
|
static const struct snd_kcontrol_new in2r_to_rmixer_controls[] = {
|
|
|
|
|
SOC_DAPM_ENUM("IN2_R R+ Switch", in2r_rpga_p_enum),
|
|
|
|
|
};
|
|
|
|
|
static const struct snd_kcontrol_new in3r_to_rmixer_controls[] = {
|
|
|
|
|
SOC_DAPM_ENUM("IN3_R R+ Switch", in3r_rpga_p_enum),
|
|
|
|
|
};
|
|
|
|
|
static const struct snd_kcontrol_new in2l_to_rmixer_controls[] = {
|
|
|
|
|
SOC_DAPM_ENUM("IN2_L R+ Switch", in2l_rpga_p_enum),
|
|
|
|
|
};
|
|
|
|
|
static const struct snd_kcontrol_new cmr_to_rmixer_controls[] = {
|
|
|
|
|
SOC_DAPM_ENUM("CM_R R- Switch", cmr_rpga_n_enum),
|
|
|
|
|
};
|
|
|
|
|
static const struct snd_kcontrol_new in1l_to_rmixer_controls[] = {
|
|
|
|
|
SOC_DAPM_ENUM("IN1_L R- Switch", in1l_rpga_n_enum),
|
|
|
|
|
};
|
|
|
|
|
static const struct snd_kcontrol_new in3l_to_rmixer_controls[] = {
|
|
|
|
|
SOC_DAPM_ENUM("IN3_L R- Switch", in3l_rpga_n_enum),
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
static const struct snd_soc_dapm_widget aic32x4_dapm_widgets[] = {
|
|
|
|
@ -214,14 +271,39 @@ static const struct snd_soc_dapm_widget aic32x4_dapm_widgets[] = {
|
|
|
|
|
&lor_output_mixer_controls[0],
|
|
|
|
|
ARRAY_SIZE(lor_output_mixer_controls)),
|
|
|
|
|
SND_SOC_DAPM_PGA("LOR Power", AIC32X4_OUTPWRCTL, 2, 0, NULL, 0),
|
|
|
|
|
SND_SOC_DAPM_MIXER("Left Input Mixer", SND_SOC_NOPM, 0, 0,
|
|
|
|
|
&left_input_mixer_controls[0],
|
|
|
|
|
ARRAY_SIZE(left_input_mixer_controls)),
|
|
|
|
|
SND_SOC_DAPM_MIXER("Right Input Mixer", SND_SOC_NOPM, 0, 0,
|
|
|
|
|
&right_input_mixer_controls[0],
|
|
|
|
|
ARRAY_SIZE(right_input_mixer_controls)),
|
|
|
|
|
SND_SOC_DAPM_ADC("Left ADC", "Left Capture", AIC32X4_ADCSETUP, 7, 0),
|
|
|
|
|
|
|
|
|
|
SND_SOC_DAPM_ADC("Right ADC", "Right Capture", AIC32X4_ADCSETUP, 6, 0),
|
|
|
|
|
SND_SOC_DAPM_MUX("IN1_R to Right Mixer Positive Resistor", SND_SOC_NOPM, 0, 0,
|
|
|
|
|
in1r_to_rmixer_controls),
|
|
|
|
|
SND_SOC_DAPM_MUX("IN2_R to Right Mixer Positive Resistor", SND_SOC_NOPM, 0, 0,
|
|
|
|
|
in2r_to_rmixer_controls),
|
|
|
|
|
SND_SOC_DAPM_MUX("IN3_R to Right Mixer Positive Resistor", SND_SOC_NOPM, 0, 0,
|
|
|
|
|
in3r_to_rmixer_controls),
|
|
|
|
|
SND_SOC_DAPM_MUX("IN2_L to Right Mixer Positive Resistor", SND_SOC_NOPM, 0, 0,
|
|
|
|
|
in2l_to_rmixer_controls),
|
|
|
|
|
SND_SOC_DAPM_MUX("CM_R to Right Mixer Negative Resistor", SND_SOC_NOPM, 0, 0,
|
|
|
|
|
cmr_to_rmixer_controls),
|
|
|
|
|
SND_SOC_DAPM_MUX("IN1_L to Right Mixer Negative Resistor", SND_SOC_NOPM, 0, 0,
|
|
|
|
|
in1l_to_rmixer_controls),
|
|
|
|
|
SND_SOC_DAPM_MUX("IN3_L to Right Mixer Negative Resistor", SND_SOC_NOPM, 0, 0,
|
|
|
|
|
in3l_to_rmixer_controls),
|
|
|
|
|
|
|
|
|
|
SND_SOC_DAPM_ADC("Left ADC", "Left Capture", AIC32X4_ADCSETUP, 7, 0),
|
|
|
|
|
SND_SOC_DAPM_MUX("IN1_L to Left Mixer Positive Resistor", SND_SOC_NOPM, 0, 0,
|
|
|
|
|
in1l_to_lmixer_controls),
|
|
|
|
|
SND_SOC_DAPM_MUX("IN2_L to Left Mixer Positive Resistor", SND_SOC_NOPM, 0, 0,
|
|
|
|
|
in2l_to_lmixer_controls),
|
|
|
|
|
SND_SOC_DAPM_MUX("IN3_L to Left Mixer Positive Resistor", SND_SOC_NOPM, 0, 0,
|
|
|
|
|
in3l_to_lmixer_controls),
|
|
|
|
|
SND_SOC_DAPM_MUX("IN1_R to Left Mixer Positive Resistor", SND_SOC_NOPM, 0, 0,
|
|
|
|
|
in1r_to_lmixer_controls),
|
|
|
|
|
SND_SOC_DAPM_MUX("CM_L to Left Mixer Negative Resistor", SND_SOC_NOPM, 0, 0,
|
|
|
|
|
cml_to_lmixer_controls),
|
|
|
|
|
SND_SOC_DAPM_MUX("IN2_R to Left Mixer Negative Resistor", SND_SOC_NOPM, 0, 0,
|
|
|
|
|
in2r_to_lmixer_controls),
|
|
|
|
|
SND_SOC_DAPM_MUX("IN3_R to Left Mixer Negative Resistor", SND_SOC_NOPM, 0, 0,
|
|
|
|
|
in3r_to_lmixer_controls),
|
|
|
|
|
|
|
|
|
|
SND_SOC_DAPM_MICBIAS("Mic Bias", AIC32X4_MICBIAS, 6, 0),
|
|
|
|
|
|
|
|
|
|
SND_SOC_DAPM_OUTPUT("HPL"),
|
|
|
|
@ -261,19 +343,77 @@ static const struct snd_soc_dapm_route aic32x4_dapm_routes[] = {
|
|
|
|
|
{"LOR Power", NULL, "LOR Output Mixer"},
|
|
|
|
|
{"LOR", NULL, "LOR Power"},
|
|
|
|
|
|
|
|
|
|
/* Left input */
|
|
|
|
|
{"Left Input Mixer", "IN1_L P Switch", "IN1_L"},
|
|
|
|
|
{"Left Input Mixer", "IN2_L P Switch", "IN2_L"},
|
|
|
|
|
{"Left Input Mixer", "IN3_L P Switch", "IN3_L"},
|
|
|
|
|
|
|
|
|
|
{"Left ADC", NULL, "Left Input Mixer"},
|
|
|
|
|
|
|
|
|
|
/* Right Input */
|
|
|
|
|
{"Right Input Mixer", "IN1_R P Switch", "IN1_R"},
|
|
|
|
|
{"Right Input Mixer", "IN2_R P Switch", "IN2_R"},
|
|
|
|
|
{"Right Input Mixer", "IN3_R P Switch", "IN3_R"},
|
|
|
|
|
{"Right ADC", NULL, "IN1_R to Right Mixer Positive Resistor"},
|
|
|
|
|
{"IN1_R to Right Mixer Positive Resistor", "10 kOhm", "IN1_R"},
|
|
|
|
|
{"IN1_R to Right Mixer Positive Resistor", "20 kOhm", "IN1_R"},
|
|
|
|
|
{"IN1_R to Right Mixer Positive Resistor", "40 kOhm", "IN1_R"},
|
|
|
|
|
|
|
|
|
|
{"Right ADC", NULL, "Right Input Mixer"},
|
|
|
|
|
{"Right ADC", NULL, "IN2_R to Right Mixer Positive Resistor"},
|
|
|
|
|
{"IN2_R to Right Mixer Positive Resistor", "10 kOhm", "IN2_R"},
|
|
|
|
|
{"IN2_R to Right Mixer Positive Resistor", "20 kOhm", "IN2_R"},
|
|
|
|
|
{"IN2_R to Right Mixer Positive Resistor", "40 kOhm", "IN2_R"},
|
|
|
|
|
|
|
|
|
|
{"Right ADC", NULL, "IN3_R to Right Mixer Positive Resistor"},
|
|
|
|
|
{"IN3_R to Right Mixer Positive Resistor", "10 kOhm", "IN3_R"},
|
|
|
|
|
{"IN3_R to Right Mixer Positive Resistor", "20 kOhm", "IN3_R"},
|
|
|
|
|
{"IN3_R to Right Mixer Positive Resistor", "40 kOhm", "IN3_R"},
|
|
|
|
|
|
|
|
|
|
{"Right ADC", NULL, "IN2_L to Right Mixer Positive Resistor"},
|
|
|
|
|
{"IN2_L to Right Mixer Positive Resistor", "10 kOhm", "IN2_L"},
|
|
|
|
|
{"IN2_L to Right Mixer Positive Resistor", "20 kOhm", "IN2_L"},
|
|
|
|
|
{"IN2_L to Right Mixer Positive Resistor", "40 kOhm", "IN2_L"},
|
|
|
|
|
|
|
|
|
|
{"Right ADC", NULL, "CM_R to Right Mixer Negative Resistor"},
|
|
|
|
|
{"CM_R to Right Mixer Negative Resistor", "10 kOhm", "CM_R"},
|
|
|
|
|
{"CM_R to Right Mixer Negative Resistor", "20 kOhm", "CM_R"},
|
|
|
|
|
{"CM_R to Right Mixer Negative Resistor", "40 kOhm", "CM_R"},
|
|
|
|
|
|
|
|
|
|
{"Right ADC", NULL, "IN1_L to Right Mixer Negative Resistor"},
|
|
|
|
|
{"IN1_L to Right Mixer Negative Resistor", "10 kOhm", "IN1_L"},
|
|
|
|
|
{"IN1_L to Right Mixer Negative Resistor", "20 kOhm", "IN1_L"},
|
|
|
|
|
{"IN1_L to Right Mixer Negative Resistor", "40 kOhm", "IN1_L"},
|
|
|
|
|
|
|
|
|
|
{"Right ADC", NULL, "IN3_L to Right Mixer Negative Resistor"},
|
|
|
|
|
{"IN3_L to Right Mixer Negative Resistor", "10 kOhm", "IN3_L"},
|
|
|
|
|
{"IN3_L to Right Mixer Negative Resistor", "20 kOhm", "IN3_L"},
|
|
|
|
|
{"IN3_L to Right Mixer Negative Resistor", "40 kOhm", "IN3_L"},
|
|
|
|
|
|
|
|
|
|
/* Left Input */
|
|
|
|
|
{"Left ADC", NULL, "IN1_L to Left Mixer Positive Resistor"},
|
|
|
|
|
{"IN1_L to Left Mixer Positive Resistor", "10 kOhm", "IN1_L"},
|
|
|
|
|
{"IN1_L to Left Mixer Positive Resistor", "20 kOhm", "IN1_L"},
|
|
|
|
|
{"IN1_L to Left Mixer Positive Resistor", "40 kOhm", "IN1_L"},
|
|
|
|
|
|
|
|
|
|
{"Left ADC", NULL, "IN2_L to Left Mixer Positive Resistor"},
|
|
|
|
|
{"IN2_L to Left Mixer Positive Resistor", "10 kOhm", "IN2_L"},
|
|
|
|
|
{"IN2_L to Left Mixer Positive Resistor", "20 kOhm", "IN2_L"},
|
|
|
|
|
{"IN2_L to Left Mixer Positive Resistor", "40 kOhm", "IN2_L"},
|
|
|
|
|
|
|
|
|
|
{"Left ADC", NULL, "IN3_L to Left Mixer Positive Resistor"},
|
|
|
|
|
{"IN3_L to Left Mixer Positive Resistor", "10 kOhm", "IN3_L"},
|
|
|
|
|
{"IN3_L to Left Mixer Positive Resistor", "20 kOhm", "IN3_L"},
|
|
|
|
|
{"IN3_L to Left Mixer Positive Resistor", "40 kOhm", "IN3_L"},
|
|
|
|
|
|
|
|
|
|
{"Left ADC", NULL, "IN1_R to Left Mixer Positive Resistor"},
|
|
|
|
|
{"IN1_R to Left Mixer Positive Resistor", "10 kOhm", "IN1_R"},
|
|
|
|
|
{"IN1_R to Left Mixer Positive Resistor", "20 kOhm", "IN1_R"},
|
|
|
|
|
{"IN1_R to Left Mixer Positive Resistor", "40 kOhm", "IN1_R"},
|
|
|
|
|
|
|
|
|
|
{"Left ADC", NULL, "CM_L to Left Mixer Negative Resistor"},
|
|
|
|
|
{"CM_L to Left Mixer Negative Resistor", "10 kOhm", "CM_L"},
|
|
|
|
|
{"CM_L to Left Mixer Negative Resistor", "20 kOhm", "CM_L"},
|
|
|
|
|
{"CM_L to Left Mixer Negative Resistor", "40 kOhm", "CM_L"},
|
|
|
|
|
|
|
|
|
|
{"Left ADC", NULL, "IN2_R to Left Mixer Negative Resistor"},
|
|
|
|
|
{"IN2_R to Left Mixer Negative Resistor", "10 kOhm", "IN2_R"},
|
|
|
|
|
{"IN2_R to Left Mixer Negative Resistor", "20 kOhm", "IN2_R"},
|
|
|
|
|
{"IN2_R to Left Mixer Negative Resistor", "40 kOhm", "IN2_R"},
|
|
|
|
|
|
|
|
|
|
{"Left ADC", NULL, "IN3_R to Left Mixer Negative Resistor"},
|
|
|
|
|
{"IN3_R to Left Mixer Negative Resistor", "10 kOhm", "IN3_R"},
|
|
|
|
|
{"IN3_R to Left Mixer Negative Resistor", "20 kOhm", "IN3_R"},
|
|
|
|
|
{"IN3_R to Left Mixer Negative Resistor", "40 kOhm", "IN3_R"},
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
static const struct regmap_range_cfg aic32x4_regmap_pages[] = {
|
|
|
|
@ -287,14 +427,12 @@ static const struct regmap_range_cfg aic32x4_regmap_pages[] = {
|
|
|
|
|
},
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
static const struct regmap_config aic32x4_regmap = {
|
|
|
|
|
.reg_bits = 8,
|
|
|
|
|
.val_bits = 8,
|
|
|
|
|
|
|
|
|
|
const struct regmap_config aic32x4_regmap_config = {
|
|
|
|
|
.max_register = AIC32X4_RMICPGAVOL,
|
|
|
|
|
.ranges = aic32x4_regmap_pages,
|
|
|
|
|
.num_ranges = ARRAY_SIZE(aic32x4_regmap_pages),
|
|
|
|
|
};
|
|
|
|
|
EXPORT_SYMBOL(aic32x4_regmap_config);
|
|
|
|
|
|
|
|
|
|
static inline int aic32x4_get_divs(int mclk, int rate)
|
|
|
|
|
{
|
|
|
|
@ -567,7 +705,7 @@ static int aic32x4_set_bias_level(struct snd_soc_codec *codec,
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#define AIC32X4_RATES SNDRV_PCM_RATE_8000_48000
|
|
|
|
|
#define AIC32X4_RATES SNDRV_PCM_RATE_8000_96000
|
|
|
|
|
#define AIC32X4_FORMATS (SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S20_3LE \
|
|
|
|
|
| SNDRV_PCM_FMTBIT_S24_3LE | SNDRV_PCM_FMTBIT_S32_LE)
|
|
|
|
|
|
|
|
|
@ -596,7 +734,7 @@ static struct snd_soc_dai_driver aic32x4_dai = {
|
|
|
|
|
.symmetric_rates = 1,
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
static int aic32x4_probe(struct snd_soc_codec *codec)
|
|
|
|
|
static int aic32x4_codec_probe(struct snd_soc_codec *codec)
|
|
|
|
|
{
|
|
|
|
|
struct aic32x4_priv *aic32x4 = snd_soc_codec_get_drvdata(codec);
|
|
|
|
|
u32 tmp_reg;
|
|
|
|
@ -655,7 +793,7 @@ static int aic32x4_probe(struct snd_soc_codec *codec)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static struct snd_soc_codec_driver soc_codec_dev_aic32x4 = {
|
|
|
|
|
.probe = aic32x4_probe,
|
|
|
|
|
.probe = aic32x4_codec_probe,
|
|
|
|
|
.set_bias_level = aic32x4_set_bias_level,
|
|
|
|
|
.suspend_bias_off = true,
|
|
|
|
|
|
|
|
|
@ -777,24 +915,22 @@ error_ldo:
|
|
|
|
|
return ret;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static int aic32x4_i2c_probe(struct i2c_client *i2c,
|
|
|
|
|
const struct i2c_device_id *id)
|
|
|
|
|
int aic32x4_probe(struct device *dev, struct regmap *regmap)
|
|
|
|
|
{
|
|
|
|
|
struct aic32x4_pdata *pdata = i2c->dev.platform_data;
|
|
|
|
|
struct aic32x4_priv *aic32x4;
|
|
|
|
|
struct device_node *np = i2c->dev.of_node;
|
|
|
|
|
struct aic32x4_pdata *pdata = dev->platform_data;
|
|
|
|
|
struct device_node *np = dev->of_node;
|
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
|
|
aic32x4 = devm_kzalloc(&i2c->dev, sizeof(struct aic32x4_priv),
|
|
|
|
|
if (IS_ERR(regmap))
|
|
|
|
|
return PTR_ERR(regmap);
|
|
|
|
|
|
|
|
|
|
aic32x4 = devm_kzalloc(dev, sizeof(struct aic32x4_priv),
|
|
|
|
|
GFP_KERNEL);
|
|
|
|
|
if (aic32x4 == NULL)
|
|
|
|
|
return -ENOMEM;
|
|
|
|
|
|
|
|
|
|
aic32x4->regmap = devm_regmap_init_i2c(i2c, &aic32x4_regmap);
|
|
|
|
|
if (IS_ERR(aic32x4->regmap))
|
|
|
|
|
return PTR_ERR(aic32x4->regmap);
|
|
|
|
|
|
|
|
|
|
i2c_set_clientdata(i2c, aic32x4);
|
|
|
|
|
dev_set_drvdata(dev, aic32x4);
|
|
|
|
|
|
|
|
|
|
if (pdata) {
|
|
|
|
|
aic32x4->power_cfg = pdata->power_cfg;
|
|
|
|
@ -804,7 +940,7 @@ static int aic32x4_i2c_probe(struct i2c_client *i2c,
|
|
|
|
|
} else if (np) {
|
|
|
|
|
ret = aic32x4_parse_dt(aic32x4, np);
|
|
|
|
|
if (ret) {
|
|
|
|
|
dev_err(&i2c->dev, "Failed to parse DT node\n");
|
|
|
|
|
dev_err(dev, "Failed to parse DT node\n");
|
|
|
|
|
return ret;
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
@ -814,71 +950,48 @@ static int aic32x4_i2c_probe(struct i2c_client *i2c,
|
|
|
|
|
aic32x4->rstn_gpio = -1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
aic32x4->mclk = devm_clk_get(&i2c->dev, "mclk");
|
|
|
|
|
aic32x4->mclk = devm_clk_get(dev, "mclk");
|
|
|
|
|
if (IS_ERR(aic32x4->mclk)) {
|
|
|
|
|
dev_err(&i2c->dev, "Failed getting the mclk. The current implementation does not support the usage of this codec without mclk\n");
|
|
|
|
|
dev_err(dev, "Failed getting the mclk. The current implementation does not support the usage of this codec without mclk\n");
|
|
|
|
|
return PTR_ERR(aic32x4->mclk);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (gpio_is_valid(aic32x4->rstn_gpio)) {
|
|
|
|
|
ret = devm_gpio_request_one(&i2c->dev, aic32x4->rstn_gpio,
|
|
|
|
|
ret = devm_gpio_request_one(dev, aic32x4->rstn_gpio,
|
|
|
|
|
GPIOF_OUT_INIT_LOW, "tlv320aic32x4 rstn");
|
|
|
|
|
if (ret != 0)
|
|
|
|
|
return ret;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ret = aic32x4_setup_regulators(&i2c->dev, aic32x4);
|
|
|
|
|
ret = aic32x4_setup_regulators(dev, aic32x4);
|
|
|
|
|
if (ret) {
|
|
|
|
|
dev_err(&i2c->dev, "Failed to setup regulators\n");
|
|
|
|
|
dev_err(dev, "Failed to setup regulators\n");
|
|
|
|
|
return ret;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ret = snd_soc_register_codec(&i2c->dev,
|
|
|
|
|
ret = snd_soc_register_codec(dev,
|
|
|
|
|
&soc_codec_dev_aic32x4, &aic32x4_dai, 1);
|
|
|
|
|
if (ret) {
|
|
|
|
|
dev_err(&i2c->dev, "Failed to register codec\n");
|
|
|
|
|
dev_err(dev, "Failed to register codec\n");
|
|
|
|
|
aic32x4_disable_regulators(aic32x4);
|
|
|
|
|
return ret;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
i2c_set_clientdata(i2c, aic32x4);
|
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
EXPORT_SYMBOL(aic32x4_probe);
|
|
|
|
|
|
|
|
|
|
static int aic32x4_i2c_remove(struct i2c_client *client)
|
|
|
|
|
int aic32x4_remove(struct device *dev)
|
|
|
|
|
{
|
|
|
|
|
struct aic32x4_priv *aic32x4 = i2c_get_clientdata(client);
|
|
|
|
|
struct aic32x4_priv *aic32x4 = dev_get_drvdata(dev);
|
|
|
|
|
|
|
|
|
|
aic32x4_disable_regulators(aic32x4);
|
|
|
|
|
|
|
|
|
|
snd_soc_unregister_codec(&client->dev);
|
|
|
|
|
snd_soc_unregister_codec(dev);
|
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static const struct i2c_device_id aic32x4_i2c_id[] = {
|
|
|
|
|
{ "tlv320aic32x4", 0 },
|
|
|
|
|
{ }
|
|
|
|
|
};
|
|
|
|
|
MODULE_DEVICE_TABLE(i2c, aic32x4_i2c_id);
|
|
|
|
|
|
|
|
|
|
static const struct of_device_id aic32x4_of_id[] = {
|
|
|
|
|
{ .compatible = "ti,tlv320aic32x4", },
|
|
|
|
|
{ /* senitel */ }
|
|
|
|
|
};
|
|
|
|
|
MODULE_DEVICE_TABLE(of, aic32x4_of_id);
|
|
|
|
|
|
|
|
|
|
static struct i2c_driver aic32x4_i2c_driver = {
|
|
|
|
|
.driver = {
|
|
|
|
|
.name = "tlv320aic32x4",
|
|
|
|
|
.of_match_table = aic32x4_of_id,
|
|
|
|
|
},
|
|
|
|
|
.probe = aic32x4_i2c_probe,
|
|
|
|
|
.remove = aic32x4_i2c_remove,
|
|
|
|
|
.id_table = aic32x4_i2c_id,
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
module_i2c_driver(aic32x4_i2c_driver);
|
|
|
|
|
EXPORT_SYMBOL(aic32x4_remove);
|
|
|
|
|
|
|
|
|
|
MODULE_DESCRIPTION("ASoC tlv320aic32x4 codec driver");
|
|
|
|
|
MODULE_AUTHOR("Javier Martin <javier.martin@vista-silicon.com>");
|
|
|
|
|