18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-or-later */
28c2ecf20Sopenharmony_ci/*
38c2ecf20Sopenharmony_ci * NXP TDA18250BHN silicon tuner driver
48c2ecf20Sopenharmony_ci *
58c2ecf20Sopenharmony_ci * Copyright (C) 2017 Olli Salonen <olli.salonen@iki.fi>
68c2ecf20Sopenharmony_ci */
78c2ecf20Sopenharmony_ci
88c2ecf20Sopenharmony_ci#ifndef TDA18250_PRIV_H
98c2ecf20Sopenharmony_ci#define TDA18250_PRIV_H
108c2ecf20Sopenharmony_ci
118c2ecf20Sopenharmony_ci#include "tda18250.h"
128c2ecf20Sopenharmony_ci
138c2ecf20Sopenharmony_ci#define R00_ID1		0x00	/* ID byte 1 */
148c2ecf20Sopenharmony_ci#define R01_ID2		0x01	/* ID byte 2 */
158c2ecf20Sopenharmony_ci#define R02_ID3		0x02	/* ID byte 3 */
168c2ecf20Sopenharmony_ci#define R03_THERMO1	0x03	/* Thermo byte 1 */
178c2ecf20Sopenharmony_ci#define R04_THERMO2	0x04	/* Thermo byte 2 */
188c2ecf20Sopenharmony_ci#define R05_POWER1	0x05	/* Power byte 1 */
198c2ecf20Sopenharmony_ci#define R06_POWER2	0x06	/* Power byte 2 */
208c2ecf20Sopenharmony_ci#define R07_GPIO	0x07	/* GPIO */
218c2ecf20Sopenharmony_ci#define R08_IRQ1	0x08	/* IRQ */
228c2ecf20Sopenharmony_ci#define R09_IRQ2	0x09	/* IRQ */
238c2ecf20Sopenharmony_ci#define R0A_IRQ3	0x0a	/* IRQ */
248c2ecf20Sopenharmony_ci#define R0B_IRQ4	0x0b	/* IRQ */
258c2ecf20Sopenharmony_ci#define R0C_AGC11	0x0c	/* AGC1 byte 1 */
268c2ecf20Sopenharmony_ci#define R0D_AGC12	0x0d	/* AGC1 byte 2 */
278c2ecf20Sopenharmony_ci#define R0E_AGC13	0x0e	/* AGC1 byte 3 */
288c2ecf20Sopenharmony_ci#define R0F_AGC14	0x0f	/* AGC1 byte 4 */
298c2ecf20Sopenharmony_ci#define R10_LT1		0x10	/* LT byte 1 */
308c2ecf20Sopenharmony_ci#define R11_LT2		0x11	/* LT byte 2 */
318c2ecf20Sopenharmony_ci#define R12_AGC21	0x12	/* AGC2 byte 1 */
328c2ecf20Sopenharmony_ci#define R13_AGC22	0x13	/* AGC2 byte 2 */
338c2ecf20Sopenharmony_ci#define R14_AGC23	0x14	/* AGC2 byte 3 */
348c2ecf20Sopenharmony_ci#define R15_AGC24	0x15	/* AGC2 byte 4 */
358c2ecf20Sopenharmony_ci#define R16_AGC25	0x16	/* AGC2 byte 5 */
368c2ecf20Sopenharmony_ci#define R17_AGC31	0x17	/* AGC3 byte 1 */
378c2ecf20Sopenharmony_ci#define R18_AGC32	0x18	/* AGC3 byte 2 */
388c2ecf20Sopenharmony_ci#define R19_AGC33	0x19	/* AGC3 byte 3 */
398c2ecf20Sopenharmony_ci#define R1A_AGCK	0x1a
408c2ecf20Sopenharmony_ci#define R1B_GAIN1	0x1b
418c2ecf20Sopenharmony_ci#define R1C_GAIN2	0x1c
428c2ecf20Sopenharmony_ci#define R1D_GAIN3	0x1d
438c2ecf20Sopenharmony_ci#define R1E_WI_FI	0x1e	/* Wireless Filter */
448c2ecf20Sopenharmony_ci#define R1F_RF_BPF	0x1f	/* RF Band Pass Filter */
458c2ecf20Sopenharmony_ci#define R20_IR_MIX	0x20	/* IR Mixer */
468c2ecf20Sopenharmony_ci#define R21_IF_AGC	0x21
478c2ecf20Sopenharmony_ci#define R22_IF1		0x22	/* IF byte 1 */
488c2ecf20Sopenharmony_ci#define R23_IF2		0x23	/* IF byte 2 */
498c2ecf20Sopenharmony_ci#define R24_IF3		0x24	/* IF byte 3 */
508c2ecf20Sopenharmony_ci#define R25_REF		0x25	/* reference byte */
518c2ecf20Sopenharmony_ci#define R26_IF		0x26	/* IF frequency */
528c2ecf20Sopenharmony_ci#define R27_RF1		0x27	/* RF frequency byte 1 */
538c2ecf20Sopenharmony_ci#define R28_RF2		0x28	/* RF frequency byte 2 */
548c2ecf20Sopenharmony_ci#define R29_RF3		0x29	/* RF frequency byte 3 */
558c2ecf20Sopenharmony_ci#define R2A_MSM1	0x2a
568c2ecf20Sopenharmony_ci#define R2B_MSM2	0x2b
578c2ecf20Sopenharmony_ci#define R2C_PS1		0x2c	/* power saving mode byte 1 */
588c2ecf20Sopenharmony_ci#define R2D_PS2		0x2d	/* power saving mode byte 2 */
598c2ecf20Sopenharmony_ci#define R2E_PS3		0x2e	/* power saving mode byte 3 */
608c2ecf20Sopenharmony_ci#define R2F_RSSI1	0x2f
618c2ecf20Sopenharmony_ci#define R30_RSSI2	0x30
628c2ecf20Sopenharmony_ci#define R31_IRQ_CTRL	0x31
638c2ecf20Sopenharmony_ci#define R32_DUMMY	0x32
648c2ecf20Sopenharmony_ci#define R33_TEST	0x33
658c2ecf20Sopenharmony_ci#define R34_MD1		0x34
668c2ecf20Sopenharmony_ci#define R35_SD1		0x35
678c2ecf20Sopenharmony_ci#define R36_SD2		0x36
688c2ecf20Sopenharmony_ci#define R37_SD3		0x37
698c2ecf20Sopenharmony_ci#define R38_SD4		0x38
708c2ecf20Sopenharmony_ci#define R39_SD5		0x39
718c2ecf20Sopenharmony_ci#define R3A_SD_TEST	0x3a
728c2ecf20Sopenharmony_ci#define R3B_REGU	0x3b
738c2ecf20Sopenharmony_ci#define R3C_RCCAL1	0x3c
748c2ecf20Sopenharmony_ci#define R3D_RCCAL2	0x3d
758c2ecf20Sopenharmony_ci#define R3E_IRCAL1	0x3e
768c2ecf20Sopenharmony_ci#define R3F_IRCAL2	0x3f
778c2ecf20Sopenharmony_ci#define R40_IRCAL3	0x40
788c2ecf20Sopenharmony_ci#define R41_IRCAL4	0x41
798c2ecf20Sopenharmony_ci#define R42_IRCAL5	0x42
808c2ecf20Sopenharmony_ci#define R43_PD1		0x43	/* power down byte 1 */
818c2ecf20Sopenharmony_ci#define R44_PD2		0x44	/* power down byte 2 */
828c2ecf20Sopenharmony_ci#define R45_PD		0x45	/* power down */
838c2ecf20Sopenharmony_ci#define R46_CPUMP	0x46	/* charge pump */
848c2ecf20Sopenharmony_ci#define R47_LNAPOL	0x47	/* LNA polar casc */
858c2ecf20Sopenharmony_ci#define R48_SMOOTH1	0x48	/* smooth test byte 1 */
868c2ecf20Sopenharmony_ci#define R49_SMOOTH2	0x49	/* smooth test byte 2 */
878c2ecf20Sopenharmony_ci#define R4A_SMOOTH3	0x4a	/* smooth test byte 3 */
888c2ecf20Sopenharmony_ci#define R4B_XTALOSC1	0x4b
898c2ecf20Sopenharmony_ci#define R4C_XTALOSC2	0x4c
908c2ecf20Sopenharmony_ci#define R4D_XTALFLX1	0x4d
918c2ecf20Sopenharmony_ci#define R4E_XTALFLX2	0x4e
928c2ecf20Sopenharmony_ci#define R4F_XTALFLX3	0x4f
938c2ecf20Sopenharmony_ci#define R50_XTALFLX4	0x50
948c2ecf20Sopenharmony_ci#define R51_XTALFLX5	0x51
958c2ecf20Sopenharmony_ci#define R52_IRLOOP0	0x52
968c2ecf20Sopenharmony_ci#define R53_IRLOOP1	0x53
978c2ecf20Sopenharmony_ci#define R54_IRLOOP2	0x54
988c2ecf20Sopenharmony_ci#define R55_IRLOOP3	0x55
998c2ecf20Sopenharmony_ci#define R56_IRLOOP4	0x56
1008c2ecf20Sopenharmony_ci#define R57_PLL_LOG	0x57
1018c2ecf20Sopenharmony_ci#define R58_AGC2_UP1	0x58
1028c2ecf20Sopenharmony_ci#define R59_AGC2_UP2	0x59
1038c2ecf20Sopenharmony_ci#define R5A_H3H5	0x5a
1048c2ecf20Sopenharmony_ci#define R5B_AGC_AUTO	0x5b
1058c2ecf20Sopenharmony_ci#define R5C_AGC_DEBUG	0x5c
1068c2ecf20Sopenharmony_ci
1078c2ecf20Sopenharmony_ci#define TDA18250_NUM_REGS 93
1088c2ecf20Sopenharmony_ci
1098c2ecf20Sopenharmony_ci#define TDA18250_POWER_STANDBY 0
1108c2ecf20Sopenharmony_ci#define TDA18250_POWER_NORMAL 1
1118c2ecf20Sopenharmony_ci
1128c2ecf20Sopenharmony_ci#define TDA18250_IRQ_CAL     0x81
1138c2ecf20Sopenharmony_ci#define TDA18250_IRQ_HW_INIT 0x82
1148c2ecf20Sopenharmony_ci#define TDA18250_IRQ_TUNE    0x88
1158c2ecf20Sopenharmony_ci
1168c2ecf20Sopenharmony_cistruct tda18250_dev {
1178c2ecf20Sopenharmony_ci	struct mutex i2c_mutex;
1188c2ecf20Sopenharmony_ci	struct dvb_frontend *fe;
1198c2ecf20Sopenharmony_ci	struct i2c_adapter *i2c;
1208c2ecf20Sopenharmony_ci	struct regmap *regmap;
1218c2ecf20Sopenharmony_ci	u8 xtal_freq;
1228c2ecf20Sopenharmony_ci	/* IF in kHz */
1238c2ecf20Sopenharmony_ci	u16 if_dvbt_6;
1248c2ecf20Sopenharmony_ci	u16 if_dvbt_7;
1258c2ecf20Sopenharmony_ci	u16 if_dvbt_8;
1268c2ecf20Sopenharmony_ci	u16 if_dvbc_6;
1278c2ecf20Sopenharmony_ci	u16 if_dvbc_8;
1288c2ecf20Sopenharmony_ci	u16 if_atsc;
1298c2ecf20Sopenharmony_ci	u16 if_frequency;
1308c2ecf20Sopenharmony_ci	bool slave;
1318c2ecf20Sopenharmony_ci	bool loopthrough;
1328c2ecf20Sopenharmony_ci	bool warm;
1338c2ecf20Sopenharmony_ci	u8 regs[TDA18250_NUM_REGS];
1348c2ecf20Sopenharmony_ci};
1358c2ecf20Sopenharmony_ci
1368c2ecf20Sopenharmony_ci#endif
137