From 1309d2cfd8355bf90a4a5a92734fc5380ab3a408 Mon Sep 17 00:00:00 2001 From: "xingyu.wu" Date: Tue, 1 Mar 2022 10:47:48 +0800 Subject: [PATCH] Adjust Vdec and Venc driver vdec.c/venc.c: not disable clock of 'vdecbrg_main' and 'vencbrg_main'. Signed-off-by: Xingyu Wu --- .../code/vdi/linux/driver/vdec-starfive.h | 36 ++++++++----------- .../wave511/code/vdi/linux/driver/vdec.c | 2 +- .../code/vdi/linux/driver/venc-starfive.h | 36 ++++++++----------- .../wave521/code/vdi/linux/driver/venc.c | 8 ++--- 4 files changed, 33 insertions(+), 49 deletions(-) diff --git a/soft_3rdpart/wave511/code/vdi/linux/driver/vdec-starfive.h b/soft_3rdpart/wave511/code/vdi/linux/driver/vdec-starfive.h index 52df3c4cbec6..6f40c8676aa8 100644 --- a/soft_3rdpart/wave511/code/vdi/linux/driver/vdec-starfive.h +++ b/soft_3rdpart/wave511/code/vdi/linux/driver/vdec-starfive.h @@ -18,17 +18,6 @@ struct starfive_vdec_data { struct device *dev; - struct clk *clk_vdec_axi; - struct clk *clk_vdecbrg_main; - struct clk *clk_vdec_bclk; - struct clk *clk_vdec_cclk; - struct clk *clk_vdec_apb; - - struct reset_control *rst_vdecbrg_main; - struct reset_control *rst_vdec_axi; - struct reset_control *rst_vdec_bclk; - struct reset_control *rst_vdec_cclk; - struct reset_control *rst_vdec_apb; struct clk *clk_vdec_id[VDEC_ID_NUM]; struct reset_control *rst_vdec_id[VDEC_ID_NUM]; @@ -38,8 +27,8 @@ struct starfive_vdec_data { static struct starfive_vdec_data *sf_vdec = NULL; const char vdec_data_id[VDEC_ID_NUM][15] = { - "vdec_axi", "vdecbrg_main", + "vdec_axi", "vdec_bclk", "vdec_cclk", "vdec_apb", @@ -71,13 +60,12 @@ void starfive_vdec_rst_exit(void) { int i; int ret; - for (i = 0; i < VDEC_ID_NUM; i++) { + for (i = 1; i < VDEC_ID_NUM; i++) { /* Assert the reset of "vdecbrg_main" could crash*/ - if (i != 1){ - ret = reset_control_assert(sf_vdec->rst_vdec_id[i]); - if (ret) { - dev_err(sf_vdec->dev, "reset assert failed\n"); - } + ret = reset_control_assert(sf_vdec->rst_vdec_id[i]); + if (ret) { + dev_err(sf_vdec->dev, "VDEC reset assert failed:\n"); + dev_err(sf_vdec->dev, vdec_data_id[i]); } } return; @@ -86,7 +74,7 @@ void starfive_vdec_rst_exit(void) void starfive_vdec_clk_exit(void) { int i; - for (i = 0; i < VDEC_ID_NUM; i++) { + for (i = 1; i < VDEC_ID_NUM; i++) { clk_disable_unprepare(sf_vdec->clk_vdec_id[i]); } return; @@ -99,6 +87,7 @@ static int starfive_vdec_clk_init(void) for (i = 0; i < VDEC_ID_NUM; i++) { ret = clk_prepare_enable(sf_vdec->clk_vdec_id[i]); if (ret) { + dev_err(sf_vdec->dev, "VDEC enable clock failed:\n"); dev_err(sf_vdec->dev, vdec_data_id[i]); goto init_clk_failed; } @@ -107,7 +96,7 @@ static int starfive_vdec_clk_init(void) return 0; init_clk_failed: - for(; i > 0 ; i--) { + for(; i > 1 ; i--) { clk_disable_unprepare(sf_vdec->clk_vdec_id[i-1]); } @@ -122,6 +111,7 @@ static int starfive_vdec_get_clk(void) for ( i = 0; i < VDEC_ID_NUM ; i++) { sf_vdec->clk_vdec_id[i] = devm_clk_get(sf_vdec->dev, vdec_data_id[i]); if (IS_ERR(sf_vdec->clk_vdec_id[i])) { + dev_err(sf_vdec->dev, "VDEC get clock failed:\n"); dev_err(sf_vdec->dev, vdec_data_id[i]); ret = PTR_ERR(sf_vdec->clk_vdec_id[i]); goto get_clk_failed; @@ -145,6 +135,7 @@ static int starfive_vdec_reset_init(void) for (i = 0; i < VDEC_ID_NUM ; i++) { ret = reset_control_deassert(sf_vdec->rst_vdec_id[i]); if (ret) { + dev_err(sf_vdec->dev, "VDEC deassert reset failed:\n"); dev_err(sf_vdec->dev, vdec_data_id[i]); goto init_reset_failed; } @@ -153,7 +144,7 @@ static int starfive_vdec_reset_init(void) return 0; init_reset_failed: - for (; i > 0 ; i--) { + for (; i > 1 ; i--) { reset_control_assert(sf_vdec->rst_vdec_id[i-1]); } @@ -167,6 +158,7 @@ static int starfive_vdec_get_resets(void) for (i = 0; i < VDEC_ID_NUM ; i++) { sf_vdec->rst_vdec_id[i] = devm_reset_control_get_exclusive(sf_vdec->dev, vdec_data_id[i]); if (IS_ERR(sf_vdec->rst_vdec_id[i])) { + dev_err(sf_vdec->dev, "VDEC get reset failed:\n"); dev_err(sf_vdec->dev, vdec_data_id[i]); ret = PTR_ERR(sf_vdec->rst_vdec_id[i]); goto get_resets_failed; @@ -294,7 +286,7 @@ int starfive_vdec_clk_rst_init(struct platform_device *pdev) goto init_failed; } - printk("starfive vdec clock & reset init success."); + dev_info(sf_vdec->dev, "success to init VDEC clock & reset."); return 0; init_failed: diff --git a/soft_3rdpart/wave511/code/vdi/linux/driver/vdec.c b/soft_3rdpart/wave511/code/vdi/linux/driver/vdec.c index f4d5f489c2b0..c7bd12f4eee1 100755 --- a/soft_3rdpart/wave511/code/vdi/linux/driver/vdec.c +++ b/soft_3rdpart/wave511/code/vdi/linux/driver/vdec.c @@ -1969,7 +1969,7 @@ static int _clk_control(int enable) else { _disable_clk(p_breg+clk_vdec_axi_ctrl_REG_OFFSET,31); - _disable_clk(p_breg+clk_vdecbrg_mainclk_ctrl_REG_OFFSET,31); + // _disable_clk(p_breg+clk_vdecbrg_mainclk_ctrl_REG_OFFSET,31); _disable_clk(p_breg+clk_vdec_bclk_ctrl_REG_OFFSET,31); _disable_clk(p_breg+clk_vdec_cclk_ctrl_REG_OFFSET,31); _disable_clk(p_breg+clk_vdec_apb_ctrl_REG_OFFSET,31); diff --git a/soft_3rdpart/wave521/code/vdi/linux/driver/venc-starfive.h b/soft_3rdpart/wave521/code/vdi/linux/driver/venc-starfive.h index 222c22c77d10..a568f3566cff 100644 --- a/soft_3rdpart/wave521/code/vdi/linux/driver/venc-starfive.h +++ b/soft_3rdpart/wave521/code/vdi/linux/driver/venc-starfive.h @@ -18,17 +18,6 @@ struct starfive_venc_data { struct device *dev; - struct clk *clk_venc_axi; - struct clk *clk_vencbrg_main; - struct clk *clk_venc_bclk; - struct clk *clk_venc_cclk; - struct clk *clk_venc_apb; - - struct reset_control *rst_vencbrg_main; - struct reset_control *rst_venc_axi; - struct reset_control *rst_venc_bclk; - struct reset_control *rst_venc_cclk; - struct reset_control *rst_venc_apb; struct clk *clk_venc_id[VENC_ID_NUM]; struct reset_control *rst_venc_id[VENC_ID_NUM]; @@ -37,8 +26,8 @@ struct starfive_venc_data { static struct starfive_venc_data *sf_venc = NULL; const char venc_data_id[VENC_ID_NUM][15] = { - "venc_axi", "vencbrg_main", + "venc_axi", "venc_bclk", "venc_cclk", "venc_apb", @@ -70,13 +59,12 @@ void starfive_venc_rst_exit(void) { int i; int ret; - for (i = 0; i < VENC_ID_NUM; i++) { + for (i = 1; i < VENC_ID_NUM; i++) { /* Assert the reset of "vencbrg_main" could crash*/ - if (i != 1 ) { - ret = reset_control_assert(sf_venc->rst_venc_id[i]); - if (ret) { - dev_err(sf_venc->dev, "reset assert failed\n"); - } + ret = reset_control_assert(sf_venc->rst_venc_id[i]); + if (ret) { + dev_err(sf_venc->dev, "VENC reset assert failed:\n"); + dev_err(sf_venc->dev, venc_data_id[i]); } } return; @@ -85,7 +73,7 @@ void starfive_venc_rst_exit(void) void starfive_venc_clk_exit(void) { int i; - for (i = 0; i < VENC_ID_NUM; i++) { + for (i = 1; i < VENC_ID_NUM; i++) { clk_disable_unprepare(sf_venc->clk_venc_id[i]); } @@ -99,6 +87,7 @@ static int starfive_venc_clk_init(void) for (i = 0; i < VENC_ID_NUM; i++) { ret = clk_prepare_enable(sf_venc->clk_venc_id[i]); if (ret) { + dev_err(sf_venc->dev, "VENC enable clock failed:\n"); dev_err(sf_venc->dev, venc_data_id[i]); goto init_clk_failed; } @@ -107,7 +96,7 @@ static int starfive_venc_clk_init(void) return 0; init_clk_failed: - for(; i > 0 ; i--) { + for(; i > 1 ; i--) { clk_disable_unprepare(sf_venc->clk_venc_id[i-1]); } @@ -121,6 +110,7 @@ static int starfive_venc_get_clk(void) for ( i = 0; i < VENC_ID_NUM ; i++) { sf_venc->clk_venc_id[i] = devm_clk_get(sf_venc->dev, venc_data_id[i]); if (IS_ERR(sf_venc->clk_venc_id[i])) { + dev_err(sf_venc->dev, "VENC get clock failed:\n"); dev_err(sf_venc->dev, venc_data_id[i]); ret = PTR_ERR(sf_venc->clk_venc_id[i]); goto get_clk_failed; @@ -144,6 +134,7 @@ static int starfive_venc_reset_init(void) for (i = 0; i < VENC_ID_NUM ; i++) { ret = reset_control_deassert(sf_venc->rst_venc_id[i]); if (ret) { + dev_err(sf_venc->dev, "VENC deassert reset failed:\n"); dev_err(sf_venc->dev, venc_data_id[i]); goto init_reset_failed; } @@ -152,7 +143,7 @@ static int starfive_venc_reset_init(void) return 0; init_reset_failed: - for (; i > 0 ; i--) { + for (; i > 1 ; i--) { reset_control_assert(sf_venc->rst_venc_id[i-1]); } @@ -167,6 +158,7 @@ static int starfive_venc_get_resets(void) for (i = 0; i < VENC_ID_NUM ; i++) { sf_venc->rst_venc_id[i] = devm_reset_control_get_exclusive(sf_venc->dev, venc_data_id[i]); if (IS_ERR(sf_venc->rst_venc_id[i])) { + dev_err(sf_venc->dev, "VENC get reset failed:\n"); dev_err(sf_venc->dev, venc_data_id[i]); ret = PTR_ERR(sf_venc->rst_venc_id[i]); goto get_resets_failed; @@ -295,7 +287,7 @@ int starfive_venc_clk_rst_init(struct platform_device *pdev) } starfive_venc_rst_status(); - printk("starfive venc clock & reset init success."); + dev_info(sf_venc->dev, "success to init VENC clock & reset."); return 0; init_failed: diff --git a/soft_3rdpart/wave521/code/vdi/linux/driver/venc.c b/soft_3rdpart/wave521/code/vdi/linux/driver/venc.c index 8754e0998d4c..4a39d65c7b8d 100755 --- a/soft_3rdpart/wave521/code/vdi/linux/driver/venc.c +++ b/soft_3rdpart/wave521/code/vdi/linux/driver/venc.c @@ -1288,11 +1288,11 @@ static int vpu_probe(struct platform_device *pdev) dev_info(vpu_dev,"device init.\n"); } -#ifdef VPU_SUPPORT_CLOCK_CONTROL +#ifdef VPU_SUPPORT_CLOCK_CONTROL vpu_dev->of_node = of_find_node_by_name(NULL, "vpu_enc"); if (!(vpu_dev->of_node)) printk("The node of vpu_enc is not found in device tree.\n"); - + err = of_address_to_resource(vpu_dev->of_node, 0, &venc_resource[0]); if (err) { printk(KERN_ERR "could not find venc register address\n"); @@ -1301,7 +1301,7 @@ static int vpu_probe(struct platform_device *pdev) venc_resource[1].start = irq_of_parse_and_map(vpu_dev->of_node, 0); venc_resource[1].end = venc_resource[1].start; - + err = platform_device_add_resources(pdev, venc_resource, 2); if (err) { printk(KERN_ERR "could not add venc resource\n"); @@ -1923,7 +1923,7 @@ static int _clk_control(int enable) else { _disable_clk(p_breg+clk_venc_axi_ctrl_REG_OFFSET,31); - _disable_clk(p_breg+clk_vencbrg_mainclk_ctrl_REG_OFFSET,31); + // _disable_clk(p_breg+clk_vencbrg_mainclk_ctrl_REG_OFFSET,31); _disable_clk(p_breg+clk_venc_bclk_ctrl_REG_OFFSET,31); _disable_clk(p_breg+clk_venc_cclk_ctrl_REG_OFFSET,31); _disable_clk(p_breg+clk_venc_apb_ctrl_REG_OFFSET,31);