saa7164-cards.c 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649
  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_HVR2250] = {
  203. .name = "Hauppauge WinTV-HVR2250",
  204. .porta = SAA7164_MPEG_DVB,
  205. .portb = SAA7164_MPEG_DVB,
  206. .portc = SAA7164_MPEG_ENCODER,
  207. .portd = SAA7164_MPEG_ENCODER,
  208. .portc = SAA7164_MPEG_ENCODER,
  209. .portd = SAA7164_MPEG_ENCODER,
  210. .porte = SAA7164_MPEG_VBI,
  211. .portf = SAA7164_MPEG_VBI,
  212. .chiprev = SAA7164_CHIP_REV3,
  213. .unit = {{
  214. .id = 0x22,
  215. .type = SAA7164_UNIT_EEPROM,
  216. .name = "4K EEPROM",
  217. .i2c_bus_nr = SAA7164_I2C_BUS_0,
  218. .i2c_bus_addr = 0xa0 >> 1,
  219. .i2c_reg_len = REGLEN_8bit,
  220. }, {
  221. .id = 0x04,
  222. .type = SAA7164_UNIT_TUNER,
  223. .name = "TDA18271-1",
  224. .i2c_bus_nr = SAA7164_I2C_BUS_1,
  225. .i2c_bus_addr = 0xc0 >> 1,
  226. .i2c_reg_len = REGLEN_8bit,
  227. }, {
  228. .id = 0x07,
  229. .type = SAA7164_UNIT_DIGITAL_DEMODULATOR,
  230. .name = "CX24228/S5H1411-1 (TOP)",
  231. .i2c_bus_nr = SAA7164_I2C_BUS_1,
  232. .i2c_bus_addr = 0x32 >> 1,
  233. .i2c_reg_len = REGLEN_8bit,
  234. }, {
  235. .id = 0x08,
  236. .type = SAA7164_UNIT_DIGITAL_DEMODULATOR,
  237. .name = "CX24228/S5H1411-1 (QAM)",
  238. .i2c_bus_nr = SAA7164_I2C_BUS_1,
  239. .i2c_bus_addr = 0x34 >> 1,
  240. .i2c_reg_len = REGLEN_8bit,
  241. }, {
  242. .id = 0x1e,
  243. .type = SAA7164_UNIT_TUNER,
  244. .name = "TDA18271-2",
  245. .i2c_bus_nr = SAA7164_I2C_BUS_2,
  246. .i2c_bus_addr = 0xc0 >> 1,
  247. .i2c_reg_len = REGLEN_8bit,
  248. }, {
  249. .id = 0x20,
  250. .type = SAA7164_UNIT_DIGITAL_DEMODULATOR,
  251. .name = "CX24228/S5H1411-2 (TOP)",
  252. .i2c_bus_nr = SAA7164_I2C_BUS_2,
  253. .i2c_bus_addr = 0x32 >> 1,
  254. .i2c_reg_len = REGLEN_8bit,
  255. }, {
  256. .id = 0x23,
  257. .type = SAA7164_UNIT_DIGITAL_DEMODULATOR,
  258. .name = "CX24228/S5H1411-2 (QAM)",
  259. .i2c_bus_nr = SAA7164_I2C_BUS_2,
  260. .i2c_bus_addr = 0x34 >> 1,
  261. .i2c_reg_len = REGLEN_8bit,
  262. } },
  263. },
  264. [SAA7164_BOARD_HAUPPAUGE_HVR2250_2] = {
  265. .name = "Hauppauge WinTV-HVR2250",
  266. .porta = SAA7164_MPEG_DVB,
  267. .portb = SAA7164_MPEG_DVB,
  268. .portc = SAA7164_MPEG_ENCODER,
  269. .portd = SAA7164_MPEG_ENCODER,
  270. .porte = SAA7164_MPEG_VBI,
  271. .portf = SAA7164_MPEG_VBI,
  272. .porte = SAA7164_MPEG_VBI,
  273. .portf = SAA7164_MPEG_VBI,
  274. .chiprev = SAA7164_CHIP_REV3,
  275. .unit = {{
  276. .id = 0x28,
  277. .type = SAA7164_UNIT_EEPROM,
  278. .name = "4K EEPROM",
  279. .i2c_bus_nr = SAA7164_I2C_BUS_0,
  280. .i2c_bus_addr = 0xa0 >> 1,
  281. .i2c_reg_len = REGLEN_8bit,
  282. }, {
  283. .id = 0x04,
  284. .type = SAA7164_UNIT_TUNER,
  285. .name = "TDA18271-1",
  286. .i2c_bus_nr = SAA7164_I2C_BUS_1,
  287. .i2c_bus_addr = 0xc0 >> 1,
  288. .i2c_reg_len = REGLEN_8bit,
  289. }, {
  290. .id = 0x07,
  291. .type = SAA7164_UNIT_DIGITAL_DEMODULATOR,
  292. .name = "CX24228/S5H1411-1 (TOP)",
  293. .i2c_bus_nr = SAA7164_I2C_BUS_1,
  294. .i2c_bus_addr = 0x32 >> 1,
  295. .i2c_reg_len = REGLEN_8bit,
  296. }, {
  297. .id = 0x08,
  298. .type = SAA7164_UNIT_DIGITAL_DEMODULATOR,
  299. .name = "CX24228/S5H1411-1 (QAM)",
  300. .i2c_bus_nr = SAA7164_I2C_BUS_1,
  301. .i2c_bus_addr = 0x34 >> 1,
  302. .i2c_reg_len = REGLEN_8bit,
  303. }, {
  304. .id = 0x24,
  305. .type = SAA7164_UNIT_TUNER,
  306. .name = "TDA18271-2",
  307. .i2c_bus_nr = SAA7164_I2C_BUS_2,
  308. .i2c_bus_addr = 0xc0 >> 1,
  309. .i2c_reg_len = REGLEN_8bit,
  310. }, {
  311. .id = 0x26,
  312. .type = SAA7164_UNIT_DIGITAL_DEMODULATOR,
  313. .name = "CX24228/S5H1411-2 (TOP)",
  314. .i2c_bus_nr = SAA7164_I2C_BUS_2,
  315. .i2c_bus_addr = 0x32 >> 1,
  316. .i2c_reg_len = REGLEN_8bit,
  317. }, {
  318. .id = 0x29,
  319. .type = SAA7164_UNIT_DIGITAL_DEMODULATOR,
  320. .name = "CX24228/S5H1411-2 (QAM)",
  321. .i2c_bus_nr = SAA7164_I2C_BUS_2,
  322. .i2c_bus_addr = 0x34 >> 1,
  323. .i2c_reg_len = REGLEN_8bit,
  324. } },
  325. },
  326. [SAA7164_BOARD_HAUPPAUGE_HVR2250_3] = {
  327. .name = "Hauppauge WinTV-HVR2250",
  328. .porta = SAA7164_MPEG_DVB,
  329. .portb = SAA7164_MPEG_DVB,
  330. .portc = SAA7164_MPEG_ENCODER,
  331. .portd = SAA7164_MPEG_ENCODER,
  332. .porte = SAA7164_MPEG_VBI,
  333. .portf = SAA7164_MPEG_VBI,
  334. .chiprev = SAA7164_CHIP_REV3,
  335. .unit = {{
  336. .id = 0x26,
  337. .type = SAA7164_UNIT_EEPROM,
  338. .name = "4K EEPROM",
  339. .i2c_bus_nr = SAA7164_I2C_BUS_0,
  340. .i2c_bus_addr = 0xa0 >> 1,
  341. .i2c_reg_len = REGLEN_8bit,
  342. }, {
  343. .id = 0x04,
  344. .type = SAA7164_UNIT_TUNER,
  345. .name = "TDA18271-1",
  346. .i2c_bus_nr = SAA7164_I2C_BUS_1,
  347. .i2c_bus_addr = 0xc0 >> 1,
  348. .i2c_reg_len = REGLEN_8bit,
  349. }, {
  350. .id = 0x07,
  351. .type = SAA7164_UNIT_DIGITAL_DEMODULATOR,
  352. .name = "CX24228/S5H1411-1 (TOP)",
  353. .i2c_bus_nr = SAA7164_I2C_BUS_1,
  354. .i2c_bus_addr = 0x32 >> 1,
  355. .i2c_reg_len = REGLEN_8bit,
  356. }, {
  357. .id = 0x08,
  358. .type = SAA7164_UNIT_DIGITAL_DEMODULATOR,
  359. .name = "CX24228/S5H1411-1 (QAM)",
  360. .i2c_bus_nr = SAA7164_I2C_BUS_1,
  361. .i2c_bus_addr = 0x34 >> 1,
  362. .i2c_reg_len = REGLEN_8bit,
  363. }, {
  364. .id = 0x22,
  365. .type = SAA7164_UNIT_TUNER,
  366. .name = "TDA18271-2",
  367. .i2c_bus_nr = SAA7164_I2C_BUS_2,
  368. .i2c_bus_addr = 0xc0 >> 1,
  369. .i2c_reg_len = REGLEN_8bit,
  370. }, {
  371. .id = 0x24,
  372. .type = SAA7164_UNIT_DIGITAL_DEMODULATOR,
  373. .name = "CX24228/S5H1411-2 (TOP)",
  374. .i2c_bus_nr = SAA7164_I2C_BUS_2,
  375. .i2c_bus_addr = 0x32 >> 1,
  376. .i2c_reg_len = REGLEN_8bit,
  377. }, {
  378. .id = 0x27,
  379. .type = SAA7164_UNIT_DIGITAL_DEMODULATOR,
  380. .name = "CX24228/S5H1411-2 (QAM)",
  381. .i2c_bus_nr = SAA7164_I2C_BUS_2,
  382. .i2c_bus_addr = 0x34 >> 1,
  383. .i2c_reg_len = REGLEN_8bit,
  384. } },
  385. },
  386. };
  387. const unsigned int saa7164_bcount = ARRAY_SIZE(saa7164_boards);
  388. /* ------------------------------------------------------------------ */
  389. /* PCI subsystem IDs */
  390. struct saa7164_subid saa7164_subids[] = {
  391. {
  392. .subvendor = 0x0070,
  393. .subdevice = 0x8880,
  394. .card = SAA7164_BOARD_HAUPPAUGE_HVR2250,
  395. }, {
  396. .subvendor = 0x0070,
  397. .subdevice = 0x8810,
  398. .card = SAA7164_BOARD_HAUPPAUGE_HVR2250,
  399. }, {
  400. .subvendor = 0x0070,
  401. .subdevice = 0x8980,
  402. .card = SAA7164_BOARD_HAUPPAUGE_HVR2200,
  403. }, {
  404. .subvendor = 0x0070,
  405. .subdevice = 0x8900,
  406. .card = SAA7164_BOARD_HAUPPAUGE_HVR2200_2,
  407. }, {
  408. .subvendor = 0x0070,
  409. .subdevice = 0x8901,
  410. .card = SAA7164_BOARD_HAUPPAUGE_HVR2200_3,
  411. }, {
  412. .subvendor = 0x0070,
  413. .subdevice = 0x88A1,
  414. .card = SAA7164_BOARD_HAUPPAUGE_HVR2250_3,
  415. }, {
  416. .subvendor = 0x0070,
  417. .subdevice = 0x8891,
  418. .card = SAA7164_BOARD_HAUPPAUGE_HVR2250_2,
  419. }, {
  420. .subvendor = 0x0070,
  421. .subdevice = 0x8851,
  422. .card = SAA7164_BOARD_HAUPPAUGE_HVR2250_2,
  423. },
  424. };
  425. const unsigned int saa7164_idcount = ARRAY_SIZE(saa7164_subids);
  426. void saa7164_card_list(struct saa7164_dev *dev)
  427. {
  428. int i;
  429. if (0 == dev->pci->subsystem_vendor &&
  430. 0 == dev->pci->subsystem_device) {
  431. printk(KERN_ERR
  432. "%s: Board has no valid PCIe Subsystem ID and can't\n"
  433. "%s: be autodetected. Pass card=<n> insmod option to\n"
  434. "%s: workaround that. Send complaints to the vendor\n"
  435. "%s: of the TV card. Best regards,\n"
  436. "%s: -- tux\n",
  437. dev->name, dev->name, dev->name, dev->name, dev->name);
  438. } else {
  439. printk(KERN_ERR
  440. "%s: Your board isn't known (yet) to the driver.\n"
  441. "%s: Try to pick one of the existing card configs via\n"
  442. "%s: card=<n> insmod option. Updating to the latest\n"
  443. "%s: version might help as well.\n",
  444. dev->name, dev->name, dev->name, dev->name);
  445. }
  446. printk(KERN_ERR "%s: Here are valid choices for the card=<n> insmod "
  447. "option:\n", dev->name);
  448. for (i = 0; i < saa7164_bcount; i++)
  449. printk(KERN_ERR "%s: card=%d -> %s\n",
  450. dev->name, i, saa7164_boards[i].name);
  451. }
  452. /* TODO: clean this define up into the -cards.c structs */
  453. #define PCIEBRIDGE_UNITID 2
  454. void saa7164_gpio_setup(struct saa7164_dev *dev)
  455. {
  456. switch (dev->board) {
  457. case SAA7164_BOARD_HAUPPAUGE_HVR2200:
  458. case SAA7164_BOARD_HAUPPAUGE_HVR2200_2:
  459. case SAA7164_BOARD_HAUPPAUGE_HVR2200_3:
  460. case SAA7164_BOARD_HAUPPAUGE_HVR2250:
  461. case SAA7164_BOARD_HAUPPAUGE_HVR2250_2:
  462. case SAA7164_BOARD_HAUPPAUGE_HVR2250_3:
  463. /*
  464. GPIO 2: s5h1411 / tda10048-1 demod reset
  465. GPIO 3: s5h1411 / tda10048-2 demod reset
  466. GPIO 7: IRBlaster Zilog reset
  467. */
  468. /* Reset parts by going in and out of reset */
  469. saa7164_api_clear_gpiobit(dev, PCIEBRIDGE_UNITID, 2);
  470. saa7164_api_clear_gpiobit(dev, PCIEBRIDGE_UNITID, 3);
  471. msleep(20);
  472. saa7164_api_set_gpiobit(dev, PCIEBRIDGE_UNITID, 2);
  473. saa7164_api_set_gpiobit(dev, PCIEBRIDGE_UNITID, 3);
  474. break;
  475. }
  476. }
  477. static void hauppauge_eeprom(struct saa7164_dev *dev, u8 *eeprom_data)
  478. {
  479. struct tveeprom tv;
  480. /* TODO: Assumption: eeprom on bus 0 */
  481. tveeprom_hauppauge_analog(&dev->i2c_bus[0].i2c_client, &tv,
  482. eeprom_data);
  483. /* Make sure we support the board model */
  484. switch (tv.model) {
  485. case 88001:
  486. /* Development board - Limit circulation */
  487. /* WinTV-HVR2250 (PCIe, Retail, full-height bracket)
  488. * ATSC/QAM (TDA18271/S5H1411) and basic analog, no IR, FM */
  489. case 88021:
  490. /* WinTV-HVR2250 (PCIe, Retail, full-height bracket)
  491. * ATSC/QAM (TDA18271/S5H1411) and basic analog, MCE CIR, FM */
  492. break;
  493. case 88041:
  494. /* WinTV-HVR2250 (PCIe, Retail, full-height bracket)
  495. * ATSC/QAM (TDA18271/S5H1411) and basic analog, no IR, FM */
  496. break;
  497. case 88061:
  498. /* WinTV-HVR2250 (PCIe, Retail, full-height bracket)
  499. * ATSC/QAM (TDA18271/S5H1411) and basic analog, FM */
  500. break;
  501. case 89519:
  502. case 89609:
  503. /* WinTV-HVR2200 (PCIe, Retail, full-height)
  504. * DVB-T (TDA18271/TDA10048) and basic analog, no IR */
  505. break;
  506. case 89619:
  507. /* WinTV-HVR2200 (PCIe, Retail, half-height)
  508. * DVB-T (TDA18271/TDA10048) and basic analog, no IR */
  509. break;
  510. default:
  511. printk(KERN_ERR "%s: Warning: Unknown Hauppauge model #%d\n",
  512. dev->name, tv.model);
  513. break;
  514. }
  515. printk(KERN_INFO "%s: Hauppauge eeprom: model=%d\n", dev->name,
  516. tv.model);
  517. }
  518. void saa7164_card_setup(struct saa7164_dev *dev)
  519. {
  520. static u8 eeprom[256];
  521. if (dev->i2c_bus[0].i2c_rc == 0) {
  522. if (saa7164_api_read_eeprom(dev, &eeprom[0],
  523. sizeof(eeprom)) < 0)
  524. return;
  525. }
  526. switch (dev->board) {
  527. case SAA7164_BOARD_HAUPPAUGE_HVR2200:
  528. case SAA7164_BOARD_HAUPPAUGE_HVR2200_2:
  529. case SAA7164_BOARD_HAUPPAUGE_HVR2200_3:
  530. case SAA7164_BOARD_HAUPPAUGE_HVR2250:
  531. case SAA7164_BOARD_HAUPPAUGE_HVR2250_2:
  532. case SAA7164_BOARD_HAUPPAUGE_HVR2250_3:
  533. hauppauge_eeprom(dev, &eeprom[0]);
  534. break;
  535. }
  536. }
  537. /* With most other drivers, the kernel expects to communicate with subdrivers
  538. * through i2c. This bridge does not allow that, it does not expose any direct
  539. * access to I2C. Instead we have to communicate through the device f/w for
  540. * register access to 'processing units'. Each unit has a unique
  541. * id, regardless of how the physical implementation occurs across
  542. * the three physical i2c busses. The being said if we want leverge of
  543. * the existing kernel drivers for tuners and demods we have to 'speak i2c',
  544. * to this bridge implements 3 virtual i2c buses. This is a helper function
  545. * for those.
  546. *
  547. * Description: Translate the kernels notion of an i2c address and bus into
  548. * the appropriate unitid.
  549. */
  550. int saa7164_i2caddr_to_unitid(struct saa7164_i2c *bus, int addr)
  551. {
  552. /* For a given bus and i2c device address, return the saa7164 unique
  553. * unitid. < 0 on error */
  554. struct saa7164_dev *dev = bus->dev;
  555. struct saa7164_unit *unit;
  556. int i;
  557. for (i = 0; i < SAA7164_MAX_UNITS; i++) {
  558. unit = &saa7164_boards[dev->board].unit[i];
  559. if (unit->type == SAA7164_UNIT_UNDEFINED)
  560. continue;
  561. if ((bus->nr == unit->i2c_bus_nr) &&
  562. (addr == unit->i2c_bus_addr))
  563. return unit->id;
  564. }
  565. return -1;
  566. }
  567. /* The 7164 API needs to know the i2c register length in advance.
  568. * this is a helper function. Based on a specific chip addr and bus return the
  569. * reg length.
  570. */
  571. int saa7164_i2caddr_to_reglen(struct saa7164_i2c *bus, int addr)
  572. {
  573. /* For a given bus and i2c device address, return the
  574. * saa7164 registry address width. < 0 on error
  575. */
  576. struct saa7164_dev *dev = bus->dev;
  577. struct saa7164_unit *unit;
  578. int i;
  579. for (i = 0; i < SAA7164_MAX_UNITS; i++) {
  580. unit = &saa7164_boards[dev->board].unit[i];
  581. if (unit->type == SAA7164_UNIT_UNDEFINED)
  582. continue;
  583. if ((bus->nr == unit->i2c_bus_nr) &&
  584. (addr == unit->i2c_bus_addr))
  585. return unit->i2c_reg_len;
  586. }
  587. return -1;
  588. }
  589. /* TODO: implement a 'findeeprom' functio like the above and fix any other
  590. * eeprom related todo's in -api.c.
  591. */
  592. /* Translate a unitid into a x readable device name, for display purposes. */
  593. char *saa7164_unitid_name(struct saa7164_dev *dev, u8 unitid)
  594. {
  595. char *undefed = "UNDEFINED";
  596. char *bridge = "BRIDGE";
  597. struct saa7164_unit *unit;
  598. int i;
  599. if (unitid == 0)
  600. return bridge;
  601. for (i = 0; i < SAA7164_MAX_UNITS; i++) {
  602. unit = &saa7164_boards[dev->board].unit[i];
  603. if (unit->type == SAA7164_UNIT_UNDEFINED)
  604. continue;
  605. if (unitid == unit->id)
  606. return unit->name;
  607. }
  608. return undefed;
  609. }