ths8200.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556
  1. /*
  2. * ths8200 - Texas Instruments THS8200 video encoder driver
  3. *
  4. * Copyright 2013 Cisco Systems, Inc. and/or its affiliates.
  5. *
  6. * This program is free software; you may redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation; version 2 of the License.
  9. *
  10. * This program is free software; you can redistribute it and/or
  11. * modify it under the terms of the GNU General Public License as
  12. * published by the Free Software Foundation version 2.
  13. *
  14. * This program is distributed .as is. WITHOUT ANY WARRANTY of any
  15. * kind, whether express or implied; without even the implied warranty
  16. * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  17. * GNU General Public License for more details.
  18. */
  19. #include <linux/i2c.h>
  20. #include <linux/module.h>
  21. #include <linux/v4l2-dv-timings.h>
  22. #include <media/v4l2-device.h>
  23. #include "ths8200_regs.h"
  24. static int debug;
  25. module_param(debug, int, 0644);
  26. MODULE_PARM_DESC(debug, "debug level (0-2)");
  27. MODULE_DESCRIPTION("Texas Instruments THS8200 video encoder driver");
  28. MODULE_AUTHOR("Mats Randgaard <mats.randgaard@cisco.com>");
  29. MODULE_AUTHOR("Martin Bugge <martin.bugge@cisco.com>");
  30. MODULE_LICENSE("GPL v2");
  31. struct ths8200_state {
  32. struct v4l2_subdev sd;
  33. uint8_t chip_version;
  34. /* Is the ths8200 powered on? */
  35. bool power_on;
  36. struct v4l2_dv_timings dv_timings;
  37. };
  38. static const struct v4l2_dv_timings ths8200_timings[] = {
  39. V4L2_DV_BT_CEA_720X480P59_94,
  40. V4L2_DV_BT_CEA_1280X720P24,
  41. V4L2_DV_BT_CEA_1280X720P25,
  42. V4L2_DV_BT_CEA_1280X720P30,
  43. V4L2_DV_BT_CEA_1280X720P50,
  44. V4L2_DV_BT_CEA_1280X720P60,
  45. V4L2_DV_BT_CEA_1920X1080P24,
  46. V4L2_DV_BT_CEA_1920X1080P25,
  47. V4L2_DV_BT_CEA_1920X1080P30,
  48. V4L2_DV_BT_CEA_1920X1080P50,
  49. V4L2_DV_BT_CEA_1920X1080P60,
  50. };
  51. static inline struct ths8200_state *to_state(struct v4l2_subdev *sd)
  52. {
  53. return container_of(sd, struct ths8200_state, sd);
  54. }
  55. static inline unsigned hblanking(const struct v4l2_bt_timings *t)
  56. {
  57. return t->hfrontporch + t->hsync + t->hbackporch;
  58. }
  59. static inline unsigned htotal(const struct v4l2_bt_timings *t)
  60. {
  61. return t->width + t->hfrontporch + t->hsync + t->hbackporch;
  62. }
  63. static inline unsigned vblanking(const struct v4l2_bt_timings *t)
  64. {
  65. return t->vfrontporch + t->vsync + t->vbackporch;
  66. }
  67. static inline unsigned vtotal(const struct v4l2_bt_timings *t)
  68. {
  69. return t->height + t->vfrontporch + t->vsync + t->vbackporch;
  70. }
  71. static int ths8200_read(struct v4l2_subdev *sd, u8 reg)
  72. {
  73. struct i2c_client *client = v4l2_get_subdevdata(sd);
  74. return i2c_smbus_read_byte_data(client, reg);
  75. }
  76. static int ths8200_write(struct v4l2_subdev *sd, u8 reg, u8 val)
  77. {
  78. struct i2c_client *client = v4l2_get_subdevdata(sd);
  79. int ret;
  80. int i;
  81. for (i = 0; i < 3; i++) {
  82. ret = i2c_smbus_write_byte_data(client, reg, val);
  83. if (ret == 0)
  84. return 0;
  85. }
  86. v4l2_err(sd, "I2C Write Problem\n");
  87. return ret;
  88. }
  89. /* To set specific bits in the register, a clear-mask is given (to be AND-ed),
  90. * and then the value-mask (to be OR-ed).
  91. */
  92. static inline void
  93. ths8200_write_and_or(struct v4l2_subdev *sd, u8 reg,
  94. uint8_t clr_mask, uint8_t val_mask)
  95. {
  96. ths8200_write(sd, reg, (ths8200_read(sd, reg) & clr_mask) | val_mask);
  97. }
  98. #ifdef CONFIG_VIDEO_ADV_DEBUG
  99. static int ths8200_g_register(struct v4l2_subdev *sd,
  100. struct v4l2_dbg_register *reg)
  101. {
  102. reg->val = ths8200_read(sd, reg->reg & 0xff);
  103. reg->size = 1;
  104. return 0;
  105. }
  106. static int ths8200_s_register(struct v4l2_subdev *sd,
  107. const struct v4l2_dbg_register *reg)
  108. {
  109. ths8200_write(sd, reg->reg & 0xff, reg->val & 0xff);
  110. return 0;
  111. }
  112. #endif
  113. static void ths8200_print_timings(struct v4l2_subdev *sd,
  114. struct v4l2_dv_timings *timings,
  115. const char *txt, bool detailed)
  116. {
  117. struct v4l2_bt_timings *bt = &timings->bt;
  118. u32 htot, vtot;
  119. if (timings->type != V4L2_DV_BT_656_1120)
  120. return;
  121. htot = htotal(bt);
  122. vtot = vtotal(bt);
  123. v4l2_info(sd, "%s %dx%d%s%d (%dx%d)",
  124. txt, bt->width, bt->height, bt->interlaced ? "i" : "p",
  125. (htot * vtot) > 0 ? ((u32)bt->pixelclock / (htot * vtot)) : 0,
  126. htot, vtot);
  127. if (detailed) {
  128. v4l2_info(sd, " horizontal: fp = %d, %ssync = %d, bp = %d\n",
  129. bt->hfrontporch,
  130. (bt->polarities & V4L2_DV_HSYNC_POS_POL) ? "+" : "-",
  131. bt->hsync, bt->hbackporch);
  132. v4l2_info(sd, " vertical: fp = %d, %ssync = %d, bp = %d\n",
  133. bt->vfrontporch,
  134. (bt->polarities & V4L2_DV_VSYNC_POS_POL) ? "+" : "-",
  135. bt->vsync, bt->vbackporch);
  136. v4l2_info(sd,
  137. " pixelclock: %lld, flags: 0x%x, standards: 0x%x\n",
  138. bt->pixelclock, bt->flags, bt->standards);
  139. }
  140. }
  141. static int ths8200_log_status(struct v4l2_subdev *sd)
  142. {
  143. struct ths8200_state *state = to_state(sd);
  144. uint8_t reg_03 = ths8200_read(sd, THS8200_CHIP_CTL);
  145. v4l2_info(sd, "----- Chip status -----\n");
  146. v4l2_info(sd, "version: %u\n", state->chip_version);
  147. v4l2_info(sd, "power: %s\n", (reg_03 & 0x0c) ? "off" : "on");
  148. v4l2_info(sd, "reset: %s\n", (reg_03 & 0x01) ? "off" : "on");
  149. v4l2_info(sd, "test pattern: %s\n",
  150. (reg_03 & 0x20) ? "enabled" : "disabled");
  151. v4l2_info(sd, "format: %ux%u\n",
  152. ths8200_read(sd, THS8200_DTG2_PIXEL_CNT_MSB) * 256 +
  153. ths8200_read(sd, THS8200_DTG2_PIXEL_CNT_LSB),
  154. (ths8200_read(sd, THS8200_DTG2_LINE_CNT_MSB) & 0x07) * 256 +
  155. ths8200_read(sd, THS8200_DTG2_LINE_CNT_LSB));
  156. ths8200_print_timings(sd, &state->dv_timings,
  157. "Configured format:", true);
  158. return 0;
  159. }
  160. /* Power up/down ths8200 */
  161. static int ths8200_s_power(struct v4l2_subdev *sd, int on)
  162. {
  163. struct ths8200_state *state = to_state(sd);
  164. v4l2_dbg(1, debug, sd, "%s: power %s\n", __func__, on ? "on" : "off");
  165. state->power_on = on;
  166. /* Power up/down - leave in reset state until input video is present */
  167. ths8200_write_and_or(sd, THS8200_CHIP_CTL, 0xf2, (on ? 0x00 : 0x0c));
  168. return 0;
  169. }
  170. static const struct v4l2_subdev_core_ops ths8200_core_ops = {
  171. .log_status = ths8200_log_status,
  172. .s_power = ths8200_s_power,
  173. #ifdef CONFIG_VIDEO_ADV_DEBUG
  174. .g_register = ths8200_g_register,
  175. .s_register = ths8200_s_register,
  176. #endif
  177. };
  178. /* -----------------------------------------------------------------------------
  179. * V4L2 subdev video operations
  180. */
  181. static int ths8200_s_stream(struct v4l2_subdev *sd, int enable)
  182. {
  183. struct ths8200_state *state = to_state(sd);
  184. if (enable && !state->power_on)
  185. ths8200_s_power(sd, true);
  186. ths8200_write_and_or(sd, THS8200_CHIP_CTL, 0xfe,
  187. (enable ? 0x01 : 0x00));
  188. v4l2_dbg(1, debug, sd, "%s: %sable\n",
  189. __func__, (enable ? "en" : "dis"));
  190. return 0;
  191. }
  192. static void ths8200_core_init(struct v4l2_subdev *sd)
  193. {
  194. /* setup clocks */
  195. ths8200_write_and_or(sd, THS8200_CHIP_CTL, 0x3f, 0xc0);
  196. /**** Data path control (DATA) ****/
  197. /* Set FSADJ 700 mV,
  198. * bypass 422-444 interpolation,
  199. * input format 30 bit RGB444
  200. */
  201. ths8200_write(sd, THS8200_DATA_CNTL, 0x70);
  202. /* DTG Mode (Video blocked during blanking
  203. * VESA slave
  204. */
  205. ths8200_write(sd, THS8200_DTG1_MODE, 0x87);
  206. /**** Display Timing Generator Control, Part 1 (DTG1). ****/
  207. /* Disable embedded syncs on the output by setting
  208. * the amplitude to zero for all channels.
  209. */
  210. ths8200_write(sd, THS8200_DTG1_Y_SYNC_MSB, 0x2a);
  211. ths8200_write(sd, THS8200_DTG1_CBCR_SYNC_MSB, 0x2a);
  212. }
  213. static void ths8200_setup(struct v4l2_subdev *sd, struct v4l2_bt_timings *bt)
  214. {
  215. uint8_t polarity = 0;
  216. uint16_t line_start_active_video = (bt->vsync + bt->vbackporch);
  217. uint16_t line_start_front_porch = (vtotal(bt) - bt->vfrontporch);
  218. /*** System ****/
  219. /* Set chip in reset while it is configured */
  220. ths8200_s_stream(sd, false);
  221. /* configure video output timings */
  222. ths8200_write(sd, THS8200_DTG1_SPEC_A, bt->hsync);
  223. ths8200_write(sd, THS8200_DTG1_SPEC_B, bt->hfrontporch);
  224. /* Zero for progressive scan formats.*/
  225. if (!bt->interlaced)
  226. ths8200_write(sd, THS8200_DTG1_SPEC_C, 0x00);
  227. /* Distance from leading edge of h sync to start of active video.
  228. * MSB in 0x2b
  229. */
  230. ths8200_write(sd, THS8200_DTG1_SPEC_D_LSB,
  231. (bt->hbackporch + bt->hsync) & 0xff);
  232. /* Zero for SDTV-mode. MSB in 0x2b */
  233. ths8200_write(sd, THS8200_DTG1_SPEC_E_LSB, 0x00);
  234. /*
  235. * MSB for dtg1_spec(d/e/h). See comment for
  236. * corresponding LSB registers.
  237. */
  238. ths8200_write(sd, THS8200_DTG1_SPEC_DEH_MSB,
  239. ((bt->hbackporch + bt->hsync) & 0x100) >> 1);
  240. /* h front porch */
  241. ths8200_write(sd, THS8200_DTG1_SPEC_K_LSB, (bt->hfrontporch) & 0xff);
  242. ths8200_write(sd, THS8200_DTG1_SPEC_K_MSB,
  243. ((bt->hfrontporch) & 0x700) >> 8);
  244. /* Half the line length. Used to calculate SDTV line types. */
  245. ths8200_write(sd, THS8200_DTG1_SPEC_G_LSB, (htotal(bt)/2) & 0xff);
  246. ths8200_write(sd, THS8200_DTG1_SPEC_G_MSB,
  247. ((htotal(bt)/2) >> 8) & 0x0f);
  248. /* Total pixels per line (ex. 720p: 1650) */
  249. ths8200_write(sd, THS8200_DTG1_TOT_PIXELS_MSB, htotal(bt) >> 8);
  250. ths8200_write(sd, THS8200_DTG1_TOT_PIXELS_LSB, htotal(bt) & 0xff);
  251. /* Frame height and field height */
  252. /* Field height should be programmed higher than frame_size for
  253. * progressive scan formats
  254. */
  255. ths8200_write(sd, THS8200_DTG1_FRAME_FIELD_SZ_MSB,
  256. ((vtotal(bt) >> 4) & 0xf0) + 0x7);
  257. ths8200_write(sd, THS8200_DTG1_FRAME_SZ_LSB, vtotal(bt) & 0xff);
  258. /* Should be programmed higher than frame_size
  259. * for progressive formats
  260. */
  261. if (!bt->interlaced)
  262. ths8200_write(sd, THS8200_DTG1_FIELD_SZ_LSB, 0xff);
  263. /**** Display Timing Generator Control, Part 2 (DTG2). ****/
  264. /* Set breakpoint line numbers and types
  265. * THS8200 generates line types with different properties. A line type
  266. * that sets all the RGB-outputs to zero is used in the blanking areas,
  267. * while a line type that enable the RGB-outputs is used in active video
  268. * area. The line numbers for start of active video, start of front
  269. * porch and after the last line in the frame must be set with the
  270. * corresponding line types.
  271. *
  272. * Line types:
  273. * 0x9 - Full normal sync pulse: Blocks data when dtg1_pass is off.
  274. * Used in blanking area.
  275. * 0x0 - Active video: Video data is always passed. Used in active
  276. * video area.
  277. */
  278. ths8200_write_and_or(sd, THS8200_DTG2_BP1_2_MSB, 0x88,
  279. ((line_start_active_video >> 4) & 0x70) +
  280. ((line_start_front_porch >> 8) & 0x07));
  281. ths8200_write(sd, THS8200_DTG2_BP3_4_MSB, ((vtotal(bt)) >> 4) & 0x70);
  282. ths8200_write(sd, THS8200_DTG2_BP1_LSB, line_start_active_video & 0xff);
  283. ths8200_write(sd, THS8200_DTG2_BP2_LSB, line_start_front_porch & 0xff);
  284. ths8200_write(sd, THS8200_DTG2_BP3_LSB, (vtotal(bt)) & 0xff);
  285. /* line types */
  286. ths8200_write(sd, THS8200_DTG2_LINETYPE1, 0x90);
  287. ths8200_write(sd, THS8200_DTG2_LINETYPE2, 0x90);
  288. /* h sync width transmitted */
  289. ths8200_write(sd, THS8200_DTG2_HLENGTH_LSB, bt->hsync & 0xff);
  290. ths8200_write_and_or(sd, THS8200_DTG2_HLENGTH_LSB_HDLY_MSB, 0x3f,
  291. (bt->hsync >> 2) & 0xc0);
  292. /* The pixel value h sync is asserted on */
  293. ths8200_write_and_or(sd, THS8200_DTG2_HLENGTH_LSB_HDLY_MSB, 0xe0,
  294. (htotal(bt) >> 8) & 0x1f);
  295. ths8200_write(sd, THS8200_DTG2_HLENGTH_HDLY_LSB, htotal(bt));
  296. /* v sync width transmitted */
  297. ths8200_write(sd, THS8200_DTG2_VLENGTH1_LSB, (bt->vsync) & 0xff);
  298. ths8200_write_and_or(sd, THS8200_DTG2_VLENGTH1_MSB_VDLY1_MSB, 0x3f,
  299. ((bt->vsync) >> 2) & 0xc0);
  300. /* The pixel value v sync is asserted on */
  301. ths8200_write_and_or(sd, THS8200_DTG2_VLENGTH1_MSB_VDLY1_MSB, 0xf8,
  302. (vtotal(bt)>>8) & 0x7);
  303. ths8200_write(sd, THS8200_DTG2_VDLY1_LSB, vtotal(bt));
  304. /* For progressive video vlength2 must be set to all 0 and vdly2 must
  305. * be set to all 1.
  306. */
  307. ths8200_write(sd, THS8200_DTG2_VLENGTH2_LSB, 0x00);
  308. ths8200_write(sd, THS8200_DTG2_VLENGTH2_MSB_VDLY2_MSB, 0x07);
  309. ths8200_write(sd, THS8200_DTG2_VDLY2_LSB, 0xff);
  310. /* Internal delay factors to synchronize the sync pulses and the data */
  311. /* Experimental values delays (hor 4, ver 1) */
  312. ths8200_write(sd, THS8200_DTG2_HS_IN_DLY_MSB, (htotal(bt)>>8) & 0x1f);
  313. ths8200_write(sd, THS8200_DTG2_HS_IN_DLY_LSB, (htotal(bt) - 4) & 0xff);
  314. ths8200_write(sd, THS8200_DTG2_VS_IN_DLY_MSB, 0);
  315. ths8200_write(sd, THS8200_DTG2_VS_IN_DLY_LSB, 1);
  316. /* Polarity of received and transmitted sync signals */
  317. if (bt->polarities & V4L2_DV_HSYNC_POS_POL) {
  318. polarity |= 0x01; /* HS_IN */
  319. polarity |= 0x08; /* HS_OUT */
  320. }
  321. if (bt->polarities & V4L2_DV_VSYNC_POS_POL) {
  322. polarity |= 0x02; /* VS_IN */
  323. polarity |= 0x10; /* VS_OUT */
  324. }
  325. /* RGB mode, no embedded timings */
  326. /* Timing of video input bus is derived from HS, VS, and FID dedicated
  327. * inputs
  328. */
  329. ths8200_write(sd, THS8200_DTG2_CNTL, 0x47 | polarity);
  330. /* leave reset */
  331. ths8200_s_stream(sd, true);
  332. v4l2_dbg(1, debug, sd, "%s: frame %dx%d, polarity %d\n"
  333. "horizontal: front porch %d, back porch %d, sync %d\n"
  334. "vertical: sync %d\n", __func__, htotal(bt), vtotal(bt),
  335. polarity, bt->hfrontporch, bt->hbackporch,
  336. bt->hsync, bt->vsync);
  337. }
  338. static int ths8200_s_dv_timings(struct v4l2_subdev *sd,
  339. struct v4l2_dv_timings *timings)
  340. {
  341. struct ths8200_state *state = to_state(sd);
  342. int i;
  343. v4l2_dbg(1, debug, sd, "%s:\n", __func__);
  344. if (timings->type != V4L2_DV_BT_656_1120)
  345. return -EINVAL;
  346. /* TODO Support interlaced formats */
  347. if (timings->bt.interlaced) {
  348. v4l2_dbg(1, debug, sd, "TODO Support interlaced formats\n");
  349. return -EINVAL;
  350. }
  351. for (i = 0; i < ARRAY_SIZE(ths8200_timings); i++) {
  352. if (v4l_match_dv_timings(&ths8200_timings[i], timings, 10))
  353. break;
  354. }
  355. if (i == ARRAY_SIZE(ths8200_timings)) {
  356. v4l2_dbg(1, debug, sd, "Unsupported format\n");
  357. return -EINVAL;
  358. }
  359. timings->bt.flags &= ~V4L2_DV_FL_REDUCED_FPS;
  360. /* save timings */
  361. state->dv_timings = *timings;
  362. ths8200_setup(sd, &timings->bt);
  363. return 0;
  364. }
  365. static int ths8200_g_dv_timings(struct v4l2_subdev *sd,
  366. struct v4l2_dv_timings *timings)
  367. {
  368. struct ths8200_state *state = to_state(sd);
  369. v4l2_dbg(1, debug, sd, "%s:\n", __func__);
  370. *timings = state->dv_timings;
  371. return 0;
  372. }
  373. static int ths8200_enum_dv_timings(struct v4l2_subdev *sd,
  374. struct v4l2_enum_dv_timings *timings)
  375. {
  376. /* Check requested format index is within range */
  377. if (timings->index >= ARRAY_SIZE(ths8200_timings))
  378. return -EINVAL;
  379. timings->timings = ths8200_timings[timings->index];
  380. return 0;
  381. }
  382. static int ths8200_dv_timings_cap(struct v4l2_subdev *sd,
  383. struct v4l2_dv_timings_cap *cap)
  384. {
  385. cap->type = V4L2_DV_BT_656_1120;
  386. cap->bt.max_width = 1920;
  387. cap->bt.max_height = 1080;
  388. cap->bt.min_pixelclock = 27000000;
  389. cap->bt.max_pixelclock = 148500000;
  390. cap->bt.standards = V4L2_DV_BT_STD_CEA861;
  391. cap->bt.capabilities = V4L2_DV_BT_CAP_PROGRESSIVE;
  392. return 0;
  393. }
  394. /* Specific video subsystem operation handlers */
  395. static const struct v4l2_subdev_video_ops ths8200_video_ops = {
  396. .s_stream = ths8200_s_stream,
  397. .s_dv_timings = ths8200_s_dv_timings,
  398. .g_dv_timings = ths8200_g_dv_timings,
  399. .enum_dv_timings = ths8200_enum_dv_timings,
  400. .dv_timings_cap = ths8200_dv_timings_cap,
  401. };
  402. /* V4L2 top level operation handlers */
  403. static const struct v4l2_subdev_ops ths8200_ops = {
  404. .core = &ths8200_core_ops,
  405. .video = &ths8200_video_ops,
  406. };
  407. static int ths8200_probe(struct i2c_client *client,
  408. const struct i2c_device_id *id)
  409. {
  410. struct ths8200_state *state;
  411. struct v4l2_subdev *sd;
  412. /* Check if the adapter supports the needed features */
  413. if (!i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_BYTE_DATA))
  414. return -EIO;
  415. state = devm_kzalloc(&client->dev, sizeof(*state), GFP_KERNEL);
  416. if (!state)
  417. return -ENOMEM;
  418. sd = &state->sd;
  419. v4l2_i2c_subdev_init(sd, client, &ths8200_ops);
  420. state->chip_version = ths8200_read(sd, THS8200_VERSION);
  421. v4l2_dbg(1, debug, sd, "chip version 0x%x\n", state->chip_version);
  422. ths8200_core_init(sd);
  423. v4l2_info(sd, "%s found @ 0x%x (%s)\n", client->name,
  424. client->addr << 1, client->adapter->name);
  425. return 0;
  426. }
  427. static int ths8200_remove(struct i2c_client *client)
  428. {
  429. struct v4l2_subdev *sd = i2c_get_clientdata(client);
  430. v4l2_dbg(1, debug, sd, "%s removed @ 0x%x (%s)\n", client->name,
  431. client->addr << 1, client->adapter->name);
  432. ths8200_s_power(sd, false);
  433. v4l2_device_unregister_subdev(sd);
  434. return 0;
  435. }
  436. static struct i2c_device_id ths8200_id[] = {
  437. { "ths8200", 0 },
  438. {},
  439. };
  440. MODULE_DEVICE_TABLE(i2c, ths8200_id);
  441. static struct i2c_driver ths8200_driver = {
  442. .driver = {
  443. .owner = THIS_MODULE,
  444. .name = "ths8200",
  445. },
  446. .probe = ths8200_probe,
  447. .remove = ths8200_remove,
  448. .id_table = ths8200_id,
  449. };
  450. module_i2c_driver(ths8200_driver);