Lines Matching +full:mclk +full:- +full:div

1 // SPDX-License-Identifier: GPL-2.0-or-later
23 /* set demod main mclk and ts mclk */
26 struct m88rs6000t_dev *dev = fe->tuner_priv; in m88rs6000t_set_demod_mclk()
27 struct dtv_frontend_properties *c = &fe->dtv_property_cache; in m88rs6000t_set_demod_mclk()
31 u32 div, ts_mclk; in m88rs6000t_set_demod_mclk() local
35 /* select demod main mclk */ in m88rs6000t_set_demod_mclk()
36 ret = regmap_read(dev->regmap, 0x15, &utmp); in m88rs6000t_set_demod_mclk()
40 if (c->symbol_rate > 45010000) { in m88rs6000t_set_demod_mclk()
43 reg16 = 115; /* mclk = 110.25MHz */ in m88rs6000t_set_demod_mclk()
47 reg16 = 96; /* mclk = 96MHz */ in m88rs6000t_set_demod_mclk()
50 /* set ts mclk */ in m88rs6000t_set_demod_mclk()
51 if (c->delivery_system == SYS_DVBS) in m88rs6000t_set_demod_mclk()
60 div = 36000 * pll_div_fb; in m88rs6000t_set_demod_mclk()
61 div /= ts_mclk; in m88rs6000t_set_demod_mclk()
63 if (div <= 32) { in m88rs6000t_set_demod_mclk()
66 f1 = div / 2; in m88rs6000t_set_demod_mclk()
67 f2 = div - f1; in m88rs6000t_set_demod_mclk()
69 } else if (div <= 48) { in m88rs6000t_set_demod_mclk()
71 f0 = div / 3; in m88rs6000t_set_demod_mclk()
72 f1 = (div - f0) / 2; in m88rs6000t_set_demod_mclk()
73 f2 = div - f0 - f1; in m88rs6000t_set_demod_mclk()
75 } else if (div <= 64) { in m88rs6000t_set_demod_mclk()
77 f0 = div / 4; in m88rs6000t_set_demod_mclk()
78 f1 = (div - f0) / 3; in m88rs6000t_set_demod_mclk()
79 f2 = (div - f0 - f1) / 2; in m88rs6000t_set_demod_mclk()
80 f3 = div - f0 - f1 - f2; in m88rs6000t_set_demod_mclk()
98 ret = regmap_read(dev->regmap, 0x1D, &utmp); in m88rs6000t_set_demod_mclk()
103 reg1D |= N - 1; in m88rs6000t_set_demod_mclk()
108 ret = regmap_write(dev->regmap, 0x05, 0x40); in m88rs6000t_set_demod_mclk()
111 ret = regmap_write(dev->regmap, 0x11, 0x08); in m88rs6000t_set_demod_mclk()
114 ret = regmap_write(dev->regmap, 0x15, reg15); in m88rs6000t_set_demod_mclk()
117 ret = regmap_write(dev->regmap, 0x16, reg16); in m88rs6000t_set_demod_mclk()
120 ret = regmap_write(dev->regmap, 0x1D, reg1D); in m88rs6000t_set_demod_mclk()
123 ret = regmap_write(dev->regmap, 0x1E, reg1E); in m88rs6000t_set_demod_mclk()
126 ret = regmap_write(dev->regmap, 0x1F, reg1F); in m88rs6000t_set_demod_mclk()
129 ret = regmap_write(dev->regmap, 0x17, 0xc1); in m88rs6000t_set_demod_mclk()
132 ret = regmap_write(dev->regmap, 0x17, 0x81); in m88rs6000t_set_demod_mclk()
136 ret = regmap_write(dev->regmap, 0x05, 0x00); in m88rs6000t_set_demod_mclk()
139 ret = regmap_write(dev->regmap, 0x11, reg11); in m88rs6000t_set_demod_mclk()
145 dev_dbg(&dev->client->dev, "failed=%d\n", ret); in m88rs6000t_set_demod_mclk()
161 ret = regmap_write(dev->regmap, 0x36, (refDiv - 8)); in m88rs6000t_set_pll_freq()
164 ret = regmap_write(dev->regmap, 0x31, 0x00); in m88rs6000t_set_pll_freq()
167 ret = regmap_write(dev->regmap, 0x2c, 0x02); in m88rs6000t_set_pll_freq()
214 / fcry_KHz - 1024) / 2; in m88rs6000t_set_pll_freq()
216 / fcry_KHz - 1024) / 2; in m88rs6000t_set_pll_freq()
219 ret = regmap_write(dev->regmap, 0x27, reg27); in m88rs6000t_set_pll_freq()
222 ret = regmap_write(dev->regmap, 0x28, (u8)(ulNDiv1 & 0xFF)); in m88rs6000t_set_pll_freq()
226 ret = regmap_write(dev->regmap, 0x29, reg29); in m88rs6000t_set_pll_freq()
229 ret = regmap_write(dev->regmap, 0x2a, (u8)(ulNDiv2 & 0xFF)); in m88rs6000t_set_pll_freq()
232 ret = regmap_write(dev->regmap, 0x2F, 0xf5); in m88rs6000t_set_pll_freq()
235 ret = regmap_write(dev->regmap, 0x30, 0x05); in m88rs6000t_set_pll_freq()
238 ret = regmap_write(dev->regmap, 0x08, 0x1f); in m88rs6000t_set_pll_freq()
241 ret = regmap_write(dev->regmap, 0x08, 0x3f); in m88rs6000t_set_pll_freq()
244 ret = regmap_write(dev->regmap, 0x09, 0x20); in m88rs6000t_set_pll_freq()
247 ret = regmap_write(dev->regmap, 0x09, 0x00); in m88rs6000t_set_pll_freq()
250 ret = regmap_write(dev->regmap, 0x3e, 0x11); in m88rs6000t_set_pll_freq()
253 ret = regmap_write(dev->regmap, 0x08, 0x2f); in m88rs6000t_set_pll_freq()
256 ret = regmap_write(dev->regmap, 0x08, 0x3f); in m88rs6000t_set_pll_freq()
259 ret = regmap_write(dev->regmap, 0x09, 0x10); in m88rs6000t_set_pll_freq()
262 ret = regmap_write(dev->regmap, 0x09, 0x00); in m88rs6000t_set_pll_freq()
267 ret = regmap_read(dev->regmap, 0x42, &utmp); in m88rs6000t_set_pll_freq()
272 ret = regmap_write(dev->regmap, 0x3e, 0x10); in m88rs6000t_set_pll_freq()
275 ret = regmap_write(dev->regmap, 0x08, 0x2f); in m88rs6000t_set_pll_freq()
278 ret = regmap_write(dev->regmap, 0x08, 0x3f); in m88rs6000t_set_pll_freq()
281 ret = regmap_write(dev->regmap, 0x09, 0x10); in m88rs6000t_set_pll_freq()
284 ret = regmap_write(dev->regmap, 0x09, 0x00); in m88rs6000t_set_pll_freq()
289 ret = regmap_read(dev->regmap, 0x42, &utmp); in m88rs6000t_set_pll_freq()
294 ret = regmap_write(dev->regmap, 0x3e, 0x11); in m88rs6000t_set_pll_freq()
300 ret = regmap_read(dev->regmap, 0x2d, &utmp); in m88rs6000t_set_pll_freq()
303 ret = regmap_write(dev->regmap, 0x2d, utmp); in m88rs6000t_set_pll_freq()
306 ret = regmap_read(dev->regmap, 0x2e, &utmp); in m88rs6000t_set_pll_freq()
309 ret = regmap_write(dev->regmap, 0x2e, utmp); in m88rs6000t_set_pll_freq()
313 ret = regmap_read(dev->regmap, 0x27, &utmp); in m88rs6000t_set_pll_freq()
317 ret = regmap_read(dev->regmap, 0x83, &utmp); in m88rs6000t_set_pll_freq()
332 ret = regmap_write(dev->regmap, 0x36, (refDiv - 8)); in m88rs6000t_set_pll_freq()
336 / fcry_KHz - 1024) / 2; in m88rs6000t_set_pll_freq()
341 ret = regmap_write(dev->regmap, 0x27, reg27); in m88rs6000t_set_pll_freq()
344 ret = regmap_write(dev->regmap, 0x28, (u8)(ulNDiv & 0xFF)); in m88rs6000t_set_pll_freq()
347 ret = regmap_write(dev->regmap, 0x29, 0x80); in m88rs6000t_set_pll_freq()
350 ret = regmap_write(dev->regmap, 0x31, 0x03); in m88rs6000t_set_pll_freq()
358 ret = regmap_write(dev->regmap, 0x3b, utmp); in m88rs6000t_set_pll_freq()
362 dev->frequency_khz = fcry_KHz * (ulNDiv * 2 + 1024) / refDiv / ucLoDiv; in m88rs6000t_set_pll_freq()
364 dev_dbg(&dev->client->dev, in m88rs6000t_set_pll_freq()
365 "actual tune frequency=%d\n", dev->frequency_khz); in m88rs6000t_set_pll_freq()
368 dev_dbg(&dev->client->dev, "failed=%d\n", ret); in m88rs6000t_set_pll_freq()
382 return regmap_write(dev->regmap, 0x40, reg40); in m88rs6000t_set_bb()
387 struct m88rs6000t_dev *dev = fe->tuner_priv; in m88rs6000t_set_params()
388 struct dtv_frontend_properties *c = &fe->dtv_property_cache; in m88rs6000t_set_params()
393 dev_dbg(&dev->client->dev, in m88rs6000t_set_params()
395 c->frequency, c->symbol_rate); in m88rs6000t_set_params()
397 if (c->symbol_rate < 5000000) in m88rs6000t_set_params()
402 realFreq = c->frequency + lpf_offset_KHz; in m88rs6000t_set_params()
408 ret = m88rs6000t_set_bb(dev, c->symbol_rate / 1000, lpf_offset_KHz); in m88rs6000t_set_params()
411 ret = regmap_write(dev->regmap, 0x00, 0x01); in m88rs6000t_set_params()
414 ret = regmap_write(dev->regmap, 0x00, 0x00); in m88rs6000t_set_params()
421 dev_dbg(&dev->client->dev, "failed=%d\n", ret); in m88rs6000t_set_params()
427 struct m88rs6000t_dev *dev = fe->tuner_priv; in m88rs6000t_init()
430 dev_dbg(&dev->client->dev, "%s:\n", __func__); in m88rs6000t_init()
432 ret = regmap_update_bits(dev->regmap, 0x11, 0x08, 0x08); in m88rs6000t_init()
436 ret = regmap_update_bits(dev->regmap, 0x10, 0x01, 0x01); in m88rs6000t_init()
440 ret = regmap_write(dev->regmap, 0x07, 0x7d); in m88rs6000t_init()
443 dev_dbg(&dev->client->dev, "failed=%d\n", ret); in m88rs6000t_init()
449 struct m88rs6000t_dev *dev = fe->tuner_priv; in m88rs6000t_sleep()
452 dev_dbg(&dev->client->dev, "%s:\n", __func__); in m88rs6000t_sleep()
454 ret = regmap_write(dev->regmap, 0x07, 0x6d); in m88rs6000t_sleep()
456 dev_dbg(&dev->client->dev, "failed=%d\n", ret); in m88rs6000t_sleep()
465 struct m88rs6000t_dev *dev = fe->tuner_priv; in m88rs6000t_get_frequency()
467 dev_dbg(&dev->client->dev, "\n"); in m88rs6000t_get_frequency()
469 *frequency = dev->frequency_khz; in m88rs6000t_get_frequency()
475 struct m88rs6000t_dev *dev = fe->tuner_priv; in m88rs6000t_get_if_frequency()
477 dev_dbg(&dev->client->dev, "\n"); in m88rs6000t_get_if_frequency()
479 *frequency = 0; /* Zero-IF */ in m88rs6000t_get_if_frequency()
486 struct m88rs6000t_dev *dev = fe->tuner_priv; in m88rs6000t_get_rf_strength()
501 ret = regmap_read(dev->regmap, 0x5A, &val); in m88rs6000t_get_rf_strength()
506 ret = regmap_read(dev->regmap, 0x5F, &val); in m88rs6000t_get_rf_strength()
511 ret = regmap_read(dev->regmap, 0x3F, &val); in m88rs6000t_get_rf_strength()
516 ret = regmap_read(dev->regmap, 0x77, &val); in m88rs6000t_get_rf_strength()
521 ret = regmap_read(dev->regmap, 0x76, &val); in m88rs6000t_get_rf_strength()
550 gain = RFG + IFG - TIAG + BBG + PGA2G; in m88rs6000t_get_rf_strength()
552 /* scale value to 0x0000-0xffff */ in m88rs6000t_get_rf_strength()
554 *strength = (10500 - gain) * 0xffff / (10500 - 1000); in m88rs6000t_get_rf_strength()
557 dev_dbg(&dev->client->dev, "failed=%d\n", ret); in m88rs6000t_get_rf_strength()
578 struct m88rs6000t_config *cfg = client->dev.platform_data; in m88rs6000t_probe()
579 struct dvb_frontend *fe = cfg->fe; in m88rs6000t_probe()
617 ret = -ENOMEM; in m88rs6000t_probe()
618 dev_err(&client->dev, "kzalloc() failed\n"); in m88rs6000t_probe()
622 memcpy(&dev->cfg, cfg, sizeof(struct m88rs6000t_config)); in m88rs6000t_probe()
623 dev->client = client; in m88rs6000t_probe()
624 dev->regmap = devm_regmap_init_i2c(client, &regmap_config); in m88rs6000t_probe()
625 if (IS_ERR(dev->regmap)) { in m88rs6000t_probe()
626 ret = PTR_ERR(dev->regmap); in m88rs6000t_probe()
630 ret = regmap_update_bits(dev->regmap, 0x11, 0x08, 0x08); in m88rs6000t_probe()
634 ret = regmap_update_bits(dev->regmap, 0x10, 0x01, 0x01); in m88rs6000t_probe()
638 ret = regmap_write(dev->regmap, 0x07, 0x7d); in m88rs6000t_probe()
641 ret = regmap_write(dev->regmap, 0x04, 0x01); in m88rs6000t_probe()
646 ret = regmap_read(dev->regmap, 0x01, &utmp); in m88rs6000t_probe()
649 dev_info(&dev->client->dev, "chip_id=%02x\n", utmp); in m88rs6000t_probe()
651 ret = -ENODEV; in m88rs6000t_probe()
656 ret = regmap_write(dev->regmap, 0x05, 0x40); in m88rs6000t_probe()
659 ret = regmap_write(dev->regmap, 0x11, 0x08); in m88rs6000t_probe()
662 ret = regmap_write(dev->regmap, 0x15, 0x6c); in m88rs6000t_probe()
665 ret = regmap_write(dev->regmap, 0x17, 0xc1); in m88rs6000t_probe()
668 ret = regmap_write(dev->regmap, 0x17, 0x81); in m88rs6000t_probe()
672 ret = regmap_write(dev->regmap, 0x05, 0x00); in m88rs6000t_probe()
675 ret = regmap_write(dev->regmap, 0x11, 0x0a); in m88rs6000t_probe()
680 ret = regmap_write(dev->regmap, in m88rs6000t_probe()
686 dev_info(&dev->client->dev, "Montage M88RS6000 internal tuner successfully identified\n"); in m88rs6000t_probe()
688 fe->tuner_priv = dev; in m88rs6000t_probe()
689 memcpy(&fe->ops.tuner_ops, &m88rs6000t_tuner_ops, in m88rs6000t_probe()
694 dev_dbg(&client->dev, "failed=%d\n", ret); in m88rs6000t_probe()
702 struct dvb_frontend *fe = dev->cfg.fe; in m88rs6000t_remove()
704 dev_dbg(&client->dev, "\n"); in m88rs6000t_remove()
706 memset(&fe->ops.tuner_ops, 0, sizeof(struct dvb_tuner_ops)); in m88rs6000t_remove()
707 fe->tuner_priv = NULL; in m88rs6000t_remove()