saa7164-cards.c 21 KB

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