m88ds3103_priv.h 6.3 KB

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