From patchwork Fri Jun 17 04:42:49 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Judy Hsiao X-Patchwork-Id: 12885082 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (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 B454EC433EF for ; Fri, 17 Jun 2022 04:43:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=PE8C+Z2T44/ThSQFwcxgKPI9tl7TQbBJL72XdSk4iAo=; b=MagLWkhoOfoGUl oBuCKc1hyb96vPiamMTNmzPvyrqm526Wp3Mb6oNQcTXVPb7HRr19Aha6KeWS2c6uz9qeSi7MhC9yz f+MWlMjiuocZuTtb7iIvkkaMO2ZPUITOZJ/AF4OvA6XxDx++N6mcTFvFfr2viIpdh6GeVGuL8Y/L8 aXZQ5cihCokJqbC+jbZ4QlzGulCGWyEylCy7Hauy8y9uxvTVGuxhyN0liuXXw3gxjWJaJ4qLSTCig ImxvUYASMUSlA20Yvz81yIg6/dMHSZJ8sqVoAGeNDdCl2knI2RRYzMORnPgt5kfGsu0ciuTkCZkF5 VyLS5eQK7FdTyGpncSEg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1o23pJ-005Sd0-Tc; Fri, 17 Jun 2022 04:43:21 +0000 Received: from mail-pl1-x635.google.com ([2607:f8b0:4864:20::635]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1o23p1-005SUQ-AG for linux-rockchip@lists.infradead.org; Fri, 17 Jun 2022 04:43:05 +0000 Received: by mail-pl1-x635.google.com with SMTP id r1so2912990plo.10 for ; Thu, 16 Jun 2022 21:43:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=7qm0AV+eEkYcioHyqrZmg4KTKdUKCTL+PHt2XXgTZN4=; b=C1RImj30Vr0KSWg4SrSlti9tJXEp0BuR9xbh/Nu2FVRRHeWR9Wfm0oRxYmVMWoBxC+ 5WB31Po3TPMST4rq1bjOVr0x0Zcf1xANG3obmQW+0/IaIqUwKxo4bcacX/keCxvMjdqr d3SqtUbWHUe3DYv0YhGEzmlgqXOPoKVkJCO50= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=7qm0AV+eEkYcioHyqrZmg4KTKdUKCTL+PHt2XXgTZN4=; b=3cCuefjcWrI0lWfvrLluJp+d80/xh1WK7Lx9MsUyq1MHZNQg821FYoaYwCp89O9uTb H692/doQAeFrErdkp1FMozba9pJt1hcTQcX3xB1b1z9f0dzI9S64whtRTtYqDve/lRWb vdXJPeOnY1yByj5r63rYBuVvWAP7qDZ/M9LW4/lVy7egxtyIUX0ETeiyrKjlEDxdDdCA Duk7SWBuXmw5iWcrGLMOv3OJeCLvwxCchyM4aOdlrERUQP/r+oEGsoPYwCmipjlxJXWP rzErzQwlg7qzAk72bBUx08Bssdo7gBRbkdSAAFyV4ZmFOQCjOg6mn3anZ3n+cRfjZ5wQ TmRA== X-Gm-Message-State: AJIora+sAgb06zdotrL/GZ9jdyOnTXGIYr5CvvJ9HzrrG/+yn8LEMiWV sinafbUC7cfyP3fTs4kxS5jE/8ws22XATVSu X-Google-Smtp-Source: AGRyM1u47Xwd9C4J12AwhST7whGJZczwk3OeT+Nq150Gu/wrM/gCORce+SkGdAaiCNARdWwEzokGBQ== X-Received: by 2002:a17:902:f708:b0:153:839f:bf2c with SMTP id h8-20020a170902f70800b00153839fbf2cmr8037455plo.113.1655440981674; Thu, 16 Jun 2022 21:43:01 -0700 (PDT) Received: from judyhsiao0523.c.googlers.com.com (0.223.81.34.bc.googleusercontent.com. [34.81.223.0]) by smtp.gmail.com with ESMTPSA id v8-20020a17090a778800b001eab0a27d92sm4491030pjk.51.2022.06.16.21.42.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 16 Jun 2022 21:43:01 -0700 (PDT) From: Judy Hsiao To: Heiko Stuebner Cc: Liam Girdwood , Rob Herring , Brian Norris , Mark Brown , Jaroslav Kysela , Chen-Yu Tsai , alsa-devel@alsa-project.org, linux-arm-kernel@lists.infradead.org, linux-rockchip@lists.infradead.org, linux-kernel@vger.kernel.org, Judy Hsiao Subject: [PATCH v3 1/3] ASoC: rockchip: i2s: switch BCLK to GPIO Date: Fri, 17 Jun 2022 04:42:49 +0000 Message-Id: <20220617044251.4029697-2-judyhsiao@chromium.org> X-Mailer: git-send-email 2.36.1.476.g0c4daa206d-goog In-Reply-To: <20220617044251.4029697-1-judyhsiao@chromium.org> References: <20220616155836.3401420-1-judyhsiao@chromium.org> <20220617044251.4029697-1-judyhsiao@chromium.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220616_214303_429768_2C2A3FB0 X-CRM114-Status: GOOD ( 18.86 ) X-BeenThere: linux-rockchip@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Upstream kernel work for Rockchip platforms List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "Linux-rockchip" Errors-To: linux-rockchip-bounces+linux-rockchip=archiver.kernel.org@lists.infradead.org We discovered that the state of BCLK on, LRCLK off and SD_MODE on may cause the speaker melting issue. Removing LRCLK while BCLK is present can cause unexpected output behavior including a large DC output voltage as described in the Max98357a datasheet. In order to: 1. prevent BCLK from turning on by other component. 2. keep BCLK and LRCLK being present at the same time This patch switches BCLK to GPIO func before LRCLK output, and configures BCLK func back during LRCLK is output. Without this fix, BCLK is turned on 11 ms earlier than LRCK by the da7219. With this fix, BCLK is turned on only 0.4 ms earlier than LRCK by the rockchip codec. Signed-off-by: Judy Hsiao Reviewed-by: Brian Norris --- sound/soc/rockchip/rockchip_i2s.c | 167 ++++++++++++++++++++++-------- 1 file changed, 121 insertions(+), 46 deletions(-) diff --git a/sound/soc/rockchip/rockchip_i2s.c b/sound/soc/rockchip/rockchip_i2s.c index 47a3971a9ce1..5e3cb06377a1 100644 --- a/sound/soc/rockchip/rockchip_i2s.c +++ b/sound/soc/rockchip/rockchip_i2s.c @@ -54,8 +54,38 @@ struct rk_i2s_dev { const struct rk_i2s_pins *pins; unsigned int bclk_ratio; spinlock_t lock; /* tx/rx lock */ + struct pinctrl *pinctrl; + struct pinctrl_state *bclk_on; + struct pinctrl_state *bclk_off; }; +static int i2s_pinctrl_select_bclk_on(struct rk_i2s_dev *i2s) +{ + int ret = 0; + + if (!IS_ERR(i2s->pinctrl) && !IS_ERR_OR_NULL(i2s->bclk_on)) + ret = pinctrl_select_state(i2s->pinctrl, i2s->bclk_on); + + if (ret) + dev_err(i2s->dev, "bclk enable failed %d\n", ret); + + return ret; +} + +static int i2s_pinctrl_select_bclk_off(struct rk_i2s_dev *i2s) +{ + + int ret = 0; + + if (!IS_ERR(i2s->pinctrl) && !IS_ERR_OR_NULL(i2s->bclk_off)) + ret = pinctrl_select_state(i2s->pinctrl, i2s->bclk_off); + + if (ret) + dev_err(i2s->dev, "bclk disable failed %d\n", ret); + + return ret; +} + static int i2s_runtime_suspend(struct device *dev) { struct rk_i2s_dev *i2s = dev_get_drvdata(dev); @@ -92,39 +122,46 @@ static inline struct rk_i2s_dev *to_info(struct snd_soc_dai *dai) return snd_soc_dai_get_drvdata(dai); } -static void rockchip_snd_txctrl(struct rk_i2s_dev *i2s, int on) +static int rockchip_snd_txctrl(struct rk_i2s_dev *i2s, int on) { unsigned int val = 0; int retry = 10; - + int ret = 0; + spin_lock(&i2s->lock); if (on) { - regmap_update_bits(i2s->regmap, I2S_DMACR, - I2S_DMACR_TDE_ENABLE, I2S_DMACR_TDE_ENABLE); - - regmap_update_bits(i2s->regmap, I2S_XFER, - I2S_XFER_TXS_START | I2S_XFER_RXS_START, - I2S_XFER_TXS_START | I2S_XFER_RXS_START); - + ret = regmap_update_bits(i2s->regmap, I2S_DMACR, + I2S_DMACR_TDE_ENABLE, I2S_DMACR_TDE_ENABLE); + if (ret < 0) + goto end; + ret = regmap_update_bits(i2s->regmap, I2S_XFER, + I2S_XFER_TXS_START | I2S_XFER_RXS_START, + I2S_XFER_TXS_START | I2S_XFER_RXS_START); + if (ret < 0) + goto end; i2s->tx_start = true; } else { i2s->tx_start = false; - regmap_update_bits(i2s->regmap, I2S_DMACR, - I2S_DMACR_TDE_ENABLE, I2S_DMACR_TDE_DISABLE); + ret = regmap_update_bits(i2s->regmap, I2S_DMACR, + I2S_DMACR_TDE_ENABLE, I2S_DMACR_TDE_DISABLE); + if (ret < 0) + goto end; if (!i2s->rx_start) { - regmap_update_bits(i2s->regmap, I2S_XFER, - I2S_XFER_TXS_START | - I2S_XFER_RXS_START, - I2S_XFER_TXS_STOP | - I2S_XFER_RXS_STOP); - + ret = regmap_update_bits(i2s->regmap, I2S_XFER, + I2S_XFER_TXS_START | + I2S_XFER_RXS_START, + I2S_XFER_TXS_STOP | + I2S_XFER_RXS_STOP); + if (ret < 0) + goto end; udelay(150); - regmap_update_bits(i2s->regmap, I2S_CLR, - I2S_CLR_TXC | I2S_CLR_RXC, - I2S_CLR_TXC | I2S_CLR_RXC); - + ret = regmap_update_bits(i2s->regmap, I2S_CLR, + I2S_CLR_TXC | I2S_CLR_RXC, + I2S_CLR_TXC | I2S_CLR_RXC); + if (ret < 0) + goto end; regmap_read(i2s->regmap, I2S_CLR, &val); /* Should wait for clear operation to finish */ @@ -138,42 +175,53 @@ static void rockchip_snd_txctrl(struct rk_i2s_dev *i2s, int on) } } } +end: spin_unlock(&i2s->lock); + if (ret < 0) + dev_err(i2s->dev, "lrclk update failed\n"); + + return ret; } static void rockchip_snd_rxctrl(struct rk_i2s_dev *i2s, int on) { unsigned int val = 0; int retry = 10; + int ret = 0; spin_lock(&i2s->lock); if (on) { - regmap_update_bits(i2s->regmap, I2S_DMACR, - I2S_DMACR_RDE_ENABLE, I2S_DMACR_RDE_ENABLE); - - regmap_update_bits(i2s->regmap, I2S_XFER, - I2S_XFER_TXS_START | I2S_XFER_RXS_START, - I2S_XFER_TXS_START | I2S_XFER_RXS_START); - + ret = regmap_update_bits(i2s->regmap, I2S_DMACR, + I2S_DMACR_RDE_ENABLE, I2S_DMACR_RDE_ENABLE); + if (ret < 0) + goto end; + + ret = regmap_update_bits(i2s->regmap, I2S_XFER, + I2S_XFER_TXS_START | I2S_XFER_RXS_START, + I2S_XFER_TXS_START | I2S_XFER_RXS_START); + if (ret < 0) + goto end; i2s->rx_start = true; } else { i2s->rx_start = false; - regmap_update_bits(i2s->regmap, I2S_DMACR, - I2S_DMACR_RDE_ENABLE, I2S_DMACR_RDE_DISABLE); + ret = regmap_update_bits(i2s->regmap, I2S_DMACR, + I2S_DMACR_RDE_ENABLE, I2S_DMACR_RDE_DISABLE); + if (ret < 0) + goto end; if (!i2s->tx_start) { - regmap_update_bits(i2s->regmap, I2S_XFER, - I2S_XFER_TXS_START | - I2S_XFER_RXS_START, - I2S_XFER_TXS_STOP | - I2S_XFER_RXS_STOP); - + ret = regmap_update_bits(i2s->regmap, I2S_XFER, + I2S_XFER_TXS_START | I2S_XFER_RXS_START, + I2S_XFER_TXS_STOP | I2S_XFER_RXS_STOP); + if (ret < 0) + goto end; udelay(150); - regmap_update_bits(i2s->regmap, I2S_CLR, - I2S_CLR_TXC | I2S_CLR_RXC, - I2S_CLR_TXC | I2S_CLR_RXC); - + ret = regmap_update_bits(i2s->regmap, I2S_CLR, + I2S_CLR_TXC | I2S_CLR_RXC, + I2S_CLR_TXC | I2S_CLR_RXC); + if (ret < 0) + goto end; regmap_read(i2s->regmap, I2S_CLR, &val); /* Should wait for clear operation to finish */ @@ -187,7 +235,12 @@ static void rockchip_snd_rxctrl(struct rk_i2s_dev *i2s, int on) } } } +end: spin_unlock(&i2s->lock); + if (ret < 0) + dev_err(i2s->dev, "lrclk update failed\n"); + + return ret; } static int rockchip_i2s_set_fmt(struct snd_soc_dai *cpu_dai, @@ -425,17 +478,25 @@ static int rockchip_i2s_trigger(struct snd_pcm_substream *substream, case SNDRV_PCM_TRIGGER_RESUME: case SNDRV_PCM_TRIGGER_PAUSE_RELEASE: if (substream->stream == SNDRV_PCM_STREAM_CAPTURE) - rockchip_snd_rxctrl(i2s, 1); + ret = rockchip_snd_rxctrl(i2s, 1); else - rockchip_snd_txctrl(i2s, 1); + ret = rockchip_snd_txctrl(i2s, 1); + if (ret < 0) + return ret; + i2s_pinctrl_select_bclk_on(i2s); break; case SNDRV_PCM_TRIGGER_SUSPEND: case SNDRV_PCM_TRIGGER_STOP: case SNDRV_PCM_TRIGGER_PAUSE_PUSH: - if (substream->stream == SNDRV_PCM_STREAM_CAPTURE) - rockchip_snd_rxctrl(i2s, 0); - else - rockchip_snd_txctrl(i2s, 0); + if (substream->stream == SNDRV_PCM_STREAM_CAPTURE) { + if (!i2s->tx_start) + i2s_pinctrl_select_bclk_off(i2s); + ret = rockchip_snd_rxctrl(i2s, 0); + } else { + if (!i2s->rx_start) + i2s_pinctrl_select_bclk_off(i2s); + ret = rockchip_snd_txctrl(i2s, 0); + } break; default: ret = -EINVAL; @@ -736,6 +797,20 @@ static int rockchip_i2s_probe(struct platform_device *pdev) } i2s->bclk_ratio = 64; + i2s->pinctrl = devm_pinctrl_get(&pdev->dev); + if (IS_ERR(i2s->pinctrl)) + dev_err(&pdev->dev, "failed to find i2s pinctrl\n"); + + i2s->bclk_on = pinctrl_lookup_state(i2s->pinctrl, "bclk_on"); + if (!IS_ERR_OR_NULL(i2s->bclk_on)) { + i2s->bclk_off = pinctrl_lookup_state(i2s->pinctrl, "bclk_off"); + if (IS_ERR_OR_NULL(i2s->bclk_off)) { + dev_err(&pdev->dev, "failed to find i2s bclk_off\n"); + goto err_clk; + } + } + + i2s_pinctrl_select_bclk_off(i2s); dev_set_drvdata(&pdev->dev, i2s); From patchwork Fri Jun 17 04:42:50 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Judy Hsiao X-Patchwork-Id: 12885083 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (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 CDD2EC43334 for ; Fri, 17 Jun 2022 04:43:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=03XuZi+5a4zuI3VInU9mhBouBfat72ou4ZCjgMU4NAU=; b=fC1m7JP5aeF8QL tx9FLfaCBNEoIixWoN73bm5Z+2X/eMnyMuULtH/iFM6IfI7UUogCepexGX2LQ1lig0yHG+DQsBm50 PC27NggafHxjAU7kiFsgvO8L+PKIATwo/GSmEEah0gZnDJbfENKzTaL6uP2TOTMLshlVWjLe/8TNf jxMXsfpt5rj50F6cQd+wr0YBnih99q2wx7wBaGXV+JogD99XEBjGRLbn0EsQjabpBqbF0arjEbf8G ttwK6ggHn2u27KBV6q3BN1/T6pSHd7EbfzyHXhQ2ixS1wV1gPkL937pWEzVtoWJr5I8daY/N5e07E aIJ79cN61wD/PNl5Ud4w==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1o23pT-005Sgl-HW; Fri, 17 Jun 2022 04:43:31 +0000 Received: from mail-pj1-x1030.google.com ([2607:f8b0:4864:20::1030]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1o23p4-005SWE-Qu for linux-rockchip@lists.infradead.org; Fri, 17 Jun 2022 04:43:08 +0000 Received: by mail-pj1-x1030.google.com with SMTP id g10-20020a17090a708a00b001ea8aadd42bso3223606pjk.0 for ; Thu, 16 Jun 2022 21:43:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=8Wxs+t8AydwdeN+7uxKuiteA2RZtEpmD8TRPNehIbXA=; b=BujGQWIgJyIOYZGwuzcY38wUuoThSD7buWCL2pX60I69wFEdu7+4sM97/CuuVe63UF kSOvoRLcEKVngTAEfeb9HcagtkZH/K6atNQO20UxjATp1F9eMvejLWdZpSGScvt3Fcff cONnKc9Kb6kUAiBd3BS9vm223Z6RhV6AUDdBo= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=8Wxs+t8AydwdeN+7uxKuiteA2RZtEpmD8TRPNehIbXA=; b=ckvYvoQOyH9mGRquSQZcvdUQxqe0EBbh+WQGQYrME1hzEi1Zg/fpfZCIyYBev0n/Wk ZqSMYZStd2ocQZl1FeWQ2iQ0D+m5AKgfCPm7qkMWQQGMUonvkfueJ6awsaRidQlPIxsy /ARqHsYGuIkc9NYhQtyPi8pI5LwrFXoQXAC0HPQXZQlFF8TZViYye9GtdwMs3Qwj5xlt H/iLD5tAQWHwlEwD6bgqNMQLQWMG+y8cA1TbJpqaTWkRLW07GRWor/uchIh6s21mjJoE 6uhq5FduECrs4WZQ206jkHxtA+DcZ7DyT8HiFzR8FOCjtIt9d1p+jAGohx8xi9WS69is 1vgw== X-Gm-Message-State: AJIora9sOulvo4/oFiFo+jLtDcJ2WIF2dqqUWi0w27e4VaS1Vxny/w/E B7h81CffqC0D0GhJpWwcLMPuaR1FiN+CGV8+ X-Google-Smtp-Source: AGRyM1s9wJKWUpL9MAnTnB+BbKU3V/LCXZui5P3kXeXzIVbNwKcGBtESmejkYk/lmWprL5Bn4LvPig== X-Received: by 2002:a17:90b:947:b0:1e8:9bd0:5420 with SMTP id dw7-20020a17090b094700b001e89bd05420mr8697939pjb.32.1655440985174; Thu, 16 Jun 2022 21:43:05 -0700 (PDT) Received: from judyhsiao0523.c.googlers.com.com (0.223.81.34.bc.googleusercontent.com. [34.81.223.0]) by smtp.gmail.com with ESMTPSA id v8-20020a17090a778800b001eab0a27d92sm4491030pjk.51.2022.06.16.21.43.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 16 Jun 2022 21:43:04 -0700 (PDT) From: Judy Hsiao To: Heiko Stuebner Cc: Liam Girdwood , Rob Herring , Brian Norris , Mark Brown , Jaroslav Kysela , Chen-Yu Tsai , alsa-devel@alsa-project.org, linux-arm-kernel@lists.infradead.org, linux-rockchip@lists.infradead.org, linux-kernel@vger.kernel.org, Judy Hsiao Subject: [PATCH v3 2/3] arm64: dts: rk3399: i2s: switch BCLK to GPIO Date: Fri, 17 Jun 2022 04:42:50 +0000 Message-Id: <20220617044251.4029697-3-judyhsiao@chromium.org> X-Mailer: git-send-email 2.36.1.476.g0c4daa206d-goog In-Reply-To: <20220617044251.4029697-1-judyhsiao@chromium.org> References: <20220616155836.3401420-1-judyhsiao@chromium.org> <20220617044251.4029697-1-judyhsiao@chromium.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220616_214306_921159_4A1AD230 X-CRM114-Status: GOOD ( 13.33 ) X-BeenThere: linux-rockchip@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Upstream kernel work for Rockchip platforms List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "Linux-rockchip" Errors-To: linux-rockchip-bounces+linux-rockchip=archiver.kernel.org@lists.infradead.org We discovered that the state of BCLK on, LRCLK off and SD_MODE on may cause the speaker melting issue. Removing LRCLK while BCLK is present can cause unexpected output behavior including a large DC output voltage as described in the Max98357a datasheet. In order to: 1. prevent BCLK from turning on by other component. 2. keep BCLK and LRCLK being present at the same time This patch adjusts the device tree to allow BCLK to switch to GPIO func before LRCLK output, and switch back during LRCLK is output. Signed-off-by: Judy Hsiao Reviewed-by: Brian Norris --- .../boot/dts/rockchip/rk3399-gru-scarlet.dtsi | 10 ++++++++ arch/arm64/boot/dts/rockchip/rk3399.dtsi | 25 ++++++++++++++++++- 2 files changed, 34 insertions(+), 1 deletion(-) diff --git a/arch/arm64/boot/dts/rockchip/rk3399-gru-scarlet.dtsi b/arch/arm64/boot/dts/rockchip/rk3399-gru-scarlet.dtsi index 913d845eb51a..df1647e9d487 100644 --- a/arch/arm64/boot/dts/rockchip/rk3399-gru-scarlet.dtsi +++ b/arch/arm64/boot/dts/rockchip/rk3399-gru-scarlet.dtsi @@ -766,6 +766,16 @@ &i2s0_8ch_bus { <4 RK_PA0 1 &pcfg_pull_none_6ma>; }; +&i2s0_8ch_bus_bclk_off { + rockchip,pins = + <3 RK_PD0 RK_FUNC_GPIO &pcfg_pull_none_6ma>, + <3 RK_PD1 1 &pcfg_pull_none_6ma>, + <3 RK_PD2 1 &pcfg_pull_none_6ma>, + <3 RK_PD3 1 &pcfg_pull_none_6ma>, + <3 RK_PD7 1 &pcfg_pull_none_6ma>, + <4 RK_PA0 1 &pcfg_pull_none_6ma>; +}; + /* there is no external pull up, so need to set this pin pull up */ &sdmmc_cd_pin { rockchip,pins = <1 RK_PB3 RK_FUNC_GPIO &pcfg_pull_up>; diff --git a/arch/arm64/boot/dts/rockchip/rk3399.dtsi b/arch/arm64/boot/dts/rockchip/rk3399.dtsi index fbd0346624e6..311c8394cc84 100644 --- a/arch/arm64/boot/dts/rockchip/rk3399.dtsi +++ b/arch/arm64/boot/dts/rockchip/rk3399.dtsi @@ -1662,8 +1662,9 @@ i2s0: i2s@ff880000 { dma-names = "tx", "rx"; clock-names = "i2s_clk", "i2s_hclk"; clocks = <&cru SCLK_I2S0_8CH>, <&cru HCLK_I2S0_8CH>; - pinctrl-names = "default"; + pinctrl-names = "bclk_on", "bclk_off"; pinctrl-0 = <&i2s0_8ch_bus>; + pinctrl-1 = <&i2s0_8ch_bus_bclk_off>; power-domains = <&power RK3399_PD_SDIOAUDIO>; #sound-dai-cells = <0>; status = "disabled"; @@ -2407,6 +2408,19 @@ i2s0_8ch_bus: i2s0-8ch-bus { <3 RK_PD7 1 &pcfg_pull_none>, <4 RK_PA0 1 &pcfg_pull_none>; }; + + i2s0_8ch_bus_bclk_off: i2s0-8ch-bus-bclk-off { + rockchip,pins = + <3 RK_PD0 RK_FUNC_GPIO &pcfg_pull_none>, + <3 RK_PD1 1 &pcfg_pull_none>, + <3 RK_PD2 1 &pcfg_pull_none>, + <3 RK_PD3 1 &pcfg_pull_none>, + <3 RK_PD4 1 &pcfg_pull_none>, + <3 RK_PD5 1 &pcfg_pull_none>, + <3 RK_PD6 1 &pcfg_pull_none>, + <3 RK_PD7 1 &pcfg_pull_none>, + <4 RK_PA0 1 &pcfg_pull_none>; + }; }; i2s1 { @@ -2418,6 +2432,15 @@ i2s1_2ch_bus: i2s1-2ch-bus { <4 RK_PA6 1 &pcfg_pull_none>, <4 RK_PA7 1 &pcfg_pull_none>; }; + + i2s1_2ch_bus_bclk_off: i2s1-2ch-bus-bclk-off { + rockchip,pins = + <4 RK_PA3 RK_FUNC_GPIO &pcfg_pull_none>, + <4 RK_PA4 1 &pcfg_pull_none>, + <4 RK_PA5 1 &pcfg_pull_none>, + <4 RK_PA6 1 &pcfg_pull_none>, + <4 RK_PA7 1 &pcfg_pull_none>; + }; }; sdio0 { From patchwork Fri Jun 17 04:42:51 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Judy Hsiao X-Patchwork-Id: 12885084 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (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 285C8C433EF for ; Fri, 17 Jun 2022 04:43:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=Qz2XhVt4vBT2foEpteBT25Ppa2AIh8UJz472kmt6oLE=; b=npbjHesXJe0AF4 /Ns6ACeZQVCKPTKZVJ8LpCdk4EHbZLb0qRmrNM3mzMMqX2HNJpmWOV2+m90nlHgpf3dVRYLFfKM8J 1HiHApbhWiPkchOdBACqGT/MKDp1of6jolQdjwjbFIHsX7cUGgRgP/cwktVOpHJRsNbPR8AfvhRaF kTxn9atEGVK7R9f9lR18mEp/cFJEWn9EPVn9DO3e3u14Yl3DsRW93JQW07g8tBWx/SYK+PjEbd54V /mGRio+LoGxHYQe0z5TsVsP+X5ToqH2upIR6a2rx8GusMeHMQWx3lrtUWiqVTqeH0obktWkb8/TWA qVwd2cMUGAa2Oluewpkw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1o23pU-005ShI-FS; Fri, 17 Jun 2022 04:43:32 +0000 Received: from mail-pl1-x633.google.com ([2607:f8b0:4864:20::633]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1o23p8-005SXZ-55 for linux-rockchip@lists.infradead.org; Fri, 17 Jun 2022 04:43:11 +0000 Received: by mail-pl1-x633.google.com with SMTP id d5so2909280plo.12 for ; Thu, 16 Jun 2022 21:43:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=2fjP9Be4hnegvsgOyWKGbkMNBDmKFNmzp11PphlEg+I=; b=IZdqemgjM011t7qSaeazGC5ggc3b5p1NDSvXtc+PuYsJrlv/olkGHyV8kaSghNi7KW 9TzKTQfhxWc31HVBifhIwFyTieKiEnksb0h9otWk5FFg9Xky6MpqgNSfBT8Am+60SFNX N/FsTDI5dlR673K0ktxd/t1h8azx7yqqJpME4= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=2fjP9Be4hnegvsgOyWKGbkMNBDmKFNmzp11PphlEg+I=; b=NyPUw97+6gWOmHaF/XZDn/x1AXi4tKJ8iI+1y9fgP8M4GkYd7m6d57WhkORN3jql5K BW7oSpfHRMfwhnwX83qkLJMVDVQYmQPvnuLV51lcLfYYY3G+JXWGRHQ79LjqE/YXZ4JN RnqBtYJFZoqK1enjBMQbpy+wly2wVml8Mo/O+Q7qaka/6H558hXEQnfP3vM89J0Z4gX3 ys8gs6ulpuA9li1NisbjBB67Bkj8SJtLYJ9Mzry2F9ajcloamc8dmMwmiB5cCQnSBaY0 9A9MaB2MpHBrg92VY5tCP8oPCJ+IroPQZPp9gUuLpYwJ6Bm4VRG+gKRDwqjNrfm68UvT /6rw== X-Gm-Message-State: AJIora+46/dhfUsjbgE7vB07CUPskvSNgsPRvAW6IUFa/JhyBjqQYTKi oHVLzMEkQETrkotc2QuJTGY7HA== X-Google-Smtp-Source: AGRyM1vLs55QXCgklZT2ekRxVqDn+icjviHTpjMZkA9w+4RQE27UUTrD8lRbDtZ8X4JwMc8QXD9xGQ== X-Received: by 2002:a17:902:9b83:b0:164:59e:b189 with SMTP id y3-20020a1709029b8300b00164059eb189mr7540998plp.91.1655440988545; Thu, 16 Jun 2022 21:43:08 -0700 (PDT) Received: from judyhsiao0523.c.googlers.com.com (0.223.81.34.bc.googleusercontent.com. [34.81.223.0]) by smtp.gmail.com with ESMTPSA id v8-20020a17090a778800b001eab0a27d92sm4491030pjk.51.2022.06.16.21.43.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 16 Jun 2022 21:43:08 -0700 (PDT) From: Judy Hsiao To: Heiko Stuebner Cc: Liam Girdwood , Rob Herring , Brian Norris , Mark Brown , Jaroslav Kysela , Chen-Yu Tsai , alsa-devel@alsa-project.org, linux-arm-kernel@lists.infradead.org, linux-rockchip@lists.infradead.org, linux-kernel@vger.kernel.org, Judy Hsiao Subject: [PATCH v3 3/3] ASoC: dt-bindings: rockchip: Document pinctrl-names for i2s Date: Fri, 17 Jun 2022 04:42:51 +0000 Message-Id: <20220617044251.4029697-4-judyhsiao@chromium.org> X-Mailer: git-send-email 2.36.1.476.g0c4daa206d-goog In-Reply-To: <20220617044251.4029697-1-judyhsiao@chromium.org> References: <20220616155836.3401420-1-judyhsiao@chromium.org> <20220617044251.4029697-1-judyhsiao@chromium.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220616_214310_258380_48818EC8 X-CRM114-Status: UNSURE ( 8.35 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-rockchip@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Upstream kernel work for Rockchip platforms List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "Linux-rockchip" Errors-To: linux-rockchip-bounces+linux-rockchip=archiver.kernel.org@lists.infradead.org This patch documents pinctrl-names for i2s. Signed-off-by: Judy Hsiao --- Documentation/devicetree/bindings/sound/rockchip-i2s.yaml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Documentation/devicetree/bindings/sound/rockchip-i2s.yaml b/Documentation/devicetree/bindings/sound/rockchip-i2s.yaml index 5ea16b8ef93f..7e36e389e976 100644 --- a/Documentation/devicetree/bindings/sound/rockchip-i2s.yaml +++ b/Documentation/devicetree/bindings/sound/rockchip-i2s.yaml @@ -61,6 +61,13 @@ properties: - const: tx - const: rx + pinctrl-names: + oneOf: + - const: default + - items: + - const: bclk_on + - const: bclk_off + power-domains: maxItems: 1