Lines Matching +full:platform +full:- +full:pll +full:- +full:div2

1 // SPDX-License-Identifier: GPL-2.0-or-later
31 { .addr = priv->cfg->i2c_address, .flags = 0, .len = 1 }, in mt2060_readreg()
32 { .addr = priv->cfg->i2c_address, .flags = I2C_M_RD, .len = 1 }, in mt2060_readreg()
39 return -ENOMEM; in mt2060_readreg()
47 if (i2c_transfer(priv->i2c, msg, 2) != 2) { in mt2060_readreg()
49 rc = -EREMOTEIO; in mt2060_readreg()
61 .addr = priv->cfg->i2c_address, .flags = 0, .len = 2 in mt2060_writereg()
68 return -ENOMEM; in mt2060_writereg()
75 if (i2c_transfer(priv->i2c, &msg, 1) != 1) { in mt2060_writereg()
77 rc = -EREMOTEIO; in mt2060_writereg()
90 .addr = priv->cfg->i2c_address, .flags = 0 in mt2060_writeregs()
95 return -ENOMEM; in mt2060_writeregs()
99 for (rem = len - 1; rem > 0; rem -= priv->i2c_max_regs) { in mt2060_writeregs()
100 val_len = min_t(int, rem, priv->i2c_max_regs); in mt2060_writeregs()
102 xfer_buf[0] = buf[0] + len - 1 - rem; in mt2060_writeregs()
103 memcpy(&xfer_buf[1], &buf[1 + len - 1 - rem], val_len); in mt2060_writeregs()
105 if (i2c_transfer(priv->i2c, &msg, 1) != 1) { in mt2060_writeregs()
107 rc = -EREMOTEIO; in mt2060_writeregs()
117 // LNABAND=3, NUM1=0x3C, DIV1=0x74, NUM2=0x1080, DIV2=0x49
141 diff = I*(int)lo1-J*(int)lo2; in mt2060_spurcalc()
142 if (diff < 0) diff=-diff; in mt2060_spurcalc()
143 dia = (diff-(int)if2); in mt2060_spurcalc()
144 if (dia < 0) dia=-dia; in mt2060_spurcalc()
167 Sp2 = mt2060_spurcalc(lo1-I,lo2-I,if2); in mt2060_spurcheck()
170 J=-J; I=-I; Spur=Sp2; in mt2060_spurcheck()
190 struct dtv_frontend_properties *c = &fe->dtv_property_cache; in mt2060_set_params()
196 u32 div1,num1,div2,num2; in mt2060_set_params() local
200 priv = fe->tuner_priv; in mt2060_set_params()
202 if1 = priv->if1_freq; in mt2060_set_params()
206 if (fe->ops.i2c_gate_ctrl) in mt2060_set_params()
207 fe->ops.i2c_gate_ctrl(fe, 1); /* open i2c_gate */ in mt2060_set_params()
211 freq = c->frequency / 1000; /* Hz -> kHz */ in mt2060_set_params()
215 f_lo2 = f_lo1 - freq - IF2; in mt2060_set_params()
218 priv->frequency = (f_lo1 - f_lo2 - IF2) * 1000; in mt2060_set_params()
221 // LO-related spurs detection and correction in mt2060_set_params()
231 // Frequency LO2 = 16MHz * (DIV2 + NUM2/8192 ) in mt2060_set_params()
233 div2 = num2 / 8192; in mt2060_set_params()
252 b[5] = ((num2 >>12) & 1) | (div2 << 1); in mt2060_set_params()
255 dprintk("PLL freq=%dkHz f_lo1=%dkHz f_lo2=%dkHz",(int)freq,(int)f_lo1,(int)f_lo2); in mt2060_set_params()
256 dprintk("PLL div1=%d num1=%d div2=%d num2=%d",(int)div1,(int)num1,(int)div2,(int)num2); in mt2060_set_params()
257 dprintk("PLL [1..5]: %2x %2x %2x %2x %2x",(int)b[1],(int)b[2],(int)b[3],(int)b[4],(int)b[5]); in mt2060_set_params()
261 //Waits for pll lock or timeout in mt2060_set_params()
271 if (fe->ops.i2c_gate_ctrl) in mt2060_set_params()
272 fe->ops.i2c_gate_ctrl(fe, 0); /* close i2c_gate */ in mt2060_set_params()
288 mt2060_writereg(priv, REG_VGAG, (priv->cfg->clock_out << 6) | 0x30); in mt2060_calibrate()
314 mt2060_readreg(priv, REG_FM_FREQ, &priv->fmfreq); // now find out, what is fmreq used for :) in mt2060_calibrate()
315 dprintk("calibration was successful: %d", (int)priv->fmfreq); in mt2060_calibrate()
322 struct mt2060_priv *priv = fe->tuner_priv; in mt2060_get_frequency()
323 *frequency = priv->frequency; in mt2060_get_frequency()
335 struct mt2060_priv *priv = fe->tuner_priv; in mt2060_init()
338 if (fe->ops.i2c_gate_ctrl) in mt2060_init()
339 fe->ops.i2c_gate_ctrl(fe, 1); /* open i2c_gate */ in mt2060_init()
341 if (priv->sleep) { in mt2060_init()
348 (priv->cfg->clock_out << 6) | 0x33); in mt2060_init()
351 if (fe->ops.i2c_gate_ctrl) in mt2060_init()
352 fe->ops.i2c_gate_ctrl(fe, 0); /* close i2c_gate */ in mt2060_init()
359 struct mt2060_priv *priv = fe->tuner_priv; in mt2060_sleep()
362 if (fe->ops.i2c_gate_ctrl) in mt2060_sleep()
363 fe->ops.i2c_gate_ctrl(fe, 1); /* open i2c_gate */ in mt2060_sleep()
366 (priv->cfg->clock_out << 6) | 0x30); in mt2060_sleep()
370 if (priv->sleep) in mt2060_sleep()
374 if (fe->ops.i2c_gate_ctrl) in mt2060_sleep()
375 fe->ops.i2c_gate_ctrl(fe, 0); /* close i2c_gate */ in mt2060_sleep()
382 kfree(fe->tuner_priv); in mt2060_release()
383 fe->tuner_priv = NULL; in mt2060_release()
414 priv->cfg = cfg; in mt2060_attach()
415 priv->i2c = i2c; in mt2060_attach()
416 priv->if1_freq = if1; in mt2060_attach()
417 priv->i2c_max_regs = ~0; in mt2060_attach()
419 if (fe->ops.i2c_gate_ctrl) in mt2060_attach()
420 fe->ops.i2c_gate_ctrl(fe, 1); /* open i2c_gate */ in mt2060_attach()
432 memcpy(&fe->ops.tuner_ops, &mt2060_tuner_ops, sizeof(struct dvb_tuner_ops)); in mt2060_attach()
434 fe->tuner_priv = priv; in mt2060_attach()
438 if (fe->ops.i2c_gate_ctrl) in mt2060_attach()
439 fe->ops.i2c_gate_ctrl(fe, 0); /* close i2c_gate */ in mt2060_attach()
447 struct mt2060_platform_data *pdata = client->dev.platform_data; in mt2060_probe()
453 dev_dbg(&client->dev, "\n"); in mt2060_probe()
456 dev_err(&client->dev, "Cannot proceed without platform data\n"); in mt2060_probe()
457 ret = -EINVAL; in mt2060_probe()
461 dev = devm_kzalloc(&client->dev, sizeof(*dev), GFP_KERNEL); in mt2060_probe()
463 ret = -ENOMEM; in mt2060_probe()
467 fe = pdata->dvb_frontend; in mt2060_probe()
468 dev->config.i2c_address = client->addr; in mt2060_probe()
469 dev->config.clock_out = pdata->clock_out; in mt2060_probe()
470 dev->cfg = &dev->config; in mt2060_probe()
471 dev->i2c = client->adapter; in mt2060_probe()
472 dev->if1_freq = pdata->if1 ? pdata->if1 : 1220; in mt2060_probe()
473 dev->client = client; in mt2060_probe()
474 dev->i2c_max_regs = pdata->i2c_write_max ? pdata->i2c_write_max - 1 : ~0; in mt2060_probe()
475 dev->sleep = true; in mt2060_probe()
479 ret = -ENODEV; in mt2060_probe()
483 dev_dbg(&client->dev, "chip id=%02x\n", chip_id); in mt2060_probe()
486 ret = -ENODEV; in mt2060_probe()
499 dev_info(&client->dev, "Microtune MT2060 successfully identified\n"); in mt2060_probe()
500 memcpy(&fe->ops.tuner_ops, &mt2060_tuner_ops, sizeof(fe->ops.tuner_ops)); in mt2060_probe()
501 fe->ops.tuner_ops.release = NULL; in mt2060_probe()
502 fe->tuner_priv = dev; in mt2060_probe()
507 dev_dbg(&client->dev, "failed=%d\n", ret); in mt2060_probe()
513 dev_dbg(&client->dev, "\n"); in mt2060_remove()