From patchwork Fri Aug 11 20:14:00 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Watts X-Patchwork-Id: 13351398 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id B6D70C0015E for ; Fri, 11 Aug 2023 20:16:16 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id E3721836; Fri, 11 Aug 2023 22:15:24 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz E3721836 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1691784975; bh=+ikxxxBrtOIscAn6X3WvP38OjXEPcCycQ8XlzG8y5WU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=MrmSIjPAfGEm8UOj7FGkh3jGuB2kfC6g5mPtdaUHpZZul9Vy40Wz6KaijqExjFinn cxQzkAoGjwREXuzDZXMXuc1Q4ieYDqEZhRfAAvYVcovZYGPDJaIWYJN1eQaFnnzDQH tB4d+TGVBcB9RcnlKNjLoixuLTO4q6yArMlMU6h0= Received: by alsa1.perex.cz (Postfix, from userid 50401) id C9674F8055B; Fri, 11 Aug 2023 22:14:36 +0200 (CEST) Received: from mailman-core.alsa-project.org (mailman-core.alsa-project.org [10.254.200.10]) by alsa1.perex.cz (Postfix) with ESMTP id 2E6B4F8055B; Fri, 11 Aug 2023 22:14:36 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id D973FF80166; Fri, 11 Aug 2023 22:14:31 +0200 (CEST) Received: from out-74.mta1.migadu.com (out-74.mta1.migadu.com [95.215.58.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 9E3A7F800F4 for ; Fri, 11 Aug 2023 22:14:24 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 9E3A7F800F4 Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key, unprotected) header.d=jookia.org header.i=@jookia.org header.a=rsa-sha256 header.s=key1 header.b=fOEGh3YG X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=jookia.org; s=key1; t=1691784863; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=gXxLpbwnK2iER9aMBTnDKfRuAwj+8nGNCQhtYFkwJrs=; b=fOEGh3YG4Ed6CywSJa3zIzGH2UVPJ+thdSdatxaiyOcU9nDq8LREc/TvthapaRnzpBYlnG FkZ+uW225LdaA9JsXIeD5pOY9Rx70nNzbDvQkHyx4EZkch9XQTJ+q+Trt3jDSQ0HaXCLWM 4TNb6SgeURSj5+UtJy+h5JVwtLu9vuMthKYiutq26Ba0xvfEQSeWgHXfXoIXu0HtFLiMf9 kKijtcXvYSnpNQ/MVYktvL6GvO1DSGUTJWvhaVC7DleXPcqp14j6KzM9nheB19wcrGJnhQ M6Y7kj7j4/qNa4Mbt+bxVFjD7KRyMATH5Ja2J+Lsga4DJsrlT78qDjwMeGd7LA== From: John Watts To: alsa-devel@alsa-project.org Cc: Liam Girdwood , Mark Brown , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Chen-Yu Tsai , Jernej Skrabec , Samuel Holland , Jaroslav Kysela , Takashi Iwai , John Watts , =?utf-8?q?U?= =?utf-8?q?we_Kleine-K=C3=B6nig?= , Maxime Ripard , devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-sunxi@lists.linux.dev, linux-kernel@vger.kernel.org Subject: [RFC PATCH 1/7] ASoC: sunxi: sun4i-i2s: Prepare for runtime DIN pin selection Date: Sat, 12 Aug 2023 06:14:00 +1000 Message-ID: <20230811201406.4096210-2-contact@jookia.org> In-Reply-To: <20230811201406.4096210-1-contact@jookia.org> References: <20230811201406.4096210-1-contact@jookia.org> MIME-Version: 1.0 X-Migadu-Flow: FLOW_OUT Message-ID-Hash: I3ONR2BSDGVSL5VDNAO6UQBY66KOY2BE X-Message-ID-Hash: I3ONR2BSDGVSL5VDNAO6UQBY66KOY2BE X-MailFrom: contact@jookia.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-alsa-devel.alsa-project.org-0; header-match-alsa-devel.alsa-project.org-1; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.8 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: The R329 and D1 support multiple I2S data input pins, but to use these they require explicit mapping to channels. Add a mapping of DIN pins to the 16 channels in the sun4i_i2s struct then use that to write the channel mapping register. For now the mapping is always to DIN0, identical to the previous behaviour. Signed-off-by: John Watts --- sound/soc/sunxi/sun4i-i2s.c | 40 +++++++++++++++++++++++++++++++++---- 1 file changed, 36 insertions(+), 4 deletions(-) diff --git a/sound/soc/sunxi/sun4i-i2s.c b/sound/soc/sunxi/sun4i-i2s.c index 669d712bbe9f..d8f999ecaf05 100644 --- a/sound/soc/sunxi/sun4i-i2s.c +++ b/sound/soc/sunxi/sun4i-i2s.c @@ -216,6 +216,7 @@ struct sun4i_i2s { unsigned int mclk_freq; unsigned int slots; unsigned int slot_width; + u8 channel_dins[16]; struct snd_dmaengine_dai_dma_data capture_dma_data; struct snd_dmaengine_dai_dma_data playback_dma_data; @@ -233,6 +234,13 @@ struct sun4i_i2s_clk_div { u8 val; }; +static int sun4i_i2s_read_channel_dins(struct device *dev, struct sun4i_i2s *i2s) +{ + /* Use DIN pin 0 by default */ + memset(i2s->channel_dins, 0, sizeof(i2s->channel_dins)); + return 0; +} + static const struct sun4i_i2s_clk_div sun4i_i2s_bclk_div[] = { { .div = 2, .val = 0 }, { .div = 4, .val = 1 }, @@ -527,6 +535,25 @@ static int sun8i_i2s_set_chan_cfg(const struct sun4i_i2s *i2s, return 0; } +static void sun50i_h6_write_channel_map(const struct sun4i_i2s *i2s, + unsigned int reg, + unsigned int channel_start) +{ + unsigned int reg_value = 0; + + /* Loop backwards so we can shift values in */ + for (int i = 3; i >= 0; i--) { + int channel = channel_start + i; + u8 din = i2s->channel_dins[channel]; + u8 slot = channel; /* Map slot to channel */ + + reg_value <<= 8; + reg_value |= (din << 4) | slot; + } + + regmap_write(i2s->regmap, reg, reg_value); +} + static int sun50i_h6_i2s_set_chan_cfg(const struct sun4i_i2s *i2s, unsigned int channels, unsigned int slots, unsigned int slot_width) @@ -537,10 +564,10 @@ static int sun50i_h6_i2s_set_chan_cfg(const struct sun4i_i2s *i2s, regmap_write(i2s->regmap, SUN50I_H6_I2S_TX_CHAN_MAP0_REG(0), 0xFEDCBA98); regmap_write(i2s->regmap, SUN50I_H6_I2S_TX_CHAN_MAP1_REG(0), 0x76543210); if (i2s->variant->num_din_pins > 1) { - regmap_write(i2s->regmap, SUN50I_R329_I2S_RX_CHAN_MAP0_REG, 0x0F0E0D0C); - regmap_write(i2s->regmap, SUN50I_R329_I2S_RX_CHAN_MAP1_REG, 0x0B0A0908); - regmap_write(i2s->regmap, SUN50I_R329_I2S_RX_CHAN_MAP2_REG, 0x07060504); - regmap_write(i2s->regmap, SUN50I_R329_I2S_RX_CHAN_MAP3_REG, 0x03020100); + sun50i_h6_write_channel_map(i2s, SUN50I_R329_I2S_RX_CHAN_MAP0_REG, 12); + sun50i_h6_write_channel_map(i2s, SUN50I_R329_I2S_RX_CHAN_MAP1_REG, 8); + sun50i_h6_write_channel_map(i2s, SUN50I_R329_I2S_RX_CHAN_MAP2_REG, 4); + sun50i_h6_write_channel_map(i2s, SUN50I_R329_I2S_RX_CHAN_MAP3_REG, 0); } else { regmap_write(i2s->regmap, SUN50I_H6_I2S_RX_CHAN_MAP0_REG, 0xFEDCBA98); regmap_write(i2s->regmap, SUN50I_H6_I2S_RX_CHAN_MAP1_REG, 0x76543210); @@ -1559,6 +1586,11 @@ static int sun4i_i2s_probe(struct platform_device *pdev) } } + if (sun4i_i2s_read_channel_dins(&pdev->dev, i2s)) { + dev_err(&pdev->dev, "Invalid channel DINs\n"); + return -EINVAL; + } + i2s->playback_dma_data.addr = res->start + i2s->variant->reg_offset_txdata; i2s->playback_dma_data.maxburst = 8; From patchwork Fri Aug 11 20:14:01 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Watts X-Patchwork-Id: 13351399 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 5504BC001DE for ; Fri, 11 Aug 2023 20:16:24 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id B57EB84A; Fri, 11 Aug 2023 22:15:31 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz B57EB84A DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1691784981; bh=bp1uhKiN2iX+iNkgzk+NUQQsCKc99cuDK9aP8t52O5A=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=txMukbKo89KZrtv7K+CvbgCu/hJzKWdMrZFta0Fg/uuhhUGvxDPdGFd73wiabfxzx 6osqMeDEiH4POKCnnCzFauumBYcj0O+oZ5WSNyMu48kG3UJ8mq9o2Zz+DEzalgGp0d WjT7w++TC+BEieTxVTcQHO/9WtJORoOtYA3O1Wz0= Received: by alsa1.perex.cz (Postfix, from userid 50401) id 1CC2DF80579; Fri, 11 Aug 2023 22:14:40 +0200 (CEST) Received: from mailman-core.alsa-project.org (mailman-core.alsa-project.org [10.254.200.10]) by alsa1.perex.cz (Postfix) with ESMTP id 9F6FFF8056F; Fri, 11 Aug 2023 22:14:40 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 334EEF8056F; Fri, 11 Aug 2023 22:14:37 +0200 (CEST) Received: from out-102.mta1.migadu.com (out-102.mta1.migadu.com [IPv6:2001:41d0:203:375::66]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 73672F8016E for ; Fri, 11 Aug 2023 22:14:32 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 73672F8016E Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key, unprotected) header.d=jookia.org header.i=@jookia.org header.a=rsa-sha256 header.s=key1 header.b=G3FR1BhY X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=jookia.org; s=key1; t=1691784872; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=DhYtgX26LvJBhk6rq6uv3xTzs4w5PTKDtDH5ARnA/4A=; b=G3FR1BhYf+QYeepS8uWwGULIaRbKottmRdYsDjusazmWtWiDg8fF5tcuc4FuZXcRMNF2Mo ieoy9oUrsQeJSeROCAv/695QGWwCOuZAuV7fs5AWXgdfEsc6UgpJpBjuPRS2Hofz0af/VT tmBpbOYnVZpR6BIbJBm8dYGC0gUvtemdTvaRXMkVzbJLGzE4MTaO1SXq/PmfzOvOwrqO9H tXOGIlA2GciINGlf4QK/fJ4JFnwS/FO+t48g2Sg9qwwBMjwkhOkNqm5iTPO+TSAU4Rx84E dVyExjbZ389fkoZxoqmDquJNbI2ASpqJqqKj3A1P+Sy1ou5RNvSxx8guWMrfog== From: John Watts To: alsa-devel@alsa-project.org Cc: Liam Girdwood , Mark Brown , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Chen-Yu Tsai , Jernej Skrabec , Samuel Holland , Jaroslav Kysela , Takashi Iwai , John Watts , =?utf-8?q?U?= =?utf-8?q?we_Kleine-K=C3=B6nig?= , Maxime Ripard , devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-sunxi@lists.linux.dev, linux-kernel@vger.kernel.org Subject: [RFC PATCH 2/7] ASoC: sunxi: sun4i-i2s: Use channel-dins device tree property Date: Sat, 12 Aug 2023 06:14:01 +1000 Message-ID: <20230811201406.4096210-3-contact@jookia.org> In-Reply-To: <20230811201406.4096210-1-contact@jookia.org> References: <20230811201406.4096210-1-contact@jookia.org> MIME-Version: 1.0 X-Migadu-Flow: FLOW_OUT Message-ID-Hash: HDXFNBBND4IN3XOFUTYSEM7QF7CZLDT5 X-Message-ID-Hash: HDXFNBBND4IN3XOFUTYSEM7QF7CZLDT5 X-MailFrom: contact@jookia.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-alsa-devel.alsa-project.org-0; header-match-alsa-devel.alsa-project.org-1; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.8 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: Instead of using DIN pin 0 for all pins, allow changing this using the device tree property. As an example: &i2s2 { channel-dins = /bits/ 8 <0 0 1 1 2 2>; }; This sets channels 0 and 1 to DIN pin 0, channels 1 and 2 to DIN pin 1, and channels 3 and 4 to DIN pin 3 respectively. Signed-off-by: John Watts --- sound/soc/sunxi/sun4i-i2s.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/sound/soc/sunxi/sun4i-i2s.c b/sound/soc/sunxi/sun4i-i2s.c index d8f999ecaf05..cf66f21646a4 100644 --- a/sound/soc/sunxi/sun4i-i2s.c +++ b/sound/soc/sunxi/sun4i-i2s.c @@ -236,8 +236,33 @@ struct sun4i_i2s_clk_div { static int sun4i_i2s_read_channel_dins(struct device *dev, struct sun4i_i2s *i2s) { + struct device_node *np = dev->of_node; + int max_channels = ARRAY_SIZE(i2s->channel_dins); + int ret; + /* Use DIN pin 0 by default */ memset(i2s->channel_dins, 0, sizeof(i2s->channel_dins)); + + if (!np) + return 0; + + ret = of_property_read_variable_u8_array(np, "channel-dins", + i2s->channel_dins, + 1, max_channels); + + if (ret == -EINVAL) + return 0; + + if (ret < 0) + return ret; + + for (int i = 0; i < ret; ++i) { + u8 din = i2s->channel_dins[i]; + + if (din >= i2s->variant->num_din_pins) + return -EINVAL; + } + return 0; } From patchwork Fri Aug 11 20:14:02 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Watts X-Patchwork-Id: 13351400 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 61273C001DE for ; Fri, 11 Aug 2023 20:16:43 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id A0CEC822; Fri, 11 Aug 2023 22:15:51 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz A0CEC822 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1691785001; bh=ysp5gU6h3jAj+JUX9RAzuvheYouVZnnYpv0v9EEUWAQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=kOYwOJbbuvkNwHAsZmqUmmsbrFQgzo+kINdd7L15Jod+gCV7Dx3SVQQ5aMzjA0deC egm5kYOhOnTji3zdAGk109MdCbxTqKJuedRYdClZcK2PM9qVKQflptJKXD+B5yaGJQ v3gMuH43ta+z+P7Kh4FX2ivPvIGLlZD0bWbEEkyg= Received: by alsa1.perex.cz (Postfix, from userid 50401) id B2577F80588; Fri, 11 Aug 2023 22:14:49 +0200 (CEST) Received: from mailman-core.alsa-project.org (mailman-core.alsa-project.org [10.254.200.10]) by alsa1.perex.cz (Postfix) with ESMTP id 1335BF8057E; Fri, 11 Aug 2023 22:14:49 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 72D43F8057E; Fri, 11 Aug 2023 22:14:45 +0200 (CEST) Received: from out-110.mta1.migadu.com (out-110.mta1.migadu.com [95.215.58.110]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 1BA1FF80568 for ; Fri, 11 Aug 2023 22:14:41 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 1BA1FF80568 Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key, unprotected) header.d=jookia.org header.i=@jookia.org header.a=rsa-sha256 header.s=key1 header.b=b+X1lQvd X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=jookia.org; s=key1; t=1691784880; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=KohIP0ksHXxdx+GVUlJOfMvQCC6gcPhr/Z2zQUgwBik=; b=b+X1lQvdVhoQYU2XhhOyNGjflc23TRX6lpdQ4j3TVZPlsuUKRMU+OpZQaiDS13YPvo+Gag srOdPv0LV4WyVDiGbaOwKk/3WyOs2rlMkTR0lV3mh4EVr0rPjdTAgIvJxr6aaOPBWEh2/X nqesEmlNJGzzk6D9VQaz2yT3iRwRBq4rS9h58rGcfz/05bwCfeuo8YweYJqoScg0fw0DDe ZqaXU+vo2rLuDoUP1fOskzn8svSeJFPncg0PpgpBHvIpnIihbYRYERlAU8sL1dRIh3pTHO HWQ0HeRwYvp3S7Lcge1dubVrRGxaDvUpc6XOqdcdZXu6kYIPajrkAEiFFJXifQ== From: John Watts To: alsa-devel@alsa-project.org Cc: Liam Girdwood , Mark Brown , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Chen-Yu Tsai , Jernej Skrabec , Samuel Holland , Jaroslav Kysela , Takashi Iwai , John Watts , =?utf-8?q?U?= =?utf-8?q?we_Kleine-K=C3=B6nig?= , Maxime Ripard , devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-sunxi@lists.linux.dev, linux-kernel@vger.kernel.org Subject: [RFC PATCH 3/7] ASoC: sunxi: sun4i-i2s: Prepare for runtime channel slot selection Date: Sat, 12 Aug 2023 06:14:02 +1000 Message-ID: <20230811201406.4096210-4-contact@jookia.org> In-Reply-To: <20230811201406.4096210-1-contact@jookia.org> References: <20230811201406.4096210-1-contact@jookia.org> MIME-Version: 1.0 X-Migadu-Flow: FLOW_OUT Message-ID-Hash: UQO75D5IETOK6KIVHCQMWX3HOA4GRCMG X-Message-ID-Hash: UQO75D5IETOK6KIVHCQMWX3HOA4GRCMG X-MailFrom: contact@jookia.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-alsa-devel.alsa-project.org-0; header-match-alsa-devel.alsa-project.org-1; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.8 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: The sun4i I2S controller supports mapping channels to specific TDM slots. This is usually done in a 1:1 mapping because there's not really a reason to re-order the TDM slots in software. On the R329 and D1 multiplexing can be done using pins as well as TDM. Here's an example of using 3 pins and 2 slots (left and right): Channel 0 -> DIN0 -> ADC0, TDM slot 0 Channel 1 -> DIN0 -> ADC0, TDM slot 1 Channel 2 -> DIN1 -> ADC1, TDM slot 0 Channel 3 -> DIN1 -> ADC1, TDM slot 1 Channel 4 -> DIN2 -> ADC2, TDM slot 0 Channel 5 -> DIN2 -> ADC2, TDM slot 1 This connects 3 separate TDM-unaware ADCs to the I2S controller. Likewise, multiple TDM slots could be used to run two sets of TDM-aware ADCs on one I2S controller. Prepare for configurable slot selection by adding a channel to slot mapping array and using that in the R329 code if we multiple DIN pins. Signed-off-by: John Watts --- sound/soc/sunxi/sun4i-i2s.c | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/sound/soc/sunxi/sun4i-i2s.c b/sound/soc/sunxi/sun4i-i2s.c index cf66f21646a4..627bf319e1cc 100644 --- a/sound/soc/sunxi/sun4i-i2s.c +++ b/sound/soc/sunxi/sun4i-i2s.c @@ -217,6 +217,7 @@ struct sun4i_i2s { unsigned int slots; unsigned int slot_width; u8 channel_dins[16]; + u8 channel_slots[16]; struct snd_dmaengine_dai_dma_data capture_dma_data; struct snd_dmaengine_dai_dma_data playback_dma_data; @@ -266,6 +267,17 @@ static int sun4i_i2s_read_channel_dins(struct device *dev, struct sun4i_i2s *i2s return 0; } +static int sun4i_i2s_read_channel_slots(struct device *dev, struct sun4i_i2s *i2s) +{ + int max_channels = ARRAY_SIZE(i2s->channel_dins); + + /* Use a 1:1 mapping by default */ + for (int i = 0; i < max_channels; ++i) + i2s->channel_slots[i] = i; + + return 0; +} + static const struct sun4i_i2s_clk_div sun4i_i2s_bclk_div[] = { { .div = 2, .val = 0 }, { .div = 4, .val = 1 }, @@ -570,7 +582,7 @@ static void sun50i_h6_write_channel_map(const struct sun4i_i2s *i2s, for (int i = 3; i >= 0; i--) { int channel = channel_start + i; u8 din = i2s->channel_dins[channel]; - u8 slot = channel; /* Map slot to channel */ + u8 slot = i2s->channel_slots[channel]; reg_value <<= 8; reg_value |= (din << 4) | slot; @@ -1616,6 +1628,11 @@ static int sun4i_i2s_probe(struct platform_device *pdev) return -EINVAL; } + if (sun4i_i2s_read_channel_slots(&pdev->dev, i2s)) { + dev_err(&pdev->dev, "Invalid channel slots\n"); + return -EINVAL; + } + i2s->playback_dma_data.addr = res->start + i2s->variant->reg_offset_txdata; i2s->playback_dma_data.maxburst = 8; From patchwork Fri Aug 11 20:14:03 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Watts X-Patchwork-Id: 13351401 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 8C848C0015E for ; Fri, 11 Aug 2023 20:17:07 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 4A4AF3E7; Fri, 11 Aug 2023 22:16:15 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 4A4AF3E7 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1691785025; bh=SNYGVN58R1htz8XAP/Ki30YWSq5luVzCpIBPqVinuws=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=lOWmZZJmK98OJAwaGc+b3jyxQPyL/xaKegZeJI+w2+7Ce77kKGixASxqx7YLdzLCt Qt8SleawaQwBiMvYIJWR33MNZIfai4TJvz4vgdGPDJKFSQtlMJuJ419zjb926HRddP NGfiVlolJ0yY0moZBsr3v0HFXLJdoviCnqQcwXlI= Received: by alsa1.perex.cz (Postfix, from userid 50401) id 5B030F805A9; Fri, 11 Aug 2023 22:14:58 +0200 (CEST) Received: from mailman-core.alsa-project.org (mailman-core.alsa-project.org [10.254.200.10]) by alsa1.perex.cz (Postfix) with ESMTP id CC04BF805AB; Fri, 11 Aug 2023 22:14:57 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id D369FF805AB; Fri, 11 Aug 2023 22:14:53 +0200 (CEST) Received: from out-95.mta0.migadu.com (out-95.mta0.migadu.com [91.218.175.95]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 6D95DF8058C for ; Fri, 11 Aug 2023 22:14:50 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 6D95DF8058C Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key, unprotected) header.d=jookia.org header.i=@jookia.org header.a=rsa-sha256 header.s=key1 header.b=SF7GQFQI X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=jookia.org; s=key1; t=1691784889; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=c760wkxPLczuI7tECzLOiGz+mznMFHiURmBp9IfloLs=; b=SF7GQFQIMbGSIRIbDdfcfm1/Ln1i/WscUwrTn0q7g9Z2FxkvffM46DLW+yosRia5C+01hO nSO9wHJ/nCkY+BuHCKtIPRhAvlQ26+RjFiLI3/9+ZRCUZU2QEYAs9tMPvWJLEALKgYLQcr DXWIy6JF3NZOOctaC6Rs+MK3rVAx64b2TffmFFG3FEaGNLX9rj59OoEnqqcuvwluBe52LX YHzSeZ9+eDwjs+4n980y4xyfurS640oORu3/5Co+ieSypxHceQZLOxxpOShOjqpjQSaoD1 TkEoo/NHBMJqeVdbqUaF3VscGKV8A8XKNogDdt3TwOKPlMVigfFEWFhfkC/d5Q== From: John Watts To: alsa-devel@alsa-project.org Cc: Liam Girdwood , Mark Brown , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Chen-Yu Tsai , Jernej Skrabec , Samuel Holland , Jaroslav Kysela , Takashi Iwai , John Watts , =?utf-8?q?U?= =?utf-8?q?we_Kleine-K=C3=B6nig?= , Maxime Ripard , devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-sunxi@lists.linux.dev, linux-kernel@vger.kernel.org Subject: [RFC PATCH 4/7] ASoC: sunxi: sun4i-i2s: Use channel-slots device tree property Date: Sat, 12 Aug 2023 06:14:03 +1000 Message-ID: <20230811201406.4096210-5-contact@jookia.org> In-Reply-To: <20230811201406.4096210-1-contact@jookia.org> References: <20230811201406.4096210-1-contact@jookia.org> MIME-Version: 1.0 X-Migadu-Flow: FLOW_OUT Message-ID-Hash: SG3GYFEYRGQFNNAKVAQSSWUENQQDKWKJ X-Message-ID-Hash: SG3GYFEYRGQFNNAKVAQSSWUENQQDKWKJ X-MailFrom: contact@jookia.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-alsa-devel.alsa-project.org-0; header-match-alsa-devel.alsa-project.org-1; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.8 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: On R329 I2S variants with multiple pins it's useful to read from multiple devices within a single TDM slot. Allow changing the assignment of slots through a device tree property. As an example: &i2s2 { channel-dins = /bits/ 8 <0 0 1 1 2 2>; channel-slots = /bits/ 8 <0 1 0 1 0 1>; }; In addition to configuring the first 6 channels to use different DIN pins for three separate ADCs, the addition of channel-slots allows all three ADCs to be sampled within the first two TDM slots. Signed-off-by: John Watts --- sound/soc/sunxi/sun4i-i2s.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/sound/soc/sunxi/sun4i-i2s.c b/sound/soc/sunxi/sun4i-i2s.c index 627bf319e1cc..019a4856c90b 100644 --- a/sound/soc/sunxi/sun4i-i2s.c +++ b/sound/soc/sunxi/sun4i-i2s.c @@ -269,12 +269,27 @@ static int sun4i_i2s_read_channel_dins(struct device *dev, struct sun4i_i2s *i2s static int sun4i_i2s_read_channel_slots(struct device *dev, struct sun4i_i2s *i2s) { + struct device_node *np = dev->of_node; int max_channels = ARRAY_SIZE(i2s->channel_dins); + int ret; /* Use a 1:1 mapping by default */ for (int i = 0; i < max_channels; ++i) i2s->channel_slots[i] = i; + if (!np) + return 0; + + ret = of_property_read_variable_u8_array(np, "channel-slots", + i2s->channel_slots, + 1, max_channels); + + if (ret == -EINVAL) + return 0; + + if (ret < 0) + return ret; + return 0; } From patchwork Fri Aug 11 20:14:04 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Watts X-Patchwork-Id: 13351406 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 3CAA8C0015E for ; Fri, 11 Aug 2023 20:17:20 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 479B51E0; Fri, 11 Aug 2023 22:16:28 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 479B51E0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1691785038; bh=rCB5UZmPyBYgYHxvNl3rMWz09DbhN20vUmDjiBpqxnk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=nqWQZ7LnTTG2ScxeNw29xqYqnnEsbsMj04e7w6Z1owLWsIJSoE5O/oobkQW4zN/qk WrBD1kpNAaqqqPlvRqvlTqV36Atbe74DO5ARoMuNfKElAAaRyrDt/rsWkl4WhqzgU2 VpB6SEr7IJAHK3pEMe+4XNMvT0Dgyc/r0QMM8v70= Received: by alsa1.perex.cz (Postfix, from userid 50401) id 3415BF805BA; Fri, 11 Aug 2023 22:15:08 +0200 (CEST) Received: from mailman-core.alsa-project.org (mailman-core.alsa-project.org [10.254.200.10]) by alsa1.perex.cz (Postfix) with ESMTP id 88CB7F800EE; Fri, 11 Aug 2023 22:15:07 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 6D8D7F805B4; Fri, 11 Aug 2023 22:15:04 +0200 (CEST) Received: from out-89.mta1.migadu.com (out-89.mta1.migadu.com [IPv6:2001:41d0:203:375::59]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 8705FF805B3 for ; Fri, 11 Aug 2023 22:14:58 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 8705FF805B3 Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key, unprotected) header.d=jookia.org header.i=@jookia.org header.a=rsa-sha256 header.s=key1 header.b=LToGtkDr X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=jookia.org; s=key1; t=1691784898; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=QeLKekQPGIWeXPPUTKz0UKXYLZ76J8hy48F28uG+rX0=; b=LToGtkDrOCSOVpZih3iIpGEia0EWeKKZmc8sXDwvIDst79QFhcJMmKPTrN3sDyjY1Wy2V+ 6d5pHC5gzuuL+DV3YeuRE4CYWcZnwxcupNJ3tJ80rEWDQ6JfN4SLY7DiGJYwKfqWtUjjJo hlQ3qR7G7/W+ktYvQSU1ELwD75mHRMwo2GrfLValj+Rr+pHqoyjnO1uKCyC4tQbuSZ0b23 oJrlGZFLUvH42hPAC5gr/y6pY7gbYWeaM2Q7ApnKbPjjkWEH2BueC6PRj0KLdKAGt0IrlZ 4qb39dtKKzPT7NmuAjpPVfonV6xd//g4n3/p05BnPMSkG5/Ihe01O7RRs5AdGw== From: John Watts To: alsa-devel@alsa-project.org Cc: Liam Girdwood , Mark Brown , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Chen-Yu Tsai , Jernej Skrabec , Samuel Holland , Jaroslav Kysela , Takashi Iwai , John Watts , =?utf-8?q?U?= =?utf-8?q?we_Kleine-K=C3=B6nig?= , Maxime Ripard , devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-sunxi@lists.linux.dev, linux-kernel@vger.kernel.org Subject: [RFC PATCH 5/7] ASoC: sunxi: sun4i-i2s: Detect TDM slots based on channel slots Date: Sat, 12 Aug 2023 06:14:04 +1000 Message-ID: <20230811201406.4096210-6-contact@jookia.org> In-Reply-To: <20230811201406.4096210-1-contact@jookia.org> References: <20230811201406.4096210-1-contact@jookia.org> MIME-Version: 1.0 X-Migadu-Flow: FLOW_OUT Message-ID-Hash: V6Q3AEKJX6MQKNSFSG76WMB3B4EARL4T X-Message-ID-Hash: V6Q3AEKJX6MQKNSFSG76WMB3B4EARL4T X-MailFrom: contact@jookia.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-alsa-devel.alsa-project.org-0; header-match-alsa-devel.alsa-project.org-1; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.8 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: The current controller code assumes a 1:1 relationship between audio channel and TDM slot. This may not be the case when slots are set explicitly. Instead figure out how many slots we need based on the number of slots used in the channel map. This allows the case of reading multiple data pins on a single slot. Signed-off-by: John Watts --- sound/soc/sunxi/sun4i-i2s.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/sound/soc/sunxi/sun4i-i2s.c b/sound/soc/sunxi/sun4i-i2s.c index 019a4856c90b..6347aaaed016 100644 --- a/sound/soc/sunxi/sun4i-i2s.c +++ b/sound/soc/sunxi/sun4i-i2s.c @@ -271,6 +271,7 @@ static int sun4i_i2s_read_channel_slots(struct device *dev, struct sun4i_i2s *i2 { struct device_node *np = dev->of_node; int max_channels = ARRAY_SIZE(i2s->channel_dins); + int slot_max; int ret; /* Use a 1:1 mapping by default */ @@ -290,6 +291,16 @@ static int sun4i_i2s_read_channel_slots(struct device *dev, struct sun4i_i2s *i2 if (ret < 0) return ret; + for (int i = 0; i < ret; ++i) { + int slot = i2s->channel_slots[i]; + + if (slot_max < slot) + slot_max = slot; + } + + /* Add 1 to be inclusive of slot 0 */ + i2s->slots = slot_max + 1; + return 0; } From patchwork Fri Aug 11 20:14:05 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Watts X-Patchwork-Id: 13351407 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 5F4A3C001DE for ; Fri, 11 Aug 2023 20:17:34 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 4F4DC84B; Fri, 11 Aug 2023 22:16:42 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 4F4DC84B DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1691785052; bh=5T6m5zTJR/icPSiP1uXX3ubyrA/veVn0IqzsYdtg638=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=iaJnHrggfZyYQ+CUUf6xs3dfWx0fsJfhSuGc0S9MY/rIcCxA4HcIpJO6vXzLiXIi9 Sw1esI71VcfM+Php7GV3Kwn2d5u3JGINoIAKdBssiiRQ7a/T2zobSNZ2KQdSu3w8Ct llhcl3G8HQJJviPWR8Og12HKKXKC6ONdiDURGcB4= Received: by alsa1.perex.cz (Postfix, from userid 50401) id 58E26F800EE; Fri, 11 Aug 2023 22:15:15 +0200 (CEST) Received: from mailman-core.alsa-project.org (mailman-core.alsa-project.org [10.254.200.10]) by alsa1.perex.cz (Postfix) with ESMTP id ECA0CF805BF; Fri, 11 Aug 2023 22:15:14 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 58DA3F805BF; Fri, 11 Aug 2023 22:15:12 +0200 (CEST) Received: from out-77.mta1.migadu.com (out-77.mta1.migadu.com [95.215.58.77]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 3B717F800EE for ; Fri, 11 Aug 2023 22:15:07 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 3B717F800EE Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key, unprotected) header.d=jookia.org header.i=@jookia.org header.a=rsa-sha256 header.s=key1 header.b=CD4lRSoh X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=jookia.org; s=key1; t=1691784906; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=/hW1ak8KgoejCSW9QrrxKnaZZBYUUgvs8EvZwonWW7Q=; b=CD4lRSohS0DnXE6VQTtKXerkV30clc05gHhy1KjszANLvk8PDxlFSV7Qua/nro9kKonJHc e8eoHeaLZp5s7KZlNwDK34rkKsUWBfUCmWTCwRWVwy5QVgHHMZM8sSork3+go0HP+WS2zL +wBm7nWZHqrkbT8zDGGfazKRPg1VK2rWYNYP0YW6raQ/isdg1uta45WuZX3DZboZBPOXsr DA0c5ijB5Kpf3Kj+R7DF+Ni0j9/bqE9IkI7pP9wCtKYgDEMMQjTSXd1APKUViWkkroB+Sh CrJoPs2fjzC35iszArbzoMgCTxYKK2L00BJPuquI4sL0bH08DFY/JDbOupdFfg== From: John Watts To: alsa-devel@alsa-project.org Cc: Liam Girdwood , Mark Brown , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Chen-Yu Tsai , Jernej Skrabec , Samuel Holland , Jaroslav Kysela , Takashi Iwai , John Watts , =?utf-8?q?U?= =?utf-8?q?we_Kleine-K=C3=B6nig?= , Maxime Ripard , devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-sunxi@lists.linux.dev, linux-kernel@vger.kernel.org Subject: [RFC PATCH 6/7] dt-bindings: sound: sun4i-i2s: Add channel-dins property Date: Sat, 12 Aug 2023 06:14:05 +1000 Message-ID: <20230811201406.4096210-7-contact@jookia.org> In-Reply-To: <20230811201406.4096210-1-contact@jookia.org> References: <20230811201406.4096210-1-contact@jookia.org> MIME-Version: 1.0 X-Migadu-Flow: FLOW_OUT Message-ID-Hash: HE4JWVPG3TDBJNFE6S3J4F5MYUVJMUML X-Message-ID-Hash: HE4JWVPG3TDBJNFE6S3J4F5MYUVJMUML X-MailFrom: contact@jookia.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-alsa-devel.alsa-project.org-0; header-match-alsa-devel.alsa-project.org-1; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.8 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: The R329 variant of the sun4i I2S controller supports multiple data input pins (din pins) for receiving data. Each channel can have its data input pin configured. Allow this to be configured using a new channel-dins property. Signed-off-by: John Watts --- .../sound/allwinner,sun4i-a10-i2s.yaml | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/Documentation/devicetree/bindings/sound/allwinner,sun4i-a10-i2s.yaml b/Documentation/devicetree/bindings/sound/allwinner,sun4i-a10-i2s.yaml index 739114fb6549..402549f9941c 100644 --- a/Documentation/devicetree/bindings/sound/allwinner,sun4i-a10-i2s.yaml +++ b/Documentation/devicetree/bindings/sound/allwinner,sun4i-a10-i2s.yaml @@ -52,6 +52,13 @@ properties: - const: apb - const: mod + channel-dins: + $ref: /schemas/types.yaml#/definitions/uint8-array + description: + This is a list of DIN pin numbers, each used for a receiving I2S + channel. Pins are mapped to channels based on array index. + Channel 0 is the first number, then channel 1, and so on. + # Even though it only applies to subschemas under the conditionals, # not listing them here will trigger a warning because of the # additionalsProperties set to false. @@ -144,4 +151,19 @@ examples: dma-names = "rx", "tx"; }; + - | + i2s0_d1: i2s@2032000 { + #sound-dai-cells = <0>; + compatible = "allwinner,sun20i-d1-i2s", + "allwinner,sun50i-r329-i2s"; + reg = <0x2032000 0x1000>; + interrupts = <0 26 0>; + clocks = <&ccu 86>, <&ccu 82>; + clock-names = "apb", "mod"; + resets = <&ccu 34>; + dmas = <&dma 3>, <&dma 3>; + dma-names = "rx", "tx"; + channel-dins = /bits/ 8 <0 0 1 1 2 2>; + }; + ... From patchwork Fri Aug 11 20:14:06 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Watts X-Patchwork-Id: 13351408 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id E9BB6C001DE for ; Fri, 11 Aug 2023 20:17:44 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 282D284D; Fri, 11 Aug 2023 22:16:53 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 282D284D DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1691785063; bh=rmvq/HQFDjVU+f2U0kTPfsArn0F4LVVQzHyN+2OF4Qg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=fb3+3E+kcpa2kPIiKH9R4TG8jAfGqeduzWOzOWLsAqZ0+8sKkWHL5sWHmHPiKXFN/ IFVw4qpwucuCnxL96XnIxA9RKumzkt/Hs4bIhIhXytDetBCaauKkHpu3lt65Rr2Nzz hA0MgqiortzQOj44dSCeK1qK0b/W6SmFJ3QFuduc= Received: by alsa1.perex.cz (Postfix, from userid 50401) id C9E2EF805D2; Fri, 11 Aug 2023 22:15:21 +0200 (CEST) Received: from mailman-core.alsa-project.org (mailman-core.alsa-project.org [10.254.200.10]) by alsa1.perex.cz (Postfix) with ESMTP id 4A743F805C0; Fri, 11 Aug 2023 22:15:21 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 5645DF805C8; Fri, 11 Aug 2023 22:15:18 +0200 (CEST) Received: from out-112.mta1.migadu.com (out-112.mta1.migadu.com [95.215.58.112]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 28E02F805C0 for ; Fri, 11 Aug 2023 22:15:15 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 28E02F805C0 Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key, unprotected) header.d=jookia.org header.i=@jookia.org header.a=rsa-sha256 header.s=key1 header.b=B7i/2R3i X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=jookia.org; s=key1; t=1691784914; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=iYu4Dz4hSNyn9kJzzK4p3lb9piHB7a9wwJ9aGUktfD0=; b=B7i/2R3iHC2ro6I9YUbHM1FvoB39fIf9DPTD/SmZey33EEFmx1QnK5KHPYfPpGFyrVjy6b j1F4S4QKVceyrPo4Rt7R42KM8h/+TKatWo9+iY0nazcL7pPZEniFrdFx+6CNXbZ/AdhHf1 aRDDIdWVuexKugvOjAH2RfxfuJ2ScwKgnOPsxfNcWV01LvTPJzC6zhsT8ahXRey2kbzFog XARZ1uI/K6YTATMTxZ4Pu/UsKVkoiC0oWJXwIcyBPoIMAmJvHj5xCx5Ep6EoNezVeeUs/h FlmeZ8gYKpenjqwDlrWOZV7PwrOv/uXUQBHKCbg5jRabvsDkoOvwzk+kscj/Vw== From: John Watts To: alsa-devel@alsa-project.org Cc: Liam Girdwood , Mark Brown , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Chen-Yu Tsai , Jernej Skrabec , Samuel Holland , Jaroslav Kysela , Takashi Iwai , John Watts , =?utf-8?q?U?= =?utf-8?q?we_Kleine-K=C3=B6nig?= , Maxime Ripard , devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-sunxi@lists.linux.dev, linux-kernel@vger.kernel.org Subject: [RFC PATCH 7/7] dt-bindings: sound: sun4i-i2s: Add channel-slots property Date: Sat, 12 Aug 2023 06:14:06 +1000 Message-ID: <20230811201406.4096210-8-contact@jookia.org> In-Reply-To: <20230811201406.4096210-1-contact@jookia.org> References: <20230811201406.4096210-1-contact@jookia.org> MIME-Version: 1.0 X-Migadu-Flow: FLOW_OUT Message-ID-Hash: NNPG3DDD67FQR2FDKU36GWFP7PI7PNWF X-Message-ID-Hash: NNPG3DDD67FQR2FDKU36GWFP7PI7PNWF X-MailFrom: contact@jookia.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-alsa-devel.alsa-project.org-0; header-match-alsa-devel.alsa-project.org-1; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.8 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: The sun4i I2S controller supports mapping arbitrary TDM slots to each channel. Allow this to be expressed in the device tree. This is currently only implemented in the R329 I2S variant. Allow this to be configured using a new channel-dins property. Signed-off-by: John Watts --- .../bindings/sound/allwinner,sun4i-a10-i2s.yaml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/Documentation/devicetree/bindings/sound/allwinner,sun4i-a10-i2s.yaml b/Documentation/devicetree/bindings/sound/allwinner,sun4i-a10-i2s.yaml index 402549f9941c..a74b02387d8a 100644 --- a/Documentation/devicetree/bindings/sound/allwinner,sun4i-a10-i2s.yaml +++ b/Documentation/devicetree/bindings/sound/allwinner,sun4i-a10-i2s.yaml @@ -59,6 +59,13 @@ properties: channel. Pins are mapped to channels based on array index. Channel 0 is the first number, then channel 1, and so on. + channel-slots: + $ref: /schemas/types.yaml#/definitions/uint8-array + description: + This is a list of channel I2S TDM slot numbers. Slots are mapped + to channels based on array index. + Channel 0 is the first number, then channel 1, and so on. + # Even though it only applies to subschemas under the conditionals, # not listing them here will trigger a warning because of the # additionalsProperties set to false. @@ -164,6 +171,7 @@ examples: dmas = <&dma 3>, <&dma 3>; dma-names = "rx", "tx"; channel-dins = /bits/ 8 <0 0 1 1 2 2>; + channel-slots = /bits/ 8 <0 1 0 1 0 1>; }; ...