1 /* SPDX-License-Identifier: GPL-2.0-or-later */ 2 /* 3 * Montage Technology M88DS3103/M88RS6000 demodulator driver 4 * 5 * Copyright (C) 2013 Antti Palosaari <crope@iki.fi> 6 */ 7 8 #ifndef M88DS3103_PRIV_H 9 #define M88DS3103_PRIV_H 10 11 #include <media/dvb_frontend.h> 12 #include "m88ds3103.h" 13 #include <linux/int_log.h> 14 #include <linux/firmware.h> 15 #include <linux/i2c-mux.h> 16 #include <linux/regmap.h> 17 #include <linux/math64.h> 18 19 #define M88DS3103B_FIRMWARE "dvb-demod-m88ds3103b.fw" 20 #define M88DS3103C_FIRMWARE "dvb-demod-m88ds3103c.fw" 21 #define M88DS3103_FIRMWARE "dvb-demod-m88ds3103.fw" 22 #define M88RS6000_FIRMWARE "dvb-demod-m88rs6000.fw" 23 24 #define M88DS3103_CHIP_ID 0x70 25 #define M88RS6000_CHIP_ID 0x74 26 #define M88DS3103C_CHIP_ID 0x71 27 28 #define M88DS3103_CHIPTYPE_3103 0 29 #define M88DS3103_CHIPTYPE_RS6000 1 30 #define M88DS3103_CHIPTYPE_3103B 2 31 #define M88DS3103_CHIPTYPE_3103C 3 32 33 struct m88ds3103_dev { 34 struct i2c_client *client; 35 struct i2c_client *dt_client; 36 struct regmap_config regmap_config; 37 struct regmap *regmap; 38 struct m88ds3103_config config; 39 const struct m88ds3103_config *cfg; 40 struct dvb_frontend fe; 41 enum fe_delivery_system delivery_system; 42 enum fe_status fe_status; 43 u32 dvbv3_ber; /* for old DVBv3 API read_ber */ 44 bool warm; /* FW running */ 45 struct i2c_mux_core *muxc; 46 /* auto detect chip id to do different config */ 47 u8 chip_id; 48 /* chip type to differentiate m88rs6000 from m88ds3103b */ 49 u8 chiptype; 50 /* main mclk is calculated for M88RS6000 dynamically */ 51 s32 mclk; 52 u64 post_bit_error; 53 u64 post_bit_count; 54 u8 dt_addr; 55 }; 56 57 struct m88ds3103_reg_val { 58 u8 reg; 59 u8 val; 60 }; 61 62 static const struct m88ds3103_reg_val m88ds3103_dvbs_init_reg_vals[] = { 63 {0x23, 0x07}, 64 {0x08, 0x03}, 65 {0x0c, 0x02}, 66 {0x21, 0x54}, 67 {0x25, 0x8a}, 68 {0x27, 0x31}, 69 {0x30, 0x08}, 70 {0x31, 0x40}, 71 {0x32, 0x32}, 72 {0x35, 0xff}, 73 {0x3a, 0x00}, 74 {0x37, 0x10}, 75 {0x38, 0x10}, 76 {0x39, 0x02}, 77 {0x42, 0x60}, 78 {0x4a, 0x80}, 79 {0x4b, 0x04}, 80 {0x4d, 0x91}, 81 {0x5d, 0xc8}, 82 {0x50, 0x36}, 83 {0x51, 0x36}, 84 {0x52, 0x36}, 85 {0x53, 0x36}, 86 {0x56, 0x01}, 87 {0x63, 0x0f}, 88 {0x64, 0x30}, 89 {0x65, 0x40}, 90 {0x68, 0x26}, 91 {0x69, 0x4c}, 92 {0x70, 0x20}, 93 {0x71, 0x70}, 94 {0x72, 0x04}, 95 {0x73, 0x00}, 96 {0x70, 0x40}, 97 {0x71, 0x70}, 98 {0x72, 0x04}, 99 {0x73, 0x00}, 100 {0x70, 0x60}, 101 {0x71, 0x70}, 102 {0x72, 0x04}, 103 {0x73, 0x00}, 104 {0x70, 0x80}, 105 {0x71, 0x70}, 106 {0x72, 0x04}, 107 {0x73, 0x00}, 108 {0x70, 0xa0}, 109 {0x71, 0x70}, 110 {0x72, 0x04}, 111 {0x73, 0x00}, 112 {0x70, 0x1f}, 113 {0x76, 0x38}, 114 {0x77, 0xa6}, 115 {0x78, 0x0c}, 116 {0x79, 0x80}, 117 {0x7f, 0x14}, 118 {0x7c, 0x00}, 119 {0xae, 0x82}, 120 {0x80, 0x64}, 121 {0x81, 0x66}, 122 {0x82, 0x44}, 123 {0x85, 0x04}, 124 {0xcd, 0xf4}, 125 {0x90, 0x33}, 126 {0xa0, 0x44}, 127 {0xc0, 0x08}, 128 {0xc3, 0x10}, 129 {0xc4, 0x08}, 130 {0xc5, 0xf0}, 131 {0xc6, 0xff}, 132 {0xc7, 0x00}, 133 {0xc8, 0x1a}, 134 {0xc9, 0x80}, 135 {0xe0, 0xf8}, 136 {0xe6, 0x8b}, 137 {0xd0, 0x40}, 138 {0xf8, 0x20}, 139 {0xfa, 0x0f}, 140 {0x00, 0x00}, 141 {0xbd, 0x01}, 142 {0xb8, 0x00}, 143 }; 144 145 static const struct m88ds3103_reg_val m88ds3103_dvbs2_init_reg_vals[] = { 146 {0x23, 0x07}, 147 {0x08, 0x07}, 148 {0x0c, 0x02}, 149 {0x21, 0x54}, 150 {0x25, 0x8a}, 151 {0x27, 0x31}, 152 {0x30, 0x08}, 153 {0x32, 0x32}, 154 {0x35, 0xff}, 155 {0x3a, 0x00}, 156 {0x37, 0x10}, 157 {0x38, 0x10}, 158 {0x39, 0x02}, 159 {0x42, 0x60}, 160 {0x4a, 0x80}, 161 {0x4b, 0x04}, 162 {0x4d, 0x91}, 163 {0x5d, 0xc8}, 164 {0x50, 0x36}, 165 {0x51, 0x36}, 166 {0x52, 0x36}, 167 {0x53, 0x36}, 168 {0x56, 0x01}, 169 {0x63, 0x0f}, 170 {0x64, 0x10}, 171 {0x65, 0x20}, 172 {0x68, 0x46}, 173 {0x69, 0xcd}, 174 {0x70, 0x20}, 175 {0x71, 0x70}, 176 {0x72, 0x04}, 177 {0x73, 0x00}, 178 {0x70, 0x40}, 179 {0x71, 0x70}, 180 {0x72, 0x04}, 181 {0x73, 0x00}, 182 {0x70, 0x60}, 183 {0x71, 0x70}, 184 {0x72, 0x04}, 185 {0x73, 0x00}, 186 {0x70, 0x80}, 187 {0x71, 0x70}, 188 {0x72, 0x04}, 189 {0x73, 0x00}, 190 {0x70, 0xa0}, 191 {0x71, 0x70}, 192 {0x72, 0x04}, 193 {0x73, 0x00}, 194 {0x70, 0x1f}, 195 {0x76, 0x38}, 196 {0x77, 0xa6}, 197 {0x78, 0x0c}, 198 {0x79, 0x80}, 199 {0x7f, 0x14}, 200 {0x85, 0x08}, 201 {0xcd, 0xf4}, 202 {0x90, 0x33}, 203 {0x86, 0x00}, 204 {0x87, 0x0f}, 205 {0x89, 0x00}, 206 {0x8b, 0x44}, 207 {0x8c, 0x66}, 208 {0x9d, 0xc1}, 209 {0x8a, 0x10}, 210 {0xad, 0x40}, 211 {0xa0, 0x44}, 212 {0xc0, 0x08}, 213 {0xc1, 0x10}, 214 {0xc2, 0x08}, 215 {0xc3, 0x10}, 216 {0xc4, 0x08}, 217 {0xc5, 0xf0}, 218 {0xc6, 0xff}, 219 {0xc7, 0x00}, 220 {0xc8, 0x1a}, 221 {0xc9, 0x80}, 222 {0xca, 0x23}, 223 {0xcb, 0x24}, 224 {0xcc, 0xf4}, 225 {0xce, 0x74}, 226 {0x00, 0x00}, 227 {0xbd, 0x01}, 228 {0xb8, 0x00}, 229 }; 230 231 static const struct m88ds3103_reg_val m88rs6000_dvbs_init_reg_vals[] = { 232 {0x23, 0x07}, 233 {0x08, 0x03}, 234 {0x0c, 0x02}, 235 {0x20, 0x00}, 236 {0x21, 0x54}, 237 {0x25, 0x82}, 238 {0x27, 0x31}, 239 {0x30, 0x08}, 240 {0x31, 0x40}, 241 {0x32, 0x32}, 242 {0x33, 0x35}, 243 {0x35, 0xff}, 244 {0x3a, 0x00}, 245 {0x37, 0x10}, 246 {0x38, 0x10}, 247 {0x39, 0x02}, 248 {0x42, 0x60}, 249 {0x4a, 0x80}, 250 {0x4b, 0x04}, 251 {0x4d, 0x91}, 252 {0x5d, 0xc8}, 253 {0x50, 0x36}, 254 {0x51, 0x36}, 255 {0x52, 0x36}, 256 {0x53, 0x36}, 257 {0x63, 0x0f}, 258 {0x64, 0x30}, 259 {0x65, 0x40}, 260 {0x68, 0x26}, 261 {0x69, 0x4c}, 262 {0x70, 0x20}, 263 {0x71, 0x70}, 264 {0x72, 0x04}, 265 {0x73, 0x00}, 266 {0x70, 0x40}, 267 {0x71, 0x70}, 268 {0x72, 0x04}, 269 {0x73, 0x00}, 270 {0x70, 0x60}, 271 {0x71, 0x70}, 272 {0x72, 0x04}, 273 {0x73, 0x00}, 274 {0x70, 0x80}, 275 {0x71, 0x70}, 276 {0x72, 0x04}, 277 {0x73, 0x00}, 278 {0x70, 0xa0}, 279 {0x71, 0x70}, 280 {0x72, 0x04}, 281 {0x73, 0x00}, 282 {0x70, 0x1f}, 283 {0x76, 0x38}, 284 {0x77, 0xa6}, 285 {0x78, 0x0c}, 286 {0x79, 0x80}, 287 {0x7f, 0x14}, 288 {0x7c, 0x00}, 289 {0xae, 0x82}, 290 {0x80, 0x64}, 291 {0x81, 0x66}, 292 {0x82, 0x44}, 293 {0x85, 0x04}, 294 {0xcd, 0xf4}, 295 {0x90, 0x33}, 296 {0xa0, 0x44}, 297 {0xbe, 0x00}, 298 {0xc0, 0x08}, 299 {0xc3, 0x10}, 300 {0xc4, 0x08}, 301 {0xc5, 0xf0}, 302 {0xc6, 0xff}, 303 {0xc7, 0x00}, 304 {0xc8, 0x1a}, 305 {0xc9, 0x80}, 306 {0xe0, 0xf8}, 307 {0xe6, 0x8b}, 308 {0xd0, 0x40}, 309 {0xf8, 0x20}, 310 {0xfa, 0x0f}, 311 {0x00, 0x00}, 312 {0xbd, 0x01}, 313 {0xb8, 0x00}, 314 {0x29, 0x11}, 315 }; 316 317 static const struct m88ds3103_reg_val m88rs6000_dvbs2_init_reg_vals[] = { 318 {0x23, 0x07}, 319 {0x08, 0x07}, 320 {0x0c, 0x02}, 321 {0x20, 0x00}, 322 {0x21, 0x54}, 323 {0x25, 0x82}, 324 {0x27, 0x31}, 325 {0x30, 0x08}, 326 {0x32, 0x32}, 327 {0x33, 0x35}, 328 {0x35, 0xff}, 329 {0x3a, 0x00}, 330 {0x37, 0x10}, 331 {0x38, 0x10}, 332 {0x39, 0x02}, 333 {0x42, 0x60}, 334 {0x4a, 0x80}, 335 {0x4b, 0x04}, 336 {0x4d, 0x91}, 337 {0x5d, 0xc8}, 338 {0x50, 0x36}, 339 {0x51, 0x36}, 340 {0x52, 0x36}, 341 {0x53, 0x36}, 342 {0x63, 0x0f}, 343 {0x64, 0x10}, 344 {0x65, 0x20}, 345 {0x68, 0x46}, 346 {0x69, 0xcd}, 347 {0x70, 0x20}, 348 {0x71, 0x70}, 349 {0x72, 0x04}, 350 {0x73, 0x00}, 351 {0x70, 0x40}, 352 {0x71, 0x70}, 353 {0x72, 0x04}, 354 {0x73, 0x00}, 355 {0x70, 0x60}, 356 {0x71, 0x70}, 357 {0x72, 0x04}, 358 {0x73, 0x00}, 359 {0x70, 0x80}, 360 {0x71, 0x70}, 361 {0x72, 0x04}, 362 {0x73, 0x00}, 363 {0x70, 0xa0}, 364 {0x71, 0x70}, 365 {0x72, 0x04}, 366 {0x73, 0x00}, 367 {0x70, 0x1f}, 368 {0x76, 0x38}, 369 {0x77, 0xa6}, 370 {0x78, 0x0c}, 371 {0x79, 0x80}, 372 {0x7f, 0x14}, 373 {0x85, 0x08}, 374 {0xcd, 0xf4}, 375 {0x90, 0x33}, 376 {0x86, 0x00}, 377 {0x87, 0x0f}, 378 {0x89, 0x00}, 379 {0x8b, 0x44}, 380 {0x8c, 0x66}, 381 {0x9d, 0xc1}, 382 {0x8a, 0x10}, 383 {0xad, 0x40}, 384 {0xa0, 0x44}, 385 {0xbe, 0x00}, 386 {0xc0, 0x08}, 387 {0xc1, 0x10}, 388 {0xc2, 0x08}, 389 {0xc3, 0x10}, 390 {0xc4, 0x08}, 391 {0xc5, 0xf0}, 392 {0xc6, 0xff}, 393 {0xc7, 0x00}, 394 {0xc8, 0x1a}, 395 {0xc9, 0x80}, 396 {0xca, 0x23}, 397 {0xcb, 0x24}, 398 {0xcc, 0xf4}, 399 {0xce, 0x74}, 400 {0x00, 0x00}, 401 {0xbd, 0x01}, 402 {0xb8, 0x00}, 403 {0x29, 0x01}, 404 }; 405 406 static const struct m88ds3103_reg_val m88ds3103c_dvbs_init_reg_vals[] = { 407 {0x04, 0x10}, 408 {0x8a, 0x01}, 409 {0x16, 0xa7}, 410 {0x30, 0x08}, 411 {0x32, 0x32}, 412 {0x33, 0x35}, 413 {0x35, 0xff}, 414 {0x4a, 0x80}, 415 {0x4d, 0x93}, 416 {0xae, 0x09}, 417 {0x22, 0x01}, 418 {0x23, 0x00}, 419 {0x24, 0x00}, 420 {0x27, 0x07}, 421 {0x9c, 0x31}, 422 {0x9d, 0xc1}, 423 {0xcb, 0xf4}, 424 {0xca, 0x00}, 425 {0x7f, 0x04}, 426 {0x78, 0x0c}, 427 {0x85, 0x08}, 428 {0x08, 0x47}, 429 {0xf0, 0x03}, 430 {0xfa, 0x01}, 431 {0xf2, 0x00}, 432 {0xfa, 0x00}, 433 {0xe6, 0x00}, 434 {0xe7, 0xf3}, 435 {0x08, 0x43}, 436 {0xe0, 0xf8}, 437 {0x00, 0x00}, 438 {0xbd, 0x82}, 439 {0x80, 0xa8}, 440 {0x81, 0xea}, 441 {0xbe, 0xa1} 442 }; 443 444 #endif 445