18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-or-later */
28c2ecf20Sopenharmony_ci/*
38c2ecf20Sopenharmony_ci *  Driver for Microtune MT2060 "Single chip dual conversion broadband tuner"
48c2ecf20Sopenharmony_ci *
58c2ecf20Sopenharmony_ci *  Copyright (c) 2006 Olivier DANET <odanet@caramail.com>
68c2ecf20Sopenharmony_ci */
78c2ecf20Sopenharmony_ci
88c2ecf20Sopenharmony_ci#ifndef MT2060_PRIV_H
98c2ecf20Sopenharmony_ci#define MT2060_PRIV_H
108c2ecf20Sopenharmony_ci
118c2ecf20Sopenharmony_ci// Uncomment the #define below to enable spurs checking. The results where quite unconvincing.
128c2ecf20Sopenharmony_ci// #define MT2060_SPURCHECK
138c2ecf20Sopenharmony_ci
148c2ecf20Sopenharmony_ci/* This driver is based on the information available in the datasheet of the
158c2ecf20Sopenharmony_ci   "Comtech SDVBT-3K6M" tuner ( K1000737843.pdf ) which features the MT2060 register map :
168c2ecf20Sopenharmony_ci
178c2ecf20Sopenharmony_ci   I2C Address : 0x60
188c2ecf20Sopenharmony_ci
198c2ecf20Sopenharmony_ci   Reg.No |   B7   |   B6   |   B5   |   B4   |   B3   |   B2   |   B1   |   B0   | ( defaults )
208c2ecf20Sopenharmony_ci   --------------------------------------------------------------------------------
218c2ecf20Sopenharmony_ci       00 | [              PART             ] | [              REV              ] | R  = 0x63
228c2ecf20Sopenharmony_ci       01 | [             LNABAND           ] | [              NUM1(5:2)        ] | RW = 0x3F
238c2ecf20Sopenharmony_ci       02 | [                               DIV1                                ] | RW = 0x74
248c2ecf20Sopenharmony_ci       03 | FM1CA  | FM1SS  | [  NUM1(1:0)  ] | [              NUM2(3:0)        ] | RW = 0x00
258c2ecf20Sopenharmony_ci       04 |                                 NUM2(11:4)                          ] | RW = 0x08
268c2ecf20Sopenharmony_ci       05 | [                               DIV2                       ] |NUM2(12)| RW = 0x93
278c2ecf20Sopenharmony_ci       06 | L1LK   | [        TAD1          ] | L2LK   | [         TAD2         ] | R
288c2ecf20Sopenharmony_ci       07 | [                               FMF                                 ] | R
298c2ecf20Sopenharmony_ci       08 |   ?    | FMCAL  |   ?    |   ?    |   ?    |   ?    |   ?    | TEMP   | R
308c2ecf20Sopenharmony_ci       09 |   0    |   0    | [    FMGC     ] |   0    | GP02   | GP01   |   0    | RW = 0x20
318c2ecf20Sopenharmony_ci       0A | ??
328c2ecf20Sopenharmony_ci       0B |   0    |   0    |   1    |   1    |   0    |   0    | [   VGAG      ] | RW = 0x30
338c2ecf20Sopenharmony_ci       0C | V1CSE  |   1    |   1    |   1    |   1    |   1    |   1    |   1    | RW = 0xFF
348c2ecf20Sopenharmony_ci       0D |   1    |   0    | [                      V1CS                       ] | RW = 0xB0
358c2ecf20Sopenharmony_ci       0E | ??
368c2ecf20Sopenharmony_ci       0F | ??
378c2ecf20Sopenharmony_ci       10 | ??
388c2ecf20Sopenharmony_ci       11 | [             LOTO              ] |   0    |   0    |   1    |   0    | RW = 0x42
398c2ecf20Sopenharmony_ci
408c2ecf20Sopenharmony_ci       PART    : Part code      : 6 for MT2060
418c2ecf20Sopenharmony_ci       REV     : Revision code  : 3 for current revision
428c2ecf20Sopenharmony_ci       LNABAND : Input frequency range : ( See code for details )
438c2ecf20Sopenharmony_ci       NUM1 / DIV1 / NUM2 / DIV2 : Frequencies programming ( See code for details )
448c2ecf20Sopenharmony_ci       FM1CA  : Calibration Start Bit
458c2ecf20Sopenharmony_ci       FM1SS  : Calibration Single Step bit
468c2ecf20Sopenharmony_ci       L1LK   : LO1 Lock Detect
478c2ecf20Sopenharmony_ci       TAD1   : Tune Line ADC ( ? )
488c2ecf20Sopenharmony_ci       L2LK   : LO2 Lock Detect
498c2ecf20Sopenharmony_ci       TAD2   : Tune Line ADC ( ? )
508c2ecf20Sopenharmony_ci       FMF    : Estimated first IF Center frequency Offset ( ? )
518c2ecf20Sopenharmony_ci       FM1CAL : Calibration done bit
528c2ecf20Sopenharmony_ci       TEMP   : On chip temperature sensor
538c2ecf20Sopenharmony_ci       FMCG   : Mixer 1 Cap Gain ( ? )
548c2ecf20Sopenharmony_ci       GP01 / GP02 : Programmable digital outputs. Unconnected pins ?
558c2ecf20Sopenharmony_ci       V1CSE  : LO1 VCO Automatic Capacitor Select Enable ( ? )
568c2ecf20Sopenharmony_ci       V1CS   : LO1 Capacitor Selection Value ( ? )
578c2ecf20Sopenharmony_ci       LOTO   : LO Timeout ( ? )
588c2ecf20Sopenharmony_ci       VGAG   : Tuner Output gain
598c2ecf20Sopenharmony_ci*/
608c2ecf20Sopenharmony_ci
618c2ecf20Sopenharmony_ci#define I2C_ADDRESS 0x60
628c2ecf20Sopenharmony_ci
638c2ecf20Sopenharmony_ci#define REG_PART_REV   0
648c2ecf20Sopenharmony_ci#define REG_LO1C1      1
658c2ecf20Sopenharmony_ci#define REG_LO1C2      2
668c2ecf20Sopenharmony_ci#define REG_LO2C1      3
678c2ecf20Sopenharmony_ci#define REG_LO2C2      4
688c2ecf20Sopenharmony_ci#define REG_LO2C3      5
698c2ecf20Sopenharmony_ci#define REG_LO_STATUS  6
708c2ecf20Sopenharmony_ci#define REG_FM_FREQ    7
718c2ecf20Sopenharmony_ci#define REG_MISC_STAT  8
728c2ecf20Sopenharmony_ci#define REG_MISC_CTRL  9
738c2ecf20Sopenharmony_ci#define REG_RESERVED_A 0x0A
748c2ecf20Sopenharmony_ci#define REG_VGAG       0x0B
758c2ecf20Sopenharmony_ci#define REG_LO1B1      0x0C
768c2ecf20Sopenharmony_ci#define REG_LO1B2      0x0D
778c2ecf20Sopenharmony_ci#define REG_LOTO       0x11
788c2ecf20Sopenharmony_ci
798c2ecf20Sopenharmony_ci#define PART_REV 0x63 // The current driver works only with PART=6 and REV=3 chips
808c2ecf20Sopenharmony_ci
818c2ecf20Sopenharmony_cistruct mt2060_priv {
828c2ecf20Sopenharmony_ci	struct mt2060_config *cfg;
838c2ecf20Sopenharmony_ci	struct i2c_adapter   *i2c;
848c2ecf20Sopenharmony_ci	struct i2c_client *client;
858c2ecf20Sopenharmony_ci	struct mt2060_config config;
868c2ecf20Sopenharmony_ci
878c2ecf20Sopenharmony_ci	u8 i2c_max_regs;
888c2ecf20Sopenharmony_ci	u32 frequency;
898c2ecf20Sopenharmony_ci	u16 if1_freq;
908c2ecf20Sopenharmony_ci	u8  fmfreq;
918c2ecf20Sopenharmony_ci
928c2ecf20Sopenharmony_ci	/*
938c2ecf20Sopenharmony_ci	 * Use REG_MISC_CTRL register for sleep. That drops sleep power usage
948c2ecf20Sopenharmony_ci	 * about 0.9W (huge!). Register bit meanings are unknown, so let it be
958c2ecf20Sopenharmony_ci	 * disabled by default to avoid possible regression. Convert driver to
968c2ecf20Sopenharmony_ci	 * i2c model in order to enable it.
978c2ecf20Sopenharmony_ci	 */
988c2ecf20Sopenharmony_ci	bool sleep;
998c2ecf20Sopenharmony_ci};
1008c2ecf20Sopenharmony_ci
1018c2ecf20Sopenharmony_ci#endif
102