fc2580.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638
  1. /*
  2. * FCI FC2580 silicon tuner driver
  3. *
  4. * Copyright (C) 2012 Antti Palosaari <crope@iki.fi>
  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. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License along
  17. * with this program; if not, write to the Free Software Foundation, Inc.,
  18. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  19. */
  20. #include "fc2580_priv.h"
  21. /*
  22. * TODO:
  23. * I2C write and read works only for one single register. Multiple registers
  24. * could not be accessed using normal register address auto-increment.
  25. * There could be (very likely) register to change that behavior....
  26. */
  27. /* write single register conditionally only when value differs from 0xff
  28. * XXX: This is special routine meant only for writing fc2580_freq_regs_lut[]
  29. * values. Do not use for the other purposes. */
  30. static int fc2580_wr_reg_ff(struct fc2580_dev *dev, u8 reg, u8 val)
  31. {
  32. if (val == 0xff)
  33. return 0;
  34. else
  35. return regmap_write(dev->regmap, reg, val);
  36. }
  37. static int fc2580_set_params(struct fc2580_dev *dev)
  38. {
  39. struct i2c_client *client = dev->client;
  40. int ret, i;
  41. unsigned int uitmp, div_ref, div_ref_val, div_n, k, k_cw, div_out;
  42. u64 f_vco;
  43. u8 synth_config;
  44. unsigned long timeout;
  45. if (!dev->active) {
  46. dev_dbg(&client->dev, "tuner is sleeping\n");
  47. return 0;
  48. }
  49. /*
  50. * Fractional-N synthesizer
  51. *
  52. * +---------------------------------------+
  53. * v |
  54. * Fref +----+ +----+ +-------+ +----+ +------+ +---+
  55. * ------> | /R | --> | PD | --> | VCO | ------> | /2 | --> | /N.F | <-- | K |
  56. * +----+ +----+ +-------+ +----+ +------+ +---+
  57. * |
  58. * |
  59. * v
  60. * +-------+ Fout
  61. * | /Rout | ------>
  62. * +-------+
  63. */
  64. for (i = 0; i < ARRAY_SIZE(fc2580_pll_lut); i++) {
  65. if (dev->f_frequency <= fc2580_pll_lut[i].freq)
  66. break;
  67. }
  68. if (i == ARRAY_SIZE(fc2580_pll_lut)) {
  69. ret = -EINVAL;
  70. goto err;
  71. }
  72. #define DIV_PRE_N 2
  73. #define F_REF dev->clk
  74. div_out = fc2580_pll_lut[i].div_out;
  75. f_vco = (u64) dev->f_frequency * div_out;
  76. synth_config = fc2580_pll_lut[i].band;
  77. if (f_vco < 2600000000ULL)
  78. synth_config |= 0x06;
  79. else
  80. synth_config |= 0x0e;
  81. /* select reference divider R (keep PLL div N in valid range) */
  82. #define DIV_N_MIN 76
  83. if (f_vco >= div_u64((u64) DIV_PRE_N * DIV_N_MIN * F_REF, 1)) {
  84. div_ref = 1;
  85. div_ref_val = 0x00;
  86. } else if (f_vco >= div_u64((u64) DIV_PRE_N * DIV_N_MIN * F_REF, 2)) {
  87. div_ref = 2;
  88. div_ref_val = 0x10;
  89. } else {
  90. div_ref = 4;
  91. div_ref_val = 0x20;
  92. }
  93. /* calculate PLL integer and fractional control word */
  94. uitmp = DIV_PRE_N * F_REF / div_ref;
  95. div_n = div_u64_rem(f_vco, uitmp, &k);
  96. k_cw = div_u64((u64) k * 0x100000, uitmp);
  97. dev_dbg(&client->dev,
  98. "frequency=%u bandwidth=%u f_vco=%llu F_REF=%u div_ref=%u div_n=%u k=%u div_out=%u k_cw=%0x\n",
  99. dev->f_frequency, dev->f_bandwidth, f_vco, F_REF, div_ref,
  100. div_n, k, div_out, k_cw);
  101. ret = regmap_write(dev->regmap, 0x02, synth_config);
  102. if (ret)
  103. goto err;
  104. ret = regmap_write(dev->regmap, 0x18, div_ref_val << 0 | k_cw >> 16);
  105. if (ret)
  106. goto err;
  107. ret = regmap_write(dev->regmap, 0x1a, (k_cw >> 8) & 0xff);
  108. if (ret)
  109. goto err;
  110. ret = regmap_write(dev->regmap, 0x1b, (k_cw >> 0) & 0xff);
  111. if (ret)
  112. goto err;
  113. ret = regmap_write(dev->regmap, 0x1c, div_n);
  114. if (ret)
  115. goto err;
  116. /* registers */
  117. for (i = 0; i < ARRAY_SIZE(fc2580_freq_regs_lut); i++) {
  118. if (dev->f_frequency <= fc2580_freq_regs_lut[i].freq)
  119. break;
  120. }
  121. if (i == ARRAY_SIZE(fc2580_freq_regs_lut)) {
  122. ret = -EINVAL;
  123. goto err;
  124. }
  125. ret = fc2580_wr_reg_ff(dev, 0x25, fc2580_freq_regs_lut[i].r25_val);
  126. if (ret)
  127. goto err;
  128. ret = fc2580_wr_reg_ff(dev, 0x27, fc2580_freq_regs_lut[i].r27_val);
  129. if (ret)
  130. goto err;
  131. ret = fc2580_wr_reg_ff(dev, 0x28, fc2580_freq_regs_lut[i].r28_val);
  132. if (ret)
  133. goto err;
  134. ret = fc2580_wr_reg_ff(dev, 0x29, fc2580_freq_regs_lut[i].r29_val);
  135. if (ret)
  136. goto err;
  137. ret = fc2580_wr_reg_ff(dev, 0x2b, fc2580_freq_regs_lut[i].r2b_val);
  138. if (ret)
  139. goto err;
  140. ret = fc2580_wr_reg_ff(dev, 0x2c, fc2580_freq_regs_lut[i].r2c_val);
  141. if (ret)
  142. goto err;
  143. ret = fc2580_wr_reg_ff(dev, 0x2d, fc2580_freq_regs_lut[i].r2d_val);
  144. if (ret)
  145. goto err;
  146. ret = fc2580_wr_reg_ff(dev, 0x30, fc2580_freq_regs_lut[i].r30_val);
  147. if (ret)
  148. goto err;
  149. ret = fc2580_wr_reg_ff(dev, 0x44, fc2580_freq_regs_lut[i].r44_val);
  150. if (ret)
  151. goto err;
  152. ret = fc2580_wr_reg_ff(dev, 0x50, fc2580_freq_regs_lut[i].r50_val);
  153. if (ret)
  154. goto err;
  155. ret = fc2580_wr_reg_ff(dev, 0x53, fc2580_freq_regs_lut[i].r53_val);
  156. if (ret)
  157. goto err;
  158. ret = fc2580_wr_reg_ff(dev, 0x5f, fc2580_freq_regs_lut[i].r5f_val);
  159. if (ret)
  160. goto err;
  161. ret = fc2580_wr_reg_ff(dev, 0x61, fc2580_freq_regs_lut[i].r61_val);
  162. if (ret)
  163. goto err;
  164. ret = fc2580_wr_reg_ff(dev, 0x62, fc2580_freq_regs_lut[i].r62_val);
  165. if (ret)
  166. goto err;
  167. ret = fc2580_wr_reg_ff(dev, 0x63, fc2580_freq_regs_lut[i].r63_val);
  168. if (ret)
  169. goto err;
  170. ret = fc2580_wr_reg_ff(dev, 0x67, fc2580_freq_regs_lut[i].r67_val);
  171. if (ret)
  172. goto err;
  173. ret = fc2580_wr_reg_ff(dev, 0x68, fc2580_freq_regs_lut[i].r68_val);
  174. if (ret)
  175. goto err;
  176. ret = fc2580_wr_reg_ff(dev, 0x69, fc2580_freq_regs_lut[i].r69_val);
  177. if (ret)
  178. goto err;
  179. ret = fc2580_wr_reg_ff(dev, 0x6a, fc2580_freq_regs_lut[i].r6a_val);
  180. if (ret)
  181. goto err;
  182. ret = fc2580_wr_reg_ff(dev, 0x6b, fc2580_freq_regs_lut[i].r6b_val);
  183. if (ret)
  184. goto err;
  185. ret = fc2580_wr_reg_ff(dev, 0x6c, fc2580_freq_regs_lut[i].r6c_val);
  186. if (ret)
  187. goto err;
  188. ret = fc2580_wr_reg_ff(dev, 0x6d, fc2580_freq_regs_lut[i].r6d_val);
  189. if (ret)
  190. goto err;
  191. ret = fc2580_wr_reg_ff(dev, 0x6e, fc2580_freq_regs_lut[i].r6e_val);
  192. if (ret)
  193. goto err;
  194. ret = fc2580_wr_reg_ff(dev, 0x6f, fc2580_freq_regs_lut[i].r6f_val);
  195. if (ret)
  196. goto err;
  197. /* IF filters */
  198. for (i = 0; i < ARRAY_SIZE(fc2580_if_filter_lut); i++) {
  199. if (dev->f_bandwidth <= fc2580_if_filter_lut[i].freq)
  200. break;
  201. }
  202. if (i == ARRAY_SIZE(fc2580_if_filter_lut)) {
  203. ret = -EINVAL;
  204. goto err;
  205. }
  206. ret = regmap_write(dev->regmap, 0x36, fc2580_if_filter_lut[i].r36_val);
  207. if (ret)
  208. goto err;
  209. uitmp = (unsigned int) 8058000 - (dev->f_bandwidth * 122 / 100 / 2);
  210. uitmp = div64_u64((u64) dev->clk * uitmp, 1000000000000ULL);
  211. ret = regmap_write(dev->regmap, 0x37, uitmp);
  212. if (ret)
  213. goto err;
  214. ret = regmap_write(dev->regmap, 0x39, fc2580_if_filter_lut[i].r39_val);
  215. if (ret)
  216. goto err;
  217. timeout = jiffies + msecs_to_jiffies(30);
  218. for (uitmp = ~0xc0; !time_after(jiffies, timeout) && uitmp != 0xc0;) {
  219. /* trigger filter */
  220. ret = regmap_write(dev->regmap, 0x2e, 0x09);
  221. if (ret)
  222. goto err;
  223. /* locked when [7:6] are set (val: d7 6MHz, d5 7MHz, cd 8MHz) */
  224. ret = regmap_read(dev->regmap, 0x2f, &uitmp);
  225. if (ret)
  226. goto err;
  227. uitmp &= 0xc0;
  228. ret = regmap_write(dev->regmap, 0x2e, 0x01);
  229. if (ret)
  230. goto err;
  231. }
  232. if (uitmp != 0xc0)
  233. dev_dbg(&client->dev, "filter did not lock %02x\n", uitmp);
  234. return 0;
  235. err:
  236. dev_dbg(&client->dev, "failed=%d\n", ret);
  237. return ret;
  238. }
  239. static int fc2580_init(struct fc2580_dev *dev)
  240. {
  241. struct i2c_client *client = dev->client;
  242. int ret, i;
  243. dev_dbg(&client->dev, "\n");
  244. for (i = 0; i < ARRAY_SIZE(fc2580_init_reg_vals); i++) {
  245. ret = regmap_write(dev->regmap, fc2580_init_reg_vals[i].reg,
  246. fc2580_init_reg_vals[i].val);
  247. if (ret)
  248. goto err;
  249. }
  250. dev->active = true;
  251. return 0;
  252. err:
  253. dev_dbg(&client->dev, "failed=%d\n", ret);
  254. return ret;
  255. }
  256. static int fc2580_sleep(struct fc2580_dev *dev)
  257. {
  258. struct i2c_client *client = dev->client;
  259. int ret;
  260. dev_dbg(&client->dev, "\n");
  261. dev->active = false;
  262. ret = regmap_write(dev->regmap, 0x02, 0x0a);
  263. if (ret)
  264. goto err;
  265. return 0;
  266. err:
  267. dev_dbg(&client->dev, "failed=%d\n", ret);
  268. return ret;
  269. }
  270. /*
  271. * DVB API
  272. */
  273. static int fc2580_dvb_set_params(struct dvb_frontend *fe)
  274. {
  275. struct fc2580_dev *dev = fe->tuner_priv;
  276. struct dtv_frontend_properties *c = &fe->dtv_property_cache;
  277. dev->f_frequency = c->frequency;
  278. dev->f_bandwidth = c->bandwidth_hz;
  279. return fc2580_set_params(dev);
  280. }
  281. static int fc2580_dvb_init(struct dvb_frontend *fe)
  282. {
  283. return fc2580_init(fe->tuner_priv);
  284. }
  285. static int fc2580_dvb_sleep(struct dvb_frontend *fe)
  286. {
  287. return fc2580_sleep(fe->tuner_priv);
  288. }
  289. static int fc2580_dvb_get_if_frequency(struct dvb_frontend *fe, u32 *frequency)
  290. {
  291. *frequency = 0; /* Zero-IF */
  292. return 0;
  293. }
  294. static const struct dvb_tuner_ops fc2580_dvb_tuner_ops = {
  295. .info = {
  296. .name = "FCI FC2580",
  297. .frequency_min_hz = 174 * MHz,
  298. .frequency_max_hz = 862 * MHz,
  299. },
  300. .init = fc2580_dvb_init,
  301. .sleep = fc2580_dvb_sleep,
  302. .set_params = fc2580_dvb_set_params,
  303. .get_if_frequency = fc2580_dvb_get_if_frequency,
  304. };
  305. /*
  306. * V4L2 API
  307. */
  308. #if IS_ENABLED(CONFIG_VIDEO_V4L2)
  309. static const struct v4l2_frequency_band bands[] = {
  310. {
  311. .type = V4L2_TUNER_RF,
  312. .index = 0,
  313. .capability = V4L2_TUNER_CAP_1HZ | V4L2_TUNER_CAP_FREQ_BANDS,
  314. .rangelow = 130000000,
  315. .rangehigh = 2000000000,
  316. },
  317. };
  318. static inline struct fc2580_dev *fc2580_subdev_to_dev(struct v4l2_subdev *sd)
  319. {
  320. return container_of(sd, struct fc2580_dev, subdev);
  321. }
  322. static int fc2580_standby(struct v4l2_subdev *sd)
  323. {
  324. struct fc2580_dev *dev = fc2580_subdev_to_dev(sd);
  325. int ret;
  326. ret = fc2580_sleep(dev);
  327. if (ret)
  328. return ret;
  329. return fc2580_set_params(dev);
  330. }
  331. static int fc2580_g_tuner(struct v4l2_subdev *sd, struct v4l2_tuner *v)
  332. {
  333. struct fc2580_dev *dev = fc2580_subdev_to_dev(sd);
  334. struct i2c_client *client = dev->client;
  335. dev_dbg(&client->dev, "index=%d\n", v->index);
  336. strlcpy(v->name, "FCI FC2580", sizeof(v->name));
  337. v->type = V4L2_TUNER_RF;
  338. v->capability = V4L2_TUNER_CAP_1HZ | V4L2_TUNER_CAP_FREQ_BANDS;
  339. v->rangelow = bands[0].rangelow;
  340. v->rangehigh = bands[0].rangehigh;
  341. return 0;
  342. }
  343. static int fc2580_s_tuner(struct v4l2_subdev *sd, const struct v4l2_tuner *v)
  344. {
  345. struct fc2580_dev *dev = fc2580_subdev_to_dev(sd);
  346. struct i2c_client *client = dev->client;
  347. dev_dbg(&client->dev, "index=%d\n", v->index);
  348. return 0;
  349. }
  350. static int fc2580_g_frequency(struct v4l2_subdev *sd, struct v4l2_frequency *f)
  351. {
  352. struct fc2580_dev *dev = fc2580_subdev_to_dev(sd);
  353. struct i2c_client *client = dev->client;
  354. dev_dbg(&client->dev, "tuner=%d\n", f->tuner);
  355. f->frequency = dev->f_frequency;
  356. return 0;
  357. }
  358. static int fc2580_s_frequency(struct v4l2_subdev *sd,
  359. const struct v4l2_frequency *f)
  360. {
  361. struct fc2580_dev *dev = fc2580_subdev_to_dev(sd);
  362. struct i2c_client *client = dev->client;
  363. dev_dbg(&client->dev, "tuner=%d type=%d frequency=%u\n",
  364. f->tuner, f->type, f->frequency);
  365. dev->f_frequency = clamp_t(unsigned int, f->frequency,
  366. bands[0].rangelow, bands[0].rangehigh);
  367. return fc2580_set_params(dev);
  368. }
  369. static int fc2580_enum_freq_bands(struct v4l2_subdev *sd,
  370. struct v4l2_frequency_band *band)
  371. {
  372. struct fc2580_dev *dev = fc2580_subdev_to_dev(sd);
  373. struct i2c_client *client = dev->client;
  374. dev_dbg(&client->dev, "tuner=%d type=%d index=%d\n",
  375. band->tuner, band->type, band->index);
  376. if (band->index >= ARRAY_SIZE(bands))
  377. return -EINVAL;
  378. band->capability = bands[band->index].capability;
  379. band->rangelow = bands[band->index].rangelow;
  380. band->rangehigh = bands[band->index].rangehigh;
  381. return 0;
  382. }
  383. static const struct v4l2_subdev_tuner_ops fc2580_subdev_tuner_ops = {
  384. .standby = fc2580_standby,
  385. .g_tuner = fc2580_g_tuner,
  386. .s_tuner = fc2580_s_tuner,
  387. .g_frequency = fc2580_g_frequency,
  388. .s_frequency = fc2580_s_frequency,
  389. .enum_freq_bands = fc2580_enum_freq_bands,
  390. };
  391. static const struct v4l2_subdev_ops fc2580_subdev_ops = {
  392. .tuner = &fc2580_subdev_tuner_ops,
  393. };
  394. static int fc2580_s_ctrl(struct v4l2_ctrl *ctrl)
  395. {
  396. struct fc2580_dev *dev = container_of(ctrl->handler, struct fc2580_dev, hdl);
  397. struct i2c_client *client = dev->client;
  398. int ret;
  399. dev_dbg(&client->dev, "ctrl: id=%d name=%s cur.val=%d val=%d\n",
  400. ctrl->id, ctrl->name, ctrl->cur.val, ctrl->val);
  401. switch (ctrl->id) {
  402. case V4L2_CID_RF_TUNER_BANDWIDTH_AUTO:
  403. case V4L2_CID_RF_TUNER_BANDWIDTH:
  404. /*
  405. * TODO: Auto logic does not work 100% correctly as tuner driver
  406. * do not have information to calculate maximum suitable
  407. * bandwidth. Calculating it is responsible of master driver.
  408. */
  409. dev->f_bandwidth = dev->bandwidth->val;
  410. ret = fc2580_set_params(dev);
  411. break;
  412. default:
  413. dev_dbg(&client->dev, "unknown ctrl");
  414. ret = -EINVAL;
  415. }
  416. return ret;
  417. }
  418. static const struct v4l2_ctrl_ops fc2580_ctrl_ops = {
  419. .s_ctrl = fc2580_s_ctrl,
  420. };
  421. #endif
  422. static struct v4l2_subdev *fc2580_get_v4l2_subdev(struct i2c_client *client)
  423. {
  424. struct fc2580_dev *dev = i2c_get_clientdata(client);
  425. if (dev->subdev.ops)
  426. return &dev->subdev;
  427. else
  428. return NULL;
  429. }
  430. static int fc2580_probe(struct i2c_client *client,
  431. const struct i2c_device_id *id)
  432. {
  433. struct fc2580_dev *dev;
  434. struct fc2580_platform_data *pdata = client->dev.platform_data;
  435. struct dvb_frontend *fe = pdata->dvb_frontend;
  436. int ret;
  437. unsigned int uitmp;
  438. static const struct regmap_config regmap_config = {
  439. .reg_bits = 8,
  440. .val_bits = 8,
  441. };
  442. dev = kzalloc(sizeof(*dev), GFP_KERNEL);
  443. if (!dev) {
  444. ret = -ENOMEM;
  445. goto err;
  446. }
  447. if (pdata->clk)
  448. dev->clk = pdata->clk;
  449. else
  450. dev->clk = 16384000; /* internal clock */
  451. dev->client = client;
  452. dev->regmap = devm_regmap_init_i2c(client, &regmap_config);
  453. if (IS_ERR(dev->regmap)) {
  454. ret = PTR_ERR(dev->regmap);
  455. goto err_kfree;
  456. }
  457. /* check if the tuner is there */
  458. ret = regmap_read(dev->regmap, 0x01, &uitmp);
  459. if (ret)
  460. goto err_kfree;
  461. dev_dbg(&client->dev, "chip_id=%02x\n", uitmp);
  462. switch (uitmp) {
  463. case 0x56:
  464. case 0x5a:
  465. break;
  466. default:
  467. ret = -ENODEV;
  468. goto err_kfree;
  469. }
  470. #if IS_ENABLED(CONFIG_VIDEO_V4L2)
  471. /* Register controls */
  472. v4l2_ctrl_handler_init(&dev->hdl, 2);
  473. dev->bandwidth_auto = v4l2_ctrl_new_std(&dev->hdl, &fc2580_ctrl_ops,
  474. V4L2_CID_RF_TUNER_BANDWIDTH_AUTO,
  475. 0, 1, 1, 1);
  476. dev->bandwidth = v4l2_ctrl_new_std(&dev->hdl, &fc2580_ctrl_ops,
  477. V4L2_CID_RF_TUNER_BANDWIDTH,
  478. 3000, 10000000, 1, 3000);
  479. v4l2_ctrl_auto_cluster(2, &dev->bandwidth_auto, 0, false);
  480. if (dev->hdl.error) {
  481. ret = dev->hdl.error;
  482. dev_err(&client->dev, "Could not initialize controls\n");
  483. v4l2_ctrl_handler_free(&dev->hdl);
  484. goto err_kfree;
  485. }
  486. dev->subdev.ctrl_handler = &dev->hdl;
  487. dev->f_frequency = bands[0].rangelow;
  488. dev->f_bandwidth = dev->bandwidth->val;
  489. v4l2_i2c_subdev_init(&dev->subdev, client, &fc2580_subdev_ops);
  490. #endif
  491. fe->tuner_priv = dev;
  492. memcpy(&fe->ops.tuner_ops, &fc2580_dvb_tuner_ops,
  493. sizeof(fe->ops.tuner_ops));
  494. pdata->get_v4l2_subdev = fc2580_get_v4l2_subdev;
  495. i2c_set_clientdata(client, dev);
  496. dev_info(&client->dev, "FCI FC2580 successfully identified\n");
  497. return 0;
  498. err_kfree:
  499. kfree(dev);
  500. err:
  501. dev_dbg(&client->dev, "failed=%d\n", ret);
  502. return ret;
  503. }
  504. static int fc2580_remove(struct i2c_client *client)
  505. {
  506. struct fc2580_dev *dev = i2c_get_clientdata(client);
  507. dev_dbg(&client->dev, "\n");
  508. #if IS_ENABLED(CONFIG_VIDEO_V4L2)
  509. v4l2_ctrl_handler_free(&dev->hdl);
  510. #endif
  511. kfree(dev);
  512. return 0;
  513. }
  514. static const struct i2c_device_id fc2580_id_table[] = {
  515. {"fc2580", 0},
  516. {}
  517. };
  518. MODULE_DEVICE_TABLE(i2c, fc2580_id_table);
  519. static struct i2c_driver fc2580_driver = {
  520. .driver = {
  521. .name = "fc2580",
  522. .suppress_bind_attrs = true,
  523. },
  524. .probe = fc2580_probe,
  525. .remove = fc2580_remove,
  526. .id_table = fc2580_id_table,
  527. };
  528. module_i2c_driver(fc2580_driver);
  529. MODULE_DESCRIPTION("FCI FC2580 silicon tuner driver");
  530. MODULE_AUTHOR("Antti Palosaari <crope@iki.fi>");
  531. MODULE_LICENSE("GPL");