162306a36Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-or-later */
262306a36Sopenharmony_ci/*
362306a36Sopenharmony_ci * NXP TDA18250BHN silicon tuner driver
462306a36Sopenharmony_ci *
562306a36Sopenharmony_ci * Copyright (C) 2017 Olli Salonen <olli.salonen@iki.fi>
662306a36Sopenharmony_ci */
762306a36Sopenharmony_ci
862306a36Sopenharmony_ci#ifndef TDA18250_PRIV_H
962306a36Sopenharmony_ci#define TDA18250_PRIV_H
1062306a36Sopenharmony_ci
1162306a36Sopenharmony_ci#include "tda18250.h"
1262306a36Sopenharmony_ci
1362306a36Sopenharmony_ci#define R00_ID1		0x00	/* ID byte 1 */
1462306a36Sopenharmony_ci#define R01_ID2		0x01	/* ID byte 2 */
1562306a36Sopenharmony_ci#define R02_ID3		0x02	/* ID byte 3 */
1662306a36Sopenharmony_ci#define R03_THERMO1	0x03	/* Thermo byte 1 */
1762306a36Sopenharmony_ci#define R04_THERMO2	0x04	/* Thermo byte 2 */
1862306a36Sopenharmony_ci#define R05_POWER1	0x05	/* Power byte 1 */
1962306a36Sopenharmony_ci#define R06_POWER2	0x06	/* Power byte 2 */
2062306a36Sopenharmony_ci#define R07_GPIO	0x07	/* GPIO */
2162306a36Sopenharmony_ci#define R08_IRQ1	0x08	/* IRQ */
2262306a36Sopenharmony_ci#define R09_IRQ2	0x09	/* IRQ */
2362306a36Sopenharmony_ci#define R0A_IRQ3	0x0a	/* IRQ */
2462306a36Sopenharmony_ci#define R0B_IRQ4	0x0b	/* IRQ */
2562306a36Sopenharmony_ci#define R0C_AGC11	0x0c	/* AGC1 byte 1 */
2662306a36Sopenharmony_ci#define R0D_AGC12	0x0d	/* AGC1 byte 2 */
2762306a36Sopenharmony_ci#define R0E_AGC13	0x0e	/* AGC1 byte 3 */
2862306a36Sopenharmony_ci#define R0F_AGC14	0x0f	/* AGC1 byte 4 */
2962306a36Sopenharmony_ci#define R10_LT1		0x10	/* LT byte 1 */
3062306a36Sopenharmony_ci#define R11_LT2		0x11	/* LT byte 2 */
3162306a36Sopenharmony_ci#define R12_AGC21	0x12	/* AGC2 byte 1 */
3262306a36Sopenharmony_ci#define R13_AGC22	0x13	/* AGC2 byte 2 */
3362306a36Sopenharmony_ci#define R14_AGC23	0x14	/* AGC2 byte 3 */
3462306a36Sopenharmony_ci#define R15_AGC24	0x15	/* AGC2 byte 4 */
3562306a36Sopenharmony_ci#define R16_AGC25	0x16	/* AGC2 byte 5 */
3662306a36Sopenharmony_ci#define R17_AGC31	0x17	/* AGC3 byte 1 */
3762306a36Sopenharmony_ci#define R18_AGC32	0x18	/* AGC3 byte 2 */
3862306a36Sopenharmony_ci#define R19_AGC33	0x19	/* AGC3 byte 3 */
3962306a36Sopenharmony_ci#define R1A_AGCK	0x1a
4062306a36Sopenharmony_ci#define R1B_GAIN1	0x1b
4162306a36Sopenharmony_ci#define R1C_GAIN2	0x1c
4262306a36Sopenharmony_ci#define R1D_GAIN3	0x1d
4362306a36Sopenharmony_ci#define R1E_WI_FI	0x1e	/* Wireless Filter */
4462306a36Sopenharmony_ci#define R1F_RF_BPF	0x1f	/* RF Band Pass Filter */
4562306a36Sopenharmony_ci#define R20_IR_MIX	0x20	/* IR Mixer */
4662306a36Sopenharmony_ci#define R21_IF_AGC	0x21
4762306a36Sopenharmony_ci#define R22_IF1		0x22	/* IF byte 1 */
4862306a36Sopenharmony_ci#define R23_IF2		0x23	/* IF byte 2 */
4962306a36Sopenharmony_ci#define R24_IF3		0x24	/* IF byte 3 */
5062306a36Sopenharmony_ci#define R25_REF		0x25	/* reference byte */
5162306a36Sopenharmony_ci#define R26_IF		0x26	/* IF frequency */
5262306a36Sopenharmony_ci#define R27_RF1		0x27	/* RF frequency byte 1 */
5362306a36Sopenharmony_ci#define R28_RF2		0x28	/* RF frequency byte 2 */
5462306a36Sopenharmony_ci#define R29_RF3		0x29	/* RF frequency byte 3 */
5562306a36Sopenharmony_ci#define R2A_MSM1	0x2a
5662306a36Sopenharmony_ci#define R2B_MSM2	0x2b
5762306a36Sopenharmony_ci#define R2C_PS1		0x2c	/* power saving mode byte 1 */
5862306a36Sopenharmony_ci#define R2D_PS2		0x2d	/* power saving mode byte 2 */
5962306a36Sopenharmony_ci#define R2E_PS3		0x2e	/* power saving mode byte 3 */
6062306a36Sopenharmony_ci#define R2F_RSSI1	0x2f
6162306a36Sopenharmony_ci#define R30_RSSI2	0x30
6262306a36Sopenharmony_ci#define R31_IRQ_CTRL	0x31
6362306a36Sopenharmony_ci#define R32_DUMMY	0x32
6462306a36Sopenharmony_ci#define R33_TEST	0x33
6562306a36Sopenharmony_ci#define R34_MD1		0x34
6662306a36Sopenharmony_ci#define R35_SD1		0x35
6762306a36Sopenharmony_ci#define R36_SD2		0x36
6862306a36Sopenharmony_ci#define R37_SD3		0x37
6962306a36Sopenharmony_ci#define R38_SD4		0x38
7062306a36Sopenharmony_ci#define R39_SD5		0x39
7162306a36Sopenharmony_ci#define R3A_SD_TEST	0x3a
7262306a36Sopenharmony_ci#define R3B_REGU	0x3b
7362306a36Sopenharmony_ci#define R3C_RCCAL1	0x3c
7462306a36Sopenharmony_ci#define R3D_RCCAL2	0x3d
7562306a36Sopenharmony_ci#define R3E_IRCAL1	0x3e
7662306a36Sopenharmony_ci#define R3F_IRCAL2	0x3f
7762306a36Sopenharmony_ci#define R40_IRCAL3	0x40
7862306a36Sopenharmony_ci#define R41_IRCAL4	0x41
7962306a36Sopenharmony_ci#define R42_IRCAL5	0x42
8062306a36Sopenharmony_ci#define R43_PD1		0x43	/* power down byte 1 */
8162306a36Sopenharmony_ci#define R44_PD2		0x44	/* power down byte 2 */
8262306a36Sopenharmony_ci#define R45_PD		0x45	/* power down */
8362306a36Sopenharmony_ci#define R46_CPUMP	0x46	/* charge pump */
8462306a36Sopenharmony_ci#define R47_LNAPOL	0x47	/* LNA polar casc */
8562306a36Sopenharmony_ci#define R48_SMOOTH1	0x48	/* smooth test byte 1 */
8662306a36Sopenharmony_ci#define R49_SMOOTH2	0x49	/* smooth test byte 2 */
8762306a36Sopenharmony_ci#define R4A_SMOOTH3	0x4a	/* smooth test byte 3 */
8862306a36Sopenharmony_ci#define R4B_XTALOSC1	0x4b
8962306a36Sopenharmony_ci#define R4C_XTALOSC2	0x4c
9062306a36Sopenharmony_ci#define R4D_XTALFLX1	0x4d
9162306a36Sopenharmony_ci#define R4E_XTALFLX2	0x4e
9262306a36Sopenharmony_ci#define R4F_XTALFLX3	0x4f
9362306a36Sopenharmony_ci#define R50_XTALFLX4	0x50
9462306a36Sopenharmony_ci#define R51_XTALFLX5	0x51
9562306a36Sopenharmony_ci#define R52_IRLOOP0	0x52
9662306a36Sopenharmony_ci#define R53_IRLOOP1	0x53
9762306a36Sopenharmony_ci#define R54_IRLOOP2	0x54
9862306a36Sopenharmony_ci#define R55_IRLOOP3	0x55
9962306a36Sopenharmony_ci#define R56_IRLOOP4	0x56
10062306a36Sopenharmony_ci#define R57_PLL_LOG	0x57
10162306a36Sopenharmony_ci#define R58_AGC2_UP1	0x58
10262306a36Sopenharmony_ci#define R59_AGC2_UP2	0x59
10362306a36Sopenharmony_ci#define R5A_H3H5	0x5a
10462306a36Sopenharmony_ci#define R5B_AGC_AUTO	0x5b
10562306a36Sopenharmony_ci#define R5C_AGC_DEBUG	0x5c
10662306a36Sopenharmony_ci
10762306a36Sopenharmony_ci#define TDA18250_NUM_REGS 93
10862306a36Sopenharmony_ci
10962306a36Sopenharmony_ci#define TDA18250_POWER_STANDBY 0
11062306a36Sopenharmony_ci#define TDA18250_POWER_NORMAL 1
11162306a36Sopenharmony_ci
11262306a36Sopenharmony_ci#define TDA18250_IRQ_CAL     0x81
11362306a36Sopenharmony_ci#define TDA18250_IRQ_HW_INIT 0x82
11462306a36Sopenharmony_ci#define TDA18250_IRQ_TUNE    0x88
11562306a36Sopenharmony_ci
11662306a36Sopenharmony_cistruct tda18250_dev {
11762306a36Sopenharmony_ci	struct mutex i2c_mutex;
11862306a36Sopenharmony_ci	struct dvb_frontend *fe;
11962306a36Sopenharmony_ci	struct i2c_adapter *i2c;
12062306a36Sopenharmony_ci	struct regmap *regmap;
12162306a36Sopenharmony_ci	u8 xtal_freq;
12262306a36Sopenharmony_ci	/* IF in kHz */
12362306a36Sopenharmony_ci	u16 if_dvbt_6;
12462306a36Sopenharmony_ci	u16 if_dvbt_7;
12562306a36Sopenharmony_ci	u16 if_dvbt_8;
12662306a36Sopenharmony_ci	u16 if_dvbc_6;
12762306a36Sopenharmony_ci	u16 if_dvbc_8;
12862306a36Sopenharmony_ci	u16 if_atsc;
12962306a36Sopenharmony_ci	u16 if_frequency;
13062306a36Sopenharmony_ci	bool slave;
13162306a36Sopenharmony_ci	bool loopthrough;
13262306a36Sopenharmony_ci	bool warm;
13362306a36Sopenharmony_ci	u8 regs[TDA18250_NUM_REGS];
13462306a36Sopenharmony_ci};
13562306a36Sopenharmony_ci
13662306a36Sopenharmony_ci#endif
137