Lines Matching refs:ctx
30 #define mxm_dbg(ctx, fmt, arg...) dev_dbg(&ctx->client->dev, fmt, ## arg) argument
31 #define mxm_err(ctx, fmt, arg...) dev_err(&ctx->client->dev, fmt, ## arg) argument
316 static int max2175_read(struct max2175 *ctx, u8 idx, u8 *val) in max2175_read() argument
321 ret = regmap_read(ctx->regmap, idx, ®val); in max2175_read()
323 mxm_err(ctx, "read ret(%d): idx 0x%02x\n", ret, idx); in max2175_read()
330 static int max2175_write(struct max2175 *ctx, u8 idx, u8 val) in max2175_write() argument
334 ret = regmap_write(ctx->regmap, idx, val); in max2175_write()
336 mxm_err(ctx, "write ret(%d): idx 0x%02x val 0x%02x\n", in max2175_write()
342 static u8 max2175_read_bits(struct max2175 *ctx, u8 idx, u8 msb, u8 lsb) in max2175_read_bits() argument
346 if (max2175_read(ctx, idx, &val)) in max2175_read_bits()
352 static int max2175_write_bits(struct max2175 *ctx, u8 idx, in max2175_write_bits() argument
355 int ret = regmap_update_bits(ctx->regmap, idx, GENMASK(msb, lsb), in max2175_write_bits()
359 mxm_err(ctx, "wbits ret(%d): idx 0x%02x\n", ret, idx); in max2175_write_bits()
364 static int max2175_write_bit(struct max2175 *ctx, u8 idx, u8 bit, u8 newval) in max2175_write_bit() argument
366 return max2175_write_bits(ctx, idx, bit, bit, newval); in max2175_write_bit()
370 static int max2175_poll_timeout(struct max2175 *ctx, u8 idx, u8 msb, u8 lsb, in max2175_poll_timeout() argument
375 return regmap_read_poll_timeout(ctx->regmap, idx, val, in max2175_poll_timeout()
380 static int max2175_poll_csm_ready(struct max2175 *ctx) in max2175_poll_csm_ready() argument
384 ret = max2175_poll_timeout(ctx, 69, 1, 1, 0, 50000); in max2175_poll_csm_ready()
386 mxm_err(ctx, "csm not ready\n"); in max2175_poll_csm_ready()
391 #define MAX2175_IS_BAND_AM(ctx) \ argument
392 (max2175_read_bits(ctx, 5, 1, 0) == MAX2175_BAND_AM)
394 #define MAX2175_IS_BAND_VHF(ctx) \ argument
395 (max2175_read_bits(ctx, 5, 1, 0) == MAX2175_BAND_VHF)
397 #define MAX2175_IS_FM_MODE(ctx) \ argument
398 (max2175_read_bits(ctx, 12, 5, 4) == 0)
400 #define MAX2175_IS_FMHD_MODE(ctx) \ argument
401 (max2175_read_bits(ctx, 12, 5, 4) == 1)
403 #define MAX2175_IS_DAB_MODE(ctx) \ argument
404 (max2175_read_bits(ctx, 12, 5, 4) == 2)
416 static void max2175_i2s_enable(struct max2175 *ctx, bool enable) in max2175_i2s_enable() argument
420 max2175_write_bits(ctx, 104, 3, 0, 2); in max2175_i2s_enable()
423 max2175_write_bits(ctx, 104, 3, 0, 9); in max2175_i2s_enable()
424 mxm_dbg(ctx, "i2s %sabled\n", enable ? "en" : "dis"); in max2175_i2s_enable()
427 static void max2175_set_filter_coeffs(struct max2175 *ctx, u8 m_sel, in max2175_set_filter_coeffs() argument
433 mxm_dbg(ctx, "set_filter_coeffs: m_sel %d bank %d\n", m_sel, bank); in max2175_set_filter_coeffs()
434 max2175_write_bits(ctx, 114, 5, 4, m_sel); in max2175_set_filter_coeffs()
441 max2175_write(ctx, 115, coeffs[i] >> 8); in max2175_set_filter_coeffs()
442 max2175_write(ctx, 116, coeffs[i]); in max2175_set_filter_coeffs()
443 max2175_write(ctx, 117, coeff_addr | 1 << 7); in max2175_set_filter_coeffs()
445 max2175_write_bit(ctx, 117, 7, 0); in max2175_set_filter_coeffs()
448 static void max2175_load_fmeu_1p2(struct max2175 *ctx) in max2175_load_fmeu_1p2() argument
453 max2175_write(ctx, fmeu1p2_map[i].idx, fmeu1p2_map[i].val); in max2175_load_fmeu_1p2()
455 ctx->decim_ratio = 36; in max2175_load_fmeu_1p2()
458 max2175_set_filter_coeffs(ctx, MAX2175_CH_MSEL, 0, ch_coeff_fmeu); in max2175_load_fmeu_1p2()
459 max2175_set_filter_coeffs(ctx, MAX2175_EQ_MSEL, 0, in max2175_load_fmeu_1p2()
463 static void max2175_load_dab_1p2(struct max2175 *ctx) in max2175_load_dab_1p2() argument
468 max2175_write(ctx, dab12_map[i].idx, dab12_map[i].val); in max2175_load_dab_1p2()
470 ctx->decim_ratio = 1; in max2175_load_dab_1p2()
473 max2175_set_filter_coeffs(ctx, MAX2175_CH_MSEL, 2, ch_coeff_dab1); in max2175_load_dab_1p2()
476 static void max2175_load_fmna_1p0(struct max2175 *ctx) in max2175_load_fmna_1p0() argument
481 max2175_write(ctx, fmna1p0_map[i].idx, fmna1p0_map[i].val); in max2175_load_fmna_1p0()
484 static void max2175_load_fmna_2p0(struct max2175 *ctx) in max2175_load_fmna_2p0() argument
489 max2175_write(ctx, fmna2p0_map[i].idx, fmna2p0_map[i].val); in max2175_load_fmna_2p0()
492 static void max2175_set_bbfilter(struct max2175 *ctx) in max2175_set_bbfilter() argument
494 if (MAX2175_IS_BAND_AM(ctx)) { in max2175_set_bbfilter()
495 max2175_write_bits(ctx, 12, 3, 0, ctx->rom_bbf_bw_am); in max2175_set_bbfilter()
496 mxm_dbg(ctx, "set_bbfilter AM: rom %d\n", ctx->rom_bbf_bw_am); in max2175_set_bbfilter()
497 } else if (MAX2175_IS_DAB_MODE(ctx)) { in max2175_set_bbfilter()
498 max2175_write_bits(ctx, 12, 3, 0, ctx->rom_bbf_bw_dab); in max2175_set_bbfilter()
499 mxm_dbg(ctx, "set_bbfilter DAB: rom %d\n", ctx->rom_bbf_bw_dab); in max2175_set_bbfilter()
501 max2175_write_bits(ctx, 12, 3, 0, ctx->rom_bbf_bw_fm); in max2175_set_bbfilter()
502 mxm_dbg(ctx, "set_bbfilter FM: rom %d\n", ctx->rom_bbf_bw_fm); in max2175_set_bbfilter()
506 static int max2175_set_csm_mode(struct max2175 *ctx, in max2175_set_csm_mode() argument
509 int ret = max2175_poll_csm_ready(ctx); in max2175_set_csm_mode()
514 max2175_write_bits(ctx, 0, 2, 0, new_mode); in max2175_set_csm_mode()
515 mxm_dbg(ctx, "set csm new mode %d\n", new_mode); in max2175_set_csm_mode()
530 return max2175_poll_csm_ready(ctx); in max2175_set_csm_mode()
533 static int max2175_csm_action(struct max2175 *ctx, in max2175_csm_action() argument
538 mxm_dbg(ctx, "csm_action: %d\n", action); in max2175_csm_action()
541 ret = max2175_set_csm_mode(ctx, MAX2175_LOAD_TO_BUFFER); in max2175_csm_action()
545 return max2175_set_csm_mode(ctx, MAX2175_PRESET_TUNE); in max2175_csm_action()
548 static int max2175_set_lo_freq(struct max2175 *ctx, u32 lo_freq) in max2175_set_lo_freq() argument
555 band = max2175_read_bits(ctx, 5, 1, 0); in max2175_set_lo_freq()
593 int_desired = lo_freq / ctx->xtal_freq; in max2175_set_lo_freq()
594 frac_desired = div64_ul((u64)(lo_freq % ctx->xtal_freq) << 20, in max2175_set_lo_freq()
595 ctx->xtal_freq); in max2175_set_lo_freq()
598 ret = max2175_poll_csm_ready(ctx); in max2175_set_lo_freq()
602 mxm_dbg(ctx, "lo_mult %u int %u frac %u\n", in max2175_set_lo_freq()
606 max2175_write(ctx, 1, int_desired); in max2175_set_lo_freq()
607 max2175_write_bits(ctx, 2, 3, 0, (frac_desired >> 16) & 0xf); in max2175_set_lo_freq()
608 max2175_write(ctx, 3, frac_desired >> 8); in max2175_set_lo_freq()
609 max2175_write(ctx, 4, frac_desired); in max2175_set_lo_freq()
610 max2175_write_bits(ctx, 5, 3, 2, loband_bits); in max2175_set_lo_freq()
611 max2175_write_bits(ctx, 6, 7, 6, vcodiv_bits); in max2175_set_lo_freq()
628 static int max2175_set_nco_freq(struct max2175 *ctx, s32 nco_freq) in max2175_set_nco_freq() argument
630 s32 clock_rate = ctx->xtal_freq / ctx->decim_ratio; in max2175_set_nco_freq()
649 ret = max2175_poll_csm_ready(ctx); in max2175_set_nco_freq()
653 mxm_dbg(ctx, "freq %d desired %lld reg %u\n", in max2175_set_nco_freq()
657 max2175_write_bits(ctx, 7, 4, 0, (nco_reg >> 16) & 0x1f); in max2175_set_nco_freq()
658 max2175_write(ctx, 8, nco_reg >> 8); in max2175_set_nco_freq()
659 max2175_write(ctx, 9, nco_reg); in max2175_set_nco_freq()
664 static int max2175_set_rf_freq_non_am_bands(struct max2175 *ctx, u64 freq, in max2175_set_rf_freq_non_am_bands() argument
670 mxm_dbg(ctx, "rf_freq: non AM bands\n"); in max2175_set_rf_freq_non_am_bands()
672 if (MAX2175_IS_FM_MODE(ctx)) in max2175_set_rf_freq_non_am_bands()
674 else if (MAX2175_IS_FMHD_MODE(ctx)) in max2175_set_rf_freq_non_am_bands()
677 return max2175_set_lo_freq(ctx, freq); in max2175_set_rf_freq_non_am_bands()
679 if (MAX2175_IS_BAND_VHF(ctx) == (lo_pos == MAX2175_LO_ABOVE_DESIRED)) in max2175_set_rf_freq_non_am_bands()
684 ret = max2175_set_lo_freq(ctx, adj_freq); in max2175_set_rf_freq_non_am_bands()
688 return max2175_set_nco_freq(ctx, -low_if_freq); in max2175_set_rf_freq_non_am_bands()
691 static int max2175_set_rf_freq(struct max2175 *ctx, u64 freq, u32 lo_pos) in max2175_set_rf_freq() argument
695 if (MAX2175_IS_BAND_AM(ctx)) in max2175_set_rf_freq()
696 ret = max2175_set_nco_freq(ctx, freq); in max2175_set_rf_freq()
698 ret = max2175_set_rf_freq_non_am_bands(ctx, freq, lo_pos); in max2175_set_rf_freq()
700 mxm_dbg(ctx, "set_rf_freq: ret %d freq %llu\n", ret, freq); in max2175_set_rf_freq()
705 static int max2175_tune_rf_freq(struct max2175 *ctx, u64 freq, u32 hsls) in max2175_tune_rf_freq() argument
709 ret = max2175_set_rf_freq(ctx, freq, hsls); in max2175_tune_rf_freq()
713 ret = max2175_csm_action(ctx, MAX2175_BUFFER_PLUS_PRESET_TUNE); in max2175_tune_rf_freq()
717 mxm_dbg(ctx, "tune_rf_freq: old %u new %llu\n", ctx->freq, freq); in max2175_tune_rf_freq()
718 ctx->freq = freq; in max2175_tune_rf_freq()
723 static void max2175_set_hsls(struct max2175 *ctx, u32 lo_pos) in max2175_set_hsls() argument
725 mxm_dbg(ctx, "set_hsls: lo_pos %u\n", lo_pos); in max2175_set_hsls()
727 if ((lo_pos == MAX2175_LO_BELOW_DESIRED) == MAX2175_IS_BAND_VHF(ctx)) in max2175_set_hsls()
728 max2175_write_bit(ctx, 5, 4, 1); in max2175_set_hsls()
730 max2175_write_bit(ctx, 5, 4, 0); in max2175_set_hsls()
733 static void max2175_set_eu_rx_mode(struct max2175 *ctx, u32 rx_mode) in max2175_set_eu_rx_mode() argument
737 max2175_load_fmeu_1p2(ctx); in max2175_set_eu_rx_mode()
741 max2175_load_dab_1p2(ctx); in max2175_set_eu_rx_mode()
745 if (!ctx->master) in max2175_set_eu_rx_mode()
746 max2175_write_bit(ctx, 30, 7, 1); in max2175_set_eu_rx_mode()
749 static void max2175_set_na_rx_mode(struct max2175 *ctx, u32 rx_mode) in max2175_set_na_rx_mode() argument
753 max2175_load_fmna_1p0(ctx); in max2175_set_na_rx_mode()
756 max2175_load_fmna_2p0(ctx); in max2175_set_na_rx_mode()
760 if (!ctx->master) in max2175_set_na_rx_mode()
761 max2175_write_bit(ctx, 30, 7, 1); in max2175_set_na_rx_mode()
763 ctx->decim_ratio = 27; in max2175_set_na_rx_mode()
766 max2175_set_filter_coeffs(ctx, MAX2175_CH_MSEL, 0, ch_coeff_fmna); in max2175_set_na_rx_mode()
767 max2175_set_filter_coeffs(ctx, MAX2175_EQ_MSEL, 0, in max2175_set_na_rx_mode()
771 static int max2175_set_rx_mode(struct max2175 *ctx, u32 rx_mode) in max2175_set_rx_mode() argument
773 mxm_dbg(ctx, "set_rx_mode: %u am_hiz %u\n", rx_mode, ctx->am_hiz); in max2175_set_rx_mode()
774 if (ctx->xtal_freq == MAX2175_EU_XTAL_FREQ) in max2175_set_rx_mode()
775 max2175_set_eu_rx_mode(ctx, rx_mode); in max2175_set_rx_mode()
777 max2175_set_na_rx_mode(ctx, rx_mode); in max2175_set_rx_mode()
779 if (ctx->am_hiz) { in max2175_set_rx_mode()
780 mxm_dbg(ctx, "setting AM HiZ related config\n"); in max2175_set_rx_mode()
781 max2175_write_bit(ctx, 50, 5, 1); in max2175_set_rx_mode()
782 max2175_write_bit(ctx, 90, 7, 1); in max2175_set_rx_mode()
783 max2175_write_bits(ctx, 73, 1, 0, 2); in max2175_set_rx_mode()
784 max2175_write_bits(ctx, 80, 5, 0, 33); in max2175_set_rx_mode()
788 max2175_set_bbfilter(ctx); in max2175_set_rx_mode()
791 max2175_set_hsls(ctx, ctx->hsls->cur.val); in max2175_set_rx_mode()
794 max2175_i2s_enable(ctx, ctx->i2s_en->cur.val); in max2175_set_rx_mode()
796 ctx->mode_resolved = true; in max2175_set_rx_mode()
801 static int max2175_rx_mode_from_freq(struct max2175 *ctx, u32 freq, u32 *mode) in max2175_rx_mode_from_freq() argument
807 for (i = 0; i <= ctx->rx_mode->maximum; i++) { in max2175_rx_mode_from_freq()
808 if (ctx->rx_modes[i].band == band) { in max2175_rx_mode_from_freq()
810 mxm_dbg(ctx, "rx_mode_from_freq: freq %u mode %d\n", in max2175_rx_mode_from_freq()
819 static bool max2175_freq_rx_mode_valid(struct max2175 *ctx, in max2175_freq_rx_mode_valid() argument
824 return (ctx->rx_modes[mode].band == band); in max2175_freq_rx_mode_valid()
827 static void max2175_load_adc_presets(struct max2175 *ctx) in max2175_load_adc_presets() argument
833 max2175_write(ctx, 146 + j + i * 55, adc_presets[i][j]); in max2175_load_adc_presets()
836 static int max2175_init_power_manager(struct max2175 *ctx) in max2175_init_power_manager() argument
841 max2175_write_bit(ctx, 99, 2, 0); in max2175_init_power_manager()
843 max2175_write_bit(ctx, 99, 2, 1); in max2175_init_power_manager()
846 ret = max2175_poll_timeout(ctx, 69, 7, 7, 1, 50000); in max2175_init_power_manager()
848 mxm_err(ctx, "init pm failed\n"); in max2175_init_power_manager()
853 static int max2175_recalibrate_adc(struct max2175 *ctx) in max2175_recalibrate_adc() argument
858 max2175_write(ctx, 150, 0xff); in max2175_recalibrate_adc()
859 max2175_write(ctx, 205, 0xff); in max2175_recalibrate_adc()
860 max2175_write(ctx, 147, 0x20); in max2175_recalibrate_adc()
861 max2175_write(ctx, 147, 0x00); in max2175_recalibrate_adc()
862 max2175_write(ctx, 202, 0x20); in max2175_recalibrate_adc()
863 max2175_write(ctx, 202, 0x00); in max2175_recalibrate_adc()
865 ret = max2175_poll_timeout(ctx, 69, 4, 3, 3, 50000); in max2175_recalibrate_adc()
867 mxm_err(ctx, "adc recalibration failed\n"); in max2175_recalibrate_adc()
872 static u8 max2175_read_rom(struct max2175 *ctx, u8 row) in max2175_read_rom() argument
876 max2175_write_bit(ctx, 56, 4, 0); in max2175_read_rom()
877 max2175_write_bits(ctx, 56, 3, 0, row); in max2175_read_rom()
880 max2175_read(ctx, 58, &data); in max2175_read_rom()
882 max2175_write_bits(ctx, 56, 3, 0, 0); in max2175_read_rom()
884 mxm_dbg(ctx, "read_rom: row %d data 0x%02x\n", row, data); in max2175_read_rom()
889 static void max2175_load_from_rom(struct max2175 *ctx) in max2175_load_from_rom() argument
893 data = max2175_read_rom(ctx, 0); in max2175_load_from_rom()
894 ctx->rom_bbf_bw_am = data & 0x0f; in max2175_load_from_rom()
895 max2175_write_bits(ctx, 81, 3, 0, data >> 4); in max2175_load_from_rom()
897 data = max2175_read_rom(ctx, 1); in max2175_load_from_rom()
898 ctx->rom_bbf_bw_fm = data & 0x0f; in max2175_load_from_rom()
899 ctx->rom_bbf_bw_dab = data >> 4; in max2175_load_from_rom()
901 data = max2175_read_rom(ctx, 2); in max2175_load_from_rom()
902 max2175_write_bits(ctx, 82, 4, 0, data & 0x1f); in max2175_load_from_rom()
903 max2175_write_bits(ctx, 82, 7, 5, data >> 5); in max2175_load_from_rom()
905 data = max2175_read_rom(ctx, 3); in max2175_load_from_rom()
906 if (ctx->am_hiz) { in max2175_load_from_rom()
908 data |= (max2175_read_rom(ctx, 7) & 0x40) >> 2; in max2175_load_from_rom()
913 data |= (max2175_read_rom(ctx, 7) & 0x80) >> 3; in max2175_load_from_rom()
917 max2175_write_bits(ctx, 80, 5, 0, data + 31); in max2175_load_from_rom()
919 data = max2175_read_rom(ctx, 6); in max2175_load_from_rom()
920 max2175_write_bits(ctx, 81, 7, 6, data >> 6); in max2175_load_from_rom()
923 static void max2175_load_full_fm_eu_1p0(struct max2175 *ctx) in max2175_load_full_fm_eu_1p0() argument
928 max2175_write(ctx, i + 1, full_fm_eu_1p0[i]); in max2175_load_full_fm_eu_1p0()
931 ctx->decim_ratio = 36; in max2175_load_full_fm_eu_1p0()
934 static void max2175_load_full_fm_na_1p0(struct max2175 *ctx) in max2175_load_full_fm_na_1p0() argument
939 max2175_write(ctx, i + 1, full_fm_na_1p0[i]); in max2175_load_full_fm_na_1p0()
942 ctx->decim_ratio = 27; in max2175_load_full_fm_na_1p0()
945 static int max2175_core_init(struct max2175 *ctx, u32 refout_bits) in max2175_core_init() argument
950 if (ctx->xtal_freq == MAX2175_EU_XTAL_FREQ) in max2175_core_init()
951 max2175_load_full_fm_eu_1p0(ctx); in max2175_core_init()
953 max2175_load_full_fm_na_1p0(ctx); in max2175_core_init()
956 if (!ctx->master) in max2175_core_init()
957 max2175_write_bit(ctx, 30, 7, 1); in max2175_core_init()
959 mxm_dbg(ctx, "refout_bits %u\n", refout_bits); in max2175_core_init()
962 max2175_write_bits(ctx, 56, 7, 5, refout_bits); in max2175_core_init()
965 max2175_write_bit(ctx, 99, 1, 0); in max2175_core_init()
967 max2175_write_bit(ctx, 99, 1, 1); in max2175_core_init()
970 max2175_load_adc_presets(ctx); in max2175_core_init()
973 ret = max2175_init_power_manager(ctx); in max2175_core_init()
978 ret = max2175_recalibrate_adc(ctx); in max2175_core_init()
983 max2175_load_from_rom(ctx); in max2175_core_init()
985 if (ctx->xtal_freq == MAX2175_EU_XTAL_FREQ) { in max2175_core_init()
987 max2175_set_filter_coeffs(ctx, MAX2175_CH_MSEL, 0, in max2175_core_init()
989 max2175_set_filter_coeffs(ctx, MAX2175_EQ_MSEL, 0, in max2175_core_init()
993 max2175_set_filter_coeffs(ctx, MAX2175_CH_MSEL, 0, in max2175_core_init()
995 max2175_set_filter_coeffs(ctx, MAX2175_EQ_MSEL, 0, in max2175_core_init()
998 mxm_dbg(ctx, "core initialized\n"); in max2175_core_init()
1003 static void max2175_s_ctrl_rx_mode(struct max2175 *ctx, u32 rx_mode) in max2175_s_ctrl_rx_mode() argument
1006 max2175_set_rx_mode(ctx, rx_mode); in max2175_s_ctrl_rx_mode()
1008 mxm_dbg(ctx, "s_ctrl_rx_mode: %u curr freq %u\n", rx_mode, ctx->freq); in max2175_s_ctrl_rx_mode()
1011 if (max2175_freq_rx_mode_valid(ctx, rx_mode, ctx->freq)) in max2175_s_ctrl_rx_mode()
1012 max2175_tune_rf_freq(ctx, ctx->freq, ctx->hsls->cur.val); in max2175_s_ctrl_rx_mode()
1015 max2175_tune_rf_freq(ctx, ctx->rx_modes[rx_mode].freq, in max2175_s_ctrl_rx_mode()
1016 ctx->hsls->cur.val); in max2175_s_ctrl_rx_mode()
1021 struct max2175 *ctx = max2175_from_ctrl_hdl(ctrl->handler); in max2175_s_ctrl() local
1023 mxm_dbg(ctx, "s_ctrl: id 0x%x, val %u\n", ctrl->id, ctrl->val); in max2175_s_ctrl()
1026 max2175_i2s_enable(ctx, ctrl->val); in max2175_s_ctrl()
1029 max2175_set_hsls(ctx, ctrl->val); in max2175_s_ctrl()
1032 max2175_s_ctrl_rx_mode(ctx, ctrl->val); in max2175_s_ctrl()
1039 static u32 max2175_get_lna_gain(struct max2175 *ctx) in max2175_get_lna_gain() argument
1041 enum max2175_band band = max2175_read_bits(ctx, 5, 1, 0); in max2175_get_lna_gain()
1045 return max2175_read_bits(ctx, 51, 3, 0); in max2175_get_lna_gain()
1047 return max2175_read_bits(ctx, 50, 3, 0); in max2175_get_lna_gain()
1049 return max2175_read_bits(ctx, 52, 5, 0); in max2175_get_lna_gain()
1057 struct max2175 *ctx = max2175_from_ctrl_hdl(ctrl->handler); in max2175_g_volatile_ctrl() local
1061 ctrl->val = max2175_get_lna_gain(ctx); in max2175_g_volatile_ctrl()
1064 ctrl->val = max2175_read_bits(ctx, 49, 4, 0); in max2175_g_volatile_ctrl()
1067 ctrl->val = (max2175_read_bits(ctx, 60, 7, 6) == 3); in max2175_g_volatile_ctrl()
1074 static int max2175_set_freq_and_mode(struct max2175 *ctx, u32 freq) in max2175_set_freq_and_mode() argument
1080 ret = max2175_rx_mode_from_freq(ctx, freq, &rx_mode); in max2175_set_freq_and_mode()
1084 mxm_dbg(ctx, "set_freq_and_mode: freq %u rx_mode %d\n", freq, rx_mode); in max2175_set_freq_and_mode()
1087 max2175_set_rx_mode(ctx, rx_mode); in max2175_set_freq_and_mode()
1088 ctx->rx_mode->cur.val = rx_mode; in max2175_set_freq_and_mode()
1091 return max2175_tune_rf_freq(ctx, freq, ctx->hsls->cur.val); in max2175_set_freq_and_mode()
1097 struct max2175 *ctx = max2175_from_sd(sd); in max2175_s_frequency() local
1101 mxm_dbg(ctx, "s_freq: new %u curr %u, mode_resolved %d\n", in max2175_s_frequency()
1102 vf->frequency, ctx->freq, ctx->mode_resolved); in max2175_s_frequency()
1107 freq = clamp(vf->frequency, ctx->bands_rf->rangelow, in max2175_s_frequency()
1108 ctx->bands_rf->rangehigh); in max2175_s_frequency()
1111 if (ctx->mode_resolved && in max2175_s_frequency()
1112 max2175_freq_rx_mode_valid(ctx, ctx->rx_mode->cur.val, freq)) in max2175_s_frequency()
1113 ret = max2175_tune_rf_freq(ctx, freq, ctx->hsls->cur.val); in max2175_s_frequency()
1116 ret = max2175_set_freq_and_mode(ctx, freq); in max2175_s_frequency()
1118 mxm_dbg(ctx, "s_freq: ret %d curr %u mode_resolved %d mode %u\n", in max2175_s_frequency()
1119 ret, ctx->freq, ctx->mode_resolved, ctx->rx_mode->cur.val); in max2175_s_frequency()
1127 struct max2175 *ctx = max2175_from_sd(sd); in max2175_g_frequency() local
1134 vf->frequency = ctx->freq; in max2175_g_frequency()
1142 struct max2175 *ctx = max2175_from_sd(sd); in max2175_enum_freq_bands() local
1147 *band = *ctx->bands_rf; in max2175_enum_freq_bands()
1154 struct max2175 *ctx = max2175_from_sd(sd); in max2175_g_tuner() local
1162 vt->rangelow = ctx->bands_rf->rangelow; in max2175_g_tuner()
1163 vt->rangehigh = ctx->bands_rf->rangehigh; in max2175_g_tuner()
1282 struct max2175 *ctx; in max2175_probe() local
1323 ctx = devm_kzalloc(&client->dev, sizeof(*ctx), GFP_KERNEL); in max2175_probe()
1324 if (ctx == NULL) in max2175_probe()
1327 sd = &ctx->sd; in max2175_probe()
1328 ctx->master = master; in max2175_probe()
1329 ctx->am_hiz = am_hiz; in max2175_probe()
1330 ctx->mode_resolved = false; in max2175_probe()
1331 ctx->regmap = regmap; in max2175_probe()
1332 ctx->xtal_freq = clk_get_rate(clk); in max2175_probe()
1333 dev_info(&client->dev, "xtal freq %luHz\n", ctx->xtal_freq); in max2175_probe()
1336 ctx->client = client; in max2175_probe()
1341 hdl = &ctx->ctrl_hdl; in max2175_probe()
1346 ctx->lna_gain = v4l2_ctrl_new_std(hdl, &max2175_ctrl_ops, in max2175_probe()
1349 ctx->lna_gain->flags |= (V4L2_CTRL_FLAG_VOLATILE | in max2175_probe()
1351 ctx->if_gain = v4l2_ctrl_new_std(hdl, &max2175_ctrl_ops, in max2175_probe()
1354 ctx->if_gain->flags |= (V4L2_CTRL_FLAG_VOLATILE | in max2175_probe()
1356 ctx->pll_lock = v4l2_ctrl_new_std(hdl, &max2175_ctrl_ops, in max2175_probe()
1359 ctx->pll_lock->flags |= (V4L2_CTRL_FLAG_VOLATILE | in max2175_probe()
1361 ctx->i2s_en = v4l2_ctrl_new_custom(hdl, &max2175_i2s_en, NULL); in max2175_probe()
1362 ctx->hsls = v4l2_ctrl_new_custom(hdl, &max2175_hsls, NULL); in max2175_probe()
1364 if (ctx->xtal_freq == MAX2175_EU_XTAL_FREQ) { in max2175_probe()
1365 ctx->rx_mode = v4l2_ctrl_new_custom(hdl, in max2175_probe()
1367 ctx->rx_modes = eu_rx_modes; in max2175_probe()
1368 ctx->bands_rf = &eu_bands_rf; in max2175_probe()
1370 ctx->rx_mode = v4l2_ctrl_new_custom(hdl, in max2175_probe()
1372 ctx->rx_modes = na_rx_modes; in max2175_probe()
1373 ctx->bands_rf = &na_bands_rf; in max2175_probe()
1375 ctx->sd.ctrl_handler = &ctx->ctrl_hdl; in max2175_probe()
1378 ctx->freq = ctx->bands_rf->rangelow; in max2175_probe()
1388 ret = max2175_core_init(ctx, refout_bits); in max2175_probe()
1401 v4l2_ctrl_handler_free(&ctx->ctrl_hdl); in max2175_probe()
1409 struct max2175 *ctx = max2175_from_sd(sd); in max2175_remove() local
1411 v4l2_ctrl_handler_free(&ctx->ctrl_hdl); in max2175_remove()