Lines Matching +full:capacitance +full:- +full:to +full:- +full:digital
1 // SPDX-License-Identifier: GPL-2.0
13 #include <linux/i2c-mux.h>
38 .addr = dev->i2c_client->addr, in mxl692_i2c_write()
44 ret = i2c_transfer(dev->i2c_client->adapter, &msg, 1); in mxl692_i2c_write()
46 dev_dbg(&dev->i2c_client->dev, "i2c write error!\n"); in mxl692_i2c_write()
55 .addr = dev->i2c_client->addr, in mxl692_i2c_read()
61 ret = i2c_transfer(dev->i2c_client->adapter, &msg, 1); in mxl692_i2c_read()
63 dev_dbg(&dev->i2c_client->dev, "i2c read error!\n"); in mxl692_i2c_read()
129 /* no swapping - all get opcodes */ in mxl692_tx_swap()
189 /* no swapping - all set opcodes */ in mxl692_rx_swap()
223 status = -EINVAL; in mxl692_validate_fw_header()
230 if ((buf_len - 16) != temp >> 8) { in mxl692_validate_fw_header()
231 status = -EINVAL; in mxl692_validate_fw_header()
239 status = -EINVAL; in mxl692_validate_fw_header()
243 dev_dbg(&dev->i2c_client->dev, "failed\n"); in mxl692_validate_fw_header()
253 int payload_max = MXL_EAGLE_MAX_I2C_PACKET_SIZE - MXL_EAGLE_I2C_MHEADER_SIZE; in mxl692_write_fw_block()
281 status = -EREMOTEIO; in mxl692_write_fw_block()
286 total_len -= chunk_len; in mxl692_write_fw_block()
291 status = -EINVAL; in mxl692_write_fw_block()
295 dev_dbg(&dev->i2c_client->dev, "err %d\n", status); in mxl692_write_fw_block()
309 if (total_len > (MXL_EAGLE_MAX_I2C_PACKET_SIZE - MXL_EAGLE_I2C_MHEADER_SIZE)) in mxl692_memwrite()
310 dev_dbg(&dev->i2c_client->dev, "hrmph?\n"); in mxl692_memwrite()
326 status = -EREMOTEIO; in mxl692_memwrite()
332 dev_dbg(&dev->i2c_client->dev, "err %d\n", status); in mxl692_memwrite()
350 mutex_lock(&dev->i2c_lock); in mxl692_memread()
354 status = mxl692_i2c_read(dev, buffer, (u16)size) < 0 ? -EREMOTEIO : 0; in mxl692_memread()
360 status = -EREMOTEIO; in mxl692_memread()
363 mutex_unlock(&dev->i2c_lock); in mxl692_memread()
366 dev_dbg(&dev->i2c_client->dev, "err %d\n", status); in mxl692_memread()
389 if (total_len > (MXL_EAGLE_MAX_I2C_PACKET_SIZE - MXL_EAGLE_I2C_PHEADER_SIZE)) in mxl692_opwrite()
390 dev_dbg(&dev->i2c_client->dev, "hrmph?\n"); in mxl692_opwrite()
402 status = -EREMOTEIO; in mxl692_opwrite()
407 dev_dbg(&dev->i2c_client->dev, "opcode %s err %d\n", in mxl692_opwrite()
408 mxl692_opcode_string(tx_hdr->opcode), status); in mxl692_opwrite()
428 dev_dbg(&dev->i2c_client->dev, "ix=%d size=%d\n", ix, size); in mxl692_opread()
429 status = -EREMOTEIO; in mxl692_opread()
435 status = -EREMOTEIO; in mxl692_opread()
439 dev_dbg(&dev->i2c_client->dev, "err %d\n", status); in mxl692_opread()
457 mutex_lock(&dev->i2c_lock); in mxl692_i2c_writeread()
460 (MXL_EAGLE_MAX_I2C_PACKET_SIZE - MXL_EAGLE_I2C_PHEADER_SIZE)) { in mxl692_i2c_writeread()
461 status = -EINVAL; in mxl692_i2c_writeread()
466 tx_header->opcode = opcode; in mxl692_i2c_writeread()
467 tx_header->seqnum = dev->seqnum++; in mxl692_i2c_writeread()
468 tx_header->payload_size = tx_payload_size; in mxl692_i2c_writeread()
469 tx_header->checksum = 0; in mxl692_i2c_writeread()
471 if (dev->seqnum == 0) in mxl692_i2c_writeread()
472 dev->seqnum = 1; in mxl692_i2c_writeread()
479 tx_header->checksum = 0; in mxl692_i2c_writeread()
480 tx_header->checksum = mxl692_checksum(tx_buf, in mxl692_i2c_writeread()
483 convert_endian(4, (u8 *)&tx_header->checksum); /* cksum is big endian */ in mxl692_i2c_writeread()
489 status = -EREMOTEIO; in mxl692_i2c_writeread()
500 timeout--; in mxl692_i2c_writeread()
502 (rx_header->seqnum == 0) && in mxl692_i2c_writeread()
503 (rx_header->checksum == 0)); in mxl692_i2c_writeread()
506 dev_dbg(&dev->i2c_client->dev, "timeout=%d status=%d\n", in mxl692_i2c_writeread()
508 status = -ETIMEDOUT; in mxl692_i2c_writeread()
512 if (rx_header->status) { in mxl692_i2c_writeread()
513 dev_dbg(&dev->i2c_client->dev, "rx header status code: %d\n", rx_header->status); in mxl692_i2c_writeread()
514 status = -EREMOTEIO; in mxl692_i2c_writeread()
518 if (rx_header->seqnum != tx_header->seqnum || in mxl692_i2c_writeread()
519 rx_header->opcode != tx_header->opcode || in mxl692_i2c_writeread()
520 rx_header->payload_size != rx_payload_expected) { in mxl692_i2c_writeread()
521 dev_dbg(&dev->i2c_client->dev, "Something failed seq=%s opcode=%s pSize=%s\n", in mxl692_i2c_writeread()
522 rx_header->seqnum != tx_header->seqnum ? "X" : "0", in mxl692_i2c_writeread()
523 rx_header->opcode != tx_header->opcode ? "X" : "0", in mxl692_i2c_writeread()
524 rx_header->payload_size != rx_payload_expected ? "X" : "0"); in mxl692_i2c_writeread()
525 if (rx_header->payload_size != rx_payload_expected) in mxl692_i2c_writeread()
526 dev_dbg(&dev->i2c_client->dev, in mxl692_i2c_writeread()
527 "rx_header->payloadSize=%d rx_payload_expected=%d\n", in mxl692_i2c_writeread()
528 rx_header->payload_size, rx_payload_expected); in mxl692_i2c_writeread()
529 status = -EREMOTEIO; in mxl692_i2c_writeread()
533 resp_checksum = rx_header->checksum; in mxl692_i2c_writeread()
534 rx_header->checksum = 0; in mxl692_i2c_writeread()
537 MXL_EAGLE_HOST_MSG_HEADER_SIZE + rx_header->payload_size); in mxl692_i2c_writeread()
542 dev_dbg(&dev->i2c_client->dev, "rx checksum failure\n"); in mxl692_i2c_writeread()
543 status = -EREMOTEIO; in mxl692_i2c_writeread()
547 mxl692_rx_swap(rx_header->opcode, rx_buf); in mxl692_i2c_writeread()
549 if (rx_header->payload_size > 0) { in mxl692_i2c_writeread()
551 dev_dbg(&dev->i2c_client->dev, "no rx payload?!?\n"); in mxl692_i2c_writeread()
552 status = -EREMOTEIO; in mxl692_i2c_writeread()
556 rx_header->payload_size); in mxl692_i2c_writeread()
560 dev_dbg(&dev->i2c_client->dev, "err %d\n", status); in mxl692_i2c_writeread()
562 mutex_unlock(&dev->i2c_lock); in mxl692_i2c_writeread()
576 return -EINVAL; in mxl692_fwdownload()
578 mutex_lock(&dev->i2c_lock); in mxl692_fwdownload()
580 dev_dbg(&dev->i2c_client->dev, "\n"); in mxl692_fwdownload()
600 mutex_unlock(&dev->i2c_lock); in mxl692_fwdownload()
616 mutex_unlock(&dev->i2c_lock); in mxl692_fwdownload()
618 dev_dbg(&dev->i2c_client->dev, "err %d\n", status); in mxl692_fwdownload()
636 dev_info(&dev->i2c_client->dev, "MxL692_DEMOD Chip ID: %s\n", in mxl692_get_versions()
639 dev_info(&dev->i2c_client->dev, in mxl692_get_versions()
655 dev_dbg(&dev->i2c_client->dev, "\n"); in mxl692_reset()
667 if (dev_type != dev->device_type) in mxl692_reset()
672 dev_dbg(&dev->i2c_client->dev, "err %d\n", status); in mxl692_reset()
682 dev_dbg(&dev->i2c_client->dev, "\n"); in mxl692_config_regulators()
684 /* configure main regulator according to the power supply source */ in mxl692_config_regulators()
697 /* configure digital regulator to high current mode */ in mxl692_config_regulators()
708 dev_dbg(&dev->i2c_client->dev, "err %d\n", status); in mxl692_config_regulators()
718 dev_dbg(&dev->i2c_client->dev, "\n"); in mxl692_config_xtal()
724 /* set XTAL capacitance */ in mxl692_config_xtal()
726 reg_val |= dev_xtal->xtal_cap; in mxl692_config_xtal()
729 reg_val = dev_xtal->clk_out_enable ? (reg_val | 0x0100) : (reg_val & 0xFFFFFEFF); in mxl692_config_xtal()
736 reg_val = dev_xtal->clk_out_div_enable ? (reg_val | 0x0200) : (reg_val & 0xFFFFFDFF); in mxl692_config_xtal()
743 reg_val = dev_xtal->xtal_sharing_enable ? (reg_val | 0x010400) : (reg_val & 0xFFFEFBFF); in mxl692_config_xtal()
754 if (dev_xtal->xtal_calibration_enable) { in mxl692_config_xtal()
755 /* enable XTAL calibration and set XTAL amplitude to a higher value */ in mxl692_config_xtal()
824 dev_dbg(&dev->i2c_client->dev, "err %d\n", status); in mxl692_config_xtal()
834 dev_dbg(&dev->i2c_client->dev, "%s\n", in mxl692_powermode()
844 dev_dbg(&dev->i2c_client->dev, "err %d\n", status); in mxl692_powermode()
848 dev->power_mode = power_mode; in mxl692_powermode()
855 struct mxl692_dev *dev = fe->demodulator_priv; in mxl692_init()
856 struct i2c_client *client = dev->i2c_client; in mxl692_init()
857 struct dtv_frontend_properties *c = &fe->dtv_property_cache; in mxl692_init()
862 dev_dbg(&dev->i2c_client->dev, "\n"); in mxl692_init()
864 if (dev->init_done) in mxl692_init()
867 dev->seqnum = 1; in mxl692_init()
888 status = request_firmware(&firmware, MXL692_FIRMWARE, &client->dev); in mxl692_init()
890 dev_dbg(&dev->i2c_client->dev, "firmware missing? %s\n", in mxl692_init()
895 status = mxl692_fwdownload(dev, firmware->data, firmware->size); in mxl692_init()
905 dev->power_mode = MXL_EAGLE_POWER_MODE_SLEEP; in mxl692_init()
908 if (dev->power_mode != MXL_EAGLE_POWER_MODE_ACTIVE) { in mxl692_init()
916 /* Init stats here to indicate which stats are supported */ in mxl692_init()
917 c->cnr.len = 1; in mxl692_init()
918 c->cnr.stat[0].scale = FE_SCALE_NOT_AVAILABLE; in mxl692_init()
919 c->post_bit_error.len = 1; in mxl692_init()
920 c->post_bit_error.stat[0].scale = FE_SCALE_NOT_AVAILABLE; in mxl692_init()
921 c->post_bit_count.len = 1; in mxl692_init()
922 c->post_bit_count.stat[0].scale = FE_SCALE_NOT_AVAILABLE; in mxl692_init()
923 c->block_error.len = 1; in mxl692_init()
924 c->block_error.stat[0].scale = FE_SCALE_NOT_AVAILABLE; in mxl692_init()
926 dev->init_done = 1; in mxl692_init()
931 dev_dbg(&dev->i2c_client->dev, "err %d\n", status); in mxl692_init()
937 struct mxl692_dev *dev = fe->demodulator_priv; in mxl692_sleep()
939 if (dev->power_mode != MXL_EAGLE_POWER_MODE_SLEEP) in mxl692_sleep()
947 struct dtv_frontend_properties *p = &fe->dtv_property_cache; in mxl692_set_frontend()
948 struct mxl692_dev *dev = fe->demodulator_priv; in mxl692_set_frontend()
958 dev_dbg(&dev->i2c_client->dev, "\n"); in mxl692_set_frontend()
960 switch (p->modulation) { in mxl692_set_frontend()
971 return -EINVAL; in mxl692_set_frontend()
974 if (dev->current_frequency == p->frequency && dev->demod_type == demod_type) { in mxl692_set_frontend()
975 dev_dbg(&dev->i2c_client->dev, "already set up\n"); in mxl692_set_frontend()
979 dev->current_frequency = -1; in mxl692_set_frontend()
980 dev->demod_type = -1; in mxl692_set_frontend()
990 dev_dbg(&dev->i2c_client->dev, in mxl692_set_frontend()
1032 if (p->modulation == QAM_64) in mxl692_set_frontend()
1054 tuner_params.freq_hz = p->frequency; in mxl692_set_frontend()
1058 dev_dbg(&dev->i2c_client->dev, " Tuning Freq: %d %s\n", tuner_params.freq_hz, in mxl692_set_frontend()
1091 dev->demod_type = demod_type; in mxl692_set_frontend()
1092 dev->current_frequency = p->frequency; in mxl692_set_frontend()
1096 dev_dbg(&dev->i2c_client->dev, "err %d\n", status); in mxl692_set_frontend()
1103 struct dtv_frontend_properties *c = &fe->dtv_property_cache; in mxl692_get_frontend()
1105 p->modulation = c->modulation; in mxl692_get_frontend()
1106 p->frequency = c->frequency; in mxl692_get_frontend()
1113 struct mxl692_dev *dev = fe->demodulator_priv; in mxl692_read_snr()
1114 struct dtv_frontend_properties *c = &fe->dtv_property_cache; in mxl692_read_snr()
1118 enum MXL_EAGLE_DEMOD_TYPE_E demod_type = dev->demod_type; in mxl692_read_snr()
1123 dev_dbg(&dev->i2c_client->dev, "\n"); in mxl692_read_snr()
1137 *snr = (u16)(atsc_status->snr_db_tenths / 10); in mxl692_read_snr()
1138 c->cnr.stat[0].scale = FE_SCALE_DECIBEL; in mxl692_read_snr()
1139 c->cnr.stat[0].svalue = *snr; in mxl692_read_snr()
1150 *snr = (u16)(qam_status->snr_db_tenths / 10); in mxl692_read_snr()
1158 dev_dbg(&dev->i2c_client->dev, "err %d\n", mxl_status); in mxl692_read_snr()
1164 struct mxl692_dev *dev = fe->demodulator_priv; in mxl692_read_ber_ucb()
1165 struct dtv_frontend_properties *c = &fe->dtv_property_cache; in mxl692_read_ber_ucb()
1168 enum MXL_EAGLE_DEMOD_TYPE_E demod_type = dev->demod_type; in mxl692_read_ber_ucb()
1172 dev_dbg(&dev->i2c_client->dev, "\n"); in mxl692_read_ber_ucb()
1185 if (atsc_errors->error_packets == 0) in mxl692_read_ber_ucb()
1188 utmp = ((atsc_errors->error_bytes / atsc_errors->error_packets) * in mxl692_read_ber_ucb()
1189 atsc_errors->total_packets); in mxl692_read_ber_ucb()
1191 c->post_bit_error.stat[0].scale = FE_SCALE_COUNTER; in mxl692_read_ber_ucb()
1192 c->post_bit_error.stat[0].uvalue += atsc_errors->error_bytes; in mxl692_read_ber_ucb()
1193 c->post_bit_count.stat[0].scale = FE_SCALE_COUNTER; in mxl692_read_ber_ucb()
1194 c->post_bit_count.stat[0].uvalue += utmp; in mxl692_read_ber_ucb()
1196 c->block_error.stat[0].scale = FE_SCALE_COUNTER; in mxl692_read_ber_ucb()
1197 c->block_error.stat[0].uvalue += atsc_errors->error_packets; in mxl692_read_ber_ucb()
1199 dev_dbg(&dev->i2c_client->dev, "%llu %llu\n", in mxl692_read_ber_ucb()
1200 c->post_bit_count.stat[0].uvalue, c->block_error.stat[0].uvalue); in mxl692_read_ber_ucb()
1210 dev_dbg(&dev->i2c_client->dev, "err %d\n", mxl_status); in mxl692_read_ber_ucb()
1218 struct mxl692_dev *dev = fe->demodulator_priv; in mxl692_read_status()
1219 struct dtv_frontend_properties *c = &fe->dtv_property_cache; in mxl692_read_status()
1223 enum MXL_EAGLE_DEMOD_TYPE_E demod_type = dev->demod_type; in mxl692_read_status()
1227 dev_dbg(&dev->i2c_client->dev, "\n"); in mxl692_read_status()
1240 if (!mxl_status && atsc_status->atsc_lock) { in mxl692_read_status()
1247 c->cnr.stat[0].scale = FE_SCALE_DECIBEL; in mxl692_read_status()
1248 c->cnr.stat[0].svalue = atsc_status->snr_db_tenths / 10; in mxl692_read_status()
1258 if (!mxl_status && qam_status->qam_locked) { in mxl692_read_status()
1265 c->cnr.stat[0].scale = FE_SCALE_DECIBEL; in mxl692_read_status()
1266 c->cnr.stat[0].svalue = qam_status->snr_db_tenths / 10; in mxl692_read_status()
1276 c->cnr.len = 1; in mxl692_read_status()
1277 c->cnr.stat[0].scale = FE_SCALE_NOT_AVAILABLE; in mxl692_read_status()
1278 c->block_error.stat[0].scale = FE_SCALE_NOT_AVAILABLE; in mxl692_read_status()
1279 c->post_bit_error.stat[0].scale = FE_SCALE_NOT_AVAILABLE; in mxl692_read_status()
1280 c->post_bit_count.stat[0].scale = FE_SCALE_NOT_AVAILABLE; in mxl692_read_status()
1285 dev_dbg(&dev->i2c_client->dev, "err %d\n", mxl_status); in mxl692_read_status()
1295 .name = "MaxLinear MxL692 VSB tuner-demodulator",
1313 struct mxl692_config *config = client->dev.platform_data; in mxl692_probe()
1319 ret = -ENOMEM; in mxl692_probe()
1320 dev_dbg(&client->dev, "kzalloc() failed\n"); in mxl692_probe()
1324 memcpy(&dev->fe.ops, &mxl692_ops, sizeof(struct dvb_frontend_ops)); in mxl692_probe()
1325 dev->fe.demodulator_priv = dev; in mxl692_probe()
1326 dev->i2c_client = client; in mxl692_probe()
1327 *config->fe = &dev->fe; in mxl692_probe()
1328 mutex_init(&dev->i2c_lock); in mxl692_probe()
1331 dev_info(&client->dev, "MaxLinear mxl692 successfully attached\n"); in mxl692_probe()
1335 dev_dbg(&client->dev, "failed %d\n", ret); in mxl692_probe()
1336 return -ENODEV; in mxl692_probe()
1343 dev->fe.demodulator_priv = NULL; in mxl692_remove()