m88ds3103_priv.h 6.8 KB

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