From patchwork Tue Oct 4 09:46:20 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Mylene JOSSERAND X-Patchwork-Id: 9361545 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 7C7E8600C8 for ; Tue, 4 Oct 2016 09:54:08 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6A12D28968 for ; Tue, 4 Oct 2016 09:54:08 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5EA0828984; Tue, 4 Oct 2016 09:54:08 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id CA16F28968 for ; Tue, 4 Oct 2016 09:54:07 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.85_2 #1 (Red Hat Linux)) id 1brMOl-0006vy-6Z; Tue, 04 Oct 2016 09:52:31 +0000 Received: from down.free-electrons.com ([37.187.137.238] helo=mail.free-electrons.com) by bombadil.infradead.org with esmtp (Exim 4.85_2 #1 (Red Hat Linux)) id 1brMKl-0001wT-Go for linux-arm-kernel@lists.infradead.org; Tue, 04 Oct 2016 09:48:30 +0000 Received: by mail.free-electrons.com (Postfix, from userid 110) id B7BFCA35; Tue, 4 Oct 2016 11:47:59 +0200 (CEST) Received: from dell-desktop.home (LStLambert-657-1-97-87.w90-63.abo.wanadoo.fr [90.63.216.87]) by mail.free-electrons.com (Postfix) with ESMTPSA id EAF9344F; Tue, 4 Oct 2016 11:47:58 +0200 (CEST) From: =?UTF-8?q?Myl=C3=A8ne=20Josserand?= To: vinod.koul@intel.com, maxime.ripard@free-electrons.com, wens@csie.org, mturquette@baylibre.com, sboyd@codeaurora.org, lgirdwood@gmail.com, broonie@kernel.org, perex@perex.cz, tiwai@suse.com, lee.jones@linaro.org, mark.rutland@arm.com, robh+dt@kernel.org Subject: [PATCH 07/14] ASoC: Add sun8i audio card Date: Tue, 4 Oct 2016 11:46:20 +0200 Message-Id: <33d641ff43f0c0349cdfa2cdbbfdcdde66205596.1475571575.git.mylene.josserand@free-electrons.com> X-Mailer: git-send-email 2.9.3 In-Reply-To: References: In-Reply-To: References: MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20161004_024824_159406_73C75540 X-CRM114-Status: GOOD ( 18.89 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: thomas.petazzoni@free-electrons.com, devicetree@vger.kernel.org, alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org, linux-sunxi@googlegroups.com, alexandre.belloni@free-electrons.com, dmaengine@vger.kernel.org, mylene.josserand@free-electrons.com, linux-clk@vger.kernel.org, linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP 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 --- 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 + * + * 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 +#include + +#include + +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 "); +MODULE_DESCRIPTION("Allwinner sun8i machine ASoC driver"); +MODULE_LICENSE("GPL v2");