Lines Matching +full:charge +full:- +full:pump +full:- +full:current
1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * Conexant cx24123/cx24109 - DVB QPSK Satellite demod/tuner driver
7 * Support for KWorld DVB-S 100 by Vadim Catana <skystar@moldova.cc>
9 * Support for CX24123/CX24113-NIM by Patrick Boettcher <pb@linuxtv.org>
26 "(1-9, default:off).");
197 {0x0d, 0x7f}, /* Force driver to shift until the maximum (+-10 MHz) */
198 {0x0e, 0x03}, /* Default non-inverted, FEC 3/4 (default) */
210 {0x2c, 0x00}, /* DiSEqC Message (0x2c - 0x31) */
217 {0x33, 0x00}, /* Interrupts off (0x33 - 0x34) */
229 {0x67, 0x83}, /* Non-DCII symbol clock */
243 err = i2c_transfer(state->i2c, &msg, 1); in cx24123_i2c_writereg()
262 ret = i2c_transfer(state->i2c, msg, 2); in cx24123_i2c_readreg()
275 cx24123_i2c_readreg(state, state->config->demod_address, reg)
277 cx24123_i2c_writereg(state, state->config->demod_address, reg, val)
301 return -EINVAL; in cx24123_set_inversion()
381 return -EOPNOTSUPP; in cx24123_set_fec()
448 if ((srate > state->frontend.ops.info.symbol_rate_max) || in cx24123_set_symbolrate()
449 (srate < state->frontend.ops.info.symbol_rate_min)) in cx24123_set_symbolrate()
450 return -EOPNOTSUPP; in cx24123_set_symbolrate()
504 struct dtv_frontend_properties *p = &fe->dtv_property_cache; in cx24123_pll_calculate()
505 struct cx24123_state *state = fe->demodulator_priv; in cx24123_pll_calculate()
508 int pump = 2; in cx24123_pll_calculate() local
515 state->VCAarg = cx24123_AGC_vals[0].VCAprogdata; in cx24123_pll_calculate()
516 state->VGAarg = cx24123_AGC_vals[0].VGAprogdata; in cx24123_pll_calculate()
517 state->bandselectarg = cx24123_bandselect_vals[0].progdata; in cx24123_pll_calculate()
524 if ((agcv->symbolrate_low <= p->symbol_rate) && in cx24123_pll_calculate()
525 (agcv->symbolrate_high >= p->symbol_rate)) { in cx24123_pll_calculate()
526 state->VCAarg = agcv->VCAprogdata; in cx24123_pll_calculate()
527 state->VGAarg = agcv->VGAprogdata; in cx24123_pll_calculate()
528 state->FILTune = agcv->FILTune; in cx24123_pll_calculate()
536 if ((bsv->freq_low <= p->frequency) && in cx24123_pll_calculate()
537 (bsv->freq_high >= p->frequency)) in cx24123_pll_calculate()
541 band = force_band - 1; in cx24123_pll_calculate()
543 state->bandselectarg = cx24123_bandselect_vals[band].progdata; in cx24123_pll_calculate()
546 /* determine the charge pump current */ in cx24123_pll_calculate()
547 if (p->frequency < (cx24123_bandselect_vals[band].freq_low + in cx24123_pll_calculate()
549 pump = 0x01; in cx24123_pll_calculate()
551 pump = 0x02; in cx24123_pll_calculate()
556 ndiv = (((p->frequency * vco_div * 10) / in cx24123_pll_calculate()
558 adiv = (((p->frequency * vco_div * 10) / in cx24123_pll_calculate()
562 ndiv--; in cx24123_pll_calculate()
564 /* control bits 11, refdiv 11, charge pump polarity 1, in cx24123_pll_calculate()
565 * charge pump current, ndiv, adiv */ in cx24123_pll_calculate()
566 state->pllarg = (3 << 19) | (3 << 17) | (1 << 16) | in cx24123_pll_calculate()
567 (pump << 14) | (ndiv << 5) | adiv; in cx24123_pll_calculate()
573 * Tuner data is 21 bits long, must be left-aligned in data.
579 struct cx24123_state *state = fe->demodulator_priv; in cx24123_pll_writereg()
597 return -EREMOTEIO; in cx24123_pll_writereg()
609 return -EREMOTEIO; in cx24123_pll_writereg()
622 return -EREMOTEIO; in cx24123_pll_writereg()
636 struct dtv_frontend_properties *p = &fe->dtv_property_cache; in cx24123_pll_tune()
637 struct cx24123_state *state = fe->demodulator_priv; in cx24123_pll_tune()
640 dprintk("frequency=%i\n", p->frequency); in cx24123_pll_tune()
644 return -EINVAL; in cx24123_pll_tune()
648 cx24123_pll_writereg(fe, state->VCAarg); in cx24123_pll_tune()
649 cx24123_pll_writereg(fe, state->VGAarg); in cx24123_pll_tune()
652 cx24123_pll_writereg(fe, state->bandselectarg); in cx24123_pll_tune()
653 cx24123_pll_writereg(fe, state->pllarg); in cx24123_pll_tune()
657 cx24123_writereg(state, 0x27, state->FILTune >> 2); in cx24123_pll_tune()
658 cx24123_writereg(state, 0x28, val | (state->FILTune & 0x3)); in cx24123_pll_tune()
660 dprintk("pll tune VCA=%d, band=%d, pll=%d\n", state->VCAarg, in cx24123_pll_tune()
661 state->bandselectarg, state->pllarg); in cx24123_pll_tune()
675 /* mode == 1 -> i2c-repeater, 0 -> bti */
688 struct cx24123_state *state = fe->demodulator_priv; in cx24123_initfe()
699 if (state->config->lnb_polarity) in cx24123_initfe()
703 if (state->config->dont_use_pll) in cx24123_initfe()
712 struct cx24123_state *state = fe->demodulator_priv; in cx24123_set_voltage()
725 /* already handled in cx88-dvb */ in cx24123_set_voltage()
728 return -EINVAL; in cx24123_set_voltage()
751 struct cx24123_state *state = fe->demodulator_priv; in cx24123_send_diseqc_msg()
767 for (i = 0; i < cmd->msg_len; i++) in cx24123_send_diseqc_msg()
768 cx24123_writereg(state, 0x2C + i, cmd->msg[i]); in cx24123_send_diseqc_msg()
772 ((cmd->msg_len-3) & 3)); in cx24123_send_diseqc_msg()
787 struct cx24123_state *state = fe->demodulator_priv; in cx24123_diseqc_send_burst()
809 return -EINVAL; in cx24123_diseqc_send_burst()
823 struct cx24123_state *state = fe->demodulator_priv; in cx24123_read_status()
827 if (state->config->dont_use_pll) { in cx24123_read_status()
829 if (fe->ops.tuner_ops.get_status) in cx24123_read_status()
830 fe->ops.tuner_ops.get_status(fe, &tun_status); in cx24123_read_status()
844 /* Reed-Solomon Status */ in cx24123_read_status()
860 struct cx24123_state *state = fe->demodulator_priv; in cx24123_read_ber()
876 struct cx24123_state *state = fe->demodulator_priv; in cx24123_read_signal_strength()
888 struct cx24123_state *state = fe->demodulator_priv; in cx24123_read_snr()
892 *snr = 65535 - (((u16)cx24123_readreg(state, 0x18) << 8) | in cx24123_read_snr()
902 struct cx24123_state *state = fe->demodulator_priv; in cx24123_set_frontend()
903 struct dtv_frontend_properties *p = &fe->dtv_property_cache; in cx24123_set_frontend()
907 if (state->config->set_ts_params) in cx24123_set_frontend()
908 state->config->set_ts_params(fe, 0); in cx24123_set_frontend()
910 state->currentfreq = p->frequency; in cx24123_set_frontend()
911 state->currentsymbolrate = p->symbol_rate; in cx24123_set_frontend()
913 cx24123_set_inversion(state, p->inversion); in cx24123_set_frontend()
914 cx24123_set_fec(state, p->fec_inner); in cx24123_set_frontend()
915 cx24123_set_symbolrate(state, p->symbol_rate); in cx24123_set_frontend()
917 if (!state->config->dont_use_pll) in cx24123_set_frontend()
919 else if (fe->ops.tuner_ops.set_params) in cx24123_set_frontend()
920 fe->ops.tuner_ops.set_params(fe); in cx24123_set_frontend()
929 if (state->config->agc_callback) in cx24123_set_frontend()
930 state->config->agc_callback(fe); in cx24123_set_frontend()
938 struct cx24123_state *state = fe->demodulator_priv; in cx24123_get_frontend()
942 if (cx24123_get_inversion(state, &p->inversion) != 0) { in cx24123_get_frontend()
944 return -EREMOTEIO; in cx24123_get_frontend()
946 if (cx24123_get_fec(state, &p->fec_inner) != 0) { in cx24123_get_frontend()
948 return -EREMOTEIO; in cx24123_get_frontend()
950 p->frequency = state->currentfreq; in cx24123_get_frontend()
951 p->symbol_rate = state->currentsymbolrate; in cx24123_get_frontend()
958 struct cx24123_state *state = fe->demodulator_priv; in cx24123_set_tone()
975 return -EINVAL; in cx24123_set_tone()
1006 struct cx24123_state *state = fe->demodulator_priv; in cx24123_release()
1008 i2c_del_adapter(&state->tuner_i2c_adapter); in cx24123_release()
1018 return i2c_transfer(state->i2c, msg, num); in cx24123_tuner_i2c_tuner_xfer()
1034 struct cx24123_state *state = fe->demodulator_priv; in cx24123_get_tuner_i2c_adapter()
1035 return &state->tuner_i2c_adapter; in cx24123_get_tuner_i2c_adapter()
1055 state->config = config; in cx24123_attach()
1056 state->i2c = i2c; in cx24123_attach()
1059 state->demod_rev = cx24123_readreg(state, 0x00); in cx24123_attach()
1060 switch (state->demod_rev) { in cx24123_attach()
1068 err("wrong demod revision: %x\n", state->demod_rev); in cx24123_attach()
1073 memcpy(&state->frontend.ops, &cx24123_ops, in cx24123_attach()
1075 state->frontend.demodulator_priv = state; in cx24123_attach()
1078 if (config->dont_use_pll) in cx24123_attach()
1081 strscpy(state->tuner_i2c_adapter.name, "CX24123 tuner I2C bus", in cx24123_attach()
1082 sizeof(state->tuner_i2c_adapter.name)); in cx24123_attach()
1083 state->tuner_i2c_adapter.algo = &cx24123_tuner_i2c_algo; in cx24123_attach()
1084 state->tuner_i2c_adapter.algo_data = NULL; in cx24123_attach()
1085 state->tuner_i2c_adapter.dev.parent = i2c->dev.parent; in cx24123_attach()
1086 i2c_set_adapdata(&state->tuner_i2c_adapter, state); in cx24123_attach()
1087 if (i2c_add_adapter(&state->tuner_i2c_adapter) < 0) { in cx24123_attach()
1092 return &state->frontend; in cx24123_attach()