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: 12013409 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;