Skip to content

Commit

Permalink
crypto: rockchip - use clk_bulk to simplify clock management
Browse files Browse the repository at this point in the history
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.

Reviewed-by: John Keeping <[email protected]>
Signed-off-by: Corentin Labbe <[email protected]>
Signed-off-by: Herbert Xu <[email protected]>
  • Loading branch information
montjoie authored and herbertx committed Oct 28, 2022
1 parent 6f61192 commit 3a6fd46
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 61 deletions.
66 changes: 9 additions & 57 deletions drivers/crypto/rockchip/rk3288_crypto.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

/*
Expand Down Expand Up @@ -266,27 +235,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;
}

Expand Down
6 changes: 2 additions & 4 deletions drivers/crypto/rockchip/rk3288_crypto.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 3a6fd46

Please sign in to comment.