From patchwork Thu Mar 11 17:42:59 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Osipenko X-Patchwork-Id: 398743 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=-13.7 required=3.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, DKIM_VALID, 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=unavailable 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 7A78CC433DB for ; Thu, 11 Mar 2021 17:46:42 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id AB6C264E77 for ; Thu, 11 Mar 2021 17:46:41 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org AB6C264E77 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=alsa-devel-bounces@alsa-project.org 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 0B95B1750; Thu, 11 Mar 2021 18:45:50 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 0B95B1750 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1615484800; bh=j4aUPdKiYoXEoNs6zvEijyuS4laHxmQHyZetALal37k=; h=From:To:Subject:Date:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=WGgwRLc71zRBh/S1j6sJ3nZl1Q5Nx+gFXESX/Vk5iCrF8xQySsw0A9Bx2p5G8Wntx r8QNiu4/YPzuH48oEgk2gF1R/KS52SXVb/p+wVze8d2YejUXH5nlDvhxx/0lkwa+Ke z2ABgB/2MZPuHVqLKkDfB6zyAmmeZPwT1pt77ZRg= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id D6711F804AD; Thu, 11 Mar 2021 18:43:40 +0100 (CET) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 9B75CF804AA; Thu, 11 Mar 2021 18:43:36 +0100 (CET) Received: from mail-lf1-x132.google.com (mail-lf1-x132.google.com [IPv6:2a00:1450:4864:20::132]) (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 461D6F802D2 for ; Thu, 11 Mar 2021 18:43:14 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 461D6F802D2 Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="ncmLWICc" Received: by mail-lf1-x132.google.com with SMTP id x4so34455895lfu.7 for ; Thu, 11 Mar 2021 09:43:14 -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=ncmLWICcV/ueLUTt4miizhqzcPLhFPWMuCwm6Wvnn4Fuexvsjv5PGhi7fuNQodHWzZ Kr42xSGHaL71hOg8vnUVxEEWOPyVxDyyLb8PDgPISlDn5Fgar9f5L4HGpq8/1umKz4nJ i5ajGHqRdqrv2Ghkje7/Egwj1Exbtvu09v9bqqDXlbP1gRHe0kdzca0+hPtZiT98j6My lyjzc743VrhggXuNxuOoEuP9GsKo7+DEqJMxnIHtk4cMK1pMI2SoOF2jnc9OL0kuR6mZ PyovLu9WEPa4OvU3sSyrrZca1aqNU6j2mhhD6sSOkqI0MeIOUpjKeeTHEovZyjEFSAC2 c6Og== 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=BeKUmJNOsTMpZ15O4L7ykWh5tcwkR995vM6sTfvr7t4KIy3f39VjIdwF/MYocFpb3S QyAUl+6EWkg+IQ/oQiz0ljXm/P54g8eY2vtubAKcPPT4VCwTsBN3DM6PRbdAa2LJh5TE non+LwUvCuNWVy5MczlaXbMk/pdWJFYpymHL8Re1I8b0vZwWo3iWEtFEVRCvEaL7W3EP HqbIeeITCgeUYjcJLIl9vHYa8HrS3MrJGcDVYA4QZ8kK7oNO+Tcvo1z48gQ6aBneDkJA DMfb1ATo782aR2A4OBT/YweyoAWzg1dflwfmdmRAEGhkxcKOxcUmhXUA8lKpbEQGlIzb QDGg== X-Gm-Message-State: AOAM533Mz9m3PnMC0FzTRM+e9DomUBd/wZ51f8BvZrIc3ZFNLx8V41Hw fqJZytPfv9hVOF/3n5v4VcvkgL91IzY= X-Google-Smtp-Source: ABdhPJx77qEmgld5IVk3yUglYrcFPBmRtlD+rxMWWSZzDCIAzCF7Voj0tGD0X0Jo2Nk0/zMo+G3X/Q== X-Received: by 2002:ac2:4896:: with SMTP id x22mr2936884lfc.565.1615484593543; Thu, 11 Mar 2021 09:43:13 -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 g10sm1021245lfe.90.2021.03.11.09.43.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Mar 2021 09:43:13 -0800 (PST) From: Dmitry Osipenko To: Thierry Reding , Jonathan Hunter , Mark Brown , Takashi Iwai , Jaroslav Kysela , Philipp Zabel , Paul Fertser Subject: [PATCH v3 2/5] ASoC: tegra20: i2s: Add reset control Date: Thu, 11 Mar 2021 20:42:59 +0300 Message-Id: <20210311174302.15430-3-digetx@gmail.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210311174302.15430-1-digetx@gmail.com> References: <20210311174302.15430-1-digetx@gmail.com> MIME-Version: 1.0 Cc: linux-tegra@vger.kernel.org, devicetree@vger.kernel.org, alsa-devel@alsa-project.org, linux-kernel@vger.kernel.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" 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