Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1495335

[PATCH 07/14] ASoC: Add sun8i audio card

From Mylène Josserand <mylene.josserand@free-electrons.com>
Newsgroups linux.kernel
Subject [PATCH 07/14] ASoC: Add sun8i audio card
Date 2016-10-04 12:00 +0200
Message-ID <souFY-W7-13@gated-at.bofh.it> (permalink)
References <souwh-SP-1@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


Add the audio card for sun8i SoC. This card links the codec driver
(digital part) with the DAI driver. The analog codec driver is
added as an aux_device.

Signed-off-by: Mylène Josserand <mylene.josserand@free-electrons.com>
---
 sound/soc/sunxi/Kconfig  |  14 +++++++
 sound/soc/sunxi/Makefile |   1 +
 sound/soc/sunxi/sun8i.c  | 101 +++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 116 insertions(+)
 create mode 100644 sound/soc/sunxi/sun8i.c

diff --git a/sound/soc/sunxi/Kconfig b/sound/soc/sunxi/Kconfig
index 9e287b0..7b97395 100644
--- a/sound/soc/sunxi/Kconfig
+++ b/sound/soc/sunxi/Kconfig
@@ -27,6 +27,20 @@ config SND_SUN4I_SPDIF
 	  Say Y or M to add support for the S/PDIF audio block in the Allwinner
 	  A10 and affiliated SoCs.
 
+config SND_SUN8I
+	tristate "Allwinner SUN6I/SUN8I audio card support"
+	select SND_SUN8I_CODEC
+	select SND_SUN4I_I2S
+	select SND_SUN8I_CODEC_ANALOG
+	select REGMAP_MMIO
+	help
+	  This option enables the audio card for Allwinner A33 (sun8i) SoC.
+	  It enables the DAI driver (SND_SUN4I_I2S), the digital audio
+	  codec driver (SND_SUN8I_CODEC) and the analog codec driver
+	  (SND_SUN8I_CODEC_ANALOG).
+
+	  Say Y or M if you want to add sun8i/6i card support
+
 config SND_SUN8I_CODEC
 	tristate "Allwinner SUN8I audio codec"
 	select REGMAP_MMIO
diff --git a/sound/soc/sunxi/Makefile b/sound/soc/sunxi/Makefile
index 1da63d3..7f1bab9 100644
--- a/sound/soc/sunxi/Makefile
+++ b/sound/soc/sunxi/Makefile
@@ -1,5 +1,6 @@
 obj-$(CONFIG_SND_SUN4I_CODEC) += sun4i-codec.o
 obj-$(CONFIG_SND_SUN4I_I2S) += sun4i-i2s.o
 obj-$(CONFIG_SND_SUN4I_SPDIF) += sun4i-spdif.o
+obj-$(CONFIG_SND_SUN8I) += sun8i.o
 obj-$(CONFIG_SND_SUN8I_CODEC) += sun8i-codec.o
 obj-$(CONFIG_SND_SUN8I_CODEC_ANALOG) += sun8i-codec-analog.o
diff --git a/sound/soc/sunxi/sun8i.c b/sound/soc/sunxi/sun8i.c
new file mode 100644
index 0000000..565cd88
--- /dev/null
+++ b/sound/soc/sunxi/sun8i.c
@@ -0,0 +1,101 @@
+/*
+ * ALSA SoC driver for Allwinner sun8i SoC
+ *
+ * Copyright (C) 2016 Mylène Josserand <mylene.josserand@free-electrons.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * 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.
+ */
+
+#include <linux/firmware.h>
+#include <linux/module.h>
+
+#include <sound/soc.h>
+
+static struct snd_soc_aux_dev sun8i_audio_prcm_aux_devs[] = {
+	{
+		.name = "sun8i-codec-analog",
+		.codec_name = "sun8i-codec-analog.0",
+	},
+};
+
+static struct snd_soc_dai_link sun8i_dai_link = {
+	.name           = "sun4i-i2s",
+	.stream_name    = "Playback",
+	.codec_dai_name = "sun8i",
+	.dai_fmt        = SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_I2S |
+			SND_SOC_DAIFMT_CBM_CFM,
+};
+
+static struct snd_soc_card sun8i_card = {
+	.name           = "sun8i-card",
+	.owner          = THIS_MODULE,
+	.dai_link       = &sun8i_dai_link,
+	.num_links      = 1,
+	.aux_dev	= sun8i_audio_prcm_aux_devs,
+	.num_aux_devs	= ARRAY_SIZE(sun8i_audio_prcm_aux_devs),
+};
+
+static int sun8i_probe(struct platform_device *pdev)
+{
+	struct snd_soc_dai_link *link = &sun8i_dai_link;
+	struct device_node *np = pdev->dev.of_node;
+	int ret;
+
+	/* register the soc card */
+	sun8i_card.dev = &pdev->dev;
+
+	/* Retrieve the audio-codec from DT */
+	link->codec_of_node = of_parse_phandle(np, "allwinner,audio-codec", 0);
+	if (!link->codec_of_node) {
+		dev_err(&pdev->dev, "Missing audio codec\n");
+		return -EINVAL;
+	}
+
+	/* Retrieve DAI from DT */
+	link->cpu_of_node = of_parse_phandle(np, "allwinner,i2s-controller", 0);
+	if (!link->cpu_of_node) {
+		dev_err(&pdev->dev, "Missing I2S controller\n");
+		return -EINVAL;
+	}
+
+	link->platform_of_node = link->cpu_of_node;
+
+	/* Register the sound card */
+	ret = devm_snd_soc_register_card(&pdev->dev, &sun8i_card);
+	if (ret) {
+		dev_err(&pdev->dev,
+			"Soc register card failed %d\n", ret);
+		return ret;
+	}
+
+	return ret;
+}
+
+static const struct of_device_id sun8i_of_match[] = {
+	{ .compatible = "allwinner,sun8i-audio", },
+	{},
+};
+
+MODULE_DEVICE_TABLE(of, sun8i_of_match);
+
+static struct platform_driver sun8i_card_driver = {
+	.probe = sun8i_probe,
+	.driver = {
+		.name   = "sun8i-audio",
+		.of_match_table = sun8i_of_match,
+	},
+};
+
+module_platform_driver(sun8i_card_driver);
+
+MODULE_AUTHOR("Mylène Josserand <mylene.josserand@free-electrons.com>");
+MODULE_DESCRIPTION("Allwinner sun8i machine ASoC driver");
+MODULE_LICENSE("GPL v2");
-- 
2.9.3

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH 00/14] ASoc: sunxi: Add Allwinner A33 codec driver Mylène Josserand          <mylene.josserand@free-electrons.com> - 2016-10-04 11:50 +0200
  [PATCH 08/14] dt-bindings: sound: Add sun8i analog codec documentation Mylène Josserand          <mylene.josserand@free-electrons.com> - 2016-10-04 11:50 +0200
    Re: [PATCH 08/14] dt-bindings: sound: Add sun8i analog codec  documentation Mark Brown <broonie@kernel.org> - 2016-10-04 12:40 +0200
    Re: [PATCH 08/14] dt-bindings: sound: Add sun8i analog codec  documentation Maxime Ripard <maxime.ripard@free-electrons.com> - 2016-10-04 18:30 +0200
      Re: [PATCH 08/14] dt-bindings: sound: Add sun8i analog codec documentation Chen-Yu Tsai <wens@csie.org> - 2016-10-05 05:10 +0200
        Re: [PATCH 08/14] dt-bindings: sound: Add sun8i analog codec  documentation Mylene Josserand <mylene.josserand@free-electrons.com> - 2016-10-05 14:10 +0200
  [PATCH 11/14] ARM: dts: sun8i: Add analog codec on prcm node Mylène Josserand          <mylene.josserand@free-electrons.com> - 2016-10-04 11:50 +0200
  [PATCH 01/14] dma: sun6i-dma: Add burst case of 4 Mylène Josserand          <mylene.josserand@free-electrons.com> - 2016-10-04 11:50 +0200
    Re: [PATCH 01/14] dma: sun6i-dma: Add burst case of 4 Jean-Francois Moine <moinejf@free.fr> - 2016-10-04 12:50 +0200
      Re: [PATCH 01/14] dma: sun6i-dma: Add burst case of 4 Thomas Petazzoni <thomas.petazzoni@free-electrons.com> - 2016-10-04 14:20 +0200
        Re: [PATCH 01/14] dma: sun6i-dma: Add burst case of 4 Jean-Francois Moine <moinejf@free.fr> - 2016-10-04 15:50 +0200
          Re: [PATCH 01/14] dma: sun6i-dma: Add burst case of 4 Vinod Koul <vinod.koul@intel.com> - 2016-10-04 17:40 +0200
      Re: [PATCH 01/14] dma: sun6i-dma: Add burst case of 4 Maxime Ripard <maxime.ripard@free-electrons.com> - 2016-10-04 19:00 +0200
  [PATCH 13/14] ARM: dts: sun8i: parrot: Enable audio nodes Mylène Josserand          <mylene.josserand@free-electrons.com> - 2016-10-04 11:50 +0200
  [PATCH 10/14] dt-bindings: sound: Add sun8i audio card documentation Mylène Josserand          <mylene.josserand@free-electrons.com> - 2016-10-04 11:50 +0200
    Re: [PATCH 10/14] dt-bindings: sound: Add sun8i audio card  documentation Maxime Ripard <maxime.ripard@free-electrons.com> - 2016-10-04 18:40 +0200
  [PATCH 12/14] ARM: dts: sun8i: Add audio codec, dai and card for A33 Mylène Josserand          <mylene.josserand@free-electrons.com> - 2016-10-04 11:50 +0200
  [PATCH 03/14] ASoC: sun4i-i2s: Add apb reset Mylène Josserand          <mylene.josserand@free-electrons.com> - 2016-10-04 11:50 +0200
    Re: [PATCH 03/14] ASoC: sun4i-i2s: Add apb reset Thomas Petazzoni <thomas.petazzoni@free-electrons.com> - 2016-10-04 14:20 +0200
      Re: [PATCH 03/14] ASoC: sun4i-i2s: Add apb reset Maxime Ripard <maxime.ripard@free-electrons.com> - 2016-10-04 17:50 +0200
        Re: [PATCH 03/14] ASoC: sun4i-i2s: Add apb reset Mylene Josserand <mylene.josserand@free-electrons.com> - 2016-10-05 11:50 +0200
    Re: [PATCH 03/14] ASoC: sun4i-i2s: Add apb reset Code Kipper <codekipper@gmail.com> - 2016-10-04 14:30 +0200
  [PATCH 02/14] clk: ccu-sun8i-a33: Add CLK_SET_RATE_PARENT to ac-dig Mylène Josserand          <mylene.josserand@free-electrons.com> - 2016-10-04 12:00 +0200
    Re: [PATCH 02/14] clk: ccu-sun8i-a33: Add CLK_SET_RATE_PARENT to  ac-dig Thomas Petazzoni <thomas.petazzoni@free-electrons.com> - 2016-10-04 14:20 +0200
      Re: [PATCH 02/14] clk: ccu-sun8i-a33: Add CLK_SET_RATE_PARENT to  ac-dig Mylene Josserand <mylene.josserand@free-electrons.com> - 2016-10-05 11:40 +0200
  [PATCH 05/14] mfd: sun6i-prcm: Add sun8i analog codec as subnode Mylène Josserand          <mylene.josserand@free-electrons.com> - 2016-10-04 12:00 +0200
    Re: [PATCH 05/14] mfd: sun6i-prcm: Add sun8i analog codec as  subnode Jean-Francois Moine <moinejf@free.fr> - 2016-10-04 13:00 +0200
  [PATCH 04/14] ASoC: Add sun8i analog codec driver Mylène Josserand          <mylene.josserand@free-electrons.com> - 2016-10-04 12:00 +0200
    Re: [PATCH 04/14] ASoC: Add sun8i analog codec driver Code Kipper <codekipper@gmail.com> - 2016-10-04 12:30 +0200
      Re: [PATCH 04/14] ASoC: Add sun8i analog codec driver Chen-Yu Tsai <wens@csie.org> - 2016-10-04 13:00 +0200
  [PATCH 07/14] ASoC: Add sun8i audio card Mylène Josserand          <mylene.josserand@free-electrons.com> - 2016-10-04 12:00 +0200
    Re: [PATCH 07/14] ASoC: Add sun8i audio card Code Kipper <codekipper@gmail.com> - 2016-10-04 12:20 +0200
      Re: [PATCH 07/14] ASoC: Add sun8i audio card Chen-Yu Tsai <wens@csie.org> - 2016-10-04 13:10 +0200
    Re: [PATCH 07/14] ASoC: Add sun8i audio card Thomas Petazzoni <thomas.petazzoni@free-electrons.com> - 2016-10-04 14:30 +0200
    Re: [PATCH 07/14] ASoC: Add sun8i audio card Code Kipper <codekipper@gmail.com> - 2016-10-05 08:10 +0200
      Re: [PATCH 07/14] ASoC: Add sun8i audio card Jean-Francois Moine <moinejf@free.fr> - 2016-10-05 12:10 +0200
  [PATCH 06/14] ASoC: Add sun8i digital audio codec Mylène Josserand          <mylene.josserand@free-electrons.com> - 2016-10-04 12:00 +0200
    Re: [PATCH 06/14] ASoC: Add sun8i digital audio codec Thomas Petazzoni <thomas.petazzoni@free-electrons.com> - 2016-10-04 14:50 +0200
      Re: [PATCH 06/14] ASoC: Add sun8i digital audio codec Mark Brown <broonie@kernel.org> - 2016-10-04 15:10 +0200
        Re: [PATCH 06/14] ASoC: Add sun8i digital audio codec Thomas Petazzoni <thomas.petazzoni@free-electrons.com> - 2016-10-04 15:20 +0200
      Re: [PATCH 06/14] ASoC: Add sun8i digital audio codec Maxime Ripard <maxime.ripard@free-electrons.com> - 2016-10-04 18:20 +0200
      Re: [PATCH 06/14] ASoC: Add sun8i digital audio codec Mylene Josserand <mylene.josserand@free-electrons.com> - 2016-10-05 14:00 +0200
    Re: [PATCH 06/14] ASoC: Add sun8i digital audio codec Maxime Ripard <maxime.ripard@free-electrons.com> - 2016-10-04 18:20 +0200
      Re: [PATCH 06/14] ASoC: Add sun8i digital audio codec Alexandre Belloni <alexandre.belloni@free-electrons.com> - 2016-10-06 20:30 +0200
  [PATCH 09/14] dt-bindings: sound: Add sun8i codec documentation Mylène Josserand          <mylene.josserand@free-electrons.com> - 2016-10-04 12:00 +0200
    Re: [PATCH 09/14] dt-bindings: sound: Add sun8i codec documentation Maxime Ripard <maxime.ripard@free-electrons.com> - 2016-10-04 18:30 +0200

csiph-web