Lines Matching +full:i2c +full:- +full:gate
1 // SPDX-License-Identifier: GPL-2.0-or-later
10 /* Max transfer size done by I2C transfer functions */
20 .addr = priv->cfg->i2c_address, in tda18218_wr_regs()
27 dev_warn(&priv->i2c->dev, in tda18218_wr_regs()
28 "%s: i2c wr reg=%04x: len=%d is too big!\n", in tda18218_wr_regs()
30 return -EINVAL; in tda18218_wr_regs()
34 remaining -= (priv->cfg->i2c_wr_max - 1)) { in tda18218_wr_regs()
36 if (len2 > (priv->cfg->i2c_wr_max - 1)) in tda18218_wr_regs()
37 len2 = (priv->cfg->i2c_wr_max - 1); in tda18218_wr_regs()
40 buf[0] = reg + len - remaining; in tda18218_wr_regs()
41 memcpy(&buf[1], &val[len - remaining], len2); in tda18218_wr_regs()
43 ret = i2c_transfer(priv->i2c, msg, 1); in tda18218_wr_regs()
51 dev_warn(&priv->i2c->dev, "%s: i2c wr failed=%d reg=%02x " \ in tda18218_wr_regs()
53 ret = -EREMOTEIO; in tda18218_wr_regs()
66 .addr = priv->cfg->i2c_address, in tda18218_rd_regs()
71 .addr = priv->cfg->i2c_address, in tda18218_rd_regs()
79 dev_warn(&priv->i2c->dev, in tda18218_rd_regs()
80 "%s: i2c wr reg=%04x: len=%d is too big!\n", in tda18218_rd_regs()
82 return -EINVAL; in tda18218_rd_regs()
85 ret = i2c_transfer(priv->i2c, msg, 2); in tda18218_rd_regs()
90 dev_warn(&priv->i2c->dev, "%s: i2c rd failed=%d reg=%02x " \ in tda18218_rd_regs()
92 ret = -EREMOTEIO; in tda18218_rd_regs()
113 struct tda18218_priv *priv = fe->tuner_priv; in tda18218_set_params()
114 struct dtv_frontend_properties *c = &fe->dtv_property_cache; in tda18218_set_params()
115 u32 bw = c->bandwidth_hz; in tda18218_set_params()
137 if (fe->ops.i2c_gate_ctrl) in tda18218_set_params()
138 fe->ops.i2c_gate_ctrl(fe, 1); /* open I2C-gate */ in tda18218_set_params()
140 /* low-pass filter cut-off frequency */ in tda18218_set_params()
143 priv->if_frequency = 3000000; in tda18218_set_params()
146 priv->if_frequency = 3500000; in tda18218_set_params()
149 priv->if_frequency = 4000000; in tda18218_set_params()
152 LO_Frac = c->frequency + priv->if_frequency; in tda18218_set_params()
154 /* band-pass filter */ in tda18218_set_params()
164 buf[0] = (priv->regs[R1A_IF1] & ~7) | BP_Filter; /* BP_Filter */ in tda18218_set_params()
165 buf[1] = (priv->regs[R1B_IF2] & ~3) | LP_Fc; /* LP_Fc */ in tda18218_set_params()
166 buf[2] = priv->regs[R1C_AGC2B]; in tda18218_set_params()
174 (priv->regs[R0C_MD5] & 0x0f); /* LO_Frac_2 */ in tda18218_set_params()
179 buf[0] = priv->regs[R0F_MD8] | (1 << 6); /* Freq_prog_Start */ in tda18218_set_params()
184 buf[0] = priv->regs[R0F_MD8] & ~(1 << 6); /* Freq_prog_Start */ in tda18218_set_params()
197 if (fe->ops.i2c_gate_ctrl) in tda18218_set_params()
198 fe->ops.i2c_gate_ctrl(fe, 0); /* close I2C-gate */ in tda18218_set_params()
201 dev_dbg(&priv->i2c->dev, "%s: failed=%d\n", __func__, ret); in tda18218_set_params()
208 struct tda18218_priv *priv = fe->tuner_priv; in tda18218_get_if_frequency()
209 *frequency = priv->if_frequency; in tda18218_get_if_frequency()
210 dev_dbg(&priv->i2c->dev, "%s: if_frequency=%d\n", __func__, *frequency); in tda18218_get_if_frequency()
216 struct tda18218_priv *priv = fe->tuner_priv; in tda18218_sleep()
219 if (fe->ops.i2c_gate_ctrl) in tda18218_sleep()
220 fe->ops.i2c_gate_ctrl(fe, 1); /* open I2C-gate */ in tda18218_sleep()
223 ret = tda18218_wr_reg(priv, R17_PD1, priv->regs[R17_PD1] | (1 << 0)); in tda18218_sleep()
225 if (fe->ops.i2c_gate_ctrl) in tda18218_sleep()
226 fe->ops.i2c_gate_ctrl(fe, 0); /* close I2C-gate */ in tda18218_sleep()
229 dev_dbg(&priv->i2c->dev, "%s: failed=%d\n", __func__, ret); in tda18218_sleep()
236 struct tda18218_priv *priv = fe->tuner_priv; in tda18218_init()
241 if (fe->ops.i2c_gate_ctrl) in tda18218_init()
242 fe->ops.i2c_gate_ctrl(fe, 1); /* open I2C-gate */ in tda18218_init()
244 ret = tda18218_wr_regs(priv, R00_ID, priv->regs, TDA18218_NUM_REGS); in tda18218_init()
246 if (fe->ops.i2c_gate_ctrl) in tda18218_init()
247 fe->ops.i2c_gate_ctrl(fe, 0); /* close I2C-gate */ in tda18218_init()
250 dev_dbg(&priv->i2c->dev, "%s: failed=%d\n", __func__, ret); in tda18218_init()
257 kfree(fe->tuner_priv); in tda18218_release()
258 fe->tuner_priv = NULL; in tda18218_release()
280 struct i2c_adapter *i2c, struct tda18218_config *cfg) in tda18218_attach() argument
299 priv->cfg = cfg; in tda18218_attach()
300 priv->i2c = i2c; in tda18218_attach()
301 fe->tuner_priv = priv; in tda18218_attach()
303 if (fe->ops.i2c_gate_ctrl) in tda18218_attach()
304 fe->ops.i2c_gate_ctrl(fe, 1); /* open I2C-gate */ in tda18218_attach()
309 dev_dbg(&priv->i2c->dev, "%s: chip id=%02x\n", __func__, val); in tda18218_attach()
315 dev_info(&priv->i2c->dev, in tda18218_attach()
319 memcpy(&fe->ops.tuner_ops, &tda18218_tuner_ops, in tda18218_attach()
321 memcpy(priv->regs, def_regs, sizeof(def_regs)); in tda18218_attach()
323 /* loop-through enabled chip default register values */ in tda18218_attach()
324 if (priv->cfg->loop_through) { in tda18218_attach()
325 priv->regs[R17_PD1] = 0xb0; in tda18218_attach()
326 priv->regs[R18_PD2] = 0x59; in tda18218_attach()
330 ret = tda18218_wr_reg(priv, R17_PD1, priv->regs[R17_PD1] | (1 << 0)); in tda18218_attach()
332 dev_dbg(&priv->i2c->dev, "%s: failed=%d\n", __func__, ret); in tda18218_attach()
334 if (fe->ops.i2c_gate_ctrl) in tda18218_attach()
335 fe->ops.i2c_gate_ctrl(fe, 0); /* close I2C-gate */ in tda18218_attach()