From patchwork Thu Sep 22 20:50:44 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nikita Yushchenko X-Patchwork-Id: 9349819 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 D7175601C2 for ; Sun, 25 Sep 2016 16:20:15 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B167828C2A for ; Sun, 25 Sep 2016 16:20:15 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8EAB928C30; Sun, 25 Sep 2016 16:20:15 +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=-1.3 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_NONE,RCVD_IN_SORBS_SPAM,T_DKIM_INVALID autolearn=no version=3.3.1 Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D702C28C2A for ; Sun, 25 Sep 2016 16:20:14 +0000 (UTC) Received: by alsa0.perex.cz (Postfix, from userid 1000) id 7D23B266B6F; Sun, 25 Sep 2016 18:20:12 +0200 (CEST) Received: from alsa0.perex.cz (localhost [127.0.0.1]) by alsa0.perex.cz (Postfix) with ESMTP id 85DC42666AA; Sun, 25 Sep 2016 18:17:53 +0200 (CEST) X-Original-To: alsa-devel@alsa-project.org Delivered-To: alsa-devel@alsa-project.org Received: by alsa0.perex.cz (Postfix, from userid 1000) id D298E266969; Thu, 22 Sep 2016 22:51:21 +0200 (CEST) Received: from mail-lf0-f45.google.com (mail-lf0-f45.google.com [209.85.215.45]) by alsa0.perex.cz (Postfix) with ESMTP id E9135266951 for ; Thu, 22 Sep 2016 22:51:19 +0200 (CEST) Received: by mail-lf0-f45.google.com with SMTP id g62so77921987lfe.3 for ; Thu, 22 Sep 2016 13:51:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cogentembedded-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id; bh=2HmUw8UeU4LB2oSzb+zVPbOXY3eiMM0zfoApAvJe2XQ=; b=Qf/roC469jsT7bjsJkqKwvWMoc31+1vnIIr8cwK5BL9baeY5/sPedws3fG3OuMsiRn 1JlfhIb0DeTdS4FgQA7NAAzAisWAN/XUd0/PvEIGEkBM3hrrrS51MQO+64DqkyRrplSD vRHExxBQ6X1xUu31ugNC+73bzsEzmDhZAllFe8EX/kJGdT2PrkvMwrVvz5dUlp4OKwyk MoYJtSYInwP4K3yAjfAzmoWcVEO0/Y5xNx/4ejrjCrv+S+5G0CROHZi1xlheyHdMKRaL 2ubMRBJz7UFLwQbKbTcDVumSuBj15Lz8xpRqDzUhma/AWHyeQQwTEuKCvl4YrLznls7b QKQQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=2HmUw8UeU4LB2oSzb+zVPbOXY3eiMM0zfoApAvJe2XQ=; b=mZTNwU/fBN/uiEhd/34PXy7/VdJSdT+HBx8W/nQmcW6ThXVnxiJq8RPTkRjAWXSR5x 63T90GujYrY9vUuAHF+hy/Dsuqt9WQPK6XmuASKqi2bj95NT5gkc22amfBsJhvRTi5sO 4xZJKo0c/3UKiSA9zlzpLUNl3XuylG2mWtSrsTVgfihlnnyF5V8KdU8cwmLnoDv+8dvq C3dk3wiSdJJaF+zVXJlE7XdlXjWjZtKtEkp5ziq5uGQul5pJUHubqF7NiQETqmmoEu5V /8KXRciTBj+VLTL/PTY6EPhL/YGRInZ0iF8hSUONUnG8KbTGKN0EenSmMlgNZUYfY67w +geA== X-Gm-Message-State: AE9vXwOMmw0+rq+cc9VCQje+GoSxpW6uX0RVtRR0nZct/sIFq7Q1rD4egBAJE+OrJDQGpQ== X-Received: by 10.25.219.11 with SMTP id s11mr1485502lfg.129.1474577478729; Thu, 22 Sep 2016 13:51:18 -0700 (PDT) Received: from hugenb.home (nikaet.starlink.ru. [94.141.168.29]) by smtp.gmail.com with ESMTPSA id 16sm624809ljj.47.2016.09.22.13.51.17 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 22 Sep 2016 13:51:18 -0700 (PDT) From: Nikita Yushchenko To: Liam Girdwood , Mark Brown , Rob Herring , Mark Rutland , Jaroslav Kysela , Takashi Iwai , =?UTF-8?q?Otto=20Kek=C3=A4l=C3=A4inen?= , Kuninori Morimoto , Mengdong Lin , Aaro Koskinen , Andrew Lunn , Peter Ujfalusi , alsa-devel@alsa-project.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Date: Thu, 22 Sep 2016 23:50:44 +0300 Message-Id: <1474577444-7598-1-git-send-email-nikita.yoush@cogentembedded.com> X-Mailer: git-send-email 2.1.4 X-Mailman-Approved-At: Sun, 25 Sep 2016 09:54:12 +0200 Cc: Nikita Yushchenko , Chris Healy Subject: [alsa-devel] [PATCH] ASoC: simple-card: add support for aux devices X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: alsa-devel-bounces@alsa-project.org Sender: alsa-devel-bounces@alsa-project.org X-Virus-Scanned: ClamAV using ClamSMTP This patch makes it possible to use simple-card in setups where separate amplifier chip is connected to codec's output. Example usage: codec: tlv320dac3100@18 { compatible = "ti,tlv320dac3100"; ... } amp: tpa6130a2@60 { compatible = "ti,tpa6130a2"; ... } sound { compatible = "simple-audio-card"; ... simple-audio-card,widgets = "Headphone", "Headphone Jack"; simple-audio-card,routing = "Headphone Jack", "HPLEFT", "Headphone Jack", "HPRIGHT", "LEFTIN", "HPL", "RIGHTIN", "HPR"; simple-audio-card,aux-devs = <&>; simple-audio-card,cpu { sound-dai = <&ssi2>; }; simple-audio-card,codec { sound-dai = <&codec1>; clocks = ... }; This describes audio path from IMX6 SSI2 through TLV320DAC3100 codec through TPA6130A2 amplifier to headphones. Signed-off-by: Nikita Yushchenko --- .../devicetree/bindings/sound/simple-card.txt | 2 ++ sound/soc/generic/simple-card.c | 34 ++++++++++++++++++++++ 2 files changed, 36 insertions(+) diff --git a/Documentation/devicetree/bindings/sound/simple-card.txt b/Documentation/devicetree/bindings/sound/simple-card.txt index 59d8628..5579f40 100644 --- a/Documentation/devicetree/bindings/sound/simple-card.txt +++ b/Documentation/devicetree/bindings/sound/simple-card.txt @@ -22,6 +22,8 @@ Optional properties: headphones are attached. - simple-audio-card,mic-det-gpio : Reference to GPIO that signals when a microphone is attached. +- simple-audio-card,aux-devs : List of phandles pointing to auxiliary devices, such + as amplifiers, to be added to the sound card. Optional subnodes: diff --git a/sound/soc/generic/simple-card.c b/sound/soc/generic/simple-card.c index 43295f0..f989f34 100644 --- a/sound/soc/generic/simple-card.c +++ b/sound/soc/generic/simple-card.c @@ -417,6 +417,36 @@ dai_link_of_err: return ret; } +static int asoc_simple_card_parse_aux_devs(struct device_node *node, + struct simple_card_data *priv) +{ + struct device *dev = simple_priv_to_dev(priv); + struct device_node *aux_node; + int i, n, len; + + if (!of_find_property(node, PREFIX "aux-devs", &len)) + return 0; /* Ok to have no aux-devs */ + + n = len / sizeof(__be32); + if (n <= 0) + return -EINVAL; + + priv->snd_card.aux_dev = devm_kzalloc(dev, + n * sizeof(*priv->snd_card.aux_dev), GFP_KERNEL); + if (!priv->snd_card.aux_dev) + return -ENOMEM; + + for (i = 0; i < n; i++) { + aux_node = of_parse_phandle(node, PREFIX "aux-devs", i); + if (!aux_node) + return -EINVAL; + priv->snd_card.aux_dev[i].codec_of_node = aux_node; + } + + priv->snd_card.num_aux_devs = n; + return 0; +} + static int asoc_simple_card_parse_of(struct device_node *node, struct simple_card_data *priv) { @@ -474,6 +504,10 @@ static int asoc_simple_card_parse_of(struct device_node *node, if (ret) return ret; + ret = asoc_simple_card_parse_aux_devs(node, priv); + if (ret) + return ret; + return 0; }