49 if (fe->
ops.analog_ops.i2c_gate_ctrl)
50 ret = fe->
ops.analog_ops.i2c_gate_ctrl(fe, enable);
53 if (fe->
ops.i2c_gate_ctrl)
54 ret = fe->
ops.i2c_gate_ctrl(fe, enable);
66 static void tda18271_dump_regs(
struct dvb_frontend *fe,
int extended)
71 tda_reg(
"=== TDA18271 REG DUMP ===\n");
73 tda_reg(
"THERMO_BYTE = 0x%02x\n", 0xff & regs[
R_TM]);
74 tda_reg(
"POWER_LEVEL_BYTE = 0x%02x\n", 0xff & regs[
R_PL]);
75 tda_reg(
"EASY_PROG_BYTE_1 = 0x%02x\n", 0xff & regs[
R_EP1]);
76 tda_reg(
"EASY_PROG_BYTE_2 = 0x%02x\n", 0xff & regs[
R_EP2]);
77 tda_reg(
"EASY_PROG_BYTE_3 = 0x%02x\n", 0xff & regs[
R_EP3]);
78 tda_reg(
"EASY_PROG_BYTE_4 = 0x%02x\n", 0xff & regs[
R_EP4]);
79 tda_reg(
"EASY_PROG_BYTE_5 = 0x%02x\n", 0xff & regs[
R_EP5]);
80 tda_reg(
"CAL_POST_DIV_BYTE = 0x%02x\n", 0xff & regs[
R_CPD]);
81 tda_reg(
"CAL_DIV_BYTE_1 = 0x%02x\n", 0xff & regs[
R_CD1]);
82 tda_reg(
"CAL_DIV_BYTE_2 = 0x%02x\n", 0xff & regs[
R_CD2]);
83 tda_reg(
"CAL_DIV_BYTE_3 = 0x%02x\n", 0xff & regs[
R_CD3]);
84 tda_reg(
"MAIN_POST_DIV_BYTE = 0x%02x\n", 0xff & regs[
R_MPD]);
85 tda_reg(
"MAIN_DIV_BYTE_1 = 0x%02x\n", 0xff & regs[
R_MD1]);
86 tda_reg(
"MAIN_DIV_BYTE_2 = 0x%02x\n", 0xff & regs[
R_MD2]);
87 tda_reg(
"MAIN_DIV_BYTE_3 = 0x%02x\n", 0xff & regs[
R_MD3]);
96 tda_reg(
"EXTENDED_BYTE_1 = 0x%02x\n", 0xff & regs[
R_EB1]);
97 tda_reg(
"EXTENDED_BYTE_2 = 0x%02x\n", 0xff & regs[
R_EB2]);
98 tda_reg(
"EXTENDED_BYTE_3 = 0x%02x\n", 0xff & regs[
R_EB3]);
99 tda_reg(
"EXTENDED_BYTE_4 = 0x%02x\n", 0xff & regs[
R_EB4]);
100 tda_reg(
"EXTENDED_BYTE_5 = 0x%02x\n", 0xff & regs[
R_EB5]);
101 tda_reg(
"EXTENDED_BYTE_6 = 0x%02x\n", 0xff & regs[
R_EB6]);
102 tda_reg(
"EXTENDED_BYTE_7 = 0x%02x\n", 0xff & regs[
R_EB7]);
103 tda_reg(
"EXTENDED_BYTE_8 = 0x%02x\n", 0xff & regs[
R_EB8]);
104 tda_reg(
"EXTENDED_BYTE_9 W = 0x%02x\n", 0xff & regs[
R_EB9]);
111 tda_reg(
"EXTENDED_BYTE_16 W = 0x%02x\n", 0xff & regs[
R_EB16]);
112 tda_reg(
"EXTENDED_BYTE_17 W = 0x%02x\n", 0xff & regs[
R_EB17]);
114 tda_reg(
"EXTENDED_BYTE_19 W = 0x%02x\n", 0xff & regs[
R_EB19]);
115 tda_reg(
"EXTENDED_BYTE_20 W = 0x%02x\n", 0xff & regs[
R_EB20]);
125 unsigned char buf = 0x00;
129 .buf = &
buf, .len = 1 },
131 .buf =
regs, .len = 16 }
134 tda18271_i2c_gate_ctrl(fe, 1);
139 tda18271_i2c_gate_ctrl(fe, 0);
142 tda_err(
"ERROR: i2c_transfer returned: %d\n", ret);
145 tda18271_dump_regs(fe, 0);
147 return (ret == 2 ? 0 : ret);
155 unsigned char buf = 0x00;
159 .buf = &
buf, .len = 1 },
164 tda18271_i2c_gate_ctrl(fe, 1);
169 tda18271_i2c_gate_ctrl(fe, 0);
172 tda_err(
"ERROR: i2c_transfer returned: %d\n", ret);
181 regs[
i] = regdump[
i];
185 tda18271_dump_regs(fe, 1);
187 return (ret == 2 ? 0 : ret);
200 BUG_ON((len == 0) || (idx + len >
sizeof(buf)));
227 tda18271_i2c_gate_ctrl(fe, 1);
235 for (i = 1; i <=
max; i++)
236 buf[i] = regs[idx - 1 + i];
250 tda18271_i2c_gate_ctrl(fe, 0);
254 tda_err(
"ERROR: idx = 0x%x, len = %d, "
255 "i2c_transfer returned: %d\n", idx,
max, ret);
257 return (ret == 1 ? 0 : ret);
262 return __tda18271_write_regs(fe, idx, len,
true);
267 static int __tda18271_charge_pump_source(
struct dvb_frontend *fe,
277 regs[r_cp] |= ((force & 1) << 5);
279 return __tda18271_write_regs(fe, r_cp, 1, lock_i2c);
285 return __tda18271_charge_pump_source(fe, pll, force,
true);
294 tda_dbg(
"initializing registers for device @ %d-%04x\n",
302 tda18271_i2c_gate_ctrl(fe, 1);
394 __tda18271_write_regs(fe,
R_EB17, 1,
false);
396 __tda18271_write_regs(fe,
R_EB17, 1,
false);
398 __tda18271_write_regs(fe,
R_EB17, 1,
false);
400 __tda18271_write_regs(fe,
R_EB17, 1,
false);
405 __tda18271_write_regs(fe,
R_EB20, 1,
false);
407 __tda18271_write_regs(fe,
R_EB20, 1,
false);
409 __tda18271_write_regs(fe,
R_EB20, 1,
false);
411 __tda18271_write_regs(fe,
R_EB20, 1,
false);
429 __tda18271_write_regs(fe,
R_EP3, 11,
false);
443 __tda18271_write_regs(fe,
R_EP1, 1,
false);
451 __tda18271_write_regs(fe,
R_EP3, 7,
false);
455 __tda18271_write_regs(fe,
R_EP2, 1,
false);
466 __tda18271_write_regs(fe,
R_EP3, 11,
false);
470 __tda18271_write_regs(fe,
R_EP1, 1,
false);
478 __tda18271_write_regs(fe,
R_EP3, 7,
false);
482 __tda18271_write_regs(fe,
R_EP2, 1,
false);
494 __tda18271_write_regs(fe,
R_EP3, 11,
false);
498 __tda18271_write_regs(fe,
R_EP1, 1,
false);
505 __tda18271_write_regs(fe,
R_EP3, 7,
false);
509 __tda18271_write_regs(fe,
R_EP2, 1,
false);
514 __tda18271_write_regs(fe,
R_EP4, 1,
false);
517 __tda18271_write_regs(fe,
R_EP1, 1,
false);
520 tda18271_i2c_gate_ctrl(fe, 0);
544 int sm,
int sm_lt,
int sm_xt)
550 tda_dbg(
"sm = %d, sm_lt = %d, sm_xt = %d\n", sm, sm_lt, sm_xt);
552 regs[
R_EP3] &= ~0xe0;
553 regs[
R_EP3] |= (sm ? (1 << 7) : 0) |
554 (sm_lt ? (1 << 6) : 0) |
555 (sm_xt ? (1 << 5) : 0);
574 regs[
R_MPD] = (0x7f & pd);
576 div = ((d * (freq / 1000)) << 7) / 125;
578 regs[
R_MD1] = 0x7f & (div >> 16);
579 regs[
R_MD2] = 0xff & (div >> 8);
599 div = ((d * (freq / 1000)) << 7) / 125;
601 regs[
R_CD1] = 0x7f & (div >> 16);
602 regs[
R_CD2] = 0xff & (div >> 8);
621 regs[
R_EP1] &= ~0x07;
655 regs[
R_EP2] &= ~0xe0;
656 regs[
R_EP2] |= (0xe0 & (val << 5));
672 regs[
R_EP2] &= ~0x1f;
689 regs[
R_EP5] &= ~0x07;
718 const char *
func,
const char *
fmt, ...)
730 rtn =
printk(
"%s%s: [%d-%04x|%c] %pV",
731 level, func, i2c_adapter_id(state->
i2c_props.adap),
736 rtn =
printk(
"%s%s: %pV", level, func, &vaf);