Lines Matching +full:clock +full:- +full:presc
1 // SPDX-License-Identifier: GPL-2.0-or-later
43 return a - b; in abssub()
45 return b - a; in abssub()
50 kfree(fe->tuner_priv); in stv6110_release()
51 fe->tuner_priv = NULL; in stv6110_release()
57 struct stv6110_priv *priv = fe->tuner_priv; in stv6110_write_regs()
61 .addr = priv->i2c_address, in stv6110_write_regs()
73 return -EINVAL; in stv6110_write_regs()
77 return -EINVAL; in stv6110_write_regs()
82 if (fe->ops.i2c_gate_ctrl) in stv6110_write_regs()
83 fe->ops.i2c_gate_ctrl(fe, 1); in stv6110_write_regs()
85 rc = i2c_transfer(priv->i2c, &msg, 1); in stv6110_write_regs()
89 if (fe->ops.i2c_gate_ctrl) in stv6110_write_regs()
90 fe->ops.i2c_gate_ctrl(fe, 0); in stv6110_write_regs()
98 struct stv6110_priv *priv = fe->tuner_priv; in stv6110_read_regs()
103 .addr = priv->i2c_address, in stv6110_read_regs()
108 .addr = priv->i2c_address, in stv6110_read_regs()
115 if (fe->ops.i2c_gate_ctrl) in stv6110_read_regs()
116 fe->ops.i2c_gate_ctrl(fe, 1); in stv6110_read_regs()
118 rc = i2c_transfer(priv->i2c, msg, 2); in stv6110_read_regs()
122 if (fe->ops.i2c_gate_ctrl) in stv6110_read_regs()
123 fe->ops.i2c_gate_ctrl(fe, 0); in stv6110_read_regs()
125 memcpy(&priv->regs[start], regs, len); in stv6110_read_regs()
167 struct stv6110_priv *priv = fe->tuner_priv; in stv6110_set_bandwidth()
176 r8 = (bandwidth / 2) / 1000000 - 5; in stv6110_set_bandwidth()
178 /* ctrl3, RCCLKOFF = 0 Activate the calibration Clock */ in stv6110_set_bandwidth()
180 priv->regs[RSTV6110_CTRL3] &= ~((1 << 6) | 0x1f); in stv6110_set_bandwidth()
181 priv->regs[RSTV6110_CTRL3] |= (r8 & 0x1f); in stv6110_set_bandwidth()
182 stv6110_write_regs(fe, &priv->regs[RSTV6110_CTRL3], RSTV6110_CTRL3, 1); in stv6110_set_bandwidth()
184 priv->regs[RSTV6110_STAT1] |= 0x02; in stv6110_set_bandwidth()
185 stv6110_write_regs(fe, &priv->regs[RSTV6110_STAT1], RSTV6110_STAT1, 1); in stv6110_set_bandwidth()
195 /* RCCLKOFF = 1 calibration done, deactivate the calibration Clock */ in stv6110_set_bandwidth()
196 priv->regs[RSTV6110_CTRL3] |= (1 << 6); in stv6110_set_bandwidth()
197 stv6110_write_regs(fe, &priv->regs[RSTV6110_CTRL3], RSTV6110_CTRL3, 1); in stv6110_set_bandwidth()
203 struct stv6110_priv *priv = fe->tuner_priv; in stv6110_init()
206 memcpy(priv->regs, buf0, 8); in stv6110_init()
207 /* K = (Reference / 1000000) - 16 */ in stv6110_init()
208 priv->regs[RSTV6110_CTRL1] &= ~(0x1f << 3); in stv6110_init()
209 priv->regs[RSTV6110_CTRL1] |= in stv6110_init()
210 ((((priv->mclk / 1000000) - 16) & 0x1f) << 3); in stv6110_init()
212 /* divisor value for the output clock */ in stv6110_init()
213 priv->regs[RSTV6110_CTRL2] &= ~0xc0; in stv6110_init()
214 priv->regs[RSTV6110_CTRL2] |= (priv->clk_div << 6); in stv6110_init()
216 stv6110_write_regs(fe, &priv->regs[RSTV6110_CTRL1], RSTV6110_CTRL1, 8); in stv6110_init()
225 struct stv6110_priv *priv = fe->tuner_priv; in stv6110_get_frequency()
231 divider = (priv->regs[RSTV6110_TUNING2] & 0x0f) << 8; in stv6110_get_frequency()
232 divider += priv->regs[RSTV6110_TUNING1]; in stv6110_get_frequency()
235 nbsteps = (priv->regs[RSTV6110_TUNING2] >> 6) & 3; in stv6110_get_frequency()
237 psd2 = (priv->regs[RSTV6110_TUNING2] >> 4) & 1; in stv6110_get_frequency()
239 freq = divider * (priv->mclk / 1000); in stv6110_get_frequency()
250 struct stv6110_priv *priv = fe->tuner_priv; in stv6110_set_frequency()
252 u32 divider, ref, p, presc, i, result_freq, vco_freq; in stv6110_set_frequency() local
256 frequency, priv->mclk); in stv6110_set_frequency()
258 /* K = (Reference / 1000000) - 16 */ in stv6110_set_frequency()
259 priv->regs[RSTV6110_CTRL1] &= ~(0x1f << 3); in stv6110_set_frequency()
260 priv->regs[RSTV6110_CTRL1] |= in stv6110_set_frequency()
261 ((((priv->mclk / 1000000) - 16) & 0x1f) << 3); in stv6110_set_frequency()
264 priv->regs[RSTV6110_CTRL2] &= ~0x0f; in stv6110_set_frequency()
265 priv->regs[RSTV6110_CTRL2] |= (priv->gain & 0x0f); in stv6110_set_frequency()
269 presc = 0; in stv6110_set_frequency()
272 presc = 1; in stv6110_set_frequency()
275 presc = 0; in stv6110_set_frequency()
278 presc = 1; in stv6110_set_frequency()
281 priv->regs[RSTV6110_TUNING2] &= ~(1 << 4); in stv6110_set_frequency()
282 priv->regs[RSTV6110_TUNING2] |= (p << 4); in stv6110_set_frequency()
284 /* PRESC32ON = presc */ in stv6110_set_frequency()
285 priv->regs[RSTV6110_TUNING2] &= ~(1 << 5); in stv6110_set_frequency()
286 priv->regs[RSTV6110_TUNING2] |= (presc << 5); in stv6110_set_frequency()
290 p_calc = (priv->mclk / 100000); in stv6110_set_frequency()
295 p_calc_opt = (priv->mclk / 100000); in stv6110_set_frequency()
299 ref = priv->mclk / ((1 << (r_div_opt + 1)) * (1 << (p + 1))); in stv6110_set_frequency()
303 priv->regs[RSTV6110_TUNING2] &= ~(3 << 6); in stv6110_set_frequency()
304 priv->regs[RSTV6110_TUNING2] |= (((r_div_opt) & 3) << 6); in stv6110_set_frequency()
307 priv->regs[RSTV6110_TUNING2] &= ~0x0f; in stv6110_set_frequency()
308 priv->regs[RSTV6110_TUNING2] |= (((divider) >> 8) & 0x0f); in stv6110_set_frequency()
311 priv->regs[RSTV6110_TUNING1] = (divider & 0xff); in stv6110_set_frequency()
314 priv->regs[RSTV6110_STAT1] |= 0x04; in stv6110_set_frequency()
315 stv6110_write_regs(fe, &priv->regs[RSTV6110_CTRL1], in stv6110_set_frequency()
329 vco_freq = divider * ((priv->mclk / 1000) / ((1 << (r_div_opt + 1)))); in stv6110_set_frequency()
338 struct dtv_frontend_properties *c = &fe->dtv_property_cache; in stv6110_set_params()
339 u32 bandwidth = carrier_width(c->symbol_rate, c->rolloff); in stv6110_set_params()
341 stv6110_set_frequency(fe, c->frequency); in stv6110_set_params()
349 struct stv6110_priv *priv = fe->tuner_priv; in stv6110_get_bandwidth()
355 r8 = priv->regs[RSTV6110_CTRL3] & 0x1f; in stv6110_get_bandwidth()
388 .addr = config->i2c_address, in stv6110_attach()
396 /* divisor value for the output clock */ in stv6110_attach()
398 reg0[2] |= (config->clk_div << 6); in stv6110_attach()
400 if (fe->ops.i2c_gate_ctrl) in stv6110_attach()
401 fe->ops.i2c_gate_ctrl(fe, 1); in stv6110_attach()
405 if (fe->ops.i2c_gate_ctrl) in stv6110_attach()
406 fe->ops.i2c_gate_ctrl(fe, 0); in stv6110_attach()
415 priv->i2c_address = config->i2c_address; in stv6110_attach()
416 priv->i2c = i2c; in stv6110_attach()
417 priv->mclk = config->mclk; in stv6110_attach()
418 priv->clk_div = config->clk_div; in stv6110_attach()
419 priv->gain = config->gain; in stv6110_attach()
421 memcpy(&priv->regs, ®0[1], 8); in stv6110_attach()
423 memcpy(&fe->ops.tuner_ops, &stv6110_tuner_ops, in stv6110_attach()
425 fe->tuner_priv = priv; in stv6110_attach()
426 printk(KERN_INFO "STV6110 attached on addr=%x!\n", priv->i2c_address); in stv6110_attach()