Skip to contentSkip to conversation

ASoC: Mediatek: Add support for MT8173 SOC

RFC PATCH New Koro Chen 1 participant 3 messages Apr 10, 2015

Subsystems (4)
lore
Share & tools
lore

Koro Chen

author
#0 lore raw

This adds basic support for the Mediatek AFE unit for MT8173 SoC. This patch is based on Linux 4.0-rc1, Sascha's clk patch [1], and his SCPSYS power patch [2].

The AFE unit comprises several memory interfaces that communicate with CPU, a multi input multi output digital audio interconnect, and several external interfaces (e.g. I2S).

The AFE unit is a DMA master, so no external DMA engine is needed.

Each external interface is presented as a DAI to ASoC. A memory interface must be connected via the interconnect to an external interface. The connection pathes are configured through the device tree.

[1] http://lists.infradead.org/pipermail/linux-mediatek/2015-March/000079.html
[2] http://lists.infradead.org/pipermail/linux-mediatek/2015-March/000132.html

Koro Chen (2):
ASoC: mediatek: Add binding support for AFE driver
ASoC: mediatek: Add AFE platform driver

 .../devicetree/bindings/sound/mtk-afe-pcm.txt      |  105 ++
 include/dt-bindings/sound/mtk-afe.h                |   36 +
 sound/soc/Kconfig                                  |    1 +
 sound/soc/Makefile                                 |    1 +
 sound/soc/mediatek/Kconfig                         |    8 +
 sound/soc/mediatek/Makefile                        |    2 +
 sound/soc/mediatek/mtk-afe-common.h                |  105 ++
 sound/soc/mediatek/mtk-afe-connection.c            |  416 ++++++
 sound/soc/mediatek/mtk-afe-connection.h            |   30 +
 sound/soc/mediatek/mtk-afe-pcm.c                   | 1497 ++++++++++++++++++++
 10 files changed, 2201 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/sound/mtk-afe-pcm.txt
 create mode 100644 include/dt-bindings/sound/mtk-afe.h
 create mode 100644 sound/soc/mediatek/Kconfig
 create mode 100644 sound/soc/mediatek/Makefile
 create mode 100644 sound/soc/mediatek/mtk-afe-common.h
 create mode 100644 sound/soc/mediatek/mtk-afe-connection.c
 create mode 100644 sound/soc/mediatek/mtk-afe-connection.h
 create mode 100644 sound/soc/mediatek/mtk-afe-pcm.c

--

author
#1 lore raw

RFC PATCH 1/2 ASoC: mediatek: Add binding support for AFE driver

Add documentation and header file to support binding of Mediatek's AFE driver

---
 .../devicetree/bindings/sound/mtk-afe-pcm.txt      | 105 +++++++++++++++++++++
 include/dt-bindings/sound/mtk-afe.h                |  36 +++++++
 2 files changed, 141 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/sound/mtk-afe-pcm.txt
 create mode 100644 include/dt-bindings/sound/mtk-afe.h
Documentation/devicetree/bindings/sound/mtk-afe-pcm.txt new file +105 -0
new file mode 100644
index 0000000..5a89090
@@ -0,0 +1,105 @@
+Mediatek AFE PCM controller
+
+The AFE unit can be illustrated by this figure:
+
+| MEMIF    |      AFE      |     IO     |
+           *****************
+DL1------> *I5           O3* <----I2S--->
+           *I6           O4*
+           *             I3*
+           *             I4*
+           *             O0* <--2ndI2S-->
+           *             O1*
+           *             I0*
+           *             I1*
+AWB<------ *O5             * <--MTKIF--->
+           *O6             *
+VUL<------ *O9             * <---HDMI--->
+           *O10            *
+           *      AFE      *
+HDMI-----> * inter-connect *
+           *****************
+AFE comprises several memory interfaces (DL1, DL2, VUL, DAI, AWB, MOD_DAI
+and HDMI) that communicate with CPU, a multi input multi output digital audio
+interconnect, and several external interfaces (I2S, proprietary MTKIF, HDMI).
+Each external interface (called "IO" in this driver) is presented as a
+DAI to ASoC. An IO must be connected via the interconnect to a memif.
+The connection pathes are configured through the device tree.
+
+Required properties:
+- compatible = "mediatek,mt8173-afe-pcm";
+- reg: array of register and sram location and size:
+       <register base address, size>,
+       <sram base address, size>;
+- interrupts: Should contain AFE interrupt
+- clock-names: should have these clock names:
+		"infra_sys_audio_clk",
+		"top_pdn_audio",
+		"top_pdn_aud_intbus",
+		"bck0",
+		"bck1",
+		"i2s0_m",
+		"i2s1_m",
+		"i2s2_m",
+		"i2s3_m",
+		"i2s3_b";
+
+DAI subnodes:
+  A DAI subnode describes which io connects to which memif.
+
+Required subnode properties:
+- io: which I/O to be used
+      (defined in include/dt-bindings/sound/mtk-afe.h)
+- connections: AFE connection pairs definition of this dai
+	       For example, <5 3 6 4> means I5->O3, I6->O4
+	       check SoC datasheet for a complete description
+- mem-interface-playback:
+  mem-interface-capture: property of memif, format is: <memif irq use_sram>;
+	                 memif: which memif to be used
+			        (defined in include/dt-bindings/sound/mtk-afe.h)
+		         irq: which irq to be used
+			      (defined in include/dt-bindings/sound/mtk-afe.h)
+		         use_sram: 1 is yes, 0 is no
+
+  Each DAI should describes at least playback or capture
+
+Example:
+
+	afe: mt8173-afe-pcm@11220000  {
+		compatible = "mediatek,mt8173-afe-pcm";
+		reg = <0 0x11220000 0 0x1000>,
+		      <0 0x11221000 0 0x9000>;
+		interrupts = <GIC_SPI 134 IRQ_TYPE_EDGE_FALLING>;
+		clocks = <&infracfg INFRA_AUDIO>,
+			<&topckgen TOP_AUDIO_SEL>,
+			<&topckgen TOP_AUD_INTBUS_SEL>,
+			<&topckgen TOP_APLL1_DIV0>,
+			<&topckgen TOP_APLL2_DIV0>,
+			<&topckgen TOP_I2S0_M_CK_SEL>,
+			<&topckgen TOP_I2S1_M_CK_SEL>,
+			<&topckgen TOP_I2S2_M_CK_SEL>,
+			<&topckgen TOP_I2S3_M_CK_SEL>,
+			<&topckgen TOP_I2S3_B_CK_SEL>;
+		clock-names = "infra_sys_audio_clk",
+				"top_pdn_audio",
+				"top_pdn_aud_intbus",
+				"bck0",
+				"bck1",
+				"i2s0_m",
+				"i2s1_m",
+				"i2s2_m",
+				"i2s3_m",
+				"i2s3_b";
+		dai@0 {
+			io = <MTK_AFE_IO_I2S>;
+			connections = <5 3 6 4 3 9 4 10>;
+			mem-interface-playback = <MTK_AFE_MEMIF_DL1 MTK_AFE_IRQ_1 1>;
+			mem-interface-capture = <MTK_AFE_MEMIF_VUL MTK_AFE_IRQ_2 0>;
+		};
+
+		dai@1 {
+			io = <MTK_AFE_IO_HDMI>;
+			connections = <36 36 37 37 34 32 35 33 32 34 33 35 30 30 31 31>;
+			mem-interface-playback = <MTK_AFE_MEMIF_HDMI MTK_AFE_IRQ_5 0>;
+		};
+	};
include/dt-bindings/sound/mtk-afe.h new file +36 -0
new file mode 100644
index 0000000..e6da18e
@@ -0,0 +1,36 @@
+#ifndef __DT_MTK_AFE_H
+#define __DT_MTK_AFE_H
+
+#define MTK_AFE_MEMIF_DL1		0
+#define MTK_AFE_MEMIF_DL2		1
+#define MTK_AFE_MEMIF_VUL		2
+#define MTK_AFE_MEMIF_DAI		3
+#define MTK_AFE_MEMIF_AWB		4
+#define MTK_AFE_MEMIF_MOD_DAI		5
+#define MTK_AFE_MEMIF_HDMI		6
+#define MTK_AFE_MEMIF_NUM		7
+
+#define MTK_AFE_IO_MOD_PCM1		0 /* connection to int main modem */
+#define MTK_AFE_IO_MOD_PCM2		1 /* connection to extrt/int modem */
+#define MTK_AFE_IO_PMIC		2 /* MTKIF for DAC and ADC */
+#define MTK_AFE_IO_I2S			3 /* I2S */
+#define MTK_AFE_IO_2ND_I2S		4 /* 2nd I2S */
+#define MTK_AFE_IO_HW_GAIN1		5 /* HW gain control */
+#define MTK_AFE_IO_HW_GAIN2		6
+#define MTK_AFE_IO_MRG_O		7 /* merge interface */
+#define MTK_AFE_IO_MRG_I		8
+#define MTK_AFE_IO_DAIBT		9
+#define MTK_AFE_IO_HDMI		10
+#define MTK_AFE_IO_NUM			11
+
+#define MTK_AFE_IRQ_1			0
+#define MTK_AFE_IRQ_2			1
+#define MTK_AFE_IRQ_3			2
+#define MTK_AFE_IRQ_4			3
+#define MTK_AFE_IRQ_5			4
+#define MTK_AFE_IRQ_6			5
+#define MTK_AFE_IRQ_7			6
+#define MTK_AFE_IRQ_8			7
+#define MTK_AFE_IRQ_NUM			8
+
+#endif /* __DT_MTK_AFE_H */
Signature · 1 line
1.8.1.1.dirty
author
#2 lore raw

RFC PATCH 2/2 ASoC: mediatek: Add AFE platform driver

In reply to Koro Chen

This includes platform driver of Mediatek's AFE (Audio Front End) unit and AFE connection control APIs.

---
 sound/soc/Kconfig                       |    1 +
 sound/soc/Makefile                      |    1 +
 sound/soc/mediatek/Kconfig              |    8 +
 sound/soc/mediatek/Makefile             |    2 +
 sound/soc/mediatek/mtk-afe-common.h     |  105 +++
 sound/soc/mediatek/mtk-afe-connection.c |  416 +++++++++
 sound/soc/mediatek/mtk-afe-connection.h |   30 +
 sound/soc/mediatek/mtk-afe-pcm.c        | 1497 +++++++++++++++++++++++++++++++
 8 files changed, 2060 insertions(+)
 create mode 100644 sound/soc/mediatek/Kconfig
 create mode 100644 sound/soc/mediatek/Makefile
 create mode 100644 sound/soc/mediatek/mtk-afe-common.h
 create mode 100644 sound/soc/mediatek/mtk-afe-connection.c
 create mode 100644 sound/soc/mediatek/mtk-afe-connection.h
 create mode 100644 sound/soc/mediatek/mtk-afe-pcm.c
sound/soc/Kconfig +1 -0
index dcc79aa..c022374 100644
@@ -45,6 +45,7 @@ source "sound/soc/nuc900/Kconfig"
 source "sound/soc/omap/Kconfig"
 source "sound/soc/kirkwood/Kconfig"
 source "sound/soc/intel/Kconfig"
+source "sound/soc/mediatek/Kconfig"
 source "sound/soc/mxs/Kconfig"
 source "sound/soc/pxa/Kconfig"
 source "sound/soc/rockchip/Kconfig"
sound/soc/Makefile +1 -0
index 5b3c8f6..6f69f01d 100644
@@ -23,6 +23,7 @@ obj-$(CONFIG_SND_SOC)	+= dwc/
 obj-$(CONFIG_SND_SOC)	+= fsl/
 obj-$(CONFIG_SND_SOC)	+= jz4740/
 obj-$(CONFIG_SND_SOC)	+= intel/
+obj-$(CONFIG_SND_SOC)	+= mediatek/
 obj-$(CONFIG_SND_SOC)	+= mxs/
 obj-$(CONFIG_SND_SOC)	+= nuc900/
 obj-$(CONFIG_SND_SOC)	+= omap/
sound/soc/mediatek/Kconfig new file +8 -0
new file mode 100644
index 0000000..7d97cf1
@@ -0,0 +1,8 @@
+config SND_SOC_MEDIATEK
+	bool "ASoC support for Mediatek chip"
+	depends on ARCH_MEDIATEK
+	help
+	  This adds ASoC platform driver support for Mediatek chip
+	  that can be used with other codecs.
+	  Select Y if you have such device.
+	  Ex: MT8173
sound/soc/mediatek/Makefile new file +2 -0
new file mode 100644
index 0000000..12003bb
@@ -0,0 +1,2 @@
+# MTK Platform Support
+obj-$(CONFIG_SND_SOC_MEDIATEK) += mtk-afe-connection.o mtk-afe-pcm.o
sound/soc/mediatek/mtk-afe-common.h new file +105 -0

105 lines not on this page · raw message

sound/soc/mediatek/mtk-afe-connection.c new file +416 -0

416 lines not on this page · raw message

sound/soc/mediatek/mtk-afe-connection.h new file +30 -0
new file mode 100644
index 0000000..eac2555
@@ -0,0 +1,30 @@
+/*
+ * mtk_afe_connection.h  --  Mediatek AFE connection support
+ *
+ * Copyright (c) 2015 MediaTek Inc.
+ * Author: Koro Chen <[email protected]>
+ *             Sascha Hauer <[email protected]>
+ *             Hidalgo Huang <[email protected]>
+ *             Ir Lian <[email protected]>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 and
+ * only version 2 as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ */
+
+#ifndef _MTK_AFE_CONNECTION_H_
+#define _MTK_AFE_CONNECTION_H_
+
+struct mtk_afe;
+
+int mtk_afe_interconn_connect(struct mtk_afe *afe_info, unsigned int in,
+			      unsigned int out, bool rightshift);
+int mtk_afe_interconn_disconnect(struct mtk_afe *afe_info, unsigned int in,
+				 unsigned int out);
+
+#endif
sound/soc/mediatek/mtk-afe-pcm.c new file +1497 -0

1,497 lines not on this page · raw message

Signature · 1 line
1.8.1.1.dirty