chrontel-ch7033.c 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620
  1. // SPDX-License-Identifier: GPL-2.0-only
  2. /*
  3. * Chrontel CH7033 Video Encoder Driver
  4. *
  5. * Copyright (C) 2019,2020 Lubomir Rintel
  6. */
  7. #include <linux/gpio/consumer.h>
  8. #include <linux/i2c.h>
  9. #include <linux/module.h>
  10. #include <linux/regmap.h>
  11. #include <drm/drm_atomic_helper.h>
  12. #include <drm/drm_bridge.h>
  13. #include <drm/drm_edid.h>
  14. #include <drm/drm_of.h>
  15. #include <drm/drm_print.h>
  16. #include <drm/drm_probe_helper.h>
  17. /* Page 0, Register 0x07 */
  18. enum {
  19. DRI_PD = BIT(3),
  20. IO_PD = BIT(5),
  21. };
  22. /* Page 0, Register 0x08 */
  23. enum {
  24. DRI_PDDRI = GENMASK(7, 4),
  25. PDDAC = GENMASK(3, 1),
  26. PANEN = BIT(0),
  27. };
  28. /* Page 0, Register 0x09 */
  29. enum {
  30. DPD = BIT(7),
  31. GCKOFF = BIT(6),
  32. TV_BP = BIT(5),
  33. SCLPD = BIT(4),
  34. SDPD = BIT(3),
  35. VGA_PD = BIT(2),
  36. HDBKPD = BIT(1),
  37. HDMI_PD = BIT(0),
  38. };
  39. /* Page 0, Register 0x0a */
  40. enum {
  41. MEMINIT = BIT(7),
  42. MEMIDLE = BIT(6),
  43. MEMPD = BIT(5),
  44. STOP = BIT(4),
  45. LVDS_PD = BIT(3),
  46. HD_DVIB = BIT(2),
  47. HDCP_PD = BIT(1),
  48. MCU_PD = BIT(0),
  49. };
  50. /* Page 0, Register 0x18 */
  51. enum {
  52. IDF = GENMASK(7, 4),
  53. INTEN = BIT(3),
  54. SWAP = GENMASK(2, 0),
  55. };
  56. enum {
  57. BYTE_SWAP_RGB = 0,
  58. BYTE_SWAP_RBG = 1,
  59. BYTE_SWAP_GRB = 2,
  60. BYTE_SWAP_GBR = 3,
  61. BYTE_SWAP_BRG = 4,
  62. BYTE_SWAP_BGR = 5,
  63. };
  64. /* Page 0, Register 0x19 */
  65. enum {
  66. HPO_I = BIT(5),
  67. VPO_I = BIT(4),
  68. DEPO_I = BIT(3),
  69. CRYS_EN = BIT(2),
  70. GCLKFREQ = GENMASK(2, 0),
  71. };
  72. /* Page 0, Register 0x2e */
  73. enum {
  74. HFLIP = BIT(7),
  75. VFLIP = BIT(6),
  76. DEPO_O = BIT(5),
  77. HPO_O = BIT(4),
  78. VPO_O = BIT(3),
  79. TE = GENMASK(2, 0),
  80. };
  81. /* Page 0, Register 0x2b */
  82. enum {
  83. SWAPS = GENMASK(7, 4),
  84. VFMT = GENMASK(3, 0),
  85. };
  86. /* Page 0, Register 0x54 */
  87. enum {
  88. COMP_BP = BIT(7),
  89. DAC_EN_T = BIT(6),
  90. HWO_HDMI_HI = GENMASK(5, 3),
  91. HOO_HDMI_HI = GENMASK(2, 0),
  92. };
  93. /* Page 0, Register 0x57 */
  94. enum {
  95. FLDSEN = BIT(7),
  96. VWO_HDMI_HI = GENMASK(5, 3),
  97. VOO_HDMI_HI = GENMASK(2, 0),
  98. };
  99. /* Page 0, Register 0x7e */
  100. enum {
  101. HDMI_LVDS_SEL = BIT(7),
  102. DE_GEN = BIT(6),
  103. PWM_INDEX_HI = BIT(5),
  104. USE_DE = BIT(4),
  105. R_INT = GENMASK(3, 0),
  106. };
  107. /* Page 1, Register 0x07 */
  108. enum {
  109. BPCKSEL = BIT(7),
  110. DRI_CMFB_EN = BIT(6),
  111. CEC_PUEN = BIT(5),
  112. CEC_T = BIT(3),
  113. CKINV = BIT(2),
  114. CK_TVINV = BIT(1),
  115. DRI_CKS2 = BIT(0),
  116. };
  117. /* Page 1, Register 0x08 */
  118. enum {
  119. DACG = BIT(6),
  120. DACKTST = BIT(5),
  121. DEDGEB = BIT(4),
  122. SYO = BIT(3),
  123. DRI_IT_LVDS = GENMASK(2, 1),
  124. DISPON = BIT(0),
  125. };
  126. /* Page 1, Register 0x0c */
  127. enum {
  128. DRI_PLL_CP = GENMASK(7, 6),
  129. DRI_PLL_DIVSEL = BIT(5),
  130. DRI_PLL_N1_1 = BIT(4),
  131. DRI_PLL_N1_0 = BIT(3),
  132. DRI_PLL_N3_1 = BIT(2),
  133. DRI_PLL_N3_0 = BIT(1),
  134. DRI_PLL_CKTSTEN = BIT(0),
  135. };
  136. /* Page 1, Register 0x6b */
  137. enum {
  138. VCO3CS = GENMASK(7, 6),
  139. ICPGBK2_0 = GENMASK(5, 3),
  140. DRI_VCO357SC = BIT(2),
  141. PDPLL2 = BIT(1),
  142. DRI_PD_SER = BIT(0),
  143. };
  144. /* Page 1, Register 0x6c */
  145. enum {
  146. PLL2N11 = GENMASK(7, 4),
  147. PLL2N5_4 = BIT(3),
  148. PLL2N5_TOP = BIT(2),
  149. DRI_PLL_PD = BIT(1),
  150. PD_I2CM = BIT(0),
  151. };
  152. /* Page 3, Register 0x28 */
  153. enum {
  154. DIFF_EN = GENMASK(7, 6),
  155. CORREC_EN = GENMASK(5, 4),
  156. VGACLK_BP = BIT(3),
  157. HM_LV_SEL = BIT(2),
  158. HD_VGA_SEL = BIT(1),
  159. };
  160. /* Page 3, Register 0x2a */
  161. enum {
  162. LVDSCLK_BP = BIT(7),
  163. HDTVCLK_BP = BIT(6),
  164. HDMICLK_BP = BIT(5),
  165. HDTV_BP = BIT(4),
  166. HDMI_BP = BIT(3),
  167. THRWL = GENMASK(2, 0),
  168. };
  169. /* Page 4, Register 0x52 */
  170. enum {
  171. PGM_ARSTB = BIT(7),
  172. MCU_ARSTB = BIT(6),
  173. MCU_RETB = BIT(2),
  174. RESETIB = BIT(1),
  175. RESETDB = BIT(0),
  176. };
  177. struct ch7033_priv {
  178. struct regmap *regmap;
  179. struct drm_bridge *next_bridge;
  180. struct drm_bridge bridge;
  181. struct drm_connector connector;
  182. };
  183. #define conn_to_ch7033_priv(x) \
  184. container_of(x, struct ch7033_priv, connector)
  185. #define bridge_to_ch7033_priv(x) \
  186. container_of(x, struct ch7033_priv, bridge)
  187. static enum drm_connector_status ch7033_connector_detect(
  188. struct drm_connector *connector, bool force)
  189. {
  190. struct ch7033_priv *priv = conn_to_ch7033_priv(connector);
  191. return drm_bridge_detect(priv->next_bridge);
  192. }
  193. static const struct drm_connector_funcs ch7033_connector_funcs = {
  194. .reset = drm_atomic_helper_connector_reset,
  195. .fill_modes = drm_helper_probe_single_connector_modes,
  196. .detect = ch7033_connector_detect,
  197. .destroy = drm_connector_cleanup,
  198. .atomic_duplicate_state = drm_atomic_helper_connector_duplicate_state,
  199. .atomic_destroy_state = drm_atomic_helper_connector_destroy_state,
  200. };
  201. static int ch7033_connector_get_modes(struct drm_connector *connector)
  202. {
  203. struct ch7033_priv *priv = conn_to_ch7033_priv(connector);
  204. struct edid *edid;
  205. int ret;
  206. edid = drm_bridge_get_edid(priv->next_bridge, connector);
  207. drm_connector_update_edid_property(connector, edid);
  208. if (edid) {
  209. ret = drm_add_edid_modes(connector, edid);
  210. kfree(edid);
  211. } else {
  212. ret = drm_add_modes_noedid(connector, 1920, 1080);
  213. drm_set_preferred_mode(connector, 1024, 768);
  214. }
  215. return ret;
  216. }
  217. static struct drm_encoder *ch7033_connector_best_encoder(
  218. struct drm_connector *connector)
  219. {
  220. struct ch7033_priv *priv = conn_to_ch7033_priv(connector);
  221. return priv->bridge.encoder;
  222. }
  223. static const struct drm_connector_helper_funcs ch7033_connector_helper_funcs = {
  224. .get_modes = ch7033_connector_get_modes,
  225. .best_encoder = ch7033_connector_best_encoder,
  226. };
  227. static void ch7033_hpd_event(void *arg, enum drm_connector_status status)
  228. {
  229. struct ch7033_priv *priv = arg;
  230. if (priv->bridge.dev)
  231. drm_helper_hpd_irq_event(priv->connector.dev);
  232. }
  233. static int ch7033_bridge_attach(struct drm_bridge *bridge,
  234. enum drm_bridge_attach_flags flags)
  235. {
  236. struct ch7033_priv *priv = bridge_to_ch7033_priv(bridge);
  237. struct drm_connector *connector = &priv->connector;
  238. int ret;
  239. ret = drm_bridge_attach(bridge->encoder, priv->next_bridge, bridge,
  240. DRM_BRIDGE_ATTACH_NO_CONNECTOR);
  241. if (ret)
  242. return ret;
  243. if (flags & DRM_BRIDGE_ATTACH_NO_CONNECTOR)
  244. return 0;
  245. if (priv->next_bridge->ops & DRM_BRIDGE_OP_DETECT) {
  246. connector->polled = DRM_CONNECTOR_POLL_HPD;
  247. } else {
  248. connector->polled = DRM_CONNECTOR_POLL_CONNECT |
  249. DRM_CONNECTOR_POLL_DISCONNECT;
  250. }
  251. if (priv->next_bridge->ops & DRM_BRIDGE_OP_HPD) {
  252. drm_bridge_hpd_enable(priv->next_bridge, ch7033_hpd_event,
  253. priv);
  254. }
  255. drm_connector_helper_add(connector,
  256. &ch7033_connector_helper_funcs);
  257. ret = drm_connector_init_with_ddc(bridge->dev, &priv->connector,
  258. &ch7033_connector_funcs,
  259. priv->next_bridge->type,
  260. priv->next_bridge->ddc);
  261. if (ret) {
  262. DRM_ERROR("Failed to initialize connector\n");
  263. return ret;
  264. }
  265. return drm_connector_attach_encoder(&priv->connector, bridge->encoder);
  266. }
  267. static void ch7033_bridge_detach(struct drm_bridge *bridge)
  268. {
  269. struct ch7033_priv *priv = bridge_to_ch7033_priv(bridge);
  270. if (priv->next_bridge->ops & DRM_BRIDGE_OP_HPD)
  271. drm_bridge_hpd_disable(priv->next_bridge);
  272. drm_connector_cleanup(&priv->connector);
  273. }
  274. static enum drm_mode_status ch7033_bridge_mode_valid(struct drm_bridge *bridge,
  275. const struct drm_display_info *info,
  276. const struct drm_display_mode *mode)
  277. {
  278. if (mode->clock > 165000)
  279. return MODE_CLOCK_HIGH;
  280. if (mode->hdisplay >= 1920)
  281. return MODE_BAD_HVALUE;
  282. if (mode->vdisplay >= 1080)
  283. return MODE_BAD_VVALUE;
  284. return MODE_OK;
  285. }
  286. static void ch7033_bridge_disable(struct drm_bridge *bridge)
  287. {
  288. struct ch7033_priv *priv = bridge_to_ch7033_priv(bridge);
  289. regmap_write(priv->regmap, 0x03, 0x04);
  290. regmap_update_bits(priv->regmap, 0x52, RESETDB, 0x00);
  291. }
  292. static void ch7033_bridge_enable(struct drm_bridge *bridge)
  293. {
  294. struct ch7033_priv *priv = bridge_to_ch7033_priv(bridge);
  295. regmap_write(priv->regmap, 0x03, 0x04);
  296. regmap_update_bits(priv->regmap, 0x52, RESETDB, RESETDB);
  297. }
  298. static void ch7033_bridge_mode_set(struct drm_bridge *bridge,
  299. const struct drm_display_mode *mode,
  300. const struct drm_display_mode *adjusted_mode)
  301. {
  302. struct ch7033_priv *priv = bridge_to_ch7033_priv(bridge);
  303. int hbporch = mode->hsync_start - mode->hdisplay;
  304. int hsynclen = mode->hsync_end - mode->hsync_start;
  305. int vbporch = mode->vsync_start - mode->vdisplay;
  306. int vsynclen = mode->vsync_end - mode->vsync_start;
  307. /*
  308. * Page 4
  309. */
  310. regmap_write(priv->regmap, 0x03, 0x04);
  311. /* Turn everything off to set all the registers to their defaults. */
  312. regmap_write(priv->regmap, 0x52, 0x00);
  313. /* Bring I/O block up. */
  314. regmap_write(priv->regmap, 0x52, RESETIB);
  315. /*
  316. * Page 0
  317. */
  318. regmap_write(priv->regmap, 0x03, 0x00);
  319. /* Bring up parts we need from the power down. */
  320. regmap_update_bits(priv->regmap, 0x07, DRI_PD | IO_PD, 0);
  321. regmap_update_bits(priv->regmap, 0x08, DRI_PDDRI | PDDAC | PANEN, 0);
  322. regmap_update_bits(priv->regmap, 0x09, DPD | GCKOFF |
  323. HDMI_PD | VGA_PD, 0);
  324. regmap_update_bits(priv->regmap, 0x0a, HD_DVIB, 0);
  325. /* Horizontal input timing. */
  326. regmap_write(priv->regmap, 0x0b, (mode->htotal >> 8) << 3 |
  327. (mode->hdisplay >> 8));
  328. regmap_write(priv->regmap, 0x0c, mode->hdisplay);
  329. regmap_write(priv->regmap, 0x0d, mode->htotal);
  330. regmap_write(priv->regmap, 0x0e, (hsynclen >> 8) << 3 |
  331. (hbporch >> 8));
  332. regmap_write(priv->regmap, 0x0f, hbporch);
  333. regmap_write(priv->regmap, 0x10, hsynclen);
  334. /* Vertical input timing. */
  335. regmap_write(priv->regmap, 0x11, (mode->vtotal >> 8) << 3 |
  336. (mode->vdisplay >> 8));
  337. regmap_write(priv->regmap, 0x12, mode->vdisplay);
  338. regmap_write(priv->regmap, 0x13, mode->vtotal);
  339. regmap_write(priv->regmap, 0x14, ((vsynclen >> 8) << 3) |
  340. (vbporch >> 8));
  341. regmap_write(priv->regmap, 0x15, vbporch);
  342. regmap_write(priv->regmap, 0x16, vsynclen);
  343. /* Input color swap. */
  344. regmap_update_bits(priv->regmap, 0x18, SWAP, BYTE_SWAP_BGR);
  345. /* Input clock and sync polarity. */
  346. regmap_update_bits(priv->regmap, 0x19, 0x1, mode->clock >> 16);
  347. regmap_update_bits(priv->regmap, 0x19, HPO_I | VPO_I | GCLKFREQ,
  348. (mode->flags & DRM_MODE_FLAG_PHSYNC) ? HPO_I : 0 |
  349. (mode->flags & DRM_MODE_FLAG_PVSYNC) ? VPO_I : 0 |
  350. mode->clock >> 16);
  351. regmap_write(priv->regmap, 0x1a, mode->clock >> 8);
  352. regmap_write(priv->regmap, 0x1b, mode->clock);
  353. /* Horizontal output timing. */
  354. regmap_write(priv->regmap, 0x1f, (mode->htotal >> 8) << 3 |
  355. (mode->hdisplay >> 8));
  356. regmap_write(priv->regmap, 0x20, mode->hdisplay);
  357. regmap_write(priv->regmap, 0x21, mode->htotal);
  358. /* Vertical output timing. */
  359. regmap_write(priv->regmap, 0x25, (mode->vtotal >> 8) << 3 |
  360. (mode->vdisplay >> 8));
  361. regmap_write(priv->regmap, 0x26, mode->vdisplay);
  362. regmap_write(priv->regmap, 0x27, mode->vtotal);
  363. /* VGA channel bypass */
  364. regmap_update_bits(priv->regmap, 0x2b, VFMT, 9);
  365. /* Output sync polarity. */
  366. regmap_update_bits(priv->regmap, 0x2e, HPO_O | VPO_O,
  367. (mode->flags & DRM_MODE_FLAG_PHSYNC) ? HPO_O : 0 |
  368. (mode->flags & DRM_MODE_FLAG_PVSYNC) ? VPO_O : 0);
  369. /* HDMI horizontal output timing. */
  370. regmap_update_bits(priv->regmap, 0x54, HWO_HDMI_HI | HOO_HDMI_HI,
  371. (hsynclen >> 8) << 3 |
  372. (hbporch >> 8));
  373. regmap_write(priv->regmap, 0x55, hbporch);
  374. regmap_write(priv->regmap, 0x56, hsynclen);
  375. /* HDMI vertical output timing. */
  376. regmap_update_bits(priv->regmap, 0x57, VWO_HDMI_HI | VOO_HDMI_HI,
  377. (vsynclen >> 8) << 3 |
  378. (vbporch >> 8));
  379. regmap_write(priv->regmap, 0x58, vbporch);
  380. regmap_write(priv->regmap, 0x59, vsynclen);
  381. /* Pick HDMI, not LVDS. */
  382. regmap_update_bits(priv->regmap, 0x7e, HDMI_LVDS_SEL, HDMI_LVDS_SEL);
  383. /*
  384. * Page 1
  385. */
  386. regmap_write(priv->regmap, 0x03, 0x01);
  387. /* No idea what these do, but VGA is wobbly and blinky without them. */
  388. regmap_update_bits(priv->regmap, 0x07, CKINV, CKINV);
  389. regmap_update_bits(priv->regmap, 0x08, DISPON, DISPON);
  390. /* DRI PLL */
  391. regmap_update_bits(priv->regmap, 0x0c, DRI_PLL_DIVSEL, DRI_PLL_DIVSEL);
  392. if (mode->clock <= 40000) {
  393. regmap_update_bits(priv->regmap, 0x0c, DRI_PLL_N1_1 |
  394. DRI_PLL_N1_0 |
  395. DRI_PLL_N3_1 |
  396. DRI_PLL_N3_0,
  397. 0);
  398. } else if (mode->clock < 80000) {
  399. regmap_update_bits(priv->regmap, 0x0c, DRI_PLL_N1_1 |
  400. DRI_PLL_N1_0 |
  401. DRI_PLL_N3_1 |
  402. DRI_PLL_N3_0,
  403. DRI_PLL_N3_0 |
  404. DRI_PLL_N1_0);
  405. } else {
  406. regmap_update_bits(priv->regmap, 0x0c, DRI_PLL_N1_1 |
  407. DRI_PLL_N1_0 |
  408. DRI_PLL_N3_1 |
  409. DRI_PLL_N3_0,
  410. DRI_PLL_N3_1 |
  411. DRI_PLL_N1_1);
  412. }
  413. /* This seems to be color calibration for VGA. */
  414. regmap_write(priv->regmap, 0x64, 0x29); /* LSB Blue */
  415. regmap_write(priv->regmap, 0x65, 0x29); /* LSB Green */
  416. regmap_write(priv->regmap, 0x66, 0x29); /* LSB Red */
  417. regmap_write(priv->regmap, 0x67, 0x00); /* MSB Blue */
  418. regmap_write(priv->regmap, 0x68, 0x00); /* MSB Green */
  419. regmap_write(priv->regmap, 0x69, 0x00); /* MSB Red */
  420. regmap_update_bits(priv->regmap, 0x6b, DRI_PD_SER, 0x00);
  421. regmap_update_bits(priv->regmap, 0x6c, DRI_PLL_PD, 0x00);
  422. /*
  423. * Page 3
  424. */
  425. regmap_write(priv->regmap, 0x03, 0x03);
  426. /* More bypasses and apparently another HDMI/LVDS selector. */
  427. regmap_update_bits(priv->regmap, 0x28, VGACLK_BP | HM_LV_SEL,
  428. VGACLK_BP | HM_LV_SEL);
  429. regmap_update_bits(priv->regmap, 0x2a, HDMICLK_BP | HDMI_BP,
  430. HDMICLK_BP | HDMI_BP);
  431. /*
  432. * Page 4
  433. */
  434. regmap_write(priv->regmap, 0x03, 0x04);
  435. /* Output clock. */
  436. regmap_write(priv->regmap, 0x10, mode->clock >> 16);
  437. regmap_write(priv->regmap, 0x11, mode->clock >> 8);
  438. regmap_write(priv->regmap, 0x12, mode->clock);
  439. }
  440. static const struct drm_bridge_funcs ch7033_bridge_funcs = {
  441. .attach = ch7033_bridge_attach,
  442. .detach = ch7033_bridge_detach,
  443. .mode_valid = ch7033_bridge_mode_valid,
  444. .disable = ch7033_bridge_disable,
  445. .enable = ch7033_bridge_enable,
  446. .mode_set = ch7033_bridge_mode_set,
  447. };
  448. static const struct regmap_config ch7033_regmap_config = {
  449. .reg_bits = 8,
  450. .val_bits = 8,
  451. .max_register = 0x7f,
  452. };
  453. static int ch7033_probe(struct i2c_client *client,
  454. const struct i2c_device_id *id)
  455. {
  456. struct device *dev = &client->dev;
  457. struct ch7033_priv *priv;
  458. unsigned int val;
  459. int ret;
  460. priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL);
  461. if (!priv)
  462. return -ENOMEM;
  463. dev_set_drvdata(dev, priv);
  464. ret = drm_of_find_panel_or_bridge(dev->of_node, 1, -1, NULL,
  465. &priv->next_bridge);
  466. if (ret)
  467. return ret;
  468. priv->regmap = devm_regmap_init_i2c(client, &ch7033_regmap_config);
  469. if (IS_ERR(priv->regmap)) {
  470. dev_err(&client->dev, "regmap init failed\n");
  471. return PTR_ERR(priv->regmap);
  472. }
  473. ret = regmap_read(priv->regmap, 0x00, &val);
  474. if (ret < 0) {
  475. dev_err(&client->dev, "error reading the model id: %d\n", ret);
  476. return ret;
  477. }
  478. if ((val & 0xf7) != 0x56) {
  479. dev_err(&client->dev, "the device is not a ch7033\n");
  480. return -ENODEV;
  481. }
  482. regmap_write(priv->regmap, 0x03, 0x04);
  483. ret = regmap_read(priv->regmap, 0x51, &val);
  484. if (ret < 0) {
  485. dev_err(&client->dev, "error reading the model id: %d\n", ret);
  486. return ret;
  487. }
  488. if ((val & 0x0f) != 3) {
  489. dev_err(&client->dev, "unknown revision %u\n", val);
  490. return -ENODEV;
  491. }
  492. INIT_LIST_HEAD(&priv->bridge.list);
  493. priv->bridge.funcs = &ch7033_bridge_funcs;
  494. priv->bridge.of_node = dev->of_node;
  495. drm_bridge_add(&priv->bridge);
  496. dev_info(dev, "Chrontel CH7033 Video Encoder\n");
  497. return 0;
  498. }
  499. static void ch7033_remove(struct i2c_client *client)
  500. {
  501. struct device *dev = &client->dev;
  502. struct ch7033_priv *priv = dev_get_drvdata(dev);
  503. drm_bridge_remove(&priv->bridge);
  504. }
  505. static const struct of_device_id ch7033_dt_ids[] = {
  506. { .compatible = "chrontel,ch7033", },
  507. { }
  508. };
  509. MODULE_DEVICE_TABLE(of, ch7033_dt_ids);
  510. static const struct i2c_device_id ch7033_ids[] = {
  511. { "ch7033", 0 },
  512. { }
  513. };
  514. MODULE_DEVICE_TABLE(i2c, ch7033_ids);
  515. static struct i2c_driver ch7033_driver = {
  516. .probe = ch7033_probe,
  517. .remove = ch7033_remove,
  518. .driver = {
  519. .name = "ch7033",
  520. .of_match_table = of_match_ptr(ch7033_dt_ids),
  521. },
  522. .id_table = ch7033_ids,
  523. };
  524. module_i2c_driver(ch7033_driver);
  525. MODULE_AUTHOR("Lubomir Rintel <[email protected]>");
  526. MODULE_DESCRIPTION("Chrontel CH7033 Video Encoder Driver");
  527. MODULE_LICENSE("GPL v2");