Commit 61fe43dc authored by Ming Qian's avatar Ming Qian Committed by Mauro Carvalho Chehab

media: imx-jpeg: Apply clk_bulk api instead of operating specific clk

using the api of clk_bulk can simplify the code.
and the clock of the jpeg codec may be changed,
the clk_bulk api can be compatible with the future change.

Fixes: 4c2e5156 ("media: imx-jpeg: Add pm-runtime support for imx-jpeg")
Signed-off-by: default avatarMing Qian <ming.qian@nxp.com>
Signed-off-by: default avatarHans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@kernel.org>
parent c07e734b
...@@ -2472,19 +2472,12 @@ static int mxc_jpeg_probe(struct platform_device *pdev) ...@@ -2472,19 +2472,12 @@ static int mxc_jpeg_probe(struct platform_device *pdev)
jpeg->mode = mode; jpeg->mode = mode;
/* Get clocks */ /* Get clocks */
jpeg->clk_ipg = devm_clk_get(dev, "ipg"); ret = devm_clk_bulk_get_all(&pdev->dev, &jpeg->clks);
if (IS_ERR(jpeg->clk_ipg)) { if (ret < 0) {
dev_err(dev, "failed to get clock: ipg\n"); dev_err(dev, "failed to get clock\n");
ret = PTR_ERR(jpeg->clk_ipg);
goto err_clk;
}
jpeg->clk_per = devm_clk_get(dev, "per");
if (IS_ERR(jpeg->clk_per)) {
dev_err(dev, "failed to get clock: per\n");
ret = PTR_ERR(jpeg->clk_per);
goto err_clk; goto err_clk;
} }
jpeg->num_clks = ret;
ret = mxc_jpeg_attach_pm_domains(jpeg); ret = mxc_jpeg_attach_pm_domains(jpeg);
if (ret < 0) { if (ret < 0) {
...@@ -2581,32 +2574,20 @@ static int mxc_jpeg_runtime_resume(struct device *dev) ...@@ -2581,32 +2574,20 @@ static int mxc_jpeg_runtime_resume(struct device *dev)
struct mxc_jpeg_dev *jpeg = dev_get_drvdata(dev); struct mxc_jpeg_dev *jpeg = dev_get_drvdata(dev);
int ret; int ret;
ret = clk_prepare_enable(jpeg->clk_ipg); ret = clk_bulk_prepare_enable(jpeg->num_clks, jpeg->clks);
if (ret < 0) {
dev_err(dev, "failed to enable clock: ipg\n");
goto err_ipg;
}
ret = clk_prepare_enable(jpeg->clk_per);
if (ret < 0) { if (ret < 0) {
dev_err(dev, "failed to enable clock: per\n"); dev_err(dev, "failed to enable clock\n");
goto err_per; return ret;
} }
return 0; return 0;
err_per:
clk_disable_unprepare(jpeg->clk_ipg);
err_ipg:
return ret;
} }
static int mxc_jpeg_runtime_suspend(struct device *dev) static int mxc_jpeg_runtime_suspend(struct device *dev)
{ {
struct mxc_jpeg_dev *jpeg = dev_get_drvdata(dev); struct mxc_jpeg_dev *jpeg = dev_get_drvdata(dev);
clk_disable_unprepare(jpeg->clk_ipg); clk_bulk_disable_unprepare(jpeg->num_clks, jpeg->clks);
clk_disable_unprepare(jpeg->clk_per);
return 0; return 0;
} }
......
...@@ -120,8 +120,8 @@ struct mxc_jpeg_dev { ...@@ -120,8 +120,8 @@ struct mxc_jpeg_dev {
spinlock_t hw_lock; /* hardware access lock */ spinlock_t hw_lock; /* hardware access lock */
unsigned int mode; unsigned int mode;
struct mutex lock; /* v4l2 ioctls serialization */ struct mutex lock; /* v4l2 ioctls serialization */
struct clk *clk_ipg; struct clk_bulk_data *clks;
struct clk *clk_per; int num_clks;
struct platform_device *pdev; struct platform_device *pdev;
struct device *dev; struct device *dev;
void __iomem *base_reg; void __iomem *base_reg;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment