block_reg, block_val);
block_val = atv_dmd_rd_long(block_addr, block_reg);
pr_dbg("readback_val:0x%x\n", block_val);
- } else if (!strncmp(parm[0], "pin_mux", 7)) {
- aml_atvdemod_dev->pin = devm_pinctrl_get_select(
- aml_atvdemod_dev->dev,
- aml_atvdemod_dev->pin_name);
- pr_dbg("atvdemod agc pinmux name:%s\n",
- aml_atvdemod_dev->pin_name);
} else if (!strncmp(parm[0], "snr_cur", 7)) {
data_snr_avg = aml_atvdemod_get_snr_ex();
pr_dbg("**********snr_cur:%d*********\n", data_snr_avg);
ret = of_property_read_string(node, "pinctrl-names",
&pdev->pin_name);
if (ret) {
- pdev->pin = NULL;
+ pdev->agc_pin = NULL;
pr_err("can't find agc pinmux.\n");
} else {
-#if 0
- amlatvdemod_devp->pin = devm_pinctrl_get_select(
- &pdev->dev, pdev->pin_name);
+#if 0 /* Get it when you actually use it */
+ pdev->agc_pin = devm_pinctrl_get_select(
+ pdev->dev, pdev->pin_name);
#endif
pr_err("atvdemod agc pinmux name: %s\n",
pdev->pin_name);
pdev->tuner_id = AM_TUNER_SI2159;
else if (!strncmp(str, "r840_tuner", 10))
pdev->tuner_id = AM_TUNER_R840;
+ else if (!strncmp(str, "r842_tuner", 10))
+ pdev->tuner_id = AM_TUNER_R842;
else
pr_err("can't find tuner: %s.\n", str);
}
if (!dev->tuner_attached) {
switch (dev->tuner_id) {
case AM_TUNER_R840:
+ p = v4l2_attach(r840_attach, fe,
+ dev->i2c_adp, dev->i2c_addr);
+ break;
+ case AM_TUNER_R842:
+ p = v4l2_attach(r842_attach, fe,
+ dev->i2c_adp, dev->i2c_addr);
break;
case AM_TUNER_SI2151:
p = v4l2_attach(si2151_attach, fe,
dev->demod_reg_base);
res = platform_get_resource(pdev, IORESOURCE_MEM, 1);
+ if (!res) {
+ pr_err("no hiu demod memory resource.\n");
+ dev->hiu_reg_base = NULL;
+ } else {
+ size_io_reg = resource_size(res);
+ dev->hiu_reg_base = devm_ioremap_nocache(
+ &pdev->dev, res->start, size_io_reg);
+ if (!dev->hiu_reg_base) {
+ pr_err("hiu ioremap failed.\n");
+ goto fail_get_resource;
+ }
+
+ pr_info("hiu start = 0x%p, size = 0x%x, hiu_reg_base = 0x%p.\n",
+ (void *) res->start, size_io_reg,
+ dev->hiu_reg_base);
+ }
+
+ res = platform_get_resource(pdev, IORESOURCE_MEM, 2);
+ if (!res) {
+ pr_err("no periphs demod memory resource.\n");
+ dev->periphs_reg_base = NULL;
+ } else {
+ size_io_reg = resource_size(res);
+ dev->periphs_reg_base = devm_ioremap_nocache(
+ &pdev->dev, res->start, size_io_reg);
+ if (!dev->periphs_reg_base) {
+ pr_err("periphs ioremap failed.\n");
+ goto fail_get_resource;
+ }
+
+ pr_info("periphs start = 0x%p, size = 0x%x, periphs_reg_base = 0x%p.\n",
+ (void *) res->start, size_io_reg,
+ dev->periphs_reg_base);
+ }
+
+ res = platform_get_resource(pdev, IORESOURCE_MEM, 3);
if (!res) {
pr_err("no audio demod memory resource.\n");
dev->audio_reg_base = NULL;
dev->audio_reg_base);
}
+#if 0 /* form dts config */
if (is_meson_txlx_cpu() || is_meson_txhd_cpu())
dev->hiu_reg_base = ioremap(0xff63c000, 0x2000);
else
dev->periphs_reg_base = ioremap(0xc8834000, 0x2000);
pr_info("periphs_reg_base = 0x%p.\n", dev->periphs_reg_base);
+#endif
- /* add for audio system control */
- dev->audio_demod_reg_base = ioremap(round_down(0xffd0d340, 0x3), 4);
+ if (is_meson_txlx_cpu() || is_meson_txhd_cpu()) {
+ /* add for audio system control */
+ dev->audio_demod_reg_base = ioremap(
+ round_down(0xffd0d340, 0x3), 4);
- pr_info("audio_demod_reg_base = 0x%p.\n", dev->audio_demod_reg_base);
+ pr_info("audio_demod_reg_base = 0x%p.\n",
+ dev->audio_demod_reg_base);
+ }
aml_atvdemod_dt_parse(dev);
static const struct of_device_id aml_atvdemod_dt_match[] = {
{
- .compatible = "amlogic, aml_atvdemod",
+ .compatible = "amlogic, atv-demod",
},
{
},
unsigned int if_inv;
u64 std;
unsigned int audmode;
-
int fre_offset;
- struct pinctrl *pin;
+
+ struct pinctrl *agc_pin;
const char *pin_name;
struct v4l2_frontend v4l2_fe;
return 0;
#endif
if (amlatvdemod_devp->pin_name != NULL)
- amlatvdemod_devp->pin =
+ amlatvdemod_devp->agc_pin =
devm_pinctrl_get_select(amlatvdemod_devp->dev,
amlatvdemod_devp->pin_name);
set_aft_thread_enable(0, 0);
atvdemod_uninit();
- if (amlatvdemod_devp->pin != NULL) {
- devm_pinctrl_put(amlatvdemod_devp->pin);
- amlatvdemod_devp->pin = NULL;
+ if (amlatvdemod_devp->agc_pin != NULL) {
+ devm_pinctrl_put(amlatvdemod_devp->agc_pin);
+ amlatvdemod_devp->agc_pin = NULL;
}
vdac_enable(0, 1);
if ((p->param.std != amlatvdemod_devp->std) ||
(p->tuner_id == AM_TUNER_R840) ||
+ (p->tuner_id == AM_TUNER_R842) ||
(p->tuner_id == AM_TUNER_SI2151) ||
(p->tuner_id == AM_TUNER_MXL661) ||
(p->tuner_id == AM_TUNER_SI2159)) {
- /* open AGC if needed */
- if (amlatvdemod_devp->pin != NULL)
- devm_pinctrl_put(amlatvdemod_devp->pin);
- if (amlatvdemod_devp->pin_name)
- amlatvdemod_devp->pin =
- devm_pinctrl_get_select(amlatvdemod_devp->dev,
- amlatvdemod_devp->pin_name);
#if 0 /* unused */
last_frq = p->param.frequency;
last_std = p->param.std;
pr_dbg("get varify_cnt:%d, cnt:%d, std_bk:0x%x\n",
varify_cnt, i,
(unsigned int) std_bk);
- if ((v4l2_fe->tuner_id == AM_TUNER_R840
+ if (((v4l2_fe->tuner_id == AM_TUNER_R840
+ || v4l2_fe->tuner_id == AM_TUNER_R842)
&& varify_cnt > 0)
|| varify_cnt > 3)
break;
while (abs(afc) > AFC_BEST_LOCK) {
if (tuner_id == AM_TUNER_SI2151 ||
tuner_id == AM_TUNER_SI2159 ||
- tuner_id == AM_TUNER_R840)
+ tuner_id == AM_TUNER_R840 ||
+ tuner_id == AM_TUNER_R842)
usleep_range(20 * 1000, 20 * 1000 + 100);
else if (tuner_id == AM_TUNER_MXL661)
usleep_range(30 * 1000, 30 * 1000 + 100);
if (fe->ops.analog_ops.get_afc &&
((tuner_id == AM_TUNER_R840) ||
+ (tuner_id == AM_TUNER_R842) ||
(tuner_id == AM_TUNER_SI2151) ||
(tuner_id == AM_TUNER_SI2159) ||
(tuner_id == AM_TUNER_MXL661)))
/*from the current freq start, and set the afc_step*/
/*if step is 2Mhz,r840 will miss program*/
- if (slow_mode || (tuner_id == AM_TUNER_R840)
- || (p->afc_range == ATV_AFC_1_0MHZ)) {
+ if (slow_mode ||
+ (tuner_id == AM_TUNER_R840 || tuner_id == AM_TUNER_R842) ||
+ (p->afc_range == ATV_AFC_1_0MHZ)) {
pr_dbg("[%s] slow mode to search the channel\n", __func__);
afc_step = ATV_AFC_1_0MHZ;
} else if (!slow_mode) {
do {
if (tuner_id == AM_TUNER_MXL661) {
usleep_range(30 * 1000, 30 * 1000 + 100);
- } else if (tuner_id == AM_TUNER_R840) {
+ } else if (tuner_id == AM_TUNER_R840 ||
+ tuner_id == AM_TUNER_R842) {
usleep_range(20 * 1000, 20 * 1000 + 100);
fe->ops.tuner_ops.get_status(fe,
&tuner_state);
tuner_status_cnt_local--;
if (((ade_state == V4L2_HAS_LOCK ||
tuner_state == V4L2_HAS_LOCK) &&
- (tuner_id != AM_TUNER_R840)) ||
+ (tuner_id != AM_TUNER_R840 &&
+ tuner_id != AM_TUNER_R842)) ||
((ade_state == V4L2_HAS_LOCK &&
tuner_state == V4L2_HAS_LOCK) &&
- (tuner_id == AM_TUNER_R840))) {
+ (tuner_id == AM_TUNER_R840 ||
+ tuner_id == AM_TUNER_R842))) {
pll_lock = true;
break;
}
atv_dmd_wr_byte(0x0f, 0x45, 0x90); /*zhuangwei*/
atv_dmd_wr_long(0x0f, 0x44, 0x5c8808c1);/*zhuangwei*/
- if (amlatvdemod_devp->tuner_id == AM_TUNER_R840) {
+ if (amlatvdemod_devp->tuner_id == AM_TUNER_R840 ||
+ amlatvdemod_devp->tuner_id == AM_TUNER_R842) {
atv_dmd_wr_long(0x0f, 0x3c, reg_23cf);/*zhuangwei*/
/*guanzhong@20150804a*/
atv_dmd_wr_byte(APB_BLOCK_ADDR_SIF_STG_2, 0x00, 0x1);
atv_dmd_wr_long(APB_BLOCK_ADDR_ADC_SE, 0x0, 0x03180e0f);
else
atv_dmd_wr_long(APB_BLOCK_ADDR_ADC_SE, 0x0, 0x03150e0f);
- if (amlatvdemod_devp->tuner_id == AM_TUNER_R840) {
+ if (amlatvdemod_devp->tuner_id == AM_TUNER_R840 ||
+ amlatvdemod_devp->tuner_id == AM_TUNER_R842) {
/*config pwm for tuner r840*/
atv_dmd_wr_byte(APB_BLOCK_ADDR_ADC_SE, 1, 0xf);
}
atv_dmd_wr_long(APB_BLOCK_ADDR_AGC_PWM, 0x04, 0xc8);
/*26 dB dynamic range*/
atv_dmd_wr_byte(APB_BLOCK_ADDR_AGC_PWM, 0x09, 0xa);
- if (amlatvdemod_devp->tuner_id == AM_TUNER_R840) {
+ if (amlatvdemod_devp->tuner_id == AM_TUNER_R840 ||
+ amlatvdemod_devp->tuner_id == AM_TUNER_R842) {
/*config pwm for tuner r840*/
atv_dmd_wr_long(APB_BLOCK_ADDR_AGC_PWM, 0, 0xc80);
/* guanzhong for Tuner AGC shock */
aud_std == AUDIO_STANDARD_BTSC)
audio_mode_det(aud_mode);
*/
- set_outputmode(aud_std, aud_mode);
+ if (is_meson_txlx_cpu() || is_meson_txhd_cpu())
+ set_outputmode(aud_std, aud_mode);
if (non_std_onoff)
atv_dmd_non_std_set(true);
if (amlatvdemod_devp->tuner_id == AM_TUNER_R840) {
if_freq = amlatvdemod_devp->if_freq;
if_inv = amlatvdemod_devp->if_inv;
+ } else if (amlatvdemod_devp->tuner_id == AM_TUNER_R842) {
+ if_freq = amlatvdemod_devp->if_freq;
+ if_inv = amlatvdemod_devp->if_inv;
} else if (amlatvdemod_devp->tuner_id == AM_TUNER_MXL661) {
if_freq = amlatvdemod_devp->if_freq;
if_inv = amlatvdemod_devp->if_inv;
return 0;
}
} else if (0 == (ADC_EN_ATV_DEMOD & tvafe_adc_get_pll_flag())) {
- pr_info("%s atv demod pll not init\n", __func__);
+ pr_dbg("%s atv demod pll not init\n", __func__);
return 0;
}
return 0;
}
} else if (0 == (ADC_EN_ATV_DEMOD & tvafe_adc_get_pll_flag())) {
- pr_info("%s atv demod pll not init\n", __func__);
+ pr_dbg("%s atv demod pll not init\n", __func__);
return 0;
}
int amlatvdemod_hiu_reg_read(unsigned int reg, unsigned int *val)
{
- *val = readl(amlatvdemod_devp->hiu_reg_base + ((reg - 0x1000)<<2));
+ if (amlatvdemod_devp->hiu_reg_base)
+ *val = readl(amlatvdemod_devp->hiu_reg_base +
+ ((reg - 0x1000) << 2));
+
return 0;
}
int amlatvdemod_hiu_reg_write(unsigned int reg, unsigned int val)
{
- writel(val, (amlatvdemod_devp->hiu_reg_base + ((reg - 0x1000)<<2)));
+ if (amlatvdemod_devp->hiu_reg_base)
+ writel(val, (amlatvdemod_devp->hiu_reg_base +
+ ((reg - 0x1000) << 2)));
+
return 0;
}
int amlatvdemod_periphs_reg_read(unsigned int reg, unsigned int *val)
{
- *val = readl(amlatvdemod_devp->periphs_reg_base + ((reg - 0x1000)<<2));
+ if (amlatvdemod_devp->periphs_reg_base)
+ *val = readl(amlatvdemod_devp->periphs_reg_base +
+ ((reg - 0x1000) << 2));
+
return 0;
}
int amlatvdemod_periphs_reg_write(unsigned int reg, unsigned int val)
{
- writel(val, (amlatvdemod_devp->periphs_reg_base + ((reg - 0x1000)<<2)));
+ if (amlatvdemod_devp->periphs_reg_base)
+ writel(val, (amlatvdemod_devp->periphs_reg_base +
+ ((reg - 0x1000) << 2)));
+
return 0;
}
AM_TUNER_MXL661 = 10,
AM_TUNER_MXL608 = 11,
AM_TUNER_SI2159 = 12,
+ AM_TUNER_R842 = 13,
};
extern struct dvb_frontend *mxl661_attach(struct dvb_frontend *fe,
struct i2c_adapter *i2c_adap, u8 i2c_addr);
extern struct dvb_frontend *si2159_attach(struct dvb_frontend *fe,
struct i2c_adapter *i2c_adap, u8 i2c_addr);
+extern struct dvb_frontend *r840_attach(struct dvb_frontend *fe,
+ struct i2c_adapter *i2c_adap, u8 i2c_addr);
+extern struct dvb_frontend *r842_attach(struct dvb_frontend *fe,
+ struct i2c_adapter *i2c_adap, u8 i2c_addr);
/* For attach tuner driver end*/
#endif /* __AML_ATVDEMOD_H__ */