Skip to contentSkip to conversation

ASoC: cs35l36: Add support for Cirrus CS35L36 Amplifier

PATCH In review James Schulman 2 participants 2 messages Feb 1, 2019 – Feb 2, 2019

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

PATCH 1/2 ASoC: cs35l36: Add support for Cirrus CS35L36 Amplifier

Add driver support for Cirrus Logic CS35L36 boosted speaker amplifier

---
 include/sound/cs35l36.h    |   44 +
 sound/soc/codecs/Kconfig   |    5 +
 sound/soc/codecs/Makefile  |    2 +
 sound/soc/codecs/cs35l36.c | 1959 ++++++++++++++++++++++++++++++++++++++++++++
 sound/soc/codecs/cs35l36.h |  446 ++++++++++
 5 files changed, 2456 insertions(+)
 create mode 100644 include/sound/cs35l36.h
 create mode 100644 sound/soc/codecs/cs35l36.c
 create mode 100644 sound/soc/codecs/cs35l36.h
include/sound/cs35l36.h new file +44 -0
new file mode 100644
index 0000000..1ee7527
@@ -0,0 +1,44 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/*
+ * linux/sound/cs35l36.h -- Platform data for CS35L36
+ *
+ * Copyright 2018 Cirrus Logic, Inc.
+ *
+ * Author: James Schulman <[email protected]>
+ *
+ */
+
+#ifndef __CS35L36_H
+#define __CS35L36_H
+
+struct cs35l36_vpbr_cfg {
+	bool is_present;
+	bool vpbr_en;
+	int vpbr_thld;
+	int vpbr_atk_rate;
+	int vpbr_atk_vol;
+	int vpbr_max_attn;
+	int vpbr_wait;
+	int vpbr_rel_rate;
+	int vpbr_mute_en;
+};
+
+struct cs35l36_platform_data {
+	bool multi_amp_mode;
+	bool dcm_mode;
+	int ldm_mode_sel;
+	bool amp_pcm_inv;
+	bool imon_pol_inv;
+	bool vmon_pol_inv;
+	int boost_ind;
+	int bst_vctl;
+	int bst_vctl_sel;
+	int bst_ipk;
+	bool extern_boost;
+	int temp_warn_thld;
+	int irq_drv_sel;
+	int irq_gpio_sel;
+	struct cs35l36_vpbr_cfg vpbr_config;
+};
+
+#endif /* __CS35L36_H */
sound/soc/codecs/Kconfig +5 -0
index a15710c..3946222 100644
@@ -55,6 +55,7 @@ config SND_SOC_ALL_CODECS
 	select SND_SOC_CS35L33 if I2C
 	select SND_SOC_CS35L34 if I2C
 	select SND_SOC_CS35L35 if I2C
+	select SND_SOC_CS35L36 if I2C
 	select SND_SOC_CS42L42 if I2C
 	select SND_SOC_CS42L51_I2C if I2C
 	select SND_SOC_CS42L52 if I2C && INPUT
@@ -483,6 +484,10 @@ config SND_SOC_CS35L35
 	tristate "Cirrus Logic CS35L35 CODEC"
 	depends on I2C
 
+config SND_SOC_CS35L36
+	tristate "Cirrus Logic CS35L36 CODEC"
+	depends on I2C
+
 config SND_SOC_CS42L42
 	tristate "Cirrus Logic CS42L42 CODEC"
 	depends on I2C
sound/soc/codecs/Makefile +2 -0
index 3d7a597..427b180 100644
@@ -47,6 +47,7 @@ snd-soc-cs35l32-objs := cs35l32.o
 snd-soc-cs35l33-objs := cs35l33.o
 snd-soc-cs35l34-objs := cs35l34.o
 snd-soc-cs35l35-objs := cs35l35.o
+snd-soc-cs35l36-objs := cs35l36.o
 snd-soc-cs42l42-objs := cs42l42.o
 snd-soc-cs42l51-objs := cs42l51.o
 snd-soc-cs42l51-i2c-objs := cs42l51-i2c.o
@@ -318,6 +319,7 @@ obj-$(CONFIG_SND_SOC_CS35L32)	+= snd-soc-cs35l32.o
 obj-$(CONFIG_SND_SOC_CS35L33)	+= snd-soc-cs35l33.o
 obj-$(CONFIG_SND_SOC_CS35L34)	+= snd-soc-cs35l34.o
 obj-$(CONFIG_SND_SOC_CS35L35)	+= snd-soc-cs35l35.o
+obj-$(CONFIG_SND_SOC_CS35L36)	+= snd-soc-cs35l36.o
 obj-$(CONFIG_SND_SOC_CS42L42)	+= snd-soc-cs42l42.o
 obj-$(CONFIG_SND_SOC_CS42L51)	+= snd-soc-cs42l51.o
 obj-$(CONFIG_SND_SOC_CS42L51_I2C)	+= snd-soc-cs42l51-i2c.o
sound/soc/codecs/cs35l36.c new file +1959 -0

1,959 lines not on this page · raw message

sound/soc/codecs/cs35l36.h new file +446 -0

446 lines not on this page · raw message

Signature · 1 line
1.9.1
maintainer
#1 lore raw

sound/soc/codecs/cs35l36.c line 3

Quoted 5 lines · James Schulman

+++ b/sound/soc/codecs/cs35l36.c

sound/soc/codecs/cs35l36.c new file +3 -0
@@ -0,0 +1,1959 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/*
+ * cs35l36.c -- CS35L36 ALSA SoC audio driver

SPDX headers in C files need to be C++ comments; please make the entire thing a C++ comment so it looks more intentional. Headers should still use /* */

Quoted 4 lines
sound/soc/codecs/cs35l36.c new file +4 -0
+static int cs35l36_ldm_sel_put(struct snd_kcontrol *kcontrol,
+			       struct snd_ctl_elem_value *ucontrol)
+{
+	struct snd_soc_component *component =

sound/soc/codecs/cs35l36.c line 484

Quoted 10 lines
sound/soc/codecs/cs35l36.c new file +10 -0
+			snd_soc_kcontrol_component(kcontrol);
+	struct cs35l36_private *cs35l36 =
+			snd_soc_component_get_drvdata(component);
+	int val = (ucontrol->value.integer.value[0]) ? CS35L36_NG_AMP_EN_MASK :
+						       0;
+
+	cs35l36->pdata.ldm_mode_sel = val;
+
+	regmap_update_bits(cs35l36->regmap, CS35L36_NG_CFG,
+			   CS35L36_NG_AMP_EN_MASK, val);

If this can be usefully changed at runtime why is it part of the platform data? I'd expect control by one of these methods but not both.

sound/soc/codecs/cs35l36.c line 496

Quoted 2 lines
sound/soc/codecs/cs35l36.c new file +2 -0
+	SOC_SINGLE("Amp Gain Zero-Cross", CS35L36_AMP_GAIN_CTRL,
+		CS35L36_AMP_ZC_SHIFT, 1, 0),

This is an on/off switch so should have Switch at the end fo the name so that userspace tools know how to handle it (the same thing seems to apply to at least some of the other controls).