1 /* SPDX-License-Identifier: GPL-2.0-or-later */
2 /*
3 	STB6100 Silicon Tuner
4 	Copyright (C) Manu Abraham (abraham.manu@gmail.com)
5 
6 	Copyright (C) ST Microelectronics
7 
8 */
9 
10 #ifndef __STB_6100_REG_H
11 #define __STB_6100_REG_H
12 
13 #include <linux/dvb/frontend.h>
14 #include <media/dvb_frontend.h>
15 
16 #define STB6100_LD			0x00
17 #define STB6100_LD_LOCK			(1 << 0)
18 
19 #define STB6100_VCO			0x01
20 #define STB6100_VCO_OSCH		(0x01 << 7)
21 #define STB6100_VCO_OSCH_SHIFT		7
22 #define STB6100_VCO_OCK			(0x03 << 5)
23 #define STB6100_VCO_OCK_SHIFT		5
24 #define STB6100_VCO_ODIV		(0x01 << 4)
25 #define STB6100_VCO_ODIV_SHIFT		4
26 #define STB6100_VCO_OSM			(0x0f << 0)
27 
28 #define STB6100_NI			0x02
29 #define STB6100_NF_LSB			0x03
30 
31 #define STB6100_K			0x04
32 #define STB6100_K_PSD2			(0x01 << 2)
33 #define STB6100_K_PSD2_SHIFT            2
34 #define STB6100_K_NF_MSB		(0x03 << 0)
35 
36 #define STB6100_G			0x05
37 #define STB6100_G_G			(0x0f << 0)
38 #define STB6100_G_GCT			(0x07 << 5)
39 
40 #define STB6100_F			0x06
41 #define STB6100_F_F			(0x1f << 0)
42 
43 #define STB6100_DLB			0x07
44 
45 #define STB6100_TEST1			0x08
46 
47 #define STB6100_FCCK			0x09
48 #define STB6100_FCCK_FCCK		(0x01 << 6)
49 
50 #define STB6100_LPEN			0x0a
51 #define STB6100_LPEN_LPEN		(0x01 << 4)
52 #define STB6100_LPEN_SYNP		(0x01 << 5)
53 #define STB6100_LPEN_OSCP		(0x01 << 6)
54 #define STB6100_LPEN_BEN		(0x01 << 7)
55 
56 #define STB6100_TEST3			0x0b
57 
58 #define STB6100_NUMREGS                 0x0c
59 
60 
61 #define INRANGE(val, x, y)		(((x <= val) && (val <= y)) ||		\
62 					 ((y <= val) && (val <= x)) ? 1 : 0)
63 
64 #define CHKRANGE(val, x, y)		(((val >= x) && (val < y)) ? 1 : 0)
65 
66 struct stb6100_config {
67 	u8	tuner_address;
68 	u32	refclock;
69 };
70 
71 struct stb6100_state {
72 	struct i2c_adapter *i2c;
73 
74 	const struct stb6100_config	*config;
75 	struct dvb_tuner_ops		ops;
76 	struct dvb_frontend		*frontend;
77 
78 	u32 frequency;
79 	u32 srate;
80 	u32 bandwidth;
81 	u32 reference;
82 };
83 
84 #if IS_REACHABLE(CONFIG_DVB_STB6100)
85 
86 extern struct dvb_frontend *stb6100_attach(struct dvb_frontend *fe,
87 					   const struct stb6100_config *config,
88 					   struct i2c_adapter *i2c);
89 
90 #else
91 
92 static inline struct dvb_frontend *stb6100_attach(struct dvb_frontend *fe,
93 						  const struct stb6100_config *config,
94 						  struct i2c_adapter *i2c)
95 {
96 	printk(KERN_WARNING "%s: Driver disabled by Kconfig\n", __func__);
97 	return NULL;
98 }
99 
100 #endif //CONFIG_DVB_STB6100
101 
102 #endif
103