diff options
Diffstat (limited to 'drivers/media/dvb/frontends/tda18271-common.c')
-rw-r--r-- | drivers/media/dvb/frontends/tda18271-common.c | 57 |
1 files changed, 35 insertions, 22 deletions
diff --git a/drivers/media/dvb/frontends/tda18271-common.c b/drivers/media/dvb/frontends/tda18271-common.c index bca570990613..e27a7620a32f 100644 --- a/drivers/media/dvb/frontends/tda18271-common.c +++ b/drivers/media/dvb/frontends/tda18271-common.c | |||
@@ -125,16 +125,16 @@ int tda18271_read_regs(struct dvb_frontend *fe) | |||
125 | unsigned char buf = 0x00; | 125 | unsigned char buf = 0x00; |
126 | int ret; | 126 | int ret; |
127 | struct i2c_msg msg[] = { | 127 | struct i2c_msg msg[] = { |
128 | { .addr = priv->i2c_addr, .flags = 0, | 128 | { .addr = priv->i2c_props.addr, .flags = 0, |
129 | .buf = &buf, .len = 1 }, | 129 | .buf = &buf, .len = 1 }, |
130 | { .addr = priv->i2c_addr, .flags = I2C_M_RD, | 130 | { .addr = priv->i2c_props.addr, .flags = I2C_M_RD, |
131 | .buf = regs, .len = 16 } | 131 | .buf = regs, .len = 16 } |
132 | }; | 132 | }; |
133 | 133 | ||
134 | tda18271_i2c_gate_ctrl(fe, 1); | 134 | tda18271_i2c_gate_ctrl(fe, 1); |
135 | 135 | ||
136 | /* read all registers */ | 136 | /* read all registers */ |
137 | ret = i2c_transfer(priv->i2c_adap, msg, 2); | 137 | ret = i2c_transfer(priv->i2c_props.adap, msg, 2); |
138 | 138 | ||
139 | tda18271_i2c_gate_ctrl(fe, 0); | 139 | tda18271_i2c_gate_ctrl(fe, 0); |
140 | 140 | ||
@@ -155,16 +155,16 @@ int tda18271_read_extended(struct dvb_frontend *fe) | |||
155 | unsigned char buf = 0x00; | 155 | unsigned char buf = 0x00; |
156 | int ret, i; | 156 | int ret, i; |
157 | struct i2c_msg msg[] = { | 157 | struct i2c_msg msg[] = { |
158 | { .addr = priv->i2c_addr, .flags = 0, | 158 | { .addr = priv->i2c_props.addr, .flags = 0, |
159 | .buf = &buf, .len = 1 }, | 159 | .buf = &buf, .len = 1 }, |
160 | { .addr = priv->i2c_addr, .flags = I2C_M_RD, | 160 | { .addr = priv->i2c_props.addr, .flags = I2C_M_RD, |
161 | .buf = regdump, .len = TDA18271_NUM_REGS } | 161 | .buf = regdump, .len = TDA18271_NUM_REGS } |
162 | }; | 162 | }; |
163 | 163 | ||
164 | tda18271_i2c_gate_ctrl(fe, 1); | 164 | tda18271_i2c_gate_ctrl(fe, 1); |
165 | 165 | ||
166 | /* read all registers */ | 166 | /* read all registers */ |
167 | ret = i2c_transfer(priv->i2c_adap, msg, 2); | 167 | ret = i2c_transfer(priv->i2c_props.adap, msg, 2); |
168 | 168 | ||
169 | tda18271_i2c_gate_ctrl(fe, 0); | 169 | tda18271_i2c_gate_ctrl(fe, 0); |
170 | 170 | ||
@@ -192,7 +192,7 @@ int tda18271_write_regs(struct dvb_frontend *fe, int idx, int len) | |||
192 | struct tda18271_priv *priv = fe->tuner_priv; | 192 | struct tda18271_priv *priv = fe->tuner_priv; |
193 | unsigned char *regs = priv->tda18271_regs; | 193 | unsigned char *regs = priv->tda18271_regs; |
194 | unsigned char buf[TDA18271_NUM_REGS + 1]; | 194 | unsigned char buf[TDA18271_NUM_REGS + 1]; |
195 | struct i2c_msg msg = { .addr = priv->i2c_addr, .flags = 0, | 195 | struct i2c_msg msg = { .addr = priv->i2c_props.addr, .flags = 0, |
196 | .buf = buf, .len = len + 1 }; | 196 | .buf = buf, .len = len + 1 }; |
197 | int i, ret; | 197 | int i, ret; |
198 | 198 | ||
@@ -205,7 +205,7 @@ int tda18271_write_regs(struct dvb_frontend *fe, int idx, int len) | |||
205 | tda18271_i2c_gate_ctrl(fe, 1); | 205 | tda18271_i2c_gate_ctrl(fe, 1); |
206 | 206 | ||
207 | /* write registers */ | 207 | /* write registers */ |
208 | ret = i2c_transfer(priv->i2c_adap, &msg, 1); | 208 | ret = i2c_transfer(priv->i2c_props.adap, &msg, 1); |
209 | 209 | ||
210 | tda18271_i2c_gate_ctrl(fe, 0); | 210 | tda18271_i2c_gate_ctrl(fe, 0); |
211 | 211 | ||
@@ -217,13 +217,29 @@ int tda18271_write_regs(struct dvb_frontend *fe, int idx, int len) | |||
217 | 217 | ||
218 | /*---------------------------------------------------------------------*/ | 218 | /*---------------------------------------------------------------------*/ |
219 | 219 | ||
220 | int tda18271_charge_pump_source(struct dvb_frontend *fe, | ||
221 | enum tda18271_pll pll, int force) | ||
222 | { | ||
223 | struct tda18271_priv *priv = fe->tuner_priv; | ||
224 | unsigned char *regs = priv->tda18271_regs; | ||
225 | |||
226 | int r_cp = (pll == TDA18271_CAL_PLL) ? R_EB7 : R_EB4; | ||
227 | |||
228 | regs[r_cp] &= ~0x20; | ||
229 | regs[r_cp] |= ((force & 1) << 5); | ||
230 | tda18271_write_regs(fe, r_cp, 1); | ||
231 | |||
232 | return 0; | ||
233 | } | ||
234 | |||
220 | int tda18271_init_regs(struct dvb_frontend *fe) | 235 | int tda18271_init_regs(struct dvb_frontend *fe) |
221 | { | 236 | { |
222 | struct tda18271_priv *priv = fe->tuner_priv; | 237 | struct tda18271_priv *priv = fe->tuner_priv; |
223 | unsigned char *regs = priv->tda18271_regs; | 238 | unsigned char *regs = priv->tda18271_regs; |
224 | 239 | ||
225 | tda_dbg("initializing registers for device @ %d-%04x\n", | 240 | tda_dbg("initializing registers for device @ %d-%04x\n", |
226 | i2c_adapter_id(priv->i2c_adap), priv->i2c_addr); | 241 | i2c_adapter_id(priv->i2c_props.adap), |
242 | priv->i2c_props.addr); | ||
227 | 243 | ||
228 | /* initialize registers */ | 244 | /* initialize registers */ |
229 | switch (priv->id) { | 245 | switch (priv->id) { |
@@ -310,7 +326,12 @@ int tda18271_init_regs(struct dvb_frontend *fe) | |||
310 | regs[R_EB22] = 0x48; | 326 | regs[R_EB22] = 0x48; |
311 | regs[R_EB23] = 0xb0; | 327 | regs[R_EB23] = 0xb0; |
312 | 328 | ||
313 | tda18271_write_regs(fe, 0x00, TDA18271_NUM_REGS); | 329 | if (priv->small_i2c) { |
330 | tda18271_write_regs(fe, 0x00, 0x10); | ||
331 | tda18271_write_regs(fe, 0x10, 0x10); | ||
332 | tda18271_write_regs(fe, 0x20, 0x07); | ||
333 | } else | ||
334 | tda18271_write_regs(fe, 0x00, TDA18271_NUM_REGS); | ||
314 | 335 | ||
315 | /* setup agc1 gain */ | 336 | /* setup agc1 gain */ |
316 | regs[R_EB17] = 0x00; | 337 | regs[R_EB17] = 0x00; |
@@ -349,24 +370,15 @@ int tda18271_init_regs(struct dvb_frontend *fe) | |||
349 | regs[R_MD2] = 0x08; | 370 | regs[R_MD2] = 0x08; |
350 | regs[R_MD3] = 0x00; | 371 | regs[R_MD3] = 0x00; |
351 | 372 | ||
352 | switch (priv->id) { | 373 | tda18271_write_regs(fe, R_EP3, 11); |
353 | case TDA18271HDC1: | ||
354 | tda18271_write_regs(fe, R_EP3, 11); | ||
355 | break; | ||
356 | case TDA18271HDC2: | ||
357 | tda18271_write_regs(fe, R_EP3, 12); | ||
358 | break; | ||
359 | }; | ||
360 | 374 | ||
361 | if ((priv->id) == TDA18271HDC2) { | 375 | if ((priv->id) == TDA18271HDC2) { |
362 | /* main pll cp source on */ | 376 | /* main pll cp source on */ |
363 | regs[R_EB4] = 0x61; | 377 | tda18271_charge_pump_source(fe, TDA18271_MAIN_PLL, 1); |
364 | tda18271_write_regs(fe, R_EB4, 1); | ||
365 | msleep(1); | 378 | msleep(1); |
366 | 379 | ||
367 | /* main pll cp source off */ | 380 | /* main pll cp source off */ |
368 | regs[R_EB4] = 0x41; | 381 | tda18271_charge_pump_source(fe, TDA18271_MAIN_PLL, 0); |
369 | tda18271_write_regs(fe, R_EB4, 1); | ||
370 | } | 382 | } |
371 | 383 | ||
372 | msleep(5); /* pll locking */ | 384 | msleep(5); /* pll locking */ |
@@ -398,6 +410,7 @@ int tda18271_init_regs(struct dvb_frontend *fe) | |||
398 | tda18271_write_regs(fe, R_EP3, 11); | 410 | tda18271_write_regs(fe, R_EP3, 11); |
399 | msleep(5); /* pll locking */ | 411 | msleep(5); /* pll locking */ |
400 | 412 | ||
413 | /* launch detector */ | ||
401 | tda18271_write_regs(fe, R_EP1, 1); | 414 | tda18271_write_regs(fe, R_EP1, 1); |
402 | msleep(5); /* wanted mid measurement */ | 415 | msleep(5); /* wanted mid measurement */ |
403 | 416 | ||