Re: [PATCH 3/7] ASoC: codecs: wcd938x: add basic driver

2021-03-15 Thread Srinivas Kandagatla




On 12/03/2021 15:34, Mark Brown wrote:

On Thu, Mar 11, 2021 at 05:34:12PM +, Srinivas Kandagatla wrote:


+static int wcd9380_update_status(struct sdw_slave *slave,
+enum sdw_slave_status status)
+{
+   return 0;
+}
+
+static int wcd9380_port_prep(struct sdw_slave *slave,
+struct sdw_prepare_ch *prepare_ch,
+enum sdw_port_prep_ops state)
+{
+   return 0;
+}


If these can legitimately be empty I'd expect the framework to support
them being omitted.


One of them is not mandatory, I will revisit this before sending out 
next version.


thanks,
srini




Re: [PATCH 3/7] ASoC: codecs: wcd938x: add basic driver

2021-03-12 Thread Mark Brown
On Thu, Mar 11, 2021 at 05:34:12PM +, Srinivas Kandagatla wrote:

> +static int wcd9380_update_status(struct sdw_slave *slave,
> +  enum sdw_slave_status status)
> +{
> + return 0;
> +}
> +
> +static int wcd9380_port_prep(struct sdw_slave *slave,
> +  struct sdw_prepare_ch *prepare_ch,
> +  enum sdw_port_prep_ops state)
> +{
> + return 0;
> +}

If these can legitimately be empty I'd expect the framework to support
them being omitted.


signature.asc
Description: PGP signature


[PATCH 3/7] ASoC: codecs: wcd938x: add basic driver

2021-03-11 Thread Srinivas Kandagatla
This patch adds basic SoundWire codec driver to support for
WCD938X TX and RX devices.

Signed-off-by: Srinivas Kandagatla 
---
 sound/soc/codecs/Kconfig   |9 +
 sound/soc/codecs/Makefile  |2 +
 sound/soc/codecs/wcd938x-sdw.c |  294 ++
 sound/soc/codecs/wcd938x.c | 1618 
 sound/soc/codecs/wcd938x.h |  675 +
 5 files changed, 2598 insertions(+)
 create mode 100644 sound/soc/codecs/wcd938x-sdw.c
 create mode 100644 sound/soc/codecs/wcd938x.c
 create mode 100644 sound/soc/codecs/wcd938x.h

diff --git a/sound/soc/codecs/Kconfig b/sound/soc/codecs/Kconfig
index 6ce74c99a305..1c35cb21b61e 100644
--- a/sound/soc/codecs/Kconfig
+++ b/sound/soc/codecs/Kconfig
@@ -230,6 +230,7 @@ config SND_SOC_ALL_CODECS
imply SND_SOC_UDA1380
imply SND_SOC_WCD9335
imply SND_SOC_WCD934X
+   imply SND_SOC_WCD938X
imply SND_SOC_LPASS_RX_MACRO
imply SND_SOC_LPASS_TX_MACRO
imply SND_SOC_WL1273
@@ -1514,6 +1515,14 @@ config SND_SOC_WCD934X
  The WCD9340/9341 is a audio codec IC Integrated in
  Qualcomm SoCs like SDM845.
 
+config SND_SOC_WCD938X
+   tristate "WCD9380/WCD9385 Codec"
+   depends on SOUNDWIRE
+   select REGMAP_SOUNDWIRE
+   help
+ The WCD9380/9385 is a audio codec IC Integrated in
+ Qualcomm SoCs like SM8250.
+
 config SND_SOC_WL1273
tristate
 
diff --git a/sound/soc/codecs/Makefile b/sound/soc/codecs/Makefile
index dcc2f757bb82..287fe6b1a3d2 100644
--- a/sound/soc/codecs/Makefile
+++ b/sound/soc/codecs/Makefile
@@ -248,6 +248,7 @@ snd-soc-uda134x-objs := uda134x.o
 snd-soc-uda1380-objs := uda1380.o
 snd-soc-wcd9335-objs := wcd-clsh-v2.o wcd9335.o
 snd-soc-wcd934x-objs := wcd-clsh-v2.o wcd934x.o
+snd-soc-wcd938x-objs := wcd938x.o wcd938x-sdw.o wcd-clsh-v2.o wcd938x-sdw.o
 snd-soc-wl1273-objs := wl1273.o
 snd-soc-wm-adsp-objs := wm_adsp.o
 snd-soc-wm0010-objs := wm0010.o
@@ -566,6 +567,7 @@ obj-$(CONFIG_SND_SOC_UDA134X)   += snd-soc-uda134x.o
 obj-$(CONFIG_SND_SOC_UDA1380)  += snd-soc-uda1380.o
 obj-$(CONFIG_SND_SOC_WCD9335)  += snd-soc-wcd9335.o
 obj-$(CONFIG_SND_SOC_WCD934X)  += snd-soc-wcd934x.o
+obj-$(CONFIG_SND_SOC_WCD938X)  += snd-soc-wcd938x.o
 obj-$(CONFIG_SND_SOC_WL1273)   += snd-soc-wl1273.o
 obj-$(CONFIG_SND_SOC_WM0010)   += snd-soc-wm0010.o
 obj-$(CONFIG_SND_SOC_WM1250_EV1) += snd-soc-wm1250-ev1.o
diff --git a/sound/soc/codecs/wcd938x-sdw.c b/sound/soc/codecs/wcd938x-sdw.c
new file mode 100644
index ..3ebfcc1a1a49
--- /dev/null
+++ b/sound/soc/codecs/wcd938x-sdw.c
@@ -0,0 +1,294 @@
+// SPDX-License-Identifier: GPL-2.0
+// Copyright (c) 2021, Linaro Limited
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include "wcd938x.h"
+
+#define WCD938X_RATES_MASK (SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_16000 |\
+   SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_48000 |\
+   SNDRV_PCM_RATE_96000 | SNDRV_PCM_RATE_192000)
+/* Fractional Rates */
+#define WCD938X_FRAC_RATES_MASK (SNDRV_PCM_RATE_44100 | SNDRV_PCM_RATE_88200 |\
+SNDRV_PCM_RATE_176400)
+#define WCD938X_FORMATS_S16_S24_LE (SNDRV_PCM_FMTBIT_S16_LE | \
+   SNDRV_PCM_FMTBIT_S24_LE)
+#define SWRS_SCP_HOST_CLK_DIV2_CTL_BANK(m) (0xE0 + 0x10 * (m))
+
+static struct wcd938x_sdw_ch_info wcd938x_sdw_rx_ch_info[] = {
+   WCD_SDW_CH(WCD938X_HPH_L, WCD938X_HPH_PORT, BIT(0)),
+   WCD_SDW_CH(WCD938X_HPH_R, WCD938X_HPH_PORT, BIT(1)),
+   WCD_SDW_CH(WCD938X_CLSH, WCD938X_CLSH_PORT, BIT(0)),
+   WCD_SDW_CH(WCD938X_COMP_L, WCD938X_COMP_PORT, BIT(0)),
+   WCD_SDW_CH(WCD938X_COMP_R, WCD938X_COMP_PORT, BIT(1)),
+   WCD_SDW_CH(WCD938X_LO, WCD938X_LO_PORT, BIT(0)),
+   WCD_SDW_CH(WCD938X_DSD_L, WCD938X_DSD_PORT, BIT(0)),
+   WCD_SDW_CH(WCD938X_DSD_R, WCD938X_DSD_PORT, BIT(1)),
+};
+
+static struct wcd938x_sdw_ch_info wcd938x_sdw_tx_ch_info[] = {
+   WCD_SDW_CH(WCD938X_ADC1, WCD938X_ADC_1_2_PORT, BIT(0)),
+   WCD_SDW_CH(WCD938X_ADC2, WCD938X_ADC_1_2_PORT, BIT(1)),
+   WCD_SDW_CH(WCD938X_ADC3, WCD938X_ADC_3_4_PORT, BIT(0)),
+   WCD_SDW_CH(WCD938X_ADC4, WCD938X_ADC_3_4_PORT, BIT(1)),
+   WCD_SDW_CH(WCD938X_DMIC0, WCD938X_DMIC_0_3_MBHC_PORT, BIT(0)),
+   WCD_SDW_CH(WCD938X_DMIC1, WCD938X_DMIC_0_3_MBHC_PORT, BIT(1)),
+   WCD_SDW_CH(WCD938X_MBHC, WCD938X_DMIC_0_3_MBHC_PORT, BIT(2)),
+   WCD_SDW_CH(WCD938X_DMIC2, WCD938X_DMIC_0_3_MBHC_PORT, BIT(2)),
+   WCD_SDW_CH(WCD938X_DMIC3, WCD938X_DMIC_0_3_MBHC_PORT, BIT(3)),
+   WCD_SDW_CH(WCD938X_DMIC4, WCD938X_DMIC_4_7_PORT, BIT(0)),
+   WCD_SDW_CH(WCD938X_DMIC5, WCD938X_DMIC_4_7_PORT, BIT(1)),
+   WCD_SDW_CH(WCD938X_DMIC6, WCD938X_DMIC_4_7_PORT, BIT(2)),
+   WCD_SDW_CH(WCD938X_DMIC7, WCD938X_DMIC_4_7_PORT, BIT(3)),
+};
+