From patchwork Thu Mar 11 15:15:51 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Osipenko X-Patchwork-Id: 397778 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4C2F2C433E0 for ; Thu, 11 Mar 2021 15:17:54 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id EE84464FD6 for ; Thu, 11 Mar 2021 15:17:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233892AbhCKPRW (ORCPT ); Thu, 11 Mar 2021 10:17:22 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41412 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234045AbhCKPRB (ORCPT ); Thu, 11 Mar 2021 10:17:01 -0500 Received: from mail-lj1-x231.google.com (mail-lj1-x231.google.com [IPv6:2a00:1450:4864:20::231]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 24239C061760; Thu, 11 Mar 2021 07:17:01 -0800 (PST) Received: by mail-lj1-x231.google.com with SMTP id y1so2608690ljm.10; Thu, 11 Mar 2021 07:17:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=yx3Rm9jzGKCPBq80QBACsTq0WbETqkrvY2ZCaXbwiog=; b=fdhn0cqNtOGsS+FkhNuEYVxjrSNMfJN4/JT3nvRRNLIuX7pIJBZ0K43szPsgcx6SLo LKe3pbvvqUUM6G7Oa5IEOc6qlqpQyoBW2+oB0XjGJ5QtXYppa6ZBeNt2JB67BWGgaQGa EPj1Nlp3goLM8PpN+gDy0eu1XHUSr0GZ1Mx8zP3plBON9ZgaDwPfvT9QFY/9ZDYakXcP +xDR6gjJ6R9UQwf/MTRDZo02hTWejhJpfwKJCIc6MIiQC1MpFw2gEcGhIM/8TzbtzuOe leq5JZtNnTTeeaPwsnOLfzInW1m1vHueuVyBquiN3iArLbvaSiY5rx4zkMZ4+HdzRBkN ip8Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=yx3Rm9jzGKCPBq80QBACsTq0WbETqkrvY2ZCaXbwiog=; b=n079i5ikjYVxNf4yepZ+N30XOSEgSEjA8YhbplZjW8ov6mOUHn2Uf5CpaZsW4qpdew ab/jCfoNnLQMR/dbBNayREPkoqhpoNijxJ+RE7oooI2Ui/FQ0dcJOP0sBg+Z2w0dhF65 CXN1gS2X5gQZYu4cayMmQ2SogIz++nkoT320XIbSj99eWWBzcCxh8AnqaDf2sgVnJYd4 4XuwbFuYL6SDoREtezD2wFglzUSsFP4czOaV70iNpS5v5Z+tqj9VVEA0c1Y4XOkyBNFi WHjuK6QUYPz1EBqSF2T8RYoTQLPUBofCfMHdqNUge4oWq6FTS10Zu4TxYrzlrsjRrpfc 3Qbg== X-Gm-Message-State: AOAM5335uBMjDjY5x8BLQdgKIzGNtfPyEyTNonECwxheQ93SSafLrECF j3dsqWEOaNmohHSyxJXdf/4= X-Google-Smtp-Source: ABdhPJyv0BJfQc+9voAuMRFcGPw/Ohlw89GvLQ+5ElSAYE6VDCUOyEllSt41MCcTEueBj/O1O6g/UQ== X-Received: by 2002:a2e:8047:: with SMTP id p7mr5326159ljg.8.1615475819663; Thu, 11 Mar 2021 07:16:59 -0800 (PST) Received: from localhost.localdomain (109-252-193-52.dynamic.spd-mgts.ru. [109.252.193.52]) by smtp.gmail.com with ESMTPSA id m24sm923138lfq.184.2021.03.11.07.16.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Mar 2021 07:16:59 -0800 (PST) From: Dmitry Osipenko To: Thierry Reding , Jonathan Hunter , Mark Brown , Takashi Iwai , Jaroslav Kysela , Philipp Zabel , Paul Fertser Cc: alsa-devel@alsa-project.org, devicetree@vger.kernel.org, linux-tegra@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 2/5] ASoC: tegra20: i2s: Add reset control Date: Thu, 11 Mar 2021 18:15:51 +0300 Message-Id: <20210311151554.23982-3-digetx@gmail.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210311151554.23982-1-digetx@gmail.com> References: <20210311151554.23982-1-digetx@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org The I2S reset may be asserted at a boot time, in particular this is the case on Tegra20 AC100 netbook. Tegra20 I2S driver doesn't manage the reset control and currently it happens to work because reset is implicitly deasserted by the tegra-clk driver when I2S clock is enabled. The I2S permanently stays in a reset once tegra-clk is fixed to not touch the resets, which it shouldn't be doing. Add reset control to the Tegra20 I2S driver. Note that I2S reset was always specified in Tegra20 device-tree, hence DTB ABI changes aren't required. Tested-by: Paul Fertser # T20 AC100 Reported-by: Paul Fertser Signed-off-by: Dmitry Osipenko --- sound/soc/tegra/tegra20_i2s.c | 31 +++++++++++++++++++++++++++++++ sound/soc/tegra/tegra20_i2s.h | 1 + 2 files changed, 32 insertions(+) diff --git a/sound/soc/tegra/tegra20_i2s.c b/sound/soc/tegra/tegra20_i2s.c index d7a3d046c8f8..c0af5352b483 100644 --- a/sound/soc/tegra/tegra20_i2s.c +++ b/sound/soc/tegra/tegra20_i2s.c @@ -22,6 +22,7 @@ #include #include #include +#include #include #include #include @@ -37,6 +38,8 @@ static int tegra20_i2s_runtime_suspend(struct device *dev) { struct tegra20_i2s *i2s = dev_get_drvdata(dev); + regcache_cache_only(i2s->regmap, true); + clk_disable_unprepare(i2s->clk_i2s); return 0; @@ -47,13 +50,35 @@ static int tegra20_i2s_runtime_resume(struct device *dev) struct tegra20_i2s *i2s = dev_get_drvdata(dev); int ret; + ret = reset_control_assert(i2s->reset); + if (ret) + return ret; + ret = clk_prepare_enable(i2s->clk_i2s); if (ret) { dev_err(dev, "clk_enable failed: %d\n", ret); return ret; } + usleep_range(10, 100); + + ret = reset_control_deassert(i2s->reset); + if (ret) + goto disable_clocks; + + regcache_cache_only(i2s->regmap, false); + regcache_mark_dirty(i2s->regmap); + + ret = regcache_sync(i2s->regmap); + if (ret) + goto disable_clocks; + return 0; + +disable_clocks: + clk_disable_unprepare(i2s->clk_i2s); + + return ret; } static int tegra20_i2s_set_fmt(struct snd_soc_dai *dai, @@ -339,6 +364,12 @@ static int tegra20_i2s_platform_probe(struct platform_device *pdev) i2s->dai = tegra20_i2s_dai_template; i2s->dai.name = dev_name(&pdev->dev); + i2s->reset = devm_reset_control_get_exclusive(&pdev->dev, "i2s"); + if (IS_ERR(i2s->reset)) { + dev_err(&pdev->dev, "Can't retrieve i2s reset\n"); + return PTR_ERR(i2s->reset); + } + i2s->clk_i2s = clk_get(&pdev->dev, NULL); if (IS_ERR(i2s->clk_i2s)) { dev_err(&pdev->dev, "Can't retrieve i2s clock\n"); diff --git a/sound/soc/tegra/tegra20_i2s.h b/sound/soc/tegra/tegra20_i2s.h index 628d3ca09f42..8233e5fa2eff 100644 --- a/sound/soc/tegra/tegra20_i2s.h +++ b/sound/soc/tegra/tegra20_i2s.h @@ -144,6 +144,7 @@ struct tegra20_i2s { struct snd_dmaengine_dai_dma_data capture_dma_data; struct snd_dmaengine_dai_dma_data playback_dma_data; struct regmap *regmap; + struct reset_control *reset; }; #endif