Skip to contentSkip to conversation

ASoC: Add max98926 codec driver

PATCH In review Anish Kumar 2 participants 4 messages May 29, 2015 – Jun 15, 2015

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ASoC: Add max98926 codec driver

---
 .../devicetree/bindings/sound/max98926.txt         |  32 +
 sound/soc/codecs/Kconfig                           |   4 +
 sound/soc/codecs/Makefile                          |   2 +
 sound/soc/codecs/max98926.c                        | 727 ++++++++++++++++++
 sound/soc/codecs/max98926.h                        | 846 +++++++++++++++++++++
 5 files changed, 1611 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/sound/max98926.txt
 create mode 100644 sound/soc/codecs/max98926.c
 create mode 100644 sound/soc/codecs/max98926.h
Documentation/devicetree/bindings/sound/max98926.txt new file +32 -0
new file mode 100644
index 0000000..ee26f7d
@@ -0,0 +1,32 @@
+max98926 audio CODEC
+
+This device supports I2C.
+
+Required properties:
+
+  - compatible : "maxim,max98926"
+
+  - vmon-slot-no : slot number used to send voltage information
+                   or in inteleave mode this will be used as
+                   interleave slot.
+
+  - imon-slot-no : slot number used to send current information
+
+  - interleave-mode : When using two MAX98926 in a system it is
+                      possible to create ADC data that that will
+                      overflow the frame size. Digital Audio Interleave
+                      mode provides a means to output VMON and IMON data
+                      from two devices on a single DOUT line when running
+                      smaller frames sizes such as 32 BCLKS per LRCLK or
+                      48 BCLKS per LRCLK.
+
+  - reg : the I2C address of the device for I2C
+
+Example:
+
+codec: max98926@1a {
+	compatible = "maxim,max98926";
+	vmon-slot-no = <0>;
+	imon-slot-no = <2>;
+	reg = <0x1a>;
+};
sound/soc/codecs/Kconfig +4 -0
index 061c465..10c9c46 100644
@@ -71,6 +71,7 @@ config SND_SOC_ALL_CODECS
 	select SND_SOC_MAX98095 if I2C
 	select SND_SOC_MAX98357A if GPIOLIB
 	select SND_SOC_MAX98925 if I2C
+	select SND_SOC_MAX98926 if I2C
 	select SND_SOC_MAX9850 if I2C
 	select SND_SOC_MAX9768 if I2C
 	select SND_SOC_MAX9877 if I2C
@@ -465,6 +466,9 @@ config SND_SOC_MAX98357A
 config SND_SOC_MAX98925
        tristate
 
+config SND_SOC_MAX98926
+       tristate
+
 config SND_SOC_MAX9850
 	tristate
 
sound/soc/codecs/Makefile +2 -0
index abe2d7e..8768c42 100644
@@ -66,6 +66,7 @@ snd-soc-max98090-objs := max98090.o
 snd-soc-max98095-objs := max98095.o
 snd-soc-max98357a-objs := max98357a.o
 snd-soc-max98925-objs := max98925.o
+snd-soc-max98926-objs := max98926.o
 snd-soc-max9850-objs := max9850.o
 snd-soc-mc13783-objs := mc13783.o
 snd-soc-ml26124-objs := ml26124.o
@@ -251,6 +252,7 @@ obj-$(CONFIG_SND_SOC_MAX98090)	+= snd-soc-max98090.o
 obj-$(CONFIG_SND_SOC_MAX98095)	+= snd-soc-max98095.o
 obj-$(CONFIG_SND_SOC_MAX98357A)	+= snd-soc-max98357a.o
 obj-$(CONFIG_SND_SOC_MAX98925)	+= snd-soc-max98925.o
+obj-$(CONFIG_SND_SOC_MAX98926)	+= snd-soc-max98926.o
 obj-$(CONFIG_SND_SOC_MAX9850)	+= snd-soc-max9850.o
 obj-$(CONFIG_SND_SOC_MC13783)	+= snd-soc-mc13783.o
 obj-$(CONFIG_SND_SOC_ML26124)	+= snd-soc-ml26124.o
sound/soc/codecs/max98926.c new file +727 -0

727 lines not on this page · raw message

sound/soc/codecs/max98926.h new file +846 -0

846 lines not on this page · raw message

Signature · 1 line
1.9.3
maintainer
#1 lore raw

On Fri, May 29, 2015 at 01:32:05PM -0700, Anish Kumar wrote:

This looks mostly good, there's a few things below but they're mostly pretty small and should be easy to update.

sound/soc/codecs/max98926.c line 36

Quoted 4 lines
sound/soc/codecs/max98926.c new file +4 -0
+static const char *const max98926_hpf_cutoff_txt[] = {
+	"hpf_disable", "hpf_dc_block", "hpf_enable_100",
+	"hpf_enable_200", "hpf_enable_400", "hpf_enable_800",
+};

Please write these like other ALSA controls write user visible strings - "Disable", "DC Block", "100Hz" and so on.

sound/soc/codecs/max98926.c line 40

Quoted 3 lines
sound/soc/codecs/max98926.c new file +3 -0
+static const char *const max98926_input_txt[] = {
+	"Pcm", "Analog",
+};

PCM.

sound/soc/codecs/max98926.c line 47

Quoted 6 lines
sound/soc/codecs/max98926.c new file +6 -0
+static struct reg_default max98926_reg[] = {
+	{ 0x00, 0x00 }, /* Battery Voltage Data */
+	{ 0x01, 0x00 }, /* Boost Voltage Data */
+	{ 0x02, 0x00 }, /* Live Status0 */
+	{ 0x03, 0x00 }, /* Live Status1 */
+	{ 0x04, 0x00 }, /* Live Status2 */

These and some of the other registers sound like volatile registers which shouldn't have defaults since they shouldn't be in the cache at all but rather read from the device - and you do in fact have a function marking them as volatile further down.

Quoted 6 lines
sound/soc/codecs/max98926.c new file +6 -0
+static int max98926_dac_event(struct snd_soc_dapm_widget *w,
+		struct snd_kcontrol *kcontrol, int event)
+{
+	struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
+	struct max98926_priv *max98926 = snd_soc_codec_get_drvdata(codec);
+

sound/soc/codecs/max98926.c line 119

Quoted 10 lines
sound/soc/codecs/max98926.c new file +10 -0
+	switch (event) {
+	case SND_SOC_DAPM_PRE_PMU:
+		regmap_update_bits(max98926->regmap,
+			MAX98926_BLOCK_ENABLE, MAX98926_BST_EN_MASK |
+			MAX98926_ADC_IMON_EN_MASK |
+			MAX98926_ADC_VMON_EN_MASK,
+			MAX98926_BST_EN_MASK |
+			MAX98926_ADC_IMON_EN_MASK |
+			MAX98926_ADC_VMON_EN_MASK);
+		break;

Why not just use DAPM widgets for these? BST looks like a boost amplifier so should probably be a PGA, IMON and VMON can probably be represented usefully as supplies (or could be PGAs routed through when recording the signal, presumably users could save a little power by not enabling the monitoring if they don't care for some reason).

sound/soc/codecs/max98926.c line 185

Quoted 2 lines
sound/soc/codecs/max98926.c new file +2 -0
+static int pdm_ch_zero;
+static int pdm_ch_one;

No global variables, store any state you need in driver data.

sound/soc/codecs/max98926.c line 202

Quoted 3 lines
sound/soc/codecs/max98926.c new file +3 -0
+			MAX98926_PDM_CHANNEL_1_MASK);
+	}
+	switch (source) {

Coding style: blank line between blocks.

Quoted 18 lines
sound/soc/codecs/max98926.c new file +18 -0
+	case 0:
+		/* enable current */
+		regmap_update_bits(max98926->regmap,
+			reg, MAX98926_PDM_CURRENT_MASK,
+			MAX98926_PDM_CURRENT_MASK);
+		/* enable source*/
+		if (channel == 0)
+			regmap_update_bits(max98926->regmap,
+				reg, MAX98926_PDM_SOURCE_0_MASK,
+				MAX98926_PDM_SOURCE_0_MASK);
+		else
+			regmap_update_bits(max98926->regmap,
+				reg, MAX98926_PDM_SOURCE_1_MASK,
+				MAX98926_PDM_SOURCE_1_MASK);
+		break;
+	case 1:
+		/* enable voltage */
+		regmap_update_bits(max98926->regmap,

sound/soc/codecs/max98926.c line 230

Quoted 10 lines
sound/soc/codecs/max98926.c new file +10 -0
+			reg, MAX98926_PDM_VOLTAGE_MASK,
+			MAX98926_PDM_VOLTAGE_MASK);
+		/* enable source*/
+		if (channel == 0)
+			regmap_update_bits(max98926->regmap,
+				reg, MAX98926_PDM_SOURCE_0_MASK, 0);
+		else
+			regmap_update_bits(max98926->regmap,
+				reg, MAX98926_PDM_SOURCE_1_MASK, 0);
+		break;

This seems a bit magic numberish (what are 0 and 1 here?).

sound/soc/codecs/max98926.c line 281

Quoted 3 lines
sound/soc/codecs/max98926.c new file +3 -0
+static const struct soc_enum max98926_global_enum[] = {
+	SOC_ENUM_SINGLE_EXT(ARRAY_SIZE(pdm_text), pdm_text),
+};

Not sure what this control is supposed to do?

sound/soc/codecs/max98926.c line 315

Quoted 2 lines
sound/soc/codecs/max98926.c new file +2 -0
+	SOC_ENUM("Input Sel", max98926_input_sel),
+	SOC_ENUM("DAI Input Sel", max98926_dai_input_sel),

These look like DAPM controls?

sound/soc/codecs/max98926.c line 319

Quoted 4 lines
sound/soc/codecs/max98926.c new file +4 -0
+	SOC_ENUM_EXT("PDM CH0 Enable", max98926_global_enum[0],
+		max98926_get_pdm_ch_zero, max98926_put_pdm_ch_zero),
+	SOC_ENUM_EXT("PDM CH1 Enable", max98926_global_enum[0],
+		max98926_get_pdm_ch_one, max98926_put_pdm_ch_one),

There's two different controls mapping to one element of an array?

sound/soc/codecs/max98926.c line 366

Quoted 3 lines
sound/soc/codecs/max98926.c new file +3 -0
+static void max98926_set_sense_data(struct max98926_priv *max98926)
+{
+	if (max98926->intrleave_mode) {

interleave.

sound/soc/codecs/max98926.c line 415

Quoted 10 lines
sound/soc/codecs/max98926.c new file +10 -0
+	switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) {
+	case SND_SOC_DAIFMT_CBS_CFS:
+		max98926_set_sense_data(max98926);
+		break;
+	case SND_SOC_DAIFMT_CBM_CFM:
+	case SND_SOC_DAIFMT_CBS_CFM:
+	case SND_SOC_DAIFMT_CBM_CFS:
+	default:
+		dev_err(codec->dev, "DAI clock mode unsupported");
+		return -EINVAL;

No need to list all the formats you don't support.

sound/soc/codecs/max98926.c line 421

Quoted 6 lines
sound/soc/codecs/max98926.c new file +6 -0
+	}
+
+	switch (fmt & SND_SOC_DAIFMT_FORMAT_MASK) {
+	case SND_SOC_DAIFMT_I2S:
+	case SND_SOC_DAIFMT_LEFT_J:
+		break;

I'm not seeing anything that handles these diffeerently, they are different formats so you should only list whichever one is actually supported.

sound/soc/codecs/max98926.c line 552

Quoted 6 lines
sound/soc/codecs/max98926.c new file +6 -0
+	default:
+		dev_dbg(codec->dev, "format unsupported %d",
+				params_format(params));
+		return -EINVAL;
+	}
+	return max98926_set_clock(max98926, params);

May as well just inline set_clock() here - this appears to be the only place it's used.

sound/soc/codecs/max98926.c line 563

Quoted 9 lines
sound/soc/codecs/max98926.c new file +9 -0
+static int max98926_dai_set_sysclk(struct snd_soc_dai *dai,
+				   int clk_id, unsigned int freq, int dir)
+{
+	struct snd_soc_codec *codec = dai->codec;
+	struct max98926_priv *max98926 = snd_soc_codec_get_drvdata(codec);
+
+	max98926->sysclk = freq;
+	return 0;
+}

You had error checking on sysclk in hw_params(), it'd bet better to do that here too so people can tell they set a bad clock before they start a stream.

sound/soc/codecs/max98926.c line 608

Quoted 8 lines
sound/soc/codecs/max98926.c new file +8 -0
+	ret = regmap_read(max98926->regmap,
+			MAX98926_VERSION, &reg);
+	if ((ret < 0) ||
+		((reg != MAX98926_CHIP_VERSION) &&
+		(reg != MAX98926_CHIP_VERSION1))) {
+		dev_err(codec->dev, "Failed to read: %x\n", reg);
+		return -EINVAL;
+	}

You should do this check in the I2C level probe. The error message is also wrong if the register does read but isn't what we expected.

Are you *sure* no new revisions of the device will be made?

sound/soc/codecs/max98926.c line 613

Quoted 3 lines
sound/soc/codecs/max98926.c new file +3 -0
+	/* It's not the default but we need to set DAI_DLY */
+	regmap_write(max98926->regmap,
+			MAX98926_FORMAT, MAX98926_DAI_DLY_MASK);

Sounds like this might be the I2S vs left justified configuration?

#2 lore raw
Quoted 2 lines · Mark Brown

On Fri, May 29, 2015 at 01:32:05PM -0700, Anish Kumar wrote:

Commented in the places where i have either
doubt or want to respond. Other changes will
be incorporated in next patch.

Quoted 43 lines

This looks mostly good, there's a few things below but they're mostly pretty small and should be easy to update.

sound/soc/codecs/max98926.c line 36

Quoted 4 lines
sound/soc/codecs/max98926.c new file +4 -0
+static const char *const max98926_hpf_cutoff_txt[] = {
+     "hpf_disable", "hpf_dc_block", "hpf_enable_100",
+     "hpf_enable_200", "hpf_enable_400", "hpf_enable_800",
+};

Please write these like other ALSA controls write user visible strings - "Disable", "DC Block", "100Hz" and so on.

sound/soc/codecs/max98926.c line 40

Quoted 3 lines
sound/soc/codecs/max98926.c new file +3 -0
+static const char *const max98926_input_txt[] = {
+     "Pcm", "Analog",
+};

PCM.

sound/soc/codecs/max98926.c line 47

Quoted 6 lines
sound/soc/codecs/max98926.c new file +6 -0
+static struct reg_default max98926_reg[] = {
+     { 0x00, 0x00 }, /* Battery Voltage Data */
+     { 0x01, 0x00 }, /* Boost Voltage Data */
+     { 0x02, 0x00 }, /* Live Status0 */
+     { 0x03, 0x00 }, /* Live Status1 */
+     { 0x04, 0x00 }, /* Live Status2 */

These and some of the other registers sound like volatile registers which shouldn't have defaults since they shouldn't be in the cache at all but rather read from the device - and you do in fact have a function marking them as volatile further down.

Quoted 14 lines
sound/soc/codecs/max98926.c new file +14 -0
+static int max98926_dac_event(struct snd_soc_dapm_widget *w,
+             struct snd_kcontrol *kcontrol, int event)
+{
+     struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
+     struct max98926_priv *max98926 = snd_soc_codec_get_drvdata(codec);
+
+     switch (event) {
+     case SND_SOC_DAPM_PRE_PMU:
+             regmap_update_bits(max98926->regmap,
+                     MAX98926_BLOCK_ENABLE, MAX98926_BST_EN_MASK |
+                     MAX98926_ADC_IMON_EN_MASK |
+                     MAX98926_ADC_VMON_EN_MASK,
+                     MAX98926_BST_EN_MASK |
+                     MAX98926_ADC_IMON_EN_MASK |
Quoted 8 lines

Review

Quoted 2 lines
(quoted diff) +2 -0
+                     MAX98926_ADC_VMON_EN_MASK);
+             break;

Why not just use DAPM widgets for these? BST looks like a boost amplifier so should probably be a PGA, IMON and VMON can probably be represented usefully as supplies (or could be PGAs routed through when recording the signal, presumably users could save a little power by not enabling the monitoring if they don't care for some reason).

BST will be PGA widget. I will represent
I/VMON as supplies.

Quoted 41 lines

sound/soc/codecs/max98926.c line 185

Quoted 3 lines
sound/soc/codecs/max98926.c new file +2 -0
+static int pdm_ch_zero;
+static int pdm_ch_one;

No global variables, store any state you need in driver data.

sound/soc/codecs/max98926.c line 202

Quoted 3 lines
sound/soc/codecs/max98926.c new file +3 -0
+                     MAX98926_PDM_CHANNEL_1_MASK);
+     }
+     switch (source) {

Coding style: blank line between blocks.

Quoted 18 lines
sound/soc/codecs/max98926.c new file +18 -0
+     case 0:
+             /* enable current */
+             regmap_update_bits(max98926->regmap,
+                     reg, MAX98926_PDM_CURRENT_MASK,
+                     MAX98926_PDM_CURRENT_MASK);
+             /* enable source*/
+             if (channel == 0)
+                     regmap_update_bits(max98926->regmap,
+                             reg, MAX98926_PDM_SOURCE_0_MASK,
+                             MAX98926_PDM_SOURCE_0_MASK);
+             else
+                     regmap_update_bits(max98926->regmap,
+                             reg, MAX98926_PDM_SOURCE_1_MASK,
+                             MAX98926_PDM_SOURCE_1_MASK);
+             break;
+     case 1:
+             /* enable voltage */
+             regmap_update_bits(max98926->regmap,

sound/soc/codecs/max98926.c line 230

Quoted 10 lines
sound/soc/codecs/max98926.c new file +10 -0
+                     reg, MAX98926_PDM_VOLTAGE_MASK,
+                     MAX98926_PDM_VOLTAGE_MASK);
+             /* enable source*/
+             if (channel == 0)
+                     regmap_update_bits(max98926->regmap,
+                             reg, MAX98926_PDM_SOURCE_0_MASK, 0);
+             else
+                     regmap_update_bits(max98926->regmap,
+                             reg, MAX98926_PDM_SOURCE_1_MASK, 0);
+             break;
Quoted 1 line

This seems a bit magic numberish (what are 0 and 1 here?).

answer below

Quoted 6 lines

sound/soc/codecs/max98926.c line 281

Quoted 4 lines
sound/soc/codecs/max98926.c new file +3 -0
+static const struct soc_enum max98926_global_enum[] = {
+     SOC_ENUM_SINGLE_EXT(ARRAY_SIZE(pdm_text), pdm_text),
+};

Not sure what this control is supposed to do?

answer below

Quoted 5 lines

sound/soc/codecs/max98926.c line 315

Quoted 3 lines
sound/soc/codecs/max98926.c new file +2 -0
+     SOC_ENUM("Input Sel", max98926_input_sel),
+     SOC_ENUM("DAI Input Sel", max98926_dai_input_sel),

These look like DAPM controls?

'Input Sel' is basically as below:
DAC Input Select
Selects the left, right or mix of left + right as the DAC input signal. 00 = Left DAI input (default)
01 = Right DAI input
10 = Left + Right
11 = Left/2 + Right/2
So i think it is best that it is not part
of dapm.

'DAI Input Sel' is the input to the power amplifier. 98926 amplifier can take PCM input from I2S or can take analog signal. So we need to set this as control.

Quoted 5 lines

sound/soc/codecs/max98926.c line 319

Quoted 5 lines
sound/soc/codecs/max98926.c new file +4 -0
+     SOC_ENUM_EXT("PDM CH0 Enable", max98926_global_enum[0],
+             max98926_get_pdm_ch_zero, max98926_put_pdm_ch_zero),
+     SOC_ENUM_EXT("PDM CH1 Enable", max98926_global_enum[0],
+             max98926_get_pdm_ch_one, max98926_put_pdm_ch_one),

We can get vi feedback in two channels. Customer can enable either channel 0 or channel 1. Channel 0 source can be voltage or current. So basically i created kcontrol for that so that we can either enable channel 0, 1 or both.

'PDM CH0 Enable' 1 causes channel 0 to be enabled for current. So i enable all the relevant bit in put callback.

Quoted 66 lines

There's two different controls mapping to one element of an array?

sound/soc/codecs/max98926.c line 366

Quoted 3 lines
sound/soc/codecs/max98926.c new file +3 -0
+static void max98926_set_sense_data(struct max98926_priv *max98926)
+{
+     if (max98926->intrleave_mode) {

interleave.

sound/soc/codecs/max98926.c line 415

Quoted 10 lines
sound/soc/codecs/max98926.c new file +10 -0
+     switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) {
+     case SND_SOC_DAIFMT_CBS_CFS:
+             max98926_set_sense_data(max98926);
+             break;
+     case SND_SOC_DAIFMT_CBM_CFM:
+     case SND_SOC_DAIFMT_CBS_CFM:
+     case SND_SOC_DAIFMT_CBM_CFS:
+     default:
+             dev_err(codec->dev, "DAI clock mode unsupported");
+             return -EINVAL;

No need to list all the formats you don't support.

sound/soc/codecs/max98926.c line 421

Quoted 6 lines
sound/soc/codecs/max98926.c new file +6 -0
+     }
+
+     switch (fmt & SND_SOC_DAIFMT_FORMAT_MASK) {
+     case SND_SOC_DAIFMT_I2S:
+     case SND_SOC_DAIFMT_LEFT_J:
+             break;

I'm not seeing anything that handles these diffeerently, they are different formats so you should only list whichever one is actually supported.

sound/soc/codecs/max98926.c line 552

Quoted 6 lines
sound/soc/codecs/max98926.c new file +6 -0
+     default:
+             dev_dbg(codec->dev, "format unsupported %d",
+                             params_format(params));
+             return -EINVAL;
+     }
+     return max98926_set_clock(max98926, params);

May as well just inline set_clock() here - this appears to be the only place it's used.

sound/soc/codecs/max98926.c line 563

Quoted 9 lines
sound/soc/codecs/max98926.c new file +9 -0
+static int max98926_dai_set_sysclk(struct snd_soc_dai *dai,
+                                int clk_id, unsigned int freq, int dir)
+{
+     struct snd_soc_codec *codec = dai->codec;
+     struct max98926_priv *max98926 = snd_soc_codec_get_drvdata(codec);
+
+     max98926->sysclk = freq;
+     return 0;
+}

You had error checking on sysclk in hw_params(), it'd bet better to do that here too so people can tell they set a bad clock before they start a stream.

sound/soc/codecs/max98926.c line 608

Quoted 8 lines
sound/soc/codecs/max98926.c new file +8 -0
+     ret = regmap_read(max98926->regmap,
+                     MAX98926_VERSION, &reg);
+     if ((ret < 0) ||
+             ((reg != MAX98926_CHIP_VERSION) &&
+             (reg != MAX98926_CHIP_VERSION1))) {
+             dev_err(codec->dev, "Failed to read: %x\n", reg);
+             return -EINVAL;
+     }
Quoted 4 lines

You should do this check in the I2C level probe. The error message is also wrong if the register does read but isn't what we expected.

Are you *sure* no new revisions of the device will be made?

yes will remove the revision check as we have
few revisions planned.

Quoted 6 lines

sound/soc/codecs/max98926.c line 613

Quoted 4 lines
sound/soc/codecs/max98926.c new file +3 -0
+     /* It's not the default but we need to set DAI_DLY */
+     regmap_write(max98926->regmap,
+                     MAX98926_FORMAT, MAX98926_DAI_DLY_MASK);

Sounds like this might be the I2S vs left justified configuration?

basically it is dai data delay. Setting this way causes the MSB to be valid on second active edge after LRCLK event.

maintainer
#3 lore raw
Quoted 18 lines · anish kumar
Quoted 6 lines · Mark Brown

sound/soc/codecs/max98926.c line 315

Quoted 2 lines · Anish Kumar
sound/soc/codecs/max98926.c new file +2 -0
+     SOC_ENUM("Input Sel", max98926_input_sel),
+     SOC_ENUM("DAI Input Sel", max98926_dai_input_sel),

These look like DAPM controls?

'Input Sel' is basically as below:
DAC Input Select
Selects the left, right or mix of left + right as the DAC input signal. 00 = Left DAI input (default)
01 = Right DAI input
10 = Left + Right
11 = Left/2 + Right/2
So i think it is best that it is not part
of dapm.

Quoted 4 lines

'DAI Input Sel' is the input to the power amplifier. 98926 amplifier can take PCM input from I2S or can take analog signal. So we need to set this as control.

Sure, but it looks like a DAPM control.

Quoted 5 lines
Quoted 4 lines

sound/soc/codecs/max98926.c line 319

Quoted 4 lines
sound/soc/codecs/max98926.c new file +4 -0
+     SOC_ENUM_EXT("PDM CH0 Enable", max98926_global_enum[0],
+             max98926_get_pdm_ch_zero, max98926_put_pdm_ch_zero),
+     SOC_ENUM_EXT("PDM CH1 Enable", max98926_global_enum[0],
+             max98926_get_pdm_ch_one, max98926_put_pdm_ch_one),
Quoted 8 lines

We can get vi feedback in two channels. Customer can enable either channel 0 or channel 1. Channel 0 source can be voltage or current. So basically i created kcontrol for that so that we can either enable channel 0, 1 or both.

'PDM CH0 Enable' 1 causes channel 0 to be enabled for current. So i enable all the relevant bit in put callback.

The user needs to be able to tell all this from the controls, it doesn't seem that hard - it sounds like you want to have SIGGEN widgets for the measurements and then route them to the capture DAI normally.

Quoted 7 lines
Quoted 7 lines
Quoted 6 lines
sound/soc/codecs/max98926.c new file +6 -0
+     if ((ret < 0) ||
+             ((reg != MAX98926_CHIP_VERSION) &&
+             (reg != MAX98926_CHIP_VERSION1))) {
+             dev_err(codec->dev, "Failed to read: %x\n", reg);
+             return -EINVAL;
+     }
Quoted 6 lines
Quoted 4 lines

You should do this check in the I2C level probe. The error message is also wrong if the register does read but isn't what we expected.

Are you *sure* no new revisions of the device will be made?

yes will remove the revision check as we have
few revisions planned.

The driver should probably print the revision for diagnostics.

Quoted 9 lines
Quoted 5 lines

sound/soc/codecs/max98926.c line 613

Quoted 3 lines
sound/soc/codecs/max98926.c new file +3 -0
+     /* It's not the default but we need to set DAI_DLY */
+     regmap_write(max98926->regmap,
+                     MAX98926_FORMAT, MAX98926_DAI_DLY_MASK);

Sounds like this might be the I2S vs left justified configuration?

basically it is dai data delay. Setting this way causes the MSB to be valid on second active edge after LRCLK event.

This should be part of setting the DAI format then.