fc8150_bb.c 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821
  1. /*****************************************************************************
  2. Copyright(c) 2012 FCI Inc. All Rights Reserved
  3. File name : fc8150_bb.c
  4. Description : API of 1-SEG baseband module
  5. *******************************************************************************/
  6. #include <linux/delay.h>
  7. #include "fci_types.h"
  8. #include "fci_oal.h"
  9. #include "fci_hal.h"
  10. #include "fci_tun.h"
  11. #include "fc8150_regs.h"
  12. static u8 filter_coef_6M[7][16] = {
  13. { 0x00, 0x00, 0x00, 0x07, 0x0f, 0x01, 0x03, 0x04
  14. , 0x01, 0x19, 0x14, 0x18, 0x0a, 0x26, 0x40, 0x4a},
  15. /*xtal_in : 24,16,32 (adc clk = 4.0000)*/
  16. { 0x00, 0x07, 0x07, 0x00, 0x01, 0x03, 0x03, 0x01
  17. , 0x1c, 0x17, 0x16, 0x1e, 0x10, 0x27, 0x3b, 0x43},
  18. /*xtal_in : 26 (adc clk = 4.3333)*/
  19. { 0x00, 0x07, 0x07, 0x00, 0x01, 0x03, 0x03, 0x00
  20. , 0x1b, 0x16, 0x16, 0x1f, 0x11, 0x27, 0x3a, 0x41},
  21. /*xtal_in : 27,18 (adc clk = 4.5000)*/
  22. { 0x00, 0x00, 0x07, 0x07, 0x00, 0x02, 0x03, 0x03
  23. , 0x1f, 0x18, 0x14, 0x1a, 0x0c, 0x26, 0x3e, 0x47},
  24. /*xtal_in : 16.384, 24.576 (adc clk = 4.0960)*/
  25. { 0x00, 0x07, 0x07, 0x00, 0x02, 0x03, 0x02, 0x0f
  26. , 0x1a, 0x16, 0x18, 0x02, 0x13, 0x27, 0x38, 0x3e},
  27. /*xtal_in : 19.2, 38.4 (adc clk = 4.8000)*/
  28. { 0x00, 0x07, 0x07, 0x00, 0x01, 0x03, 0x03, 0x00
  29. , 0x1b, 0x16, 0x16, 0x1f, 0x11, 0x27, 0x3a, 0x41},
  30. /*xtal_in : 27.12 (adc clk = 4.5200)*/
  31. { 0x00, 0x07, 0x07, 0x00, 0x02, 0x03, 0x03, 0x00
  32. , 0x1a, 0x16, 0x17, 0x01, 0x12, 0x27, 0x39, 0x3f}
  33. /*xtal_in : 37.4 (adc clk = 4.6750)*/
  34. };
  35. #if 0
  36. static u8 filter_coef_7M[7][16] = {
  37. { 0x00, 0x00, 0x00, 0x00, 0x0f, 0x0e, 0x00, 0x04, 0x05
  38. , 0x1f, 0x15, 0x12, 0x01, 0x22, 0x45, 0x55},
  39. /*xtal_in : 24,16,32 (adc clk = 4.0000)*/
  40. { 0x00, 0x00, 0x00, 0x07, 0x0e, 0x0f, 0x02, 0x05, 0x04
  41. , 0x1c, 0x14, 0x14, 0x05, 0x24, 0x43, 0x50},
  42. /*xtal_in : 26 (adc clk = 4.3333)*/
  43. { 0x00, 0x00, 0x00, 0x07, 0x0f, 0x00, 0x03, 0x05, 0x02
  44. , 0x1b, 0x14, 0x16, 0x07, 0x25, 0x42, 0x4d},
  45. /*xtal_in : 27,18 (adc clk = 4.5000)*/
  46. { 0x00, 0x00, 0x00, 0x00, 0x0f, 0x0f, 0x01, 0x04, 0x05
  47. , 0x1e, 0x15, 0x13, 0x02, 0x23, 0x44, 0x53},
  48. /*xtal_in : 16.384, 24.576 (adc clk = 4.0960)*/
  49. { 0x00, 0x00, 0x07, 0x07, 0x00, 0x02, 0x04, 0x03, 0x1f
  50. , 0x18, 0x14, 0x1a, 0x0c, 0x26, 0x3e, 0x47},
  51. /*xtal_in : 19.2, 38.4 (adc clk = 4.8000)*/
  52. { 0x00, 0x00, 0x00, 0x07, 0x0f, 0x00, 0x03, 0x05, 0x02
  53. , 0x1b, 0x14, 0x16, 0x07, 0x25, 0x41, 0x4d},
  54. /*xtal_in : 27.12 (adc clk = 4.5200)*/
  55. { 0x00, 0x00, 0x00, 0x07, 0x0f, 0x01, 0x03, 0x04, 0x00
  56. , 0x19, 0x14, 0x18, 0x0a, 0x26, 0x3f, 0x4a}
  57. /*xtal_in : 37.4 (adc clk = 4.6750)*/
  58. };
  59. static u8 filter_coef_8M[7][16] = {
  60. { 0x00, 0x00, 0x00, 0x01, 0x01, 0x0f, 0x0d, 0x0f, 0x05
  61. , 0x06, 0x1d, 0x10, 0xf6, 0x1a, 0x4b, 0x62},
  62. /*xtal_in : 24,16,32 (adc clk = 4.0000)*/
  63. { 0x00, 0x00, 0x00, 0x01, 0x00, 0x0e, 0x0e, 0x02, 0x06
  64. , 0x04, 0x19, 0x10, 0xfb, 0x1e, 0x48, 0x5b},
  65. /*xtal_in : 26 (adc clk = 4.3333)*/
  66. { 0x00, 0x00, 0x00, 0x00, 0x0f, 0x0e, 0x00, 0x03, 0x05
  67. , 0x00, 0x16, 0x11, 0xff, 0x21, 0x46, 0x56},
  68. /*xtal_in : 27,18 (adc clk = 4.5000)*/
  69. { 0x00, 0x00, 0x00, 0x01, 0x00, 0x0f, 0x0d, 0x00, 0x05
  70. , 0x06, 0x1c, 0x10, 0xf7, 0x1b, 0x4a, 0x60},
  71. /*xtal_in : 16.384, 24.576 (adc clk = 4.0960)*/
  72. { 0x00, 0x00, 0x00, 0x07, 0x0e, 0x0f, 0x01, 0x05, 0x04
  73. , 0x1d, 0x14, 0x13, 0x04, 0x23, 0x44, 0x51},
  74. /*xtal_in : 19.2, 38.4 (adc clk = 4.8000)*/
  75. { 0x00, 0x00, 0x00, 0x00, 0x0f, 0x0e, 0x00, 0x04, 0x05
  76. , 0x00, 0x16, 0x12, 0x00, 0x21, 0x46, 0x56},
  77. /*xtal_in : 27.12 (adc clk = 4.5200)*/
  78. { 0x00, 0x00, 0x00, 0x00, 0x0f, 0x0f, 0x01, 0x04, 0x05
  79. , 0x1e, 0x15, 0x13, 0x02, 0x23, 0x44, 0x53}
  80. /*xtal_in : 37.4 (adc clk = 4.6750)*/
  81. };
  82. #endif
  83. static void fc8150_clock_mode(HANDLE hDevice)
  84. {
  85. int i;
  86. #if (BBM_XTAL_FREQ == 16000)
  87. bbm_write(hDevice, 0x0016, 0);
  88. #if (BBM_BAND_WIDTH == 6)
  89. bbm_word_write(hDevice, 0x1032, 0x30a4);
  90. bbm_long_write(hDevice, 0x103c, 0x1f800000);
  91. bbm_write(hDevice, 0x200a, 0x04);
  92. bbm_write(hDevice, 0x2009, 0x10);
  93. bbm_write(hDevice, 0x2008, 0x41);
  94. for (i = 0; i < 16; i++)
  95. bbm_write(hDevice, 0x1040+i, filter_coef_6M[0][i]);
  96. #elif (BBM_BAND_WIDTH == 7)
  97. bbm_word_write(hDevice, 0x1032, 0x30a4);
  98. bbm_long_write(hDevice, 0x103c, 0x1b000000);
  99. bbm_write(hDevice, 0x200a, 0x04);
  100. bbm_write(hDevice, 0x2009, 0xbd);
  101. bbm_write(hDevice, 0x2008, 0xa1);
  102. for (i = 0; i < 16; i++)
  103. bbm_write(hDevice, 0x1040+i, filter_coef_7M[0][i]);
  104. #else
  105. bbm_word_write(hDevice, 0x1032, 0x3ae1);
  106. bbm_long_write(hDevice, 0x103c, 0x17a00000);
  107. bbm_write(hDevice, 0x200a, 0x05);
  108. bbm_write(hDevice, 0x2009, 0x6b);
  109. bbm_write(hDevice, 0x2008, 0x01);
  110. for (i = 0; i < 16; i++)
  111. bbm_write(hDevice, 0x1040+i, filter_coef_8M[0][i]);
  112. #endif
  113. #elif (BBM_XTAL_FREQ == 16384)
  114. bbm_write(hDevice, 0x0016, 0);
  115. #if (BBM_BAND_WIDTH == 6)
  116. bbm_word_write(hDevice, 0x1032, 0x2f80);
  117. bbm_long_write(hDevice, 0x103c, 0x20418937);
  118. bbm_write(hDevice, 0x200a, 0x03);
  119. bbm_write(hDevice, 0x2009, 0xf7);
  120. bbm_write(hDevice, 0x2008, 0xdf);
  121. for (i = 0; i < 16; i++)
  122. bbm_write(hDevice, 0x1040+i, filter_coef_6M[3][i]);
  123. #elif (BBM_BAND_WIDTH == 7)
  124. bbm_word_write(hDevice, 0x1032, 0x2f80);
  125. bbm_long_write(hDevice, 0x103c, 0x1ba5e354);
  126. bbm_write(hDevice, 0x200a, 0x04);
  127. bbm_write(hDevice, 0x2009, 0xa1);
  128. bbm_write(hDevice, 0x2008, 0x2f);
  129. for (i = 0; i < 16; i++)
  130. bbm_write(hDevice, 0x1040+i, filter_coef_7M[3][i]);
  131. #else
  132. bbm_word_write(hDevice, 0x1032, 0x3980);
  133. bbm_long_write(hDevice, 0x103c, 0x183126e9);
  134. bbm_write(hDevice, 0x200a, 0x05);
  135. bbm_write(hDevice, 0x2009, 0x4a);
  136. bbm_write(hDevice, 0x2008, 0x7f);
  137. for (i = 0; i < 16; i++)
  138. bbm_write(hDevice, 0x1040+i, filter_coef_8M[3][i]);
  139. #endif
  140. #elif (BBM_XTAL_FREQ == 18000)
  141. bbm_write(hDevice, 0x0016, 0);
  142. #if (BBM_BAND_WIDTH == 6)
  143. bbm_word_write(hDevice, 0x1032, 0x2b3c);
  144. bbm_long_write(hDevice, 0x103c, 0x23700000);
  145. bbm_write(hDevice, 0x200a, 0x03);
  146. bbm_write(hDevice, 0x2009, 0x9c);
  147. bbm_write(hDevice, 0x2008, 0xac);
  148. for (i = 0; i < 16; i++)
  149. bbm_write(hDevice, 0x1040+i, filter_coef_6M[2][i]);
  150. #elif (BBM_BAND_WIDTH == 7)
  151. bbm_word_write(hDevice, 0x1032, 0x2b3c);
  152. bbm_long_write(hDevice, 0x103c, 0x1e600000);
  153. bbm_write(hDevice, 0x200a, 0x04);
  154. bbm_write(hDevice, 0x2009, 0x36);
  155. bbm_write(hDevice, 0x2008, 0xc8);
  156. for (i = 0; i < 16; i++)
  157. bbm_write(hDevice, 0x1040+i, filter_coef_7M[2][i]);
  158. #else
  159. bbm_word_write(hDevice, 0x1032, 0x3456);
  160. bbm_long_write(hDevice, 0x103c, 0x1a940000);
  161. bbm_write(hDevice, 0x200a, 0x04);
  162. bbm_write(hDevice, 0x2009, 0xd0);
  163. bbm_write(hDevice, 0x2008, 0xe5);
  164. for (i = 0; i < 16; i++)
  165. bbm_write(hDevice, 0x1040+i, filter_coef_8M[2][i]);
  166. #endif
  167. #elif (BBM_XTAL_FREQ == 19200)
  168. bbm_write(hDevice, 0x0016, 0);
  169. #if (BBM_BAND_WIDTH == 6)
  170. bbm_word_write(hDevice, 0x1032, 0x2889);
  171. bbm_long_write(hDevice, 0x103c, 0x25cccccd);
  172. bbm_write(hDevice, 0x200a, 0x03);
  173. bbm_write(hDevice, 0x2009, 0x62);
  174. bbm_write(hDevice, 0x2008, 0xe1);
  175. for (i = 0; i < 16; i++)
  176. bbm_write(hDevice, 0x1040+i, filter_coef_6M[4][i]);
  177. #elif (BBM_BAND_WIDTH == 7)
  178. bbm_word_write(hDevice, 0x1032, 0x2889);
  179. bbm_long_write(hDevice, 0x103c, 0x20666666);
  180. bbm_write(hDevice, 0x200a, 0x03);
  181. bbm_write(hDevice, 0x2009, 0xf3);
  182. bbm_write(hDevice, 0x2008, 0x5c);
  183. for (i = 0; i < 16; i++)
  184. bbm_write(hDevice, 0x1040+i, filter_coef_7M[4][i]);
  185. #else
  186. bbm_word_write(hDevice, 0x1032, 0x3111);
  187. bbm_long_write(hDevice, 0x103c, 0x1c59999a);
  188. bbm_write(hDevice, 0x200a, 0x04);
  189. bbm_write(hDevice, 0x2009, 0x83);
  190. bbm_write(hDevice, 0x2008, 0xd6);
  191. for (i = 0; i < 16; i++)
  192. bbm_write(hDevice, 0x1040+i, filter_coef_8M[4][i]);
  193. #endif
  194. #elif (BBM_XTAL_FREQ == 24000)
  195. bbm_write(hDevice, 0x0016, 2);
  196. #if (BBM_BAND_WIDTH == 6)
  197. bbm_word_write(hDevice, 0x1032, 0x30a4);
  198. bbm_long_write(hDevice, 0x103c, 0x1f800000);
  199. bbm_write(hDevice, 0x200a, 0x04);
  200. bbm_write(hDevice, 0x2009, 0x10);
  201. bbm_write(hDevice, 0x2008, 0x41);
  202. for (i = 0; i < 16; i++)
  203. bbm_write(hDevice, 0x1040+i, filter_coef_6M[0][i]);
  204. #elif (BBM_BAND_WIDTH == 7)
  205. bbm_word_write(hDevice, 0x1032, 0x30a4);
  206. bbm_long_write(hDevice, 0x103c, 0x1b000000);
  207. bbm_write(hDevice, 0x200a, 0x04);
  208. bbm_write(hDevice, 0x2009, 0xbd);
  209. bbm_write(hDevice, 0x2008, 0xa1);
  210. for (i = 0; i < 16; i++)
  211. bbm_write(hDevice, 0x1040+i, filter_coef_7M[0][i]);
  212. #else
  213. bbm_word_write(hDevice, 0x1032, 0x3ae1);
  214. bbm_long_write(hDevice, 0x103c, 0x17a00000);
  215. bbm_write(hDevice, 0x200a, 0x05);
  216. bbm_write(hDevice, 0x2009, 0x6b);
  217. bbm_write(hDevice, 0x2008, 0x01);
  218. for (i = 0; i < 16; i++)
  219. bbm_write(hDevice, 0x1040+i, filter_coef_8M[0][i]);
  220. #endif
  221. #elif (BBM_XTAL_FREQ == 26000)
  222. bbm_write(hDevice, 0x0016, 2);
  223. #if (BBM_BAND_WIDTH == 6)
  224. bbm_word_write(hDevice, 0x1032, 0x2ce6);
  225. bbm_long_write(hDevice, 0x103c, 0x221fffd4);
  226. bbm_write(hDevice, 0x200a, 0x03);
  227. bbm_write(hDevice, 0x2009, 0xc0);
  228. bbm_write(hDevice, 0x2008, 0x3c);
  229. for (i = 0; i < 16; i++)
  230. bbm_write(hDevice, 0x1040+i, filter_coef_6M[1][i]);
  231. #elif (BBM_BAND_WIDTH == 7)
  232. bbm_word_write(hDevice, 0x1032, 0x2ce6);
  233. bbm_long_write(hDevice, 0x103c, 0x1d3fffda);
  234. bbm_write(hDevice, 0x200a, 0x04);
  235. bbm_write(hDevice, 0x2009, 0x60);
  236. bbm_write(hDevice, 0x2008, 0x46);
  237. for (i = 0; i < 16; i++)
  238. bbm_write(hDevice, 0x1040+i, filter_coef_7M[1][i]);
  239. #else
  240. bbm_word_write(hDevice, 0x1032, 0x365a);
  241. bbm_long_write(hDevice, 0x103c, 0x1997ffdf);
  242. bbm_write(hDevice, 0x200a, 0x05);
  243. bbm_write(hDevice, 0x2009, 0x00);
  244. bbm_write(hDevice, 0x2008, 0x50);
  245. for (i = 0; i < 16; i++)
  246. bbm_write(hDevice, 0x1040+i, filter_coef_8M[1][i]);
  247. #endif
  248. #elif (BBM_XTAL_FREQ == 27000)
  249. bbm_write(hDevice, 0x0016, 2);
  250. #if (BBM_BAND_WIDTH == 6)
  251. bbm_word_write(hDevice, 0x1032, 0x2b3c);
  252. bbm_long_write(hDevice, 0x103c, 0x23700000);
  253. bbm_write(hDevice, 0x200a, 0x03);
  254. bbm_write(hDevice, 0x2009, 0x9c);
  255. bbm_write(hDevice, 0x2008, 0xac);
  256. for (i = 0; i < 16; i++)
  257. bbm_write(hDevice, 0x1040+i, filter_coef_6M[2][i]);
  258. #elif (BBM_BAND_WIDTH == 7)
  259. bbm_word_write(hDevice, 0x1032, 0x2b3c);
  260. bbm_long_write(hDevice, 0x103c, 0x1e600000);
  261. bbm_write(hDevice, 0x200a, 0x04);
  262. bbm_write(hDevice, 0x2009, 0x36);
  263. bbm_write(hDevice, 0x2008, 0xc8);
  264. for (i = 0; i < 16; i++)
  265. bbm_write(hDevice, 0x1040+i, filter_coef_7M[2][i]);
  266. #else
  267. bbm_word_write(hDevice, 0x1032, 0x3456);
  268. bbm_long_write(hDevice, 0x103c, 0x1a940000);
  269. bbm_write(hDevice, 0x200a, 0x04);
  270. bbm_write(hDevice, 0x2009, 0xd0);
  271. bbm_write(hDevice, 0x2008, 0xe5);
  272. for (i = 0; i < 16; i++)
  273. bbm_write(hDevice, 0x1040+i, filter_coef_8M[2][i]);
  274. #endif
  275. #elif (BBM_XTAL_FREQ == 27120)
  276. bbm_write(hDevice, 0x0016, 2);
  277. #if (BBM_BAND_WIDTH == 6)
  278. bbm_word_write(hDevice, 0x1032, 0x2b0b);
  279. bbm_long_write(hDevice, 0x103c, 0x239851ec);
  280. bbm_write(hDevice, 0x200a, 0x03);
  281. bbm_write(hDevice, 0x2009, 0x98);
  282. bbm_write(hDevice, 0x2008, 0x94);
  283. for (i = 0; i < 16; i++)
  284. bbm_write(hDevice, 0x1040+i, filter_coef_6M[5][i]);
  285. #elif (BBM_BAND_WIDTH == 7)
  286. bbm_word_write(hDevice, 0x1032, 0x2b0b);
  287. bbm_long_write(hDevice, 0x103c, 0x1e828f5c);
  288. bbm_write(hDevice, 0x200a, 0x04);
  289. bbm_write(hDevice, 0x2009, 0x32);
  290. bbm_write(hDevice, 0x2008, 0x02);
  291. for (i = 0; i < 16; i++)
  292. bbm_write(hDevice, 0x1040+i, filter_coef_7M[5][i]);
  293. #else
  294. bbm_word_write(hDevice, 0x1032, 0x341b);
  295. bbm_long_write(hDevice, 0x103c, 0x1ab23d71);
  296. bbm_write(hDevice, 0x200a, 0x04);
  297. bbm_write(hDevice, 0x2009, 0xcb);
  298. bbm_write(hDevice, 0x2008, 0x70);
  299. for (i = 0; i < 16; i++)
  300. bbm_write(hDevice, 0x1040+i, filter_coef_8M[5][i]);
  301. #endif
  302. #elif (BBM_XTAL_FREQ == 24576)
  303. bbm_write(hDevice, 0x0016, 2);
  304. #if (BBM_BAND_WIDTH == 6)
  305. bbm_word_write(hDevice, 0x1032, 0x2f80);
  306. bbm_long_write(hDevice, 0x103c, 0x20418937);
  307. bbm_write(hDevice, 0x200a, 0x03);
  308. bbm_write(hDevice, 0x2009, 0xf7);
  309. bbm_write(hDevice, 0x2008, 0xdf);
  310. for (i = 0; i < 16; i++)
  311. bbm_write(hDevice, 0x1040+i, filter_coef_6M[3][i]);
  312. #elif (BBM_BAND_WIDTH == 7)
  313. bbm_word_write(hDevice, 0x1032, 0x2f80);
  314. bbm_long_write(hDevice, 0x103c, 0x1ba5e354);
  315. bbm_write(hDevice, 0x200a, 0x04);
  316. bbm_write(hDevice, 0x2009, 0xa1);
  317. bbm_write(hDevice, 0x2008, 0x2f);
  318. for (i = 0; i < 16; i++)
  319. bbm_write(hDevice, 0x1040+i, filter_coef_7M[3][i]);
  320. #else
  321. bbm_word_write(hDevice, 0x1032, 0x3980);
  322. bbm_long_write(hDevice, 0x103c, 0x183126e9);
  323. bbm_write(hDevice, 0x200a, 0x05);
  324. bbm_write(hDevice, 0x2009, 0x4a);
  325. bbm_write(hDevice, 0x2008, 0x7f);
  326. for (i = 0; i < 16; i++)
  327. bbm_write(hDevice, 0x1040+i, filter_coef_8M[3][i]);
  328. #endif
  329. #elif (BBM_XTAL_FREQ == 32000)
  330. /* Default Clock */
  331. bbm_write(hDevice, 0x0016, 1);
  332. #if (BBM_BAND_WIDTH == 6)
  333. /* Default Band-width */
  334. bbm_word_write(hDevice, 0x1032, 0x30a4);
  335. bbm_long_write(hDevice, 0x103c, 0x1f800000);
  336. bbm_write(hDevice, 0x200a, 0x04);
  337. bbm_write(hDevice, 0x2009, 0x10);
  338. bbm_write(hDevice, 0x2008, 0x41);
  339. for (i = 0; i < 16; i++)
  340. bbm_write(hDevice, 0x1040+i, filter_coef_6M[0][i]);
  341. #elif (BBM_BAND_WIDTH == 7)
  342. bbm_word_write(hDevice, 0x1032, 0x30a4);
  343. bbm_long_write(hDevice, 0x103c, 0x1b000000);
  344. bbm_write(hDevice, 0x200a, 0x04);
  345. bbm_write(hDevice, 0x2009, 0xbd);
  346. bbm_write(hDevice, 0x2008, 0xa1);
  347. for (i = 0; i < 16; i++)
  348. bbm_write(hDevice, 0x1040+i, filter_coef_7M[0][i]);
  349. #else
  350. bbm_word_write(hDevice, 0x1032, 0x3ae1);
  351. bbm_long_write(hDevice, 0x103c, 0x17a00000);
  352. bbm_write(hDevice, 0x200a, 0x05);
  353. bbm_write(hDevice, 0x2009, 0x6b);
  354. bbm_write(hDevice, 0x2008, 0x01);
  355. for (i = 0; i < 16; i++)
  356. bbm_write(hDevice, 0x1040+i, filter_coef_8M[0][i]);
  357. #endif
  358. #elif (BBM_XTAL_FREQ == 37400)
  359. bbm_write(hDevice, 0x0016, 1);
  360. #if (BBM_BAND_WIDTH == 6)
  361. bbm_word_write(hDevice, 0x1032, 0x299e);
  362. bbm_long_write(hDevice, 0x103c, 0x24d0cccd);
  363. bbm_write(hDevice, 0x200a, 0x03);
  364. bbm_write(hDevice, 0x2009, 0x7a);
  365. bbm_write(hDevice, 0x2008, 0x0f);
  366. for (i = 0; i < 16; i++)
  367. bbm_write(hDevice, 0x1040+i, filter_coef_6M[6][i]);
  368. #elif (BBM_BAND_WIDTH == 7)
  369. bbm_word_write(hDevice, 0x1032, 0x299e);
  370. bbm_long_write(hDevice, 0x103c, 0x1f8e6666);
  371. bbm_write(hDevice, 0x200a, 0x04);
  372. bbm_write(hDevice, 0x2009, 0x0e);
  373. bbm_write(hDevice, 0x2008, 0x66);
  374. for (i = 0; i < 16; i++)
  375. bbm_write(hDevice, 0x1040+i, filter_coef_7M[6][i]);
  376. #else
  377. bbm_word_write(hDevice, 0x1032, 0x3261);
  378. bbm_long_write(hDevice, 0x103c, 0x1b9c999a);
  379. bbm_write(hDevice, 0x200a, 0x04);
  380. bbm_write(hDevice, 0x2009, 0xa2);
  381. bbm_write(hDevice, 0x2008, 0xbe);
  382. for (i = 0; i < 16; i++)
  383. bbm_write(hDevice, 0x1040+i, filter_coef_8M[6][i]);
  384. #endif
  385. #elif (BBM_XTAL_FREQ == 38400)
  386. bbm_write(hDevice, 0x0016, 1);
  387. #if (BBM_BAND_WIDTH == 6)
  388. bbm_word_write(hDevice, 0x1032, 0x2889);
  389. bbm_long_write(hDevice, 0x103c, 0x25cccccd);
  390. bbm_write(hDevice, 0x200a, 0x03);
  391. bbm_write(hDevice, 0x2009, 0x62);
  392. bbm_write(hDevice, 0x2008, 0xe1);
  393. for (i = 0; i < 16; i++)
  394. bbm_write(hDevice, 0x1040+i, filter_coef_6M[4][i]);
  395. #elif (BBM_BAND_WIDTH == 7)
  396. bbm_word_write(hDevice, 0x1032, 0x2889);
  397. bbm_long_write(hDevice, 0x103c, 0x20666666);
  398. bbm_write(hDevice, 0x200a, 0x03);
  399. bbm_write(hDevice, 0x2009, 0xf3);
  400. bbm_write(hDevice, 0x2008, 0x5c);
  401. for (i = 0; i < 16; i++)
  402. bbm_write(hDevice, 0x1040+i, filter_coef_7M[4][i]);
  403. #else
  404. bbm_word_write(hDevice, 0x1032, 0x3111);
  405. bbm_long_write(hDevice, 0x103c, 0x1c59999a);
  406. bbm_write(hDevice, 0x200a, 0x04);
  407. bbm_write(hDevice, 0x2009, 0x83);
  408. bbm_write(hDevice, 0x2008, 0xd6);
  409. for (i = 0; i < 16; i++)
  410. bbm_write(hDevice, 0x1040+i, filter_coef_8M[4][i]);
  411. #endif
  412. #endif
  413. }
  414. int fc8150_reset(HANDLE hDevice)
  415. {
  416. bbm_write(hDevice, BBM_SW_RESET, 0x7f);
  417. bbm_write(hDevice, BBM_SW_RESET, 0xff);
  418. return BBM_OK;
  419. }
  420. int fc8150_probe(HANDLE hDevice)
  421. {
  422. u16 ver;
  423. bbm_word_read(hDevice, BBM_CHIP_ID_L, &ver);
  424. return (ver == 0x8150) ? BBM_OK : BBM_NOK;
  425. }
  426. int fc8150_init(HANDLE hDevice)
  427. {
  428. printk(KERN_ERR "ISDBT fc8150_init \n");
  429. bbm_write(hDevice, 0x00b0, 0x03);
  430. bbm_write(hDevice, 0x00b1, 0x00);
  431. bbm_write(hDevice, 0x00b2, 0x05);
  432. fc8150_reset(hDevice);
  433. fc8150_clock_mode(hDevice);
  434. bbm_write(hDevice, 0x1000, 0x27);
  435. bbm_write(hDevice, 0x1004, 0x4d);
  436. bbm_write(hDevice, 0x1069, 0x09);
  437. bbm_write(hDevice, 0x1075, 0x00);
  438. bbm_write(hDevice, 0x1083, 0x14);
  439. bbm_write(hDevice, 0x1084, 0x0f);
  440. bbm_word_write(hDevice, 0x00b4, 0x0000);
  441. /*bbm_write(hDevice, 0x00b6, 0x03);*/ /* Default 0x03, 0x00, 0x07*/
  442. bbm_write(hDevice, 0x00b9, 0x00);
  443. bbm_write(hDevice, 0x00ba, 0x01);
  444. bbm_write(hDevice, 0x2004, 0x41);
  445. bbm_write(hDevice, 0x2106, 0x1f);
  446. bbm_write(hDevice, 0x5010, 0x00);
  447. bbm_write(hDevice, BBM_RS_FAIL_TX, 0x00); /* RS FAILURE TX: 0x02 original:0x00*/
  448. bbm_word_write(hDevice, BBM_BUF_TS_START, TS_BUF_START);
  449. bbm_word_write(hDevice, BBM_BUF_TS_END, TS_BUF_END);
  450. bbm_word_write(hDevice, BBM_BUF_TS_THR, TS_BUF_THR);
  451. /*bbm_word_write(hDevice, BBM_BUF_AC_START, AC_BUF_START);*/
  452. /*bbm_word_write(hDevice, BBM_BUF_AC_END, AC_BUF_END);*/
  453. /*bbm_word_write(hDevice, BBM_BUF_AC_THR, AC_BUF_THR);*/
  454. /*bbm_write(hDevice, BBM_INT_POLAR_SEL, 0x00);*/
  455. bbm_write(hDevice, BBM_INT_AUTO_CLEAR, 0x01);
  456. #ifdef FEATURE_INT_AUTO_MODE
  457. bbm_write(hDevice, BBM_STATUS_AUTO_CLEAR_EN, 0x00);
  458. #endif
  459. bbm_write(hDevice, BBM_BUF_ENABLE, 0x01);
  460. bbm_write(hDevice, BBM_BUF_INT, 0x01);
  461. bbm_write(hDevice, BBM_INT_MASK, 0x07);
  462. #ifdef BBM_I2C_TSIF
  463. bbm_write(hDevice, BBM_INT_STS_EN, 0x00);
  464. #else
  465. bbm_write(hDevice, BBM_INT_STS_EN, 0x01);
  466. #endif
  467. return BBM_OK;
  468. }
  469. int fc8150_deinit(HANDLE hDevice)
  470. {
  471. bbm_write(hDevice, BBM_SW_RESET, 0x00);
  472. printk(KERN_ERR "ISDBT fc8150_deinit \n");
  473. return BBM_OK;
  474. }
  475. int fc8150_scan_status(HANDLE hDevice)
  476. {
  477. u32 ifagc_timeout = 7;
  478. u32 ofdm_timeout = 16;
  479. u32 ffs_lock_timeout = 10;
  480. u32 dagc_timeout = 100; /* always done*/
  481. u32 cfs_timeout = 12;
  482. u32 tmcc_timeout = 105;
  483. u32 ts_err_free_timeout = 0;
  484. int rssi;
  485. u8 data, data1;
  486. u8 lay0_mod, lay0_cr;
  487. int i;
  488. printk(KERN_ERR "ISDBT fc8150_scan_status \n");
  489. for (i = 0; i < ifagc_timeout; i++) {
  490. bbm_read(hDevice, 0x3025, &data);
  491. printk(KERN_ERR "ifagc loop: data=0x%x\n",data);
  492. if (data & 0x01)
  493. break;
  494. msWait(10);
  495. }
  496. if (i == ifagc_timeout)
  497. return BBM_NOK;
  498. tuner_get_rssi(hDevice, &rssi);
  499. if (rssi < -107)
  500. return BBM_NOK;
  501. for (; i < ofdm_timeout; i++) {
  502. bbm_read(hDevice, 0x3025, &data);
  503. printk(KERN_ERR "ofdm loop: data=0x%x\n",data);
  504. if (data & 0x08)
  505. break;
  506. msWait(10);
  507. }
  508. if (i == ofdm_timeout)
  509. {
  510. printk(KERN_ERR "ISDBT ofdm_timeout \n");
  511. return BBM_NOK;
  512. }
  513. if (0 == (data & 0x04))
  514. return BBM_NOK;
  515. for (; i < ffs_lock_timeout; i++) {
  516. bbm_read(hDevice, 0x3026, &data);
  517. printk(KERN_ERR "ffs loop: data=0x%x\n",data);
  518. if (data & 0x10)
  519. break;
  520. msWait(10);
  521. }
  522. if (i == ffs_lock_timeout)
  523. {
  524. printk(KERN_ERR "ISDBT ffs_lock_timeout \n");
  525. return BBM_NOK;
  526. }
  527. /* DAGC Lock*/
  528. for (i = 0; i < dagc_timeout; i++) {
  529. bbm_read(hDevice, 0x3026, &data);
  530. if (data & 0x01)
  531. break;
  532. msWait(10);
  533. }
  534. if (i == dagc_timeout)
  535. return BBM_NOK;
  536. for (i = 0; i < cfs_timeout; i++) {
  537. bbm_read(hDevice, 0x3025, &data);
  538. printk(KERN_ERR "cfs loop: data=0x%x\n",data);
  539. if (data & 0x40)
  540. break;
  541. msWait(10);
  542. }
  543. if (i == cfs_timeout)
  544. {
  545. printk(KERN_ERR "ISDBT cfs_timeout \n");
  546. return BBM_NOK;
  547. }
  548. bbm_read(hDevice, 0x2023, &data1);
  549. if (data1 & 1)
  550. {
  551. printk(KERN_ERR "ISDBT data1 & 0x01 = 1 return BBM_NOK \n");
  552. return BBM_NOK;
  553. }
  554. for (i = 0; i < tmcc_timeout; i++) {
  555. bbm_read(hDevice, 0x3026, &data);
  556. printk(KERN_ERR "tmcc loop: data=0x%x\n",data);
  557. if (data & 0x02)
  558. break;
  559. msWait(10);
  560. }
  561. if (i == tmcc_timeout)
  562. {
  563. printk(KERN_ERR "ISDBT tmcc_timeout \n");
  564. return BBM_NOK;
  565. }
  566. bbm_read(hDevice, 0x4113, &data);
  567. bbm_read(hDevice, 0x4114, &data1);
  568. if (((data >> 3) & 0x1) == 0)
  569. return BBM_NOK;
  570. lay0_mod = ((data & 0x10) >> 2) |
  571. ((data & 0x20) >> 4) |
  572. ((data & 0x40) >> 6);
  573. lay0_cr = ((data & 0x80) >> 5) |
  574. ((data1 & 0x01) << 1) |
  575. ((data1 & 0x02) >> 1);
  576. if (!((lay0_mod == 1) || (lay0_mod == 2)))
  577. return BBM_NOK;
  578. if (((0x70 & data) == 0x40) && ((0x1c & data1) == 0x18))
  579. ts_err_free_timeout = 40;
  580. else
  581. ts_err_free_timeout = 65;
  582. for (i = 0; i < ts_err_free_timeout; i++) {
  583. bbm_read(hDevice, 0x5053, &data);
  584. printk(KERN_ERR "ts-err loop: data=0x%x\n",data);
  585. if (data & 0x01)
  586. break;
  587. msWait(10);
  588. }
  589. if (i == ts_err_free_timeout)
  590. {
  591. printk(KERN_ERR "ISDBT ts_err_free_timeout\n");
  592. return BBM_NOK;
  593. }
  594. return BBM_OK;
  595. }