Re: [PATCH v1 07/10] ASoC: codecs: add wsa881x-i2c amplifier codec driver

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, Nov 1, 2024 at 12:32 AM Alexey Klimov <alexey.klimov@xxxxxxxxxx> wrote:
>
> Add support to analog mode of WSA8810/WSA8815 Class-D Smart Speaker
> family of amplifiers. Such amplifiers is primarily interfaced with
> SoundWire but they also support analog mode which is configurable
> by setting one of the pins to high/low. In such case the WSA881X
> amplifier is configurable only using i2c.
>
> To have stereo two WSA881X amplifiers are required but mono
> configurations are also possible.
>
> Cc: Srinivas Kandagatla <srinivas.kandagatla@xxxxxxxxxx>
> Signed-off-by: Alexey Klimov <alexey.klimov@xxxxxxxxxx>
> ---
>  sound/soc/codecs/Kconfig          |   11 +
>  sound/soc/codecs/Makefile         |    2 +
>  sound/soc/codecs/wsa881x-common.h |   19 +
>  sound/soc/codecs/wsa881x-i2c.c    | 1454 +++++++++++++++++++++++++++++
>  4 files changed, 1486 insertions(+)
>  create mode 100644 sound/soc/codecs/wsa881x-i2c.c
>
> diff --git a/sound/soc/codecs/Kconfig b/sound/soc/codecs/Kconfig
> index b8ea8cf73d63..3d7868977262 100644
> --- a/sound/soc/codecs/Kconfig
> +++ b/sound/soc/codecs/Kconfig
> @@ -350,6 +350,7 @@ config SND_SOC_ALL_CODECS
>         imply SND_SOC_WM9712
>         imply SND_SOC_WM9713
>         imply SND_SOC_WSA881X
> +       imply SND_SOC_WSA881X_I2C
>         imply SND_SOC_WSA883X
>         imply SND_SOC_WSA884X
>         imply SND_SOC_ZL38060
> @@ -2484,6 +2485,16 @@ config SND_SOC_WSA881X
>           This enables support for Qualcomm WSA8810/WSA8815 Class-D
>           Smart Speaker Amplifier.
>
> +config SND_SOC_WSA881X_I2C
> +       tristate "WSA881X Codec - Analog mode"
> +       depends on I2C
> +       select REGMAP_I2C
> +       select SND_SOC_WSA881X_COMMON
> +       help
> +         This enables support for Qualcomm WSA8810/WSA8815 Class-D Smart
> +         Speaker Amplifier that works in analog mode and configurable
> +         via I2C.
> +
>  config SND_SOC_WSA883X
>         tristate "WSA883X Codec"
>         depends on SOUNDWIRE
> diff --git a/sound/soc/codecs/Makefile b/sound/soc/codecs/Makefile
> index bc1498cedf08..682bdf63abea 100644
> --- a/sound/soc/codecs/Makefile
> +++ b/sound/soc/codecs/Makefile
> @@ -399,6 +399,7 @@ snd-soc-wm9713-y := wm9713.o
>  snd-soc-wm-hubs-y := wm_hubs.o
>  snd-soc-wsa881x-y := wsa881x.o
>  snd-soc-wsa881x-common-y := wsa881x-common.o
> +snd-soc-wsa881x-i2c-y := wsa881x-i2c.o
>  snd-soc-wsa883x-y := wsa883x.o
>  snd-soc-wsa884x-y := wsa884x.o
>  snd-soc-zl38060-y := zl38060.o
> @@ -821,6 +822,7 @@ obj-$(CONFIG_SND_SOC_WM_ADSP)       += snd-soc-wm-adsp.o
>  obj-$(CONFIG_SND_SOC_WM_HUBS)  += snd-soc-wm-hubs.o
>  obj-$(CONFIG_SND_SOC_WSA881X)  += snd-soc-wsa881x.o
>  obj-$(CONFIG_SND_SOC_WSA881X_COMMON)   += snd-soc-wsa881x-common.o
> +obj-$(CONFIG_SND_SOC_WSA881X_I2C)      += snd-soc-wsa881x-i2c.o
>  obj-$(CONFIG_SND_SOC_WSA883X)  += snd-soc-wsa883x.o
>  obj-$(CONFIG_SND_SOC_WSA884X)  += snd-soc-wsa884x.o
>  obj-$(CONFIG_SND_SOC_ZL38060)  += snd-soc-zl38060.o
> diff --git a/sound/soc/codecs/wsa881x-common.h b/sound/soc/codecs/wsa881x-common.h
> index cf8643e1f7f7..1b9c20cd3807 100644
> --- a/sound/soc/codecs/wsa881x-common.h
> +++ b/sound/soc/codecs/wsa881x-common.h
> @@ -2,6 +2,7 @@
>  #ifndef __WSA881x_COMMON_H__
>  #define __WSA881x_COMMON_H__
>
> +#include <linux/i2c.h>
>  #include <linux/soundwire/sdw.h>
>  #include <sound/soc.h>
>
> @@ -193,6 +194,24 @@ struct wsa881x_priv {
>         bool port_enable[WSA881X_MAX_SWR_PORTS];
>  #endif
>
> +#if IS_ENABLED(CONFIG_SND_SOC_WSA881X_I2C)
> +       /* i2c interace for analog mode */
> +       struct regmap *regmap_analog;
> +       /* First client is for digital part, the second is for analog part */
> +       struct i2c_client *client[2];
> +       struct snd_soc_component *component;
> +       struct snd_soc_dai_driver *dai_driver;
> +       struct snd_soc_component_driver *driver;
> +       struct gpio_desc *mclk_pin;
> +       struct clk *wsa_mclk;
> +       bool boost_enable;
> +       int spk_pa_gain;
> +       struct i2c_msg xfer_msg[2];
> +       bool regmap_flag;
> +       bool wsa_active;
> +       int index;
> +       int version;
> +#endif
>         struct gpio_desc *sd_n;
>         /*
>          * Logical state for SD_N GPIO: high for shutdown, low for enable.
> diff --git a/sound/soc/codecs/wsa881x-i2c.c b/sound/soc/codecs/wsa881x-i2c.c
> new file mode 100644
> index 000000000000..74fa85306ad9
> --- /dev/null
> +++ b/sound/soc/codecs/wsa881x-i2c.c
> @@ -0,0 +1,1454 @@
> +// SPDX-License-Identifier: GPL-2.0-only
> +/*
> + * Copyright (c) 2015-2016, 2018-2020, The Linux Foundation. All rights reserved.
> + * Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved.
> + * Copyright (c) 2024, Linaro Limited
> + */
> +
> +#include <linux/clk.h>
> +#include <linux/clk-provider.h>
> +#include <linux/module.h>
> +#include <linux/init.h>
> +#include <linux/slab.h>
> +#include <linux/of_gpio.h>

No new users of this please. We are working on removing it.

Rob





[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [Linux for Sparc]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]

  Powered by Linux