162306a36Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-or-later */
262306a36Sopenharmony_ci/*
362306a36Sopenharmony_ci *  Driver for Microtune MT2060 "Single chip dual conversion broadband tuner"
462306a36Sopenharmony_ci *
562306a36Sopenharmony_ci *  Copyright (c) 2006 Olivier DANET <odanet@caramail.com>
662306a36Sopenharmony_ci */
762306a36Sopenharmony_ci
862306a36Sopenharmony_ci#ifndef MT2060_PRIV_H
962306a36Sopenharmony_ci#define MT2060_PRIV_H
1062306a36Sopenharmony_ci
1162306a36Sopenharmony_ci// Uncomment the #define below to enable spurs checking. The results where quite unconvincing.
1262306a36Sopenharmony_ci// #define MT2060_SPURCHECK
1362306a36Sopenharmony_ci
1462306a36Sopenharmony_ci/* This driver is based on the information available in the datasheet of the
1562306a36Sopenharmony_ci   "Comtech SDVBT-3K6M" tuner ( K1000737843.pdf ) which features the MT2060 register map :
1662306a36Sopenharmony_ci
1762306a36Sopenharmony_ci   I2C Address : 0x60
1862306a36Sopenharmony_ci
1962306a36Sopenharmony_ci   Reg.No |   B7   |   B6   |   B5   |   B4   |   B3   |   B2   |   B1   |   B0   | ( defaults )
2062306a36Sopenharmony_ci   --------------------------------------------------------------------------------
2162306a36Sopenharmony_ci       00 | [              PART             ] | [              REV              ] | R  = 0x63
2262306a36Sopenharmony_ci       01 | [             LNABAND           ] | [              NUM1(5:2)        ] | RW = 0x3F
2362306a36Sopenharmony_ci       02 | [                               DIV1                                ] | RW = 0x74
2462306a36Sopenharmony_ci       03 | FM1CA  | FM1SS  | [  NUM1(1:0)  ] | [              NUM2(3:0)        ] | RW = 0x00
2562306a36Sopenharmony_ci       04 |                                 NUM2(11:4)                          ] | RW = 0x08
2662306a36Sopenharmony_ci       05 | [                               DIV2                       ] |NUM2(12)| RW = 0x93
2762306a36Sopenharmony_ci       06 | L1LK   | [        TAD1          ] | L2LK   | [         TAD2         ] | R
2862306a36Sopenharmony_ci       07 | [                               FMF                                 ] | R
2962306a36Sopenharmony_ci       08 |   ?    | FMCAL  |   ?    |   ?    |   ?    |   ?    |   ?    | TEMP   | R
3062306a36Sopenharmony_ci       09 |   0    |   0    | [    FMGC     ] |   0    | GP02   | GP01   |   0    | RW = 0x20
3162306a36Sopenharmony_ci       0A | ??
3262306a36Sopenharmony_ci       0B |   0    |   0    |   1    |   1    |   0    |   0    | [   VGAG      ] | RW = 0x30
3362306a36Sopenharmony_ci       0C | V1CSE  |   1    |   1    |   1    |   1    |   1    |   1    |   1    | RW = 0xFF
3462306a36Sopenharmony_ci       0D |   1    |   0    | [                      V1CS                       ] | RW = 0xB0
3562306a36Sopenharmony_ci       0E | ??
3662306a36Sopenharmony_ci       0F | ??
3762306a36Sopenharmony_ci       10 | ??
3862306a36Sopenharmony_ci       11 | [             LOTO              ] |   0    |   0    |   1    |   0    | RW = 0x42
3962306a36Sopenharmony_ci
4062306a36Sopenharmony_ci       PART    : Part code      : 6 for MT2060
4162306a36Sopenharmony_ci       REV     : Revision code  : 3 for current revision
4262306a36Sopenharmony_ci       LNABAND : Input frequency range : ( See code for details )
4362306a36Sopenharmony_ci       NUM1 / DIV1 / NUM2 / DIV2 : Frequencies programming ( See code for details )
4462306a36Sopenharmony_ci       FM1CA  : Calibration Start Bit
4562306a36Sopenharmony_ci       FM1SS  : Calibration Single Step bit
4662306a36Sopenharmony_ci       L1LK   : LO1 Lock Detect
4762306a36Sopenharmony_ci       TAD1   : Tune Line ADC ( ? )
4862306a36Sopenharmony_ci       L2LK   : LO2 Lock Detect
4962306a36Sopenharmony_ci       TAD2   : Tune Line ADC ( ? )
5062306a36Sopenharmony_ci       FMF    : Estimated first IF Center frequency Offset ( ? )
5162306a36Sopenharmony_ci       FM1CAL : Calibration done bit
5262306a36Sopenharmony_ci       TEMP   : On chip temperature sensor
5362306a36Sopenharmony_ci       FMCG   : Mixer 1 Cap Gain ( ? )
5462306a36Sopenharmony_ci       GP01 / GP02 : Programmable digital outputs. Unconnected pins ?
5562306a36Sopenharmony_ci       V1CSE  : LO1 VCO Automatic Capacitor Select Enable ( ? )
5662306a36Sopenharmony_ci       V1CS   : LO1 Capacitor Selection Value ( ? )
5762306a36Sopenharmony_ci       LOTO   : LO Timeout ( ? )
5862306a36Sopenharmony_ci       VGAG   : Tuner Output gain
5962306a36Sopenharmony_ci*/
6062306a36Sopenharmony_ci
6162306a36Sopenharmony_ci#define I2C_ADDRESS 0x60
6262306a36Sopenharmony_ci
6362306a36Sopenharmony_ci#define REG_PART_REV   0
6462306a36Sopenharmony_ci#define REG_LO1C1      1
6562306a36Sopenharmony_ci#define REG_LO1C2      2
6662306a36Sopenharmony_ci#define REG_LO2C1      3
6762306a36Sopenharmony_ci#define REG_LO2C2      4
6862306a36Sopenharmony_ci#define REG_LO2C3      5
6962306a36Sopenharmony_ci#define REG_LO_STATUS  6
7062306a36Sopenharmony_ci#define REG_FM_FREQ    7
7162306a36Sopenharmony_ci#define REG_MISC_STAT  8
7262306a36Sopenharmony_ci#define REG_MISC_CTRL  9
7362306a36Sopenharmony_ci#define REG_RESERVED_A 0x0A
7462306a36Sopenharmony_ci#define REG_VGAG       0x0B
7562306a36Sopenharmony_ci#define REG_LO1B1      0x0C
7662306a36Sopenharmony_ci#define REG_LO1B2      0x0D
7762306a36Sopenharmony_ci#define REG_LOTO       0x11
7862306a36Sopenharmony_ci
7962306a36Sopenharmony_ci#define PART_REV 0x63 // The current driver works only with PART=6 and REV=3 chips
8062306a36Sopenharmony_ci
8162306a36Sopenharmony_cistruct mt2060_priv {
8262306a36Sopenharmony_ci	struct mt2060_config *cfg;
8362306a36Sopenharmony_ci	struct i2c_adapter   *i2c;
8462306a36Sopenharmony_ci	struct i2c_client *client;
8562306a36Sopenharmony_ci	struct mt2060_config config;
8662306a36Sopenharmony_ci
8762306a36Sopenharmony_ci	u8 i2c_max_regs;
8862306a36Sopenharmony_ci	u32 frequency;
8962306a36Sopenharmony_ci	u16 if1_freq;
9062306a36Sopenharmony_ci	u8  fmfreq;
9162306a36Sopenharmony_ci
9262306a36Sopenharmony_ci	/*
9362306a36Sopenharmony_ci	 * Use REG_MISC_CTRL register for sleep. That drops sleep power usage
9462306a36Sopenharmony_ci	 * about 0.9W (huge!). Register bit meanings are unknown, so let it be
9562306a36Sopenharmony_ci	 * disabled by default to avoid possible regression. Convert driver to
9662306a36Sopenharmony_ci	 * i2c model in order to enable it.
9762306a36Sopenharmony_ci	 */
9862306a36Sopenharmony_ci	bool sleep;
9962306a36Sopenharmony_ci};
10062306a36Sopenharmony_ci
10162306a36Sopenharmony_ci#endif
102