Lines Matching +full:a +full:- +full:f0 +full:- +full:9
1 // SPDX-License-Identifier: GPL-2.0-or-later
21 ret = regmap_bulk_read(dev->regmap, reg, &tmp, 1); in m88ds3103_update_bits()
30 return regmap_bulk_write(dev->regmap, reg, &val, 1); in m88ds3103_update_bits()
37 struct i2c_client *client = dev->client; in m88ds3103_wr_reg_val_tab()
41 dev_dbg(&client->dev, "tab_len=%d\n", tab_len); in m88ds3103_wr_reg_val_tab()
44 ret = -EINVAL; in m88ds3103_wr_reg_val_tab()
51 if (i == tab_len - 1 || tab[i].reg != tab[i + 1].reg - 1 || in m88ds3103_wr_reg_val_tab()
52 !((j + 1) % (dev->cfg->i2c_wr_max - 1))) { in m88ds3103_wr_reg_val_tab()
53 ret = regmap_bulk_write(dev->regmap, tab[i].reg - j, buf, j + 1); in m88ds3103_wr_reg_val_tab()
57 j = -1; in m88ds3103_wr_reg_val_tab()
63 dev_dbg(&client->dev, "failed=%d\n", ret); in m88ds3103_wr_reg_val_tab()
73 struct i2c_client *client = dev->client; in m88ds3103b_dt_write()
78 .addr = dev->dt_addr, .flags = 0, .buf = buf, .len = 2 in m88ds3103b_dt_write()
84 ret = regmap_write(dev->regmap, 0x03, val); in m88ds3103b_dt_write()
86 dev_dbg(&client->dev, "fail=%d\n", ret); in m88ds3103b_dt_write()
88 ret = i2c_transfer(dev->dt_client->adapter, &msg, 1); in m88ds3103b_dt_write()
90 dev_err(&client->dev, "0x%02x (ret=%i, reg=0x%02x, value=0x%02x)\n", in m88ds3103b_dt_write()
91 dev->dt_addr, ret, reg, data); in m88ds3103b_dt_write()
94 return -EREMOTEIO; in m88ds3103b_dt_write()
98 dev_dbg(&client->dev, "0x%02x reg 0x%02x, value 0x%02x\n", in m88ds3103b_dt_write()
99 dev->dt_addr, reg, data); in m88ds3103b_dt_write()
110 struct i2c_client *client = dev->client; in m88ds3103b_dt_read()
117 .addr = dev->dt_addr, in m88ds3103b_dt_read()
123 .addr = dev->dt_addr, in m88ds3103b_dt_read()
133 ret = regmap_write(dev->regmap, 0x03, val); in m88ds3103b_dt_read()
135 dev_dbg(&client->dev, "fail=%d\n", ret); in m88ds3103b_dt_read()
137 ret = i2c_transfer(dev->dt_client->adapter, msg, 2); in m88ds3103b_dt_read()
139 dev_err(&client->dev, "0x%02x (ret=%d, reg=0x%02x)\n", in m88ds3103b_dt_read()
140 dev->dt_addr, ret, reg); in m88ds3103b_dt_read()
143 return -EREMOTEIO; in m88ds3103b_dt_read()
147 dev_dbg(&client->dev, "0x%02x reg 0x%02x, value 0x%02x\n", in m88ds3103b_dt_read()
148 dev->dt_addr, reg, b1[0]); in m88ds3103b_dt_read()
158 struct m88ds3103_dev *dev = fe->demodulator_priv; in m88ds3103_get_agc_pwm()
162 ret = regmap_read(dev->regmap, 0x3f, &tmp); in m88ds3103_get_agc_pwm()
172 struct m88ds3103_dev *dev = fe->demodulator_priv; in m88ds3103_read_status()
173 struct i2c_client *client = dev->client; in m88ds3103_read_status()
174 struct dtv_frontend_properties *c = &fe->dtv_property_cache; in m88ds3103_read_status()
181 if (!dev->warm) { in m88ds3103_read_status()
182 ret = -EAGAIN; in m88ds3103_read_status()
186 switch (c->delivery_system) { in m88ds3103_read_status()
188 ret = regmap_read(dev->regmap, 0xd1, &utmp); in m88ds3103_read_status()
198 ret = regmap_read(dev->regmap, 0x0d, &utmp); in m88ds3103_read_status()
208 dev_dbg(&client->dev, "invalid delivery_system\n"); in m88ds3103_read_status()
209 ret = -EINVAL; in m88ds3103_read_status()
213 dev->fe_status = *status; in m88ds3103_read_status()
214 dev_dbg(&client->dev, "lock=%02x status=%02x\n", utmp, *status); in m88ds3103_read_status()
217 if (dev->fe_status & FE_HAS_VITERBI) { in m88ds3103_read_status()
224 switch (c->delivery_system) { in m88ds3103_read_status()
229 ret = regmap_read(dev->regmap, 0xff, &utmp); in m88ds3103_read_status()
247 ret = regmap_bulk_read(dev->regmap, 0x8c, buf, 3); in m88ds3103_read_status()
271 dev_dbg(&client->dev, "invalid delivery_system\n"); in m88ds3103_read_status()
272 ret = -EINVAL; in m88ds3103_read_status()
277 c->cnr.stat[0].scale = FE_SCALE_DECIBEL; in m88ds3103_read_status()
278 c->cnr.stat[0].svalue = cnr; in m88ds3103_read_status()
280 c->cnr.stat[0].scale = FE_SCALE_NOT_AVAILABLE; in m88ds3103_read_status()
283 c->cnr.stat[0].scale = FE_SCALE_NOT_AVAILABLE; in m88ds3103_read_status()
287 if (dev->fe_status & FE_HAS_LOCK) { in m88ds3103_read_status()
290 switch (c->delivery_system) { in m88ds3103_read_status()
292 ret = regmap_write(dev->regmap, 0xf9, 0x04); in m88ds3103_read_status()
296 ret = regmap_read(dev->regmap, 0xf8, &utmp); in m88ds3103_read_status()
302 ret = regmap_bulk_read(dev->regmap, 0xf6, buf, 2); in m88ds3103_read_status()
308 dev->post_bit_error += post_bit_error; in m88ds3103_read_status()
309 dev->post_bit_count += post_bit_count; in m88ds3103_read_status()
310 dev->dvbv3_ber = post_bit_error; in m88ds3103_read_status()
314 ret = regmap_write(dev->regmap, 0xf8, utmp); in m88ds3103_read_status()
320 ret = regmap_bulk_read(dev->regmap, 0xd5, buf, 3); in m88ds3103_read_status()
328 ret = regmap_bulk_read(dev->regmap, 0xf7, buf, 2); in m88ds3103_read_status()
334 dev->post_bit_error += post_bit_error; in m88ds3103_read_status()
335 dev->post_bit_count += post_bit_count; in m88ds3103_read_status()
336 dev->dvbv3_ber = post_bit_error; in m88ds3103_read_status()
339 ret = regmap_write(dev->regmap, 0xd1, 0x01); in m88ds3103_read_status()
343 ret = regmap_write(dev->regmap, 0xf9, 0x01); in m88ds3103_read_status()
347 ret = regmap_write(dev->regmap, 0xf9, 0x00); in m88ds3103_read_status()
351 ret = regmap_write(dev->regmap, 0xd1, 0x00); in m88ds3103_read_status()
357 dev_dbg(&client->dev, "invalid delivery_system\n"); in m88ds3103_read_status()
358 ret = -EINVAL; in m88ds3103_read_status()
362 c->post_bit_error.stat[0].scale = FE_SCALE_COUNTER; in m88ds3103_read_status()
363 c->post_bit_error.stat[0].uvalue = dev->post_bit_error; in m88ds3103_read_status()
364 c->post_bit_count.stat[0].scale = FE_SCALE_COUNTER; in m88ds3103_read_status()
365 c->post_bit_count.stat[0].uvalue = dev->post_bit_count; in m88ds3103_read_status()
367 c->post_bit_error.stat[0].scale = FE_SCALE_NOT_AVAILABLE; in m88ds3103_read_status()
368 c->post_bit_count.stat[0].scale = FE_SCALE_NOT_AVAILABLE; in m88ds3103_read_status()
373 dev_dbg(&client->dev, "failed=%d\n", ret); in m88ds3103_read_status()
379 struct i2c_client *client = dev->client; in m88ds3103b_select_mclk()
380 struct dtv_frontend_properties *c = &dev->fe.dtv_property_cache; in m88ds3103b_select_mclk()
385 u32 old_setting = dev->mclk; in m88ds3103b_select_mclk()
386 u32 tuner_freq_MHz = c->frequency / 1000; in m88ds3103b_select_mclk()
390 big_symbol = (c->symbol_rate > 45010000) ? 1 : 0; in m88ds3103b_select_mclk()
402 offset_MHz[i] = adc_Freq_MHz[i] - offset_MHz[i]; in m88ds3103b_select_mclk()
407 dev->mclk = adc_Freq_MHz[i] * 1000 * 1000; in m88ds3103b_select_mclk()
410 dev->mclk /= 2; in m88ds3103b_select_mclk()
412 dev_dbg(&client->dev, "modifying mclk %u -> %u\n", in m88ds3103b_select_mclk()
413 old_setting, dev->mclk); in m88ds3103b_select_mclk()
418 if (dev->mclk == 93000000) in m88ds3103b_select_mclk()
419 regmap_write(dev->regmap, 0xA0, 0x42); in m88ds3103b_select_mclk()
420 else if (dev->mclk == 96000000) in m88ds3103b_select_mclk()
421 regmap_write(dev->regmap, 0xA0, 0x44); in m88ds3103b_select_mclk()
422 else if (dev->mclk == 99000000) in m88ds3103b_select_mclk()
423 regmap_write(dev->regmap, 0xA0, 0x46); in m88ds3103b_select_mclk()
424 else if (dev->mclk == 110250000) in m88ds3103b_select_mclk()
425 regmap_write(dev->regmap, 0xA0, 0x4E); in m88ds3103b_select_mclk()
427 regmap_write(dev->regmap, 0xA0, 0x44); in m88ds3103b_select_mclk()
455 u8 sm, f0 = 0, f1 = 0, f2 = 0, f3 = 0; in m88ds3103b_set_mclk() local
463 if (dev->cfg->ts_mode != M88DS3103_TS_SERIAL) { in m88ds3103b_set_mclk()
482 if (dev->cfg->ts_mode == M88DS3103_TS_SERIAL) { in m88ds3103b_set_mclk()
488 f0 = 0; in m88ds3103b_set_mclk()
490 f2 = div - f1; in m88ds3103b_set_mclk()
495 f0 = div / N; in m88ds3103b_set_mclk()
496 f1 = (div - f0) / (N - 1); in m88ds3103b_set_mclk()
497 f2 = div - f0 - f1; in m88ds3103b_set_mclk()
502 f0 = div / N; in m88ds3103b_set_mclk()
503 f1 = (div - f0) / (N - 1); in m88ds3103b_set_mclk()
504 f2 = (div - f0 - f1) / (N - 2); in m88ds3103b_set_mclk()
505 f3 = div - f0 - f1 - f2; in m88ds3103b_set_mclk()
509 f0 = 16; in m88ds3103b_set_mclk()
515 if (f0 == 16) in m88ds3103b_set_mclk()
516 f0 = 0; in m88ds3103b_set_mclk()
517 else if ((f0 < 8) && (f0 != 0)) in m88ds3103b_set_mclk()
518 f0 = 8; in m88ds3103b_set_mclk()
540 f0 = 0; in m88ds3103b_set_mclk()
542 f2 = div - f1; in m88ds3103b_set_mclk()
547 f0 = div / N; in m88ds3103b_set_mclk()
548 f1 = (div - f0) / (N - 1); in m88ds3103b_set_mclk()
549 f2 = div - f0 - f1; in m88ds3103b_set_mclk()
554 f0 = div / N; in m88ds3103b_set_mclk()
555 f1 = (div - f0) / (N - 1); in m88ds3103b_set_mclk()
556 f2 = (div - f0 - f1) / (N - 2); in m88ds3103b_set_mclk()
557 f3 = div - f0 - f1 - f2; in m88ds3103b_set_mclk()
561 f0 = 16; in m88ds3103b_set_mclk()
567 if (f0 == 16) in m88ds3103b_set_mclk()
568 f0 = 0; in m88ds3103b_set_mclk()
569 else if ((f0 < 9) && (f0 != 0)) in m88ds3103b_set_mclk()
570 f0 = 9; in m88ds3103b_set_mclk()
574 else if ((f1 < 9) && (f1 != 0)) in m88ds3103b_set_mclk()
575 f1 = 9; in m88ds3103b_set_mclk()
579 else if ((f2 < 9) && (f2 != 0)) in m88ds3103b_set_mclk()
580 f2 = 9; in m88ds3103b_set_mclk()
584 else if ((f3 < 9) && (f3 != 0)) in m88ds3103b_set_mclk()
585 f3 = 9; in m88ds3103b_set_mclk()
588 sm = N - 1; in m88ds3103b_set_mclk()
601 reg1F = ((f1 << 4) + f0) & 0xFF; in m88ds3103b_set_mclk()
624 struct m88ds3103_dev *dev = fe->demodulator_priv; in m88ds3103_set_frontend()
625 struct i2c_client *client = dev->client; in m88ds3103_set_frontend()
626 struct dtv_frontend_properties *c = &fe->dtv_property_cache; in m88ds3103_set_frontend()
638 dev_dbg(&client->dev, in m88ds3103_set_frontend()
640 c->delivery_system, c->modulation, c->frequency, c->symbol_rate, in m88ds3103_set_frontend()
641 c->inversion, c->pilot, c->rolloff); in m88ds3103_set_frontend()
643 if (!dev->warm) { in m88ds3103_set_frontend()
644 ret = -EAGAIN; in m88ds3103_set_frontend()
649 ret = regmap_multi_reg_write(dev->regmap, reset_buf, 2); in m88ds3103_set_frontend()
654 if (dev->chip_id == M88RS6000_CHIP_ID) { in m88ds3103_set_frontend()
655 if (dev->chiptype == M88DS3103_CHIPTYPE_3103B) { in m88ds3103_set_frontend()
656 ret = regmap_read(dev->regmap, 0xb2, &u32tmp); in m88ds3103_set_frontend()
660 ret = regmap_write(dev->regmap, 0x00, 0x00); in m88ds3103_set_frontend()
663 ret = regmap_write(dev->regmap, 0xb2, 0x00); in m88ds3103_set_frontend()
669 ret = regmap_write(dev->regmap, 0x06, 0xe0); in m88ds3103_set_frontend()
675 if (fe->ops.tuner_ops.set_params) { in m88ds3103_set_frontend()
676 ret = fe->ops.tuner_ops.set_params(fe); in m88ds3103_set_frontend()
681 if (fe->ops.tuner_ops.get_frequency) { in m88ds3103_set_frontend()
682 ret = fe->ops.tuner_ops.get_frequency(fe, &tuner_frequency_khz); in m88ds3103_set_frontend()
691 tuner_frequency_khz = c->frequency; in m88ds3103_set_frontend()
695 if (dev->chip_id == M88RS6000_CHIP_ID) { in m88ds3103_set_frontend()
696 if (c->symbol_rate > 45010000) in m88ds3103_set_frontend()
697 dev->mclk = 110250000; in m88ds3103_set_frontend()
699 dev->mclk = 96000000; in m88ds3103_set_frontend()
701 if (c->delivery_system == SYS_DVBS) in m88ds3103_set_frontend()
706 if (dev->chiptype == M88DS3103_CHIPTYPE_3103B) { in m88ds3103_set_frontend()
712 ret = regmap_write(dev->regmap, 0x06, 0x00); in m88ds3103_set_frontend()
718 dev->mclk = 96000000; in m88ds3103_set_frontend()
720 switch (dev->cfg->ts_mode) { in m88ds3103_set_frontend()
723 target_mclk = dev->cfg->ts_clk; in m88ds3103_set_frontend()
727 if (c->delivery_system == SYS_DVBS) in m88ds3103_set_frontend()
730 if (c->symbol_rate < 18000000) in m88ds3103_set_frontend()
732 else if (c->symbol_rate < 28000000) in m88ds3103_set_frontend()
739 dev_dbg(&client->dev, "invalid ts_mode\n"); in m88ds3103_set_frontend()
740 ret = -EINVAL; in m88ds3103_set_frontend()
766 ret = regmap_write(dev->regmap, 0xb2, 0x01); in m88ds3103_set_frontend()
770 ret = regmap_write(dev->regmap, 0x00, 0x01); in m88ds3103_set_frontend()
774 switch (c->delivery_system) { in m88ds3103_set_frontend()
776 if (dev->chip_id == M88RS6000_CHIP_ID) { in m88ds3103_set_frontend()
785 if (dev->chip_id == M88RS6000_CHIP_ID) { in m88ds3103_set_frontend()
794 dev_dbg(&client->dev, "invalid delivery_system\n"); in m88ds3103_set_frontend()
795 ret = -EINVAL; in m88ds3103_set_frontend()
800 if (c->delivery_system != dev->delivery_system) { in m88ds3103_set_frontend()
806 if (dev->chip_id == M88RS6000_CHIP_ID) { in m88ds3103_set_frontend()
807 if (c->delivery_system == SYS_DVBS2 && in m88ds3103_set_frontend()
808 c->symbol_rate <= 5000000) { in m88ds3103_set_frontend()
809 ret = regmap_write(dev->regmap, 0xc0, 0x04); in m88ds3103_set_frontend()
815 ret = regmap_bulk_write(dev->regmap, 0x8a, buf, 3); in m88ds3103_set_frontend()
823 if (dev->chiptype == M88DS3103_CHIPTYPE_3103B) { in m88ds3103_set_frontend()
827 if (c->symbol_rate > 45010000) { in m88ds3103_set_frontend()
830 buf[0] |= ((147 - 32) >> 8) & 0x01; in m88ds3103_set_frontend()
831 buf[1] = (147 - 32) & 0xFF; in m88ds3103_set_frontend()
833 dev->mclk = 110250 * 1000; in m88ds3103_set_frontend()
836 buf[0] |= ((128 - 32) >> 8) & 0x01; in m88ds3103_set_frontend()
837 buf[1] = (128 - 32) & 0xFF; in m88ds3103_set_frontend()
839 dev->mclk = 96000 * 1000; in m88ds3103_set_frontend()
844 regmap_read(dev->regmap, 0x30, &u32tmp); in m88ds3103_set_frontend()
846 regmap_write(dev->regmap, 0x30, u32tmp & 0xff); in m88ds3103_set_frontend()
849 ret = regmap_write(dev->regmap, 0xf1, 0x01); in m88ds3103_set_frontend()
853 if (dev->chiptype != M88DS3103_CHIPTYPE_3103B) { in m88ds3103_set_frontend()
860 switch (dev->cfg->ts_mode) { in m88ds3103_set_frontend()
871 if (dev->chiptype == M88DS3103_CHIPTYPE_3103B) { in m88ds3103_set_frontend()
880 dev_dbg(&client->dev, "invalid ts_mode\n"); in m88ds3103_set_frontend()
881 ret = -EINVAL; in m88ds3103_set_frontend()
885 if (dev->cfg->ts_clk_pol) in m88ds3103_set_frontend()
889 ret = regmap_write(dev->regmap, 0xfd, u8tmp); in m88ds3103_set_frontend()
893 switch (dev->cfg->ts_mode) { in m88ds3103_set_frontend()
904 if (dev->chiptype == M88DS3103_CHIPTYPE_3103B) { in m88ds3103_set_frontend()
911 u16tmp = DIV_ROUND_UP(target_mclk, dev->cfg->ts_clk); in m88ds3103_set_frontend()
912 u8tmp1 = u16tmp / 2 - 1; in m88ds3103_set_frontend()
913 u8tmp2 = DIV_ROUND_UP(u16tmp, 2) - 1; in m88ds3103_set_frontend()
916 dev_dbg(&client->dev, "target_mclk=%u ts_clk=%u ts_clk_divide_ratio=%u\n", in m88ds3103_set_frontend()
917 target_mclk, dev->cfg->ts_clk, u16tmp); in m88ds3103_set_frontend()
922 ret = regmap_update_bits(dev->regmap, 0xfe, 0x0f, u8tmp); in m88ds3103_set_frontend()
926 ret = regmap_write(dev->regmap, 0xea, u8tmp); in m88ds3103_set_frontend()
930 if (c->symbol_rate <= 3000000) in m88ds3103_set_frontend()
932 else if (c->symbol_rate <= 10000000) in m88ds3103_set_frontend()
937 if (dev->chiptype == M88DS3103_CHIPTYPE_3103B) in m88ds3103_set_frontend()
940 ret = regmap_write(dev->regmap, 0xc3, 0x08); in m88ds3103_set_frontend()
944 ret = regmap_write(dev->regmap, 0xc8, u8tmp); in m88ds3103_set_frontend()
948 ret = regmap_write(dev->regmap, 0xc4, 0x08); in m88ds3103_set_frontend()
952 ret = regmap_write(dev->regmap, 0xc7, 0x00); in m88ds3103_set_frontend()
956 u16tmp = DIV_ROUND_CLOSEST_ULL((u64)c->symbol_rate * 0x10000, dev->mclk); in m88ds3103_set_frontend()
959 ret = regmap_bulk_write(dev->regmap, 0x61, buf, 2); in m88ds3103_set_frontend()
963 ret = m88ds3103_update_bits(dev, 0x4d, 0x02, dev->cfg->spec_inv << 1); in m88ds3103_set_frontend()
967 ret = m88ds3103_update_bits(dev, 0x30, 0x10, dev->cfg->agc_inv << 4); in m88ds3103_set_frontend()
971 ret = regmap_write(dev->regmap, 0x33, dev->cfg->agc); in m88ds3103_set_frontend()
975 if (dev->chiptype == M88DS3103_CHIPTYPE_3103B) { in m88ds3103_set_frontend()
978 (c->delivery_system == SYS_DVBS) ? 0x10 : 0x0); in m88ds3103_set_frontend()
987 dev_dbg(&client->dev, "carrier offset=%d\n", in m88ds3103_set_frontend()
988 (tuner_frequency_khz - c->frequency)); in m88ds3103_set_frontend()
990 /* Use 32-bit calc as there is no s64 version of DIV_ROUND_CLOSEST() */ in m88ds3103_set_frontend()
991 s32tmp = 0x10000 * (tuner_frequency_khz - c->frequency); in m88ds3103_set_frontend()
992 s32tmp = DIV_ROUND_CLOSEST(s32tmp, dev->mclk / 1000); in m88ds3103_set_frontend()
995 ret = regmap_bulk_write(dev->regmap, 0x5e, buf, 2); in m88ds3103_set_frontend()
999 ret = regmap_write(dev->regmap, 0x00, 0x00); in m88ds3103_set_frontend()
1003 ret = regmap_write(dev->regmap, 0xb2, 0x00); in m88ds3103_set_frontend()
1007 dev->delivery_system = c->delivery_system; in m88ds3103_set_frontend()
1011 dev_dbg(&client->dev, "failed=%d\n", ret); in m88ds3103_set_frontend()
1017 struct m88ds3103_dev *dev = fe->demodulator_priv; in m88ds3103_init()
1018 struct i2c_client *client = dev->client; in m88ds3103_init()
1019 struct dtv_frontend_properties *c = &fe->dtv_property_cache; in m88ds3103_init()
1025 dev_dbg(&client->dev, "\n"); in m88ds3103_init()
1028 dev->warm = false; in m88ds3103_init()
1042 ret = regmap_read(dev->regmap, 0xb9, &utmp); in m88ds3103_init()
1046 dev_dbg(&client->dev, "firmware=%02x\n", utmp); in m88ds3103_init()
1052 ret = regmap_write(dev->regmap, 0x07, 0xe0); in m88ds3103_init()
1055 ret = regmap_write(dev->regmap, 0x07, 0x00); in m88ds3103_init()
1059 /* cold state - try to download firmware */ in m88ds3103_init()
1060 dev_info(&client->dev, "found a '%s' in cold state\n", in m88ds3103_init()
1061 dev->fe.ops.info.name); in m88ds3103_init()
1063 if (dev->chiptype == M88DS3103_CHIPTYPE_3103B) in m88ds3103_init()
1065 else if (dev->chip_id == M88RS6000_CHIP_ID) in m88ds3103_init()
1071 ret = request_firmware(&firmware, name, &client->dev); in m88ds3103_init()
1073 dev_err(&client->dev, "firmware file '%s' not found\n", name); in m88ds3103_init()
1077 dev_info(&client->dev, "downloading firmware from file '%s'\n", name); in m88ds3103_init()
1079 ret = regmap_write(dev->regmap, 0xb2, 0x01); in m88ds3103_init()
1083 for (rem = firmware->size; rem > 0; rem -= (dev->cfg->i2c_wr_max - 1)) { in m88ds3103_init()
1084 len = min(dev->cfg->i2c_wr_max - 1, rem); in m88ds3103_init()
1085 ret = regmap_bulk_write(dev->regmap, 0xb0, in m88ds3103_init()
1086 &firmware->data[firmware->size - rem], in m88ds3103_init()
1089 dev_err(&client->dev, "firmware download failed %d\n", in m88ds3103_init()
1095 ret = regmap_write(dev->regmap, 0xb2, 0x00); in m88ds3103_init()
1101 ret = regmap_read(dev->regmap, 0xb9, &utmp); in m88ds3103_init()
1106 ret = -EINVAL; in m88ds3103_init()
1107 dev_info(&client->dev, "firmware did not run\n"); in m88ds3103_init()
1111 dev_info(&client->dev, "found a '%s' in warm state\n", in m88ds3103_init()
1112 dev->fe.ops.info.name); in m88ds3103_init()
1113 dev_info(&client->dev, "firmware version: %X.%X\n", in m88ds3103_init()
1116 if (dev->chiptype == M88DS3103_CHIPTYPE_3103B) { in m88ds3103_init()
1124 dev->warm = true; in m88ds3103_init()
1127 c->cnr.len = 1; in m88ds3103_init()
1128 c->cnr.stat[0].scale = FE_SCALE_NOT_AVAILABLE; in m88ds3103_init()
1129 c->post_bit_error.len = 1; in m88ds3103_init()
1130 c->post_bit_error.stat[0].scale = FE_SCALE_NOT_AVAILABLE; in m88ds3103_init()
1131 c->post_bit_count.len = 1; in m88ds3103_init()
1132 c->post_bit_count.stat[0].scale = FE_SCALE_NOT_AVAILABLE; in m88ds3103_init()
1138 dev_dbg(&client->dev, "failed=%d\n", ret); in m88ds3103_init()
1144 struct m88ds3103_dev *dev = fe->demodulator_priv; in m88ds3103_sleep()
1145 struct i2c_client *client = dev->client; in m88ds3103_sleep()
1149 dev_dbg(&client->dev, "\n"); in m88ds3103_sleep()
1151 dev->fe_status = 0; in m88ds3103_sleep()
1152 dev->delivery_system = SYS_UNDEFINED; in m88ds3103_sleep()
1154 /* TS Hi-Z */ in m88ds3103_sleep()
1155 if (dev->chip_id == M88RS6000_CHIP_ID) in m88ds3103_sleep()
1176 dev_dbg(&client->dev, "failed=%d\n", ret); in m88ds3103_sleep()
1183 struct m88ds3103_dev *dev = fe->demodulator_priv; in m88ds3103_get_frontend()
1184 struct i2c_client *client = dev->client; in m88ds3103_get_frontend()
1188 dev_dbg(&client->dev, "\n"); in m88ds3103_get_frontend()
1190 if (!dev->warm || !(dev->fe_status & FE_HAS_LOCK)) { in m88ds3103_get_frontend()
1195 switch (c->delivery_system) { in m88ds3103_get_frontend()
1197 ret = regmap_bulk_read(dev->regmap, 0xe0, &buf[0], 1); in m88ds3103_get_frontend()
1201 ret = regmap_bulk_read(dev->regmap, 0xe6, &buf[1], 1); in m88ds3103_get_frontend()
1207 c->inversion = INVERSION_OFF; in m88ds3103_get_frontend()
1210 c->inversion = INVERSION_ON; in m88ds3103_get_frontend()
1216 c->fec_inner = FEC_7_8; in m88ds3103_get_frontend()
1219 c->fec_inner = FEC_5_6; in m88ds3103_get_frontend()
1222 c->fec_inner = FEC_3_4; in m88ds3103_get_frontend()
1225 c->fec_inner = FEC_2_3; in m88ds3103_get_frontend()
1228 c->fec_inner = FEC_1_2; in m88ds3103_get_frontend()
1231 dev_dbg(&client->dev, "invalid fec_inner\n"); in m88ds3103_get_frontend()
1234 c->modulation = QPSK; in m88ds3103_get_frontend()
1238 ret = regmap_bulk_read(dev->regmap, 0x7e, &buf[0], 1); in m88ds3103_get_frontend()
1242 ret = regmap_bulk_read(dev->regmap, 0x89, &buf[1], 1); in m88ds3103_get_frontend()
1246 ret = regmap_bulk_read(dev->regmap, 0xf2, &buf[2], 1); in m88ds3103_get_frontend()
1252 c->fec_inner = FEC_2_5; in m88ds3103_get_frontend()
1255 c->fec_inner = FEC_1_2; in m88ds3103_get_frontend()
1258 c->fec_inner = FEC_3_5; in m88ds3103_get_frontend()
1261 c->fec_inner = FEC_2_3; in m88ds3103_get_frontend()
1264 c->fec_inner = FEC_3_4; in m88ds3103_get_frontend()
1267 c->fec_inner = FEC_4_5; in m88ds3103_get_frontend()
1270 c->fec_inner = FEC_5_6; in m88ds3103_get_frontend()
1272 case 9: in m88ds3103_get_frontend()
1273 c->fec_inner = FEC_8_9; in m88ds3103_get_frontend()
1276 c->fec_inner = FEC_9_10; in m88ds3103_get_frontend()
1279 dev_dbg(&client->dev, "invalid fec_inner\n"); in m88ds3103_get_frontend()
1284 c->pilot = PILOT_OFF; in m88ds3103_get_frontend()
1287 c->pilot = PILOT_ON; in m88ds3103_get_frontend()
1293 c->modulation = QPSK; in m88ds3103_get_frontend()
1296 c->modulation = PSK_8; in m88ds3103_get_frontend()
1299 c->modulation = APSK_16; in m88ds3103_get_frontend()
1302 c->modulation = APSK_32; in m88ds3103_get_frontend()
1305 dev_dbg(&client->dev, "invalid modulation\n"); in m88ds3103_get_frontend()
1310 c->inversion = INVERSION_OFF; in m88ds3103_get_frontend()
1313 c->inversion = INVERSION_ON; in m88ds3103_get_frontend()
1319 c->rolloff = ROLLOFF_35; in m88ds3103_get_frontend()
1322 c->rolloff = ROLLOFF_25; in m88ds3103_get_frontend()
1325 c->rolloff = ROLLOFF_20; in m88ds3103_get_frontend()
1328 dev_dbg(&client->dev, "invalid rolloff\n"); in m88ds3103_get_frontend()
1332 dev_dbg(&client->dev, "invalid delivery_system\n"); in m88ds3103_get_frontend()
1333 ret = -EINVAL; in m88ds3103_get_frontend()
1337 ret = regmap_bulk_read(dev->regmap, 0x6d, buf, 2); in m88ds3103_get_frontend()
1341 c->symbol_rate = DIV_ROUND_CLOSEST_ULL((u64)(buf[1] << 8 | buf[0] << 0) * dev->mclk, 0x10000); in m88ds3103_get_frontend()
1345 dev_dbg(&client->dev, "failed=%d\n", ret); in m88ds3103_get_frontend()
1351 struct dtv_frontend_properties *c = &fe->dtv_property_cache; in m88ds3103_read_snr()
1353 if (c->cnr.stat[0].scale == FE_SCALE_DECIBEL) in m88ds3103_read_snr()
1354 *snr = div_s64(c->cnr.stat[0].svalue, 100); in m88ds3103_read_snr()
1363 struct m88ds3103_dev *dev = fe->demodulator_priv; in m88ds3103_read_ber()
1365 *ber = dev->dvbv3_ber; in m88ds3103_read_ber()
1373 struct m88ds3103_dev *dev = fe->demodulator_priv; in m88ds3103_set_tone()
1374 struct i2c_client *client = dev->client; in m88ds3103_set_tone()
1378 dev_dbg(&client->dev, "fe_sec_tone_mode=%d\n", fe_sec_tone_mode); in m88ds3103_set_tone()
1380 if (!dev->warm) { in m88ds3103_set_tone()
1381 ret = -EAGAIN; in m88ds3103_set_tone()
1395 dev_dbg(&client->dev, "invalid fe_sec_tone_mode\n"); in m88ds3103_set_tone()
1396 ret = -EINVAL; in m88ds3103_set_tone()
1400 utmp = tone << 7 | dev->cfg->envelope_mode << 5; in m88ds3103_set_tone()
1412 dev_dbg(&client->dev, "failed=%d\n", ret); in m88ds3103_set_tone()
1419 struct m88ds3103_dev *dev = fe->demodulator_priv; in m88ds3103_set_voltage()
1420 struct i2c_client *client = dev->client; in m88ds3103_set_voltage()
1425 dev_dbg(&client->dev, "fe_sec_voltage=%d\n", fe_sec_voltage); in m88ds3103_set_voltage()
1427 if (!dev->warm) { in m88ds3103_set_voltage()
1428 ret = -EAGAIN; in m88ds3103_set_voltage()
1446 dev_dbg(&client->dev, "invalid fe_sec_voltage\n"); in m88ds3103_set_voltage()
1447 ret = -EINVAL; in m88ds3103_set_voltage()
1452 voltage_sel ^= dev->cfg->lnb_hv_pol; in m88ds3103_set_voltage()
1453 voltage_dis ^= dev->cfg->lnb_en_pol; in m88ds3103_set_voltage()
1462 dev_dbg(&client->dev, "failed=%d\n", ret); in m88ds3103_set_voltage()
1469 struct m88ds3103_dev *dev = fe->demodulator_priv; in m88ds3103_diseqc_send_master_cmd()
1470 struct i2c_client *client = dev->client; in m88ds3103_diseqc_send_master_cmd()
1475 dev_dbg(&client->dev, "msg=%*ph\n", in m88ds3103_diseqc_send_master_cmd()
1476 diseqc_cmd->msg_len, diseqc_cmd->msg); in m88ds3103_diseqc_send_master_cmd()
1478 if (!dev->warm) { in m88ds3103_diseqc_send_master_cmd()
1479 ret = -EAGAIN; in m88ds3103_diseqc_send_master_cmd()
1483 if (diseqc_cmd->msg_len < 3 || diseqc_cmd->msg_len > 6) { in m88ds3103_diseqc_send_master_cmd()
1484 ret = -EINVAL; in m88ds3103_diseqc_send_master_cmd()
1488 utmp = dev->cfg->envelope_mode << 5; in m88ds3103_diseqc_send_master_cmd()
1493 ret = regmap_bulk_write(dev->regmap, 0xa3, diseqc_cmd->msg, in m88ds3103_diseqc_send_master_cmd()
1494 diseqc_cmd->msg_len); in m88ds3103_diseqc_send_master_cmd()
1498 ret = regmap_write(dev->regmap, 0xa1, in m88ds3103_diseqc_send_master_cmd()
1499 (diseqc_cmd->msg_len - 1) << 3 | 0x07); in m88ds3103_diseqc_send_master_cmd()
1508 utmp = diseqc_cmd->msg_len * 13500; in m88ds3103_diseqc_send_master_cmd()
1509 usleep_range(utmp - 4000, utmp); in m88ds3103_diseqc_send_master_cmd()
1512 ret = regmap_read(dev->regmap, 0xa1, &utmp); in m88ds3103_diseqc_send_master_cmd()
1519 dev_dbg(&client->dev, "diseqc tx took %u ms\n", in m88ds3103_diseqc_send_master_cmd()
1520 jiffies_to_msecs(jiffies) - in m88ds3103_diseqc_send_master_cmd()
1521 (jiffies_to_msecs(timeout) - SEND_MASTER_CMD_TIMEOUT)); in m88ds3103_diseqc_send_master_cmd()
1523 dev_dbg(&client->dev, "diseqc tx timeout\n"); in m88ds3103_diseqc_send_master_cmd()
1535 ret = -ETIMEDOUT; in m88ds3103_diseqc_send_master_cmd()
1541 dev_dbg(&client->dev, "failed=%d\n", ret); in m88ds3103_diseqc_send_master_cmd()
1548 struct m88ds3103_dev *dev = fe->demodulator_priv; in m88ds3103_diseqc_send_burst()
1549 struct i2c_client *client = dev->client; in m88ds3103_diseqc_send_burst()
1554 dev_dbg(&client->dev, "fe_sec_mini_cmd=%d\n", fe_sec_mini_cmd); in m88ds3103_diseqc_send_burst()
1556 if (!dev->warm) { in m88ds3103_diseqc_send_burst()
1557 ret = -EAGAIN; in m88ds3103_diseqc_send_burst()
1561 utmp = dev->cfg->envelope_mode << 5; in m88ds3103_diseqc_send_burst()
1574 dev_dbg(&client->dev, "invalid fe_sec_mini_cmd\n"); in m88ds3103_diseqc_send_burst()
1575 ret = -EINVAL; in m88ds3103_diseqc_send_burst()
1579 ret = regmap_write(dev->regmap, 0xa1, burst); in m88ds3103_diseqc_send_burst()
1591 ret = regmap_read(dev->regmap, 0xa1, &utmp); in m88ds3103_diseqc_send_burst()
1598 dev_dbg(&client->dev, "diseqc tx took %u ms\n", in m88ds3103_diseqc_send_burst()
1599 jiffies_to_msecs(jiffies) - in m88ds3103_diseqc_send_burst()
1600 (jiffies_to_msecs(timeout) - SEND_BURST_TIMEOUT)); in m88ds3103_diseqc_send_burst()
1602 dev_dbg(&client->dev, "diseqc tx timeout\n"); in m88ds3103_diseqc_send_burst()
1614 ret = -ETIMEDOUT; in m88ds3103_diseqc_send_burst()
1620 dev_dbg(&client->dev, "failed=%d\n", ret); in m88ds3103_diseqc_send_burst()
1627 s->min_delay_ms = 3000; in m88ds3103_get_tune_settings()
1634 struct m88ds3103_dev *dev = fe->demodulator_priv; in m88ds3103_release()
1635 struct i2c_client *client = dev->client; in m88ds3103_release()
1643 struct i2c_client *client = dev->client; in m88ds3103_select()
1646 .addr = client->addr, in m88ds3103_select()
1653 ret = __i2c_transfer(client->adapter, &msg, 1); in m88ds3103_select()
1655 dev_warn(&client->dev, "i2c wr failed=%d\n", ret); in m88ds3103_select()
1657 ret = -EREMOTEIO; in m88ds3103_select()
1677 pdata.clk = cfg->clock; in m88ds3103_attach()
1678 pdata.i2c_wr_max = cfg->i2c_wr_max; in m88ds3103_attach()
1679 pdata.ts_mode = cfg->ts_mode; in m88ds3103_attach()
1680 pdata.ts_clk = cfg->ts_clk; in m88ds3103_attach()
1681 pdata.ts_clk_pol = cfg->ts_clk_pol; in m88ds3103_attach()
1682 pdata.spec_inv = cfg->spec_inv; in m88ds3103_attach()
1683 pdata.agc = cfg->agc; in m88ds3103_attach()
1684 pdata.agc_inv = cfg->agc_inv; in m88ds3103_attach()
1685 pdata.clk_out = cfg->clock_out; in m88ds3103_attach()
1686 pdata.envelope_mode = cfg->envelope_mode; in m88ds3103_attach()
1687 pdata.lnb_hv_pol = cfg->lnb_hv_pol; in m88ds3103_attach()
1688 pdata.lnb_en_pol = cfg->lnb_en_pol; in m88ds3103_attach()
1693 board_info.addr = cfg->i2c_addr; in m88ds3103_attach()
1753 dev_dbg(&client->dev, "\n"); in m88ds3103_get_dvb_frontend()
1755 return &dev->fe; in m88ds3103_get_dvb_frontend()
1762 dev_dbg(&client->dev, "\n"); in m88ds3103_get_i2c_adapter()
1764 return dev->muxc->adapter[0]; in m88ds3103_get_i2c_adapter()
1771 struct m88ds3103_platform_data *pdata = client->dev.platform_data; in m88ds3103_probe()
1777 ret = -ENOMEM; in m88ds3103_probe()
1781 dev->client = client; in m88ds3103_probe()
1782 dev->config.clock = pdata->clk; in m88ds3103_probe()
1783 dev->config.i2c_wr_max = pdata->i2c_wr_max; in m88ds3103_probe()
1784 dev->config.ts_mode = pdata->ts_mode; in m88ds3103_probe()
1785 dev->config.ts_clk = pdata->ts_clk * 1000; in m88ds3103_probe()
1786 dev->config.ts_clk_pol = pdata->ts_clk_pol; in m88ds3103_probe()
1787 dev->config.spec_inv = pdata->spec_inv; in m88ds3103_probe()
1788 dev->config.agc_inv = pdata->agc_inv; in m88ds3103_probe()
1789 dev->config.clock_out = pdata->clk_out; in m88ds3103_probe()
1790 dev->config.envelope_mode = pdata->envelope_mode; in m88ds3103_probe()
1791 dev->config.agc = pdata->agc; in m88ds3103_probe()
1792 dev->config.lnb_hv_pol = pdata->lnb_hv_pol; in m88ds3103_probe()
1793 dev->config.lnb_en_pol = pdata->lnb_en_pol; in m88ds3103_probe()
1794 dev->cfg = &dev->config; in m88ds3103_probe()
1796 dev->regmap_config.reg_bits = 8, in m88ds3103_probe()
1797 dev->regmap_config.val_bits = 8, in m88ds3103_probe()
1798 dev->regmap_config.lock_arg = dev, in m88ds3103_probe()
1799 dev->regmap = devm_regmap_init_i2c(client, &dev->regmap_config); in m88ds3103_probe()
1800 if (IS_ERR(dev->regmap)) { in m88ds3103_probe()
1801 ret = PTR_ERR(dev->regmap); in m88ds3103_probe()
1806 ret = regmap_read(dev->regmap, 0x00, &utmp); in m88ds3103_probe()
1810 dev->chip_id = utmp >> 1; in m88ds3103_probe()
1811 dev->chiptype = (u8)id->driver_data; in m88ds3103_probe()
1813 dev_dbg(&client->dev, "chip_id=%02x\n", dev->chip_id); in m88ds3103_probe()
1815 switch (dev->chip_id) { in m88ds3103_probe()
1820 ret = -ENODEV; in m88ds3103_probe()
1821 dev_err(&client->dev, "Unknown device. Chip_id=%02x\n", dev->chip_id); in m88ds3103_probe()
1825 switch (dev->cfg->clock_out) { in m88ds3103_probe()
1836 ret = -EINVAL; in m88ds3103_probe()
1840 if (!pdata->ts_clk) { in m88ds3103_probe()
1841 ret = -EINVAL; in m88ds3103_probe()
1847 if (dev->chip_id == M88RS6000_CHIP_ID) in m88ds3103_probe()
1850 ret = regmap_write(dev->regmap, 0x29, utmp); in m88ds3103_probe()
1866 dev->muxc = i2c_mux_alloc(client->adapter, &client->dev, 1, 0, 0, in m88ds3103_probe()
1868 if (!dev->muxc) { in m88ds3103_probe()
1869 ret = -ENOMEM; in m88ds3103_probe()
1872 dev->muxc->priv = dev; in m88ds3103_probe()
1873 ret = i2c_mux_add_adapter(dev->muxc, 0, 0, 0); in m88ds3103_probe()
1878 memcpy(&dev->fe.ops, &m88ds3103_ops, sizeof(struct dvb_frontend_ops)); in m88ds3103_probe()
1879 if (dev->chiptype == M88DS3103_CHIPTYPE_3103B) in m88ds3103_probe()
1880 strscpy(dev->fe.ops.info.name, "Montage Technology M88DS3103B", in m88ds3103_probe()
1881 sizeof(dev->fe.ops.info.name)); in m88ds3103_probe()
1882 else if (dev->chip_id == M88RS6000_CHIP_ID) in m88ds3103_probe()
1883 strscpy(dev->fe.ops.info.name, "Montage Technology M88RS6000", in m88ds3103_probe()
1884 sizeof(dev->fe.ops.info.name)); in m88ds3103_probe()
1885 if (!pdata->attach_in_use) in m88ds3103_probe()
1886 dev->fe.ops.release = NULL; in m88ds3103_probe()
1887 dev->fe.demodulator_priv = dev; in m88ds3103_probe()
1891 pdata->get_dvb_frontend = m88ds3103_get_dvb_frontend; in m88ds3103_probe()
1892 pdata->get_i2c_adapter = m88ds3103_get_i2c_adapter; in m88ds3103_probe()
1894 if (dev->chiptype == M88DS3103_CHIPTYPE_3103B) { in m88ds3103_probe()
1899 ret = regmap_read(dev->regmap, 0x29, &utmp); in m88ds3103_probe()
1902 dev->dt_addr = ((utmp & 0x80) == 0) ? 0x42 >> 1 : 0x40 >> 1; in m88ds3103_probe()
1903 dev_dbg(&client->dev, "dt addr is 0x%02x\n", dev->dt_addr); in m88ds3103_probe()
1905 dev->dt_client = i2c_new_dummy_device(client->adapter, in m88ds3103_probe()
1906 dev->dt_addr); in m88ds3103_probe()
1907 if (!dev->dt_client) { in m88ds3103_probe()
1908 ret = -ENODEV; in m88ds3103_probe()
1917 dev_dbg(&client->dev, "failed=%d\n", ret); in m88ds3103_probe()
1925 dev_dbg(&client->dev, "\n"); in m88ds3103_remove()
1927 if (dev->dt_client) in m88ds3103_remove()
1928 i2c_unregister_device(dev->dt_client); in m88ds3103_remove()
1930 i2c_mux_del_adapters(dev->muxc); in m88ds3103_remove()
1957 MODULE_DESCRIPTION("Montage Technology M88DS3103 DVB-S/S2 demodulator driver");