Lines Matching refs:ctx

38 #define mxm_dbg(ctx, fmt, arg...) dev_dbg(&ctx->client->dev, fmt, ## arg)  argument
39 #define mxm_err(ctx, fmt, arg...) dev_err(&ctx->client->dev, fmt, ## arg) argument
324 static int max2175_read(struct max2175 *ctx, u8 idx, u8 *val) in max2175_read() argument
329 ret = regmap_read(ctx->regmap, idx, &regval); in max2175_read()
331 mxm_err(ctx, "read ret(%d): idx 0x%02x\n", ret, idx); in max2175_read()
338 static int max2175_write(struct max2175 *ctx, u8 idx, u8 val) in max2175_write() argument
342 ret = regmap_write(ctx->regmap, idx, val); in max2175_write()
344 mxm_err(ctx, "write ret(%d): idx 0x%02x val 0x%02x\n", in max2175_write()
350 static u8 max2175_read_bits(struct max2175 *ctx, u8 idx, u8 msb, u8 lsb) in max2175_read_bits() argument
354 if (max2175_read(ctx, idx, &val)) in max2175_read_bits()
360 static int max2175_write_bits(struct max2175 *ctx, u8 idx, in max2175_write_bits() argument
363 int ret = regmap_update_bits(ctx->regmap, idx, GENMASK(msb, lsb), in max2175_write_bits()
367 mxm_err(ctx, "wbits ret(%d): idx 0x%02x\n", ret, idx); in max2175_write_bits()
372 static int max2175_write_bit(struct max2175 *ctx, u8 idx, u8 bit, u8 newval) in max2175_write_bit() argument
374 return max2175_write_bits(ctx, idx, bit, bit, newval); in max2175_write_bit()
378 static int max2175_poll_timeout(struct max2175 *ctx, u8 idx, u8 msb, u8 lsb, in max2175_poll_timeout() argument
383 return regmap_read_poll_timeout(ctx->regmap, idx, val, in max2175_poll_timeout()
388 static int max2175_poll_csm_ready(struct max2175 *ctx) in max2175_poll_csm_ready() argument
392 ret = max2175_poll_timeout(ctx, 69, 1, 1, 0, 50000); in max2175_poll_csm_ready()
394 mxm_err(ctx, "csm not ready\n"); in max2175_poll_csm_ready()
399 #define MAX2175_IS_BAND_AM(ctx) \ argument
400 (max2175_read_bits(ctx, 5, 1, 0) == MAX2175_BAND_AM)
402 #define MAX2175_IS_BAND_VHF(ctx) \ argument
403 (max2175_read_bits(ctx, 5, 1, 0) == MAX2175_BAND_VHF)
405 #define MAX2175_IS_FM_MODE(ctx) \ argument
406 (max2175_read_bits(ctx, 12, 5, 4) == 0)
408 #define MAX2175_IS_FMHD_MODE(ctx) \ argument
409 (max2175_read_bits(ctx, 12, 5, 4) == 1)
411 #define MAX2175_IS_DAB_MODE(ctx) \ argument
412 (max2175_read_bits(ctx, 12, 5, 4) == 2)
424 static void max2175_i2s_enable(struct max2175 *ctx, bool enable) in max2175_i2s_enable() argument
428 max2175_write_bits(ctx, 104, 3, 0, 2); in max2175_i2s_enable()
431 max2175_write_bits(ctx, 104, 3, 0, 9); in max2175_i2s_enable()
432 mxm_dbg(ctx, "i2s %sabled\n", enable ? "en" : "dis"); in max2175_i2s_enable()
435 static void max2175_set_filter_coeffs(struct max2175 *ctx, u8 m_sel, in max2175_set_filter_coeffs() argument
441 mxm_dbg(ctx, "set_filter_coeffs: m_sel %d bank %d\n", m_sel, bank); in max2175_set_filter_coeffs()
442 max2175_write_bits(ctx, 114, 5, 4, m_sel); in max2175_set_filter_coeffs()
449 max2175_write(ctx, 115, coeffs[i] >> 8); in max2175_set_filter_coeffs()
450 max2175_write(ctx, 116, coeffs[i]); in max2175_set_filter_coeffs()
451 max2175_write(ctx, 117, coeff_addr | 1 << 7); in max2175_set_filter_coeffs()
453 max2175_write_bit(ctx, 117, 7, 0); in max2175_set_filter_coeffs()
456 static void max2175_load_fmeu_1p2(struct max2175 *ctx) in max2175_load_fmeu_1p2() argument
461 max2175_write(ctx, fmeu1p2_map[i].idx, fmeu1p2_map[i].val); in max2175_load_fmeu_1p2()
463 ctx->decim_ratio = 36; in max2175_load_fmeu_1p2()
466 max2175_set_filter_coeffs(ctx, MAX2175_CH_MSEL, 0, ch_coeff_fmeu); in max2175_load_fmeu_1p2()
467 max2175_set_filter_coeffs(ctx, MAX2175_EQ_MSEL, 0, in max2175_load_fmeu_1p2()
471 static void max2175_load_dab_1p2(struct max2175 *ctx) in max2175_load_dab_1p2() argument
476 max2175_write(ctx, dab12_map[i].idx, dab12_map[i].val); in max2175_load_dab_1p2()
478 ctx->decim_ratio = 1; in max2175_load_dab_1p2()
481 max2175_set_filter_coeffs(ctx, MAX2175_CH_MSEL, 2, ch_coeff_dab1); in max2175_load_dab_1p2()
484 static void max2175_load_fmna_1p0(struct max2175 *ctx) in max2175_load_fmna_1p0() argument
489 max2175_write(ctx, fmna1p0_map[i].idx, fmna1p0_map[i].val); in max2175_load_fmna_1p0()
492 static void max2175_load_fmna_2p0(struct max2175 *ctx) in max2175_load_fmna_2p0() argument
497 max2175_write(ctx, fmna2p0_map[i].idx, fmna2p0_map[i].val); in max2175_load_fmna_2p0()
500 static void max2175_set_bbfilter(struct max2175 *ctx) in max2175_set_bbfilter() argument
502 if (MAX2175_IS_BAND_AM(ctx)) { in max2175_set_bbfilter()
503 max2175_write_bits(ctx, 12, 3, 0, ctx->rom_bbf_bw_am); in max2175_set_bbfilter()
504 mxm_dbg(ctx, "set_bbfilter AM: rom %d\n", ctx->rom_bbf_bw_am); in max2175_set_bbfilter()
505 } else if (MAX2175_IS_DAB_MODE(ctx)) { in max2175_set_bbfilter()
506 max2175_write_bits(ctx, 12, 3, 0, ctx->rom_bbf_bw_dab); in max2175_set_bbfilter()
507 mxm_dbg(ctx, "set_bbfilter DAB: rom %d\n", ctx->rom_bbf_bw_dab); in max2175_set_bbfilter()
509 max2175_write_bits(ctx, 12, 3, 0, ctx->rom_bbf_bw_fm); in max2175_set_bbfilter()
510 mxm_dbg(ctx, "set_bbfilter FM: rom %d\n", ctx->rom_bbf_bw_fm); in max2175_set_bbfilter()
514 static bool max2175_set_csm_mode(struct max2175 *ctx, in max2175_set_csm_mode() argument
517 int ret = max2175_poll_csm_ready(ctx); in max2175_set_csm_mode()
522 max2175_write_bits(ctx, 0, 2, 0, new_mode); in max2175_set_csm_mode()
523 mxm_dbg(ctx, "set csm new mode %d\n", new_mode); in max2175_set_csm_mode()
538 return max2175_poll_csm_ready(ctx); in max2175_set_csm_mode()
541 static int max2175_csm_action(struct max2175 *ctx, in max2175_csm_action() argument
546 mxm_dbg(ctx, "csm_action: %d\n", action); in max2175_csm_action()
549 ret = max2175_set_csm_mode(ctx, MAX2175_LOAD_TO_BUFFER); in max2175_csm_action()
553 return max2175_set_csm_mode(ctx, MAX2175_PRESET_TUNE); in max2175_csm_action()
556 static int max2175_set_lo_freq(struct max2175 *ctx, u32 lo_freq) in max2175_set_lo_freq() argument
563 band = max2175_read_bits(ctx, 5, 1, 0); in max2175_set_lo_freq()
601 int_desired = lo_freq / ctx->xtal_freq; in max2175_set_lo_freq()
602 frac_desired = div_u64((u64)(lo_freq % ctx->xtal_freq) << 20, in max2175_set_lo_freq()
603 ctx->xtal_freq); in max2175_set_lo_freq()
606 ret = max2175_poll_csm_ready(ctx); in max2175_set_lo_freq()
610 mxm_dbg(ctx, "lo_mult %u int %u frac %u\n", in max2175_set_lo_freq()
614 max2175_write(ctx, 1, int_desired); in max2175_set_lo_freq()
615 max2175_write_bits(ctx, 2, 3, 0, (frac_desired >> 16) & 0xf); in max2175_set_lo_freq()
616 max2175_write(ctx, 3, frac_desired >> 8); in max2175_set_lo_freq()
617 max2175_write(ctx, 4, frac_desired); in max2175_set_lo_freq()
618 max2175_write_bits(ctx, 5, 3, 2, loband_bits); in max2175_set_lo_freq()
619 max2175_write_bits(ctx, 6, 7, 6, vcodiv_bits); in max2175_set_lo_freq()
636 static int max2175_set_nco_freq(struct max2175 *ctx, s32 nco_freq) in max2175_set_nco_freq() argument
638 s32 clock_rate = ctx->xtal_freq / ctx->decim_ratio; in max2175_set_nco_freq()
657 ret = max2175_poll_csm_ready(ctx); in max2175_set_nco_freq()
661 mxm_dbg(ctx, "freq %d desired %lld reg %u\n", in max2175_set_nco_freq()
665 max2175_write_bits(ctx, 7, 4, 0, (nco_reg >> 16) & 0x1f); in max2175_set_nco_freq()
666 max2175_write(ctx, 8, nco_reg >> 8); in max2175_set_nco_freq()
667 max2175_write(ctx, 9, nco_reg); in max2175_set_nco_freq()
672 static int max2175_set_rf_freq_non_am_bands(struct max2175 *ctx, u64 freq, in max2175_set_rf_freq_non_am_bands() argument
678 mxm_dbg(ctx, "rf_freq: non AM bands\n"); in max2175_set_rf_freq_non_am_bands()
680 if (MAX2175_IS_FM_MODE(ctx)) in max2175_set_rf_freq_non_am_bands()
682 else if (MAX2175_IS_FMHD_MODE(ctx)) in max2175_set_rf_freq_non_am_bands()
685 return max2175_set_lo_freq(ctx, freq); in max2175_set_rf_freq_non_am_bands()
687 if (MAX2175_IS_BAND_VHF(ctx) == (lo_pos == MAX2175_LO_ABOVE_DESIRED)) in max2175_set_rf_freq_non_am_bands()
692 ret = max2175_set_lo_freq(ctx, adj_freq); in max2175_set_rf_freq_non_am_bands()
696 return max2175_set_nco_freq(ctx, -low_if_freq); in max2175_set_rf_freq_non_am_bands()
699 static int max2175_set_rf_freq(struct max2175 *ctx, u64 freq, u32 lo_pos) in max2175_set_rf_freq() argument
703 if (MAX2175_IS_BAND_AM(ctx)) in max2175_set_rf_freq()
704 ret = max2175_set_nco_freq(ctx, freq); in max2175_set_rf_freq()
706 ret = max2175_set_rf_freq_non_am_bands(ctx, freq, lo_pos); in max2175_set_rf_freq()
708 mxm_dbg(ctx, "set_rf_freq: ret %d freq %llu\n", ret, freq); in max2175_set_rf_freq()
713 static int max2175_tune_rf_freq(struct max2175 *ctx, u64 freq, u32 hsls) in max2175_tune_rf_freq() argument
717 ret = max2175_set_rf_freq(ctx, freq, hsls); in max2175_tune_rf_freq()
721 ret = max2175_csm_action(ctx, MAX2175_BUFFER_PLUS_PRESET_TUNE); in max2175_tune_rf_freq()
725 mxm_dbg(ctx, "tune_rf_freq: old %u new %llu\n", ctx->freq, freq); in max2175_tune_rf_freq()
726 ctx->freq = freq; in max2175_tune_rf_freq()
731 static void max2175_set_hsls(struct max2175 *ctx, u32 lo_pos) in max2175_set_hsls() argument
733 mxm_dbg(ctx, "set_hsls: lo_pos %u\n", lo_pos); in max2175_set_hsls()
735 if ((lo_pos == MAX2175_LO_BELOW_DESIRED) == MAX2175_IS_BAND_VHF(ctx)) in max2175_set_hsls()
736 max2175_write_bit(ctx, 5, 4, 1); in max2175_set_hsls()
738 max2175_write_bit(ctx, 5, 4, 0); in max2175_set_hsls()
741 static void max2175_set_eu_rx_mode(struct max2175 *ctx, u32 rx_mode) in max2175_set_eu_rx_mode() argument
745 max2175_load_fmeu_1p2(ctx); in max2175_set_eu_rx_mode()
749 max2175_load_dab_1p2(ctx); in max2175_set_eu_rx_mode()
753 if (!ctx->master) in max2175_set_eu_rx_mode()
754 max2175_write_bit(ctx, 30, 7, 1); in max2175_set_eu_rx_mode()
757 static void max2175_set_na_rx_mode(struct max2175 *ctx, u32 rx_mode) in max2175_set_na_rx_mode() argument
761 max2175_load_fmna_1p0(ctx); in max2175_set_na_rx_mode()
764 max2175_load_fmna_2p0(ctx); in max2175_set_na_rx_mode()
768 if (!ctx->master) in max2175_set_na_rx_mode()
769 max2175_write_bit(ctx, 30, 7, 1); in max2175_set_na_rx_mode()
771 ctx->decim_ratio = 27; in max2175_set_na_rx_mode()
774 max2175_set_filter_coeffs(ctx, MAX2175_CH_MSEL, 0, ch_coeff_fmna); in max2175_set_na_rx_mode()
775 max2175_set_filter_coeffs(ctx, MAX2175_EQ_MSEL, 0, in max2175_set_na_rx_mode()
779 static int max2175_set_rx_mode(struct max2175 *ctx, u32 rx_mode) in max2175_set_rx_mode() argument
781 mxm_dbg(ctx, "set_rx_mode: %u am_hiz %u\n", rx_mode, ctx->am_hiz); in max2175_set_rx_mode()
782 if (ctx->xtal_freq == MAX2175_EU_XTAL_FREQ) in max2175_set_rx_mode()
783 max2175_set_eu_rx_mode(ctx, rx_mode); in max2175_set_rx_mode()
785 max2175_set_na_rx_mode(ctx, rx_mode); in max2175_set_rx_mode()
787 if (ctx->am_hiz) { in max2175_set_rx_mode()
788 mxm_dbg(ctx, "setting AM HiZ related config\n"); in max2175_set_rx_mode()
789 max2175_write_bit(ctx, 50, 5, 1); in max2175_set_rx_mode()
790 max2175_write_bit(ctx, 90, 7, 1); in max2175_set_rx_mode()
791 max2175_write_bits(ctx, 73, 1, 0, 2); in max2175_set_rx_mode()
792 max2175_write_bits(ctx, 80, 5, 0, 33); in max2175_set_rx_mode()
796 max2175_set_bbfilter(ctx); in max2175_set_rx_mode()
799 max2175_set_hsls(ctx, ctx->hsls->cur.val); in max2175_set_rx_mode()
802 max2175_i2s_enable(ctx, ctx->i2s_en->cur.val); in max2175_set_rx_mode()
804 ctx->mode_resolved = true; in max2175_set_rx_mode()
809 static int max2175_rx_mode_from_freq(struct max2175 *ctx, u32 freq, u32 *mode) in max2175_rx_mode_from_freq() argument
815 for (i = 0; i <= ctx->rx_mode->maximum; i++) { in max2175_rx_mode_from_freq()
816 if (ctx->rx_modes[i].band == band) { in max2175_rx_mode_from_freq()
818 mxm_dbg(ctx, "rx_mode_from_freq: freq %u mode %d\n", in max2175_rx_mode_from_freq()
827 static bool max2175_freq_rx_mode_valid(struct max2175 *ctx, in max2175_freq_rx_mode_valid() argument
832 return (ctx->rx_modes[mode].band == band); in max2175_freq_rx_mode_valid()
835 static void max2175_load_adc_presets(struct max2175 *ctx) in max2175_load_adc_presets() argument
841 max2175_write(ctx, 146 + j + i * 55, adc_presets[i][j]); in max2175_load_adc_presets()
844 static int max2175_init_power_manager(struct max2175 *ctx) in max2175_init_power_manager() argument
849 max2175_write_bit(ctx, 99, 2, 0); in max2175_init_power_manager()
851 max2175_write_bit(ctx, 99, 2, 1); in max2175_init_power_manager()
854 ret = max2175_poll_timeout(ctx, 69, 7, 7, 1, 50000); in max2175_init_power_manager()
856 mxm_err(ctx, "init pm failed\n"); in max2175_init_power_manager()
861 static int max2175_recalibrate_adc(struct max2175 *ctx) in max2175_recalibrate_adc() argument
866 max2175_write(ctx, 150, 0xff); in max2175_recalibrate_adc()
867 max2175_write(ctx, 205, 0xff); in max2175_recalibrate_adc()
868 max2175_write(ctx, 147, 0x20); in max2175_recalibrate_adc()
869 max2175_write(ctx, 147, 0x00); in max2175_recalibrate_adc()
870 max2175_write(ctx, 202, 0x20); in max2175_recalibrate_adc()
871 max2175_write(ctx, 202, 0x00); in max2175_recalibrate_adc()
873 ret = max2175_poll_timeout(ctx, 69, 4, 3, 3, 50000); in max2175_recalibrate_adc()
875 mxm_err(ctx, "adc recalibration failed\n"); in max2175_recalibrate_adc()
880 static u8 max2175_read_rom(struct max2175 *ctx, u8 row) in max2175_read_rom() argument
884 max2175_write_bit(ctx, 56, 4, 0); in max2175_read_rom()
885 max2175_write_bits(ctx, 56, 3, 0, row); in max2175_read_rom()
888 max2175_read(ctx, 58, &data); in max2175_read_rom()
890 max2175_write_bits(ctx, 56, 3, 0, 0); in max2175_read_rom()
892 mxm_dbg(ctx, "read_rom: row %d data 0x%02x\n", row, data); in max2175_read_rom()
897 static void max2175_load_from_rom(struct max2175 *ctx) in max2175_load_from_rom() argument
901 data = max2175_read_rom(ctx, 0); in max2175_load_from_rom()
902 ctx->rom_bbf_bw_am = data & 0x0f; in max2175_load_from_rom()
903 max2175_write_bits(ctx, 81, 3, 0, data >> 4); in max2175_load_from_rom()
905 data = max2175_read_rom(ctx, 1); in max2175_load_from_rom()
906 ctx->rom_bbf_bw_fm = data & 0x0f; in max2175_load_from_rom()
907 ctx->rom_bbf_bw_dab = data >> 4; in max2175_load_from_rom()
909 data = max2175_read_rom(ctx, 2); in max2175_load_from_rom()
910 max2175_write_bits(ctx, 82, 4, 0, data & 0x1f); in max2175_load_from_rom()
911 max2175_write_bits(ctx, 82, 7, 5, data >> 5); in max2175_load_from_rom()
913 data = max2175_read_rom(ctx, 3); in max2175_load_from_rom()
914 if (ctx->am_hiz) { in max2175_load_from_rom()
916 data |= (max2175_read_rom(ctx, 7) & 0x40) >> 2; in max2175_load_from_rom()
921 data |= (max2175_read_rom(ctx, 7) & 0x80) >> 3; in max2175_load_from_rom()
925 max2175_write_bits(ctx, 80, 5, 0, data + 31); in max2175_load_from_rom()
927 data = max2175_read_rom(ctx, 6); in max2175_load_from_rom()
928 max2175_write_bits(ctx, 81, 7, 6, data >> 6); in max2175_load_from_rom()
931 static void max2175_load_full_fm_eu_1p0(struct max2175 *ctx) in max2175_load_full_fm_eu_1p0() argument
936 max2175_write(ctx, i + 1, full_fm_eu_1p0[i]); in max2175_load_full_fm_eu_1p0()
939 ctx->decim_ratio = 36; in max2175_load_full_fm_eu_1p0()
942 static void max2175_load_full_fm_na_1p0(struct max2175 *ctx) in max2175_load_full_fm_na_1p0() argument
947 max2175_write(ctx, i + 1, full_fm_na_1p0[i]); in max2175_load_full_fm_na_1p0()
950 ctx->decim_ratio = 27; in max2175_load_full_fm_na_1p0()
953 static int max2175_core_init(struct max2175 *ctx, u32 refout_bits) in max2175_core_init() argument
958 if (ctx->xtal_freq == MAX2175_EU_XTAL_FREQ) in max2175_core_init()
959 max2175_load_full_fm_eu_1p0(ctx); in max2175_core_init()
961 max2175_load_full_fm_na_1p0(ctx); in max2175_core_init()
964 if (!ctx->master) in max2175_core_init()
965 max2175_write_bit(ctx, 30, 7, 1); in max2175_core_init()
967 mxm_dbg(ctx, "refout_bits %u\n", refout_bits); in max2175_core_init()
970 max2175_write_bits(ctx, 56, 7, 5, refout_bits); in max2175_core_init()
973 max2175_write_bit(ctx, 99, 1, 0); in max2175_core_init()
975 max2175_write_bit(ctx, 99, 1, 1); in max2175_core_init()
978 max2175_load_adc_presets(ctx); in max2175_core_init()
981 ret = max2175_init_power_manager(ctx); in max2175_core_init()
986 ret = max2175_recalibrate_adc(ctx); in max2175_core_init()
991 max2175_load_from_rom(ctx); in max2175_core_init()
993 if (ctx->xtal_freq == MAX2175_EU_XTAL_FREQ) { in max2175_core_init()
995 max2175_set_filter_coeffs(ctx, MAX2175_CH_MSEL, 0, in max2175_core_init()
997 max2175_set_filter_coeffs(ctx, MAX2175_EQ_MSEL, 0, in max2175_core_init()
1001 max2175_set_filter_coeffs(ctx, MAX2175_CH_MSEL, 0, in max2175_core_init()
1003 max2175_set_filter_coeffs(ctx, MAX2175_EQ_MSEL, 0, in max2175_core_init()
1006 mxm_dbg(ctx, "core initialized\n"); in max2175_core_init()
1011 static void max2175_s_ctrl_rx_mode(struct max2175 *ctx, u32 rx_mode) in max2175_s_ctrl_rx_mode() argument
1014 max2175_set_rx_mode(ctx, rx_mode); in max2175_s_ctrl_rx_mode()
1016 mxm_dbg(ctx, "s_ctrl_rx_mode: %u curr freq %u\n", rx_mode, ctx->freq); in max2175_s_ctrl_rx_mode()
1019 if (max2175_freq_rx_mode_valid(ctx, rx_mode, ctx->freq)) in max2175_s_ctrl_rx_mode()
1020 max2175_tune_rf_freq(ctx, ctx->freq, ctx->hsls->cur.val); in max2175_s_ctrl_rx_mode()
1023 max2175_tune_rf_freq(ctx, ctx->rx_modes[rx_mode].freq, in max2175_s_ctrl_rx_mode()
1024 ctx->hsls->cur.val); in max2175_s_ctrl_rx_mode()
1029 struct max2175 *ctx = max2175_from_ctrl_hdl(ctrl->handler); in max2175_s_ctrl() local
1031 mxm_dbg(ctx, "s_ctrl: id 0x%x, val %u\n", ctrl->id, ctrl->val); in max2175_s_ctrl()
1034 max2175_i2s_enable(ctx, ctrl->val); in max2175_s_ctrl()
1037 max2175_set_hsls(ctx, ctrl->val); in max2175_s_ctrl()
1040 max2175_s_ctrl_rx_mode(ctx, ctrl->val); in max2175_s_ctrl()
1047 static u32 max2175_get_lna_gain(struct max2175 *ctx) in max2175_get_lna_gain() argument
1049 enum max2175_band band = max2175_read_bits(ctx, 5, 1, 0); in max2175_get_lna_gain()
1053 return max2175_read_bits(ctx, 51, 3, 0); in max2175_get_lna_gain()
1055 return max2175_read_bits(ctx, 50, 3, 0); in max2175_get_lna_gain()
1057 return max2175_read_bits(ctx, 52, 5, 0); in max2175_get_lna_gain()
1065 struct max2175 *ctx = max2175_from_ctrl_hdl(ctrl->handler); in max2175_g_volatile_ctrl() local
1069 ctrl->val = max2175_get_lna_gain(ctx); in max2175_g_volatile_ctrl()
1072 ctrl->val = max2175_read_bits(ctx, 49, 4, 0); in max2175_g_volatile_ctrl()
1075 ctrl->val = (max2175_read_bits(ctx, 60, 7, 6) == 3); in max2175_g_volatile_ctrl()
1082 static int max2175_set_freq_and_mode(struct max2175 *ctx, u32 freq) in max2175_set_freq_and_mode() argument
1088 ret = max2175_rx_mode_from_freq(ctx, freq, &rx_mode); in max2175_set_freq_and_mode()
1092 mxm_dbg(ctx, "set_freq_and_mode: freq %u rx_mode %d\n", freq, rx_mode); in max2175_set_freq_and_mode()
1095 max2175_set_rx_mode(ctx, rx_mode); in max2175_set_freq_and_mode()
1096 ctx->rx_mode->cur.val = rx_mode; in max2175_set_freq_and_mode()
1099 return max2175_tune_rf_freq(ctx, freq, ctx->hsls->cur.val); in max2175_set_freq_and_mode()
1105 struct max2175 *ctx = max2175_from_sd(sd); in max2175_s_frequency() local
1109 mxm_dbg(ctx, "s_freq: new %u curr %u, mode_resolved %d\n", in max2175_s_frequency()
1110 vf->frequency, ctx->freq, ctx->mode_resolved); in max2175_s_frequency()
1115 freq = clamp(vf->frequency, ctx->bands_rf->rangelow, in max2175_s_frequency()
1116 ctx->bands_rf->rangehigh); in max2175_s_frequency()
1119 if (ctx->mode_resolved && in max2175_s_frequency()
1120 max2175_freq_rx_mode_valid(ctx, ctx->rx_mode->cur.val, freq)) in max2175_s_frequency()
1121 ret = max2175_tune_rf_freq(ctx, freq, ctx->hsls->cur.val); in max2175_s_frequency()
1124 ret = max2175_set_freq_and_mode(ctx, freq); in max2175_s_frequency()
1126 mxm_dbg(ctx, "s_freq: ret %d curr %u mode_resolved %d mode %u\n", in max2175_s_frequency()
1127 ret, ctx->freq, ctx->mode_resolved, ctx->rx_mode->cur.val); in max2175_s_frequency()
1135 struct max2175 *ctx = max2175_from_sd(sd); in max2175_g_frequency() local
1143 vf->frequency = ctx->freq; in max2175_g_frequency()
1151 struct max2175 *ctx = max2175_from_sd(sd); in max2175_enum_freq_bands() local
1156 *band = *ctx->bands_rf; in max2175_enum_freq_bands()
1163 struct max2175 *ctx = max2175_from_sd(sd); in max2175_g_tuner() local
1171 vt->rangelow = ctx->bands_rf->rangelow; in max2175_g_tuner()
1172 vt->rangehigh = ctx->bands_rf->rangehigh; in max2175_g_tuner()
1292 struct max2175 *ctx; in max2175_probe() local
1333 ctx = devm_kzalloc(&client->dev, sizeof(*ctx), GFP_KERNEL); in max2175_probe()
1334 if (ctx == NULL) in max2175_probe()
1337 sd = &ctx->sd; in max2175_probe()
1338 ctx->master = master; in max2175_probe()
1339 ctx->am_hiz = am_hiz; in max2175_probe()
1340 ctx->mode_resolved = false; in max2175_probe()
1341 ctx->regmap = regmap; in max2175_probe()
1342 ctx->xtal_freq = clk_get_rate(clk); in max2175_probe()
1343 dev_info(&client->dev, "xtal freq %luHz\n", ctx->xtal_freq); in max2175_probe()
1346 ctx->client = client; in max2175_probe()
1351 hdl = &ctx->ctrl_hdl; in max2175_probe()
1356 ctx->lna_gain = v4l2_ctrl_new_std(hdl, &max2175_ctrl_ops, in max2175_probe()
1359 ctx->lna_gain->flags |= (V4L2_CTRL_FLAG_VOLATILE | in max2175_probe()
1361 ctx->if_gain = v4l2_ctrl_new_std(hdl, &max2175_ctrl_ops, in max2175_probe()
1364 ctx->if_gain->flags |= (V4L2_CTRL_FLAG_VOLATILE | in max2175_probe()
1366 ctx->pll_lock = v4l2_ctrl_new_std(hdl, &max2175_ctrl_ops, in max2175_probe()
1369 ctx->pll_lock->flags |= (V4L2_CTRL_FLAG_VOLATILE | in max2175_probe()
1371 ctx->i2s_en = v4l2_ctrl_new_custom(hdl, &max2175_i2s_en, NULL); in max2175_probe()
1372 ctx->hsls = v4l2_ctrl_new_custom(hdl, &max2175_hsls, NULL); in max2175_probe()
1374 if (ctx->xtal_freq == MAX2175_EU_XTAL_FREQ) { in max2175_probe()
1375 ctx->rx_mode = v4l2_ctrl_new_custom(hdl, in max2175_probe()
1377 ctx->rx_modes = eu_rx_modes; in max2175_probe()
1378 ctx->bands_rf = &eu_bands_rf; in max2175_probe()
1380 ctx->rx_mode = v4l2_ctrl_new_custom(hdl, in max2175_probe()
1382 ctx->rx_modes = na_rx_modes; in max2175_probe()
1383 ctx->bands_rf = &na_bands_rf; in max2175_probe()
1385 ctx->sd.ctrl_handler = &ctx->ctrl_hdl; in max2175_probe()
1388 ctx->freq = ctx->bands_rf->rangelow; in max2175_probe()
1398 ret = max2175_core_init(ctx, refout_bits); in max2175_probe()
1411 v4l2_ctrl_handler_free(&ctx->ctrl_hdl); in max2175_probe()
1419 struct max2175 *ctx = max2175_from_sd(sd); in max2175_remove() local
1421 v4l2_ctrl_handler_free(&ctx->ctrl_hdl); in max2175_remove()