Skip to contentSkip to conversation

ASoc: add driver for Atmel I2S controller

PATCH Superseded Cyrille Pitchen 1 participant 4 messages Sep 28, 2015 – Sep 29, 2015

Subsystems (5)

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

cover ASoc: add driver for Atmel I2S controller

This series of patches add support to the new Atmel I2S controller embedded on sama5d2 SoCs.

Cyrille Pitchen (2):
ASoC: atmel-i2s: add DT bindings for I2S controller
ASoC: atmel-i2s: add driver for the new Atmel I2S controller

 .../devicetree/bindings/sound/atmel-i2s.txt        |  43 ++
 sound/soc/atmel/Kconfig                            |  10 +
 sound/soc/atmel/Makefile                           |   2 +
 sound/soc/atmel/atmel-i2s.c                        | 760 +++++++++++++++++++++
 4 files changed, 815 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/sound/atmel-i2s.txt
 create mode 100644 sound/soc/atmel/atmel-i2s.c
Signature · 1 line
1.8.2.2
#1 lore raw

PATCH 1/2 ASoC: atmel-i2s: add DT bindings for I2S controller

This patch adds DT bindings for the new Atmel I2S controller embedded inside sama5d2x SoCs.

---
 .../devicetree/bindings/sound/atmel-i2s.txt        | 43 ++++++++++++++++++++++
 1 file changed, 43 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/sound/atmel-i2s.txt
Documentation/devicetree/bindings/sound/atmel-i2s.txt new file +43 -0
new file mode 100644
index 000000000000..83bc6b9070bf
@@ -0,0 +1,43 @@
+* Atmel I2S controller
+
+Required properties:
+- compatible:     Should be "atmel,sama5d2-i2s".
+- reg:            Should be the physical base address of the controller and the
+                  length of memory mapped region.
+- interrupts:     Should contain the interrupt for the controller.
+- dmas:           Should be a list of pairs of DMA controller phandle and flags.
+- dma-names:      Should be a list of DMA channel name among "rx", "tx" or
+                  "rx-tx".
+- clocks:         Should be a list of phandles of clocks used by the controller
+                  (1).
+- clock-names:    Should be a list matching the clocks phandles list:
+                  - "pclk" (peripheral clock) Required.
+                  - "gclk" (generated clock) Optional (1).
+                  - "aclk" (Audio PLL clock) Optional (1).
+
+Optional properties:
+- pinctrl-0:      Should specify pin control groups used for this controller.
+- princtrl-names: Should contain only one value - "default".
+
+
+(1) : Only the peripheral clock is required. The generated clock and the Audio
+      PLL clock are optional and should only be set together.
+
+Example:
+
+	i2s@f8050000 {
+		compatible = "atmel,sama5d2-i2s";
+		reg = <0xf8050000 0x300>;
+		interrupts = <54 IRQ_TYPE_LEVEL_HIGH 7>;
+		dmas = <&dma0
+			(AT91_XDMAC_DT_MEM_IF(0) | AT91_XDMAC_DT_PER_IF(1) |
+			 AT91_XDMAC_DT_PERID(31))>,
+		       <&dma0
+			(AT91_XDMAC_DT_MEM_IF(0) | AT91_XDMAC_DT_PER_IF(1) |
+			 AT91_XDMAC_DT_PERID(32))>;
+		dma-names = "tx", "rx";
+		clocks = <&i2s0_clk>, <&i2s0_gclk>, <&audio_pll_pmc>;
+		clock-names = "pclk", "gclk", "aclk";
+		pinctrl-names = "default";
+		pinctrl-0 = <&pinctrl_i2s0_default>;
+	};
Signature · 6 lines
1.8.2.2

--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#2 lore raw

PATCH 2/2 ASoC: atmel-i2s: add driver for the new Atmel I2S controller

In reply to Cyrille Pitchen

This patch adds support for the Atmel I2S controller embedded into sama5d2x SoCs.

---
 sound/soc/atmel/Kconfig     |  10 +
 sound/soc/atmel/Makefile    |   2 +
 sound/soc/atmel/atmel-i2s.c | 760 ++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 772 insertions(+)
 create mode 100644 sound/soc/atmel/atmel-i2s.c
sound/soc/atmel/Kconfig +10 -0
index 1489cd461aec..c026c207a386 100644
@@ -30,6 +30,16 @@ config SND_ATMEL_SOC_SSC
 	default y if SND_ATMEL_SOC_SSC_DMA=y || SND_ATMEL_SOC_SSC_PDC=y
 	default m if SND_ATMEL_SOC_SSC_DMA=m || SND_ATMEL_SOC_SSC_PDC=m
 
+config SND_ATMEL_SOC_I2S
+	tristate "SoC Audio support for the Atmel I2S module"
+	select SND_SOC_GENERIC_DMAENGINE_PCM
+	select REGMAP_MMIO
+	depends on OF && (ARCH_AT91 || COMPILE_TEST)
+	help
+	  Say Y or M if you want to add support for codecs attached to
+	  the Atmel I2S interface. You will also need
+	  to select the audio interfaces to support below.
+
 config SND_AT91_SOC_SAM9G20_WM8731
 	tristate "SoC Audio support for WM8731-based At91sam9g20 evaluation board"
 	depends on ARCH_AT91 || COMPILE_TEST
sound/soc/atmel/Makefile +2 -0
index b327e5cc8de3..4d960464aecb 100644
@@ -2,10 +2,12 @@
 snd-soc-atmel-pcm-pdc-objs := atmel-pcm-pdc.o
 snd-soc-atmel-pcm-dma-objs := atmel-pcm-dma.o
 snd-soc-atmel_ssc_dai-objs := atmel_ssc_dai.o
+snd-soc-atmel-i2s-objs := atmel-i2s.o
 
 obj-$(CONFIG_SND_ATMEL_SOC_PDC) += snd-soc-atmel-pcm-pdc.o
 obj-$(CONFIG_SND_ATMEL_SOC_DMA) += snd-soc-atmel-pcm-dma.o
 obj-$(CONFIG_SND_ATMEL_SOC_SSC) += snd-soc-atmel_ssc_dai.o
+obj-$(CONFIG_SND_ATMEL_SOC_I2S) += snd-soc-atmel-i2s.o
 
 # AT91 Machine Support
 snd-soc-sam9g20-wm8731-objs := sam9g20_wm8731.o
sound/soc/atmel/atmel-i2s.c new file +760 -0

760 lines not on this page · raw message

Signature · 6 lines
1.8.2.2

--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#3 lore raw

Re: [PATCH 2/2] ASoC: atmel-i2s: add driver for the new Atmel I2S controller

Le 28/09/2015 17:05, Cyrille Pitchen a écrit :
[...]

Quoted 24 lines
sound/soc/atmel/atmel-i2s.c new file +24 -0
+	/* Get audio clocks to generate the I2S Master Clock (I2S_MCK) */
+	dev->aclk = devm_clk_get(&pdev->dev, "aclk");
+	dev->gclk = devm_clk_get(&pdev->dev, "gclk");
+	if (IS_ERR(dev->aclk) && IS_ERR(dev->gclk)) {
+		/* Master Mode not supported */
+		dev->aclk = NULL;
+		dev->gclk = NULL;
+	} else if (IS_ERR(dev->gclk)) {
+		err = PTR_ERR(dev->gclk);
+		dev_err(&pdev->dev,
+			"failed to get the PMC generated clock: %d\n", err);
+		return err;
+	} else if (IS_ERR(dev->aclk)) {
+		err = PTR_ERR(dev->aclk);
+		dev_err(&pdev->dev,
+			"failed to get the PLL audio clock: %d\n", err);
+		return err;
+	}
+
+	/* Do hardware specific settings to initialize I2S_MCK generator */
+	if (dev->caps && dev->caps->mck_init) {
+		err = dev->caps->mck_init(dev, np);
+		if (err)
+			return err;

sound/soc/atmel/atmel-i2s.c line 702

Quoted 10 lines
sound/soc/atmel/atmel-i2s.c new file +10 -0
+	}
+
+	/* Enable the peripheral clock. */
+	err = clk_prepare_enable(dev->pclk);
+	if (err)
+		return err;
+
+	dev->dev = &pdev->dev;
+	dev->regmap = regmap;
+	platform_set_drvdata(pdev, dev);

those last 3 lines should be moved before calling dev->caps->mck_init(), otherwise dev->dev would not be initialized yet if dev_err() is called by atmel_i2s_sama5d2_mck_init().

Will be fixed in the next series.
[...]
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html