saa7164-cards.c 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943
  1. // SPDX-License-Identifier: GPL-2.0-or-later
  2. /*
  3. * Driver for the NXP SAA7164 PCIe bridge
  4. *
  5. * Copyright (c) 2010-2015 Steven Toth <[email protected]>
  6. */
  7. #include <linux/init.h>
  8. #include <linux/module.h>
  9. #include <linux/pci.h>
  10. #include <linux/delay.h>
  11. #include "saa7164.h"
  12. /* The Bridge API needs to understand register widths (in bytes) for the
  13. * attached I2C devices, so we can simplify the virtual i2c mechansms
  14. * and keep the -i2c.c implementation clean.
  15. */
  16. #define REGLEN_0bit 0
  17. #define REGLEN_8bit 1
  18. #define REGLEN_16bit 2
  19. struct saa7164_board saa7164_boards[] = {
  20. [SAA7164_BOARD_UNKNOWN] = {
  21. /* Bridge will not load any firmware, without knowing
  22. * the rev this would be fatal. */
  23. .name = "Unknown",
  24. },
  25. [SAA7164_BOARD_UNKNOWN_REV2] = {
  26. /* Bridge will load the v2 f/w and dump descriptors */
  27. /* Required during new board bringup */
  28. .name = "Generic Rev2",
  29. .chiprev = SAA7164_CHIP_REV2,
  30. },
  31. [SAA7164_BOARD_UNKNOWN_REV3] = {
  32. /* Bridge will load the v2 f/w and dump descriptors */
  33. /* Required during new board bringup */
  34. .name = "Generic Rev3",
  35. .chiprev = SAA7164_CHIP_REV3,
  36. },
  37. [SAA7164_BOARD_HAUPPAUGE_HVR2200] = {
  38. .name = "Hauppauge WinTV-HVR2200",
  39. .porta = SAA7164_MPEG_DVB,
  40. .portb = SAA7164_MPEG_DVB,
  41. .portc = SAA7164_MPEG_ENCODER,
  42. .portd = SAA7164_MPEG_ENCODER,
  43. .porte = SAA7164_MPEG_VBI,
  44. .portf = SAA7164_MPEG_VBI,
  45. .chiprev = SAA7164_CHIP_REV3,
  46. .unit = {{
  47. .id = 0x1d,
  48. .type = SAA7164_UNIT_EEPROM,
  49. .name = "4K EEPROM",
  50. .i2c_bus_nr = SAA7164_I2C_BUS_0,
  51. .i2c_bus_addr = 0xa0 >> 1,
  52. .i2c_reg_len = REGLEN_8bit,
  53. }, {
  54. .id = 0x04,
  55. .type = SAA7164_UNIT_TUNER,
  56. .name = "TDA18271-1",
  57. .i2c_bus_nr = SAA7164_I2C_BUS_1,
  58. .i2c_bus_addr = 0xc0 >> 1,
  59. .i2c_reg_len = REGLEN_8bit,
  60. }, {
  61. .id = 0x1b,
  62. .type = SAA7164_UNIT_TUNER,
  63. .name = "TDA18271-2",
  64. .i2c_bus_nr = SAA7164_I2C_BUS_2,
  65. .i2c_bus_addr = 0xc0 >> 1,
  66. .i2c_reg_len = REGLEN_8bit,
  67. }, {
  68. .id = 0x1e,
  69. .type = SAA7164_UNIT_DIGITAL_DEMODULATOR,
  70. .name = "TDA10048-1",
  71. .i2c_bus_nr = SAA7164_I2C_BUS_1,
  72. .i2c_bus_addr = 0x10 >> 1,
  73. .i2c_reg_len = REGLEN_8bit,
  74. }, {
  75. .id = 0x1f,
  76. .type = SAA7164_UNIT_DIGITAL_DEMODULATOR,
  77. .name = "TDA10048-2",
  78. .i2c_bus_nr = SAA7164_I2C_BUS_2,
  79. .i2c_bus_addr = 0x12 >> 1,
  80. .i2c_reg_len = REGLEN_8bit,
  81. } },
  82. },
  83. [SAA7164_BOARD_HAUPPAUGE_HVR2200_2] = {
  84. .name = "Hauppauge WinTV-HVR2200",
  85. .porta = SAA7164_MPEG_DVB,
  86. .portb = SAA7164_MPEG_DVB,
  87. .portc = SAA7164_MPEG_ENCODER,
  88. .portd = SAA7164_MPEG_ENCODER,
  89. .porte = SAA7164_MPEG_VBI,
  90. .portf = SAA7164_MPEG_VBI,
  91. .chiprev = SAA7164_CHIP_REV2,
  92. .unit = {{
  93. .id = 0x06,
  94. .type = SAA7164_UNIT_EEPROM,
  95. .name = "4K EEPROM",
  96. .i2c_bus_nr = SAA7164_I2C_BUS_0,
  97. .i2c_bus_addr = 0xa0 >> 1,
  98. .i2c_reg_len = REGLEN_8bit,
  99. }, {
  100. .id = 0x04,
  101. .type = SAA7164_UNIT_TUNER,
  102. .name = "TDA18271-1",
  103. .i2c_bus_nr = SAA7164_I2C_BUS_1,
  104. .i2c_bus_addr = 0xc0 >> 1,
  105. .i2c_reg_len = REGLEN_8bit,
  106. }, {
  107. .id = 0x05,
  108. .type = SAA7164_UNIT_DIGITAL_DEMODULATOR,
  109. .name = "TDA10048-1",
  110. .i2c_bus_nr = SAA7164_I2C_BUS_1,
  111. .i2c_bus_addr = 0x10 >> 1,
  112. .i2c_reg_len = REGLEN_8bit,
  113. }, {
  114. .id = 0x1e,
  115. .type = SAA7164_UNIT_TUNER,
  116. .name = "TDA18271-2",
  117. .i2c_bus_nr = SAA7164_I2C_BUS_2,
  118. .i2c_bus_addr = 0xc0 >> 1,
  119. .i2c_reg_len = REGLEN_8bit,
  120. }, {
  121. .id = 0x1f,
  122. .type = SAA7164_UNIT_DIGITAL_DEMODULATOR,
  123. .name = "TDA10048-2",
  124. .i2c_bus_nr = SAA7164_I2C_BUS_2,
  125. .i2c_bus_addr = 0x12 >> 1,
  126. .i2c_reg_len = REGLEN_8bit,
  127. } },
  128. },
  129. [SAA7164_BOARD_HAUPPAUGE_HVR2200_3] = {
  130. .name = "Hauppauge WinTV-HVR2200",
  131. .porta = SAA7164_MPEG_DVB,
  132. .portb = SAA7164_MPEG_DVB,
  133. .portc = SAA7164_MPEG_ENCODER,
  134. .portd = SAA7164_MPEG_ENCODER,
  135. .porte = SAA7164_MPEG_VBI,
  136. .portf = SAA7164_MPEG_VBI,
  137. .chiprev = SAA7164_CHIP_REV2,
  138. .unit = {{
  139. .id = 0x1d,
  140. .type = SAA7164_UNIT_EEPROM,
  141. .name = "4K EEPROM",
  142. .i2c_bus_nr = SAA7164_I2C_BUS_0,
  143. .i2c_bus_addr = 0xa0 >> 1,
  144. .i2c_reg_len = REGLEN_8bit,
  145. }, {
  146. .id = 0x04,
  147. .type = SAA7164_UNIT_TUNER,
  148. .name = "TDA18271-1",
  149. .i2c_bus_nr = SAA7164_I2C_BUS_1,
  150. .i2c_bus_addr = 0xc0 >> 1,
  151. .i2c_reg_len = REGLEN_8bit,
  152. }, {
  153. .id = 0x05,
  154. .type = SAA7164_UNIT_ANALOG_DEMODULATOR,
  155. .name = "TDA8290-1",
  156. .i2c_bus_nr = SAA7164_I2C_BUS_1,
  157. .i2c_bus_addr = 0x84 >> 1,
  158. .i2c_reg_len = REGLEN_8bit,
  159. }, {
  160. .id = 0x1b,
  161. .type = SAA7164_UNIT_TUNER,
  162. .name = "TDA18271-2",
  163. .i2c_bus_nr = SAA7164_I2C_BUS_2,
  164. .i2c_bus_addr = 0xc0 >> 1,
  165. .i2c_reg_len = REGLEN_8bit,
  166. }, {
  167. .id = 0x1c,
  168. .type = SAA7164_UNIT_ANALOG_DEMODULATOR,
  169. .name = "TDA8290-2",
  170. .i2c_bus_nr = SAA7164_I2C_BUS_2,
  171. .i2c_bus_addr = 0x84 >> 1,
  172. .i2c_reg_len = REGLEN_8bit,
  173. }, {
  174. .id = 0x1e,
  175. .type = SAA7164_UNIT_DIGITAL_DEMODULATOR,
  176. .name = "TDA10048-1",
  177. .i2c_bus_nr = SAA7164_I2C_BUS_1,
  178. .i2c_bus_addr = 0x10 >> 1,
  179. .i2c_reg_len = REGLEN_8bit,
  180. }, {
  181. .id = 0x1f,
  182. .type = SAA7164_UNIT_DIGITAL_DEMODULATOR,
  183. .name = "TDA10048-2",
  184. .i2c_bus_nr = SAA7164_I2C_BUS_2,
  185. .i2c_bus_addr = 0x12 >> 1,
  186. .i2c_reg_len = REGLEN_8bit,
  187. } },
  188. },
  189. [SAA7164_BOARD_HAUPPAUGE_HVR2200_4] = {
  190. .name = "Hauppauge WinTV-HVR2200",
  191. .porta = SAA7164_MPEG_DVB,
  192. .portb = SAA7164_MPEG_DVB,
  193. .portc = SAA7164_MPEG_ENCODER,
  194. .portd = SAA7164_MPEG_ENCODER,
  195. .porte = SAA7164_MPEG_VBI,
  196. .portf = SAA7164_MPEG_VBI,
  197. .chiprev = SAA7164_CHIP_REV3,
  198. .unit = {{
  199. .id = 0x1d,
  200. .type = SAA7164_UNIT_EEPROM,
  201. .name = "4K EEPROM",
  202. .i2c_bus_nr = SAA7164_I2C_BUS_0,
  203. .i2c_bus_addr = 0xa0 >> 1,
  204. .i2c_reg_len = REGLEN_8bit,
  205. }, {
  206. .id = 0x04,
  207. .type = SAA7164_UNIT_TUNER,
  208. .name = "TDA18271-1",
  209. .i2c_bus_nr = SAA7164_I2C_BUS_1,
  210. .i2c_bus_addr = 0xc0 >> 1,
  211. .i2c_reg_len = REGLEN_8bit,
  212. }, {
  213. .id = 0x05,
  214. .type = SAA7164_UNIT_ANALOG_DEMODULATOR,
  215. .name = "TDA8290-1",
  216. .i2c_bus_nr = SAA7164_I2C_BUS_1,
  217. .i2c_bus_addr = 0x84 >> 1,
  218. .i2c_reg_len = REGLEN_8bit,
  219. }, {
  220. .id = 0x1b,
  221. .type = SAA7164_UNIT_TUNER,
  222. .name = "TDA18271-2",
  223. .i2c_bus_nr = SAA7164_I2C_BUS_2,
  224. .i2c_bus_addr = 0xc0 >> 1,
  225. .i2c_reg_len = REGLEN_8bit,
  226. }, {
  227. .id = 0x1c,
  228. .type = SAA7164_UNIT_ANALOG_DEMODULATOR,
  229. .name = "TDA8290-2",
  230. .i2c_bus_nr = SAA7164_I2C_BUS_2,
  231. .i2c_bus_addr = 0x84 >> 1,
  232. .i2c_reg_len = REGLEN_8bit,
  233. }, {
  234. .id = 0x1e,
  235. .type = SAA7164_UNIT_DIGITAL_DEMODULATOR,
  236. .name = "TDA10048-1",
  237. .i2c_bus_nr = SAA7164_I2C_BUS_1,
  238. .i2c_bus_addr = 0x10 >> 1,
  239. .i2c_reg_len = REGLEN_8bit,
  240. }, {
  241. .id = 0x1f,
  242. .type = SAA7164_UNIT_DIGITAL_DEMODULATOR,
  243. .name = "TDA10048-2",
  244. .i2c_bus_nr = SAA7164_I2C_BUS_2,
  245. .i2c_bus_addr = 0x12 >> 1,
  246. .i2c_reg_len = REGLEN_8bit,
  247. } },
  248. },
  249. [SAA7164_BOARD_HAUPPAUGE_HVR2250] = {
  250. .name = "Hauppauge WinTV-HVR2250",
  251. .porta = SAA7164_MPEG_DVB,
  252. .portb = SAA7164_MPEG_DVB,
  253. .portc = SAA7164_MPEG_ENCODER,
  254. .portd = SAA7164_MPEG_ENCODER,
  255. .porte = SAA7164_MPEG_VBI,
  256. .portf = SAA7164_MPEG_VBI,
  257. .chiprev = SAA7164_CHIP_REV3,
  258. .unit = {{
  259. .id = 0x22,
  260. .type = SAA7164_UNIT_EEPROM,
  261. .name = "4K EEPROM",
  262. .i2c_bus_nr = SAA7164_I2C_BUS_0,
  263. .i2c_bus_addr = 0xa0 >> 1,
  264. .i2c_reg_len = REGLEN_8bit,
  265. }, {
  266. .id = 0x04,
  267. .type = SAA7164_UNIT_TUNER,
  268. .name = "TDA18271-1",
  269. .i2c_bus_nr = SAA7164_I2C_BUS_1,
  270. .i2c_bus_addr = 0xc0 >> 1,
  271. .i2c_reg_len = REGLEN_8bit,
  272. }, {
  273. .id = 0x07,
  274. .type = SAA7164_UNIT_DIGITAL_DEMODULATOR,
  275. .name = "CX24228/S5H1411-1 (TOP)",
  276. .i2c_bus_nr = SAA7164_I2C_BUS_1,
  277. .i2c_bus_addr = 0x32 >> 1,
  278. .i2c_reg_len = REGLEN_8bit,
  279. }, {
  280. .id = 0x08,
  281. .type = SAA7164_UNIT_DIGITAL_DEMODULATOR,
  282. .name = "CX24228/S5H1411-1 (QAM)",
  283. .i2c_bus_nr = SAA7164_I2C_BUS_1,
  284. .i2c_bus_addr = 0x34 >> 1,
  285. .i2c_reg_len = REGLEN_8bit,
  286. }, {
  287. .id = 0x1e,
  288. .type = SAA7164_UNIT_TUNER,
  289. .name = "TDA18271-2",
  290. .i2c_bus_nr = SAA7164_I2C_BUS_2,
  291. .i2c_bus_addr = 0xc0 >> 1,
  292. .i2c_reg_len = REGLEN_8bit,
  293. }, {
  294. .id = 0x20,
  295. .type = SAA7164_UNIT_DIGITAL_DEMODULATOR,
  296. .name = "CX24228/S5H1411-2 (TOP)",
  297. .i2c_bus_nr = SAA7164_I2C_BUS_2,
  298. .i2c_bus_addr = 0x32 >> 1,
  299. .i2c_reg_len = REGLEN_8bit,
  300. }, {
  301. .id = 0x23,
  302. .type = SAA7164_UNIT_DIGITAL_DEMODULATOR,
  303. .name = "CX24228/S5H1411-2 (QAM)",
  304. .i2c_bus_nr = SAA7164_I2C_BUS_2,
  305. .i2c_bus_addr = 0x34 >> 1,
  306. .i2c_reg_len = REGLEN_8bit,
  307. } },
  308. },
  309. [SAA7164_BOARD_HAUPPAUGE_HVR2250_2] = {
  310. .name = "Hauppauge WinTV-HVR2250",
  311. .porta = SAA7164_MPEG_DVB,
  312. .portb = SAA7164_MPEG_DVB,
  313. .portc = SAA7164_MPEG_ENCODER,
  314. .portd = SAA7164_MPEG_ENCODER,
  315. .porte = SAA7164_MPEG_VBI,
  316. .portf = SAA7164_MPEG_VBI,
  317. .chiprev = SAA7164_CHIP_REV3,
  318. .unit = {{
  319. .id = 0x28,
  320. .type = SAA7164_UNIT_EEPROM,
  321. .name = "4K EEPROM",
  322. .i2c_bus_nr = SAA7164_I2C_BUS_0,
  323. .i2c_bus_addr = 0xa0 >> 1,
  324. .i2c_reg_len = REGLEN_8bit,
  325. }, {
  326. .id = 0x04,
  327. .type = SAA7164_UNIT_TUNER,
  328. .name = "TDA18271-1",
  329. .i2c_bus_nr = SAA7164_I2C_BUS_1,
  330. .i2c_bus_addr = 0xc0 >> 1,
  331. .i2c_reg_len = REGLEN_8bit,
  332. }, {
  333. .id = 0x07,
  334. .type = SAA7164_UNIT_DIGITAL_DEMODULATOR,
  335. .name = "CX24228/S5H1411-1 (TOP)",
  336. .i2c_bus_nr = SAA7164_I2C_BUS_1,
  337. .i2c_bus_addr = 0x32 >> 1,
  338. .i2c_reg_len = REGLEN_8bit,
  339. }, {
  340. .id = 0x08,
  341. .type = SAA7164_UNIT_DIGITAL_DEMODULATOR,
  342. .name = "CX24228/S5H1411-1 (QAM)",
  343. .i2c_bus_nr = SAA7164_I2C_BUS_1,
  344. .i2c_bus_addr = 0x34 >> 1,
  345. .i2c_reg_len = REGLEN_8bit,
  346. }, {
  347. .id = 0x24,
  348. .type = SAA7164_UNIT_TUNER,
  349. .name = "TDA18271-2",
  350. .i2c_bus_nr = SAA7164_I2C_BUS_2,
  351. .i2c_bus_addr = 0xc0 >> 1,
  352. .i2c_reg_len = REGLEN_8bit,
  353. }, {
  354. .id = 0x26,
  355. .type = SAA7164_UNIT_DIGITAL_DEMODULATOR,
  356. .name = "CX24228/S5H1411-2 (TOP)",
  357. .i2c_bus_nr = SAA7164_I2C_BUS_2,
  358. .i2c_bus_addr = 0x32 >> 1,
  359. .i2c_reg_len = REGLEN_8bit,
  360. }, {
  361. .id = 0x29,
  362. .type = SAA7164_UNIT_DIGITAL_DEMODULATOR,
  363. .name = "CX24228/S5H1411-2 (QAM)",
  364. .i2c_bus_nr = SAA7164_I2C_BUS_2,
  365. .i2c_bus_addr = 0x34 >> 1,
  366. .i2c_reg_len = REGLEN_8bit,
  367. } },
  368. },
  369. [SAA7164_BOARD_HAUPPAUGE_HVR2250_3] = {
  370. .name = "Hauppauge WinTV-HVR2250",
  371. .porta = SAA7164_MPEG_DVB,
  372. .portb = SAA7164_MPEG_DVB,
  373. .portc = SAA7164_MPEG_ENCODER,
  374. .portd = SAA7164_MPEG_ENCODER,
  375. .porte = SAA7164_MPEG_VBI,
  376. .portf = SAA7164_MPEG_VBI,
  377. .chiprev = SAA7164_CHIP_REV3,
  378. .unit = {{
  379. .id = 0x26,
  380. .type = SAA7164_UNIT_EEPROM,
  381. .name = "4K EEPROM",
  382. .i2c_bus_nr = SAA7164_I2C_BUS_0,
  383. .i2c_bus_addr = 0xa0 >> 1,
  384. .i2c_reg_len = REGLEN_8bit,
  385. }, {
  386. .id = 0x04,
  387. .type = SAA7164_UNIT_TUNER,
  388. .name = "TDA18271-1",
  389. .i2c_bus_nr = SAA7164_I2C_BUS_1,
  390. .i2c_bus_addr = 0xc0 >> 1,
  391. .i2c_reg_len = REGLEN_8bit,
  392. }, {
  393. .id = 0x07,
  394. .type = SAA7164_UNIT_DIGITAL_DEMODULATOR,
  395. .name = "CX24228/S5H1411-1 (TOP)",
  396. .i2c_bus_nr = SAA7164_I2C_BUS_1,
  397. .i2c_bus_addr = 0x32 >> 1,
  398. .i2c_reg_len = REGLEN_8bit,
  399. }, {
  400. .id = 0x08,
  401. .type = SAA7164_UNIT_DIGITAL_DEMODULATOR,
  402. .name = "CX24228/S5H1411-1 (QAM)",
  403. .i2c_bus_nr = SAA7164_I2C_BUS_1,
  404. .i2c_bus_addr = 0x34 >> 1,
  405. .i2c_reg_len = REGLEN_8bit,
  406. }, {
  407. .id = 0x22,
  408. .type = SAA7164_UNIT_TUNER,
  409. .name = "TDA18271-2",
  410. .i2c_bus_nr = SAA7164_I2C_BUS_2,
  411. .i2c_bus_addr = 0xc0 >> 1,
  412. .i2c_reg_len = REGLEN_8bit,
  413. }, {
  414. .id = 0x24,
  415. .type = SAA7164_UNIT_DIGITAL_DEMODULATOR,
  416. .name = "CX24228/S5H1411-2 (TOP)",
  417. .i2c_bus_nr = SAA7164_I2C_BUS_2,
  418. .i2c_bus_addr = 0x32 >> 1,
  419. .i2c_reg_len = REGLEN_8bit,
  420. }, {
  421. .id = 0x27,
  422. .type = SAA7164_UNIT_DIGITAL_DEMODULATOR,
  423. .name = "CX24228/S5H1411-2 (QAM)",
  424. .i2c_bus_nr = SAA7164_I2C_BUS_2,
  425. .i2c_bus_addr = 0x34 >> 1,
  426. .i2c_reg_len = REGLEN_8bit,
  427. } },
  428. },
  429. [SAA7164_BOARD_HAUPPAUGE_HVR2200_5] = {
  430. .name = "Hauppauge WinTV-HVR2200",
  431. .porta = SAA7164_MPEG_DVB,
  432. .portb = SAA7164_MPEG_DVB,
  433. .chiprev = SAA7164_CHIP_REV3,
  434. .unit = {{
  435. .id = 0x23,
  436. .type = SAA7164_UNIT_EEPROM,
  437. .name = "4K EEPROM",
  438. .i2c_bus_nr = SAA7164_I2C_BUS_0,
  439. .i2c_bus_addr = 0xa0 >> 1,
  440. .i2c_reg_len = REGLEN_8bit,
  441. }, {
  442. .id = 0x04,
  443. .type = SAA7164_UNIT_TUNER,
  444. .name = "TDA18271-1",
  445. .i2c_bus_nr = SAA7164_I2C_BUS_1,
  446. .i2c_bus_addr = 0xc0 >> 1,
  447. .i2c_reg_len = REGLEN_8bit,
  448. }, {
  449. .id = 0x05,
  450. .type = SAA7164_UNIT_ANALOG_DEMODULATOR,
  451. .name = "TDA8290-1",
  452. .i2c_bus_nr = SAA7164_I2C_BUS_1,
  453. .i2c_bus_addr = 0x84 >> 1,
  454. .i2c_reg_len = REGLEN_8bit,
  455. }, {
  456. .id = 0x21,
  457. .type = SAA7164_UNIT_TUNER,
  458. .name = "TDA18271-2",
  459. .i2c_bus_nr = SAA7164_I2C_BUS_2,
  460. .i2c_bus_addr = 0xc0 >> 1,
  461. .i2c_reg_len = REGLEN_8bit,
  462. }, {
  463. .id = 0x22,
  464. .type = SAA7164_UNIT_ANALOG_DEMODULATOR,
  465. .name = "TDA8290-2",
  466. .i2c_bus_nr = SAA7164_I2C_BUS_2,
  467. .i2c_bus_addr = 0x84 >> 1,
  468. .i2c_reg_len = REGLEN_8bit,
  469. }, {
  470. .id = 0x24,
  471. .type = SAA7164_UNIT_DIGITAL_DEMODULATOR,
  472. .name = "TDA10048-1",
  473. .i2c_bus_nr = SAA7164_I2C_BUS_1,
  474. .i2c_bus_addr = 0x10 >> 1,
  475. .i2c_reg_len = REGLEN_8bit,
  476. }, {
  477. .id = 0x25,
  478. .type = SAA7164_UNIT_DIGITAL_DEMODULATOR,
  479. .name = "TDA10048-2",
  480. .i2c_bus_nr = SAA7164_I2C_BUS_2,
  481. .i2c_bus_addr = 0x12 >> 1,
  482. .i2c_reg_len = REGLEN_8bit,
  483. } },
  484. },
  485. [SAA7164_BOARD_HAUPPAUGE_HVR2255proto] = {
  486. .name = "Hauppauge WinTV-HVR2255(proto)",
  487. .porta = SAA7164_MPEG_DVB,
  488. .portb = SAA7164_MPEG_DVB,
  489. .portc = SAA7164_MPEG_ENCODER,
  490. .portd = SAA7164_MPEG_ENCODER,
  491. .porte = SAA7164_MPEG_VBI,
  492. .portf = SAA7164_MPEG_VBI,
  493. .chiprev = SAA7164_CHIP_REV3,
  494. .unit = {{
  495. .id = 0x27,
  496. .type = SAA7164_UNIT_EEPROM,
  497. .name = "4K EEPROM",
  498. .i2c_bus_nr = SAA7164_I2C_BUS_0,
  499. .i2c_bus_addr = 0xa0 >> 1,
  500. .i2c_reg_len = REGLEN_8bit,
  501. }, {
  502. .id = 0x04,
  503. .type = SAA7164_UNIT_TUNER,
  504. .name = "SI2157-1",
  505. .i2c_bus_nr = SAA7164_I2C_BUS_0,
  506. .i2c_bus_addr = 0xc0 >> 1,
  507. .i2c_reg_len = REGLEN_0bit,
  508. }, {
  509. .id = 0x06,
  510. .type = SAA7164_UNIT_DIGITAL_DEMODULATOR,
  511. .name = "LGDT3306",
  512. .i2c_bus_nr = SAA7164_I2C_BUS_2,
  513. .i2c_bus_addr = 0xb2 >> 1,
  514. .i2c_reg_len = REGLEN_8bit,
  515. }, {
  516. .id = 0x24,
  517. .type = SAA7164_UNIT_TUNER,
  518. .name = "SI2157-2",
  519. .i2c_bus_nr = SAA7164_I2C_BUS_1,
  520. .i2c_bus_addr = 0xc0 >> 1,
  521. .i2c_reg_len = REGLEN_0bit,
  522. }, {
  523. .id = 0x26,
  524. .type = SAA7164_UNIT_DIGITAL_DEMODULATOR,
  525. .name = "LGDT3306-2",
  526. .i2c_bus_nr = SAA7164_I2C_BUS_2,
  527. .i2c_bus_addr = 0x1c >> 1,
  528. .i2c_reg_len = REGLEN_8bit,
  529. } },
  530. },
  531. [SAA7164_BOARD_HAUPPAUGE_HVR2255] = {
  532. .name = "Hauppauge WinTV-HVR2255",
  533. .porta = SAA7164_MPEG_DVB,
  534. .portb = SAA7164_MPEG_DVB,
  535. .portc = SAA7164_MPEG_ENCODER,
  536. .portd = SAA7164_MPEG_ENCODER,
  537. .porte = SAA7164_MPEG_VBI,
  538. .portf = SAA7164_MPEG_VBI,
  539. .chiprev = SAA7164_CHIP_REV3,
  540. .unit = {{
  541. .id = 0x28,
  542. .type = SAA7164_UNIT_EEPROM,
  543. .name = "4K EEPROM",
  544. .i2c_bus_nr = SAA7164_I2C_BUS_0,
  545. .i2c_bus_addr = 0xa0 >> 1,
  546. .i2c_reg_len = REGLEN_8bit,
  547. }, {
  548. .id = 0x04,
  549. .type = SAA7164_UNIT_TUNER,
  550. .name = "SI2157-1",
  551. .i2c_bus_nr = SAA7164_I2C_BUS_0,
  552. .i2c_bus_addr = 0xc0 >> 1,
  553. .i2c_reg_len = REGLEN_0bit,
  554. }, {
  555. .id = 0x06,
  556. .type = SAA7164_UNIT_DIGITAL_DEMODULATOR,
  557. .name = "LGDT3306-1",
  558. .i2c_bus_nr = SAA7164_I2C_BUS_2,
  559. .i2c_bus_addr = 0xb2 >> 1,
  560. .i2c_reg_len = REGLEN_8bit,
  561. }, {
  562. .id = 0x25,
  563. .type = SAA7164_UNIT_TUNER,
  564. .name = "SI2157-2",
  565. .i2c_bus_nr = SAA7164_I2C_BUS_1,
  566. .i2c_bus_addr = 0xc0 >> 1,
  567. .i2c_reg_len = REGLEN_0bit,
  568. }, {
  569. .id = 0x27,
  570. .type = SAA7164_UNIT_DIGITAL_DEMODULATOR,
  571. .name = "LGDT3306-2",
  572. .i2c_bus_nr = SAA7164_I2C_BUS_2,
  573. .i2c_bus_addr = 0x1c >> 1,
  574. .i2c_reg_len = REGLEN_8bit,
  575. } },
  576. },
  577. [SAA7164_BOARD_HAUPPAUGE_HVR2205] = {
  578. .name = "Hauppauge WinTV-HVR2205",
  579. .porta = SAA7164_MPEG_DVB,
  580. .portb = SAA7164_MPEG_DVB,
  581. .portc = SAA7164_MPEG_ENCODER,
  582. .portd = SAA7164_MPEG_ENCODER,
  583. .porte = SAA7164_MPEG_VBI,
  584. .portf = SAA7164_MPEG_VBI,
  585. .chiprev = SAA7164_CHIP_REV3,
  586. .unit = {{
  587. .id = 0x28,
  588. .type = SAA7164_UNIT_EEPROM,
  589. .name = "4K EEPROM",
  590. .i2c_bus_nr = SAA7164_I2C_BUS_0,
  591. .i2c_bus_addr = 0xa0 >> 1,
  592. .i2c_reg_len = REGLEN_8bit,
  593. }, {
  594. .id = 0x04,
  595. .type = SAA7164_UNIT_TUNER,
  596. .name = "SI2157-1",
  597. .i2c_bus_nr = SAA7164_I2C_BUS_0,
  598. .i2c_bus_addr = 0xc0 >> 1,
  599. .i2c_reg_len = REGLEN_0bit,
  600. }, {
  601. .id = 0x06,
  602. .type = SAA7164_UNIT_DIGITAL_DEMODULATOR,
  603. .name = "SI2168-1",
  604. .i2c_bus_nr = SAA7164_I2C_BUS_2,
  605. .i2c_bus_addr = 0xc8 >> 1,
  606. .i2c_reg_len = REGLEN_0bit,
  607. }, {
  608. .id = 0x25,
  609. .type = SAA7164_UNIT_TUNER,
  610. .name = "SI2157-2",
  611. .i2c_bus_nr = SAA7164_I2C_BUS_1,
  612. .i2c_bus_addr = 0xc0 >> 1,
  613. .i2c_reg_len = REGLEN_0bit,
  614. }, {
  615. .id = 0x27,
  616. .type = SAA7164_UNIT_DIGITAL_DEMODULATOR,
  617. .name = "SI2168-2",
  618. .i2c_bus_nr = SAA7164_I2C_BUS_2,
  619. .i2c_bus_addr = 0xcc >> 1,
  620. .i2c_reg_len = REGLEN_0bit,
  621. } },
  622. },
  623. };
  624. const unsigned int saa7164_bcount = ARRAY_SIZE(saa7164_boards);
  625. /* ------------------------------------------------------------------ */
  626. /* PCI subsystem IDs */
  627. struct saa7164_subid saa7164_subids[] = {
  628. {
  629. .subvendor = 0x0070,
  630. .subdevice = 0x8880,
  631. .card = SAA7164_BOARD_HAUPPAUGE_HVR2250,
  632. }, {
  633. .subvendor = 0x0070,
  634. .subdevice = 0x8810,
  635. .card = SAA7164_BOARD_HAUPPAUGE_HVR2250,
  636. }, {
  637. .subvendor = 0x0070,
  638. .subdevice = 0x8980,
  639. .card = SAA7164_BOARD_HAUPPAUGE_HVR2200,
  640. }, {
  641. .subvendor = 0x0070,
  642. .subdevice = 0x8900,
  643. .card = SAA7164_BOARD_HAUPPAUGE_HVR2200_2,
  644. }, {
  645. .subvendor = 0x0070,
  646. .subdevice = 0x8901,
  647. .card = SAA7164_BOARD_HAUPPAUGE_HVR2200_3,
  648. }, {
  649. .subvendor = 0x0070,
  650. .subdevice = 0x88A1,
  651. .card = SAA7164_BOARD_HAUPPAUGE_HVR2250_3,
  652. }, {
  653. .subvendor = 0x0070,
  654. .subdevice = 0x8891,
  655. .card = SAA7164_BOARD_HAUPPAUGE_HVR2250_2,
  656. }, {
  657. .subvendor = 0x0070,
  658. .subdevice = 0x8851,
  659. .card = SAA7164_BOARD_HAUPPAUGE_HVR2250_2,
  660. }, {
  661. .subvendor = 0x0070,
  662. .subdevice = 0x8940,
  663. .card = SAA7164_BOARD_HAUPPAUGE_HVR2200_4,
  664. }, {
  665. .subvendor = 0x0070,
  666. .subdevice = 0x8953,
  667. .card = SAA7164_BOARD_HAUPPAUGE_HVR2200_5,
  668. }, {
  669. .subvendor = 0x0070,
  670. .subdevice = 0xf111,
  671. .card = SAA7164_BOARD_HAUPPAUGE_HVR2255,
  672. /* Prototype card left here for documentation purposes.
  673. .card = SAA7164_BOARD_HAUPPAUGE_HVR2255proto,
  674. */
  675. }, {
  676. .subvendor = 0x0070,
  677. .subdevice = 0xf123,
  678. .card = SAA7164_BOARD_HAUPPAUGE_HVR2205,
  679. }, {
  680. .subvendor = 0x0070,
  681. .subdevice = 0xf120,
  682. .card = SAA7164_BOARD_HAUPPAUGE_HVR2205,
  683. },
  684. };
  685. const unsigned int saa7164_idcount = ARRAY_SIZE(saa7164_subids);
  686. void saa7164_card_list(struct saa7164_dev *dev)
  687. {
  688. int i;
  689. if (0 == dev->pci->subsystem_vendor &&
  690. 0 == dev->pci->subsystem_device) {
  691. printk(KERN_ERR
  692. "%s: Board has no valid PCIe Subsystem ID and can't\n"
  693. "%s: be autodetected. Pass card=<n> insmod option to\n"
  694. "%s: workaround that. Send complaints to the vendor\n"
  695. "%s: of the TV card. Best regards,\n"
  696. "%s: -- tux\n",
  697. dev->name, dev->name, dev->name, dev->name, dev->name);
  698. } else {
  699. printk(KERN_ERR
  700. "%s: Your board isn't known (yet) to the driver.\n"
  701. "%s: Try to pick one of the existing card configs via\n"
  702. "%s: card=<n> insmod option. Updating to the latest\n"
  703. "%s: version might help as well.\n",
  704. dev->name, dev->name, dev->name, dev->name);
  705. }
  706. printk(KERN_ERR "%s: Here are valid choices for the card=<n> insmod option:\n",
  707. dev->name);
  708. for (i = 0; i < saa7164_bcount; i++)
  709. printk(KERN_ERR "%s: card=%d -> %s\n",
  710. dev->name, i, saa7164_boards[i].name);
  711. }
  712. /* TODO: clean this define up into the -cards.c structs */
  713. #define PCIEBRIDGE_UNITID 2
  714. void saa7164_gpio_setup(struct saa7164_dev *dev)
  715. {
  716. switch (dev->board) {
  717. case SAA7164_BOARD_HAUPPAUGE_HVR2200:
  718. case SAA7164_BOARD_HAUPPAUGE_HVR2200_2:
  719. case SAA7164_BOARD_HAUPPAUGE_HVR2200_3:
  720. case SAA7164_BOARD_HAUPPAUGE_HVR2200_4:
  721. case SAA7164_BOARD_HAUPPAUGE_HVR2200_5:
  722. case SAA7164_BOARD_HAUPPAUGE_HVR2250:
  723. case SAA7164_BOARD_HAUPPAUGE_HVR2250_2:
  724. case SAA7164_BOARD_HAUPPAUGE_HVR2250_3:
  725. case SAA7164_BOARD_HAUPPAUGE_HVR2255proto:
  726. case SAA7164_BOARD_HAUPPAUGE_HVR2255:
  727. case SAA7164_BOARD_HAUPPAUGE_HVR2205:
  728. /*
  729. HVR2200 / HVR2250
  730. GPIO 2: s5h1411 / tda10048-1 demod reset
  731. GPIO 3: s5h1411 / tda10048-2 demod reset
  732. GPIO 7: IRBlaster Zilog reset
  733. */
  734. /* HVR2255
  735. * GPIO 2: lgdg3306-1 demod reset
  736. * GPIO 3: lgdt3306-2 demod reset
  737. */
  738. /* HVR2205
  739. * GPIO 2: si2168-1 demod reset
  740. * GPIO 3: si2168-2 demod reset
  741. */
  742. /* Reset parts by going in and out of reset */
  743. saa7164_api_clear_gpiobit(dev, PCIEBRIDGE_UNITID, 2);
  744. saa7164_api_clear_gpiobit(dev, PCIEBRIDGE_UNITID, 3);
  745. msleep(20);
  746. saa7164_api_set_gpiobit(dev, PCIEBRIDGE_UNITID, 2);
  747. saa7164_api_set_gpiobit(dev, PCIEBRIDGE_UNITID, 3);
  748. break;
  749. }
  750. }
  751. static void hauppauge_eeprom(struct saa7164_dev *dev, u8 *eeprom_data)
  752. {
  753. struct tveeprom tv;
  754. tveeprom_hauppauge_analog(&tv, eeprom_data);
  755. /* Make sure we support the board model */
  756. switch (tv.model) {
  757. case 88001:
  758. /* Development board - Limit circulation */
  759. /* WinTV-HVR2250 (PCIe, Retail, full-height bracket)
  760. * ATSC/QAM (TDA18271/S5H1411) and basic analog, no IR, FM */
  761. case 88021:
  762. /* WinTV-HVR2250 (PCIe, Retail, full-height bracket)
  763. * ATSC/QAM (TDA18271/S5H1411) and basic analog, MCE CIR, FM */
  764. break;
  765. case 88041:
  766. /* WinTV-HVR2250 (PCIe, Retail, full-height bracket)
  767. * ATSC/QAM (TDA18271/S5H1411) and basic analog, no IR, FM */
  768. break;
  769. case 88061:
  770. /* WinTV-HVR2250 (PCIe, Retail, full-height bracket)
  771. * ATSC/QAM (TDA18271/S5H1411) and basic analog, FM */
  772. break;
  773. case 89519:
  774. case 89609:
  775. /* WinTV-HVR2200 (PCIe, Retail, full-height)
  776. * DVB-T (TDA18271/TDA10048) and basic analog, no IR */
  777. break;
  778. case 89619:
  779. /* WinTV-HVR2200 (PCIe, Retail, half-height)
  780. * DVB-T (TDA18271/TDA10048) and basic analog, no IR */
  781. break;
  782. case 151009:
  783. /* First production board rev B2I6 */
  784. /* WinTV-HVR2205 (PCIe, Retail, full-height bracket)
  785. * DVB-T/T2/C (SI2157/SI2168) and basic analog, FM */
  786. break;
  787. case 151609:
  788. /* First production board rev B2I6 */
  789. /* WinTV-HVR2205 (PCIe, Retail, half-height bracket)
  790. * DVB-T/T2/C (SI2157/SI2168) and basic analog, FM */
  791. break;
  792. case 151061:
  793. /* First production board rev B1I6 */
  794. /* WinTV-HVR2255 (PCIe, Retail, full-height bracket)
  795. * ATSC/QAM (SI2157/LGDT3306) and basic analog, FM */
  796. break;
  797. default:
  798. printk(KERN_ERR "%s: Warning: Unknown Hauppauge model #%d\n",
  799. dev->name, tv.model);
  800. break;
  801. }
  802. printk(KERN_INFO "%s: Hauppauge eeprom: model=%d\n", dev->name,
  803. tv.model);
  804. }
  805. void saa7164_card_setup(struct saa7164_dev *dev)
  806. {
  807. static u8 eeprom[256];
  808. if (dev->i2c_bus[0].i2c_rc == 0) {
  809. if (saa7164_api_read_eeprom(dev, &eeprom[0],
  810. sizeof(eeprom)) < 0)
  811. return;
  812. }
  813. switch (dev->board) {
  814. case SAA7164_BOARD_HAUPPAUGE_HVR2200:
  815. case SAA7164_BOARD_HAUPPAUGE_HVR2200_2:
  816. case SAA7164_BOARD_HAUPPAUGE_HVR2200_3:
  817. case SAA7164_BOARD_HAUPPAUGE_HVR2200_4:
  818. case SAA7164_BOARD_HAUPPAUGE_HVR2200_5:
  819. case SAA7164_BOARD_HAUPPAUGE_HVR2250:
  820. case SAA7164_BOARD_HAUPPAUGE_HVR2250_2:
  821. case SAA7164_BOARD_HAUPPAUGE_HVR2250_3:
  822. case SAA7164_BOARD_HAUPPAUGE_HVR2255proto:
  823. case SAA7164_BOARD_HAUPPAUGE_HVR2255:
  824. case SAA7164_BOARD_HAUPPAUGE_HVR2205:
  825. hauppauge_eeprom(dev, &eeprom[0]);
  826. break;
  827. }
  828. }
  829. /* With most other drivers, the kernel expects to communicate with subdrivers
  830. * through i2c. This bridge does not allow that, it does not expose any direct
  831. * access to I2C. Instead we have to communicate through the device f/w for
  832. * register access to 'processing units'. Each unit has a unique
  833. * id, regardless of how the physical implementation occurs across
  834. * the three physical i2c buses. The being said if we want leverge of
  835. * the existing kernel drivers for tuners and demods we have to 'speak i2c',
  836. * to this bridge implements 3 virtual i2c buses. This is a helper function
  837. * for those.
  838. *
  839. * Description: Translate the kernels notion of an i2c address and bus into
  840. * the appropriate unitid.
  841. */
  842. int saa7164_i2caddr_to_unitid(struct saa7164_i2c *bus, int addr)
  843. {
  844. /* For a given bus and i2c device address, return the saa7164 unique
  845. * unitid. < 0 on error */
  846. struct saa7164_dev *dev = bus->dev;
  847. struct saa7164_unit *unit;
  848. int i;
  849. for (i = 0; i < SAA7164_MAX_UNITS; i++) {
  850. unit = &saa7164_boards[dev->board].unit[i];
  851. if (unit->type == SAA7164_UNIT_UNDEFINED)
  852. continue;
  853. if ((bus->nr == unit->i2c_bus_nr) &&
  854. (addr == unit->i2c_bus_addr))
  855. return unit->id;
  856. }
  857. return -1;
  858. }
  859. /* The 7164 API needs to know the i2c register length in advance.
  860. * this is a helper function. Based on a specific chip addr and bus return the
  861. * reg length.
  862. */
  863. int saa7164_i2caddr_to_reglen(struct saa7164_i2c *bus, int addr)
  864. {
  865. /* For a given bus and i2c device address, return the
  866. * saa7164 registry address width. < 0 on error
  867. */
  868. struct saa7164_dev *dev = bus->dev;
  869. struct saa7164_unit *unit;
  870. int i;
  871. for (i = 0; i < SAA7164_MAX_UNITS; i++) {
  872. unit = &saa7164_boards[dev->board].unit[i];
  873. if (unit->type == SAA7164_UNIT_UNDEFINED)
  874. continue;
  875. if ((bus->nr == unit->i2c_bus_nr) &&
  876. (addr == unit->i2c_bus_addr))
  877. return unit->i2c_reg_len;
  878. }
  879. return -1;
  880. }
  881. /* TODO: implement a 'findeeprom' functio like the above and fix any other
  882. * eeprom related todo's in -api.c.
  883. */
  884. /* Translate a unitid into a x readable device name, for display purposes. */
  885. char *saa7164_unitid_name(struct saa7164_dev *dev, u8 unitid)
  886. {
  887. char *undefed = "UNDEFINED";
  888. char *bridge = "BRIDGE";
  889. struct saa7164_unit *unit;
  890. int i;
  891. if (unitid == 0)
  892. return bridge;
  893. for (i = 0; i < SAA7164_MAX_UNITS; i++) {
  894. unit = &saa7164_boards[dev->board].unit[i];
  895. if (unit->type == SAA7164_UNIT_UNDEFINED)
  896. continue;
  897. if (unitid == unit->id)
  898. return unit->name;
  899. }
  900. return undefed;
  901. }