Skip to contentSkip to conversation

ASoC: Intel: Add KeemBay ASoC driver

PATCH Superseded Sia Jee Heng 2 participants 7 messages May 11, 2020 – May 15, 2020

Subsystems (4)

v1 of 5 Superseded Latest is v5 →

lore
Share & tools
lore
#0 lore raw

cover ASoC: Intel: Add KeemBay ASoC driver

The below series of patches support the KeemBay ASoC driver.
It enabled the tlv320aic3204 machine driver and the platform driver initialize the i2s to capture and playback the pcm data on the ARM. The i2s is running in polling mode.

There is no DSP in the KeemBay SoC. Users are rely on the Gstreamer plugin to perform some Audio preprocessing.

Sia Jee Heng (4):
ASoC: Intel: Add KeemBay platform driver
ASoC: Intel: Boards: Add KeemBay machine driver
ASoC: Intel: Add makefiles and kconfig changes for KeemBay
dt-bindings: sound: Add documentation for KeemBay sound card and i2s

 .../bindings/sound/intel,keembay-i2s.yaml          |  57 ++
 .../bindings/sound/intel,keembay-sound-card.yaml   |  30 +
 sound/soc/intel/Kconfig                            |   7 +
 sound/soc/intel/Makefile                           |   1 +
 sound/soc/intel/boards/Kconfig                     |  15 +
 sound/soc/intel/boards/Makefile                    |   4 +
 sound/soc/intel/boards/kmb_tlv3204.c               | 144 ++++
 sound/soc/intel/keembay/Makefile                   |   4 +
 sound/soc/intel/keembay/kmb_platform.c             | 746 +++++++++++++++++++++
 sound/soc/intel/keembay/kmb_platform.h             | 145 ++++
 10 files changed, 1153 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/sound/intel,keembay-i2s.yaml
 create mode 100644 Documentation/devicetree/bindings/sound/intel,keembay-sound-card.yaml
 create mode 100644 sound/soc/intel/boards/kmb_tlv3204.c
 create mode 100644 sound/soc/intel/keembay/Makefile
 create mode 100644 sound/soc/intel/keembay/kmb_platform.c
 create mode 100644 sound/soc/intel/keembay/kmb_platform.h
Signature · 1 line
1.9.1
#1 lore raw

PATCH 1/4 ASoC: Intel: Add KeemBay platform driver

Add KeemBay ASoC platform driver which initialize the i2s controller and uses i2s to capture and transmit pcm data to external codec. The i2s is running in polling mode.

---
 sound/soc/intel/keembay/Makefile       |   4 +
 sound/soc/intel/keembay/kmb_platform.c | 746 +++++++++++++++++++++++++++++++++
 sound/soc/intel/keembay/kmb_platform.h | 145 +++++++
 3 files changed, 895 insertions(+)
 create mode 100644 sound/soc/intel/keembay/Makefile
 create mode 100644 sound/soc/intel/keembay/kmb_platform.c
 create mode 100644 sound/soc/intel/keembay/kmb_platform.h
sound/soc/intel/keembay/Makefile new file +4 -0
new file mode 100644
index 0000000..9084e8c
@@ -0,0 +1,4 @@
+snd-soc-kmb_platform-objs := \
+	        kmb_platform.o
+
+obj-$(CONFIG_SND_SOC_INTEL_KEEMBAY) += snd-soc-kmb_platform.o
sound/soc/intel/keembay/kmb_platform.c new file +746 -0

746 lines not on this page · raw message

sound/soc/intel/keembay/kmb_platform.h new file +145 -0

145 lines not on this page · raw message

Signature · 1 line
1.9.1
#2 lore raw

PATCH 2/4 ASoC: Intel: Boards: Add KeemBay machine driver

In reply to Sia Jee Heng

Add KeemBay machine driver which glues the tlv320aic3204 codec driver and kmb_platform driver to form the asoc sound driver.

---
 sound/soc/intel/boards/kmb_tlv3204.c | 144 +++++++++++++++++++++++++++++++++++
 1 file changed, 144 insertions(+)
 create mode 100644 sound/soc/intel/boards/kmb_tlv3204.c
sound/soc/intel/boards/kmb_tlv3204.c new file +144 -0
new file mode 100644
index 0000000..813c291
@@ -0,0 +1,144 @@
+// SPDX-License-Identifier: GPL-2.0-only
+/*  KeemBay ASOC Machine driver
+ *
+ *  Copyright (C) 2020 Intel Corporation.
+ *
+ */
+
+#include <linux/module.h>
+#include <sound/dmaengine_pcm.h>
+#include <sound/soc.h>
+#include "../../codecs/tlv320aic32x4.h"
+
+static unsigned int channels[] = {
+	2,
+};
+
+static struct snd_pcm_hw_constraint_list constraints_ch = {
+	.count	= ARRAY_SIZE(channels),
+	.list	= channels,
+};
+
+static unsigned int rates[] = {
+	16000,
+	48000,
+};
+
+static struct snd_pcm_hw_constraint_list constraints_rates = {
+	.count	= ARRAY_SIZE(rates),
+	.list	= rates,
+};
+
+static int kmb_mach_hw_params(struct snd_pcm_substream *substream,
+			      struct snd_pcm_hw_params *params)
+{
+	struct snd_soc_pcm_runtime *rtd = substream->private_data;
+	struct snd_soc_dai *codec_dai = asoc_rtd_to_codec(rtd, 0);
+	int ret;
+	unsigned int sysclk;
+
+	/* As per codec datasheet Sysclk = 256 * fs */
+	sysclk = 12288000;
+
+	/* set the codec system clock */
+	ret = snd_soc_dai_set_sysclk(codec_dai, 1, sysclk, SND_SOC_CLOCK_IN);
+	if (ret < 0)
+		dev_err(rtd->dev, "snd_soc_dai_set_sysclk err = %d\n", ret);
+
+	return ret;
+}
+
+static int kmb_mach_dai_link_startup(struct snd_pcm_substream *substream)
+{
+	struct snd_pcm_runtime *str_runtime;
+
+	str_runtime = substream->runtime;
+
+	snd_pcm_hw_constraint_list(str_runtime, 0,
+				   SNDRV_PCM_HW_PARAM_CHANNELS,
+				   &constraints_ch);
+
+	snd_pcm_hw_constraint_list(str_runtime, 0,
+				   SNDRV_PCM_HW_PARAM_RATE,
+				   &constraints_rates);
+
+	return 0;
+}
+
+static const struct snd_soc_ops kmb_mach_dai_link_ops = {
+	.startup = kmb_mach_dai_link_startup,
+	.hw_params = kmb_mach_hw_params,
+};
+
+static const struct snd_soc_dapm_widget aic32x4_dapm_widgets[] = {
+	SND_SOC_DAPM_MIC("External Mic", NULL),
+	SND_SOC_DAPM_HP("Headphone", NULL),
+};
+
+static const struct snd_soc_dapm_route aic32x4_dapm_routes[] = {
+	{"Headphone", NULL, "HPL"},
+	{"Headphone", NULL, "HPR"},
+	{"IN3_R", NULL, "External Mic"},
+	{"IN3_L", NULL, "External Mic"},
+};
+
+/* Linking platform to the codec-drivers  */
+SND_SOC_DAILINK_DEFS(link1,
+	DAILINK_COMP_ARRAY(COMP_CPU("20140000.i2s")),
+	DAILINK_COMP_ARRAY(COMP_CODEC("tlv320aic32x4.2-0018",
+					"tlv320aic32x4-hifi")),
+	DAILINK_COMP_ARRAY(COMP_PLATFORM("20140000.i2s")));
+
+/* kmb digital audio interface glue */
+static struct snd_soc_dai_link kmb_mach_dais[] = {
+	{
+		.name		= "tlv320aic32x4",
+		.stream_name	= "TLV320AIC32X4",
+		.ops = &kmb_mach_dai_link_ops,
+		.dai_fmt = SND_SOC_DAIFMT_I2S |
+				SND_SOC_DAIFMT_NB_NF |
+				SND_SOC_DAIFMT_CBS_CFS,
+		SND_SOC_DAILINK_REG(link1),
+	},
+};
+
+/* kmb audio machine driver */
+static struct snd_soc_card kmb_mach = {
+	.name = "kmb_audio_card",
+	.dai_link = kmb_mach_dais,
+	.num_links = ARRAY_SIZE(kmb_mach_dais),
+	.dapm_routes = aic32x4_dapm_routes,
+	.num_dapm_routes = ARRAY_SIZE(aic32x4_dapm_routes),
+	.dapm_widgets = aic32x4_dapm_widgets,
+	.num_dapm_widgets =  ARRAY_SIZE(aic32x4_dapm_widgets),
+	.fully_routed = true,
+};
+
+static int kmb_mach_audio_probe(struct platform_device *pdev)
+{
+	kmb_mach.dev = &pdev->dev;
+
+	return devm_snd_soc_register_card(&pdev->dev, &kmb_mach);
+}
+
+static const struct of_device_id kmb_mach_of_match[] = {
+	{ .compatible = "intel,kmb-snd-asoc", },
+	{}
+};
+
+static struct platform_driver kmb_mach_audio = {
+	.probe = kmb_mach_audio_probe,
+	.driver = {
+		.name = "kmb_tlv3204",
+		.of_match_table = kmb_mach_of_match,
+	},
+};
+
+module_platform_driver(kmb_mach_audio)
+
+/* Module information */
+MODULE_DESCRIPTION("Intel Audio tlv3204 machine driver for KeemBay");
+MODULE_AUTHOR("Sia Jee Heng <[email protected]>");
+MODULE_AUTHOR("Sit, Michael Wei Hong <[email protected]>");
+MODULE_LICENSE("GPL v2");
+MODULE_ALIAS("platform:kmb_tlv3204");
Signature · 1 line
1.9.1
#3 lore raw

PATCH 3/4 ASoC: Intel: Add makefiles and kconfig changes for KeemBay

In reply to Sia Jee Heng

Add makefile and kconfig changes for KeemBay tlv320aic3204 machine driver and kmb_platform driver.

---
 sound/soc/intel/Kconfig         |  7 +++++++
 sound/soc/intel/Makefile        |  1 +
 sound/soc/intel/boards/Kconfig  | 15 +++++++++++++++
 sound/soc/intel/boards/Makefile |  4 ++++
 4 files changed, 27 insertions(+)
sound/soc/intel/Kconfig +7 -0
index c8de0bb..bc93448 100644
@@ -244,6 +244,13 @@ config SND_SOC_ACPI_INTEL_MATCH
 
 endif ## SND_SOC_INTEL_SST_TOPLEVEL || SND_SOC_SOF_INTEL_TOPLEVEL
 
+config SND_SOC_INTEL_KEEMBAY
+	tristate "Keembay Platforms"
+	depends on OF && (ARM64 || COMPILE_TEST)
+	depends on COMMON_CLK
+	help
+	  If you have a Intel Keembay platform then enable this option
+	  by saying Y or m.
 
 # ASoC codec drivers
 source "sound/soc/intel/boards/Kconfig"
sound/soc/intel/Makefile +1 -0
index 8160520..f5aa32b 100644
@@ -7,6 +7,7 @@ obj-$(CONFIG_SND_SOC_INTEL_HASWELL) += haswell/
 obj-$(CONFIG_SND_SOC_INTEL_BAYTRAIL) += baytrail/
 obj-$(CONFIG_SND_SST_ATOM_HIFI2_PLATFORM) += atom/
 obj-$(CONFIG_SND_SOC_INTEL_SKYLAKE) += skylake/
+obj-$(CONFIG_SND_SOC_INTEL_KEEMBAY) += keembay/
 
 # Machine support
 obj-$(CONFIG_SND_SOC) += boards/
sound/soc/intel/boards/Kconfig +15 -0
index 556c310..45f9fe5 100644
@@ -549,3 +549,18 @@ endif
 
 
 endif ## SND_SOC_INTEL_MACH
+
+if SND_SOC_INTEL_KEEMBAY
+
+config SND_SOC_INTEL_KEEMBAY_TLV320AIC3204_MACH
+	tristate "Keembay with TLV320AIC3204 codec"
+	depends on ARM64 || COMPILE_TEST
+	depends on I2C
+	select SND_SOC_TLV320AIC32X4
+	select SND_SOC_TLV320AIC32X4_I2C
+	help
+	  This adds support for ASoC machine driver for Intel Keembay platforms
+	  with TLV320AIC3204 codec.
+	  Say Y if you have such a device.
+	  If unsure select "N".
+endif ## SND_SOC_INTEL_KEEMBAY
sound/soc/intel/boards/Makefile +4 -0
index 1ef6e60..7201d07 100644
@@ -69,3 +69,7 @@ obj-$(CONFIG_SND_SOC_INTEL_SKL_NAU88L25_SSM4567_MACH) += snd-soc-skl_nau88l25_ss
 obj-$(CONFIG_SND_SOC_INTEL_SKL_HDA_DSP_GENERIC_MACH) += snd-soc-skl_hda_dsp.o
 obj-$(CONFIG_SND_SOC_INTEL_SOF_DA7219_MAX98373_MACH) += snd-soc-sof_da7219_max98373.o
 obj-$(CONFIG_SND_SOC_INTEL_SOUNDWIRE_SOF_MACH) += snd-soc-sof-sdw.o
+
+# Intel KeemBay Machine
+snd-soc-keembay_tlv3204-objs := kmb_tlv3204.o
+obj-$(CONFIG_SND_SOC_INTEL_KEEMBAY_TLV320AIC3204_MACH) += snd-soc-keembay_tlv3204.o
Signature · 1 line
1.9.1
#4 lore raw

PATCH 4/4 dt-bindings: sound: Add documentation for KeemBay sound card and i2s

In reply to Sia Jee Heng

Document Intel KeemBay sound card and i2s DT bindings.

---
 .../bindings/sound/intel,keembay-i2s.yaml          | 57 ++++++++++++++++++++++
 .../bindings/sound/intel,keembay-sound-card.yaml   | 30 ++++++++++++
 2 files changed, 87 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/sound/intel,keembay-i2s.yaml
 create mode 100644 Documentation/devicetree/bindings/sound/intel,keembay-sound-card.yaml
Documentation/devicetree/bindings/sound/intel,keembay-i2s.yaml new file +57 -0
new file mode 100644
index 0000000..737a16d
@@ -0,0 +1,57 @@
+# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause)
+# Copyright 2020 Intel Corporation
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/sound/intel,keembay-i2s.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Intel KeemBay I2S Device Tree Bindings
+
+maintainers:
+  - Sia, Jee Heng <[email protected]>
+
+description: |
+ Intel KeemBay I2S
+
+properties:
+  compatible:
+    enum:
+      - snps,designware-i2s
+
+  reg:
+    items:
+      - description: Should contain registers location and length
+
+  reg-names:
+    items:
+      - const: i2s-regs
+      - const: i2s_gen_cfg
+      - const: i2s_gen_cfg_count
+
+  interrupts:
+    maxItems: 1
+
+  clocks:
+    items:
+      - description: Bus Clock
+      - description: Module Clock
+
+  clock-names:
+    items:
+      - const: osc
+      - const: apb_clk
+
+examples:
+  - |
+     #include <dt-bindings/interrupt-controller/arm-gic.h>
+     #include <dt-bindings/interrupt-controller/irq.h>
+     #define KEEM_BAY_PSS_AUX_I2S3
+     #define KEEM_BAY_PSS_I2S3
+     i2s@20140000 {
+         compatible = "snps,designware-i2s";
+         reg = <0x0 0x20140000 0x0 0x200 0x0 0x202a00a4 0x0 0x4 0x0 0x202a00c0 0x0 0x4>;
+         reg-names = "i2s-regs", "i2s_gen_cfg", "i2s_gen_cfg_count";
+         interrupts = <GIC_SPI 120 IRQ_TYPE_LEVEL_HIGH>;
+         clock-names = "osc", "apb_clk";
+         clocks = <&scmi_clk KEEM_BAY_PSS_AUX_I2S3>, <&scmi_clk KEEM_BAY_PSS_I2S3>;
+     };
Documentation/devicetree/bindings/sound/intel,keembay-sound-card.yaml new file +30 -0
new file mode 100644
index 0000000..cca413a9
@@ -0,0 +1,30 @@
+# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause)
+# Copyright 2020 Intel Corporation
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/sound/intel,keembay-sound-card.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Intel KeemBay Sound Card
+
+maintainers:
+  - Sia, Jee Heng <[email protected]>
+
+description: |
+ Intel KeemBay Sound Card DT Binding
+
+properties:
+  compatible:
+    enum:
+      - intel,kmb-snd-asoc
+
+  intel,pcm-audio:
+    $ref: /schemas/types.yaml#/definitions/phandle
+    description: phandle of the i2s
+
+examples:
+ - |
+    sound {
+      compatible = "intel,kmb-snd-asoc";
+      intel,pcm-audio = <&i2s3>;
+    };
Signature · 1 line
1.9.1
maintainer
#5 lore raw

Re: [PATCH 4/4] dt-bindings: sound: Add documentation for KeemBay sound card and i2s

Documentation/devicetree/bindings/sound/intel,keembay-i2s.yaml line 19

Quoted 7 lines · Sia Jee Heng
Documentation/devicetree/bindings/sound/intel,keembay-i2s.yaml new file +7 -0
+description: |
+ Intel KeemBay I2S
+
+properties:
+  compatible:
+    enum:
+      - snps,designware-i2s

If this is the DesignWare I2S controller we already have a driver for that with existing DT bindings, anything that needs to be added should be added to that. We can't have multiple sets of bindings for the same device.

#6 lore raw

RE: [PATCH 4/4] dt-bindings: sound: Add documentation for KeemBay sound card and i2s

-----Original Message-----
From: Mark Brown <[email protected]>
Sent: Monday, May 11, 2020 7:34 PM
To: Sia, Jee Heng <[email protected]>
Cc: [email protected]; [email protected]; [email protected]; [email protected]
Subject: Re: [PATCH 4/4] dt-bindings: sound: Add documentation for KeemBay sound card and i2s

Documentation/devicetree/bindings/sound/intel,keembay-i2s.yaml line 19

Quoted 7 lines · Sia Jee Heng
Documentation/devicetree/bindings/sound/intel,keembay-i2s.yaml new file +7 -0
+description: |
+ Intel KeemBay I2S
+
+properties:
+  compatible:
+    enum:
+      - snps,designware-i2s

If this is the DesignWare I2S controller we already have a driver for that with existing DT bindings, anything that needs to be added should be added to that. We can't have multiple sets of bindings for the same device. [>>] Sorry for the confusion, I meant intel,keembay-i2s. Shall submit the fix.