bcm3510_priv.h 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448
  1. /* SPDX-License-Identifier: GPL-2.0-or-later */
  2. /*
  3. * Support for the Broadcom BCM3510 ATSC demodulator (1st generation Air2PC)
  4. *
  5. * Copyright (C) 2001-5, B2C2 inc.
  6. *
  7. * GPL/Linux driver written by Patrick Boettcher <patrick.boettcher@posteo.de>
  8. */
  9. #ifndef __BCM3510_PRIV_H__
  10. #define __BCM3510_PRIV_H__
  11. #define PACKED __attribute__((packed))
  12. #undef err
  13. #define err(format, arg...) printk(KERN_ERR "bcm3510: " format "\n" , ## arg)
  14. #undef info
  15. #define info(format, arg...) printk(KERN_INFO "bcm3510: " format "\n" , ## arg)
  16. #undef warn
  17. #define warn(format, arg...) printk(KERN_WARNING "bcm3510: " format "\n" , ## arg)
  18. #define PANASONIC_FIRST_IF_BASE_IN_KHz 1407500
  19. #define BCM3510_SYMBOL_RATE 5381000
  20. typedef union {
  21. u8 raw;
  22. struct {
  23. u8 CTL :8;
  24. } TSTCTL_2e;
  25. u8 LDCERC_4e;
  26. u8 LDUERC_4f;
  27. u8 LD_BER0_65;
  28. u8 LD_BER1_66;
  29. u8 LD_BER2_67;
  30. u8 LD_BER3_68;
  31. struct {
  32. u8 RESET :1;
  33. u8 IDLE :1;
  34. u8 STOP :1;
  35. u8 HIRQ0 :1;
  36. u8 HIRQ1 :1;
  37. u8 na0 :1;
  38. u8 HABAV :1;
  39. u8 na1 :1;
  40. } HCTL1_a0;
  41. struct {
  42. u8 na0 :1;
  43. u8 IDLMSK :1;
  44. u8 STMSK :1;
  45. u8 I0MSK :1;
  46. u8 I1MSK :1;
  47. u8 na1 :1;
  48. u8 HABMSK :1;
  49. u8 na2 :1;
  50. } HCTLMSK_a1;
  51. struct {
  52. u8 RESET :1;
  53. u8 IDLE :1;
  54. u8 STOP :1;
  55. u8 RUN :1;
  56. u8 HABAV :1;
  57. u8 MEMAV :1;
  58. u8 ALDONE :1;
  59. u8 REIRQ :1;
  60. } APSTAT1_a2;
  61. struct {
  62. u8 RSTMSK :1;
  63. u8 IMSK :1;
  64. u8 SMSK :1;
  65. u8 RMSK :1;
  66. u8 HABMSK :1;
  67. u8 MAVMSK :1;
  68. u8 ALDMSK :1;
  69. u8 REMSK :1;
  70. } APMSK1_a3;
  71. u8 APSTAT2_a4;
  72. u8 APMSK2_a5;
  73. struct {
  74. u8 HABADR :7;
  75. u8 na :1;
  76. } HABADR_a6;
  77. u8 HABDATA_a7;
  78. struct {
  79. u8 HABR :1;
  80. u8 LDHABR :1;
  81. u8 APMSK :1;
  82. u8 HMSK :1;
  83. u8 LDMSK :1;
  84. u8 na :3;
  85. } HABSTAT_a8;
  86. u8 MADRH_a9;
  87. u8 MADRL_aa;
  88. u8 MDATA_ab;
  89. struct {
  90. #define JDEC_WAIT_AT_RAM 0x7
  91. #define JDEC_EEPROM_LOAD_WAIT 0x4
  92. u8 JDEC :3;
  93. u8 na :5;
  94. } JDEC_ca;
  95. struct {
  96. u8 REV :4;
  97. u8 LAYER :4;
  98. } REVID_e0;
  99. struct {
  100. u8 unk0 :1;
  101. u8 CNTCTL :1;
  102. u8 BITCNT :1;
  103. u8 unk1 :1;
  104. u8 RESYNC :1;
  105. u8 unk2 :3;
  106. } BERCTL_fa;
  107. struct {
  108. u8 CSEL0 :1;
  109. u8 CLKED0 :1;
  110. u8 CSEL1 :1;
  111. u8 CLKED1 :1;
  112. u8 CLKLEV :1;
  113. u8 SPIVAR :1;
  114. u8 na :2;
  115. } TUNSET_fc;
  116. struct {
  117. u8 CLK :1;
  118. u8 DATA :1;
  119. u8 CS0 :1;
  120. u8 CS1 :1;
  121. u8 AGCSEL :1;
  122. u8 na0 :1;
  123. u8 TUNSEL :1;
  124. u8 na1 :1;
  125. } TUNCTL_fd;
  126. u8 TUNSEL0_fe;
  127. u8 TUNSEL1_ff;
  128. } bcm3510_register_value;
  129. /* HAB commands */
  130. /* version */
  131. #define CMD_GET_VERSION_INFO 0x3D
  132. #define MSGID_GET_VERSION_INFO 0x15
  133. struct bcm3510_hab_cmd_get_version_info {
  134. u8 microcode_version;
  135. u8 script_version;
  136. u8 config_version;
  137. u8 demod_version;
  138. } PACKED;
  139. #define BCM3510_DEF_MICROCODE_VERSION 0x0E
  140. #define BCM3510_DEF_SCRIPT_VERSION 0x06
  141. #define BCM3510_DEF_CONFIG_VERSION 0x01
  142. #define BCM3510_DEF_DEMOD_VERSION 0xB1
  143. /* acquire */
  144. #define CMD_ACQUIRE 0x38
  145. #define MSGID_EXT_TUNER_ACQUIRE 0x0A
  146. struct bcm3510_hab_cmd_ext_acquire {
  147. struct {
  148. u8 MODE :4;
  149. u8 BW :1;
  150. u8 FA :1;
  151. u8 NTSCSWEEP :1;
  152. u8 OFFSET :1;
  153. } PACKED ACQUIRE0; /* control_byte */
  154. struct {
  155. u8 IF_FREQ :3;
  156. u8 zero0 :1;
  157. u8 SYM_RATE :3;
  158. u8 zero1 :1;
  159. } PACKED ACQUIRE1; /* sym_if */
  160. u8 IF_OFFSET0; /* IF_Offset_10hz */
  161. u8 IF_OFFSET1;
  162. u8 SYM_OFFSET0; /* SymbolRateOffset */
  163. u8 SYM_OFFSET1;
  164. u8 NTSC_OFFSET0; /* NTSC_Offset_10hz */
  165. u8 NTSC_OFFSET1;
  166. } PACKED;
  167. #define MSGID_INT_TUNER_ACQUIRE 0x0B
  168. struct bcm3510_hab_cmd_int_acquire {
  169. struct {
  170. u8 MODE :4;
  171. u8 BW :1;
  172. u8 FA :1;
  173. u8 NTSCSWEEP :1;
  174. u8 OFFSET :1;
  175. } PACKED ACQUIRE0; /* control_byte */
  176. struct {
  177. u8 IF_FREQ :3;
  178. u8 zero0 :1;
  179. u8 SYM_RATE :3;
  180. u8 zero1 :1;
  181. } PACKED ACQUIRE1; /* sym_if */
  182. u8 TUNER_FREQ0;
  183. u8 TUNER_FREQ1;
  184. u8 TUNER_FREQ2;
  185. u8 TUNER_FREQ3;
  186. u8 IF_OFFSET0; /* IF_Offset_10hz */
  187. u8 IF_OFFSET1;
  188. u8 SYM_OFFSET0; /* SymbolRateOffset */
  189. u8 SYM_OFFSET1;
  190. u8 NTSC_OFFSET0; /* NTSC_Offset_10hz */
  191. u8 NTSC_OFFSET1;
  192. } PACKED;
  193. /* modes */
  194. #define BCM3510_QAM16 = 0x01
  195. #define BCM3510_QAM32 = 0x02
  196. #define BCM3510_QAM64 = 0x03
  197. #define BCM3510_QAM128 = 0x04
  198. #define BCM3510_QAM256 = 0x05
  199. #define BCM3510_8VSB = 0x0B
  200. #define BCM3510_16VSB = 0x0D
  201. /* IF_FREQS */
  202. #define BCM3510_IF_TERRESTRIAL 0x0
  203. #define BCM3510_IF_CABLE 0x1
  204. #define BCM3510_IF_USE_CMD 0x7
  205. /* SYM_RATE */
  206. #define BCM3510_SR_8VSB 0x0 /* 5381119 s/sec */
  207. #define BCM3510_SR_256QAM 0x1 /* 5360537 s/sec */
  208. #define BCM3510_SR_16QAM 0x2 /* 5056971 s/sec */
  209. #define BCM3510_SR_MISC 0x3 /* 5000000 s/sec */
  210. #define BCM3510_SR_USE_CMD 0x7
  211. /* special symbol rate */
  212. #define CMD_SET_VALUE_NOT_LISTED 0x2d
  213. #define MSGID_SET_SYMBOL_RATE_NOT_LISTED 0x0c
  214. struct bcm3510_hab_cmd_set_sr_not_listed {
  215. u8 HOST_SYM_RATE0;
  216. u8 HOST_SYM_RATE1;
  217. u8 HOST_SYM_RATE2;
  218. u8 HOST_SYM_RATE3;
  219. } PACKED;
  220. /* special IF */
  221. #define MSGID_SET_IF_FREQ_NOT_LISTED 0x0d
  222. struct bcm3510_hab_cmd_set_if_freq_not_listed {
  223. u8 HOST_IF_FREQ0;
  224. u8 HOST_IF_FREQ1;
  225. u8 HOST_IF_FREQ2;
  226. u8 HOST_IF_FREQ3;
  227. } PACKED;
  228. /* auto reacquire */
  229. #define CMD_AUTO_PARAM 0x2a
  230. #define MSGID_AUTO_REACQUIRE 0x0e
  231. struct bcm3510_hab_cmd_auto_reacquire {
  232. u8 ACQ :1; /* on/off*/
  233. u8 unused :7;
  234. } PACKED;
  235. #define MSGID_SET_RF_AGC_SEL 0x12
  236. struct bcm3510_hab_cmd_set_agc {
  237. u8 LVL :1;
  238. u8 unused :6;
  239. u8 SEL :1;
  240. } PACKED;
  241. #define MSGID_SET_AUTO_INVERSION 0x14
  242. struct bcm3510_hab_cmd_auto_inversion {
  243. u8 AI :1;
  244. u8 unused :7;
  245. } PACKED;
  246. /* bert control */
  247. #define CMD_STATE_CONTROL 0x12
  248. #define MSGID_BERT_CONTROL 0x0e
  249. #define MSGID_BERT_SET 0xfa
  250. struct bcm3510_hab_cmd_bert_control {
  251. u8 BE :1;
  252. u8 unused :7;
  253. } PACKED;
  254. #define MSGID_TRI_STATE 0x2e
  255. struct bcm3510_hab_cmd_tri_state {
  256. u8 RE :1; /* a/d ram port pins */
  257. u8 PE :1; /* baud clock pin */
  258. u8 AC :1; /* a/d clock pin */
  259. u8 BE :1; /* baud clock pin */
  260. u8 unused :4;
  261. } PACKED;
  262. /* tune */
  263. #define CMD_TUNE 0x38
  264. #define MSGID_TUNE 0x16
  265. struct bcm3510_hab_cmd_tune_ctrl_data_pair {
  266. struct {
  267. #define BITS_8 0x07
  268. #define BITS_7 0x06
  269. #define BITS_6 0x05
  270. #define BITS_5 0x04
  271. #define BITS_4 0x03
  272. #define BITS_3 0x02
  273. #define BITS_2 0x01
  274. #define BITS_1 0x00
  275. u8 size :3;
  276. u8 unk :2;
  277. u8 clk_off :1;
  278. u8 cs0 :1;
  279. u8 cs1 :1;
  280. } PACKED ctrl;
  281. u8 data;
  282. } PACKED;
  283. struct bcm3510_hab_cmd_tune {
  284. u8 length;
  285. u8 clock_width;
  286. u8 misc;
  287. u8 TUNCTL_state;
  288. struct bcm3510_hab_cmd_tune_ctrl_data_pair ctl_dat[16];
  289. } PACKED;
  290. #define CMD_STATUS 0x38
  291. #define MSGID_STATUS1 0x08
  292. struct bcm3510_hab_cmd_status1 {
  293. struct {
  294. u8 EQ_MODE :4;
  295. u8 reserved :2;
  296. u8 QRE :1; /* if QSE and the spectrum is inversed */
  297. u8 QSE :1; /* automatic spectral inversion */
  298. } PACKED STATUS0;
  299. struct {
  300. u8 RECEIVER_LOCK :1;
  301. u8 FEC_LOCK :1;
  302. u8 OUT_PLL_LOCK :1;
  303. u8 reserved :5;
  304. } PACKED STATUS1;
  305. struct {
  306. u8 reserved :2;
  307. u8 BW :1;
  308. u8 NTE :1; /* NTSC filter sweep enabled */
  309. u8 AQI :1; /* currently acquiring */
  310. u8 FA :1; /* fast acquisition */
  311. u8 ARI :1; /* auto reacquire */
  312. u8 TI :1; /* programming the tuner */
  313. } PACKED STATUS2;
  314. u8 STATUS3;
  315. u8 SNR_EST0;
  316. u8 SNR_EST1;
  317. u8 TUNER_FREQ0;
  318. u8 TUNER_FREQ1;
  319. u8 TUNER_FREQ2;
  320. u8 TUNER_FREQ3;
  321. u8 SYM_RATE0;
  322. u8 SYM_RATE1;
  323. u8 SYM_RATE2;
  324. u8 SYM_RATE3;
  325. u8 SYM_OFFSET0;
  326. u8 SYM_OFFSET1;
  327. u8 SYM_ERROR0;
  328. u8 SYM_ERROR1;
  329. u8 IF_FREQ0;
  330. u8 IF_FREQ1;
  331. u8 IF_FREQ2;
  332. u8 IF_FREQ3;
  333. u8 IF_OFFSET0;
  334. u8 IF_OFFSET1;
  335. u8 IF_ERROR0;
  336. u8 IF_ERROR1;
  337. u8 NTSC_FILTER0;
  338. u8 NTSC_FILTER1;
  339. u8 NTSC_FILTER2;
  340. u8 NTSC_FILTER3;
  341. u8 NTSC_OFFSET0;
  342. u8 NTSC_OFFSET1;
  343. u8 NTSC_ERROR0;
  344. u8 NTSC_ERROR1;
  345. u8 INT_AGC_LEVEL0;
  346. u8 INT_AGC_LEVEL1;
  347. u8 EXT_AGC_LEVEL0;
  348. u8 EXT_AGC_LEVEL1;
  349. } PACKED;
  350. #define MSGID_STATUS2 0x14
  351. struct bcm3510_hab_cmd_status2 {
  352. struct {
  353. u8 EQ_MODE :4;
  354. u8 reserved :2;
  355. u8 QRE :1;
  356. u8 QSR :1;
  357. } PACKED STATUS0;
  358. struct {
  359. u8 RL :1;
  360. u8 FL :1;
  361. u8 OL :1;
  362. u8 reserved :5;
  363. } PACKED STATUS1;
  364. u8 SYMBOL_RATE0;
  365. u8 SYMBOL_RATE1;
  366. u8 SYMBOL_RATE2;
  367. u8 SYMBOL_RATE3;
  368. u8 LDCERC0;
  369. u8 LDCERC1;
  370. u8 LDCERC2;
  371. u8 LDCERC3;
  372. u8 LDUERC0;
  373. u8 LDUERC1;
  374. u8 LDUERC2;
  375. u8 LDUERC3;
  376. u8 LDBER0;
  377. u8 LDBER1;
  378. u8 LDBER2;
  379. u8 LDBER3;
  380. struct {
  381. u8 MODE_TYPE :4; /* acquire mode 0 */
  382. u8 reservd :4;
  383. } MODE_TYPE;
  384. u8 SNR_EST0;
  385. u8 SNR_EST1;
  386. u8 SIGNAL;
  387. } PACKED;
  388. #define CMD_SET_RF_BW_NOT_LISTED 0x3f
  389. #define MSGID_SET_RF_BW_NOT_LISTED 0x11
  390. /* TODO */
  391. #endif