From patchwork Tue Jan 12 12:58:30 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Osipenko X-Patchwork-Id: 362194 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 998ABC433E0 for ; Tue, 12 Jan 2021 13:02:01 +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 EA7422310F for ; Tue, 12 Jan 2021 13:02:00 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org EA7422310F 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 67ADA1721; Tue, 12 Jan 2021 14:01:09 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 67ADA1721 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1610456519; bh=4eHETLlufxvXXHNhZ8mTFPnqcGDwqgep9kbOxfa9XfE=; h=From:To:Subject:Date:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=Y2CjkLO62kltAoACFyuJ3WM5sHDtywfeO+WJQFsF5ak7g54HF3otyvXftzhkCOkNj hRyRLVaOkX+CMOgZ4UraMCfMyXFaORwTnbGxMygXNgBUKyCHAJb71FrCoysRKeE/5D GkPiqFITZBAn4+YmG99zU4TD2XmE3bFtgn/DXyxA= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 716FBF804ED; Tue, 12 Jan 2021 13:59:37 +0100 (CET) Received: by alsa1.perex.cz (Postfix, from userid 50401) id C4995F804E3; Tue, 12 Jan 2021 13:59:31 +0100 (CET) Received: from mail-lj1-x22b.google.com (mail-lj1-x22b.google.com [IPv6:2a00:1450:4864:20::22b]) (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 79537F804D8 for ; Tue, 12 Jan 2021 13:59:28 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 79537F804D8 Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Be+mTIPt" Received: by mail-lj1-x22b.google.com with SMTP id y22so2700445ljn.9 for ; Tue, 12 Jan 2021 04:59:27 -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=U1RnP9fDqxuGuZO3p6OVv1kBuZCep9lrHH2HK3m142A=; b=Be+mTIPt6Au0v1PqAmS31FaJ0sTmRzMY9Xd+IV1+DnrSVFUQf+z4NoyF+xu6C+4uIN Jb7vprZloh3evByiRo3D/x4SHRh87jcFIWPYRFloK6Igmlhky8UdXnL80uAzzR/tU6c1 ceW3wluhmqRpPvAI7CUBYAxcByKmbM1+zGk34G5dgrA/JoR2W8yLcMIvMkeM5Ym0Jq1I WtfKNHTL8G3B4eEcDhZWDnwLXzBOUK/J4gFbHIN0if2/vEy0h1uCG9o1B/ODIOdJXQnQ wzWLqeVDSj4Zs0UvOR1zVvZHG9nacOnw82W1FFWxj7Budx7tfMygevywNt2gAQhKi+Hx X5lQ== 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=U1RnP9fDqxuGuZO3p6OVv1kBuZCep9lrHH2HK3m142A=; b=AxWeYwbq99DRZdUEkY1lE6mrGxQanUJYnGiEJFPv4lxm1si8dS3vMiKBPf6N2OuQ12 Jb9IwNC1u0vWk52Zag2GIaWpT9Ldop6q+zLedg4yDqhvoUees2GJ6f5M2a2PhhZYB7QO FZxzIfUZSTCKZJw9Af2y1p94dlTMjTME2DY8k1X/nEWirDBgzx707+/yWbo6rDiDQ8Rf huN7fVk8L4pvlkzfFNZDjXRtovfCKKyOBHaPhiJLcgB5rjlr8SGgmEfAfNFYHQv7yM/9 Yavd4hfERVEBqHZvdkSLYl+pGM+pWE6A1d9bVWQ2ycGwX8QSZNkCn52t4aKgLp+Cikq3 FNLg== X-Gm-Message-State: AOAM5322fOLRx52U2jVCB7pAbasVEP/pBmjBzKldRjTCryYsGRiF8iDg OhUfNe2p5C6Akw9TL6VFXxc= X-Google-Smtp-Source: ABdhPJw4grk6GjPtZB2Ufck6pVcNJxP481ZSHWVuteTcIsfAJMKXJ+W+tdtJwlCX0rdYfDZNAt9PsA== X-Received: by 2002:a2e:6818:: with SMTP id c24mr2126208lja.184.1610456362442; Tue, 12 Jan 2021 04:59:22 -0800 (PST) Received: from localhost.localdomain (109-252-192-57.dynamic.spd-mgts.ru. [109.252.192.57]) by smtp.gmail.com with ESMTPSA id 192sm384211lfa.219.2021.01.12.04.59.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Jan 2021 04:59:22 -0800 (PST) From: Dmitry Osipenko To: Thierry Reding , Jonathan Hunter , Sameer Pujar , Peter Geis , Nicolas Chauvet , Takashi Iwai , Jaroslav Kysela Subject: [PATCH v1 1/5] ALSA: hda/tegra: Use clk_bulk helpers Date: Tue, 12 Jan 2021 15:58:30 +0300 Message-Id: <20210112125834.21545-2-digetx@gmail.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210112125834.21545-1-digetx@gmail.com> References: <20210112125834.21545-1-digetx@gmail.com> MIME-Version: 1.0 Cc: linux-tegra@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" Use clk_bulk helpers to make code cleaner. Tested-by: Peter Geis Tested-by: Nicolas Chauvet Signed-off-by: Dmitry Osipenko Acked-by: Thierry Reding --- sound/pci/hda/hda_tegra.c | 68 ++++++--------------------------------- 1 file changed, 9 insertions(+), 59 deletions(-) diff --git a/sound/pci/hda/hda_tegra.c b/sound/pci/hda/hda_tegra.c index 70164d1428d4..4c799661c2f6 100644 --- a/sound/pci/hda/hda_tegra.c +++ b/sound/pci/hda/hda_tegra.c @@ -70,9 +70,8 @@ struct hda_tegra { struct azx chip; struct device *dev; - struct clk *hda_clk; - struct clk *hda2codec_2x_clk; - struct clk *hda2hdmi_clk; + struct clk_bulk_data clocks[3]; + unsigned int nclocks; void __iomem *regs; struct work_struct probe_work; }; @@ -113,36 +112,6 @@ static void hda_tegra_init(struct hda_tegra *hda) writel(v, hda->regs + HDA_IPFS_INTR_MASK); } -static int hda_tegra_enable_clocks(struct hda_tegra *data) -{ - int rc; - - rc = clk_prepare_enable(data->hda_clk); - if (rc) - return rc; - rc = clk_prepare_enable(data->hda2codec_2x_clk); - if (rc) - goto disable_hda; - rc = clk_prepare_enable(data->hda2hdmi_clk); - if (rc) - goto disable_codec_2x; - - return 0; - -disable_codec_2x: - clk_disable_unprepare(data->hda2codec_2x_clk); -disable_hda: - clk_disable_unprepare(data->hda_clk); - return rc; -} - -static void hda_tegra_disable_clocks(struct hda_tegra *data) -{ - clk_disable_unprepare(data->hda2hdmi_clk); - clk_disable_unprepare(data->hda2codec_2x_clk); - clk_disable_unprepare(data->hda_clk); -} - /* * power management */ @@ -186,7 +155,7 @@ static int __maybe_unused hda_tegra_runtime_suspend(struct device *dev) azx_stop_chip(chip); azx_enter_link_reset(chip); } - hda_tegra_disable_clocks(hda); + clk_bulk_disable_unprepare(hda->nclocks, hda->clocks); return 0; } @@ -198,7 +167,7 @@ static int __maybe_unused hda_tegra_runtime_resume(struct device *dev) struct hda_tegra *hda = container_of(chip, struct hda_tegra, chip); int rc; - rc = hda_tegra_enable_clocks(hda); + rc = clk_bulk_prepare_enable(hda->nclocks, hda->clocks); if (rc != 0) return rc; if (chip && chip->running) { @@ -268,29 +237,6 @@ static int hda_tegra_init_chip(struct azx *chip, struct platform_device *pdev) return 0; } -static int hda_tegra_init_clk(struct hda_tegra *hda) -{ - struct device *dev = hda->dev; - - hda->hda_clk = devm_clk_get(dev, "hda"); - if (IS_ERR(hda->hda_clk)) { - dev_err(dev, "failed to get hda clock\n"); - return PTR_ERR(hda->hda_clk); - } - hda->hda2codec_2x_clk = devm_clk_get(dev, "hda2codec_2x"); - if (IS_ERR(hda->hda2codec_2x_clk)) { - dev_err(dev, "failed to get hda2codec_2x clock\n"); - return PTR_ERR(hda->hda2codec_2x_clk); - } - hda->hda2hdmi_clk = devm_clk_get(dev, "hda2hdmi"); - if (IS_ERR(hda->hda2hdmi_clk)) { - dev_err(dev, "failed to get hda2hdmi clock\n"); - return PTR_ERR(hda->hda2hdmi_clk); - } - - return 0; -} - static int hda_tegra_first_init(struct azx *chip, struct platform_device *pdev) { struct hda_tegra *hda = container_of(chip, struct hda_tegra, chip); @@ -495,7 +441,11 @@ static int hda_tegra_probe(struct platform_device *pdev) return err; } - err = hda_tegra_init_clk(hda); + hda->clocks[hda->nclocks++].id = "hda"; + hda->clocks[hda->nclocks++].id = "hda2hdmi"; + hda->clocks[hda->nclocks++].id = "hda2codec_2x"; + + err = devm_clk_bulk_get(&pdev->dev, hda->nclocks, hda->clocks); if (err < 0) goto out_free; From patchwork Tue Jan 12 12:58:31 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Osipenko X-Patchwork-Id: 361259 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=-10.9 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, UNWANTED_LANGUAGE_BODY,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 79064C433DB for ; Tue, 12 Jan 2021 13:01:05 +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 BBDEE2310F for ; Tue, 12 Jan 2021 13:01:04 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org BBDEE2310F 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 E1C2F171B; Tue, 12 Jan 2021 14:00:12 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz E1C2F171B DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1610456463; bh=mRMTNIjb3rF7gdibI515Rx9WhGRO+QKnRbTP5NwnX1M=; h=From:To:Subject:Date:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=VkbgrgTsrTGGWbJCTiMpd2O6iKqpn0Kh2WJS3E0iGNl45KZ8wDbG7j+83B/p76hCP JpjSGJPLInoAHnBdEuk68711WFJl9wZ0HwIbzTre+Yi0NEp5LXzu23ZaYpdYbB1tPr kA+MZe4MsR/Sp7lOLHV32JF1dnMrxqaaCx/l0Glw= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id EDEA5F804DF; Tue, 12 Jan 2021 13:59:30 +0100 (CET) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 2E81CF804AB; Tue, 12 Jan 2021 13:59:27 +0100 (CET) Received: from mail-lf1-x134.google.com (mail-lf1-x134.google.com [IPv6:2a00:1450:4864:20::134]) (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 1CCD5F804AB for ; Tue, 12 Jan 2021 13:59:23 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 1CCD5F804AB Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="H368JGk7" Received: by mail-lf1-x134.google.com with SMTP id u25so3246332lfc.2 for ; Tue, 12 Jan 2021 04:59:23 -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=lg8D+6k5px/5X05zXz+RxGeDF297I8gzkoxsJjGQbFo=; b=H368JGk7iitiesfWx27XMaxrW3JztEyAntacKIDIzEvx4fBR2dR3M9bQ4t3j5plvCF G3euq9OBw5FVVxBx5VeX8I5FjyR935xO8+LJLWPfwfIFcNwYnhSMOjUyiICyuFbWOiIn dIhW/zSJmJQNN6c64J/oWNUQjpafNa77LEABfVtI1ijhOhCD8V0wB9tFISPZSo9APbrJ LhJMBYbRDfq0+BDsNcpxfYL8B/ecivFdq/UHD/e5JOthDmm6yhiM8EvHX8PJ6VPQnFAa Fmkr5DM6ZrD2VfmmPbz0hLLWoKhLawAKiv0MwgNNOoUF9i8NmBUkljQd0On7pU2NVYBG VWxA== 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=lg8D+6k5px/5X05zXz+RxGeDF297I8gzkoxsJjGQbFo=; b=SXGL+fv9e1a0aLDJSzqJS/S4hBgNS5kHskwk/4vZgRIQzz3WkH0PbK3VESna5uVisS 5YinGPg/5MlPUFS5XQpUGRQxVz0WeHFulYjGWDRqazRe+zLCIrfIM+w+IEJHnKWJyDJW gJAWfS2L1ArJfcKowSy94TII3Kr/Fdl3RnqN2ZMw7pb+uKfWqBHIvody0zXZ7Qy/MkjJ pZcs3AUjFX7KfRpIKI0n+10b25Or40VGD9+u0yIWemlJ4Aa2gThCmuvLVROwd5cDJ2l8 kutnMRB83luWj2XXs0rB24s688ZFb+G74nASJaQ/Akavk1Ym5161lF71enbDdxu+04zZ B09w== X-Gm-Message-State: AOAM530c/9z+CLR+hyh0LDqcjqeTc1X8op1v50zmJCvWh4TOPRF92gXs NdtA7+C7wsIsTpMZV/Il188= X-Google-Smtp-Source: ABdhPJxuONy2OXLST4ArDFBkn4J6Yegat6lHb2aCHoJzj6SLlnQmMD6UEqiQLnFGX7uycRMM3Jqphw== X-Received: by 2002:ac2:5612:: with SMTP id v18mr2242856lfd.584.1610456363250; Tue, 12 Jan 2021 04:59:23 -0800 (PST) Received: from localhost.localdomain (109-252-192-57.dynamic.spd-mgts.ru. [109.252.192.57]) by smtp.gmail.com with ESMTPSA id 192sm384211lfa.219.2021.01.12.04.59.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Jan 2021 04:59:22 -0800 (PST) From: Dmitry Osipenko To: Thierry Reding , Jonathan Hunter , Sameer Pujar , Peter Geis , Nicolas Chauvet , Takashi Iwai , Jaroslav Kysela Subject: [PATCH v1 2/5] ALSA: hda/tegra: Reset hardware Date: Tue, 12 Jan 2021 15:58:31 +0300 Message-Id: <20210112125834.21545-3-digetx@gmail.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210112125834.21545-1-digetx@gmail.com> References: <20210112125834.21545-1-digetx@gmail.com> MIME-Version: 1.0 Cc: linux-tegra@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" Reset hardware in order to bring it into a predictable state. Tested-by: Peter Geis Tested-by: Nicolas Chauvet Signed-off-by: Dmitry Osipenko --- sound/pci/hda/hda_tegra.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/sound/pci/hda/hda_tegra.c b/sound/pci/hda/hda_tegra.c index 4c799661c2f6..e406b7980f31 100644 --- a/sound/pci/hda/hda_tegra.c +++ b/sound/pci/hda/hda_tegra.c @@ -17,6 +17,7 @@ #include #include #include +#include #include #include #include @@ -70,6 +71,7 @@ struct hda_tegra { struct azx chip; struct device *dev; + struct reset_control *reset; struct clk_bulk_data clocks[3]; unsigned int nclocks; void __iomem *regs; @@ -167,6 +169,12 @@ static int __maybe_unused hda_tegra_runtime_resume(struct device *dev) struct hda_tegra *hda = container_of(chip, struct hda_tegra, chip); int rc; + if (!(chip && chip->running)) { + rc = reset_control_assert(hda->reset); + if (rc) + return rc; + } + rc = clk_bulk_prepare_enable(hda->nclocks, hda->clocks); if (rc != 0) return rc; @@ -176,6 +184,10 @@ static int __maybe_unused hda_tegra_runtime_resume(struct device *dev) /* disable controller wake up event*/ azx_writew(chip, WAKEEN, azx_readw(chip, WAKEEN) & ~STATESTS_INT_MASK); + } else { + rc = reset_control_reset(hda->reset); + if (rc) + return rc; } return 0; @@ -441,6 +453,12 @@ static int hda_tegra_probe(struct platform_device *pdev) return err; } + hda->reset = devm_reset_control_array_get_exclusive(&pdev->dev); + if (IS_ERR(hda->reset)) { + err = PTR_ERR(hda->reset); + goto out_free; + } + hda->clocks[hda->nclocks++].id = "hda"; hda->clocks[hda->nclocks++].id = "hda2hdmi"; hda->clocks[hda->nclocks++].id = "hda2codec_2x"; From patchwork Tue Jan 12 12:58:32 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Osipenko X-Patchwork-Id: 361258 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 BAA0EC433DB for ; Tue, 12 Jan 2021 13:01:51 +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 1A82C2310F for ; Tue, 12 Jan 2021 13:01:51 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 1A82C2310F 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 8150D16E3; Tue, 12 Jan 2021 14:00:59 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 8150D16E3 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1610456509; bh=oSU07iLhTNAcmZSgB3NWPXYbLE3v52HEQa49sGvP590=; h=From:To:Subject:Date:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=aIA4wfeYR2c+UK38aGVFPIkq6OOKwieQcqEhKK8rFdID865BUvpRzLqXHTC4ziE1t HpHbCBJbSf30Zxqh/JnsHvAg8vx2A3c6rUy9LHwG+n1P7A597mBy6lPVeP0Ocom8gm +NhWLllIA8Yh0nLvQQ0vs0mOzkrkhY3FIM4iIuSs= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 795B8F804E6; Tue, 12 Jan 2021 13:59:34 +0100 (CET) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 16918F804E1; Tue, 12 Jan 2021 13:59:30 +0100 (CET) Received: from mail-lf1-x12e.google.com (mail-lf1-x12e.google.com [IPv6:2a00:1450:4864:20::12e]) (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 C8E74F804AB for ; Tue, 12 Jan 2021 13:59:24 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz C8E74F804AB Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="eZFDw+8/" Received: by mail-lf1-x12e.google.com with SMTP id s26so3202702lfc.8 for ; Tue, 12 Jan 2021 04:59:24 -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=nOG+laR8Z5VOVTmF6Sy12FrgatG6zkwMpzVTv/S/8wI=; b=eZFDw+8/9/u7p+6fE1KA+XuOc6IySAthr3QWG7sQ9wciyLXHwxqPmnd2TBj2rmiMA/ kvkYSkCtyWfbYYR1GhkIQIja6M0n4ZdDQkPxNXYonpGg2ZpbTT6nv4rHoLtcnmsAOn7v 1a2pHxVLGmfZLtEfZbIRID2BIWylr3NOpnlH5hewfUN4WbbvXpkSsSH61ojjBcxot+/3 Pbn/OIix7bCWfJvKDiDs7HmH4d2g5Ogh87fuKFDiKNJfiAjy6oFM+xrKiOvroIv50097 fy6k2sTEeR0n5K2wzW3BT4iYqxel3GONb5JkzWRwq18luiUVjKAkFhnB2dRMATPo3rkq f6ig== 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=nOG+laR8Z5VOVTmF6Sy12FrgatG6zkwMpzVTv/S/8wI=; b=Trhj6ZgnQZYYVuY2JjWfNUzlxAUIL4362TPbQI2huseT2fwU4G50MR7opDv2q/gI2V jPzhr8JvWZJvqmAWrr+fc3TELtGFNPcVIqrH46NrZiZbTMvqx/zr7vh0/PTQ1ggXrw6N n9AMve/NCMrnmhz3CZPeMsVQ7Gjsrc4+iExp70VMO0YcqdxqR2vAIlQMNaLHAIOuxcsc A2kC9EYZn3GclEuvvaj+H+dN8rVLcsAA7Fz7zDNy3lm/xH1IO1xonSSuoe3qfIFXe1TR Mby+B15jCS+iSM3av5TePWIEQduZUJJyLF68px/ipf0HRxLNoKLMdEuebQHYiTsjXYB6 Cvfw== X-Gm-Message-State: AOAM5307K0x2cORM4vDwKc86UUcDeQZZXXdFGCNZLwbj5M0zmyGGv194 Mxk+Lb4cPHbDJxcUWsr871Q= X-Google-Smtp-Source: ABdhPJzlh6OOuLbC8EC9OmOQTflk2L6Zk58HxRZ5bEDEI01eSz/ACM8jjB2rGcDt9/JBGJJ+N95Smg== X-Received: by 2002:a19:6447:: with SMTP id b7mr2135081lfj.206.1610456364216; Tue, 12 Jan 2021 04:59:24 -0800 (PST) Received: from localhost.localdomain (109-252-192-57.dynamic.spd-mgts.ru. [109.252.192.57]) by smtp.gmail.com with ESMTPSA id 192sm384211lfa.219.2021.01.12.04.59.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Jan 2021 04:59:23 -0800 (PST) From: Dmitry Osipenko To: Thierry Reding , Jonathan Hunter , Sameer Pujar , Peter Geis , Nicolas Chauvet , Takashi Iwai , Jaroslav Kysela Subject: [PATCH v1 3/5] ASoC: tegra: ahub: Use of_reset_control_array_get_exclusive() Date: Tue, 12 Jan 2021 15:58:32 +0300 Message-Id: <20210112125834.21545-4-digetx@gmail.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210112125834.21545-1-digetx@gmail.com> References: <20210112125834.21545-1-digetx@gmail.com> MIME-Version: 1.0 Cc: linux-tegra@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" Some of resets are erroneously missed in the configlink_mods[], like APBIF for example. Use of_reset_control_array_get_exclusive() which requests all the resets. The problem was hidden by the clk driver which implicitly de-asserts the missing resets. Tested-by: Peter Geis Tested-by: Nicolas Chauvet Signed-off-by: Dmitry Osipenko --- sound/soc/tegra/tegra30_ahub.c | 66 +++++----------------------------- sound/soc/tegra/tegra30_ahub.h | 1 - 2 files changed, 9 insertions(+), 58 deletions(-) diff --git a/sound/soc/tegra/tegra30_ahub.c b/sound/soc/tegra/tegra30_ahub.c index 156e3b9d613c..1e9767c75b11 100644 --- a/sound/soc/tegra/tegra30_ahub.c +++ b/sound/soc/tegra/tegra30_ahub.c @@ -323,41 +323,6 @@ int tegra30_ahub_unset_rx_cif_source(enum tegra30_ahub_rxcif rxcif) } EXPORT_SYMBOL_GPL(tegra30_ahub_unset_rx_cif_source); -#define MOD_LIST_MASK_TEGRA30 BIT(0) -#define MOD_LIST_MASK_TEGRA114 BIT(1) -#define MOD_LIST_MASK_TEGRA124 BIT(2) - -#define MOD_LIST_MASK_TEGRA30_OR_LATER \ - (MOD_LIST_MASK_TEGRA30 | MOD_LIST_MASK_TEGRA114 | \ - MOD_LIST_MASK_TEGRA124) -#define MOD_LIST_MASK_TEGRA114_OR_LATER \ - (MOD_LIST_MASK_TEGRA114 | MOD_LIST_MASK_TEGRA124) - -static const struct { - const char *rst_name; - u32 mod_list_mask; -} configlink_mods[] = { - { "i2s0", MOD_LIST_MASK_TEGRA30_OR_LATER }, - { "i2s1", MOD_LIST_MASK_TEGRA30_OR_LATER }, - { "i2s2", MOD_LIST_MASK_TEGRA30_OR_LATER }, - { "i2s3", MOD_LIST_MASK_TEGRA30_OR_LATER }, - { "i2s4", MOD_LIST_MASK_TEGRA30_OR_LATER }, - { "dam0", MOD_LIST_MASK_TEGRA30_OR_LATER }, - { "dam1", MOD_LIST_MASK_TEGRA30_OR_LATER }, - { "dam2", MOD_LIST_MASK_TEGRA30_OR_LATER }, - { "spdif", MOD_LIST_MASK_TEGRA30_OR_LATER }, - { "amx", MOD_LIST_MASK_TEGRA114_OR_LATER }, - { "adx", MOD_LIST_MASK_TEGRA114_OR_LATER }, - { "amx1", MOD_LIST_MASK_TEGRA124 }, - { "adx1", MOD_LIST_MASK_TEGRA124 }, - { "afc0", MOD_LIST_MASK_TEGRA124 }, - { "afc1", MOD_LIST_MASK_TEGRA124 }, - { "afc2", MOD_LIST_MASK_TEGRA124 }, - { "afc3", MOD_LIST_MASK_TEGRA124 }, - { "afc4", MOD_LIST_MASK_TEGRA124 }, - { "afc5", MOD_LIST_MASK_TEGRA124 }, -}; - #define LAST_REG(name) \ (TEGRA30_AHUB_##name + \ (TEGRA30_AHUB_##name##_STRIDE * TEGRA30_AHUB_##name##_COUNT) - 4) @@ -484,17 +449,14 @@ static const struct regmap_config tegra30_ahub_ahub_regmap_config = { }; static struct tegra30_ahub_soc_data soc_data_tegra30 = { - .mod_list_mask = MOD_LIST_MASK_TEGRA30, .set_audio_cif = tegra30_ahub_set_cif, }; static struct tegra30_ahub_soc_data soc_data_tegra114 = { - .mod_list_mask = MOD_LIST_MASK_TEGRA114, .set_audio_cif = tegra30_ahub_set_cif, }; static struct tegra30_ahub_soc_data soc_data_tegra124 = { - .mod_list_mask = MOD_LIST_MASK_TEGRA124, .set_audio_cif = tegra124_ahub_set_cif, }; @@ -510,7 +472,6 @@ static int tegra30_ahub_probe(struct platform_device *pdev) const struct of_device_id *match; const struct tegra30_ahub_soc_data *soc_data; struct reset_control *rst; - int i; struct resource *res0; void __iomem *regs_apbif, *regs_ahub; int ret = 0; @@ -528,26 +489,17 @@ static int tegra30_ahub_probe(struct platform_device *pdev) * operate correctly, all devices on this bus must be out of reset. * Ensure that here. */ - for (i = 0; i < ARRAY_SIZE(configlink_mods); i++) { - if (!(configlink_mods[i].mod_list_mask & - soc_data->mod_list_mask)) - continue; - - rst = reset_control_get_exclusive(&pdev->dev, - configlink_mods[i].rst_name); - if (IS_ERR(rst)) { - dev_err(&pdev->dev, "Can't get reset %s\n", - configlink_mods[i].rst_name); - ret = PTR_ERR(rst); - return ret; - } - - ret = reset_control_deassert(rst); - reset_control_put(rst); - if (ret) - return ret; + rst = of_reset_control_array_get_exclusive(pdev->dev.of_node); + if (IS_ERR(rst)) { + dev_err(&pdev->dev, "Can't get reset: %p\n", rst); + return PTR_ERR(rst); } + ret = reset_control_deassert(rst); + reset_control_put(rst); + if (ret) + return ret; + ahub = devm_kzalloc(&pdev->dev, sizeof(struct tegra30_ahub), GFP_KERNEL); if (!ahub) diff --git a/sound/soc/tegra/tegra30_ahub.h b/sound/soc/tegra/tegra30_ahub.h index 6889c5f23d02..5a2500b4ea06 100644 --- a/sound/soc/tegra/tegra30_ahub.h +++ b/sound/soc/tegra/tegra30_ahub.h @@ -491,7 +491,6 @@ void tegra124_ahub_set_cif(struct regmap *regmap, unsigned int reg, struct tegra30_ahub_cif_conf *conf); struct tegra30_ahub_soc_data { - u32 mod_list_mask; void (*set_audio_cif)(struct regmap *regmap, unsigned int reg, struct tegra30_ahub_cif_conf *conf); From patchwork Tue Jan 12 12:58:33 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Osipenko X-Patchwork-Id: 362195 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 AEBA6C433DB for ; Tue, 12 Jan 2021 13:01:17 +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 0640123117 for ; Tue, 12 Jan 2021 13:01:16 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 0640123117 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 6F36716E8; Tue, 12 Jan 2021 14:00:25 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 6F36716E8 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1610456475; bh=K5+JYAQYo+AidPSotuCndFBykdWMadi34AXGKpPEf0M=; h=From:To:Subject:Date:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=OVzvo8/6PYXulEtucBul4bE+uh6yjvlywAa5tB/Jyl90jINtc0a5Z+X3wrMSar9tZ yv7CJBzlOnGVEjcVbZsb1Qw3/vPR6kNWNcphHsyVowyNRtwDBCnQoFu5UGQe+scnb4 1e/0Zazvzv589m5Z9Q3+QvM+DD4rRMeNBYlsKx40= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 52040F804D6; Tue, 12 Jan 2021 13:59:33 +0100 (CET) Received: by alsa1.perex.cz (Postfix, from userid 50401) id AC344F804DF; Tue, 12 Jan 2021 13:59:29 +0100 (CET) Received: from mail-lf1-x12d.google.com (mail-lf1-x12d.google.com [IPv6:2a00:1450:4864:20::12d]) (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 A38A4F800EB for ; Tue, 12 Jan 2021 13:59:26 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz A38A4F800EB Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="SZvxWZU5" Received: by mail-lf1-x12d.google.com with SMTP id o17so3234285lfg.4 for ; Tue, 12 Jan 2021 04:59:25 -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=/HJcNkl5nY2t78OqKeve4KEQLTFTI0WusBFcveQbI3Y=; b=SZvxWZU5jtXaZBiFOiUZMu98ooM1VwI1kj9mG6vlqmCv4ys2GnpwNHVRUpfvNScNRb ntv2kKjpGNxmtbBZ2NeJjOU3GzN4oTjCay44Hnvpd2tn96K2eS8nzcsjRmdo2G/loc3h K4EjWnB7Izgt3mwocLD8tdpedPAjDu0naVleeToWGgN33QEwERj52bpIY0V2Uvl8P7Pv Ny3rB8Ss9XjokprFxbYF/ZEsvTwDZcUcbIDDMxUW0Qz4mpJ4oWhNhhXGF/YH7v4KdDRC Y+ViCHaS6+ScdFpzWR/MKrFmPtFZF7w+7fw0yvOvpc8oJ9nv48oC8SxxLsDvxhRyIuoO 44aA== 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=/HJcNkl5nY2t78OqKeve4KEQLTFTI0WusBFcveQbI3Y=; b=bQWt90A4otdLuA8TyV+0KUVgbFyE8vF1MSiGxk2UZgCnozhJ8284hxaK7/4lz/5FTK 9ZzqpkElCBPaS3+UYWrz4FmSmKK+6oyQDndabYHXNZcqNhEz0S7cT63U1BIbIAxOgh2w LNr+t0kNkI/Gk20VonhvyBHNYvDARsEldBgiVoNnSdhEmgw7iKLdTXp8dBlpUM/oJ6aI K7KIOS0k7CQoIHj4cKoWi29Wq55FlPDbHcEu/41vh4TMFWzqOM4ObR1vw2xaYVDVL32h m97+Pn4aC4sj6WYNQLNwhl5UBQ4+p1yzjAkjFxw9O6PMzpQvLKK9CGoIPr0tD5oOBHRN bGuQ== X-Gm-Message-State: AOAM531bzbe3NbNeZ4UqgW5ETomLOEsxT8uzRbJ8u6V3zIhfQZbB45EO I7qt2LjR7bFdxfCtHl72n8M= X-Google-Smtp-Source: ABdhPJzddiXeMJzKEZTcHQxQ5aGewHJJB9sTdUVVkIaXRul9O3svaRqJU1kH5fYbL3uBqHhYx/Ah7A== X-Received: by 2002:a05:6512:504:: with SMTP id o4mr2352275lfb.398.1610456365037; Tue, 12 Jan 2021 04:59:25 -0800 (PST) Received: from localhost.localdomain (109-252-192-57.dynamic.spd-mgts.ru. [109.252.192.57]) by smtp.gmail.com with ESMTPSA id 192sm384211lfa.219.2021.01.12.04.59.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Jan 2021 04:59:24 -0800 (PST) From: Dmitry Osipenko To: Thierry Reding , Jonathan Hunter , Sameer Pujar , Peter Geis , Nicolas Chauvet , Takashi Iwai , Jaroslav Kysela Subject: [PATCH v1 4/5] ASoC: tegra: ahub: Use clk_bulk helpers Date: Tue, 12 Jan 2021 15:58:33 +0300 Message-Id: <20210112125834.21545-5-digetx@gmail.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210112125834.21545-1-digetx@gmail.com> References: <20210112125834.21545-1-digetx@gmail.com> MIME-Version: 1.0 Cc: linux-tegra@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" Use clk_bulk helpers to make code cleaner. Tested-by: Peter Geis Tested-by: Nicolas Chauvet Signed-off-by: Dmitry Osipenko Acked-by: Thierry Reding --- sound/soc/tegra/tegra30_ahub.c | 30 +++++++----------------------- sound/soc/tegra/tegra30_ahub.h | 4 ++-- 2 files changed, 9 insertions(+), 25 deletions(-) diff --git a/sound/soc/tegra/tegra30_ahub.c b/sound/soc/tegra/tegra30_ahub.c index 1e9767c75b11..4dbb58f7ea36 100644 --- a/sound/soc/tegra/tegra30_ahub.c +++ b/sound/soc/tegra/tegra30_ahub.c @@ -45,8 +45,7 @@ static int tegra30_ahub_runtime_suspend(struct device *dev) regcache_cache_only(ahub->regmap_apbif, true); regcache_cache_only(ahub->regmap_ahub, true); - clk_disable_unprepare(ahub->clk_apbif); - clk_disable_unprepare(ahub->clk_d_audio); + clk_bulk_disable_unprepare(ahub->nclocks, ahub->clocks); return 0; } @@ -66,17 +65,9 @@ static int tegra30_ahub_runtime_resume(struct device *dev) { int ret; - ret = clk_prepare_enable(ahub->clk_d_audio); - if (ret) { - dev_err(dev, "clk_enable d_audio failed: %d\n", ret); - return ret; - } - ret = clk_prepare_enable(ahub->clk_apbif); - if (ret) { - dev_err(dev, "clk_enable apbif failed: %d\n", ret); - clk_disable(ahub->clk_d_audio); + ret = clk_bulk_prepare_enable(ahub->nclocks, ahub->clocks); + if (ret) return ret; - } regcache_cache_only(ahub->regmap_apbif, false); regcache_cache_only(ahub->regmap_ahub, false); @@ -509,19 +500,12 @@ static int tegra30_ahub_probe(struct platform_device *pdev) ahub->soc_data = soc_data; ahub->dev = &pdev->dev; - ahub->clk_d_audio = devm_clk_get(&pdev->dev, "d_audio"); - if (IS_ERR(ahub->clk_d_audio)) { - dev_err(&pdev->dev, "Can't retrieve ahub d_audio clock\n"); - ret = PTR_ERR(ahub->clk_d_audio); - return ret; - } + ahub->clocks[ahub->nclocks++].id = "apbif"; + ahub->clocks[ahub->nclocks++].id = "d_audio"; - ahub->clk_apbif = devm_clk_get(&pdev->dev, "apbif"); - if (IS_ERR(ahub->clk_apbif)) { - dev_err(&pdev->dev, "Can't retrieve ahub apbif clock\n"); - ret = PTR_ERR(ahub->clk_apbif); + ret = devm_clk_bulk_get(&pdev->dev, ahub->nclocks, ahub->clocks); + if (ret) return ret; - } res0 = platform_get_resource(pdev, IORESOURCE_MEM, 0); regs_apbif = devm_ioremap_resource(&pdev->dev, res0); diff --git a/sound/soc/tegra/tegra30_ahub.h b/sound/soc/tegra/tegra30_ahub.h index 5a2500b4ea06..063aed5037d7 100644 --- a/sound/soc/tegra/tegra30_ahub.h +++ b/sound/soc/tegra/tegra30_ahub.h @@ -510,8 +510,8 @@ struct tegra30_ahub_soc_data { struct tegra30_ahub { const struct tegra30_ahub_soc_data *soc_data; struct device *dev; - struct clk *clk_d_audio; - struct clk *clk_apbif; + struct clk_bulk_data clocks[2]; + unsigned int nclocks; resource_size_t apbif_addr; struct regmap *regmap_apbif; struct regmap *regmap_ahub; From patchwork Tue Jan 12 12:58:34 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Osipenko X-Patchwork-Id: 361257 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 3CA0CC433DB for ; Tue, 12 Jan 2021 13:02:35 +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 6571723117 for ; Tue, 12 Jan 2021 13:02:34 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 6571723117 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 B6A881719; Tue, 12 Jan 2021 14:01:42 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz B6A881719 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1610456552; bh=lAlujD2zMkA8jsUeK7vh2jDQzc6/HCoUqLaNxZaggZY=; h=From:To:Subject:Date:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=e4fyPpFLgV2oyKBOxN2ICKXHBCXYSKrezM6u1kc0bkVPk2aQnSQPvHgVqp3xCFCBW 5L2Cks17+9cT6s92Cbe/l933Jo5MO/ICjevj5qRObfQVxgc/ATqOx1zvdGL9fbqX6F AG3S1S/3gKEe41JAa923189J8LxG9XvdVvHjxTss= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 26D84F804FA; Tue, 12 Jan 2021 13:59:38 +0100 (CET) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 74332F804E2; Tue, 12 Jan 2021 13:59:32 +0100 (CET) Received: from mail-lj1-x232.google.com (mail-lj1-x232.google.com [IPv6:2a00:1450:4864:20::232]) (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 92268F804D6 for ; Tue, 12 Jan 2021 13:59:27 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 92268F804D6 Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="rClqpU4R" Received: by mail-lj1-x232.google.com with SMTP id n8so2744593ljg.3 for ; Tue, 12 Jan 2021 04:59:27 -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=c6GtQ1NMerYE2VXfkjD0awJM9c14fA0uLhnuFd5ReVg=; b=rClqpU4RHdEeRNfl2B7s/W6CLCwbG6gTtFf+04dfQiJLrYeyw6DF1xLW8YUgTFGyzY eJ7fcnGQrVtNVDyasYBBtxu2l6VtTtdsUtO+Uq3y51c39HZRuQS5rcs5wvdvhuOwUsSS +3qnY6q6tehOG2Y9UpSO2QYE07Ml2rmVqUwYXjRDtyJ2K07693eLOXk/g7p/Y0WLDcta zQ2/k5lq2R14Dh9u2NWAOYuFPF3bCFVnC2LCmWqmjdS0BC1t14sOSf/MYIo3hIcdfKZz YWMOdCw5jL+G0k88GACjXm6wyT1CQL8dAZQF/LIF0kYcq21Kxt1Y0KBz863khILci9AD 7KSA== 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=c6GtQ1NMerYE2VXfkjD0awJM9c14fA0uLhnuFd5ReVg=; b=HXmOX3E7+DozFfggWhITAkYmj0nlmP0ECRRyuAluSGB9mG2H7uxjYlj3u5YNzrI9wZ WOl1Fo6ZewxR/bV9g6/oCENpvbB2CaVC/cp0ZBtSB6A2f9+il/3yw40US8uSKy3bRQsq 8VqDbE+dTWN8j4MZwO6XlV+iKcGXK5b7madJWTmAyYVN9HYRkMgWyhHZixXJu0aHWpcf XyVGIXAJ/qbun4s4jcc5AVfCj+Yz6byLBlJsFndLTah1Ey4chGMD0PBbB7G2wwf5e9nO jBygK5VThaiGQsMfABeDBiFS+FVK9BdE2fEONg3CR5QImrBGnUVXzTjXQ6f9r7ZIWwcz 6GzQ== X-Gm-Message-State: AOAM530/P4ddt4mn7Jr0GkXUOkYIG1VxhXQPZZNN+BIpRVt38HzyESgO vvWp+dPb7TXYU4CbcUVx1gg= X-Google-Smtp-Source: ABdhPJwOkp2bw3DDCg37hiVed+o60utA9Fo0A0qC/6V34IHbxcJcSNZMHviVRYHnYznUlpUrv995Ng== X-Received: by 2002:a2e:918a:: with SMTP id f10mr1881603ljg.302.1610456365858; Tue, 12 Jan 2021 04:59:25 -0800 (PST) Received: from localhost.localdomain (109-252-192-57.dynamic.spd-mgts.ru. [109.252.192.57]) by smtp.gmail.com with ESMTPSA id 192sm384211lfa.219.2021.01.12.04.59.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Jan 2021 04:59:25 -0800 (PST) From: Dmitry Osipenko To: Thierry Reding , Jonathan Hunter , Sameer Pujar , Peter Geis , Nicolas Chauvet , Takashi Iwai , Jaroslav Kysela Subject: [PATCH v1 5/5] ASoC: tegra: ahub: Reset hardware properly Date: Tue, 12 Jan 2021 15:58:34 +0300 Message-Id: <20210112125834.21545-6-digetx@gmail.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210112125834.21545-1-digetx@gmail.com> References: <20210112125834.21545-1-digetx@gmail.com> MIME-Version: 1.0 Cc: linux-tegra@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" Assert hardware reset before clocks are enabled and then de-assert it after clocks are enabled. This brings hardware into a predictable state and removes relying on implicit de-assertion of resets which is done by the clk driver. Tested-by: Peter Geis Tested-by: Nicolas Chauvet Signed-off-by: Dmitry Osipenko --- sound/soc/tegra/tegra30_ahub.c | 33 ++++++++++++++++----------------- sound/soc/tegra/tegra30_ahub.h | 1 + 2 files changed, 17 insertions(+), 17 deletions(-) diff --git a/sound/soc/tegra/tegra30_ahub.c b/sound/soc/tegra/tegra30_ahub.c index 4dbb58f7ea36..246cf6a373a1 100644 --- a/sound/soc/tegra/tegra30_ahub.c +++ b/sound/soc/tegra/tegra30_ahub.c @@ -65,10 +65,20 @@ static int tegra30_ahub_runtime_resume(struct device *dev) { int ret; + ret = reset_control_assert(ahub->reset); + if (ret) + return ret; + ret = clk_bulk_prepare_enable(ahub->nclocks, ahub->clocks); if (ret) return ret; + ret = reset_control_reset(ahub->reset); + if (ret) { + clk_bulk_disable_unprepare(ahub->nclocks, ahub->clocks); + return ret; + } + regcache_cache_only(ahub->regmap_apbif, false); regcache_cache_only(ahub->regmap_ahub, false); @@ -462,7 +472,6 @@ static int tegra30_ahub_probe(struct platform_device *pdev) { const struct of_device_id *match; const struct tegra30_ahub_soc_data *soc_data; - struct reset_control *rst; struct resource *res0; void __iomem *regs_apbif, *regs_ahub; int ret = 0; @@ -475,22 +484,6 @@ static int tegra30_ahub_probe(struct platform_device *pdev) return -EINVAL; soc_data = match->data; - /* - * The AHUB hosts a register bus: the "configlink". For this to - * operate correctly, all devices on this bus must be out of reset. - * Ensure that here. - */ - rst = of_reset_control_array_get_exclusive(pdev->dev.of_node); - if (IS_ERR(rst)) { - dev_err(&pdev->dev, "Can't get reset: %p\n", rst); - return PTR_ERR(rst); - } - - ret = reset_control_deassert(rst); - reset_control_put(rst); - if (ret) - return ret; - ahub = devm_kzalloc(&pdev->dev, sizeof(struct tegra30_ahub), GFP_KERNEL); if (!ahub) @@ -507,6 +500,12 @@ static int tegra30_ahub_probe(struct platform_device *pdev) if (ret) return ret; + ahub->reset = devm_reset_control_array_get_exclusive(&pdev->dev); + if (IS_ERR(ahub->reset)) { + dev_err(&pdev->dev, "Can't get reset: %p\n", ahub->reset); + return PTR_ERR(ahub->reset); + } + res0 = platform_get_resource(pdev, IORESOURCE_MEM, 0); regs_apbif = devm_ioremap_resource(&pdev->dev, res0); if (IS_ERR(regs_apbif)) diff --git a/sound/soc/tegra/tegra30_ahub.h b/sound/soc/tegra/tegra30_ahub.h index 063aed5037d7..ceb056575e98 100644 --- a/sound/soc/tegra/tegra30_ahub.h +++ b/sound/soc/tegra/tegra30_ahub.h @@ -510,6 +510,7 @@ struct tegra30_ahub_soc_data { struct tegra30_ahub { const struct tegra30_ahub_soc_data *soc_data; struct device *dev; + struct reset_control *reset; struct clk_bulk_data clocks[2]; unsigned int nclocks; resource_size_t apbif_addr;