Received: by 2002:a05:6a10:6d10:0:0:0:0 with SMTP id gq16csp1276277pxb; Thu, 14 Apr 2022 02:26:35 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw11hj+8E0/LSRSic62cpIHVX3knCXICDHpY5h/BNgS53Q0IhwwWM1RFLTS+XadCdYQuZxU X-Received: by 2002:aa7:9041:0:b0:4fe:3d6c:1739 with SMTP id n1-20020aa79041000000b004fe3d6c1739mr14066105pfo.13.1649928395357; Thu, 14 Apr 2022 02:26:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649928395; cv=none; d=google.com; s=arc-20160816; b=iZD+j/67jQ9KS4oAMGEkD4xN6L/mVhH0uH0Xipm9MzCr7cXIidnge05rviDkXq+Bvx gTWTKWxYd9/eiZ6AAe8bJGyeYlP035AKn+uugwomcRQen6jRqlof92WKaGkCOF4h5clS 2qr36xPynF/mUqH0XZly4cmGNb8Bsf21Q4VLx8VdiQeF+tYxpj5nv8UPlVzo0vBGUfeF EYyVe2wiBw/yQ0WUAQYmeAl0ErA2qPcu2A6HHayhwlRTIj63boO3h5bK3ieUy+eAkoI2 vD2MJwdCfrbiof8qiJYjkTTrdU9eMhV6OVkqekTUnaX6DM0plAUGd6cMt8S/7zRb1lvE gKNQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=pUlPI4V8y0jA00wHnfC+uOcvlIsr/c356N4se7BTI1o=; b=eKSTd0VpmAxDifWlgsCKqsccl5Q7M0A6AHxc6HziQEbzVqEicDO0UpBeI7m1EibfJQ hsc3yyXdX6hjZH0CMH9ckmnDM7bS/LPrr52cWvDL50OmO5MkaZowHxhi1R8dVY95oh3s MV9zQJQ8tTdNBBwC4964NXLa8+fiqDhAnftAKOsBxyWjKVZne/BBcqLHN79YlTB8zU8D b6j4L4i3/22VcQ+BGgWJyWQUtuAGCTEtYErPS1cj74xEqQtnGxwOr75DF6SUbcMZldU7 trVhfncGzGHW7Ig1oHRooFCvqgX/QFLpkQW7goC+E+AxUBgCMhW0f8xruYWfW3uTPWYJ esXA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@baylibre-com.20210112.gappssmtp.com header.s=20210112 header.b=kaqUlONh; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id u62-20020a638541000000b00386123c9f67si5798392pgd.148.2022.04.14.02.26.21; Thu, 14 Apr 2022 02:26:35 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@baylibre-com.20210112.gappssmtp.com header.s=20210112 header.b=kaqUlONh; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235476AbiDMTKt (ORCPT + 99 others); Wed, 13 Apr 2022 15:10:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44286 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237978AbiDMTKB (ORCPT ); Wed, 13 Apr 2022 15:10:01 -0400 Received: from mail-wr1-x430.google.com (mail-wr1-x430.google.com [IPv6:2a00:1450:4864:20::430]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 03A8B6E4F5 for ; Wed, 13 Apr 2022 12:07:39 -0700 (PDT) Received: by mail-wr1-x430.google.com with SMTP id u3so4005879wrg.3 for ; Wed, 13 Apr 2022 12:07:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=pUlPI4V8y0jA00wHnfC+uOcvlIsr/c356N4se7BTI1o=; b=kaqUlONhyx9cavl0+1jUARPWZu8+kqvYpSOtXO5NchGgWTX8rOYI8S8+7LgKQRiBxO cDIgjV7erbeqpVB6G1XGgpCzVrAQewtUGhdDun1SMfzb4Wz7FKZ6VHB4fUUoRcPLDEQp l90/ePE0eLUWvC5wo1+WpkU8vBMvRKj1xmqK4BPNyz+QvcAOqGo6L0P4t3SlGmwMFKyC APirbiu+GgH+ZUIYq6OROX1RxScDO/96Ua0qLqZ6qMj7q/H2/Rbg7cDyvT0HA2GPzsME MpOiJJ1qtCHZfl4iH556FHInYGSONtla2J6oloykRL7lR3O2eFWaK2Y3+j7RAEzEP2gt pLWQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=pUlPI4V8y0jA00wHnfC+uOcvlIsr/c356N4se7BTI1o=; b=GmnvnczVbT4xYE16QYi0SW9vbT3o0yiO6+ppW8j7BgLGNBbOXCJBK6nMbSzoSEPBgH h+7vAhWxuCSEj+ehk2VYgybWNQJL2cDGtr8GKetgM9CAtbd7yPn8Z6H5gnc/E2ZN1Tqr yvQhP3SdBiHMzkcIHPFVF938W4hpxyJTpbPgdD2R91sT5Jhb5LBYRvnu9NGgpkWXsFtz Ms07/Azvs9o14mzgvpzGmkZ+DrfSlRTN+y4I69vIw/Zjmg+Wi21S/GpNyjxLPGyJ0B4D Qg3bt06SyBz1HpUccvkhz9Pp2MpDl/T0TTydUks+ZvmXNbOk10XvD0EOhZZHrtkh0GWW OgyQ== X-Gm-Message-State: AOAM530IoK1uxaoDW9msza2ohHKxYZLlfrurp6o0cxWc+2YEfpq+nfX4 Q9MvUxcBVbGzES0B681Q7c0APg== X-Received: by 2002:a5d:591c:0:b0:207:a060:426c with SMTP id v28-20020a5d591c000000b00207a060426cmr230689wrd.305.1649876857615; Wed, 13 Apr 2022 12:07:37 -0700 (PDT) Received: from localhost.localdomain (laubervilliers-658-1-213-31.w90-63.abo.wanadoo.fr. [90.63.244.31]) by smtp.googlemail.com with ESMTPSA id o29-20020a05600c511d00b0038e3532b23csm3551852wms.15.2022.04.13.12.07.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Apr 2022 12:07:37 -0700 (PDT) From: Corentin Labbe To: heiko@sntech.de, herbert@gondor.apana.org.au, krzysztof.kozlowski+dt@linaro.org, robh+dt@kernel.org Cc: linux-arm-kernel@lists.infradead.org, linux-crypto@vger.kernel.org, linux-rockchip@lists.infradead.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Corentin Labbe Subject: [PATCH v5 15/33] crypto: rockchip: use clk_bulk to simplify clock management Date: Wed, 13 Apr 2022 19:06:55 +0000 Message-Id: <20220413190713.1427956-16-clabbe@baylibre.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220413190713.1427956-1-clabbe@baylibre.com> References: <20220413190713.1427956-1-clabbe@baylibre.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org rk3328 does not have the same clock names than rk3288, instead of using a complex clock management, let's use clk_bulk to simplify their handling. Signed-off-by: Corentin Labbe --- drivers/crypto/rockchip/rk3288_crypto.c | 66 ++++--------------------- drivers/crypto/rockchip/rk3288_crypto.h | 6 +-- 2 files changed, 11 insertions(+), 61 deletions(-) diff --git a/drivers/crypto/rockchip/rk3288_crypto.c b/drivers/crypto/rockchip/rk3288_crypto.c index a11a92e1f3fd..97ef59a36be6 100644 --- a/drivers/crypto/rockchip/rk3288_crypto.c +++ b/drivers/crypto/rockchip/rk3288_crypto.c @@ -22,47 +22,16 @@ static int rk_crypto_enable_clk(struct rk_crypto_info *dev) { int err; - err = clk_prepare_enable(dev->sclk); - if (err) { - dev_err(dev->dev, "[%s:%d], Couldn't enable clock sclk\n", - __func__, __LINE__); - goto err_return; - } - err = clk_prepare_enable(dev->aclk); - if (err) { - dev_err(dev->dev, "[%s:%d], Couldn't enable clock aclk\n", - __func__, __LINE__); - goto err_aclk; - } - err = clk_prepare_enable(dev->hclk); - if (err) { - dev_err(dev->dev, "[%s:%d], Couldn't enable clock hclk\n", - __func__, __LINE__); - goto err_hclk; - } - err = clk_prepare_enable(dev->dmaclk); - if (err) { - dev_err(dev->dev, "[%s:%d], Couldn't enable clock dmaclk\n", - __func__, __LINE__); - goto err_dmaclk; - } - return err; -err_dmaclk: - clk_disable_unprepare(dev->hclk); -err_hclk: - clk_disable_unprepare(dev->aclk); -err_aclk: - clk_disable_unprepare(dev->sclk); -err_return: + err = clk_bulk_prepare_enable(dev->num_clks, dev->clks); + if (err) + dev_err(dev->dev, "Could not enable clock clks\n"); + return err; } static void rk_crypto_disable_clk(struct rk_crypto_info *dev) { - clk_disable_unprepare(dev->dmaclk); - clk_disable_unprepare(dev->hclk); - clk_disable_unprepare(dev->aclk); - clk_disable_unprepare(dev->sclk); + clk_bulk_disable_unprepare(dev->num_clks, dev->clks); } /* @@ -257,27 +226,10 @@ static int rk_crypto_probe(struct platform_device *pdev) goto err_crypto; } - crypto_info->aclk = devm_clk_get(&pdev->dev, "aclk"); - if (IS_ERR(crypto_info->aclk)) { - err = PTR_ERR(crypto_info->aclk); - goto err_crypto; - } - - crypto_info->hclk = devm_clk_get(&pdev->dev, "hclk"); - if (IS_ERR(crypto_info->hclk)) { - err = PTR_ERR(crypto_info->hclk); - goto err_crypto; - } - - crypto_info->sclk = devm_clk_get(&pdev->dev, "sclk"); - if (IS_ERR(crypto_info->sclk)) { - err = PTR_ERR(crypto_info->sclk); - goto err_crypto; - } - - crypto_info->dmaclk = devm_clk_get(&pdev->dev, "apb_pclk"); - if (IS_ERR(crypto_info->dmaclk)) { - err = PTR_ERR(crypto_info->dmaclk); + crypto_info->num_clks = devm_clk_bulk_get_all(&pdev->dev, + &crypto_info->clks); + if (crypto_info->num_clks < 3) { + err = -EINVAL; goto err_crypto; } diff --git a/drivers/crypto/rockchip/rk3288_crypto.h b/drivers/crypto/rockchip/rk3288_crypto.h index ddbb9246ce16..28bf09fe1c1d 100644 --- a/drivers/crypto/rockchip/rk3288_crypto.h +++ b/drivers/crypto/rockchip/rk3288_crypto.h @@ -190,10 +190,8 @@ struct rk_crypto_info { struct device *dev; - struct clk *aclk; - struct clk *hclk; - struct clk *sclk; - struct clk *dmaclk; + struct clk_bulk_data *clks; + int num_clks; struct reset_control *rst; void __iomem *reg; int irq; -- 2.35.1