1 /*
2  * Montage M88DS3103 demodulator driver
3  *
4  * Copyright (C) 2013 Antti Palosaari <crope@iki.fi>
5  *
6  *    This program is free software; you can redistribute it and/or modify
7  *    it under the terms of the GNU General Public License as published by
8  *    the Free Software Foundation; either version 2 of the License, or
9  *    (at your option) any later version.
10  *
11  *    This program is distributed in the hope that it will be useful,
12  *    but WITHOUT ANY WARRANTY; without even the implied warranty of
13  *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  *    GNU General Public License for more details.
15  *
16  *    You should have received a copy of the GNU General Public License along
17  *    with this program; if not, write to the Free Software Foundation, Inc.,
18  *    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19  */
20 
21 #ifndef M88DS3103_PRIV_H
22 #define M88DS3103_PRIV_H
23 
24 #include "dvb_frontend.h"
25 #include "m88ds3103.h"
26 #include "dvb_math.h"
27 #include <linux/firmware.h>
28 
29 #define M88DS3103_FIRMWARE "dvb-demod-m88ds3103.fw"
30 #define M88DS3103_MCLK_KHZ 96000
31 
32 struct m88ds3103_priv {
33 	struct i2c_adapter *i2c;
34 	/* mutex needed due to own tuner I2C adapter */
35 	struct mutex i2c_mutex;
36 	const struct m88ds3103_config *cfg;
37 	struct dvb_frontend fe;
38 	fe_delivery_system_t delivery_system;
39 	fe_status_t fe_status;
40 	bool warm; /* FW running */
41 	struct i2c_adapter i2c_adapter;
42 };
43 
44 struct m88ds3103_reg_val {
45 	u8 reg;
46 	u8 val;
47 };
48 
49 static const struct m88ds3103_reg_val m88ds3103_dvbs_init_reg_vals[] = {
50 	{0x23, 0x07},
51 	{0x08, 0x03},
52 	{0x0c, 0x02},
53 	{0x21, 0x54},
54 	{0x25, 0x8a},
55 	{0x27, 0x31},
56 	{0x30, 0x08},
57 	{0x31, 0x40},
58 	{0x32, 0x32},
59 	{0x33, 0x35},
60 	{0x35, 0xff},
61 	{0x3a, 0x00},
62 	{0x37, 0x10},
63 	{0x38, 0x10},
64 	{0x39, 0x02},
65 	{0x42, 0x60},
66 	{0x4a, 0x80},
67 	{0x4b, 0x04},
68 	{0x4d, 0x91},
69 	{0x5d, 0xc8},
70 	{0x50, 0x36},
71 	{0x51, 0x36},
72 	{0x52, 0x36},
73 	{0x53, 0x36},
74 	{0x63, 0x0f},
75 	{0x64, 0x30},
76 	{0x65, 0x40},
77 	{0x68, 0x26},
78 	{0x69, 0x4c},
79 	{0x70, 0x20},
80 	{0x71, 0x70},
81 	{0x72, 0x04},
82 	{0x73, 0x00},
83 	{0x70, 0x40},
84 	{0x71, 0x70},
85 	{0x72, 0x04},
86 	{0x73, 0x00},
87 	{0x70, 0x60},
88 	{0x71, 0x70},
89 	{0x72, 0x04},
90 	{0x73, 0x00},
91 	{0x70, 0x80},
92 	{0x71, 0x70},
93 	{0x72, 0x04},
94 	{0x73, 0x00},
95 	{0x70, 0xa0},
96 	{0x71, 0x70},
97 	{0x72, 0x04},
98 	{0x73, 0x00},
99 	{0x70, 0x1f},
100 	{0x76, 0x38},
101 	{0x77, 0xa6},
102 	{0x78, 0x0c},
103 	{0x79, 0x80},
104 	{0x7f, 0x14},
105 	{0x7c, 0x00},
106 	{0xae, 0x82},
107 	{0x80, 0x64},
108 	{0x81, 0x66},
109 	{0x82, 0x44},
110 	{0x85, 0x04},
111 	{0xcd, 0xf4},
112 	{0x90, 0x33},
113 	{0xa0, 0x44},
114 	{0xc0, 0x08},
115 	{0xc3, 0x10},
116 	{0xc4, 0x08},
117 	{0xc5, 0xf0},
118 	{0xc6, 0xff},
119 	{0xc7, 0x00},
120 	{0xc8, 0x1a},
121 	{0xc9, 0x80},
122 	{0xe0, 0xf8},
123 	{0xe6, 0x8b},
124 	{0xd0, 0x40},
125 	{0xf8, 0x20},
126 	{0xfa, 0x0f},
127 	{0x00, 0x00},
128 	{0xbd, 0x01},
129 	{0xb8, 0x00},
130 };
131 
132 static const struct m88ds3103_reg_val m88ds3103_dvbs2_init_reg_vals[] = {
133 	{0x23, 0x07},
134 	{0x08, 0x07},
135 	{0x0c, 0x02},
136 	{0x21, 0x54},
137 	{0x25, 0x8a},
138 	{0x27, 0x31},
139 	{0x30, 0x08},
140 	{0x32, 0x32},
141 	{0x33, 0x35},
142 	{0x35, 0xff},
143 	{0x3a, 0x00},
144 	{0x37, 0x10},
145 	{0x38, 0x10},
146 	{0x39, 0x02},
147 	{0x42, 0x60},
148 	{0x4a, 0x80},
149 	{0x4b, 0x04},
150 	{0x4d, 0x91},
151 	{0x5d, 0xc8},
152 	{0x50, 0x36},
153 	{0x51, 0x36},
154 	{0x52, 0x36},
155 	{0x53, 0x36},
156 	{0x63, 0x0f},
157 	{0x64, 0x10},
158 	{0x65, 0x20},
159 	{0x68, 0x46},
160 	{0x69, 0xcd},
161 	{0x70, 0x20},
162 	{0x71, 0x70},
163 	{0x72, 0x04},
164 	{0x73, 0x00},
165 	{0x70, 0x40},
166 	{0x71, 0x70},
167 	{0x72, 0x04},
168 	{0x73, 0x00},
169 	{0x70, 0x60},
170 	{0x71, 0x70},
171 	{0x72, 0x04},
172 	{0x73, 0x00},
173 	{0x70, 0x80},
174 	{0x71, 0x70},
175 	{0x72, 0x04},
176 	{0x73, 0x00},
177 	{0x70, 0xa0},
178 	{0x71, 0x70},
179 	{0x72, 0x04},
180 	{0x73, 0x00},
181 	{0x70, 0x1f},
182 	{0x76, 0x38},
183 	{0x77, 0xa6},
184 	{0x78, 0x0c},
185 	{0x79, 0x80},
186 	{0x7f, 0x14},
187 	{0x85, 0x08},
188 	{0xcd, 0xf4},
189 	{0x90, 0x33},
190 	{0x86, 0x00},
191 	{0x87, 0x0f},
192 	{0x89, 0x00},
193 	{0x8b, 0x44},
194 	{0x8c, 0x66},
195 	{0x9d, 0xc1},
196 	{0x8a, 0x10},
197 	{0xad, 0x40},
198 	{0xa0, 0x44},
199 	{0xc0, 0x08},
200 	{0xc1, 0x10},
201 	{0xc2, 0x08},
202 	{0xc3, 0x10},
203 	{0xc4, 0x08},
204 	{0xc5, 0xf0},
205 	{0xc6, 0xff},
206 	{0xc7, 0x00},
207 	{0xc8, 0x1a},
208 	{0xc9, 0x80},
209 	{0xca, 0x23},
210 	{0xcb, 0x24},
211 	{0xcc, 0xf4},
212 	{0xce, 0x74},
213 	{0x00, 0x00},
214 	{0xbd, 0x01},
215 	{0xb8, 0x00},
216 };
217 
218 #endif
219