ASoC: Add a driver for the Cirrus Logic CS35L45 Smart Amplifier
Subsystems (4)
Richard Fitzgerald
maintainerv2 cover ASoC: Add a driver for the Cirrus Logic CS35L45 Smart Amplifier
This adds basic audio support for the Cirrus Logic CS35L45 amplifier.
The first two patches add two generic helpers to ASoC, and patch 3 is a kunit test for patch 2.
CHANGES SINCE V1:
Patch #5:
- spi .remove callback now has void return
- use new I2C .probe_new callback
- force boost-bypass mode as default
James Schulman (1):
ASoC: cs35l45: Add driver for Cirrus Logic CS35L45 Smart Amp
Richard Fitzgerald (4):
ASoC: soc.h: Add SOC_SINGLE_S_TLV() macro
ASoC: soc-utils: Add helper to calculate BCLK from TDM info
ASoC: soc-utils: Add kunit test for snd_soc_tdm_params_to_bclk()
ASoC: dt-bindings: cs35l45: Cirrus Logic CS35L45 Smart Amp
.../bindings/sound/cirrus,cs35l45.yaml | 75 ++ MAINTAINERS | 2 + include/dt-bindings/sound/cs35l45.h | 20 + include/sound/soc.h | 4 + sound/soc/Kconfig | 9 +- sound/soc/Makefile | 5 + sound/soc/codecs/Kconfig | 30 + sound/soc/codecs/Makefile | 8 + sound/soc/codecs/cs35l45-i2c.c | 72 ++ sound/soc/codecs/cs35l45-spi.c | 72 ++ sound/soc/codecs/cs35l45-tables.c | 202 +++++ sound/soc/codecs/cs35l45.c | 693 ++++++++++++++++++ sound/soc/codecs/cs35l45.h | 217 ++++++ sound/soc/soc-utils-test.c | 186 +++++ sound/soc/soc-utils.c | 45 ++ 15 files changed, 1639 insertions(+), 1 deletion(-) create mode 100644 Documentation/devicetree/bindings/sound/cirrus,cs35l45.yaml create mode 100644 include/dt-bindings/sound/cs35l45.h create mode 100644 sound/soc/codecs/cs35l45-i2c.c create mode 100644 sound/soc/codecs/cs35l45-spi.c create mode 100644 sound/soc/codecs/cs35l45-tables.c create mode 100644 sound/soc/codecs/cs35l45.c create mode 100644 sound/soc/codecs/cs35l45.h create mode 100644 sound/soc/soc-utils-test.c
Signature · 1 line
2.30.2
Richard Fitzgerald
maintainerPATCH v2 1/5 ASoC: soc.h: Add SOC_SINGLE_S_TLV() macro
Add a convenience macro for defining a single (mono) TLV control with a signed value. This can already be done by using SOC_DOUBLE_R_S_TLV() with the same address for left and right registers, but a dedicated macro is more readable.
--- include/sound/soc.h | 2 ++ 1 file changed, 2 insertions(+)
include/sound/soc.h +2 -0
@@ -176,6 +176,8 @@ .get = snd_soc_get_volsw, .put = snd_soc_put_volsw, \ .private_value = SOC_DOUBLE_R_S_VALUE(reg_left, reg_right, xshift, \ xmin, xmax, xsign_bit, xinvert) } +#define SOC_SINGLE_S_TLV (xname, xreg, xshift, xmin, xmax, xsign_bit, xinvert, tlv_array) \ + SOC_DOUBLE_R_S_TLV(xname, xreg, xreg, xshift, xmin, xmax, xsign_bit, xinvert, tlv_array)#define SOC_SINGLE_S8_TLV (xname, xreg, xmin, xmax, tlv_array) \ { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname), \ .access = SNDRV_CTL_ELEM_ACCESS_TLV_READ | \
Signature · 1 line
2.30.2
Richard Fitzgerald
maintainerPATCH v2 2/5 ASoC: soc-utils: Add helper to calculate BCLK from TDM info
In reply to Richard FitzgeraldAdd a helper function snd_soc_tdm_params_to_bclk() to calculate the bclk from params info and the tdm sots configuration.
When using a TDM frame of N slots of width W bits:
bclk = sample_rate * N * W
As a convenience to simplify calling code, if the slot count or slot width are 0 a value will be obtained from the params. This allows calling code to use this one function to handle cases of TDM where only one parameter is fixed, or I2S where the slot width is fixed (for example to set a 32-bit slot for 24-bit samples).
Also as a convenience the slot count can optionally be rounded up to a multiple. This is mainly useful for I2S systems, since I2S has two phases of LRCLK the number of slots is always a multiple of 2.
--- include/sound/soc.h | 2 ++ sound/soc/soc-utils.c | 45 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 47 insertions(+)
include/sound/soc.h +2 -0
@@ -487,6 +487,8 @@ int snd_soc_calc_frame_size(int sample_size, int channels, int tdm_slots);int snd_soc_params_to_frame_size (struct snd_pcm_hw_params *params);int snd_soc_calc_bclk (int fs,int sample_size,int channels,int tdm_slots);int snd_soc_params_to_bclk (struct snd_pcm_hw_params *parms); +int snd_soc_tdm_params_to_bclk (struct snd_pcm_hw_params *params, +int tdm_width,int tdm_slots,int slot_multiple);/* set runtime hw params */ int snd_soc_set_runtime_hwparams(struct snd_pcm_substream *substream,
sound/soc/soc-utils.c +45 -0
57 lines not on this page · raw message
Signature · 1 line
2.30.2
Richard Fitzgerald
maintainerPATCH v2 3/5 ASoC: soc-utils: Add kunit test for snd_soc_tdm_params_to_bclk()
In reply to Richard FitzgeraldCreate a new kunit test for soc-utils and use it to test snd_soc_tdm_params_to_bclk().
The test uses a table of values to avoid the possibility that an on-the-fly generator contains the same algorithmic error as the function-under-test and so fails to detect a bug.
There is no need to test every possible combination of values. Enough test cases are included to give confidence that the function is producing the correct results.
--- sound/soc/Kconfig | 9 +- sound/soc/Makefile | 5 + sound/soc/soc-utils-test.c | 186 +++++++++++++++++++++++++++++++++++++ 3 files changed, 199 insertions(+), 1 deletion(-) create mode 100644 sound/soc/soc-utils-test.c
sound/soc/Kconfig +8 -1
@@ -14,7 +14,7 @@ menuconfig SND_SOC If you want ASoC support, you should say Y here and also to the specific driver for your SoC platform below. - + ASoC provides power efficient ALSA support for embedded battery powered SoC based systems like PDA's, Phones and Personal Media Players.
@@ -55,6 +55,13 @@ config SND_SOC_TOPOLOGY_KUNIT_TEST userspace applications such as pulseaudio, to prevent unnecessary problems. +config SND_SOC_UTILS_KUNIT_TEST + tristate "KUnit tests for SoC utils" + depends on KUNIT + default KUNIT_ALL_TESTS + help + If you want to perform tests on ALSA SoC utils library say Y here. + config SND_SOC_ACPI tristate
sound/soc/Makefile +5 -0
@@ -12,6 +12,11 @@ ifneq ($(CONFIG_SND_SOC_TOPOLOGY_KUNIT_TEST),) obj-$(CONFIG_SND_SOC_TOPOLOGY_KUNIT_TEST) := soc-topology-test.o endif +ifneq ($(CONFIG_SND_SOC_UTILS_KUNIT_TEST),) +# snd-soc-test-objs := soc-utils-test.o +obj-$(CONFIG_SND_SOC_UTILS_KUNIT_TEST) := soc-utils-test.o +endif + ifneq ($(CONFIG_SND_SOC_GENERIC_DMAENGINE_PCM),) snd-soc-core-objs += soc-generic-dmaengine-pcm.o endif
sound/soc/soc-utils-test.c new file +186 -0
186 lines not on this page · raw message
Signature · 1 line
2.30.2
Richard Fitzgerald
maintainerPATCH v2 4/5 ASoC: dt-bindings: cs35l45: Cirrus Logic CS35L45 Smart Amp
In reply to Richard FitzgeraldThis adds the schema binding for the Cirrus Logic CS35L45 Smart Amp and associated header file.
--- .../bindings/sound/cirrus,cs35l45.yaml | 75 +++++++++++++++++++ MAINTAINERS | 2 + include/dt-bindings/sound/cs35l45.h | 20 +++++ 3 files changed, 97 insertions(+) create mode 100644 Documentation/devicetree/bindings/sound/cirrus,cs35l45.yaml create mode 100644 include/dt-bindings/sound/cs35l45.h
Documentation/devicetree/bindings/sound/cirrus,cs35l45.yaml new file +75 -0
@@ -0,0 +1,75 @@ +# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/sound/cirrus,cs35l45.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Cirrus Logic CS35L45 Speaker Amplifier + +maintainers: + - Ricardo Rivera-Matos <[email protected]> + - Richard Fitzgerald <[email protected]> + +description: | + CS35L45 is a Boosted Mono Class D Amplifier with DSP + Speaker Protection and Adaptive Battery Management. + +properties: + compatible: + enum: + - cirrus,cs35l45 + + reg: + maxItems: 1 + + '#sound-dai-cells': + const: 1 + + reset-gpios: + maxItems: 1 + + vdd-a-supply: + description: voltage regulator phandle for the VDD_A supply + + vdd-batt-supply: + description: voltage regulator phandle for the VDD_BATT supply + + spi-max-frequency: + maximum: 5000000 + + cirrus,asp-sdout-hiz-ctrl: + description: + Audio serial port SDOUT Hi-Z control. Sets the Hi-Z + configuration for SDOUT pin of amplifier. Logical OR of + CS35L45_ASP_TX_HIZ_xxx values. + $ref: "/schemas/types.yaml#/definitions/uint32" + minimum: 0 + maximum: 3 + default: 2 + +required: + - compatible + - reg + - "#sound-dai-cells" + +additionalProperties: false + +examples: + - | + #include <dt-bindings/sound/cs35l45.h> + spi { + #address-cells = <1>; + #size-cells = <0>; + + cs35l45: cs35l45@2 { + #sound-dai-cells = <1>; + compatible = "cirrus,cs35l45"; + reg = <2>; + spi-max-frequency = <5000000>; + vdd-a-supply = <&dummy_vreg>; + vdd-batt-supply = <&dummy_vreg>; + reset-gpios = <&gpio 110 0>; + cirrus,asp-sdout-hiz-ctrl = <(CS35L45_ASP_TX_HIZ_UNUSED | + CS35L45_ASP_TX_HIZ_DISABLED)>; + }; + };
MAINTAINERS +2 -0
@@ -4688,10 +4688,12 @@ CIRRUS LOGIC AUDIO CODEC DRIVERS M: James Schulman <[email protected]> M: David Rhodes <[email protected]> M: Lucas Tanure <[email protected]> +M: Richard Fitzgerald <[email protected]> L: [email protected] (moderated for non-subscribers) L: [email protected] S: Maintained F: Documentation/devicetree/bindings/sound/cirrus,cs* +F: include/dt-bindings/sound/cs* F: sound/pci/hda/cs* F: sound/soc/codecs/cs*
include/dt-bindings/sound/cs35l45.h new file +20 -0
@@ -0,0 +1,20 @@ +/* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */ +/* +* cs35l45.h -- CS35L45 ALSA SoC audio driver DT bindings header +* +* Copyright 2022 Cirrus Logic, Inc. +*/ + +#ifndef DT_CS35L45_H +#define DT_CS35L45_H + +/* +* cirrus,asp-sdout-hiz-ctrl +* +* TX_HIZ_UNUSED: TX pin high-impedance during unused slots. +* TX_HIZ_DISABLED: TX pin high-impedance when all channels disabled. +*/ +#define CS35L45_ASP_TX_HIZ_UNUSED 0x1 +#define CS35L45_ASP_TX_HIZ_DISABLED 0x2 + +#endif /* DT_CS35L45_H */
Signature · 1 line
2.30.2
Richard Fitzgerald
maintainerPATCH v2 5/5 ASoC: cs35l45: Add driver for Cirrus Logic CS35L45 Smart Amp
In reply to Richard FitzgeraldFrom: James Schulman <[email protected]>
The CS35L45 is a 15 V Boosted Mono Class D Amplifier with DSP Speaker Protection and Adaptive Battery Management.
This initial driver provides standard non-boosted audio operation without the DSP.
--- sound/soc/codecs/Kconfig | 30 ++ sound/soc/codecs/Makefile | 8 + sound/soc/codecs/cs35l45-i2c.c | 72 ++++ sound/soc/codecs/cs35l45-spi.c | 72 ++++ sound/soc/codecs/cs35l45-tables.c | 202 +++++++++ sound/soc/codecs/cs35l45.c | 693 ++++++++++++++++++++++++++++++ sound/soc/codecs/cs35l45.h | 217 ++++++++++ 7 files changed, 1294 insertions(+) create mode 100644 sound/soc/codecs/cs35l45-i2c.c create mode 100644 sound/soc/codecs/cs35l45-spi.c create mode 100644 sound/soc/codecs/cs35l45-tables.c create mode 100644 sound/soc/codecs/cs35l45.c create mode 100644 sound/soc/codecs/cs35l45.h
sound/soc/codecs/Kconfig +30 -0
@@ -65,6 +65,8 @@ config SND_SOC_ALL_CODECS imply SND_SOC_CS35L36 imply SND_SOC_CS35L41_SPI imply SND_SOC_CS35L41_I2C + imply SND_SOC_CS35L45_I2C + imply SND_SOC_CS35L45_SPI imply SND_SOC_CS42L42 imply SND_SOC_CS42L51_I2C imply SND_SOC_CS42L52
@@ -656,6 +658,34 @@ config SND_SOC_CS35L41_I2C select SND_SOC_CS35L41 select REGMAP_I2C +config SND_SOC_CS35L45_TABLES + tristate + +config SND_SOC_CS35L45 + tristate + +config SND_SOC_CS35L45_SPI + tristate "Cirrus Logic CS35L45 CODEC (SPI)" + depends on SPI_MASTER + select REGMAP + select REGMAP_SPI + select SND_SOC_CS35L45_TABLES + select SND_SOC_CS35L45 + help + Enable support for Cirrus Logic CS35L45 smart speaker amplifier + with SPI control. + +config SND_SOC_CS35L45_I2C + tristate "Cirrus Logic CS35L45 CODEC (I2C)" + depends on I2C + select REGMAP + select REGMAP_I2C + select SND_SOC_CS35L45_TABLES + select SND_SOC_CS35L45 + help + Enable support for Cirrus Logic CS35L45 smart speaker amplifier + with I2C control. + config SND_SOC_CS42L42 tristate "Cirrus Logic CS42L42 CODEC" depends on I2C
sound/soc/codecs/Makefile +8 -0
@@ -60,6 +60,10 @@ snd-soc-cs35l41-lib-objs := cs35l41-lib.o snd-soc-cs35l41-objs := cs35l41.o snd-soc-cs35l41-spi-objs := cs35l41-spi.o snd-soc-cs35l41-i2c-objs := cs35l41-i2c.o +snd-soc-cs35l45-tables-objs := cs35l45-tables.o +snd-soc-cs35l45-objs := cs35l45.o +snd-soc-cs35l45-spi-objs := cs35l45-spi.o +snd-soc-cs35l45-i2c-objs := cs35l45-i2c.o snd-soc-cs42l42-objs := cs42l42.o snd-soc-cs42l51-objs := cs42l51.o snd-soc-cs42l51-i2c-objs := cs42l51-i2c.o
@@ -406,6 +410,10 @@ obj-$(CONFIG_SND_SOC_CS35L41) += snd-soc-cs35l41.o obj-$(CONFIG_SND_SOC_CS35L41_LIB) += snd-soc-cs35l41-lib.o obj-$(CONFIG_SND_SOC_CS35L41_SPI) += snd-soc-cs35l41-spi.o obj-$(CONFIG_SND_SOC_CS35L41_I2C) += snd-soc-cs35l41-i2c.o +obj-$(CONFIG_SND_SOC_CS35L45_TABLES) += snd-soc-cs35l45-tables.o +obj-$(CONFIG_SND_SOC_CS35L45) += snd-soc-cs35l45.o +obj-$(CONFIG_SND_SOC_CS35L45_SPI) += snd-soc-cs35l45-spi.o +obj-$(CONFIG_SND_SOC_CS35L45_I2C) += snd-soc-cs35l45-i2c.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/cs35l45-i2c.c new file +72 -0
72 lines not on this page · raw message
sound/soc/codecs/cs35l45-spi.c new file +72 -0
72 lines not on this page · raw message
sound/soc/codecs/cs35l45-tables.c new file +202 -0
202 lines not on this page · raw message
sound/soc/codecs/cs35l45.c new file +693 -0
693 lines not on this page · raw message
sound/soc/codecs/cs35l45.h new file +217 -0
217 lines not on this page · raw message
Signature · 1 line
2.30.2
Mark Brown
maintainerQuoted 5 lines · Richard Fitzgerald
This adds basic audio support for the Cirrus Logic CS35L45 amplifier.
The first two patches add two generic helpers to ASoC, and patch 3 is a kunit test for patch 2.
Quoted 7 lines
CHANGES SINCE V1:
Patch #5:
- spi .remove callback now has void return
- use new I2C .probe_new callback
- force boost-bypass mode as default[...]
Applied to
https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-next
Thanks!
[1/5] ASoC: soc.h: Add SOC_SINGLE_S_TLV() macro
commit: bc8cb02976cd602b8d7631a6f4a54a9cf305d38c
[2/5] ASoC: soc-utils: Add helper to calculate BCLK from TDM info
commit: 1ef34dd2b90d78a9830398441801658ef86eee9d
[3/5] ASoC: soc-utils: Add kunit test for snd_soc_tdm_params_to_bclk()
commit: 89342fa38bbaade51584f255eee5cd43621f4e10
[4/5] ASoC: dt-bindings: cs35l45: Cirrus Logic CS35L45 Smart Amp
commit: 72661ff7662acc00d51976d4b2d2d13eb5628385
[5/5] ASoC: cs35l45: Add driver for Cirrus Logic CS35L45 Smart Amp
commit: 0d463d016000d68d7e982720b5e4380b2d83409aAll being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted.
You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed.
If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced.
Please add any relevant lists and maintainers to the CCs when replying to this mail.
Thanks,
Mark