Skip to contentSkip to conversation

ASoC: Add max98926 codec driver

PATCH In review anish kumar 3 participants 4 messages Dec 1, 2015 – Dec 8, 2015

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

PATCH 1/1 ASoC: Add max98926 codec driver

Changes since v1:
Made some widgets as supply widgets
Changed the names a bit
Moved some registers to volatile struct
Some coding style changes
added the print for diagnostics

---
 .../devicetree/bindings/sound/max98926.txt         |  32 +
 sound/soc/codecs/Kconfig                           |   5 +
 sound/soc/codecs/Makefile                          |   2 +
 sound/soc/codecs/max98926.c                        | 599 +++++++++++++++
 sound/soc/codecs/max98926.h                        | 848 +++++++++++++++++++++
 5 files changed, 1486 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..0b7f4e4
@@ -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 +5 -0
index cfdafc4..3fe8bd3 100644
@@ -39,6 +39,7 @@ config SND_SOC_ALL_CODECS
 	select SND_SOC_AK4613 if I2C
 	select SND_SOC_AK4641 if I2C
 	select SND_SOC_AK4642 if I2C
+	select SND_SOC_MAX98926 if I2C
 	select SND_SOC_AK4671 if I2C
 	select SND_SOC_AK5386
 	select SND_SOC_ALC5623 if I2C
@@ -331,6 +332,10 @@ config SND_SOC_AK4613
 config SND_SOC_AK4641
 	tristate
 
+config SND_SOC_MAX98926
+	tristate "MAX98926 CODEC"
+	depends on I2C
+
 config SND_SOC_AK4642
 	tristate "AKM AK4642 CODEC"
 	depends on I2C
sound/soc/codecs/Makefile +2 -0
index f632fc4..a38b536 100644
@@ -29,6 +29,7 @@ snd-soc-ak4554-objs := ak4554.o
 snd-soc-ak4613-objs := ak4613.o
 snd-soc-ak4641-objs := ak4641.o
 snd-soc-ak4642-objs := ak4642.o
+snd-soc-max98926-objs := max98926.o
 snd-soc-ak4671-objs := ak4671.o
 snd-soc-ak5386-objs := ak5386.o
 snd-soc-arizona-objs := arizona.o
@@ -222,6 +223,7 @@ obj-$(CONFIG_SND_SOC_AK4554)	+= snd-soc-ak4554.o
 obj-$(CONFIG_SND_SOC_AK4613)	+= snd-soc-ak4613.o
 obj-$(CONFIG_SND_SOC_AK4641)	+= snd-soc-ak4641.o
 obj-$(CONFIG_SND_SOC_AK4642)	+= snd-soc-ak4642.o
+obj-$(CONFIG_SND_SOC_MAX98926)	+= snd-soc-max98926.o
 obj-$(CONFIG_SND_SOC_AK4671)	+= snd-soc-ak4671.o
 obj-$(CONFIG_SND_SOC_AK5386)	+= snd-soc-ak5386.o
 obj-$(CONFIG_SND_SOC_ALC5623)    += snd-soc-alc5623.o
sound/soc/codecs/max98926.c new file +599 -0

599 lines not on this page · raw message

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

848 lines not on this page · raw message

Signature · 1 line
1.9.3
#1 lore raw
coccinelle warnings: (new ones prefixed by >>)

Hi anish,

[auto build test WARNING on asoc/for-next] [also build test WARNING on v4.4-rc3 next-20151127]

url:    https://github.com/0day-ci/linux/commits/anish-kumar/ASoC-Add-max98926-codec-driver/20151202-023631
base:   https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-next

coccinelle warnings: (new ones prefixed by >>)

>> sound/soc/codecs/max98926.c:587:3-8: No need to set .owner here. The core will do it.

Please review and possibly fold the followup patch.

---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation

#2 lore raw

[PATCH] ASoC: fix platform_no_drv_owner.cocci warnings

In reply to anish kumar
sound/soc/codecs/max98926.c:587:3-8: No need to set .owner here. The core will do it.

sound/soc/codecs/max98926.c:587:3-8: No need to set .owner here. The core will do it.

Remove .owner field if calls are used which set it automatically

Generated by: scripts/coccinelle/api/platform_no_drv_owner.cocci

---

 max98926.c |    1 -
 1 file changed, 1 deletion(-)
sound/soc/codecs/max98926.c +0 -1
@@ -584,7 +584,6 @@ MODULE_DEVICE_TABLE(of, max98926_of_matc
 static struct i2c_driver max98926_i2c_driver = {
 	.driver = {
 		.name = "max98926",
-		.owner = THIS_MODULE,
 		.of_match_table = of_match_ptr(max98926_of_match),
 		.pm = NULL,
 	},
maintainer
#3 lore raw
In reply to anish kumar
Quoted 9 lines · anish kumar

Changes since v1:
Made some widgets as supply widgets
Changed the names a bit
Moved some registers to volatile struct
Some coding style changes
added the print for diagnostics

---

Please use the patch submission format covered in SubmittingPatches - the inter-version changelog should be after the --- so it doesn't end up in the final changelog.

sound/soc/codecs/Kconfig config SND_SOC_ALL_CODECS · line 45

Quoted 6 lines
sound/soc/codecs/Kconfig +1 -0
 	select SND_SOC_AK4641 if I2C
 	select SND_SOC_AK4642 if I2C
+	select SND_SOC_MAX98926 if I2C
 	select SND_SOC_AK4671 if I2C
 	select SND_SOC_AK5386
 	select SND_SOC_ALC5623 if I2C

Please keep the Kconfig and Makefile sorted.

sound/soc/codecs/max98926.c line 112

Quoted 6 lines
sound/soc/codecs/max98926.c new file +6 -0
+static const struct snd_kcontrol_new max98926_mixer_controls[] = {
+	SOC_DAPM_SINGLE("PCM", MAX98926_SPK_AMP,
+		MAX98926_INSELECT_MODE_SHIFT, 0, 0),
+	SOC_DAPM_SINGLE("PDM", MAX98926_SPK_AMP,
+		MAX98926_INSELECT_MODE_SHIFT, 1, 0),
+};

On/off switches should have names ending in " Single".

sound/soc/codecs/max98926.c line 122

Quoted 2 lines
sound/soc/codecs/max98926.c new file +2 -0
+	SOC_DAPM_SINGLE("LeftRightDiv2", MAX98926_GAIN,
+		MAX98926_DAC_IN_SEL_SHIFT, 3, 0),

Please give this a more human readable name, something like "(Left + Right) / 2 Switch".

Quoted 5 lines
sound/soc/codecs/max98926.c new file +5 -0
+static int max98926_probe(struct snd_soc_codec *codec)
+{
+	struct max98926_priv *max98926 = snd_soc_codec_get_drvdata(codec);
+
+	max98926->codec = codec;

sound/soc/codecs/max98926.c line 486

Quoted 10 lines
sound/soc/codecs/max98926.c new file +10 -0
+	codec->control_data = max98926->regmap;
+	regmap_write(max98926->regmap, MAX98926_GLOBAL_ENABLE, 0x00);
+	regmap_write(max98926->regmap, MAX98926_TDM_SLOT_SELECT, 0xC8);
+	regmap_write(max98926->regmap, MAX98926_DOUT_HIZ_CFG1, 0xFF);
+	regmap_write(max98926->regmap, MAX98926_DOUT_HIZ_CFG2, 0xFF);
+	regmap_write(max98926->regmap, MAX98926_DOUT_HIZ_CFG3, 0xFF);
+	regmap_write(max98926->regmap, MAX98926_DOUT_HIZ_CFG4, 0xF0);
+	regmap_write(max98926->regmap, MAX98926_FILTERS, 0xD8);
+	regmap_write(max98926->regmap, MAX98926_ALC_CONFIGURATION, 0xF8);
+	regmap_write(max98926->regmap, MAX98926_CONFIGURATION, 0xF0);

Lots of random magic numbers - what's going on here?

sound/soc/codecs/max98926.c line 488

Quoted 2 lines
sound/soc/codecs/max98926.c new file +2 -0
+	/* Disable ALC muting */
+	regmap_write(max98926->regmap, MAX98926_BOOST_LIMITER, 0xF8);

Shouldn't this be a control?

sound/soc/codecs/max98926.c line 561

Quoted 12 lines
sound/soc/codecs/max98926.c new file +12 -0
+	ret = snd_soc_register_codec(&i2c->dev, &soc_codec_dev_max98926,
+			max98926_dai, ARRAY_SIZE(max98926_dai));
+	if (ret < 0)
+		dev_err(&i2c->dev,
+				"Failed to register codec: %d\n", ret);
+	ret = regmap_read(max98926->regmap,
+			MAX98926_VERSION, &reg);
+	if (ret < 0) {
+		dev_err(&i2c->dev, "Failed to read: %x\n", reg);
+		return -EINVAL;
+	}
+	dev_info(&i2c->dev, "device version: %x\n", reg);

It's more normal to read the device ID information before doing anything else - part of what we're doing is working out if we've got working register access to the device, if that fails then there's no point in registering. Please also pass back error codes rather than substituting new codes unless there's a strong reason.