From 7e5bd674b6f8acd49a932fe3ac88c45ed77e2d26 Mon Sep 17 00:00:00 2001 From: Nanxin Qin Date: Thu, 3 May 2018 18:09:36 +0800 Subject: [PATCH] vdec: the dec core was reset when the vdec poweron before. PD#165053: 1. regs about the ao dos needs to be reset when reboot. 2. the hhi regs with vdec clk should be clear when the clock reference count minus to zero. the issue also needs to be amended clk tree by qiufang. Change-Id: Idce668af7e4d8fc7e400d5907705aaf87e59043c Signed-off-by: Nanxin Qin --- .../frame_provider/decoder/utils/vdec.c | 46 +++++++++++++++++++ .../frame_provider/decoder/utils/vdec.h | 1 + .../stream_input/amports/amstream.c | 5 ++ 3 files changed, 52 insertions(+) diff --git a/drivers/amlogic/media_modules/frame_provider/decoder/utils/vdec.c b/drivers/amlogic/media_modules/frame_provider/decoder/utils/vdec.c index d4689c156d1a..1f0c3f4e73a7 100644 --- a/drivers/amlogic/media_modules/frame_provider/decoder/utils/vdec.c +++ b/drivers/amlogic/media_modules/frame_provider/decoder/utils/vdec.c @@ -2253,6 +2253,52 @@ static bool test_hevc(u32 decomp_addr, u32 us_delay) return (READ_VREG(HEVCD_IPP_DBG_DATA) & 3) == 1; } +void vdec_power_reset(void) +{ + /* enable vdec1 isolation */ + WRITE_AOREG(AO_RTI_GEN_PWR_ISO0, + READ_AOREG(AO_RTI_GEN_PWR_ISO0) | 0xc0); + /* power off vdec1 memories */ + WRITE_VREG(DOS_MEM_PD_VDEC, 0xffffffffUL); + /* vdec1 power off */ + WRITE_AOREG(AO_RTI_GEN_PWR_SLEEP0, + READ_AOREG(AO_RTI_GEN_PWR_SLEEP0) | 0xc); + + if (has_vdec2()) { + /* enable vdec2 isolation */ + WRITE_AOREG(AO_RTI_GEN_PWR_ISO0, + READ_AOREG(AO_RTI_GEN_PWR_ISO0) | 0x300); + /* power off vdec2 memories */ + WRITE_VREG(DOS_MEM_PD_VDEC2, 0xffffffffUL); + /* vdec2 power off */ + WRITE_AOREG(AO_RTI_GEN_PWR_SLEEP0, + READ_AOREG(AO_RTI_GEN_PWR_SLEEP0) | 0x30); + } + + if (has_hdec()) { + /* enable hcodec isolation */ + WRITE_AOREG(AO_RTI_GEN_PWR_ISO0, + READ_AOREG(AO_RTI_GEN_PWR_ISO0) | 0x30); + /* power off hcodec memories */ + WRITE_VREG(DOS_MEM_PD_HCODEC, 0xffffffffUL); + /* hcodec power off */ + WRITE_AOREG(AO_RTI_GEN_PWR_SLEEP0, + READ_AOREG(AO_RTI_GEN_PWR_SLEEP0) | 3); + } + + if (has_hevc_vdec()) { + /* enable hevc isolation */ + WRITE_AOREG(AO_RTI_GEN_PWR_ISO0, + READ_AOREG(AO_RTI_GEN_PWR_ISO0) | 0xc00); + /* power off hevc memories */ + WRITE_VREG(DOS_MEM_PD_HEVC, 0xffffffffUL); + /* hevc power off */ + WRITE_AOREG(AO_RTI_GEN_PWR_SLEEP0, + READ_AOREG(AO_RTI_GEN_PWR_SLEEP0) | 0xc0); + } +} +EXPORT_SYMBOL(vdec_power_reset); + void vdec_poweron(enum vdec_type_e core) { void *decomp_addr = NULL; diff --git a/drivers/amlogic/media_modules/frame_provider/decoder/utils/vdec.h b/drivers/amlogic/media_modules/frame_provider/decoder/utils/vdec.h index 0b0e0b88965b..7077280cd1a2 100644 --- a/drivers/amlogic/media_modules/frame_provider/decoder/utils/vdec.h +++ b/drivers/amlogic/media_modules/frame_provider/decoder/utils/vdec.h @@ -70,6 +70,7 @@ extern void vdec2_power_mode(int level); extern void vdec_poweron(enum vdec_type_e core); extern void vdec_poweroff(enum vdec_type_e core); extern bool vdec_on(enum vdec_type_e core); +extern void vdec_power_reset(void); /*irq num as same as .dts*/ diff --git a/drivers/amlogic/media_modules/stream_input/amports/amstream.c b/drivers/amlogic/media_modules/stream_input/amports/amstream.c index 778ac89b9da6..4614af242f61 100644 --- a/drivers/amlogic/media_modules/stream_input/amports/amstream.c +++ b/drivers/amlogic/media_modules/stream_input/amports/amstream.c @@ -3793,6 +3793,11 @@ static int amstream_probe(struct platform_device *pdev) /*prealloc fetch buf to avoid no continue buffer later...*/ stbuf_fetch_init(); REG_PATH_CONFIGS("media.amports", amports_configs); + + /* poweroff the decode core because dos can not be reset when reboot */ + if (get_cpu_type() == MESON_CPU_MAJOR_ID_G12A) + vdec_power_reset(); + return 0; /*