From cba247e20b9e47ae1f7ac8a43d837b127618ffed Mon Sep 17 00:00:00 2001 From: "nengwen.chen" Date: Fri, 23 Nov 2018 17:11:25 +0800 Subject: [PATCH] atv_demod: add atv demod support for tl1 [1/1] PD#172587 Problem: 1.add atv demod driver and dts config for tl1. 2.merge from bringup/amlogic-4.9/tl1-20181111. Solution: add atv demod driver and dts config for tl1 Verify: verified by t962x2_x301 Change-Id: Ibbc00f9d478a9f5e52c6333b9a819aac381894ec Signed-off-by: nengwen.chen --- arch/arm/boot/dts/amlogic/tl1_pxp.dts | 15 ++++++++++++++ arch/arm/boot/dts/amlogic/tl1_t962x2_skt.dts | 15 ++++++++++++++ arch/arm/boot/dts/amlogic/tl1_t962x2_x301.dts | 15 ++++++++++++++ drivers/amlogic/atv_demod/atv_demod_access.c | 29 ++++++++++++++++++++++++++- drivers/amlogic/atv_demod/atv_demod_driver.c | 15 +++++++++++--- drivers/amlogic/atv_demod/atv_demod_monitor.c | 4 +++- drivers/amlogic/atv_demod/atv_demod_ops.c | 9 +++++++-- drivers/amlogic/atv_demod/atvauddemod_func.c | 2 +- drivers/amlogic/atv_demod/atvdemod_func.c | 15 +++++++++----- 9 files changed, 106 insertions(+), 13 deletions(-) diff --git a/arch/arm/boot/dts/amlogic/tl1_pxp.dts b/arch/arm/boot/dts/amlogic/tl1_pxp.dts index de44e5a..7a47eaa 100644 --- a/arch/arm/boot/dts/amlogic/tl1_pxp.dts +++ b/arch/arm/boot/dts/amlogic/tl1_pxp.dts @@ -558,6 +558,21 @@ tuner_xtal_cap = <25>; /* when tuner_xtal_mode = 3, set 25 */ }; + atv-demod { + compatible = "amlogic, atv-demod"; + status = "okay"; + tuner = <&tuner>; + btsc_sap_mode = <1>; + /* pinctrl-names="atvdemod_agc_pins"; */ + /* pinctrl-0=<&atvdemod_agc_pins>; */ + reg = <0xff656000 0x2000 /* demod reg */ + 0xff63c000 0x2000 /* hiu reg */ + 0xff634000 0x2000 /* periphs reg */ + 0xff64a000 0x2000>; /* audio reg */ + reg_23cf = <0x88188832>; + /*default:0x88188832;r840 on haier:0x48188832*/ + }; + }; /* end of / */ &i2c0 { diff --git a/arch/arm/boot/dts/amlogic/tl1_t962x2_skt.dts b/arch/arm/boot/dts/amlogic/tl1_t962x2_skt.dts index 0087b40..000aa09 100644 --- a/arch/arm/boot/dts/amlogic/tl1_t962x2_skt.dts +++ b/arch/arm/boot/dts/amlogic/tl1_t962x2_skt.dts @@ -877,6 +877,21 @@ tuner_xtal_cap = <25>; /* when tuner_xtal_mode = 3, set 25 */ }; + atv-demod { + compatible = "amlogic, atv-demod"; + status = "okay"; + tuner = <&tuner>; + btsc_sap_mode = <1>; + /* pinctrl-names="atvdemod_agc_pins"; */ + /* pinctrl-0=<&atvdemod_agc_pins>; */ + reg = <0xff656000 0x2000 /* demod reg */ + 0xff63c000 0x2000 /* hiu reg */ + 0xff634000 0x2000 /* periphs reg */ + 0xff64a000 0x2000>; /* audio reg */ + reg_23cf = <0x88188832>; + /*default:0x88188832;r840 on haier:0x48188832*/ + }; + bt-dev{ compatible = "amlogic, bt-dev"; status = "okay"; diff --git a/arch/arm/boot/dts/amlogic/tl1_t962x2_x301.dts b/arch/arm/boot/dts/amlogic/tl1_t962x2_x301.dts index b8934ab..79dec39 100644 --- a/arch/arm/boot/dts/amlogic/tl1_t962x2_x301.dts +++ b/arch/arm/boot/dts/amlogic/tl1_t962x2_x301.dts @@ -882,6 +882,21 @@ tuner_xtal_cap = <25>; /* when tuner_xtal_mode = 3, set 25 */ }; + atv-demod { + compatible = "amlogic, atv-demod"; + status = "okay"; + tuner = <&tuner>; + btsc_sap_mode = <1>; + /* pinctrl-names="atvdemod_agc_pins"; */ + /* pinctrl-0=<&atvdemod_agc_pins>; */ + reg = <0xff656000 0x2000 /* demod reg */ + 0xff63c000 0x2000 /* hiu reg */ + 0xff634000 0x2000 /* periphs reg */ + 0xff64a000 0x2000>; /* audio reg */ + reg_23cf = <0x88188832>; + /*default:0x88188832;r840 on haier:0x48188832*/ + }; + bt-dev{ compatible = "amlogic, bt-dev"; status = "okay"; diff --git a/drivers/amlogic/atv_demod/atv_demod_access.c b/drivers/amlogic/atv_demod/atv_demod_access.c index 390c5d0..796ddf1 100644 --- a/drivers/amlogic/atv_demod/atv_demod_access.c +++ b/drivers/amlogic/atv_demod/atv_demod_access.c @@ -38,6 +38,12 @@ int amlatvdemod_reg_read(unsigned int reg, unsigned int *val) pr_err("%s GCLK_MPEG0:0x%x\n", __func__, ret); return 0; } + } else if (is_meson_tl1_cpu()) { + amlatvdemod_hiu_reg_read(HHI_GCLK_MPEG0, &ret); + if (0 == ((1 << 22) & ret)) { + pr_err("%s GCLK_MPEG0:0x%x\n", __func__, ret); + return 0; + } } else if (0 == (ADC_EN_ATV_DEMOD & tvafe_adc_get_pll_flag())) { /* pr_dbg("%s atv demod pll not init\n", __func__); */ return 0; @@ -60,6 +66,12 @@ int amlatvdemod_reg_write(unsigned int reg, unsigned int val) pr_err("%s GCLK_MPEG0:0x%x\n", __func__, ret); return 0; } + } else if (is_meson_tl1_cpu()) { + amlatvdemod_hiu_reg_read(HHI_GCLK_MPEG0, &ret); + if (0 == ((1 << 22) & ret)) { + pr_err("%s GCLK_MPEG0:0x%x\n", __func__, ret); + return 0; + } } else if (0 == (ADC_EN_ATV_DEMOD & tvafe_adc_get_pll_flag())) { /* pr_dbg("%s atv demod pll not init\n", __func__); */ return 0; @@ -73,6 +85,7 @@ int amlatvdemod_reg_write(unsigned int reg, unsigned int val) int atvaudiodem_reg_read(unsigned int reg, unsigned int *val) { +#if 0 int ret = 0; if (is_meson_txlx_cpu() || is_meson_txhd_cpu()) { @@ -81,8 +94,14 @@ int atvaudiodem_reg_read(unsigned int reg, unsigned int *val) pr_err("%s GCLK_MPEG0:0x%x\n", __func__, ret); return 0; } + } else if (is_meson_tl1_cpu()) { + amlatvdemod_hiu_reg_read(HHI_GCLK_MPEG0, &ret); + if (0 == ((1 << 28) & ret)) { + pr_err("%s GCLK_MPEG0:0x%x\n", __func__, ret); + return 0; + } } - +#endif if (amlatvdemod_devp->audio_reg_base) *val = readl(amlatvdemod_devp->audio_reg_base + reg); @@ -91,6 +110,7 @@ int atvaudiodem_reg_read(unsigned int reg, unsigned int *val) int atvaudiodem_reg_write(unsigned int reg, unsigned int val) { +#if 0 int ret = 0; if (is_meson_txlx_cpu() || is_meson_txhd_cpu()) { @@ -99,7 +119,14 @@ int atvaudiodem_reg_write(unsigned int reg, unsigned int val) pr_err("%s GCLK_MPEG0:0x%x\n", __func__, ret); return 0; } + } else if (is_meson_tl1_cpu()) { + amlatvdemod_hiu_reg_read(HHI_GCLK_MPEG0, &ret); + if (0 == ((1 << 28) & ret)) { + pr_err("%s GCLK_MPEG0:0x%x\n", __func__, ret); + return 0; + } } +#endif if (amlatvdemod_devp->audio_reg_base) writel(val, (amlatvdemod_devp->audio_reg_base + reg)); diff --git a/drivers/amlogic/atv_demod/atv_demod_driver.c b/drivers/amlogic/atv_demod/atv_demod_driver.c index ceb4f29..6f69f4b 100644 --- a/drivers/amlogic/atv_demod/atv_demod_driver.c +++ b/drivers/amlogic/atv_demod/atv_demod_driver.c @@ -93,20 +93,23 @@ static ssize_t aml_atvdemod_store(struct class *class, if (ret) pr_info("atv init error.\n"); } else if (!strncmp(parm[0], "audout_mode", 11)) { - if (is_meson_txlx_cpu() || is_meson_txhd_cpu()) { + if (is_meson_txlx_cpu() || is_meson_txhd_cpu() + || is_meson_tl1_cpu()) { atvauddemod_set_outputmode(); pr_info("atvauddemod_set_outputmode done ....\n"); } } else if (!strncmp(parm[0], "signal_audmode", 14)) { int stereo_flag, sap_flag; - if (is_meson_txlx_cpu() || is_meson_txhd_cpu()) { + if (is_meson_txlx_cpu() || is_meson_txhd_cpu() + || is_meson_tl1_cpu()) { update_btsc_mode(1, &stereo_flag, &sap_flag); pr_info("get signal_audmode done ....\n"); } } else if (!strncmp(parm[0], "clk", 3)) { adc_set_pll_cntl(1, 0x1, NULL); atvdemod_clk_init(); - if (is_meson_txlx_cpu() || is_meson_txhd_cpu()) + if (is_meson_txlx_cpu() || is_meson_txhd_cpu() + || is_meson_tl1_cpu()) aud_demod_clk_gate(1); pr_info("atvdemod_clk_init done ....\n"); } else if (!strncmp(parm[0], "tune", 4)) { @@ -625,6 +628,12 @@ static int aml_atvdemod_probe(struct platform_device *pdev) pr_info("audio_demod_reg_base = 0x%p.\n", dev->audio_demod_reg_base); + } else if (is_meson_tl1_cpu()) { + dev->audio_demod_reg_base = ioremap( + round_down(0xff600340, 0x3), 4); + + pr_info("audio_demod_reg_base = 0x%p.\n", + dev->audio_demod_reg_base); } aml_atvdemod_dt_parse(dev); diff --git a/drivers/amlogic/atv_demod/atv_demod_monitor.c b/drivers/amlogic/atv_demod/atv_demod_monitor.c index 86cd6fc..7982c32 100644 --- a/drivers/amlogic/atv_demod/atv_demod_monitor.c +++ b/drivers/amlogic/atv_demod/atv_demod_monitor.c @@ -62,7 +62,9 @@ static void atv_demod_monitor_do_work(struct work_struct *work) audio_thd_det(); if (atvaudio_det_outputmode_en && - (is_meson_txlx_cpu() || is_meson_txhd_cpu())) + (is_meson_txlx_cpu() + || is_meson_txhd_cpu() + || is_meson_tl1_cpu())) atvauddemod_set_outputmode(); if (atvdemod_det_nonstd_en) diff --git a/drivers/amlogic/atv_demod/atv_demod_ops.c b/drivers/amlogic/atv_demod/atv_demod_ops.c index 029d652..10c52d6 100644 --- a/drivers/amlogic/atv_demod/atv_demod_ops.c +++ b/drivers/amlogic/atv_demod/atv_demod_ops.c @@ -146,7 +146,7 @@ int atv_demod_enter_mode(struct dvb_frontend *fe) atvdemod_clk_init(); /* err_code = atvdemod_init(); */ - if (is_meson_txlx_cpu() || is_meson_txhd_cpu()) { + if (is_meson_txlx_cpu() || is_meson_txhd_cpu() || is_meson_tl1_cpu()) { aud_demod_clk_gate(1); /* atvauddemod_init(); */ } @@ -189,7 +189,7 @@ int atv_demod_leave_mode(struct dvb_frontend *fe) vdac_enable(0, 1); adc_set_pll_cntl(0, ADC_EN_ATV_DEMOD, NULL); - if (is_meson_txlx_cpu() || is_meson_txhd_cpu()) + if (is_meson_txlx_cpu() || is_meson_txhd_cpu() || is_meson_tl1_cpu()) aud_demod_clk_gate(0); amlatvdemod_devp->std = 0; @@ -405,11 +405,16 @@ static int atv_demod_set_config(struct dvb_frontend *fe, void *priv_cfg) case AML_ATVDEMOD_UNSCAN_MODE: priv->scanning = false; + /* No need to enable when exiting the scan, + * but enable when actually played. + */ +#if 0 if (priv->afc.enable) priv->afc.enable(&priv->afc); if (priv->monitor.enable) priv->monitor.enable(&priv->monitor); +#endif break; } diff --git a/drivers/amlogic/atv_demod/atvauddemod_func.c b/drivers/amlogic/atv_demod/atvauddemod_func.c index b787edc..4bd9219 100644 --- a/drivers/amlogic/atv_demod/atvauddemod_func.c +++ b/drivers/amlogic/atv_demod/atvauddemod_func.c @@ -1292,7 +1292,7 @@ void configure_adec(int Audio_mode) /* * set gate clk for btsc and nicam . */ - if (is_meson_txhd_cpu()) + if (is_meson_txhd_cpu() || is_meson_tl1_cpu()) adec_wr_reg(0x28, 0xa); set_standard(Audio_mode); diff --git a/drivers/amlogic/atv_demod/atvdemod_func.c b/drivers/amlogic/atv_demod/atvdemod_func.c index 286c161..fac7140 100644 --- a/drivers/amlogic/atv_demod/atvdemod_func.c +++ b/drivers/amlogic/atv_demod/atvdemod_func.c @@ -1579,7 +1579,10 @@ int atvdemod_clk_init(void) W_HIU_BIT(RESET1_REGISTER, 1, 7, 1); } #endif - W_HIU_REG(HHI_ATV_DMD_SYS_CLK_CNTL, 0x80); + if (is_meson_tl1_cpu()) + W_HIU_REG(HHI_ATV_DMD_SYS_CLK_CNTL, 0x1800080); + else + W_HIU_REG(HHI_ATV_DMD_SYS_CLK_CNTL, 0x80); /* read_version_register(); */ @@ -1709,14 +1712,16 @@ int amlfmt_aud_standard(int broad_std) int atvauddemod_init(void) { - if (is_meson_txlx_cpu() || is_meson_txhd_cpu()) { + if (is_meson_txlx_cpu() || is_meson_txhd_cpu() || is_meson_tl1_cpu()) { if (audio_thd_en) audio_thd_init(); if (aud_auto) aud_std = amlfmt_aud_standard(broad_std); - /* configure_adec(aud_std); */ - /* adec_soft_reset(); */ + else { + configure_adec(aud_std); + adec_soft_reset(); + } set_outputmode(aud_std, aud_mode); } else { /* for non support adec */ @@ -1737,7 +1742,7 @@ int atvdemod_init(void) /* 1.set system clock when atv enter*/ pr_err("%s do configure_receiver ...\n", __func__); - if (is_meson_txlx_cpu() || is_meson_txhd_cpu()) + if (is_meson_txlx_cpu() || is_meson_txhd_cpu() || is_meson_tl1_cpu()) sound_format = 1; configure_receiver(broad_std, if_freq, if_inv, gde_curve, sound_format); pr_err("%s do atv_dmd_misc ...\n", __func__); -- 2.7.4