From 9b63ffb463b499035a259547287118691fcf38f0 Mon Sep 17 00:00:00 2001 From: Nian Jing Date: Wed, 27 Mar 2019 19:04:53 +0800 Subject: [PATCH] tvafe: lower shutdown power for tl1 [1/1] PD#SWPL-6165 Problem: TL1 vdee power too high when shutdown Solution: close bandgap when shut down for tl1 close vafe ctrl close adc pll Verify: X301 Change-Id: I374bbe09ecdd456ea07f1fda3391acd4ab0bc949 Signed-off-by: Nian Jing Conflicts: drivers/amlogic/media/vout/vdac/vdac_dev.c --- drivers/amlogic/atv_demod/atv_demod_driver.c | 1 + drivers/amlogic/media/dtv_demod/amlfrontend.c | 4 +++- drivers/amlogic/media/dtv_demod/demod_func.c | 2 +- drivers/amlogic/media/vin/tvin/tvafe/tvafe.c | 5 +++++ drivers/amlogic/media/vin/tvin/tvafe/tvafe.h | 2 +- .../media/vin/tvin/tvafe/tvafe_general.c | 17 +++++++++++++++-- .../media/vin/tvin/tvafe/tvafe_general.h | 2 +- drivers/amlogic/media/vout/vdac/vdac_dev.c | 2 +- .../amlogic/media/frame_provider/tvin/tvin.h | 12 +++++------- 9 files changed, 33 insertions(+), 14 deletions(-) diff --git a/drivers/amlogic/atv_demod/atv_demod_driver.c b/drivers/amlogic/atv_demod/atv_demod_driver.c index c16cd6ada0d3..c48ecbf22d22 100644 --- a/drivers/amlogic/atv_demod/atv_demod_driver.c +++ b/drivers/amlogic/atv_demod/atv_demod_driver.c @@ -786,6 +786,7 @@ static void aml_atvdemod_shutdown(struct platform_device *pdev) struct aml_atvdemod_device *dev = platform_get_drvdata(pdev); v4l2_frontend_shutdown(&dev->v4l2_fe); + adc_pll_down(); pr_info("%s: OK.\n", __func__); } diff --git a/drivers/amlogic/media/dtv_demod/amlfrontend.c b/drivers/amlogic/media/dtv_demod/amlfrontend.c index 3d43b53e290d..8070584ee66f 100644 --- a/drivers/amlogic/media/dtv_demod/amlfrontend.c +++ b/drivers/amlogic/media/dtv_demod/amlfrontend.c @@ -3080,7 +3080,8 @@ static int leave_mode(enum aml_fe_n_mode_t mode) } } - adc_set_pll_cntl(0, 0x04, NULL); + adc_set_pll_cntl(0, 0x4, NULL); + adc_set_pll_cntl(0, 0x8, NULL); demod_mode_para = UNKNOWN; /* should disable the adc ref signal for demod */ /*vdac_enable(0, 0x2);*/ @@ -3736,6 +3737,7 @@ static void aml_dtvdemod_shutdown(struct platform_device *pdev) leave_mode(nmode); dtvdd_devp->state = DTVDEMOD_ST_IDLE; } + adc_pll_down(); } diff --git a/drivers/amlogic/media/dtv_demod/demod_func.c b/drivers/amlogic/media/dtv_demod/demod_func.c index 6f394bc8dc4b..57d8b9a2f54f 100644 --- a/drivers/amlogic/media/dtv_demod/demod_func.c +++ b/drivers/amlogic/media/dtv_demod/demod_func.c @@ -485,7 +485,7 @@ void adc_dpll_setup(int clk_a, int clk_b, int clk_sys, int dvb_mode) /* debug only */ /*printk("adcpllctl=0x%x\n",adc_pll_cntl.d32);*/ - sts_pll = adc_set_pll_cntl(1, 0x0c, &ddemod_pll); + sts_pll = adc_set_pll_cntl(1, 0x8, &ddemod_pll); if (sts_pll < 0) { /*set pll fail*/ PR_ERR("%s:set pll fail! please check!\n", __func__); diff --git a/drivers/amlogic/media/vin/tvin/tvafe/tvafe.c b/drivers/amlogic/media/vin/tvin/tvafe/tvafe.c index 630042c9f536..6e0f3515063d 100644 --- a/drivers/amlogic/media/vin/tvin/tvafe/tvafe.c +++ b/drivers/amlogic/media/vin/tvin/tvafe/tvafe.c @@ -1485,6 +1485,11 @@ static int tvafe_drv_resume(struct platform_device *pdev) static void tvafe_drv_shutdown(struct platform_device *pdev) { + if (tvafe_cpu_type() == CPU_TYPE_TL1) { + W_APB_BIT(TVFE_VAFE_CTRL0, 0, 19, 1); + W_APB_BIT(TVFE_VAFE_CTRL1, 0, 8, 1); + } + adc_pll_down(); tvafe_pr_info("tvafe_drv_shutdown ok.\n"); } diff --git a/drivers/amlogic/media/vin/tvin/tvafe/tvafe.h b/drivers/amlogic/media/vin/tvin/tvafe/tvafe.h index 0c42042b9369..6dd89eef7260 100644 --- a/drivers/amlogic/media/vin/tvin/tvafe/tvafe.h +++ b/drivers/amlogic/media/vin/tvin/tvafe/tvafe.h @@ -32,7 +32,7 @@ /* ************************************************* */ /* *** macro definitions ********************************************* */ /* *********************************************************** */ -#define TVAFE_VER "Ref.2019/03/18" +#define TVAFE_VER "Ref.2019/03/29" /* used to set the flag of tvafe_dev_s */ #define TVAFE_FLAG_DEV_OPENED 0x00000010 diff --git a/drivers/amlogic/media/vin/tvin/tvafe/tvafe_general.c b/drivers/amlogic/media/vin/tvin/tvafe/tvafe_general.c index 3f7be31d44f7..f034e965251d 100644 --- a/drivers/amlogic/media/vin/tvin/tvafe/tvafe_general.c +++ b/drivers/amlogic/media/vin/tvin/tvafe/tvafe_general.c @@ -41,8 +41,6 @@ #define VAFE_CLK_SELECT 24 #define VAFE_CLK_SELECT_WIDTH 2 - - static unsigned int adc_pll_chg; /* TOP */ @@ -599,6 +597,21 @@ void tvafe_enable_avout(enum tvin_port_e port, bool enable) } } +void adc_pll_down(void) +{ + if (!adc_pll_chg && + tvafe_cpu_type() == CPU_TYPE_TL1 && + R_HIU_BIT(HHI_ADC_PLL_CNTL0_TL1, 28, 1)) { + W_HIU_BIT(HHI_ADC_PLL_CNTL0_TL1, 0, 28, 1); + tvafe_pr_info("%s: ok\n", __func__); + } +} + +/*module_sel*/ +/*ADC_EN_ATV_DEMOD 0x1*/ +/*ADC_EN_TVAFE 0x2*/ +/*ADC_EN_DTV_DEMOD 0x4*/ +/*ADC_EN_DTV_DEMODPLL 0x8*/ int adc_set_pll_cntl(bool on, unsigned int module_sel, void *pDtvPara) { unsigned int adc_pll_lock_cnt = 0; diff --git a/drivers/amlogic/media/vin/tvin/tvafe/tvafe_general.h b/drivers/amlogic/media/vin/tvin/tvafe/tvafe_general.h index 2fa4bcb5f22f..0e978f0c5048 100644 --- a/drivers/amlogic/media/vin/tvin/tvafe/tvafe_general.h +++ b/drivers/amlogic/media/vin/tvin/tvafe/tvafe_general.h @@ -137,7 +137,7 @@ #define ADC_EN_ATV_DEMOD 0x1 #define ADC_EN_TVAFE 0x2 #define ADC_EN_DTV_DEMOD 0x4 -#define ADC_EN_DTV_DEMODPLL 0xC +#define ADC_EN_DTV_DEMODPLL 0x8 #define LOG_ADC_CAL /* #define LOG_VGA_EDID */ diff --git a/drivers/amlogic/media/vout/vdac/vdac_dev.c b/drivers/amlogic/media/vout/vdac/vdac_dev.c index 7e925f41a908..2c605bf2a01b 100644 --- a/drivers/amlogic/media/vout/vdac/vdac_dev.c +++ b/drivers/amlogic/media/vout/vdac/vdac_dev.c @@ -749,7 +749,7 @@ static void amvdac_drv_shutdown(struct platform_device *pdev) if (s_vdac_data->cpu_id == VDAC_CPU_TXL || s_vdac_data->cpu_id == VDAC_CPU_TXLX) cntl1 = 0x0; - else if (s_vdac_data->cpu_id == VDAC_CPU_TL1) + else if (s_vdac_data->cpu_id >= VDAC_CPU_TL1) cntl1 = 0x80; else cntl1 = 0x8; diff --git a/include/linux/amlogic/media/frame_provider/tvin/tvin.h b/include/linux/amlogic/media/frame_provider/tvin/tvin.h index 508585acd746..0e46c71abdd8 100644 --- a/include/linux/amlogic/media/frame_provider/tvin/tvin.h +++ b/include/linux/amlogic/media/frame_provider/tvin/tvin.h @@ -472,13 +472,6 @@ struct tvafe_pin_mux_s { *function defined applied for other driver */ -/* - *adc pll ctl, atv demod & tvafe use the same adc module - * module index: atv demod:0x01; tvafe:0x2 - */ - -/* extern void adc_set_pll_cntl(bool on, unsigned int module_sel);*/ - struct dfe_adcpll_para { unsigned int adcpllctl; unsigned int demodctl; @@ -509,6 +502,11 @@ struct rx_audio_stat_s { bool afifo_thres_pass; }; +extern void adc_pll_down(void); +/*ADC_EN_ATV_DEMOD 0x1*/ +/*ADC_EN_TVAFE 0x2*/ +/*ADC_EN_DTV_DEMOD 0x4*/ +/*ADC_EN_DTV_DEMODPLL 0x8*/ extern int adc_set_pll_cntl(bool on, unsigned int module_sel, void *pDtvPara); extern void tvafe_set_ddemod_default(void);/* add for dtv demod*/ extern void rx_get_audio_status(struct rx_audio_stat_s *aud_sts);