Commit 648372a8 authored by Xia Jiang's avatar Xia Jiang Committed by Mauro Carvalho Chehab

media: platform: Change the call functions of getting/enable/disable the jpeg's clock

Use the generic clk_bulk_* helpers to enable and disable clocks.
Reviewed-by: default avatarTomasz Figa <tfiga@chromium.org>
Signed-off-by: default avatarXia Jiang <xia.jiang@mediatek.com>
Signed-off-by: default avatarHans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab+huawei@kernel.org>
parent bd627ff5
...@@ -783,14 +783,15 @@ static void mtk_jpeg_clk_on(struct mtk_jpeg_dev *jpeg) ...@@ -783,14 +783,15 @@ static void mtk_jpeg_clk_on(struct mtk_jpeg_dev *jpeg)
ret = mtk_smi_larb_get(jpeg->larb); ret = mtk_smi_larb_get(jpeg->larb);
if (ret) if (ret)
dev_err(jpeg->dev, "mtk_smi_larb_get larbvdec fail %d\n", ret); dev_err(jpeg->dev, "mtk_smi_larb_get larbvdec fail %d\n", ret);
clk_prepare_enable(jpeg->clk_jdec_smi);
clk_prepare_enable(jpeg->clk_jdec); ret = clk_bulk_prepare_enable(jpeg->num_clks, jpeg->clks);
if (ret)
dev_err(jpeg->dev, "Failed to open jpeg clk: %d\n", ret);
} }
static void mtk_jpeg_clk_off(struct mtk_jpeg_dev *jpeg) static void mtk_jpeg_clk_off(struct mtk_jpeg_dev *jpeg)
{ {
clk_disable_unprepare(jpeg->clk_jdec); clk_bulk_disable_unprepare(jpeg->num_clks, jpeg->clks);
clk_disable_unprepare(jpeg->clk_jdec_smi);
mtk_smi_larb_put(jpeg->larb); mtk_smi_larb_put(jpeg->larb);
} }
...@@ -935,10 +936,16 @@ static const struct v4l2_file_operations mtk_jpeg_fops = { ...@@ -935,10 +936,16 @@ static const struct v4l2_file_operations mtk_jpeg_fops = {
.mmap = v4l2_m2m_fop_mmap, .mmap = v4l2_m2m_fop_mmap,
}; };
static struct clk_bulk_data mt8173_jpeg_dec_clocks[] = {
{ .id = "jpgdec-smi" },
{ .id = "jpgdec" },
};
static int mtk_jpeg_clk_init(struct mtk_jpeg_dev *jpeg) static int mtk_jpeg_clk_init(struct mtk_jpeg_dev *jpeg)
{ {
struct device_node *node; struct device_node *node;
struct platform_device *pdev; struct platform_device *pdev;
int ret;
node = of_parse_phandle(jpeg->dev->of_node, "mediatek,larb", 0); node = of_parse_phandle(jpeg->dev->of_node, "mediatek,larb", 0);
if (!node) if (!node)
...@@ -952,12 +959,15 @@ static int mtk_jpeg_clk_init(struct mtk_jpeg_dev *jpeg) ...@@ -952,12 +959,15 @@ static int mtk_jpeg_clk_init(struct mtk_jpeg_dev *jpeg)
jpeg->larb = &pdev->dev; jpeg->larb = &pdev->dev;
jpeg->clk_jdec = devm_clk_get(jpeg->dev, "jpgdec"); jpeg->clks = mt8173_jpeg_dec_clocks;
if (IS_ERR(jpeg->clk_jdec)) jpeg->num_clks = ARRAY_SIZE(mt8173_jpeg_dec_clocks);
return PTR_ERR(jpeg->clk_jdec); ret = devm_clk_bulk_get(jpeg->dev, jpeg->num_clks, jpeg->clks);
if (ret) {
dev_err(&pdev->dev, "failed to get jpeg clock:%d\n", ret);
return ret;
}
jpeg->clk_jdec_smi = devm_clk_get(jpeg->dev, "jpgdec-smi"); return 0;
return PTR_ERR_OR_ZERO(jpeg->clk_jdec_smi);
} }
static void mtk_jpeg_job_timeout_work(struct work_struct *work) static void mtk_jpeg_job_timeout_work(struct work_struct *work)
......
...@@ -52,8 +52,8 @@ enum mtk_jpeg_ctx_state { ...@@ -52,8 +52,8 @@ enum mtk_jpeg_ctx_state {
* @alloc_ctx: videobuf2 memory allocator's context * @alloc_ctx: videobuf2 memory allocator's context
* @dec_vdev: video device node for decoder mem2mem mode * @dec_vdev: video device node for decoder mem2mem mode
* @dec_reg_base: JPEG registers mapping * @dec_reg_base: JPEG registers mapping
* @clk_jdec: JPEG hw working clock * @clks: clock names
* @clk_jdec_smi: JPEG SMI bus clock * @num_clks: numbers of clock
* @larb: SMI device * @larb: SMI device
* @job_timeout_work: IRQ timeout structure * @job_timeout_work: IRQ timeout structure
*/ */
...@@ -67,8 +67,8 @@ struct mtk_jpeg_dev { ...@@ -67,8 +67,8 @@ struct mtk_jpeg_dev {
void *alloc_ctx; void *alloc_ctx;
struct video_device *dec_vdev; struct video_device *dec_vdev;
void __iomem *dec_reg_base; void __iomem *dec_reg_base;
struct clk *clk_jdec; struct clk_bulk_data *clks;
struct clk *clk_jdec_smi; int num_clks;
struct device *larb; struct device *larb;
struct delayed_work job_timeout_work; struct delayed_work job_timeout_work;
}; };
......
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