30 .addr = priv->
cfg->i2c_addr,
44 dev_warn(&priv->
i2c->dev,
"%s: i2c wr failed=%d reg=%02x " \
45 "len=%d\n", KBUILD_MODNAME, ret, reg, len);
52 static int e4000_rd_regs(
struct e4000_priv *priv,
u8 reg,
u8 *val,
int len)
63 .addr = priv->
cfg->i2c_addr,
75 dev_warn(&priv->
i2c->dev,
"%s: i2c rd failed=%d reg=%02x " \
76 "len=%d\n", KBUILD_MODNAME, ret, reg, len);
86 return e4000_wr_regs(priv, reg, &val, 1);
92 return e4000_rd_regs(priv, reg, val, 1);
102 if (fe->
ops.i2c_gate_ctrl)
103 fe->
ops.i2c_gate_ctrl(fe, 1);
106 ret = e4000_wr_reg(priv, 0x02, 0x40);
109 ret = e4000_wr_reg(priv, 0x00, 0x01);
114 ret = e4000_wr_reg(priv, 0x06, 0x00);
118 ret = e4000_wr_reg(priv, 0x7a, 0x96);
123 ret = e4000_wr_regs(priv, 0x7e,
"\x01\xfe", 2);
127 ret = e4000_wr_reg(priv, 0x82, 0x00);
131 ret = e4000_wr_reg(priv, 0x24, 0x05);
135 ret = e4000_wr_regs(priv, 0x87,
"\x20\x01", 2);
139 ret = e4000_wr_regs(priv, 0x9f,
"\x7f\x07", 2);
150 ret = e4000_wr_reg(priv, 0x2d, 0x0c);
155 ret = e4000_wr_reg(priv, 0x1a, 0x17);
159 ret = e4000_wr_reg(priv, 0x1f, 0x1a);
163 if (fe->
ops.i2c_gate_ctrl)
164 fe->
ops.i2c_gate_ctrl(fe, 0);
168 if (fe->
ops.i2c_gate_ctrl)
169 fe->
ops.i2c_gate_ctrl(fe, 0);
171 dev_dbg(&priv->
i2c->dev,
"%s: failed=%d\n", __func__, ret);
182 if (fe->
ops.i2c_gate_ctrl)
183 fe->
ops.i2c_gate_ctrl(fe, 1);
185 ret = e4000_wr_reg(priv, 0x00, 0x00);
189 if (fe->
ops.i2c_gate_ctrl)
190 fe->
ops.i2c_gate_ctrl(fe, 0);
194 if (fe->
ops.i2c_gate_ctrl)
195 fe->
ops.i2c_gate_ctrl(fe, 0);
197 dev_dbg(&priv->
i2c->dev,
"%s: failed=%d\n", __func__, ret);
205 int ret,
i, sigma_delta;
209 dev_dbg(&priv->
i2c->dev,
"%s: delivery_system=%d frequency=%d " \
210 "bandwidth_hz=%d\n", __func__,
213 if (fe->
ops.i2c_gate_ctrl)
214 fe->
ops.i2c_gate_ctrl(fe, 1);
217 ret = e4000_wr_reg(priv, 0x1a, 0x00);
222 for (i = 0; i <
ARRAY_SIZE(e4000_pll_lut); i++) {
223 if (c->
frequency <= e4000_pll_lut[i].freq)
235 sigma_delta = 0x10000
UL * (f_VCO % priv->
cfg->clock) / priv->
cfg->clock;
236 buf[0] = f_VCO / priv->
cfg->clock;
237 buf[1] = (sigma_delta >> 0) & 0xff;
238 buf[2] = (sigma_delta >> 8) & 0xff;
240 buf[4] = e4000_pll_lut[
i].div;
242 dev_dbg(&priv->
i2c->dev,
"%s: f_VCO=%u pll div=%d sigma_delta=%04x\n",
243 __func__, f_VCO, buf[0], sigma_delta);
245 ret = e4000_wr_regs(priv, 0x09, buf, 5);
250 for (i = 0; i <
ARRAY_SIZE(e400_lna_filter_lut); i++) {
251 if (c->
frequency <= e400_lna_filter_lut[i].freq)
258 ret = e4000_wr_reg(priv, 0x10, e400_lna_filter_lut[i].val);
263 for (i = 0; i <
ARRAY_SIZE(e4000_if_filter_lut); i++) {
271 buf[0] = e4000_if_filter_lut[
i].reg11_val;
272 buf[1] = e4000_if_filter_lut[
i].reg12_val;
274 ret = e4000_wr_regs(priv, 0x11, buf, 2);
279 for (i = 0; i <
ARRAY_SIZE(e4000_band_lut); i++) {
280 if (c->
frequency <= e4000_band_lut[i].freq)
287 ret = e4000_wr_reg(priv, 0x07, e4000_band_lut[i].reg07_val);
291 ret = e4000_wr_reg(priv, 0x78, e4000_band_lut[i].reg78_val);
296 ret = e4000_wr_reg(priv, 0x1a, 0x17);
300 if (fe->
ops.i2c_gate_ctrl)
301 fe->
ops.i2c_gate_ctrl(fe, 0);
305 if (fe->
ops.i2c_gate_ctrl)
306 fe->
ops.i2c_gate_ctrl(fe, 0);
308 dev_dbg(&priv->
i2c->dev,
"%s: failed=%d\n", __func__, ret);
336 .name =
"Elonics E4000",
337 .frequency_min = 174000000,
338 .frequency_max = 862000000,
341 .release = e4000_release,
344 .sleep = e4000_sleep,
345 .set_params = e4000_set_params,
347 .get_if_frequency = e4000_get_if_frequency,
357 if (fe->
ops.i2c_gate_ctrl)
358 fe->
ops.i2c_gate_ctrl(fe, 1);
363 dev_err(&i2c->
dev,
"%s: kzalloc() failed\n", KBUILD_MODNAME);
371 ret = e4000_rd_reg(priv, 0x02, &chip_id);
375 dev_dbg(&priv->
i2c->dev,
"%s: chip_id=%02x\n", __func__, chip_id);
381 ret = e4000_wr_reg(priv, 0x00, 0x00);
386 "%s: Elonics E4000 successfully identified\n",
390 memcpy(&fe->
ops.tuner_ops, &e4000_tuner_ops,
393 if (fe->
ops.i2c_gate_ctrl)
394 fe->
ops.i2c_gate_ctrl(fe, 0);
398 if (fe->
ops.i2c_gate_ctrl)
399 fe->
ops.i2c_gate_ctrl(fe, 0);
401 dev_dbg(&i2c->
dev,
"%s: failed=%d\n", __func__, ret);