26 int ret = 0, len2, remaining;
30 .addr = priv->
cfg->i2c_address,
36 for (remaining = len; remaining > 0;
37 remaining -= (priv->
cfg->i2c_wr_max - 1)) {
39 if (len2 > (priv->
cfg->i2c_wr_max - 1))
40 len2 = (priv->
cfg->i2c_wr_max - 1);
42 msg[0].
len = 1 + len2;
43 buf[0] = reg + len - remaining;
44 memcpy(&buf[1], &val[len - remaining], len2);
54 dev_warn(&priv->
i2c->dev,
"%s: i2c wr failed=%d reg=%02x " \
55 "len=%d\n", KBUILD_MODNAME, ret, reg, len);
74 .addr = priv->
cfg->i2c_address,
83 memcpy(val, &buf[reg], len);
86 dev_warn(&priv->
i2c->dev,
"%s: i2c rd failed=%d reg=%02x " \
87 "len=%d\n", KBUILD_MODNAME, ret, reg, len);
97 return tda18218_wr_regs(priv, reg, &val, 1);
104 return tda18218_rd_regs(priv, reg, val, 1);
113 u8 buf[3],
i, BP_Filter, LP_Fc;
133 if (fe->
ops.i2c_gate_ctrl)
134 fe->
ops.i2c_gate_ctrl(fe, 1);
140 }
else if (bw <= 7000000) {
151 if (LO_Frac < 188000000)
153 else if (LO_Frac < 253000000)
155 else if (LO_Frac < 343000000)
163 ret = tda18218_wr_regs(priv,
R1A_IF1, buf, 3);
167 buf[0] = (LO_Frac / 1000) >> 12;
168 buf[1] = (LO_Frac / 1000) >> 4;
169 buf[2] = (LO_Frac / 1000) << 4 |
171 ret = tda18218_wr_regs(priv,
R0A_MD3, buf, 3);
176 ret = tda18218_wr_regs(priv,
R0F_MD8, buf, 1);
181 ret = tda18218_wr_regs(priv,
R0F_MD8, buf, 1);
187 ret = tda18218_wr_reg(priv, agc[i][0], agc[i][1]);
193 if (fe->
ops.i2c_gate_ctrl)
194 fe->
ops.i2c_gate_ctrl(fe, 0);
197 dev_dbg(&priv->
i2c->dev,
"%s: failed=%d\n", __func__, ret);
206 dev_dbg(&priv->
i2c->dev,
"%s: if_frequency=%d\n", __func__, *frequency);
215 if (fe->
ops.i2c_gate_ctrl)
216 fe->
ops.i2c_gate_ctrl(fe, 1);
221 if (fe->
ops.i2c_gate_ctrl)
222 fe->
ops.i2c_gate_ctrl(fe, 0);
225 dev_dbg(&priv->
i2c->dev,
"%s: failed=%d\n", __func__, ret);
237 if (fe->
ops.i2c_gate_ctrl)
238 fe->
ops.i2c_gate_ctrl(fe, 1);
242 if (fe->
ops.i2c_gate_ctrl)
243 fe->
ops.i2c_gate_ctrl(fe, 0);
246 dev_dbg(&priv->
i2c->dev,
"%s: failed=%d\n", __func__, ret);
260 .name =
"NXP TDA18218",
262 .frequency_min = 174000000,
263 .frequency_max = 864000000,
264 .frequency_step = 1000,
267 .release = tda18218_release,
268 .init = tda18218_init,
269 .sleep = tda18218_sleep,
271 .set_params = tda18218_set_params,
273 .get_if_frequency = tda18218_get_if_frequency,
283 static u8 def_regs[] = {
284 0xc0, 0x88, 0x00, 0x8e, 0x03, 0x00, 0x00, 0xd0, 0x00, 0x40,
285 0x00, 0x00, 0x07, 0xff, 0x84, 0x09, 0x00, 0x13, 0x00, 0x00,
286 0x01, 0x84, 0x09, 0xf0, 0x19, 0x0a, 0x8e, 0x69, 0x98, 0x01,
287 0x00, 0x58, 0x10, 0x40, 0x8c, 0x00, 0x0c, 0x48, 0x85, 0xc9,
288 0xa7, 0x00, 0x00, 0x00, 0x30, 0x81, 0x80, 0x00, 0x39, 0x00,
289 0x8a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf6, 0xf6
300 if (fe->
ops.i2c_gate_ctrl)
301 fe->
ops.i2c_gate_ctrl(fe, 1);
304 ret = tda18218_rd_reg(priv,
R00_ID, &val);
305 dev_dbg(&priv->
i2c->dev,
"%s: ret=%d chip id=%02x\n", __func__, ret,
307 if (ret || val != def_regs[
R00_ID]) {
313 "%s: NXP TDA18218HN successfully identified\n",
316 memcpy(&fe->
ops.tuner_ops, &tda18218_tuner_ops,
318 memcpy(priv->
regs, def_regs,
sizeof(def_regs));
321 if (priv->
cfg->loop_through) {
329 dev_dbg(&priv->
i2c->dev,
"%s: failed=%d\n", __func__, ret);
331 if (fe->
ops.i2c_gate_ctrl)
332 fe->
ops.i2c_gate_ctrl(fe, 0);