dragonmint_t1.c 57 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374
  1. /*
  2. * Copyright 2018 Con Kolivas <kernel@kolivas.org>
  3. *
  4. * This program is free software; you can redistribute it and/or modify it
  5. * under the terms of the GNU General Public License as published by the Free
  6. * Software Foundation; either version 3 of the License, or (at your option)
  7. * any later version. See COPYING for more details.
  8. */
  9. #include <stdlib.h>
  10. #include <assert.h>
  11. #include <fcntl.h>
  12. #include <limits.h>
  13. #include <unistd.h>
  14. #include <stdbool.h>
  15. #include "logging.h"
  16. #include "miner.h"
  17. #include "util.h"
  18. #include "dragonmint_t1.h"
  19. #include "dm_temp_ctrl.h"
  20. #define MUL_COEF 1.248
  21. int opt_diff=0;
  22. static const uint32_t difficult_Tbl[24] = {
  23. 0x1d00ffff,// 1
  24. 0x1d007fff,// 2
  25. 0x1d005fff,// 3
  26. 0x1d003fff,// 4
  27. 0x1d001fff,// 8
  28. 0x1d000fff,// 16
  29. 0x1d0007ff,// 32
  30. 0x1d0006ff,// 37
  31. 0x1d0005ff,// 43
  32. 0x1d0004ff,// 52
  33. 0x1d0003ff,// 65
  34. 0x1d0002ff,// 86
  35. 0x1d00027f,// 103
  36. 0x1d0001ff,// 129
  37. 0x1c00ffff,// 256
  38. 0x1c007fff,// 512
  39. 0x1b3fffff,// 1024
  40. 0x1b1fffff,// 2048
  41. 0x1b0fffff,// 4096
  42. 0x1b07ffff,// 8192
  43. 0x1b03ffff,// 16384
  44. 0x1b01ffff,// 32768
  45. 0x1b00ffff,// 65536
  46. 0x1b007fff,// 131072
  47. };
  48. const struct PLL_Clock PLL_Clk_12Mhz[T1_PLL_LV_NUM] = {
  49. { 0, 120 , T1_PLL(1, 80 , 3)},
  50. { 1, 121 , T1_PLL(1, 81 , 3)},
  51. { 2, 123 , T1_PLL(1, 82 , 3)},
  52. { 3, 124 , T1_PLL(1, 83 , 3)},
  53. { 4, 126 , T1_PLL(1, 84 , 3)},
  54. { 5, 127 , T1_PLL(1, 85 , 3)},
  55. { 6, 129 , T1_PLL(1, 86 , 3)},
  56. { 7, 130 , T1_PLL(1, 87 , 3)},
  57. { 8, 132 , T1_PLL(1, 88 , 3)},
  58. { 9, 133 , T1_PLL(1, 89 , 3)},
  59. { 10, 135 , T1_PLL(1, 90 , 3)},
  60. { 11, 136 , T1_PLL(1, 91 , 3)},
  61. { 12, 138 , T1_PLL(1, 92 , 3)},
  62. { 13, 139 , T1_PLL(1, 93 , 3)},
  63. { 14, 141 , T1_PLL(1, 94 , 3)},
  64. { 15, 142 , T1_PLL(1, 95 , 3)},
  65. { 16, 144 , T1_PLL(1, 96 , 3)},
  66. { 17, 145 , T1_PLL(1, 97 , 3)},
  67. { 18, 147 , T1_PLL(1, 98 , 3)},
  68. { 19, 148 , T1_PLL(1, 99 , 3)},
  69. { 20, 150 , T1_PLL(1, 50 , 2)},
  70. { 21, 153 , T1_PLL(1, 51 , 2)},
  71. { 22, 156 , T1_PLL(1, 52 , 2)},
  72. { 23, 159 , T1_PLL(1, 53 , 2)},
  73. { 24, 162 , T1_PLL(1, 54 , 2)},
  74. { 25, 165 , T1_PLL(1, 55 , 2)},
  75. { 26, 168 , T1_PLL(1, 56 , 2)},
  76. { 27, 171 , T1_PLL(1, 57 , 2)},
  77. { 28, 174 , T1_PLL(1, 58 , 2)},
  78. { 29, 177 , T1_PLL(1, 59 , 2)},
  79. { 30, 180 , T1_PLL(1, 60 , 2)},
  80. { 31, 183 , T1_PLL(1, 61 , 2)},
  81. { 32, 186 , T1_PLL(1, 62 , 2)},
  82. { 33, 189 , T1_PLL(1, 63 , 2)},
  83. { 34, 192 , T1_PLL(1, 64 , 2)},
  84. { 35, 195 , T1_PLL(1, 65 , 2)},
  85. { 36, 198 , T1_PLL(1, 66 , 2)},
  86. { 37, 201 , T1_PLL(1, 67 , 2)},
  87. { 38, 204 , T1_PLL(1, 68 , 2)},
  88. { 39, 207 , T1_PLL(1, 69 , 2)},
  89. { 40, 210 , T1_PLL(1, 70 , 2)},
  90. { 41, 213 , T1_PLL(1, 71 , 2)},
  91. { 42, 216 , T1_PLL(1, 72 , 2)},
  92. { 43, 219 , T1_PLL(1, 73 , 2)},
  93. { 44, 222 , T1_PLL(1, 74 , 2)},
  94. { 45, 225 , T1_PLL(1, 75 , 2)},
  95. { 46, 228 , T1_PLL(1, 76 , 2)},
  96. { 47, 231 , T1_PLL(1, 77 , 2)},
  97. { 48, 234 , T1_PLL(1, 78 , 2)},
  98. { 49, 237 , T1_PLL(1, 79 , 2)},
  99. { 50, 240 , T1_PLL(2, 160, 2)},
  100. { 51, 241 , T1_PLL(2, 161, 2)},
  101. { 52, 243 , T1_PLL(2, 162, 2)},
  102. { 53, 244 , T1_PLL(2, 163, 2)},
  103. { 54, 246 , T1_PLL(2, 164, 2)},
  104. { 55, 247 , T1_PLL(2, 165, 2)},
  105. { 56, 249 , T1_PLL(2, 166, 2)},
  106. { 57, 250 , T1_PLL(2, 167, 2)},
  107. { 58, 252 , T1_PLL(2, 168, 2)},
  108. { 59, 253 , T1_PLL(2, 169, 2)},
  109. { 60, 255 , T1_PLL(2, 170, 2)},
  110. { 61, 256 , T1_PLL(2, 171, 2)},
  111. { 62, 258 , T1_PLL(2, 172, 2)},
  112. { 63, 259 , T1_PLL(2, 173, 2)},
  113. { 64, 261 , T1_PLL(2, 174, 2)},
  114. { 65, 262 , T1_PLL(2, 175, 2)},
  115. { 66, 264 , T1_PLL(2, 176, 2)},
  116. { 67, 265 , T1_PLL(2, 177, 2)},
  117. { 68, 267 , T1_PLL(2, 178, 2)},
  118. { 69, 268 , T1_PLL(2, 179, 2)},
  119. { 70, 270 , T1_PLL(2, 180, 2)},
  120. { 71, 271 , T1_PLL(2, 181, 2)},
  121. { 72, 273 , T1_PLL(2, 182, 2)},
  122. { 73, 274 , T1_PLL(2, 183, 2)},
  123. { 74, 276 , T1_PLL(2, 184, 2)},
  124. { 75, 277 , T1_PLL(2, 185, 2)},
  125. { 76, 279 , T1_PLL(2, 186, 2)},
  126. { 77, 280 , T1_PLL(2, 187, 2)},
  127. { 78, 282 , T1_PLL(2, 188, 2)},
  128. { 79, 283 , T1_PLL(2, 189, 2)},
  129. { 80, 285 , T1_PLL(2, 190, 2)},
  130. { 81, 286 , T1_PLL(2, 191, 2)},
  131. { 82, 288 , T1_PLL(2, 192, 2)},
  132. { 83, 289 , T1_PLL(2, 193, 2)},
  133. { 84, 291 , T1_PLL(2, 194, 2)},
  134. { 85, 292 , T1_PLL(2, 195, 2)},
  135. { 86, 294 , T1_PLL(2, 196, 2)},
  136. { 87, 295 , T1_PLL(2, 197, 2)},
  137. { 88, 297 , T1_PLL(2, 198, 2)},
  138. { 89, 298 , T1_PLL(2, 199, 2)},
  139. { 90, 300 , T1_PLL(2, 100, 1)},
  140. { 91, 303 , T1_PLL(2, 101, 1)},
  141. { 92, 306 , T1_PLL(2, 102, 1)},
  142. { 93, 309 , T1_PLL(2, 103, 1)},
  143. { 94, 312 , T1_PLL(2, 104, 1)},
  144. { 95, 315 , T1_PLL(2, 105, 1)},
  145. { 96, 318 , T1_PLL(2, 106, 1)},
  146. { 97, 321 , T1_PLL(2, 107, 1)},
  147. { 98, 324 , T1_PLL(2, 108, 1)},
  148. { 99, 327 , T1_PLL(2, 109, 1)},
  149. {100, 330 , T1_PLL(2, 110, 1)},
  150. {101, 333 , T1_PLL(2, 111, 1)},
  151. {102, 336 , T1_PLL(2, 112, 1)},
  152. {103, 339 , T1_PLL(2, 113, 1)},
  153. {104, 342 , T1_PLL(2, 114, 1)},
  154. {105, 345 , T1_PLL(2, 115, 1)},
  155. {106, 348 , T1_PLL(2, 116, 1)},
  156. {107, 351 , T1_PLL(2, 117, 1)},
  157. {108, 354 , T1_PLL(2, 118, 1)},
  158. {109, 357 , T1_PLL(2, 119, 1)},
  159. {110, 360 , T1_PLL(2, 120, 1)},
  160. {111, 363 , T1_PLL(2, 121, 1)},
  161. {112, 366 , T1_PLL(2, 122, 1)},
  162. {113, 369 , T1_PLL(2, 123, 1)},
  163. {114, 372 , T1_PLL(2, 124, 1)},
  164. {115, 375 , T1_PLL(2, 125, 1)},
  165. {116, 378 , T1_PLL(2, 126, 1)},
  166. {117, 381 , T1_PLL(2, 127, 1)},
  167. {118, 384 , T1_PLL(2, 128, 1)},
  168. {119, 387 , T1_PLL(2, 129, 1)},
  169. {120, 390 , T1_PLL(2, 130, 1)},
  170. {121, 393 , T1_PLL(2, 131, 1)},
  171. {122, 396 , T1_PLL(2, 132, 1)},
  172. {123, 399 , T1_PLL(2, 133, 1)},
  173. {124, 402 , T1_PLL(2, 134, 1)},
  174. {125, 405 , T1_PLL(2, 135, 1)},
  175. {126, 408 , T1_PLL(2, 136, 1)},
  176. {127, 411 , T1_PLL(2, 137, 1)},
  177. {128, 414 , T1_PLL(2, 138, 1)},
  178. {129, 417 , T1_PLL(2, 139, 1)},
  179. {130, 420 , T1_PLL(2, 140, 1)},
  180. {131, 423 , T1_PLL(2, 141, 1)},
  181. {132, 426 , T1_PLL(2, 142, 1)},
  182. {133, 429 , T1_PLL(2, 143, 1)},
  183. {134, 432 , T1_PLL(2, 144, 1)},
  184. {135, 435 , T1_PLL(2, 145, 1)},
  185. {136, 438 , T1_PLL(2, 146, 1)},
  186. {137, 441 , T1_PLL(2, 147, 1)},
  187. {138, 444 , T1_PLL(2, 148, 1)},
  188. {139, 447 , T1_PLL(2, 149, 1)},
  189. {140, 450 , T1_PLL(2, 150, 1)},
  190. {141, 453 , T1_PLL(2, 151, 1)},
  191. {142, 456 , T1_PLL(2, 152, 1)},
  192. {143, 459 , T1_PLL(2, 153, 1)},
  193. {144, 462 , T1_PLL(2, 154, 1)},
  194. {145, 465 , T1_PLL(2, 155, 1)},
  195. {146, 468 , T1_PLL(2, 156, 1)},
  196. {147, 471 , T1_PLL(2, 157, 1)},
  197. {148, 474 , T1_PLL(2, 158, 1)},
  198. {149, 477 , T1_PLL(2, 159, 1)},
  199. {150, 480 , T1_PLL(2, 160, 1)},
  200. {151, 483 , T1_PLL(2, 161, 1)},
  201. {152, 486 , T1_PLL(2, 162, 1)},
  202. {153, 489 , T1_PLL(2, 163, 1)},
  203. {154, 492 , T1_PLL(2, 164, 1)},
  204. {155, 495 , T1_PLL(2, 165, 1)},
  205. {156, 498 , T1_PLL(2, 166, 1)},
  206. {157, 501 , T1_PLL(2, 167, 1)},
  207. {158, 504 , T1_PLL(2, 168, 1)},
  208. {159, 507 , T1_PLL(2, 169, 1)},
  209. {160, 510 , T1_PLL(2, 170, 1)},
  210. {161, 513 , T1_PLL(2, 171, 1)},
  211. {162, 516 , T1_PLL(2, 172, 1)},
  212. {163, 519 , T1_PLL(2, 173, 1)},
  213. {164, 522 , T1_PLL(2, 174, 1)},
  214. {165, 525 , T1_PLL(2, 175, 1)},
  215. {166, 528 , T1_PLL(2, 176, 1)},
  216. {167, 531 , T1_PLL(2, 177, 1)},
  217. {168, 534 , T1_PLL(2, 178, 1)},
  218. {169, 537 , T1_PLL(2, 179, 1)},
  219. {170, 540 , T1_PLL(2, 180, 1)},
  220. {171, 543 , T1_PLL(2, 181, 1)},
  221. {172, 546 , T1_PLL(2, 182, 1)},
  222. {173, 549 , T1_PLL(2, 183, 1)},
  223. {174, 552 , T1_PLL(2, 184, 1)},
  224. {175, 555 , T1_PLL(2, 185, 1)},
  225. {176, 558 , T1_PLL(2, 186, 1)},
  226. {177, 561 , T1_PLL(2, 187, 1)},
  227. {178, 564 , T1_PLL(2, 188, 1)},
  228. {179, 567 , T1_PLL(2, 189, 1)},
  229. {180, 570 , T1_PLL(2, 190, 1)},
  230. {181, 573 , T1_PLL(2, 191, 1)},
  231. {182, 576 , T1_PLL(2, 192, 1)},
  232. {183, 579 , T1_PLL(2, 193, 1)},
  233. {184, 582 , T1_PLL(2, 194, 1)},
  234. {185, 585 , T1_PLL(2, 195, 1)},
  235. {186, 588 , T1_PLL(2, 196, 1)},
  236. {187, 591 , T1_PLL(2, 197, 1)},
  237. {188, 594 , T1_PLL(2, 198, 1)},
  238. {189, 597 , T1_PLL(2, 199, 1)},
  239. {190, 600 , T1_PLL(2, 100, 0)},
  240. {191, 606 , T1_PLL(2, 101, 0)},
  241. {192, 612 , T1_PLL(2, 102, 0)},
  242. {193, 618 , T1_PLL(2, 103, 0)},
  243. {194, 624 , T1_PLL(2, 104, 0)},
  244. {195, 630 , T1_PLL(2, 105, 0)},
  245. {196, 636 , T1_PLL(2, 106, 0)},
  246. {197, 642 , T1_PLL(2, 107, 0)},
  247. {198, 648 , T1_PLL(2, 108, 0)},
  248. {199, 654 , T1_PLL(2, 109, 0)},
  249. {200, 660 , T1_PLL(2, 110, 0)},
  250. {201, 666 , T1_PLL(2, 111, 0)},
  251. {202, 672 , T1_PLL(2, 112, 0)},
  252. {203, 678 , T1_PLL(2, 113, 0)},
  253. {204, 684 , T1_PLL(2, 114, 0)},
  254. {205, 690 , T1_PLL(2, 115, 0)},
  255. {206, 696 , T1_PLL(2, 116, 0)},
  256. {207, 702 , T1_PLL(2, 117, 0)},
  257. {208, 708 , T1_PLL(2, 118, 0)},
  258. {209, 714 , T1_PLL(2, 119, 0)},
  259. {210, 720 , T1_PLL(2, 120, 0)},
  260. {211, 726 , T1_PLL(2, 121, 0)},
  261. {212, 732 , T1_PLL(2, 122, 0)},
  262. {213, 738 , T1_PLL(2, 123, 0)},
  263. {214, 744 , T1_PLL(2, 124, 0)},
  264. {215, 750 , T1_PLL(2, 125, 0)},
  265. {216, 756 , T1_PLL(2, 126, 0)},
  266. {217, 762 , T1_PLL(2, 127, 0)},
  267. {218, 768 , T1_PLL(2, 128, 0)},
  268. {219, 774 , T1_PLL(2, 129, 0)},
  269. {220, 780 , T1_PLL(2, 130, 0)},
  270. {221, 786 , T1_PLL(2, 131, 0)},
  271. {222, 792 , T1_PLL(2, 132, 0)},
  272. {223, 798 , T1_PLL(2, 133, 0)},
  273. {224, 804 , T1_PLL(2, 134, 0)},
  274. {225, 810 , T1_PLL(2, 135, 0)},
  275. {226, 816 , T1_PLL(2, 136, 0)},
  276. {227, 822 , T1_PLL(2, 137, 0)},
  277. {228, 828 , T1_PLL(2, 138, 0)},
  278. {229, 834 , T1_PLL(2, 139, 0)},
  279. {230, 840 , T1_PLL(2, 140, 0)},
  280. {231, 846 , T1_PLL(2, 141, 0)},
  281. {232, 852 , T1_PLL(2, 142, 0)},
  282. {233, 858 , T1_PLL(2, 143, 0)},
  283. {234, 864 , T1_PLL(2, 144, 0)},
  284. {235, 870 , T1_PLL(2, 145, 0)},
  285. {236, 876 , T1_PLL(2, 146, 0)},
  286. {237, 882 , T1_PLL(2, 147, 0)},
  287. {238, 888 , T1_PLL(2, 148, 0)},
  288. {239, 894 , T1_PLL(2, 149, 0)},
  289. {240, 900 , T1_PLL(2, 150, 0)},
  290. {241, 906 , T1_PLL(2, 151, 0)},
  291. {242, 912 , T1_PLL(2, 152, 0)},
  292. {243, 918 , T1_PLL(2, 153, 0)},
  293. {244, 924 , T1_PLL(2, 154, 0)},
  294. {245, 930 , T1_PLL(2, 155, 0)},
  295. {246, 936 , T1_PLL(2, 156, 0)},
  296. {247, 942 , T1_PLL(2, 157, 0)},
  297. {248, 948 , T1_PLL(2, 158, 0)},
  298. {249, 954 , T1_PLL(2, 159, 0)},
  299. {250, 960 , T1_PLL(2, 160, 0)},
  300. {251, 966 , T1_PLL(2, 161, 0)},
  301. {252, 972 , T1_PLL(2, 162, 0)},
  302. {253, 978 , T1_PLL(2, 163, 0)},
  303. {254, 984 , T1_PLL(2, 164, 0)},
  304. {255, 990 , T1_PLL(2, 165, 0)},
  305. {256, 996 , T1_PLL(2, 166, 0)},
  306. {257, 1002, T1_PLL(2, 167, 0)},
  307. {258, 1008, T1_PLL(2, 168, 0)},
  308. {259, 1014, T1_PLL(2, 169, 0)},
  309. {260, 1020, T1_PLL(2, 170, 0)},
  310. {261, 1026, T1_PLL(2, 171, 0)},
  311. {262, 1032, T1_PLL(2, 172, 0)},
  312. {263, 1038, T1_PLL(2, 173, 0)},
  313. {264, 1044, T1_PLL(2, 174, 0)},
  314. {265, 1050, T1_PLL(2, 175, 0)},
  315. {266, 1056, T1_PLL(2, 176, 0)},
  316. {267, 1062, T1_PLL(2, 177, 0)},
  317. {268, 1068, T1_PLL(2, 178, 0)},
  318. {269, 1074, T1_PLL(2, 179, 0)},
  319. {270, 1080, T1_PLL(2, 180, 0)},
  320. {271, 1086, T1_PLL(2, 181, 0)},
  321. {272, 1092, T1_PLL(2, 182, 0)},
  322. {273, 1098, T1_PLL(2, 183, 0)},
  323. {274, 1104, T1_PLL(2, 184, 0)},
  324. {275, 1110, T1_PLL(2, 185, 0)},
  325. {276, 1116, T1_PLL(2, 186, 0)},
  326. {277, 1122, T1_PLL(2, 187, 0)},
  327. {278, 1128, T1_PLL(2, 188, 0)},
  328. {279, 1134, T1_PLL(2, 189, 0)},
  329. {280, 1140, T1_PLL(2, 190, 0)},
  330. {281, 1146, T1_PLL(2, 191, 0)},
  331. {282, 1152, T1_PLL(2, 192, 0)},
  332. {283, 1158, T1_PLL(2, 193, 0)},
  333. {284, 1164, T1_PLL(2, 194, 0)},
  334. {285, 1170, T1_PLL(2, 195, 0)},
  335. {286, 1176, T1_PLL(2, 196, 0)},
  336. {287, 1182, T1_PLL(2, 197, 0)},
  337. {288, 1188, T1_PLL(2, 198, 0)},
  338. {289, 1194, T1_PLL(2, 199, 0)},
  339. {290, 1200, T1_PLL(1, 100, 0)},
  340. {291, 1212, T1_PLL(1, 101, 0)},
  341. {292, 1224, T1_PLL(1, 102, 0)},
  342. {293, 1236, T1_PLL(1, 103, 0)},
  343. {294, 1248, T1_PLL(1, 104, 0)},
  344. {295, 1260, T1_PLL(1, 105, 0)},
  345. {296, 1272, T1_PLL(1, 106, 0)},
  346. {297, 1284, T1_PLL(1, 107, 0)},
  347. {298, 1296, T1_PLL(1, 108, 0)},
  348. {299, 1308, T1_PLL(1, 109, 0)},
  349. {300, 1320, T1_PLL(1, 110, 0)},
  350. {301, 1332, T1_PLL(1, 111, 0)},
  351. {302, 1344, T1_PLL(1, 112, 0)},
  352. {303, 1356, T1_PLL(1, 113, 0)},
  353. {304, 1368, T1_PLL(1, 114, 0)},
  354. {305, 1380, T1_PLL(1, 115, 0)},
  355. {306, 1392, T1_PLL(1, 116, 0)},
  356. {307, 1404, T1_PLL(1, 117, 0)},
  357. {308, 1416, T1_PLL(1, 118, 0)},
  358. {309, 1428, T1_PLL(1, 119, 0)},
  359. {310, 1440, T1_PLL(1, 120, 0)},
  360. {311, 1452, T1_PLL(1, 121, 0)},
  361. {312, 1464, T1_PLL(1, 122, 0)},
  362. {313, 1476, T1_PLL(1, 123, 0)},
  363. {314, 1488, T1_PLL(1, 124, 0)},
  364. {315, 1500, T1_PLL(1, 125, 0)},
  365. {316, 1512, T1_PLL(1, 126, 0)},
  366. {317, 1524, T1_PLL(1, 127, 0)},
  367. {318, 1536, T1_PLL(1, 128, 0)},
  368. {319, 1548, T1_PLL(1, 129, 0)},
  369. {320, 1560, T1_PLL(1, 130, 0)},
  370. {321, 1572, T1_PLL(1, 131, 0)},
  371. {322, 1584, T1_PLL(1, 132, 0)},
  372. {323, 1596, T1_PLL(1, 133, 0)},
  373. };
  374. const uint8_t default_reg[T1_PLL_LV_NUM][REG_LENGTH] =
  375. {
  376. {0x02, 0x50, 0x40, 0xc2, 0x00, 0x00, 0x00, 0xa0, 0x00, 0x24, 0x00, 0x00}, // 120MHz
  377. {0x02, 0x51, 0x40, 0xc2, 0x00, 0x00, 0x00, 0xa0, 0x00, 0x24, 0x00, 0x00}, // 121MHz
  378. {0x02, 0x52, 0x40, 0xc2, 0x00, 0x00, 0x00, 0xa0, 0x00, 0x24, 0x00, 0x00}, // 123MHz
  379. {0x02, 0x53, 0x40, 0xc2, 0x00, 0x00, 0x00, 0xa0, 0x00, 0x24, 0x00, 0x00}, // 124MHz
  380. {0x02, 0x54, 0x40, 0xc2, 0x00, 0x00, 0x00, 0xa0, 0x00, 0x24, 0x00, 0x00}, // 126MHz
  381. {0x02, 0x55, 0x40, 0xc2, 0x00, 0x00, 0x00, 0xa0, 0x00, 0x24, 0x00, 0x00}, // 127MHz
  382. {0x02, 0x56, 0x40, 0xc2, 0x00, 0x00, 0x00, 0xa0, 0x00, 0x24, 0x00, 0x00}, // 129MHz
  383. {0x02, 0x57, 0x40, 0xc2, 0x00, 0x00, 0x00, 0xa0, 0x00, 0x24, 0x00, 0x00}, // 130MHz
  384. {0x02, 0x58, 0x40, 0xc2, 0x00, 0x00, 0x00, 0xa0, 0x00, 0x24, 0x00, 0x00}, // 132MHz
  385. {0x02, 0x59, 0x40, 0xc2, 0x00, 0x00, 0x00, 0xa0, 0x00, 0x24, 0x00, 0x00}, // 133MHz
  386. {0x02, 0x5a, 0x40, 0xc2, 0x00, 0x00, 0x00, 0xa0, 0x00, 0x24, 0x00, 0x00}, // 135MHz
  387. {0x02, 0x5b, 0x40, 0xc2, 0x00, 0x00, 0x00, 0xa0, 0x00, 0x24, 0x00, 0x00}, // 136MHz
  388. {0x02, 0x5c, 0x40, 0xc2, 0x00, 0x00, 0x00, 0xa0, 0x00, 0x24, 0x00, 0x00}, // 138MHz
  389. {0x02, 0x5d, 0x40, 0xc2, 0x00, 0x00, 0x00, 0xa0, 0x00, 0x24, 0x00, 0x00}, // 139MHz
  390. {0x02, 0x5e, 0x40, 0xc2, 0x00, 0x00, 0x00, 0xa0, 0x00, 0x24, 0x00, 0x00}, // 141MHz
  391. {0x02, 0x5f, 0x40, 0xc2, 0x00, 0x00, 0x00, 0xa0, 0x00, 0x24, 0x00, 0x00}, // 142MHz
  392. {0x02, 0x60, 0x40, 0xc2, 0x00, 0x00, 0x00, 0xa0, 0x00, 0x24, 0x00, 0x00}, // 144MHz
  393. {0x02, 0x61, 0x40, 0xc2, 0x00, 0x00, 0x00, 0xa0, 0x00, 0x24, 0x00, 0x00}, // 145MHz
  394. {0x02, 0x62, 0x40, 0xc2, 0x00, 0x00, 0x00, 0xa0, 0x00, 0x24, 0x00, 0x00}, // 147MHz
  395. {0x02, 0x63, 0x40, 0xc2, 0x00, 0x00, 0x00, 0xa0, 0x00, 0x24, 0x00, 0x00}, // 148MHz
  396. {0x02, 0x32, 0x40, 0x82, 0x00, 0x00, 0x00, 0xa0, 0x00, 0x24, 0x00, 0x00}, // 150MHz
  397. {0x02, 0x33, 0x40, 0x82, 0x00, 0x00, 0x00, 0xa0, 0x00, 0x24, 0x00, 0x00}, // 153MHz
  398. {0x02, 0x34, 0x40, 0x82, 0x00, 0x00, 0x00, 0xa0, 0x00, 0x24, 0x00, 0x00}, // 156MHz
  399. {0x02, 0x35, 0x40, 0x82, 0x00, 0x00, 0x00, 0xa0, 0x00, 0x24, 0x00, 0x00}, // 159MHz
  400. {0x02, 0x36, 0x40, 0x82, 0x00, 0x00, 0x00, 0xa0, 0x00, 0x24, 0x00, 0x00}, // 162MHz
  401. {0x02, 0x37, 0x40, 0x82, 0x00, 0x00, 0x00, 0xa0, 0x00, 0x24, 0x00, 0x00}, // 165MHz
  402. {0x02, 0x38, 0x40, 0x82, 0x00, 0x00, 0x00, 0xa0, 0x00, 0x24, 0x00, 0x00}, // 168MHz
  403. {0x02, 0x39, 0x40, 0x82, 0x00, 0x00, 0x00, 0xa0, 0x00, 0x24, 0x00, 0x00}, // 171MHz
  404. {0x02, 0x3a, 0x40, 0x82, 0x00, 0x00, 0x00, 0xa0, 0x00, 0x24, 0x00, 0x00}, // 174MHz
  405. {0x02, 0x3b, 0x40, 0x82, 0x00, 0x00, 0x00, 0xa0, 0x00, 0x24, 0x00, 0x00}, // 177MHz
  406. {0x02, 0x3c, 0x40, 0x82, 0x00, 0x00, 0x00, 0xa0, 0x00, 0x24, 0x00, 0x00}, // 180MHz
  407. {0x02, 0x3d, 0x40, 0x82, 0x00, 0x00, 0x00, 0xa0, 0x00, 0x24, 0x00, 0x00}, // 183MHz
  408. {0x02, 0x3e, 0x40, 0x82, 0x00, 0x00, 0x00, 0xa0, 0x00, 0x24, 0x00, 0x00}, // 186MHz
  409. {0x02, 0x3f, 0x40, 0x82, 0x00, 0x00, 0x00, 0xa0, 0x00, 0x24, 0x00, 0x00}, // 189MHz
  410. {0x02, 0x40, 0x40, 0x82, 0x00, 0x00, 0x00, 0xa0, 0x00, 0x24, 0x00, 0x00}, // 192MHz
  411. {0x02, 0x41, 0x40, 0x82, 0x00, 0x00, 0x00, 0xa0, 0x00, 0x24, 0x00, 0x00}, // 195MHz
  412. {0x02, 0x42, 0x40, 0x82, 0x00, 0x00, 0x00, 0xa0, 0x00, 0x24, 0x00, 0x00}, // 198MHz
  413. {0x02, 0x43, 0x40, 0x82, 0x00, 0x00, 0x00, 0xa0, 0x00, 0x24, 0x00, 0x00}, // 201MHz
  414. {0x02, 0x44, 0x40, 0x82, 0x00, 0x00, 0x00, 0xa0, 0x00, 0x24, 0x00, 0x00}, // 204MHz
  415. {0x02, 0x45, 0x40, 0x82, 0x00, 0x00, 0x00, 0xa0, 0x00, 0x24, 0x00, 0x00}, // 207MHz
  416. {0x02, 0x46, 0x40, 0x82, 0x00, 0x00, 0x00, 0xa0, 0x00, 0x24, 0x00, 0x00}, // 210MHz
  417. {0x02, 0x47, 0x40, 0x82, 0x00, 0x00, 0x00, 0xa0, 0x00, 0x24, 0x00, 0x00}, // 213MHz
  418. {0x02, 0x48, 0x40, 0x82, 0x00, 0x00, 0x00, 0xa0, 0x00, 0x24, 0x00, 0x00}, // 216MHz
  419. {0x02, 0x49, 0x40, 0x82, 0x00, 0x00, 0x00, 0xa0, 0x00, 0x24, 0x00, 0x00}, // 219MHz
  420. {0x02, 0x4a, 0x40, 0x82, 0x00, 0x00, 0x00, 0xa0, 0x00, 0x24, 0x00, 0x00}, // 222MHz
  421. {0x02, 0x4b, 0x40, 0x82, 0x00, 0x00, 0x00, 0xa0, 0x00, 0x24, 0x00, 0x00}, // 225MHz
  422. {0x02, 0x4c, 0x40, 0x82, 0x00, 0x00, 0x00, 0xa0, 0x00, 0x24, 0x00, 0x00}, // 228MHz
  423. {0x02, 0x4d, 0x40, 0x82, 0x00, 0x00, 0x00, 0xa0, 0x00, 0x24, 0x00, 0x00}, // 231MHz
  424. {0x02, 0x4e, 0x40, 0x82, 0x00, 0x00, 0x00, 0xa0, 0x00, 0x24, 0x00, 0x00}, // 234MHz
  425. {0x02, 0x4f, 0x40, 0x82, 0x00, 0x00, 0x00, 0xa0, 0x00, 0x24, 0x00, 0x00}, // 237MHz
  426. {0x04, 0xa0, 0x40, 0x82, 0x00, 0x00, 0x00, 0xa0, 0x00, 0x24, 0x00, 0x00}, // 240MHz
  427. {0x04, 0xa1, 0x40, 0x82, 0x00, 0x00, 0x00, 0xa0, 0x00, 0x24, 0x00, 0x00}, // 241MHz
  428. {0x04, 0xa2, 0x40, 0x82, 0x00, 0x00, 0x00, 0xa0, 0x00, 0x24, 0x00, 0x00}, // 243MHz
  429. {0x04, 0xa3, 0x40, 0x82, 0x00, 0x00, 0x00, 0xa0, 0x00, 0x24, 0x00, 0x00}, // 244MHz
  430. {0x04, 0xa4, 0x40, 0x82, 0x00, 0x00, 0x00, 0xa0, 0x00, 0x24, 0x00, 0x00}, // 246MHz
  431. {0x04, 0xa5, 0x40, 0x82, 0x00, 0x00, 0x00, 0xa0, 0x00, 0x24, 0x00, 0x00}, // 247MHz
  432. {0x04, 0xa6, 0x40, 0x82, 0x00, 0x00, 0x00, 0xa0, 0x00, 0x24, 0x00, 0x00}, // 249MHz
  433. {0x04, 0xa7, 0x40, 0x82, 0x00, 0x00, 0x00, 0xa0, 0x00, 0x24, 0x00, 0x00}, // 250MHz
  434. {0x04, 0xa8, 0x40, 0x82, 0x00, 0x00, 0x00, 0xa0, 0x00, 0x24, 0x00, 0x00}, // 252MHz
  435. {0x04, 0xa9, 0x40, 0x82, 0x00, 0x00, 0x00, 0xa0, 0x00, 0x24, 0x00, 0x00}, // 253MHz
  436. {0x04, 0xaa, 0x40, 0x82, 0x00, 0x00, 0x00, 0xa0, 0x00, 0x24, 0x00, 0x00}, // 255MHz
  437. {0x04, 0xab, 0x40, 0x82, 0x00, 0x00, 0x00, 0xa0, 0x00, 0x24, 0x00, 0x00}, // 256MHz
  438. {0x04, 0xac, 0x40, 0x82, 0x00, 0x00, 0x00, 0xa0, 0x00, 0x24, 0x00, 0x00}, // 258MHz
  439. {0x04, 0xad, 0x40, 0x82, 0x00, 0x00, 0x00, 0xa0, 0x00, 0x24, 0x00, 0x00}, // 259MHz
  440. {0x04, 0xae, 0x40, 0x82, 0x00, 0x00, 0x00, 0xa0, 0x00, 0x24, 0x00, 0x00}, // 261MHz
  441. {0x04, 0xaf, 0x40, 0x82, 0x00, 0x00, 0x00, 0xa0, 0x00, 0x24, 0x00, 0x00}, // 262MHz
  442. {0x04, 0xb0, 0x40, 0x82, 0x00, 0x00, 0x00, 0xa0, 0x00, 0x24, 0x00, 0x00}, // 264MHz
  443. {0x04, 0xb1, 0x40, 0x82, 0x00, 0x00, 0x00, 0xa0, 0x00, 0x24, 0x00, 0x00}, // 265MHz
  444. {0x04, 0xb2, 0x40, 0x82, 0x00, 0x00, 0x00, 0xa0, 0x00, 0x24, 0x00, 0x00}, // 267MHz
  445. {0x04, 0xb3, 0x40, 0x82, 0x00, 0x00, 0x00, 0xa0, 0x00, 0x24, 0x00, 0x00}, // 268MHz
  446. {0x04, 0xb4, 0x40, 0x82, 0x00, 0x00, 0x00, 0xa0, 0x00, 0x24, 0x00, 0x00}, // 270MHz
  447. {0x04, 0xb5, 0x40, 0x82, 0x00, 0x00, 0x00, 0xa0, 0x00, 0x24, 0x00, 0x00}, // 271MHz
  448. {0x04, 0xb6, 0x40, 0x82, 0x00, 0x00, 0x00, 0xa0, 0x00, 0x24, 0x00, 0x00}, // 273MHz
  449. {0x04, 0xb7, 0x40, 0x82, 0x00, 0x00, 0x00, 0xa0, 0x00, 0x24, 0x00, 0x00}, // 274MHz
  450. {0x04, 0xb8, 0x40, 0x82, 0x00, 0x00, 0x00, 0xa0, 0x00, 0x24, 0x00, 0x00}, // 276MHz
  451. {0x04, 0xb9, 0x40, 0x82, 0x00, 0x00, 0x00, 0xa0, 0x00, 0x24, 0x00, 0x00}, // 277MHz
  452. {0x04, 0xba, 0x40, 0x82, 0x00, 0x00, 0x00, 0xa0, 0x00, 0x24, 0x00, 0x00}, // 279MHz
  453. {0x04, 0xbb, 0x40, 0x82, 0x00, 0x00, 0x00, 0xa0, 0x00, 0x24, 0x00, 0x00}, // 280MHz
  454. {0x04, 0xbc, 0x40, 0x82, 0x00, 0x00, 0x00, 0xa0, 0x00, 0x24, 0x00, 0x00}, // 282MHz
  455. {0x04, 0xbd, 0x40, 0x82, 0x00, 0x00, 0x00, 0xa0, 0x00, 0x24, 0x00, 0x00}, // 283MHz
  456. {0x04, 0xbe, 0x40, 0x82, 0x00, 0x00, 0x00, 0xa0, 0x00, 0x24, 0x00, 0x00}, // 285MHz
  457. {0x04, 0xbf, 0x40, 0x82, 0x00, 0x00, 0x00, 0xa0, 0x00, 0x24, 0x00, 0x00}, // 286MHz
  458. {0x04, 0xc0, 0x40, 0x82, 0x00, 0x00, 0x00, 0xa0, 0x00, 0x24, 0x00, 0x00}, // 288MHz
  459. {0x04, 0xc1, 0x40, 0x82, 0x00, 0x00, 0x00, 0xa0, 0x00, 0x24, 0x00, 0x00}, // 289MHz
  460. {0x04, 0xc2, 0x40, 0x82, 0x00, 0x00, 0x00, 0xa0, 0x00, 0x24, 0x00, 0x00}, // 291MHz
  461. {0x04, 0xc3, 0x40, 0x82, 0x00, 0x00, 0x00, 0xa0, 0x00, 0x24, 0x00, 0x00}, // 292MHz
  462. {0x04, 0xc4, 0x40, 0x82, 0x00, 0x00, 0x00, 0xa0, 0x00, 0x24, 0x00, 0x00}, // 294MHz
  463. {0x04, 0xc5, 0x40, 0x82, 0x00, 0x00, 0x00, 0xa0, 0x00, 0x24, 0x00, 0x00}, // 295MHz
  464. {0x04, 0xc6, 0x40, 0x82, 0x00, 0x00, 0x00, 0xa0, 0x00, 0x24, 0x00, 0x00}, // 297MHz
  465. {0x04, 0xc7, 0x40, 0x82, 0x00, 0x00, 0x00, 0xa0, 0x00, 0x24, 0x00, 0x00}, // 298MHz
  466. {0x04, 0x64, 0x40, 0x42, 0x00, 0x00, 0x00, 0xa0, 0x00, 0x24, 0x00, 0x00}, // 300MHz
  467. {0x04, 0x65, 0x40, 0x42, 0x00, 0x00, 0x00, 0xa0, 0x00, 0x24, 0x00, 0x00}, // 303MHz
  468. {0x04, 0x66, 0x40, 0x42, 0x00, 0x00, 0x00, 0xa0, 0x00, 0x24, 0x00, 0x00}, // 306MHz
  469. {0x04, 0x67, 0x40, 0x42, 0x00, 0x00, 0x00, 0xa0, 0x00, 0x24, 0x00, 0x00}, // 309MHz
  470. {0x04, 0x68, 0x40, 0x42, 0x00, 0x00, 0x00, 0xa0, 0x00, 0x24, 0x00, 0x00}, // 312MHz
  471. {0x04, 0x69, 0x40, 0x42, 0x00, 0x00, 0x00, 0xa0, 0x00, 0x24, 0x00, 0x00}, // 315MHz
  472. {0x04, 0x6a, 0x40, 0x42, 0x00, 0x00, 0x00, 0xa0, 0x00, 0x24, 0x00, 0x00}, // 318MHz
  473. {0x04, 0x6b, 0x40, 0x42, 0x00, 0x00, 0x00, 0xa0, 0x00, 0x24, 0x00, 0x00}, // 321MHz
  474. {0x04, 0x6c, 0x40, 0x42, 0x00, 0x00, 0x00, 0xa0, 0x00, 0x24, 0x00, 0x00}, // 324MHz
  475. {0x04, 0x6d, 0x40, 0x42, 0x00, 0x00, 0x00, 0xa0, 0x00, 0x24, 0x00, 0x00}, // 327MHz
  476. {0x04, 0x6e, 0x40, 0x42, 0x00, 0x00, 0x00, 0xa0, 0x00, 0x24, 0x00, 0x00}, // 330MHz
  477. {0x04, 0x6f, 0x40, 0x42, 0x00, 0x00, 0x00, 0xa0, 0x00, 0x24, 0x00, 0x00}, // 333MHz
  478. {0x04, 0x70, 0x40, 0x42, 0x00, 0x00, 0x00, 0xa0, 0x00, 0x24, 0x00, 0x00}, // 336MHz
  479. {0x04, 0x71, 0x40, 0x42, 0x00, 0x00, 0x00, 0xa0, 0x00, 0x24, 0x00, 0x00}, // 339MHz
  480. {0x04, 0x72, 0x40, 0x42, 0x00, 0x00, 0x00, 0xa0, 0x00, 0x24, 0x00, 0x00}, // 342MHz
  481. {0x04, 0x73, 0x40, 0x42, 0x00, 0x00, 0x00, 0xa0, 0x00, 0x24, 0x00, 0x00}, // 345MHz
  482. {0x04, 0x74, 0x40, 0x42, 0x00, 0x00, 0x00, 0xa0, 0x00, 0x24, 0x00, 0x00}, // 348MHz
  483. {0x04, 0x75, 0x40, 0x42, 0x00, 0x00, 0x00, 0xa0, 0x00, 0x24, 0x00, 0x00}, // 351MHz
  484. {0x04, 0x76, 0x40, 0x42, 0x00, 0x00, 0x00, 0xa0, 0x00, 0x24, 0x00, 0x00}, // 354MHz
  485. {0x04, 0x77, 0x40, 0x42, 0x00, 0x00, 0x00, 0xa0, 0x00, 0x24, 0x00, 0x00}, // 357MHz
  486. {0x04, 0x78, 0x40, 0x42, 0x00, 0x00, 0x00, 0xa0, 0x00, 0x24, 0x00, 0x00}, // 360MHz
  487. {0x04, 0x79, 0x40, 0x42, 0x00, 0x00, 0x00, 0xa0, 0x00, 0x24, 0x00, 0x00}, // 363MHz
  488. {0x04, 0x7a, 0x40, 0x42, 0x00, 0x00, 0x00, 0xa0, 0x00, 0x24, 0x00, 0x00}, // 366MHz
  489. {0x04, 0x7b, 0x40, 0x42, 0x00, 0x00, 0x00, 0xa0, 0x00, 0x24, 0x00, 0x00}, // 369MHz
  490. {0x04, 0x7c, 0x40, 0x42, 0x00, 0x00, 0x00, 0xa0, 0x00, 0x24, 0x00, 0x00}, // 372MHz
  491. {0x04, 0x7d, 0x40, 0x42, 0x00, 0x00, 0x00, 0xa0, 0x00, 0x24, 0x00, 0x00}, // 375MHz
  492. {0x04, 0x7e, 0x40, 0x42, 0x00, 0x00, 0x00, 0xa0, 0x00, 0x24, 0x00, 0x00}, // 378MHz
  493. {0x04, 0x7f, 0x40, 0x42, 0x00, 0x00, 0x00, 0xa0, 0x00, 0x24, 0x00, 0x00}, // 381MHz
  494. {0x04, 0x80, 0x40, 0x42, 0x00, 0x00, 0x00, 0xa0, 0x00, 0x24, 0x00, 0x00}, // 384MHz
  495. {0x04, 0x81, 0x40, 0x42, 0x00, 0x00, 0x00, 0xa0, 0x00, 0x24, 0x00, 0x00}, // 387MHz
  496. {0x04, 0x82, 0x40, 0x42, 0x00, 0x00, 0x00, 0xa0, 0x00, 0x24, 0x00, 0x00}, // 390MHz
  497. {0x04, 0x83, 0x40, 0x42, 0x00, 0x00, 0x00, 0xa0, 0x00, 0x24, 0x00, 0x00}, // 393MHz
  498. {0x04, 0x84, 0x40, 0x42, 0x00, 0x00, 0x00, 0xa0, 0x00, 0x24, 0x00, 0x00}, // 396MHz
  499. {0x04, 0x85, 0x40, 0x42, 0x00, 0x00, 0x00, 0xa0, 0x00, 0x24, 0x00, 0x00}, // 399MHz
  500. {0x04, 0x86, 0x40, 0x42, 0x00, 0x00, 0x00, 0xa0, 0x00, 0x24, 0x00, 0x00}, // 402MHz
  501. {0x04, 0x87, 0x40, 0x42, 0x00, 0x00, 0x00, 0xa0, 0x00, 0x24, 0x00, 0x00}, // 405MHz
  502. {0x04, 0x88, 0x40, 0x42, 0x00, 0x00, 0x00, 0xa0, 0x00, 0x24, 0x00, 0x00}, // 408MHz
  503. {0x04, 0x89, 0x40, 0x42, 0x00, 0x00, 0x00, 0xa0, 0x00, 0x24, 0x00, 0x00}, // 411MHz
  504. {0x04, 0x8a, 0x40, 0x42, 0x00, 0x00, 0x00, 0xa0, 0x00, 0x24, 0x00, 0x00}, // 414MHz
  505. {0x04, 0x8b, 0x40, 0x42, 0x00, 0x00, 0x00, 0xa0, 0x00, 0x24, 0x00, 0x00}, // 417MHz
  506. {0x04, 0x8c, 0x40, 0x42, 0x00, 0x00, 0x00, 0xa0, 0x00, 0x24, 0x00, 0x00}, // 420MHz
  507. {0x04, 0x8d, 0x40, 0x42, 0x00, 0x00, 0x00, 0xa0, 0x00, 0x24, 0x00, 0x00}, // 423MHz
  508. {0x04, 0x8e, 0x40, 0x42, 0x00, 0x00, 0x00, 0xa0, 0x00, 0x24, 0x00, 0x00}, // 426MHz
  509. {0x04, 0x8f, 0x40, 0x42, 0x00, 0x00, 0x00, 0xa0, 0x00, 0x24, 0x00, 0x00}, // 429MHz
  510. {0x04, 0x90, 0x40, 0x42, 0x00, 0x00, 0x00, 0xa0, 0x00, 0x24, 0x00, 0x00}, // 432MHz
  511. {0x04, 0x91, 0x40, 0x42, 0x00, 0x00, 0x00, 0xa0, 0x00, 0x24, 0x00, 0x00}, // 435MHz
  512. {0x04, 0x92, 0x40, 0x42, 0x00, 0x00, 0x00, 0xa0, 0x00, 0x24, 0x00, 0x00}, // 438MHz
  513. {0x04, 0x93, 0x40, 0x42, 0x00, 0x00, 0x00, 0xa0, 0x00, 0x24, 0x00, 0x00}, // 441MHz
  514. {0x04, 0x94, 0x40, 0x42, 0x00, 0x00, 0x00, 0xa0, 0x00, 0x24, 0x00, 0x00}, // 444MHz
  515. {0x04, 0x95, 0x40, 0x42, 0x00, 0x00, 0x00, 0xa0, 0x00, 0x24, 0x00, 0x00}, // 447MHz
  516. {0x04, 0x96, 0x40, 0x42, 0x00, 0x00, 0x00, 0xa0, 0x00, 0x24, 0x00, 0x00}, // 450MHz
  517. {0x04, 0x97, 0x40, 0x42, 0x00, 0x00, 0x00, 0xa0, 0x00, 0x24, 0x00, 0x00}, // 453MHz
  518. {0x04, 0x98, 0x40, 0x42, 0x00, 0x00, 0x00, 0xa0, 0x00, 0x24, 0x00, 0x00}, // 456MHz
  519. {0x04, 0x99, 0x40, 0x42, 0x00, 0x00, 0x00, 0xa0, 0x00, 0x24, 0x00, 0x00}, // 459MHz
  520. {0x04, 0x9a, 0x40, 0x42, 0x00, 0x00, 0x00, 0xa0, 0x00, 0x24, 0x00, 0x00}, // 462MHz
  521. {0x04, 0x9b, 0x40, 0x42, 0x00, 0x00, 0x00, 0xa0, 0x00, 0x24, 0x00, 0x00}, // 465MHz
  522. {0x04, 0x9c, 0x40, 0x42, 0x00, 0x00, 0x00, 0xa0, 0x00, 0x24, 0x00, 0x00}, // 468MHz
  523. {0x04, 0x9d, 0x40, 0x42, 0x00, 0x00, 0x00, 0xa0, 0x00, 0x24, 0x00, 0x00}, // 471MHz
  524. {0x04, 0x9e, 0x40, 0x42, 0x00, 0x00, 0x00, 0xa0, 0x00, 0x24, 0x00, 0x00}, // 474MHz
  525. {0x04, 0x9f, 0x40, 0x42, 0x00, 0x00, 0x00, 0xa0, 0x00, 0x24, 0x00, 0x00}, // 477MHz
  526. {0x04, 0xa0, 0x40, 0x42, 0x00, 0x00, 0x00, 0xa0, 0x00, 0x24, 0x00, 0x00}, // 480MHz
  527. {0x04, 0xa1, 0x40, 0x42, 0x00, 0x00, 0x00, 0xa0, 0x00, 0x24, 0x00, 0x00}, // 483MHz
  528. {0x04, 0xa2, 0x40, 0x42, 0x00, 0x00, 0x00, 0xa0, 0x00, 0x24, 0x00, 0x00}, // 486MHz
  529. {0x04, 0xa3, 0x40, 0x42, 0x00, 0x00, 0x00, 0xa0, 0x00, 0x24, 0x00, 0x00}, // 489MHz
  530. {0x04, 0xa4, 0x40, 0x42, 0x00, 0x00, 0x00, 0xa0, 0x00, 0x24, 0x00, 0x00}, // 492MHz
  531. {0x04, 0xa5, 0x40, 0x42, 0x00, 0x00, 0x00, 0xa0, 0x00, 0x24, 0x00, 0x00}, // 495MHz
  532. {0x04, 0xa6, 0x40, 0x42, 0x00, 0x00, 0x00, 0xa0, 0x00, 0x24, 0x00, 0x00}, // 498MHz
  533. {0x04, 0xa7, 0x40, 0x42, 0x00, 0x00, 0x00, 0xa0, 0x00, 0x24, 0x00, 0x00}, // 501MHz
  534. {0x04, 0xa8, 0x40, 0x42, 0x00, 0x00, 0x00, 0xa0, 0x00, 0x24, 0x00, 0x00}, // 504MHz
  535. {0x04, 0xa9, 0x40, 0x42, 0x00, 0x00, 0x00, 0xa0, 0x00, 0x24, 0x00, 0x00}, // 507MHz
  536. {0x04, 0xaa, 0x40, 0x42, 0x00, 0x00, 0x00, 0xa0, 0x00, 0x24, 0x00, 0x00}, // 510MHz
  537. {0x04, 0xab, 0x40, 0x42, 0x00, 0x00, 0x00, 0xa0, 0x00, 0x24, 0x00, 0x00}, // 513MHz
  538. {0x04, 0xac, 0x40, 0x42, 0x00, 0x00, 0x00, 0xa0, 0x00, 0x24, 0x00, 0x00}, // 516MHz
  539. {0x04, 0xad, 0x40, 0x42, 0x00, 0x00, 0x00, 0xa0, 0x00, 0x24, 0x00, 0x00}, // 519MHz
  540. {0x04, 0xae, 0x40, 0x42, 0x00, 0x00, 0x00, 0xa0, 0x00, 0x24, 0x00, 0x00}, // 522MHz
  541. {0x04, 0xaf, 0x40, 0x42, 0x00, 0x00, 0x00, 0xa0, 0x00, 0x24, 0x00, 0x00}, // 525MHz
  542. {0x04, 0xb0, 0x40, 0x42, 0x00, 0x00, 0x00, 0xa0, 0x00, 0x24, 0x00, 0x00}, // 528MHz
  543. {0x04, 0xb1, 0x40, 0x42, 0x00, 0x00, 0x00, 0xa0, 0x00, 0x24, 0x00, 0x00}, // 531MHz
  544. {0x04, 0xb2, 0x40, 0x42, 0x00, 0x00, 0x00, 0xa0, 0x00, 0x24, 0x00, 0x00}, // 534MHz
  545. {0x04, 0xb3, 0x40, 0x42, 0x00, 0x00, 0x00, 0xa0, 0x00, 0x24, 0x00, 0x00}, // 537MHz
  546. {0x04, 0xb4, 0x40, 0x42, 0x00, 0x00, 0x00, 0xa0, 0x00, 0x24, 0x00, 0x00}, // 540MHz
  547. {0x04, 0xb5, 0x40, 0x42, 0x00, 0x00, 0x00, 0xa0, 0x00, 0x24, 0x00, 0x00}, // 543MHz
  548. {0x04, 0xb6, 0x40, 0x42, 0x00, 0x00, 0x00, 0xa0, 0x00, 0x24, 0x00, 0x00}, // 546MHz
  549. {0x04, 0xb7, 0x40, 0x42, 0x00, 0x00, 0x00, 0xa0, 0x00, 0x24, 0x00, 0x00}, // 549MHz
  550. {0x04, 0xb8, 0x40, 0x42, 0x00, 0x00, 0x00, 0xa0, 0x00, 0x20, 0x00, 0x00}, // 552MHz
  551. {0x04, 0xb9, 0x40, 0x42, 0x00, 0x00, 0x00, 0xa0, 0x00, 0x20, 0x00, 0x00}, // 555MHz
  552. {0x04, 0xba, 0x40, 0x42, 0x00, 0x00, 0x00, 0xa0, 0x00, 0x20, 0x00, 0x00}, // 558MHz
  553. {0x04, 0xbb, 0x40, 0x42, 0x00, 0x00, 0x00, 0xa0, 0x00, 0x20, 0x00, 0x00}, // 561MHz
  554. {0x04, 0xbc, 0x40, 0x42, 0x00, 0x00, 0x00, 0xa0, 0x00, 0x20, 0x00, 0x00}, // 564MHz
  555. {0x04, 0xbd, 0x40, 0x42, 0x00, 0x00, 0x00, 0xa0, 0x00, 0x20, 0x00, 0x00}, // 567MHz
  556. {0x04, 0xbe, 0x40, 0x42, 0x00, 0x00, 0x00, 0xa0, 0x00, 0x20, 0x00, 0x00}, // 570MHz
  557. {0x04, 0xbf, 0x40, 0x42, 0x00, 0x00, 0x00, 0xa0, 0x00, 0x20, 0x00, 0x00}, // 573MHz
  558. {0x04, 0xc0, 0x40, 0x42, 0x00, 0x00, 0x00, 0xa0, 0x00, 0x20, 0x00, 0x00}, // 576MHz
  559. {0x04, 0xc1, 0x40, 0x42, 0x00, 0x00, 0x00, 0xa0, 0x00, 0x20, 0x00, 0x00}, // 579MHz
  560. {0x04, 0xc2, 0x40, 0x42, 0x00, 0x00, 0x00, 0xa0, 0x00, 0x20, 0x00, 0x00}, // 582MHz
  561. {0x04, 0xc3, 0x40, 0x42, 0x00, 0x00, 0x00, 0xa0, 0x00, 0x20, 0x00, 0x00}, // 585MHz
  562. {0x04, 0xc4, 0x40, 0x42, 0x00, 0x00, 0x00, 0xa0, 0x00, 0x20, 0x00, 0x00}, // 588MHz
  563. {0x04, 0xc5, 0x40, 0x42, 0x00, 0x00, 0x00, 0xa0, 0x00, 0x20, 0x00, 0x00}, // 591MHz
  564. {0x04, 0xc6, 0x40, 0x42, 0x00, 0x00, 0x00, 0xa0, 0x00, 0x20, 0x00, 0x00}, // 594MHz
  565. {0x04, 0xc7, 0x40, 0x42, 0x00, 0x00, 0x00, 0xa0, 0x00, 0x20, 0x00, 0x00}, // 597MHz
  566. {0x04, 0x64, 0x40, 0x02, 0x00, 0x00, 0x00, 0xa0, 0x00, 0x20, 0x00, 0x00}, // 600MHz
  567. {0x04, 0x65, 0x40, 0x02, 0x00, 0x00, 0x00, 0xa0, 0x00, 0x20, 0x00, 0x00}, // 606MHz
  568. {0x04, 0x66, 0x40, 0x02, 0x00, 0x00, 0x00, 0xa0, 0x00, 0x20, 0x00, 0x00}, // 612MHz
  569. {0x04, 0x67, 0x40, 0x02, 0x00, 0x00, 0x00, 0xa0, 0x00, 0x20, 0x00, 0x00}, // 618MHz
  570. {0x04, 0x68, 0x40, 0x02, 0x00, 0x00, 0x00, 0xa0, 0x00, 0x20, 0x00, 0x00}, // 624MHz
  571. {0x04, 0x69, 0x40, 0x02, 0x00, 0x00, 0x00, 0xa0, 0x00, 0x20, 0x00, 0x00}, // 630MHz
  572. {0x04, 0x6a, 0x40, 0x02, 0x00, 0x00, 0x00, 0xa0, 0x00, 0x20, 0x00, 0x00}, // 636MHz
  573. {0x04, 0x6b, 0x40, 0x02, 0x00, 0x00, 0x00, 0xa0, 0x00, 0x20, 0x00, 0x00}, // 642MHz
  574. {0x04, 0x6c, 0x40, 0x02, 0x00, 0x00, 0x00, 0xa0, 0x00, 0x20, 0x00, 0x00}, // 648MHz
  575. {0x04, 0x6d, 0x40, 0x02, 0x00, 0x00, 0x00, 0xa0, 0x00, 0x20, 0x00, 0x00}, // 654MHz
  576. {0x04, 0x6e, 0x40, 0x02, 0x00, 0x00, 0x00, 0xa0, 0x00, 0x20, 0x00, 0x00}, // 660MHz
  577. {0x04, 0x6f, 0x40, 0x02, 0x00, 0x00, 0x00, 0xa0, 0x00, 0x20, 0x00, 0x00}, // 666MHz
  578. {0x04, 0x70, 0x40, 0x02, 0x00, 0x00, 0x00, 0xa0, 0x00, 0x20, 0x00, 0x00}, // 672MHz
  579. {0x04, 0x71, 0x40, 0x02, 0x00, 0x00, 0x00, 0xa0, 0x00, 0x20, 0x00, 0x00}, // 678MHz
  580. {0x04, 0x72, 0x40, 0x02, 0x00, 0x00, 0x00, 0xa0, 0x00, 0x20, 0x00, 0x00}, // 684MHz
  581. {0x04, 0x73, 0x40, 0x02, 0x00, 0x00, 0x00, 0xa0, 0x00, 0x20, 0x00, 0x00}, // 690MHz
  582. {0x04, 0x74, 0x40, 0x02, 0x00, 0x00, 0x00, 0xa0, 0x00, 0x20, 0x00, 0x00}, // 696MHz
  583. {0x04, 0x75, 0x40, 0x02, 0x00, 0x00, 0x00, 0xa0, 0x00, 0x20, 0x00, 0x00}, // 702MHz
  584. {0x04, 0x76, 0x40, 0x02, 0x00, 0x00, 0x00, 0xa0, 0x00, 0x20, 0x00, 0x00}, // 708MHz
  585. {0x04, 0x77, 0x40, 0x02, 0x00, 0x00, 0x00, 0xa0, 0x00, 0x20, 0x00, 0x00}, // 714MHz
  586. {0x04, 0x78, 0x40, 0x02, 0x00, 0x00, 0x00, 0xa0, 0x00, 0x20, 0x00, 0x00}, // 720MHz
  587. {0x04, 0x79, 0x40, 0x02, 0x00, 0x00, 0x00, 0xa0, 0x00, 0x20, 0x00, 0x00}, // 726MHz
  588. {0x04, 0x7a, 0x40, 0x02, 0x00, 0x00, 0x00, 0xa0, 0x00, 0x20, 0x00, 0x00}, // 732MHz
  589. {0x04, 0x7b, 0x40, 0x02, 0x00, 0x00, 0x00, 0xa0, 0x00, 0x20, 0x00, 0x00}, // 738MHz
  590. {0x04, 0x7c, 0x40, 0x02, 0x00, 0x00, 0x00, 0xa0, 0x00, 0x20, 0x00, 0x00}, // 744MHz
  591. {0x04, 0x7d, 0x40, 0x02, 0x00, 0x00, 0x00, 0xa0, 0x00, 0x20, 0x00, 0x00}, // 750MHz
  592. {0x04, 0x7e, 0x40, 0x02, 0x00, 0x00, 0x00, 0xa0, 0x00, 0x20, 0x00, 0x00}, // 756MHz
  593. {0x04, 0x7f, 0x40, 0x02, 0x00, 0x00, 0x00, 0xa0, 0x00, 0x20, 0x00, 0x00}, // 762MHz
  594. {0x04, 0x80, 0x40, 0x02, 0x00, 0x00, 0x00, 0xa0, 0x00, 0x20, 0x00, 0x00}, // 768MHz
  595. {0x04, 0x81, 0x40, 0x02, 0x00, 0x00, 0x00, 0xa0, 0x00, 0x20, 0x00, 0x00}, // 774MHz
  596. {0x04, 0x82, 0x40, 0x02, 0x00, 0x00, 0x00, 0xa0, 0x00, 0x20, 0x00, 0x00}, // 780MHz
  597. {0x04, 0x83, 0x40, 0x02, 0x00, 0x00, 0x00, 0xa0, 0x00, 0x20, 0x00, 0x00}, // 786MHz
  598. {0x04, 0x84, 0x40, 0x02, 0x00, 0x00, 0x00, 0xa0, 0x00, 0x20, 0x00, 0x00}, // 792MHz
  599. {0x04, 0x85, 0x40, 0x02, 0x00, 0x00, 0x00, 0xa0, 0x00, 0x20, 0x00, 0x00}, // 798MHz
  600. {0x04, 0x86, 0x40, 0x02, 0x00, 0x00, 0x00, 0xa0, 0x00, 0x20, 0x00, 0x00}, // 804MHz
  601. {0x04, 0x87, 0x40, 0x02, 0x00, 0x00, 0x00, 0xa0, 0x00, 0x20, 0x00, 0x00}, // 810MHz
  602. {0x04, 0x88, 0x40, 0x02, 0x00, 0x00, 0x00, 0xa0, 0x00, 0x20, 0x00, 0x00}, // 816MHz
  603. {0x04, 0x89, 0x40, 0x02, 0x00, 0x00, 0x00, 0xa0, 0x00, 0x20, 0x00, 0x00}, // 822MHz
  604. {0x04, 0x8a, 0x40, 0x02, 0x00, 0x00, 0x00, 0xa0, 0x00, 0x20, 0x00, 0x00}, // 828MHz
  605. {0x04, 0x8b, 0x40, 0x02, 0x00, 0x00, 0x00, 0xa0, 0x00, 0x20, 0x00, 0x00}, // 834MHz
  606. {0x04, 0x8c, 0x40, 0x02, 0x00, 0x00, 0x00, 0xa0, 0x00, 0x20, 0x00, 0x00}, // 840MHz
  607. {0x04, 0x8d, 0x40, 0x02, 0x00, 0x00, 0x00, 0xa0, 0x00, 0x20, 0x00, 0x00}, // 846MHz
  608. {0x04, 0x8e, 0x40, 0x02, 0x00, 0x00, 0x00, 0xa0, 0x00, 0x20, 0x00, 0x00}, // 852MHz
  609. {0x04, 0x8f, 0x40, 0x02, 0x00, 0x00, 0x00, 0xa0, 0x00, 0x20, 0x00, 0x00}, // 858MHz
  610. {0x04, 0x90, 0x40, 0x02, 0x00, 0x00, 0x00, 0xa0, 0x00, 0x20, 0x00, 0x00}, // 864MHz
  611. {0x04, 0x91, 0x40, 0x02, 0x00, 0x00, 0x00, 0xa0, 0x00, 0x20, 0x00, 0x00}, // 870MHz
  612. {0x04, 0x92, 0x40, 0x02, 0x00, 0x00, 0x00, 0xa0, 0x00, 0x20, 0x00, 0x00}, // 876MHz
  613. {0x04, 0x93, 0x40, 0x02, 0x00, 0x00, 0x00, 0xa0, 0x00, 0x20, 0x00, 0x00}, // 882MHz
  614. {0x04, 0x94, 0x40, 0x02, 0x00, 0x00, 0x00, 0xa0, 0x00, 0x20, 0x00, 0x00}, // 888MHz
  615. {0x04, 0x95, 0x40, 0x02, 0x00, 0x00, 0x00, 0xa0, 0x00, 0x20, 0x00, 0x00}, // 894MHz
  616. {0x04, 0x96, 0x40, 0x02, 0x00, 0x00, 0x00, 0xa0, 0x00, 0x20, 0x00, 0x00}, // 900MHz
  617. {0x04, 0x97, 0x40, 0x02, 0x00, 0x00, 0x00, 0xa0, 0x00, 0x20, 0x00, 0x00}, // 906MHz
  618. {0x04, 0x98, 0x40, 0x02, 0x00, 0x00, 0x00, 0xa0, 0x00, 0x20, 0x00, 0x00}, // 912MHz
  619. {0x04, 0x99, 0x40, 0x02, 0x00, 0x00, 0x00, 0xa0, 0x00, 0x20, 0x00, 0x00}, // 918MHz
  620. {0x04, 0x9a, 0x40, 0x02, 0x00, 0x00, 0x00, 0xa0, 0x00, 0x20, 0x00, 0x00}, // 924MHz
  621. {0x04, 0x9b, 0x40, 0x02, 0x00, 0x00, 0x00, 0xa0, 0x00, 0x20, 0x00, 0x00}, // 930MHz
  622. {0x04, 0x9c, 0x40, 0x02, 0x00, 0x00, 0x00, 0xa0, 0x00, 0x20, 0x00, 0x00}, // 936MHz
  623. {0x04, 0x9d, 0x40, 0x02, 0x00, 0x00, 0x00, 0xa0, 0x00, 0x20, 0x00, 0x00}, // 942MHz
  624. {0x04, 0x9e, 0x40, 0x02, 0x00, 0x00, 0x00, 0xa0, 0x00, 0x20, 0x00, 0x00}, // 948MHz
  625. {0x04, 0x9f, 0x40, 0x02, 0x00, 0x00, 0x00, 0xa0, 0x00, 0x20, 0x00, 0x00}, // 954MHz
  626. {0x04, 0xa0, 0x40, 0x02, 0x00, 0x00, 0x00, 0xa0, 0x00, 0x20, 0x00, 0x00}, // 960MHz
  627. {0x04, 0xa1, 0x40, 0x02, 0x00, 0x00, 0x00, 0xa0, 0x00, 0x20, 0x00, 0x00}, // 966MHz
  628. {0x04, 0xa2, 0x40, 0x02, 0x00, 0x00, 0x00, 0xa0, 0x00, 0x20, 0x00, 0x00}, // 972MHz
  629. {0x04, 0xa3, 0x40, 0x02, 0x00, 0x00, 0x00, 0xa0, 0x00, 0x20, 0x00, 0x00}, // 978MHz
  630. {0x04, 0xa4, 0x40, 0x02, 0x00, 0x00, 0x00, 0xa0, 0x00, 0x20, 0x00, 0x00}, // 984MHz
  631. {0x04, 0xa5, 0x40, 0x02, 0x00, 0x00, 0x00, 0xa0, 0x00, 0x20, 0x00, 0x00}, // 990MHz
  632. {0x04, 0xa6, 0x40, 0x02, 0x00, 0x00, 0x00, 0xa0, 0x00, 0x20, 0x00, 0x00}, // 996MHz
  633. {0x04, 0xa7, 0x40, 0x02, 0x00, 0x00, 0x00, 0xa0, 0x00, 0x20, 0x00, 0x00}, // 1002MHz
  634. {0x04, 0xa8, 0x40, 0x02, 0x00, 0x00, 0x00, 0xa0, 0x00, 0x20, 0x00, 0x00}, // 1008MHz
  635. {0x04, 0xa9, 0x40, 0x02, 0x00, 0x00, 0x00, 0xa0, 0x00, 0x20, 0x00, 0x00}, // 1014MHz
  636. {0x04, 0xaa, 0x40, 0x02, 0x00, 0x00, 0x00, 0xa0, 0x00, 0x20, 0x00, 0x00}, // 1020MHz
  637. {0x04, 0xab, 0x40, 0x02, 0x00, 0x00, 0x00, 0xa0, 0x00, 0x20, 0x00, 0x00}, // 1026MHz
  638. {0x04, 0xac, 0x40, 0x02, 0x00, 0x00, 0x00, 0xa0, 0x00, 0x20, 0x00, 0x00}, // 1032MHz
  639. {0x04, 0xad, 0x40, 0x02, 0x00, 0x00, 0x00, 0xa0, 0x00, 0x20, 0x00, 0x00}, // 1038MHz
  640. {0x04, 0xae, 0x40, 0x02, 0x00, 0x00, 0x00, 0xa0, 0x00, 0x20, 0x00, 0x00}, // 1044MHz
  641. {0x04, 0xaf, 0x40, 0x02, 0x00, 0x00, 0x00, 0xa0, 0x00, 0x20, 0x00, 0x00}, // 1050MHz
  642. {0x04, 0xb0, 0x40, 0x02, 0x00, 0x00, 0x00, 0xa0, 0x00, 0x20, 0x00, 0x00}, // 1056MHz
  643. {0x04, 0xb1, 0x40, 0x02, 0x00, 0x00, 0x00, 0xa0, 0x00, 0x20, 0x00, 0x00}, // 1062MHz
  644. {0x04, 0xb2, 0x40, 0x02, 0x00, 0x00, 0x00, 0xa0, 0x00, 0x20, 0x00, 0x00}, // 1068MHz
  645. {0x04, 0xb3, 0x40, 0x02, 0x00, 0x00, 0x00, 0xa0, 0x00, 0x20, 0x00, 0x00}, // 1074MHz
  646. {0x04, 0xb4, 0x40, 0x02, 0x00, 0x00, 0x00, 0xa0, 0x00, 0x20, 0x00, 0x00}, // 1080MHz
  647. {0x04, 0xb5, 0x40, 0x02, 0x00, 0x00, 0x00, 0xa0, 0x00, 0x20, 0x00, 0x00}, // 1086MHz
  648. {0x04, 0xb6, 0x40, 0x02, 0x00, 0x00, 0x00, 0xa0, 0x00, 0x20, 0x00, 0x00}, // 1092MHz
  649. {0x04, 0xb7, 0x40, 0x02, 0x00, 0x00, 0x00, 0xa0, 0x00, 0x20, 0x00, 0x00}, // 1098MHz
  650. {0x04, 0xb8, 0x40, 0x02, 0x00, 0x00, 0x00, 0xa0, 0x00, 0x20, 0x00, 0x00}, // 1104MHz
  651. {0x04, 0xb9, 0x40, 0x02, 0x00, 0x00, 0x00, 0xa0, 0x00, 0x20, 0x00, 0x00}, // 1110MHz
  652. {0x04, 0xba, 0x40, 0x02, 0x00, 0x00, 0x00, 0xa0, 0x00, 0x20, 0x00, 0x00}, // 1116MHz
  653. {0x04, 0xbb, 0x40, 0x02, 0x00, 0x00, 0x00, 0xa0, 0x00, 0x20, 0x00, 0x00}, // 1122MHz
  654. {0x04, 0xbc, 0x40, 0x02, 0x00, 0x00, 0x00, 0xa0, 0x00, 0x20, 0x00, 0x00}, // 1128MHz
  655. {0x04, 0xbd, 0x40, 0x02, 0x00, 0x00, 0x00, 0xa0, 0x00, 0x20, 0x00, 0x00}, // 1134MHz
  656. {0x04, 0xbe, 0x40, 0x02, 0x00, 0x00, 0x00, 0xa0, 0x00, 0x20, 0x00, 0x00}, // 1140MHz
  657. {0x04, 0xbf, 0x40, 0x02, 0x00, 0x00, 0x00, 0xa0, 0x00, 0x20, 0x00, 0x00}, // 1146MHz
  658. {0x04, 0xc0, 0x40, 0x02, 0x00, 0x00, 0x00, 0xa0, 0x00, 0x20, 0x00, 0x00}, // 1152MHz
  659. {0x04, 0xc1, 0x40, 0x02, 0x00, 0x00, 0x00, 0xa0, 0x00, 0x20, 0x00, 0x00}, // 1158MHz
  660. {0x04, 0xc2, 0x40, 0x02, 0x00, 0x00, 0x00, 0xa0, 0x00, 0x20, 0x00, 0x00}, // 1164MHz
  661. {0x04, 0xc3, 0x40, 0x02, 0x00, 0x00, 0x00, 0xa0, 0x00, 0x20, 0x00, 0x00}, // 1170MHz
  662. {0x04, 0xc4, 0x40, 0x02, 0x00, 0x00, 0x00, 0xa0, 0x00, 0x20, 0x00, 0x00}, // 1176MHz
  663. {0x04, 0xc5, 0x40, 0x02, 0x00, 0x00, 0x00, 0xa0, 0x00, 0x20, 0x00, 0x00}, // 1182MHz
  664. {0x04, 0xc6, 0x40, 0x02, 0x00, 0x00, 0x00, 0xa0, 0x00, 0x20, 0x00, 0x00}, // 1188MHz
  665. {0x04, 0xc7, 0x40, 0x02, 0x00, 0x00, 0x00, 0xa0, 0x00, 0x20, 0x00, 0x00}, // 1194MHz
  666. {0x02, 0x64, 0x40, 0x02, 0x00, 0x00, 0x00, 0xa0, 0x00, 0x20, 0x00, 0x00}, // 1200MHz
  667. {0x02, 0x65, 0x40, 0x02, 0x00, 0x00, 0x00, 0xa0, 0x00, 0x20, 0x00, 0x00}, // 1212MHz
  668. {0x02, 0x66, 0x40, 0x02, 0x00, 0x00, 0x00, 0xa0, 0x00, 0x20, 0x00, 0x00}, // 1224MHz
  669. {0x02, 0x67, 0x40, 0x02, 0x00, 0x00, 0x00, 0xa0, 0x00, 0x20, 0x00, 0x00}, // 1236MHz
  670. {0x02, 0x68, 0x40, 0x02, 0x00, 0x00, 0x00, 0xa0, 0x00, 0x20, 0x00, 0x00}, // 1248MHz
  671. {0x02, 0x69, 0x40, 0x02, 0x00, 0x00, 0x00, 0xa0, 0x00, 0x20, 0x00, 0x00}, // 1260MHz
  672. {0x02, 0x6a, 0x40, 0x02, 0x00, 0x00, 0x00, 0xa0, 0x00, 0x20, 0x00, 0x00}, // 1272MHz
  673. {0x02, 0x6b, 0x40, 0x02, 0x00, 0x00, 0x00, 0xa0, 0x00, 0x20, 0x00, 0x00}, // 1284MHz
  674. {0x02, 0x6c, 0x40, 0x02, 0x00, 0x00, 0x00, 0xa0, 0x00, 0x20, 0x00, 0x00}, // 1296MHz
  675. {0x02, 0x6d, 0x40, 0x02, 0x00, 0x00, 0x00, 0xa0, 0x00, 0x20, 0x00, 0x00}, // 1308MHz
  676. {0x02, 0x6e, 0x40, 0x02, 0x00, 0x00, 0x00, 0xa0, 0x00, 0x20, 0x00, 0x00}, // 1320MHz
  677. {0x02, 0x6f, 0x40, 0x02, 0x00, 0x00, 0x00, 0xa0, 0x00, 0x20, 0x00, 0x00}, // 1332MHz
  678. {0x02, 0x70, 0x40, 0x02, 0x00, 0x00, 0x00, 0xa0, 0x00, 0x20, 0x00, 0x00}, // 1344MHz
  679. {0x02, 0x71, 0x40, 0x02, 0x00, 0x00, 0x00, 0xa0, 0x00, 0x20, 0x00, 0x00}, // 1356MHz
  680. {0x02, 0x72, 0x40, 0x02, 0x00, 0x00, 0x00, 0xa0, 0x00, 0x20, 0x00, 0x00}, // 1368MHz
  681. {0x02, 0x73, 0x40, 0x02, 0x00, 0x00, 0x00, 0xa0, 0x00, 0x20, 0x00, 0x00}, // 1380MHz
  682. {0x02, 0x74, 0x40, 0x02, 0x00, 0x00, 0x00, 0xa0, 0x00, 0x20, 0x00, 0x00}, // 1392MHz
  683. {0x02, 0x75, 0x40, 0x02, 0x00, 0x00, 0x00, 0xa0, 0x00, 0x20, 0x00, 0x00}, // 1404MHz
  684. {0x02, 0x76, 0x40, 0x02, 0x00, 0x00, 0x00, 0xa0, 0x00, 0x20, 0x00, 0x00}, // 1416MHz
  685. {0x02, 0x77, 0x40, 0x02, 0x00, 0x00, 0x00, 0xa0, 0x00, 0x20, 0x00, 0x00}, // 1428MHz
  686. {0x02, 0x78, 0x40, 0x02, 0x00, 0x00, 0x00, 0xa0, 0x00, 0x20, 0x00, 0x00}, // 1440MHz
  687. {0x02, 0x79, 0x40, 0x02, 0x00, 0x00, 0x00, 0xa0, 0x00, 0x20, 0x00, 0x00}, // 1452MHz
  688. {0x02, 0x7a, 0x40, 0x02, 0x00, 0x00, 0x00, 0xa0, 0x00, 0x20, 0x00, 0x00}, // 1464MHz
  689. {0x02, 0x7b, 0x40, 0x02, 0x00, 0x00, 0x00, 0xa0, 0x00, 0x20, 0x00, 0x00}, // 1476MHz
  690. {0x02, 0x7c, 0x40, 0x02, 0x00, 0x00, 0x00, 0xa0, 0x00, 0x20, 0x00, 0x00}, // 1488MHz
  691. {0x02, 0x7d, 0x40, 0x02, 0x00, 0x00, 0x00, 0xa0, 0x00, 0x20, 0x00, 0x00}, // 1500MHz
  692. {0x02, 0x7e, 0x40, 0x02, 0x00, 0x00, 0x00, 0xa0, 0x00, 0x20, 0x00, 0x00}, // 1512MHz
  693. {0x02, 0x7f, 0x40, 0x02, 0x00, 0x00, 0x00, 0xa0, 0x00, 0x20, 0x00, 0x00}, // 1524MHz
  694. {0x02, 0x80, 0x40, 0x02, 0x00, 0x00, 0x00, 0xa0, 0x00, 0x20, 0x00, 0x00}, // 1536MHz
  695. {0x02, 0x81, 0x40, 0x02, 0x00, 0x00, 0x00, 0xa0, 0x00, 0x20, 0x00, 0x00}, // 1548MHz
  696. {0x02, 0x82, 0x40, 0x02, 0x00, 0x00, 0x00, 0xa0, 0x00, 0x20, 0x00, 0x00}, // 1560MHz
  697. {0x02, 0x83, 0x40, 0x02, 0x00, 0x00, 0x00, 0xa0, 0x00, 0x20, 0x00, 0x00}, // 1572MHz
  698. {0x02, 0x84, 0x40, 0x02, 0x00, 0x00, 0x00, 0xa0, 0x00, 0x20, 0x00, 0x00}, // 1584MHz
  699. {0x02, 0x85, 0x40, 0x02, 0x00, 0x00, 0x00, 0xa0, 0x00, 0x20, 0x00, 0x00}, // 1596MHz
  700. };
  701. extern struct T1_chain *chain[MAX_CHAIN_NUM];
  702. extern uint8_t chain_mask;
  703. extern hardware_version_e g_hwver;
  704. //int chain_voltage_flag[MAX_CHAIN_NUM];
  705. #if 0
  706. const unsigned short wCRCTalbeAbs[] =
  707. {
  708. 0x0000, 0xCC01, 0xD801, 0x1400,
  709. 0xF001, 0x3C00, 0x2800, 0xE401,
  710. 0xA001, 0x6C00, 0x7800, 0xB401,
  711. 0x5000, 0x9C01, 0x8801, 0x4400,
  712. };
  713. unsigned short CRC16_2(unsigned char* pchMsg, unsigned short wDataLen)
  714. {
  715. volatile unsigned short wCRC = 0xFFFF;
  716. unsigned short i;
  717. unsigned char chChar;
  718. for (i = 0; i < wDataLen; i++)
  719. {
  720. chChar = *pchMsg++;
  721. wCRC = wCRCTalbeAbs[(chChar ^ wCRC) & 15] ^ (wCRC >> 4);
  722. wCRC = wCRCTalbeAbs[((chChar >> 4) ^ wCRC) & 15] ^ (wCRC >> 4);
  723. }
  724. return wCRC;
  725. }
  726. #endif
  727. static void applog_hexdump(char *prefix, uint8_t *buff, int len, int level)
  728. {
  729. static char line[512];
  730. char *pos = line;
  731. int i;
  732. if (len < 1)
  733. {
  734. return;
  735. }
  736. pos += sprintf(pos, "%s: %d bytes:", prefix, len);
  737. for (i = 0; i < len; i++)
  738. {
  739. if (i > 0 && (i % 32) == 0)
  740. {
  741. applog(LOG_INFO, "%s", line);
  742. pos = line;
  743. pos += sprintf(pos, "\t");
  744. }
  745. pos += sprintf(pos, "%.2X ", buff[i]);
  746. }
  747. applog(level, "%s", line);
  748. }
  749. void hexdump(char *prefix, uint8_t *buff, int len)
  750. {
  751. applog_hexdump(prefix, buff, len, LOG_WARNING);
  752. }
  753. void hexdump_error(char *prefix, uint8_t *buff, int len)
  754. {
  755. applog_hexdump(prefix, buff, len, LOG_ERR);
  756. }
  757. bool dm_cmd_resetall(uint8_t chain_id, uint8_t chip_id, uint8_t *result)
  758. {
  759. uint8_t cmd[2] = {0x0, 0x0};
  760. return mcompat_cmd_reset(chain_id, chip_id, cmd, result);
  761. }
  762. bool dm_cmd_resetjob(uint8_t chain_id, uint8_t chip_id, uint8_t *result)
  763. {
  764. uint8_t cmd[2] = {0xed, 0xed};
  765. return mcompat_cmd_reset(chain_id, chip_id, cmd, result);
  766. }
  767. bool dm_cmd_resetbist(uint8_t chain_id, uint8_t chip_id, uint8_t *result)
  768. {
  769. uint8_t cmd[2] = {0x20, 0x20};
  770. return mcompat_cmd_reset(chain_id, chip_id, cmd, result);
  771. }
  772. int T1_ConfigT1PLLClock(uint32_t optPll)
  773. {
  774. int i;
  775. int T1Pll = 0;
  776. if (optPll > 0) {
  777. if (optPll <= PLL_Clk_12Mhz[0].speedMHz) {
  778. T1Pll = 0; //found
  779. } else {
  780. for (i = 1; i < T1_PLL_LV_NUM; i++) {
  781. if (optPll < PLL_Clk_12Mhz[i].speedMHz
  782. && optPll >= PLL_Clk_12Mhz[i-1].speedMHz) {
  783. T1Pll = i - 1; //found
  784. break;
  785. }
  786. }
  787. }
  788. }
  789. return T1Pll;
  790. }
  791. bool T1_SetT1PLLClock(struct T1_chain *t1, int pllClkIdx, int chip_id)
  792. {
  793. uint8_t temp_reg[REG_LENGTH];
  794. int cid = t1->chain_id;
  795. memcpy(temp_reg, default_reg[pllClkIdx], REG_LENGTH);
  796. if (!mcompat_cmd_write_register(cid, chip_id, temp_reg, REG_LENGTH)) {
  797. applog(LOG_WARNING, "Failed to set PLL Lv.%d on T1 %d in T1_SetT1PLLClock", pllClkIdx, cid);
  798. return false;
  799. }
  800. if (chip_id) {
  801. applog(LOG_NOTICE, "T1 %d chip %d PLL set to %d %d MHz", cid, chip_id,
  802. pllClkIdx, PLL_Clk_12Mhz[pllClkIdx].speedMHz);
  803. } else {
  804. applog(LOG_NOTICE, "T1 %d PLL set to %d %d MHz", cid,
  805. pllClkIdx, PLL_Clk_12Mhz[pllClkIdx].speedMHz);
  806. t1->pll = pllClkIdx;
  807. }
  808. return true;
  809. }
  810. uint8_t *create_job(uint8_t chip_id, uint8_t job_id, struct work *work)
  811. {
  812. double sdiff = work->device_diff;
  813. uint8_t tmp_buf[JOB_LENGTH];
  814. uint16_t crc;
  815. uint8_t i;
  816. static uint8_t job[JOB_LENGTH] = {
  817. /* command */
  818. 0x00, 0x00,
  819. /* midstate3 */
  820. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  821. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  822. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  823. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  824. /* midstate2 */
  825. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  826. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  827. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  828. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  829. /* midstate1 */
  830. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  831. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  832. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  833. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  834. /* midstate0 */
  835. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  836. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  837. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  838. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  839. /* wdata */
  840. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  841. 0x00, 0x00, 0x00, 0x00,
  842. /* start nonce */
  843. 0x00, 0x00, 0x00, 0x00,
  844. /* difficulty 1 */
  845. 0xff, 0xff, 0x00, 0x1d,
  846. /* end nonce */
  847. 0xff, 0xff, 0xff, 0xff,
  848. 0x00, 0x00, 0x00, 0x00,
  849. /* crc data */
  850. 0x00, 0x00, 0x00, 0x00
  851. };
  852. uint32_t *p1 = (uint32_t *) &job[130];
  853. uint32_t *p2 = (uint32_t *) (work->data + 64);
  854. uint32_t diffIdx;
  855. //uint32_t diffIdx,*diff=(uint32_t*)&job[50]; //difficulty pointer
  856. job[0] = (job_id << 4) | CMD_WRITE_JOB_T1; // fixed by duanhao
  857. job[1] = chip_id;
  858. swab256(job + 2, work->midstate3);
  859. swab256(job + 34, work->midstate2);
  860. swab256(job + 66, work->midstate1);
  861. swab256(job + 98, work->midstate);
  862. p1 = (uint32_t *) &job[130];
  863. p2 = (uint32_t *) (work->data + 64);
  864. p1[0] = bswap_32(p2[0]);
  865. p1[1] = bswap_32(p2[1]);
  866. p1[2] = bswap_32(p2[2]);
  867. uint8_t diff[4] = {0x1e, 0x03, 0xff, 0xff};
  868. if (sdiff>131072)
  869. memcpy(diff, &(difficult_Tbl[23]), 4);
  870. else if (sdiff>65536)
  871. memcpy(diff, &(difficult_Tbl[22]), 4);
  872. else if (sdiff>32767)
  873. memcpy(diff, &(difficult_Tbl[21]), 4);
  874. else if (sdiff>16383)
  875. memcpy(diff, &(difficult_Tbl[20]), 4);
  876. else if (sdiff>8191)
  877. memcpy(diff, &(difficult_Tbl[19]), 4);
  878. else if (sdiff>4095)
  879. memcpy(diff, &(difficult_Tbl[18]), 4);
  880. else if (sdiff>2047)
  881. memcpy(diff, &(difficult_Tbl[17]), 4);
  882. else if (sdiff>1023)
  883. memcpy(diff, &(difficult_Tbl[16]), 4);
  884. else if (sdiff > 511)
  885. memcpy(diff, &(difficult_Tbl[15]), 4);
  886. else if (sdiff > 255)
  887. memcpy(diff, &(difficult_Tbl[14]), 4);
  888. else {
  889. if (opt_diff>=1&&opt_diff<=17)
  890. {
  891. diffIdx=opt_diff-1;
  892. memcpy(diff, &(difficult_Tbl[diffIdx]), 4);
  893. }
  894. else
  895. memcpy(diff, &(difficult_Tbl[13]), 4);
  896. }
  897. memcpy(job+146, diff, 4);
  898. memset(tmp_buf, 0, sizeof(tmp_buf));
  899. for(i = 0; i < 79; i++)
  900. {
  901. tmp_buf[(2 * i) + 1] = job[(2 * i) + 0];
  902. tmp_buf[(2 * i) + 0] = job[(2 * i) + 1];
  903. }
  904. crc = CRC16_2(tmp_buf, 158);
  905. job[158] = (uint8_t)((crc >> 8) & 0xff);
  906. job[159] = (uint8_t)((crc >> 0) & 0xff);
  907. //applog(LOG_NOTICE, "[create job] %d \r", sdiff);
  908. //hexdump("job:", job, JOB_LENGTH);
  909. return job;
  910. }
  911. #define COOLDOWN_MS (30 * 1000)
  912. #define DISABLE_CHIP_FAIL_THRESHOLD 3
  913. #define LEAST_CORE_ONE_CHAIN 603
  914. #define RESET_CHAIN_CNT 2
  915. /********** disable / re-enable related section (temporary for testing) */
  916. int get_current_ms(void)
  917. {
  918. cgtimer_t ct;
  919. cgtimer_time(&ct);
  920. return cgtimer_to_ms(&ct);
  921. }
  922. bool is_chip_disabled(struct T1_chain *t1, uint8_t chip_id)
  923. {
  924. struct T1_chip *chip = &t1->chips[chip_id - 1];
  925. return chip->disabled || chip->cooldown_begin != 0;
  926. }
  927. /* check and disable chip, remember time */
  928. void disable_chip(struct T1_chain *t1, uint8_t chip_id)
  929. {
  930. // flush_spi(t1);
  931. struct T1_chip *chip = &t1->chips[chip_id - 1];
  932. int cid = t1->chain_id;
  933. if (is_chip_disabled(t1, chip_id)) {
  934. applog(LOG_WARNING, "%d: chip %d already disabled",
  935. cid, chip_id);
  936. return;
  937. }
  938. applog(LOG_WARNING, "%d: temporary disabling chip %d", cid, chip_id);
  939. chip->cooldown_begin = get_current_ms();
  940. }
  941. bool set_work(struct T1_chain *t1, uint8_t chip_id, struct work *work, uint8_t queue_states)
  942. {
  943. int cid = t1->chain_id;
  944. struct T1_chip *chip = &t1->chips[chip_id - 1];
  945. bool retval = false;
  946. int job_id = chip->last_queued_id + 1;
  947. //if (chip_id==1) applog(LOG_INFO, "%d: queuing chip %d with job_id %d, state=0x%02x", cid, chip_id, job_id, queue_states);
  948. //applog(LOG_INFO, "%d: queuing chip %d with job_id %d, state=0x%02x", cid, chip_id, job_id, queue_states);
  949. if (job_id == (queue_states & 0x0f) || job_id == (queue_states >> 4))
  950. {
  951. applog(LOG_WARNING, "%d: job overlap: %d, 0x%02x", cid, job_id, queue_states);
  952. }
  953. if (chip->work[chip->last_queued_id] != NULL)
  954. {
  955. free_work(chip->work[chip->last_queued_id]);
  956. retval = true;
  957. }
  958. uint8_t *jobdata = create_job(chip_id, job_id, work);
  959. if (!mcompat_cmd_write_job(cid, chip_id, jobdata, JOB_LENGTH))
  960. {
  961. /* give back work */
  962. free_work(work);
  963. applog(LOG_ERR, "%d: failed to set work for chip %d.%d", cid, chip_id, job_id);
  964. disable_chip(t1, chip_id);
  965. }
  966. else
  967. {
  968. chip->work[chip->last_queued_id] = work;
  969. chip->last_queued_id++;
  970. chip->last_queued_id &= 3;
  971. }
  972. /*
  973. * if (chip_id == 10)
  974. * {
  975. * cgtime(&tvCurr);
  976. * timersub(&tvCurr, &tvLast, &tvDiff);
  977. * applog(LOG_NOTICE, "CCCCCCCTime.tv_sec:%d,tv_usec:%d.", tvDiff.tv_sec,tvDiff.tv_usec);
  978. * cgtime(&tvLast);
  979. }
  980. */
  981. return retval;
  982. }
  983. bool get_nonce(struct T1_chain *t1, uint8_t *nonce, uint8_t *chip_id, uint8_t *job_id, uint8_t *micro_job_id)
  984. {
  985. uint8_t buffer[10];
  986. memset(buffer, 0, sizeof(buffer));
  987. #ifdef USE_AUTONONCE
  988. if (mcompat_cmd_read_nonce(t1->chain_id, buffer, NONCE_LEN))
  989. #else
  990. if (mcompat_cmd_read_result(t1->chain_id, CMD_ADDR_BROADCAST, buffer, NONCE_LEN))
  991. #endif
  992. {
  993. *job_id = buffer[0] >> 4;
  994. *chip_id = buffer[1];
  995. *(uint16_t *)micro_job_id = buffer[3];
  996. memcpy(nonce, buffer + 4, 4);
  997. applog(LOG_INFO, "Got nonce for chain%d / chip%d / nonce 0x%08x",
  998. t1->chain_id, *chip_id, *(uint32_t*)nonce);
  999. return true;
  1000. }
  1001. return false;
  1002. }
  1003. bool check_chip(struct T1_chain *t1, int i)
  1004. {
  1005. uint8_t buffer[REG_LENGTH] = {0};
  1006. int cid = t1->chain_id;
  1007. int chip_id = i + 1;
  1008. if (!mcompat_cmd_read_register(cid, chip_id, buffer, REG_LENGTH)) {
  1009. applog(LOG_WARNING, "%d: Failed to read register for "
  1010. "chip %d -> disabling", cid, chip_id);
  1011. t1->chips[i].num_cores = 0;
  1012. t1->chips[i].disabled = true;
  1013. return false;
  1014. } else {
  1015. //hexdump("check chip:", buffer, REG_LENGTH);
  1016. }
  1017. t1->chips[i].num_cores = buffer[11];
  1018. t1->num_cores += t1->chips[i].num_cores;
  1019. //applog(LOG_WARNING, "%d: Found chip %d with %d active cores",
  1020. // cid, chip_id, t1->chips[i].num_cores);
  1021. memcpy(t1->chips[i].reg, buffer, REG_LENGTH);
  1022. t1->chips[i].temp= mcompat_temp_to_centigrade(0x000003ff & ((buffer[7] << 8) | buffer[8]));
  1023. if (t1->chips[i].num_cores < BROKEN_CHIP_THRESHOLD) {
  1024. applog(LOG_WARNING, "%d: broken chip %d with %d active "
  1025. "cores (threshold = %d)", cid, chip_id,
  1026. t1->chips[i].num_cores, BROKEN_CHIP_THRESHOLD);
  1027. t1->chips[i].disabled = true;
  1028. t1->num_cores -= t1->chips[i].num_cores;
  1029. return false;
  1030. }
  1031. if (t1->chips[i].num_cores < WEAK_CHIP_THRESHOLD) {
  1032. applog(LOG_WARNING, "%d: weak chip %d with %d active "
  1033. "cores (threshold = %d)", cid,
  1034. chip_id, t1->chips[i].num_cores, WEAK_CHIP_THRESHOLD);
  1035. return false;
  1036. }
  1037. /* Reenable this in case we have cycled through this function more than
  1038. * once. */
  1039. t1->chips[i].disabled = false;
  1040. return true;
  1041. }
  1042. int dragonmint_get_voltage_stats(struct T1_chain *t1, dragonmint_reg_ctrl_t *s_reg_ctrl)
  1043. {
  1044. int i = 0;
  1045. int cid = t1->chain_id;
  1046. s_reg_ctrl->highest_vol[cid] = s_reg_ctrl->stat_val[cid][0];
  1047. s_reg_ctrl->lowest_vol[cid] = s_reg_ctrl->stat_val[cid][0];
  1048. int total_vol = 0;
  1049. int cnt = 0;
  1050. if ((t1->num_active_chips < 1) || (t1 == NULL))
  1051. return -1;
  1052. for (i = 0; i < t1->num_active_chips; i++) {
  1053. if (s_reg_ctrl->highest_vol[cid] < s_reg_ctrl->stat_val[cid][i])
  1054. s_reg_ctrl->highest_vol[cid] = s_reg_ctrl->stat_val[cid][i];
  1055. if (s_reg_ctrl->lowest_vol[cid] > s_reg_ctrl->stat_val[cid][i])
  1056. s_reg_ctrl->lowest_vol[cid] = s_reg_ctrl->stat_val[cid][i];
  1057. // Ignore voltage value 0
  1058. if (s_reg_ctrl->stat_val[cid][i] > 0) {
  1059. total_vol += s_reg_ctrl->stat_val[cid][i];
  1060. cnt++;
  1061. }
  1062. }
  1063. // Ignore max and min voltages
  1064. if (cnt > 2) {
  1065. s_reg_ctrl->average_vol[cid] =
  1066. (total_vol - s_reg_ctrl->highest_vol[cid] - s_reg_ctrl->lowest_vol[cid]) / (cnt - 2);
  1067. } else
  1068. s_reg_ctrl->average_vol[cid] = 0;
  1069. return 0;
  1070. }
  1071. bool dragonmint_check_voltage(struct T1_chain *t1, int chip_id, dragonmint_reg_ctrl_t *s_reg_ctrl)
  1072. {
  1073. uint32_t rd[3], rd_min = 0xFFFFFFFF, rd_max = 0, rd_v = 0;
  1074. int cid = t1->chain_id, i;
  1075. float tmp_v;
  1076. uint8_t reg[REG_LENGTH] = {0};
  1077. /* Oversample by reading voltage 3 times and choosing middle value */
  1078. for (i = 0; i < 3; i++) {
  1079. if (unlikely(!mcompat_cmd_read_register(cid, chip_id, reg, REG_LENGTH))) {
  1080. applog(LOG_NOTICE, "%d: Failed to read register for ""chip %d -> disabling",
  1081. cid, chip_id);
  1082. t1->chips[chip_id - 1].num_cores = 0;
  1083. t1->chips[chip_id - 1].disabled = 1;
  1084. return false;
  1085. }
  1086. rd[i] = 0x000003ff & ((reg[7] << 8) | reg[8]);
  1087. if (rd[i] < rd_min)
  1088. rd_min = rd[i];
  1089. if (rd[i] > rd_max)
  1090. rd_max = rd[i];
  1091. }
  1092. rd_v = rd_min;
  1093. for (i = 0; i < 3; i++) {
  1094. if (rd[i] > rd_v && rd[i] < rd_max)
  1095. rd_v = rd[i];
  1096. }
  1097. /* update temp database */
  1098. tmp_v = (float)(rd_v * MUL_COEF) / 1024;
  1099. t1->chips[chip_id - 1].nVol = tmp_v * 1000;
  1100. s_reg_ctrl->stat_val[t1->chain_id][chip_id-1] = t1->chips[chip_id-1].nVol;
  1101. //applog(LOG_NOTICE, "[Read VOL %s:%d]rd_v = %d, tmp_v = %f",__FUNCTION__,__LINE__,rd_v,tmp_v);
  1102. return true;
  1103. }
  1104. hardware_version_e dragonmint_get_hwver(void)
  1105. {
  1106. FILE* fd;
  1107. char buffer[8] = {0};
  1108. hardware_version_e version;
  1109. fd = fopen(DRAGONMINT_HARDWARE_VERSION_FILE, "r");
  1110. if (fd == NULL) {
  1111. applog(LOG_ERR, "Open hwver file failed, assuming hardware version G19 !");
  1112. return HARDWARE_VERSION_G19;
  1113. }
  1114. FREAD(buffer, 8, 1, fd);
  1115. fclose(fd);
  1116. if (strstr(buffer, "G9") != NULL) {
  1117. version = HARDWARE_VERSION_G9;
  1118. applog(LOG_INFO, "hardware version is G9");
  1119. }else if (strstr(buffer, "G19") != 0) {
  1120. version = HARDWARE_VERSION_G19;
  1121. applog(LOG_INFO, "hardware version is G19");
  1122. }else {
  1123. version = 0;
  1124. applog(LOG_ERR, "unknown hardware version !!!");
  1125. }
  1126. return version;
  1127. }
  1128. uint32_t dragonmint_get_chipnum(void)
  1129. {
  1130. FILE* fd;
  1131. char buffer[8] = {0};
  1132. fd = fopen(DRAGONMINT_CHIP_NUM_FILE, "r");
  1133. if (fd == NULL) {
  1134. applog(LOG_ERR, "Failed to read chip number from %s, assuming chip number %d!",
  1135. DRAGONMINT_CHIP_NUM_FILE, MAX_CHIP_NUM);
  1136. return MAX_CHIP_NUM;
  1137. }
  1138. FREAD(buffer, 8, 1, fd);
  1139. fclose(fd);
  1140. uint32_t chipnum = atoi(buffer);
  1141. if (chipnum > 0 && chipnum <= MAX_CHIP_NUM)
  1142. return chipnum;
  1143. else
  1144. return MAX_CHIP_NUM;
  1145. }
  1146. #if 0
  1147. dragonmint_type_e dragonmint_get_miner_type(void)
  1148. {
  1149. FILE* fd;
  1150. char buffer[64] = {0};
  1151. dragonmint_type_e miner_type;
  1152. fd = fopen(DRAGONMINT_MINER_TYPE_FILE, "r");
  1153. if (fd == NULL) {
  1154. applog(LOG_ERR, "Open type file failed, assuming miner type T1 !");
  1155. return DRAGONMINT_TYPE_T1;
  1156. }
  1157. FREAD(buffer, 8, 1, fd);
  1158. fclose(fd);
  1159. if (strstr(buffer, "T1") != NULL) {
  1160. miner_type = DRAGONMINT_TYPE_T1;
  1161. applog(LOG_INFO, "miner type is T1");
  1162. }else if (strstr(buffer, "T2") != NULL) {
  1163. miner_type = DRAGONMINT_TYPE_A6;
  1164. applog(LOG_INFO, "miner type is T2");
  1165. }else if (strstr(buffer, "T3") != NULL) {
  1166. miner_type = DRAGONMINT_TYPE_A7;
  1167. applog(LOG_INFO, "miner type is T3");
  1168. }else if (strstr(buffer, "T4") != NULL) {
  1169. miner_type = DRAGONMINT_TYPE_A8;
  1170. applog(LOG_INFO, "miner type is T4");
  1171. }else {
  1172. miner_type = 0;
  1173. applog(LOG_INFO, "unknown miner type !!!");
  1174. }
  1175. return miner_type;
  1176. }
  1177. #endif
  1178. extern struct T1_chain *chain[MAX_CHAIN_NUM];
  1179. void chain_all_exit(void)
  1180. {
  1181. int i;
  1182. applog(LOG_NOTICE, "All chain power off and spi exit!");
  1183. for(i = 0; i < MAX_CHAIN_NUM; i++)
  1184. {
  1185. if (chain[i] == NULL)
  1186. continue;
  1187. free(chain[i]->chips);
  1188. mcompat_set_led(i, LED_ON);
  1189. mcompat_set_power_en(i, 0);
  1190. //asic_gpio_write(chain[i]->spi_ctx->led, 1);
  1191. //asic_gpio_write(chain[i]->spi_ctx->power_en, 0);
  1192. chain[i]->chips = NULL;
  1193. //chain[i]->spi_ctx = NULL;
  1194. free(chain[i]);
  1195. }
  1196. }
  1197. int dragonmint_chain_power_down(struct T1_chain *t1)
  1198. {
  1199. mcompat_set_power_en(t1->chain_id, 0);
  1200. mcompat_set_start_en(t1->chain_id, 0);
  1201. mcompat_set_led(t1->chain_id, LED_OFF);
  1202. return 0;
  1203. }
  1204. extern int chain_flag[MAX_CHAIN_NUM];
  1205. extern int chain_plug[MAX_CHAIN_NUM];
  1206. void power_down_all_chain(void)
  1207. {
  1208. int i;
  1209. for(i = 0; i < MAX_CHAIN_NUM; i++)
  1210. {
  1211. if (chain_flag[i] != 1){
  1212. continue;
  1213. }
  1214. dragonmint_chain_power_down(chain[i]);
  1215. }
  1216. }
  1217. void write_miner_ageing_status(uint32_t statusCode)
  1218. {
  1219. FILE* fd;
  1220. fd = fopen(MINER_AGEING_STATUS_FILE, "w+");
  1221. if (fd == NULL) {
  1222. applog(LOG_ERR, "Create miner ageing status file failed!");
  1223. return;
  1224. }
  1225. rewind(fd);
  1226. fprintf(fd, "%d", statusCode);
  1227. applog(LOG_INFO, "Miner ageing status is %d!", statusCode);
  1228. fclose(fd);
  1229. return;
  1230. }
  1231. bool t1_set_pll(struct T1_chain *t1, int chip_id, int target_pll)
  1232. {
  1233. int i, start_pll = t1->pll;
  1234. uint8_t reg[REG_LENGTH] = {0};
  1235. if (target_pll > start_pll) {
  1236. // increase pll step by step
  1237. for (i = start_pll; i <= target_pll; i++) {
  1238. memcpy(reg, default_reg[i], REG_LENGTH);
  1239. if (!T1_SetT1PLLClock(t1, i, chip_id)) {
  1240. applog(LOG_WARNING, "set default PLL fail");
  1241. write_miner_ageing_status(AGEING_CONFIG_PLL_FAILED);
  1242. return false;
  1243. }
  1244. if (chip_id == CMD_ADDR_BROADCAST)
  1245. t1->pll = i;
  1246. // update temperature for all chains once every second
  1247. dm_tempctrl_update_temp(chain_mask);
  1248. }
  1249. } else if (target_pll < start_pll) {
  1250. // decrease pll step by step
  1251. for (i = start_pll; i >= target_pll; i--) {
  1252. memcpy(reg, default_reg[i], REG_LENGTH);
  1253. if (!T1_SetT1PLLClock(t1, i, chip_id)) {
  1254. applog(LOG_WARNING, "set default PLL fail");
  1255. write_miner_ageing_status(AGEING_CONFIG_PLL_FAILED);
  1256. return false;
  1257. }
  1258. if (chip_id == CMD_ADDR_BROADCAST)
  1259. t1->pll = i;
  1260. // update temperature for all chains once every second
  1261. dm_tempctrl_update_temp(chain_mask);
  1262. }
  1263. }
  1264. /* re-config adc div cause the pll is changed */
  1265. mcompat_cfg_tsadc_divider(t1->chain_id, PLL_Clk_12Mhz[t1->pll].speedMHz);
  1266. return true;
  1267. }