From patchwork Mon Mar 12 15:57:53 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Code Kipper X-Patchwork-Id: 10276679 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 C972E60467 for ; Mon, 12 Mar 2018 16:00:44 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A5B5328B14 for ; Mon, 12 Mar 2018 16:00:42 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A387D28D1B; Mon, 12 Mar 2018 16:00:42 +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.9 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, DKIM_VALID, FREEMAIL_FROM autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 83BB328B14 for ; Mon, 12 Mar 2018 16:00:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=GgIyDLZe4eUIqJ1fnhEqRANNTFbifOj8RE5RI3C79Qw=; b=V47ce0Sk95MUJUwxhPYcQHkKdo r84kGqtvh5xGNKUxTd7Ioxr5ItZLUWUQqyU0Q+EVtNhBMOBxzU/TSt/TLTiLQYj1oZx9u016vp4ux K+nQjjCgxuXDXM10ppOn7wlA0M8nsI4DUtu5X+hZ+xibRRnojUkZpnsAw03YrM97H611gcpNEPzBm c+HoW+P81NaUjLmaaPZPTasLsktrLgJcZdkxiLvvvf9UhrLz1b6+AI6gPhFgPcOy2dvsCYUiVZZLE fNsxRJEjdrqXOlyeyqtP3DyyyUmNwp1u509ofcF1mIR5qLtWrY1DafK1X376EhvCLYn0wLU8fLYhu UgECc8bg==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.89 #1 (Red Hat Linux)) id 1evPsD-0006eq-SK; Mon, 12 Mar 2018 16:00:29 +0000 Received: from mail-lf0-x243.google.com ([2a00:1450:4010:c07::243]) by bombadil.infradead.org with esmtps (Exim 4.89 #1 (Red Hat Linux)) id 1evPpz-0004Ou-3b for linux-arm-kernel@lists.infradead.org; Mon, 12 Mar 2018 15:58:13 +0000 Received: by mail-lf0-x243.google.com with SMTP id i80-v6so24055127lfg.5 for ; Mon, 12 Mar 2018 08:58:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=99qtNV4j6dXaHKpegWHyzTQ3DepSFNY9Zs222yIUaac=; b=V/X1baCTFBrBzFsaD8L6vySG05LcJ53cK06EV6Y6QsBbKmISYN4p97evGpVQQz9g2k TNN51OWk5GCBpP+iHhnZgkPPYUKtIRaMe4novjsmzTmXQBwpxkMsFobDx+dyUPuotG7L /AAHExPC8R0E/FjfCzmwwkhh7lmlyOjiUDfRMh+r0GkWciaiS9ZexwgSG2N5dXm+n1mi McwV7lbhQoOaXH03RFBT0j9Wm/UGY0cAscXqMEdpBpTSo2wKfr+X1TYuSJ+kVCeWw5Vg DqpOwjew5SUjniDxN2YpGr1fYcbOCqSNQFq77jbMDU3L2dPHdf4XlEpPCh0yYKuTLdqC W0lQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=99qtNV4j6dXaHKpegWHyzTQ3DepSFNY9Zs222yIUaac=; b=OuPEyki1dQ11zMknFmQ5BHMJt13WNwuabMNddhgreHZBPTuherHINa8qrz5R1+UbJn 0pzDY7WkVFU7iRzobkZkIgEfW/yzlwIZv2JkuaacKGi1U0bahm368Rq0M+ycUVBrlXf+ gnDw6nsgUACZMbdK6VfB1Y83ndfjXjWrLCak8qOVEmp7dc1COYmNaBeO0Zo+XOMkcU/a 1P+Vwfus/HJb68mbibmn4IjvYU7h61p0Flr/UZ3DBp7n1gPqHBBrk6o72Fyi4KN9sTGl RjyBXDZxmj2PGaQFfu4PlqVEMDOMGDS7RPdz1BMNixPNiNRmxeTJEGg0mB8XZRvTbWLE g50Q== X-Gm-Message-State: AElRT7F/QHonDWpQRe4NBbfEm4Xf/Kn44ymvTJrFIivtmbLAFehE2g5i ilEYgo7hMYcDFgCFem4cZXc= X-Google-Smtp-Source: AG47ELuDfKabo23IdzTcxrSctGZhe2DFn7BqgYQmYjHM/8qlaCh8yAFJ5SSxJaWeMr2R0JnI/47p5w== X-Received: by 10.46.81.73 with SMTP id b9mr5389588lje.9.1520870283906; Mon, 12 Mar 2018 08:58:03 -0700 (PDT) Received: from localhost.localdomain (c83-253-254-90.bredband.comhem.se. [83.253.254.90]) by smtp.gmail.com with ESMTPSA id h11-v6sm1833448lfd.88.2018.03.12.08.58.02 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 12 Mar 2018 08:58:03 -0700 (PDT) From: codekipper@gmail.com To: maxime.ripard@free-electrons.com, wens@csie.org, linux-sunxi@googlegroups.com Subject: [PATCH v2 6/6] ASoC: sun4i-i2s: Add support for loopback Date: Mon, 12 Mar 2018 16:57:53 +0100 Message-Id: <20180312155753.9478-7-codekipper@gmail.com> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20180312155753.9478-1-codekipper@gmail.com> References: <20180312155753.9478-1-codekipper@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180312_085811_231189_D2BEE420 X-CRM114-Status: GOOD ( 15.13 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: alsa-devel@alsa-project.org, Marcus Cooper , lgirdwood@gmail.com, linux-kernel@vger.kernel.org, be17068@iperbole.bo.it, broonie@kernel.org, linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 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 From: Marcus Cooper The DAI has a loopback register which can be set and therefore routes the transmit fifo to receive fifo. This is useful for testing the block without the need for any external hardware. Signed-off-by: Marcus Cooper --- Documentation/devicetree/bindings/sound/sun4i-i2s.txt | 3 +++ sound/soc/sunxi/sun4i-i2s.c | 11 +++++++++++ 2 files changed, 14 insertions(+) diff --git a/Documentation/devicetree/bindings/sound/sun4i-i2s.txt b/Documentation/devicetree/bindings/sound/sun4i-i2s.txt index 3f966ac61b9e..325e3d4571f1 100644 --- a/Documentation/devicetree/bindings/sound/sun4i-i2s.txt +++ b/Documentation/devicetree/bindings/sound/sun4i-i2s.txt @@ -32,6 +32,9 @@ Optional properties: - allwinner,slot-width-override:if this property is present then the dai is configured to extend the slot width to the value specified. Min 8, Max 32. +- loopback: if this property is present then the dai is configured in + loopback mode where the output fifo is redirected to the input + fifo. - allwinner,playback-channels: if this property is present then the number of available channels is extended and the diff --git a/sound/soc/sunxi/sun4i-i2s.c b/sound/soc/sunxi/sun4i-i2s.c index 7cf4dfe440de..a3c33814d33e 100644 --- a/sound/soc/sunxi/sun4i-i2s.c +++ b/sound/soc/sunxi/sun4i-i2s.c @@ -31,6 +31,7 @@ #define SUN4I_I2S_CTRL_MODE_MASK BIT(5) #define SUN4I_I2S_CTRL_MODE_SLAVE (1 << 5) #define SUN4I_I2S_CTRL_MODE_MASTER (0 << 5) +#define SUN4I_I2S_CTRL_LOOP BIT(3) #define SUN4I_I2S_CTRL_TX_EN BIT(2) #define SUN4I_I2S_CTRL_RX_EN BIT(1) #define SUN4I_I2S_CTRL_GL_EN BIT(0) @@ -195,6 +196,8 @@ struct sun4i_i2s { const struct sun4i_i2s_quirks *variant; + bool loopback; + unsigned int slot_width; }; @@ -639,6 +642,11 @@ static void sun4i_i2s_start_capture(struct sun4i_i2s *i2s) regmap_update_bits(i2s->regmap, SUN4I_I2S_DMA_INT_CTRL_REG, SUN4I_I2S_DMA_INT_CTRL_RX_DRQ_EN, SUN4I_I2S_DMA_INT_CTRL_RX_DRQ_EN); + + /* Debugging without codec */ + if (i2s->loopback) + regmap_update_bits(i2s->regmap, SUN4I_I2S_CTRL_REG, + SUN4I_I2S_CTRL_LOOP, SUN4I_I2S_CTRL_LOOP); } static void sun4i_i2s_start_playback(struct sun4i_i2s *i2s) @@ -1204,6 +1212,9 @@ static int sun4i_i2s_probe(struct platform_device *pdev) soc_dai->playback.channels_max = val; } + if (of_property_read_bool(pdev->dev.of_node, "loopback")) + i2s->loopback = true; + pm_runtime_enable(&pdev->dev); if (!pm_runtime_enabled(&pdev->dev)) { ret = sun4i_i2s_runtime_resume(&pdev->dev);