From mboxrd@z Thu Jan 1 00:00:00 1970 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 6095CC43334 for ; Fri, 17 Jun 2022 20:47:51 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id B400D1EEB; Fri, 17 Jun 2022 22:46:59 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz B400D1EEB DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1655498869; bh=TQiIgCKLuC256bxvH2syv5jjB9OeKvNN9su4b4GkcAk=; h=Date:From:To:Subject:References:In-Reply-To:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=DHM8vVo7MhnEeYrpsCvp1xmf8VX5+STnF+cnyyy5AZSOVuNS9/3VerZEkdg6FOwdB PZr//Ra/o1m7kJLfYYoUJEOFB9bEjpO9OVy5a1r9c53+qC3i3SS04eCBbHxgiXETiu oawGUJ0JKqWZyBS709nhqDk2dHv3+GiIPtEdy9w8= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 4F5CBF8051F; Fri, 17 Jun 2022 22:46:59 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 3DC45F80527; Fri, 17 Jun 2022 22:46:58 +0200 (CEST) Received: from mail-pg1-x52c.google.com (mail-pg1-x52c.google.com [IPv6:2607:f8b0:4864:20::52c]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id CE6C4F800B0 for ; Fri, 17 Jun 2022 22:46:51 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz CE6C4F800B0 Authentication-Results: alsa1.perex.cz; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="lSFDDXp8" Received: by mail-pg1-x52c.google.com with SMTP id 193so2139072pgc.2 for ; Fri, 17 Jun 2022 13:46:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=GXaclX1FL0h8CGb7nidVOvl5KYslHnP1qP5vHuFEg/o=; b=lSFDDXp8fJxd3k1/NPPifUGgBLPdaE22CTJKPLAyp43SGjKFomXAGiePTZ42BlIrJh odqD9O7PRMXQHJrgctB/Y5S4MWjuJgaJD8WmZ8sebu3eFFWTXjdDxTbzEMVwKQUMkU4q U6exfnONG79nydNKJedyEQ72Xcs+9MEgrbF4s= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=GXaclX1FL0h8CGb7nidVOvl5KYslHnP1qP5vHuFEg/o=; b=Veymkfyh2ivRzPoQgni53FLvfZzTRDYK/j82o8bYbOBulDg2v4ZXCAI/MkVfPRbf9e hfwl9StMpgNEoXChnVW7oAaBM0sJnj4NwCiP+m8HBUXMNGDCWsWEUSOfZSXh/fWci5+F PaX2/GZywww2BthEFIwzJxxcvE5qS/sAKHJNY/Cmm4HvBK6fJj6NSiNuIpQCs3mXkABJ AeTnEqrLelqDXhGtxonXGUmq6P31XuSJxylqo3qKHEUhBXDPMNKddO470nxV5LGLPUab UIo6d7F7fqkHLEmCDtSQ8a6oyHYThg8yrghIXPeoA4vis9+SuN/+8al4iqnRcikjOSM7 +k0w== X-Gm-Message-State: AJIora+kQbYrGTatiQAWxRig7z6ik/1Jrqvm/twSS5fToZ3RG12CPl/N lCPTZMrJJqlPX8zXMfZeKSwncw== X-Google-Smtp-Source: AGRyM1tK3U/ZG9n4Mvxa/4Mm4J4wxTavnLkXJYks8NkYt9StAA0o/gzzGm6jYf7ZHj2JUirJCeCBHg== X-Received: by 2002:a05:6a00:b8c:b0:51c:2d3d:4595 with SMTP id g12-20020a056a000b8c00b0051c2d3d4595mr11829256pfj.80.1655498809321; Fri, 17 Jun 2022 13:46:49 -0700 (PDT) Received: from google.com ([2620:15c:202:201:6844:cedc:a28c:44b2]) by smtp.gmail.com with ESMTPSA id p7-20020a17090a428700b001e2f383110bsm5904549pjg.11.2022.06.17.13.46.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 17 Jun 2022 13:46:48 -0700 (PDT) Date: Fri, 17 Jun 2022 13:46:46 -0700 From: Brian Norris To: Judy Hsiao Subject: Re: [PATCH v3 1/3] ASoC: rockchip: i2s: switch BCLK to GPIO Message-ID: References: <20220616155836.3401420-1-judyhsiao@chromium.org> <20220617044251.4029697-1-judyhsiao@chromium.org> <20220617044251.4029697-2-judyhsiao@chromium.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220617044251.4029697-2-judyhsiao@chromium.org> Cc: alsa-devel@alsa-project.org, Heiko Stuebner , linux-kernel@vger.kernel.org, Liam Girdwood , Rob Herring , linux-rockchip@lists.infradead.org, Mark Brown , Chen-Yu Tsai , linux-arm-kernel@lists.infradead.org X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 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: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" Hi, On Fri, Jun 17, 2022 at 04:42:49AM +0000, Judy Hsiao wrote: > 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 > --- > 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 > @@ -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); This still isn't how I'd expect the indentation to look, but I think I will stop complaining about whitespace. Maybe you can either use 'clang-format' (sparingly), or else see what Mark thinks. > + if (ret < 0) > + goto end; > i2s->tx_start = true; > } else { > i2s->tx_start = false; > ... > static void rockchip_snd_rxctrl(struct rk_i2s_dev *i2s, int on) I didn't think I needed to call this out, because you already got build bots complaining about this, but... ...did you even compile-test this? You should be making this function return 'int', not 'void', because you're adding return values below. > { > unsigned int val = 0; > int retry = 10; > + int ret = 0; > ... > +end: > spin_unlock(&i2s->lock); > + if (ret < 0) > + dev_err(i2s->dev, "lrclk update failed\n"); > + > + return ret; ^^ here. > } > > static int rockchip_i2s_set_fmt(struct snd_soc_dai *cpu_dai, Aside from those, I think this looks OK to the best of my (not-very-familiar with sounds/soc/) ability: Reviewed-by: Brian Norris From mboxrd@z Thu Jan 1 00:00:00 1970 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 B21A2C433EF for ; Fri, 17 Jun 2022 21:08:11 +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:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=vap/RObWJ9zJ7YtVsr0uydwAx2qEg9YPsGBsUK8+6WM=; b=D/rYn0iSKyOq/4 AecTUl9wG58rIiNj2pa60dGMLI9fdWK3UBWg59lQkQFnpdZruSPqtFCls7S+bDmtRcpWC/nUD0a3w JLmGGs5F4ceJ84RZovqD3EoQeoCCR6VNYq3Q9kC083HfvppeRAfoLcyVVjqTit2HMMY/crUZSEd3c QaqDkQ59TB0pRHwLWfcSn68dMfry01tejlhfG0o9C12sdXT6m/kDGW9qpRu+M/y9LkHjZOrWvoAXE +if/K6wwlGmUWPVV8IxSjsBREP9MJlhFb5IP4K87EgeVx8l53TFfAzUb80AucgVQo9alSkef2nDng 9knV6yzFXUishFr6weHg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1o2JC7-0098jE-5A; Fri, 17 Jun 2022 21:07:55 +0000 Received: from mail-pg1-x52d.google.com ([2607:f8b0:4864:20::52d]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1o2Irk-0092AE-3N for linux-rockchip@lists.infradead.org; Fri, 17 Jun 2022 20:46:53 +0000 Received: by mail-pg1-x52d.google.com with SMTP id f65so4967200pgc.7 for ; Fri, 17 Jun 2022 13:46:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=GXaclX1FL0h8CGb7nidVOvl5KYslHnP1qP5vHuFEg/o=; b=lSFDDXp8fJxd3k1/NPPifUGgBLPdaE22CTJKPLAyp43SGjKFomXAGiePTZ42BlIrJh odqD9O7PRMXQHJrgctB/Y5S4MWjuJgaJD8WmZ8sebu3eFFWTXjdDxTbzEMVwKQUMkU4q U6exfnONG79nydNKJedyEQ72Xcs+9MEgrbF4s= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=GXaclX1FL0h8CGb7nidVOvl5KYslHnP1qP5vHuFEg/o=; b=fzv5TPoxKai7Yo00bgSPBXOc6eTLWWZXPWgYt/jUB/fI91VdE55u2HCpYn6i6RyBsq udmLzie4f1VlpsROqxbd4rSSNZ68Itbn1fFsafMyUVcOO7R2EDptrPV6JZ/HFXW9DxIl b9Zc5H51GvTghcHKGRE92aRxgfQhl98fViFZEUTByZu5i+gYvpCjhPiRfA9LICBJz1rU 3vaa68R4JW19PlAs/i4CgH7XB/lRTucL9Qi53/fTRO0q+rLy1UU8Ol5hxhBoD0HCe0NY MIC3UKhsYi2tV0bZwPJriZdGh7MV4mtMVqCRyanxrzM+VLLcSqQgYlpwUKTzIOFvD8F5 Qhkw== X-Gm-Message-State: AJIora+UGQiTgsysmqGY+8OPjJ5m0DWpmUYWqDWyQ2TdSX5jzyHZrlVv V7HEqROs85++yztJ7Oc2YMtanw== X-Google-Smtp-Source: AGRyM1tK3U/ZG9n4Mvxa/4Mm4J4wxTavnLkXJYks8NkYt9StAA0o/gzzGm6jYf7ZHj2JUirJCeCBHg== X-Received: by 2002:a05:6a00:b8c:b0:51c:2d3d:4595 with SMTP id g12-20020a056a000b8c00b0051c2d3d4595mr11829256pfj.80.1655498809321; Fri, 17 Jun 2022 13:46:49 -0700 (PDT) Received: from google.com ([2620:15c:202:201:6844:cedc:a28c:44b2]) by smtp.gmail.com with ESMTPSA id p7-20020a17090a428700b001e2f383110bsm5904549pjg.11.2022.06.17.13.46.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 17 Jun 2022 13:46:48 -0700 (PDT) Date: Fri, 17 Jun 2022 13:46:46 -0700 From: Brian Norris To: Judy Hsiao Cc: Heiko Stuebner , Liam Girdwood , Rob Herring , 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 Subject: Re: [PATCH v3 1/3] ASoC: rockchip: i2s: switch BCLK to GPIO Message-ID: References: <20220616155836.3401420-1-judyhsiao@chromium.org> <20220617044251.4029697-1-judyhsiao@chromium.org> <20220617044251.4029697-2-judyhsiao@chromium.org> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20220617044251.4029697-2-judyhsiao@chromium.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220617_134652_208032_AEB5CE5C X-CRM114-Status: GOOD ( 27.29 ) 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: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "Linux-rockchip" Errors-To: linux-rockchip-bounces+linux-rockchip=archiver.kernel.org@lists.infradead.org Hi, On Fri, Jun 17, 2022 at 04:42:49AM +0000, Judy Hsiao wrote: > 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 > --- > 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 > @@ -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); This still isn't how I'd expect the indentation to look, but I think I will stop complaining about whitespace. Maybe you can either use 'clang-format' (sparingly), or else see what Mark thinks. > + if (ret < 0) > + goto end; > i2s->tx_start = true; > } else { > i2s->tx_start = false; > ... > static void rockchip_snd_rxctrl(struct rk_i2s_dev *i2s, int on) I didn't think I needed to call this out, because you already got build bots complaining about this, but... ...did you even compile-test this? You should be making this function return 'int', not 'void', because you're adding return values below. > { > unsigned int val = 0; > int retry = 10; > + int ret = 0; > ... > +end: > spin_unlock(&i2s->lock); > + if (ret < 0) > + dev_err(i2s->dev, "lrclk update failed\n"); > + > + return ret; ^^ here. > } > > static int rockchip_i2s_set_fmt(struct snd_soc_dai *cpu_dai, Aside from those, I think this looks OK to the best of my (not-very-familiar with sounds/soc/) ability: Reviewed-by: Brian Norris _______________________________________________ Linux-rockchip mailing list Linux-rockchip@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-rockchip From mboxrd@z Thu Jan 1 00:00:00 1970 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 700B2C43334 for ; Fri, 17 Jun 2022 21:09:20 +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:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=v/g7I1HTnLZGgqAF3vBt5WHav1orZo74sN77Sfo1tRU=; b=vw60HcinAfS7XV UjZe/QnbPjYcRChxym5nx9yDRD2OgmuQIIq5ecFul84NR4SWiwLgTCgMw7sUFHs5qln5qNHIMypUj McGeNBjE27yddyL1a5p6/8Hf4BkZYhbKIDcaZhGeXHFlXIndGjYAztARqEct8O+OaOPIHzKKsa1bw BqsRWyMgBrUXu5nqqgBlVfuuGQgRgTaa0ij/bHG38M3U6DpCzTVSaavvqr0jZCvshmyCP0A2Y4SWQ OEQmLCchj4faZheAeQQWyWBIg9CSpvC42pMxSpvyEPO6sQfTAyKPoN3KA4yrdJNAZmzbwCELnU2NF iIrQmjnbDxAQyPPzKiBA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1o2JCA-0098kh-R8; Fri, 17 Jun 2022 21:07:59 +0000 Received: from mail-pg1-x529.google.com ([2607:f8b0:4864:20::529]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1o2Irk-0092AD-AO for linux-arm-kernel@lists.infradead.org; Fri, 17 Jun 2022 20:46:54 +0000 Received: by mail-pg1-x529.google.com with SMTP id 184so4955262pga.12 for ; Fri, 17 Jun 2022 13:46:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=GXaclX1FL0h8CGb7nidVOvl5KYslHnP1qP5vHuFEg/o=; b=lSFDDXp8fJxd3k1/NPPifUGgBLPdaE22CTJKPLAyp43SGjKFomXAGiePTZ42BlIrJh odqD9O7PRMXQHJrgctB/Y5S4MWjuJgaJD8WmZ8sebu3eFFWTXjdDxTbzEMVwKQUMkU4q U6exfnONG79nydNKJedyEQ72Xcs+9MEgrbF4s= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=GXaclX1FL0h8CGb7nidVOvl5KYslHnP1qP5vHuFEg/o=; b=ukWL7ZIkR/7ZuxGFQAiLVT0e2M5xiZ3trquYeReNQlIqWLDqkG/mpUclnXqkEkSADK lNM/SUBITKeX8qaBYIXBCTv4L8M08fyn8Elzy7xAki37thMEEtTW59k+/h5P41Q4d1rw vtsrdeBtAzgVpEBOUqJ7XvB1m133vXf0loAytcyizMAMZITWwg0eyzXE7Jpww8wTqRLl rOiWUC2H6/4jWZAOpe4rdMIGr8aEZqmHxXEC8xHFozKUTf4ZK5bUulEp0Kzf0y0iGmic bGya9Asw9gDrwdVdwNHS5pN0snAYzNYnFC1OI983hp8+dVEnsaSiS4rUIijpFr8aXcLb VpKQ== X-Gm-Message-State: AJIora9OXqp5IYF/YW5qKgjA3h76vsCEcrO0xwqbmTBgf0AfH1PEcDJ2 TAj2qTkHGOhI4+v9mtKHNHkMUg== X-Google-Smtp-Source: AGRyM1tK3U/ZG9n4Mvxa/4Mm4J4wxTavnLkXJYks8NkYt9StAA0o/gzzGm6jYf7ZHj2JUirJCeCBHg== X-Received: by 2002:a05:6a00:b8c:b0:51c:2d3d:4595 with SMTP id g12-20020a056a000b8c00b0051c2d3d4595mr11829256pfj.80.1655498809321; Fri, 17 Jun 2022 13:46:49 -0700 (PDT) Received: from google.com ([2620:15c:202:201:6844:cedc:a28c:44b2]) by smtp.gmail.com with ESMTPSA id p7-20020a17090a428700b001e2f383110bsm5904549pjg.11.2022.06.17.13.46.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 17 Jun 2022 13:46:48 -0700 (PDT) Date: Fri, 17 Jun 2022 13:46:46 -0700 From: Brian Norris To: Judy Hsiao Cc: Heiko Stuebner , Liam Girdwood , Rob Herring , 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 Subject: Re: [PATCH v3 1/3] ASoC: rockchip: i2s: switch BCLK to GPIO Message-ID: References: <20220616155836.3401420-1-judyhsiao@chromium.org> <20220617044251.4029697-1-judyhsiao@chromium.org> <20220617044251.4029697-2-judyhsiao@chromium.org> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20220617044251.4029697-2-judyhsiao@chromium.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220617_134652_439252_070BE5AF X-CRM114-Status: GOOD ( 28.28 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Hi, On Fri, Jun 17, 2022 at 04:42:49AM +0000, Judy Hsiao wrote: > 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 > --- > 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 > @@ -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); This still isn't how I'd expect the indentation to look, but I think I will stop complaining about whitespace. Maybe you can either use 'clang-format' (sparingly), or else see what Mark thinks. > + if (ret < 0) > + goto end; > i2s->tx_start = true; > } else { > i2s->tx_start = false; > ... > static void rockchip_snd_rxctrl(struct rk_i2s_dev *i2s, int on) I didn't think I needed to call this out, because you already got build bots complaining about this, but... ...did you even compile-test this? You should be making this function return 'int', not 'void', because you're adding return values below. > { > unsigned int val = 0; > int retry = 10; > + int ret = 0; > ... > +end: > spin_unlock(&i2s->lock); > + if (ret < 0) > + dev_err(i2s->dev, "lrclk update failed\n"); > + > + return ret; ^^ here. > } > > static int rockchip_i2s_set_fmt(struct snd_soc_dai *cpu_dai, Aside from those, I think this looks OK to the best of my (not-very-familiar with sounds/soc/) ability: Reviewed-by: Brian Norris _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel From mboxrd@z Thu Jan 1 00:00:00 1970 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id A9D6BC433EF for ; Fri, 17 Jun 2022 20:46:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244943AbiFQUqx (ORCPT ); Fri, 17 Jun 2022 16:46:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52640 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234461AbiFQUqu (ORCPT ); Fri, 17 Jun 2022 16:46:50 -0400 Received: from mail-pf1-x432.google.com (mail-pf1-x432.google.com [IPv6:2607:f8b0:4864:20::432]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D54D458E5F for ; Fri, 17 Jun 2022 13:46:49 -0700 (PDT) Received: by mail-pf1-x432.google.com with SMTP id w21so5128835pfc.0 for ; Fri, 17 Jun 2022 13:46:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=GXaclX1FL0h8CGb7nidVOvl5KYslHnP1qP5vHuFEg/o=; b=lSFDDXp8fJxd3k1/NPPifUGgBLPdaE22CTJKPLAyp43SGjKFomXAGiePTZ42BlIrJh odqD9O7PRMXQHJrgctB/Y5S4MWjuJgaJD8WmZ8sebu3eFFWTXjdDxTbzEMVwKQUMkU4q U6exfnONG79nydNKJedyEQ72Xcs+9MEgrbF4s= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=GXaclX1FL0h8CGb7nidVOvl5KYslHnP1qP5vHuFEg/o=; b=W68mlgHoQC7o+PLg5JEPyHLfjcZROayf51Y/BK559YCOzgxfzoWCo22jkzd0WSa49d wDUfslaqg9DqheM61LMBrja//8Zuin8+x2mCKwAIqyu9zD9RgJZAropmWDvIZcGd5jHg 8pFvLBmC9uX1/FlBDCDOnTDSf8GH3ceDP+9ch4JWa66uHnd2ZSaC3yGBVYhcvtVxvV4J BpvfI+luUTCp5tSAQ/YS6mJPmW4FVdwRpFTggjpNVHymk9L0ILIy4RJX3d5L5QrlFHsI UPjrAVJW4a0uyoQU34jso60wa6at0wqzYgHSfT0VWo//4cx1Hz2epiOxpNobPmREka0i 7FXw== X-Gm-Message-State: AJIora/34uNJnEjCOeqqDsSGa6wlMWul/+5Gx895cE0nwY40ldOIc/KF WfeDpJlOJ5FMarwrr0GzSvROsQ== X-Google-Smtp-Source: AGRyM1tK3U/ZG9n4Mvxa/4Mm4J4wxTavnLkXJYks8NkYt9StAA0o/gzzGm6jYf7ZHj2JUirJCeCBHg== X-Received: by 2002:a05:6a00:b8c:b0:51c:2d3d:4595 with SMTP id g12-20020a056a000b8c00b0051c2d3d4595mr11829256pfj.80.1655498809321; Fri, 17 Jun 2022 13:46:49 -0700 (PDT) Received: from google.com ([2620:15c:202:201:6844:cedc:a28c:44b2]) by smtp.gmail.com with ESMTPSA id p7-20020a17090a428700b001e2f383110bsm5904549pjg.11.2022.06.17.13.46.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 17 Jun 2022 13:46:48 -0700 (PDT) Date: Fri, 17 Jun 2022 13:46:46 -0700 From: Brian Norris To: Judy Hsiao Cc: Heiko Stuebner , Liam Girdwood , Rob Herring , 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 Subject: Re: [PATCH v3 1/3] ASoC: rockchip: i2s: switch BCLK to GPIO Message-ID: References: <20220616155836.3401420-1-judyhsiao@chromium.org> <20220617044251.4029697-1-judyhsiao@chromium.org> <20220617044251.4029697-2-judyhsiao@chromium.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220617044251.4029697-2-judyhsiao@chromium.org> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi, On Fri, Jun 17, 2022 at 04:42:49AM +0000, Judy Hsiao wrote: > 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 > --- > 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 > @@ -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); This still isn't how I'd expect the indentation to look, but I think I will stop complaining about whitespace. Maybe you can either use 'clang-format' (sparingly), or else see what Mark thinks. > + if (ret < 0) > + goto end; > i2s->tx_start = true; > } else { > i2s->tx_start = false; > ... > static void rockchip_snd_rxctrl(struct rk_i2s_dev *i2s, int on) I didn't think I needed to call this out, because you already got build bots complaining about this, but... ...did you even compile-test this? You should be making this function return 'int', not 'void', because you're adding return values below. > { > unsigned int val = 0; > int retry = 10; > + int ret = 0; > ... > +end: > spin_unlock(&i2s->lock); > + if (ret < 0) > + dev_err(i2s->dev, "lrclk update failed\n"); > + > + return ret; ^^ here. > } > > static int rockchip_i2s_set_fmt(struct snd_soc_dai *cpu_dai, Aside from those, I think this looks OK to the best of my (not-very-familiar with sounds/soc/) ability: Reviewed-by: Brian Norris