sil-sii8620.c 37 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564
  1. /*
  2. * Silicon Image SiI8620 HDMI/MHL bridge driver
  3. *
  4. * Copyright (C) 2015, Samsung Electronics Co., Ltd.
  5. * Andrzej Hajda <a.hajda@samsung.com>
  6. *
  7. * This program is free software; you can redistribute it and/or modify
  8. * it under the terms of the GNU General Public License version 2 as
  9. * published by the Free Software Foundation.
  10. */
  11. #include <drm/bridge/mhl.h>
  12. #include <drm/drm_crtc.h>
  13. #include <drm/drm_edid.h>
  14. #include <linux/clk.h>
  15. #include <linux/delay.h>
  16. #include <linux/gpio/consumer.h>
  17. #include <linux/i2c.h>
  18. #include <linux/interrupt.h>
  19. #include <linux/irq.h>
  20. #include <linux/kernel.h>
  21. #include <linux/list.h>
  22. #include <linux/module.h>
  23. #include <linux/mutex.h>
  24. #include <linux/regulator/consumer.h>
  25. #include <linux/slab.h>
  26. #include "sil-sii8620.h"
  27. #define VAL_RX_HDMI_CTRL2_DEFVAL VAL_RX_HDMI_CTRL2_IDLE_CNT(3)
  28. enum sii8620_mode {
  29. CM_DISCONNECTED,
  30. CM_DISCOVERY,
  31. CM_MHL1,
  32. CM_MHL3,
  33. CM_ECBUS_S
  34. };
  35. enum sii8620_sink_type {
  36. SINK_NONE,
  37. SINK_HDMI,
  38. SINK_DVI
  39. };
  40. enum sii8620_mt_state {
  41. MT_STATE_READY,
  42. MT_STATE_BUSY,
  43. MT_STATE_DONE
  44. };
  45. struct sii8620 {
  46. struct drm_bridge bridge;
  47. struct device *dev;
  48. struct clk *clk_xtal;
  49. struct gpio_desc *gpio_reset;
  50. struct gpio_desc *gpio_int;
  51. struct regulator_bulk_data supplies[2];
  52. struct mutex lock; /* context lock, protects fields below */
  53. int error;
  54. enum sii8620_mode mode;
  55. enum sii8620_sink_type sink_type;
  56. u8 cbus_status;
  57. u8 stat[MHL_DST_SIZE];
  58. u8 xstat[MHL_XDS_SIZE];
  59. u8 devcap[MHL_DCAP_SIZE];
  60. u8 xdevcap[MHL_XDC_SIZE];
  61. u8 avif[19];
  62. struct edid *edid;
  63. unsigned int gen2_write_burst:1;
  64. enum sii8620_mt_state mt_state;
  65. struct list_head mt_queue;
  66. };
  67. struct sii8620_mt_msg;
  68. typedef void (*sii8620_mt_msg_cb)(struct sii8620 *ctx,
  69. struct sii8620_mt_msg *msg);
  70. struct sii8620_mt_msg {
  71. struct list_head node;
  72. u8 reg[4];
  73. u8 ret;
  74. sii8620_mt_msg_cb send;
  75. sii8620_mt_msg_cb recv;
  76. };
  77. static const u8 sii8620_i2c_page[] = {
  78. 0x39, /* Main System */
  79. 0x3d, /* TDM and HSIC */
  80. 0x49, /* TMDS Receiver, MHL EDID */
  81. 0x4d, /* eMSC, HDCP, HSIC */
  82. 0x5d, /* MHL Spec */
  83. 0x64, /* MHL CBUS */
  84. 0x59, /* Hardware TPI (Transmitter Programming Interface) */
  85. 0x61, /* eCBUS-S, eCBUS-D */
  86. };
  87. static void sii8620_fetch_edid(struct sii8620 *ctx);
  88. static void sii8620_set_upstream_edid(struct sii8620 *ctx);
  89. static void sii8620_enable_hpd(struct sii8620 *ctx);
  90. static void sii8620_mhl_disconnected(struct sii8620 *ctx);
  91. static int sii8620_clear_error(struct sii8620 *ctx)
  92. {
  93. int ret = ctx->error;
  94. ctx->error = 0;
  95. return ret;
  96. }
  97. static void sii8620_read_buf(struct sii8620 *ctx, u16 addr, u8 *buf, int len)
  98. {
  99. struct device *dev = ctx->dev;
  100. struct i2c_client *client = to_i2c_client(dev);
  101. u8 data = addr;
  102. struct i2c_msg msg[] = {
  103. {
  104. .addr = sii8620_i2c_page[addr >> 8],
  105. .flags = client->flags,
  106. .len = 1,
  107. .buf = &data
  108. },
  109. {
  110. .addr = sii8620_i2c_page[addr >> 8],
  111. .flags = client->flags | I2C_M_RD,
  112. .len = len,
  113. .buf = buf
  114. },
  115. };
  116. int ret;
  117. if (ctx->error)
  118. return;
  119. ret = i2c_transfer(client->adapter, msg, 2);
  120. dev_dbg(dev, "read at %04x: %*ph, %d\n", addr, len, buf, ret);
  121. if (ret != 2) {
  122. dev_err(dev, "Read at %#06x of %d bytes failed with code %d.\n",
  123. addr, len, ret);
  124. ctx->error = ret < 0 ? ret : -EIO;
  125. }
  126. }
  127. static u8 sii8620_readb(struct sii8620 *ctx, u16 addr)
  128. {
  129. u8 ret;
  130. sii8620_read_buf(ctx, addr, &ret, 1);
  131. return ret;
  132. }
  133. static void sii8620_write_buf(struct sii8620 *ctx, u16 addr, const u8 *buf,
  134. int len)
  135. {
  136. struct device *dev = ctx->dev;
  137. struct i2c_client *client = to_i2c_client(dev);
  138. u8 data[2];
  139. struct i2c_msg msg = {
  140. .addr = sii8620_i2c_page[addr >> 8],
  141. .flags = client->flags,
  142. .len = len + 1,
  143. };
  144. int ret;
  145. if (ctx->error)
  146. return;
  147. if (len > 1) {
  148. msg.buf = kmalloc(len + 1, GFP_KERNEL);
  149. if (!msg.buf) {
  150. ctx->error = -ENOMEM;
  151. return;
  152. }
  153. memcpy(msg.buf + 1, buf, len);
  154. } else {
  155. msg.buf = data;
  156. msg.buf[1] = *buf;
  157. }
  158. msg.buf[0] = addr;
  159. ret = i2c_transfer(client->adapter, &msg, 1);
  160. dev_dbg(dev, "write at %04x: %*ph, %d\n", addr, len, buf, ret);
  161. if (ret != 1) {
  162. dev_err(dev, "Write at %#06x of %*ph failed with code %d.\n",
  163. addr, len, buf, ret);
  164. ctx->error = ret ?: -EIO;
  165. }
  166. if (len > 1)
  167. kfree(msg.buf);
  168. }
  169. #define sii8620_write(ctx, addr, arr...) \
  170. ({\
  171. u8 d[] = { arr }; \
  172. sii8620_write_buf(ctx, addr, d, ARRAY_SIZE(d)); \
  173. })
  174. static void __sii8620_write_seq(struct sii8620 *ctx, const u16 *seq, int len)
  175. {
  176. int i;
  177. for (i = 0; i < len; i += 2)
  178. sii8620_write(ctx, seq[i], seq[i + 1]);
  179. }
  180. #define sii8620_write_seq(ctx, seq...) \
  181. ({\
  182. const u16 d[] = { seq }; \
  183. __sii8620_write_seq(ctx, d, ARRAY_SIZE(d)); \
  184. })
  185. #define sii8620_write_seq_static(ctx, seq...) \
  186. ({\
  187. static const u16 d[] = { seq }; \
  188. __sii8620_write_seq(ctx, d, ARRAY_SIZE(d)); \
  189. })
  190. static void sii8620_setbits(struct sii8620 *ctx, u16 addr, u8 mask, u8 val)
  191. {
  192. val = (val & mask) | (sii8620_readb(ctx, addr) & ~mask);
  193. sii8620_write(ctx, addr, val);
  194. }
  195. static void sii8620_mt_cleanup(struct sii8620 *ctx)
  196. {
  197. struct sii8620_mt_msg *msg, *n;
  198. list_for_each_entry_safe(msg, n, &ctx->mt_queue, node) {
  199. list_del(&msg->node);
  200. kfree(msg);
  201. }
  202. ctx->mt_state = MT_STATE_READY;
  203. }
  204. static void sii8620_mt_work(struct sii8620 *ctx)
  205. {
  206. struct sii8620_mt_msg *msg;
  207. if (ctx->error)
  208. return;
  209. if (ctx->mt_state == MT_STATE_BUSY || list_empty(&ctx->mt_queue))
  210. return;
  211. if (ctx->mt_state == MT_STATE_DONE) {
  212. ctx->mt_state = MT_STATE_READY;
  213. msg = list_first_entry(&ctx->mt_queue, struct sii8620_mt_msg,
  214. node);
  215. if (msg->recv)
  216. msg->recv(ctx, msg);
  217. list_del(&msg->node);
  218. kfree(msg);
  219. }
  220. if (ctx->mt_state != MT_STATE_READY || list_empty(&ctx->mt_queue))
  221. return;
  222. ctx->mt_state = MT_STATE_BUSY;
  223. msg = list_first_entry(&ctx->mt_queue, struct sii8620_mt_msg, node);
  224. if (msg->send)
  225. msg->send(ctx, msg);
  226. }
  227. static void sii8620_mt_msc_cmd_send(struct sii8620 *ctx,
  228. struct sii8620_mt_msg *msg)
  229. {
  230. switch (msg->reg[0]) {
  231. case MHL_WRITE_STAT:
  232. case MHL_SET_INT:
  233. sii8620_write_buf(ctx, REG_MSC_CMD_OR_OFFSET, msg->reg + 1, 2);
  234. sii8620_write(ctx, REG_MSC_COMMAND_START,
  235. BIT_MSC_COMMAND_START_WRITE_STAT);
  236. break;
  237. case MHL_MSC_MSG:
  238. sii8620_write_buf(ctx, REG_MSC_CMD_OR_OFFSET, msg->reg, 3);
  239. sii8620_write(ctx, REG_MSC_COMMAND_START,
  240. BIT_MSC_COMMAND_START_MSC_MSG);
  241. break;
  242. default:
  243. dev_err(ctx->dev, "%s: command %#x not supported\n", __func__,
  244. msg->reg[0]);
  245. }
  246. }
  247. static struct sii8620_mt_msg *sii8620_mt_msg_new(struct sii8620 *ctx)
  248. {
  249. struct sii8620_mt_msg *msg = kzalloc(sizeof(*msg), GFP_KERNEL);
  250. if (!msg)
  251. ctx->error = -ENOMEM;
  252. else
  253. list_add_tail(&msg->node, &ctx->mt_queue);
  254. return msg;
  255. }
  256. static void sii8620_mt_msc_cmd(struct sii8620 *ctx, u8 cmd, u8 arg1, u8 arg2)
  257. {
  258. struct sii8620_mt_msg *msg = sii8620_mt_msg_new(ctx);
  259. if (!msg)
  260. return;
  261. msg->reg[0] = cmd;
  262. msg->reg[1] = arg1;
  263. msg->reg[2] = arg2;
  264. msg->send = sii8620_mt_msc_cmd_send;
  265. }
  266. static void sii8620_mt_write_stat(struct sii8620 *ctx, u8 reg, u8 val)
  267. {
  268. sii8620_mt_msc_cmd(ctx, MHL_WRITE_STAT, reg, val);
  269. }
  270. static inline void sii8620_mt_set_int(struct sii8620 *ctx, u8 irq, u8 mask)
  271. {
  272. sii8620_mt_msc_cmd(ctx, MHL_SET_INT, irq, mask);
  273. }
  274. static void sii8620_mt_msc_msg(struct sii8620 *ctx, u8 cmd, u8 data)
  275. {
  276. sii8620_mt_msc_cmd(ctx, MHL_MSC_MSG, cmd, data);
  277. }
  278. static void sii8620_mt_rap(struct sii8620 *ctx, u8 code)
  279. {
  280. sii8620_mt_msc_msg(ctx, MHL_MSC_MSG_RAP, code);
  281. }
  282. static void sii8620_mt_read_devcap_send(struct sii8620 *ctx,
  283. struct sii8620_mt_msg *msg)
  284. {
  285. u8 ctrl = BIT_EDID_CTRL_DEVCAP_SELECT_DEVCAP
  286. | BIT_EDID_CTRL_EDID_FIFO_ADDR_AUTO
  287. | BIT_EDID_CTRL_EDID_MODE_EN;
  288. if (msg->reg[0] == MHL_READ_XDEVCAP)
  289. ctrl |= BIT_EDID_CTRL_XDEVCAP_EN;
  290. sii8620_write_seq(ctx,
  291. REG_INTR9_MASK, BIT_INTR9_DEVCAP_DONE,
  292. REG_EDID_CTRL, ctrl,
  293. REG_TPI_CBUS_START, BIT_TPI_CBUS_START_GET_DEVCAP_START
  294. );
  295. }
  296. /* copy src to dst and set changed bits in src */
  297. static void sii8620_update_array(u8 *dst, u8 *src, int count)
  298. {
  299. while (--count >= 0) {
  300. *src ^= *dst;
  301. *dst++ ^= *src++;
  302. }
  303. }
  304. static void sii8620_mr_devcap(struct sii8620 *ctx)
  305. {
  306. static const char * const sink_str[] = {
  307. [SINK_NONE] = "NONE",
  308. [SINK_HDMI] = "HDMI",
  309. [SINK_DVI] = "DVI"
  310. };
  311. u8 dcap[MHL_DCAP_SIZE];
  312. char sink_name[20];
  313. struct device *dev = ctx->dev;
  314. sii8620_read_buf(ctx, REG_EDID_FIFO_RD_DATA, dcap, MHL_DCAP_SIZE);
  315. if (ctx->error < 0)
  316. return;
  317. dev_info(dev, "dcap: %*ph\n", MHL_DCAP_SIZE, dcap);
  318. dev_info(dev, "detected dongle MHL %d.%d, ChipID %02x%02x:%02x%02x\n",
  319. dcap[MHL_DCAP_MHL_VERSION] / 16,
  320. dcap[MHL_DCAP_MHL_VERSION] % 16, dcap[MHL_DCAP_ADOPTER_ID_H],
  321. dcap[MHL_DCAP_ADOPTER_ID_L], dcap[MHL_DCAP_DEVICE_ID_H],
  322. dcap[MHL_DCAP_DEVICE_ID_L]);
  323. sii8620_update_array(ctx->devcap, dcap, MHL_DCAP_SIZE);
  324. if (!(dcap[MHL_DCAP_CAT] & MHL_DCAP_CAT_SINK))
  325. return;
  326. sii8620_fetch_edid(ctx);
  327. if (!ctx->edid) {
  328. dev_err(ctx->dev, "Cannot fetch EDID\n");
  329. sii8620_mhl_disconnected(ctx);
  330. return;
  331. }
  332. if (drm_detect_hdmi_monitor(ctx->edid))
  333. ctx->sink_type = SINK_HDMI;
  334. else
  335. ctx->sink_type = SINK_DVI;
  336. drm_edid_get_monitor_name(ctx->edid, sink_name, ARRAY_SIZE(sink_name));
  337. dev_info(dev, "detected sink(type: %s): %s\n",
  338. sink_str[ctx->sink_type], sink_name);
  339. sii8620_set_upstream_edid(ctx);
  340. sii8620_enable_hpd(ctx);
  341. }
  342. static void sii8620_mr_xdevcap(struct sii8620 *ctx)
  343. {
  344. sii8620_read_buf(ctx, REG_EDID_FIFO_RD_DATA, ctx->xdevcap,
  345. MHL_XDC_SIZE);
  346. sii8620_mt_write_stat(ctx, MHL_XDS_REG(CURR_ECBUS_MODE),
  347. MHL_XDS_ECBUS_S | MHL_XDS_SLOT_MODE_8BIT);
  348. sii8620_mt_rap(ctx, MHL_RAP_CBUS_MODE_UP);
  349. }
  350. static void sii8620_mt_read_devcap_recv(struct sii8620 *ctx,
  351. struct sii8620_mt_msg *msg)
  352. {
  353. u8 ctrl = BIT_EDID_CTRL_DEVCAP_SELECT_DEVCAP
  354. | BIT_EDID_CTRL_EDID_FIFO_ADDR_AUTO
  355. | BIT_EDID_CTRL_EDID_MODE_EN;
  356. if (msg->reg[0] == MHL_READ_XDEVCAP)
  357. ctrl |= BIT_EDID_CTRL_XDEVCAP_EN;
  358. sii8620_write_seq(ctx,
  359. REG_INTR9_MASK, BIT_INTR9_DEVCAP_DONE | BIT_INTR9_EDID_DONE
  360. | BIT_INTR9_EDID_ERROR,
  361. REG_EDID_CTRL, ctrl,
  362. REG_EDID_FIFO_ADDR, 0
  363. );
  364. if (msg->reg[0] == MHL_READ_XDEVCAP)
  365. sii8620_mr_xdevcap(ctx);
  366. else
  367. sii8620_mr_devcap(ctx);
  368. }
  369. static void sii8620_mt_read_devcap(struct sii8620 *ctx, bool xdevcap)
  370. {
  371. struct sii8620_mt_msg *msg = sii8620_mt_msg_new(ctx);
  372. if (!msg)
  373. return;
  374. msg->reg[0] = xdevcap ? MHL_READ_XDEVCAP : MHL_READ_DEVCAP;
  375. msg->send = sii8620_mt_read_devcap_send;
  376. msg->recv = sii8620_mt_read_devcap_recv;
  377. }
  378. static void sii8620_fetch_edid(struct sii8620 *ctx)
  379. {
  380. u8 lm_ddc, ddc_cmd, int3, cbus;
  381. int fetched, i;
  382. int edid_len = EDID_LENGTH;
  383. u8 *edid;
  384. sii8620_readb(ctx, REG_CBUS_STATUS);
  385. lm_ddc = sii8620_readb(ctx, REG_LM_DDC);
  386. ddc_cmd = sii8620_readb(ctx, REG_DDC_CMD);
  387. sii8620_write_seq(ctx,
  388. REG_INTR9_MASK, 0,
  389. REG_EDID_CTRL, BIT_EDID_CTRL_EDID_FIFO_ADDR_AUTO,
  390. REG_HDCP2X_POLL_CS, 0x71,
  391. REG_HDCP2X_CTRL_0, BIT_HDCP2X_CTRL_0_HDCP2X_HDCPTX,
  392. REG_LM_DDC, lm_ddc | BIT_LM_DDC_SW_TPI_EN_DISABLED,
  393. );
  394. for (i = 0; i < 256; ++i) {
  395. u8 ddc_stat = sii8620_readb(ctx, REG_DDC_STATUS);
  396. if (!(ddc_stat & BIT_DDC_STATUS_DDC_I2C_IN_PROG))
  397. break;
  398. sii8620_write(ctx, REG_DDC_STATUS,
  399. BIT_DDC_STATUS_DDC_FIFO_EMPTY);
  400. }
  401. sii8620_write(ctx, REG_DDC_ADDR, 0x50 << 1);
  402. edid = kmalloc(EDID_LENGTH, GFP_KERNEL);
  403. if (!edid) {
  404. ctx->error = -ENOMEM;
  405. return;
  406. }
  407. #define FETCH_SIZE 16
  408. for (fetched = 0; fetched < edid_len; fetched += FETCH_SIZE) {
  409. sii8620_readb(ctx, REG_DDC_STATUS);
  410. sii8620_write_seq(ctx,
  411. REG_DDC_CMD, ddc_cmd | VAL_DDC_CMD_DDC_CMD_ABORT,
  412. REG_DDC_CMD, ddc_cmd | VAL_DDC_CMD_DDC_CMD_CLEAR_FIFO,
  413. REG_DDC_STATUS, BIT_DDC_STATUS_DDC_FIFO_EMPTY
  414. );
  415. sii8620_write_seq(ctx,
  416. REG_DDC_SEGM, fetched >> 8,
  417. REG_DDC_OFFSET, fetched & 0xff,
  418. REG_DDC_DIN_CNT1, FETCH_SIZE,
  419. REG_DDC_DIN_CNT2, 0,
  420. REG_DDC_CMD, ddc_cmd | VAL_DDC_CMD_ENH_DDC_READ_NO_ACK
  421. );
  422. do {
  423. int3 = sii8620_readb(ctx, REG_INTR3);
  424. cbus = sii8620_readb(ctx, REG_CBUS_STATUS);
  425. if (int3 & BIT_DDC_CMD_DONE)
  426. break;
  427. if (!(cbus & BIT_CBUS_STATUS_CBUS_CONNECTED)) {
  428. kfree(edid);
  429. edid = NULL;
  430. goto end;
  431. }
  432. } while (1);
  433. sii8620_readb(ctx, REG_DDC_STATUS);
  434. while (sii8620_readb(ctx, REG_DDC_DOUT_CNT) < FETCH_SIZE)
  435. usleep_range(10, 20);
  436. sii8620_read_buf(ctx, REG_DDC_DATA, edid + fetched, FETCH_SIZE);
  437. if (fetched + FETCH_SIZE == EDID_LENGTH) {
  438. u8 ext = ((struct edid *)edid)->extensions;
  439. if (ext) {
  440. u8 *new_edid;
  441. edid_len += ext * EDID_LENGTH;
  442. new_edid = krealloc(edid, edid_len, GFP_KERNEL);
  443. if (!new_edid) {
  444. kfree(edid);
  445. ctx->error = -ENOMEM;
  446. return;
  447. }
  448. edid = new_edid;
  449. }
  450. }
  451. if (fetched + FETCH_SIZE == edid_len)
  452. sii8620_write(ctx, REG_INTR3, int3);
  453. }
  454. sii8620_write(ctx, REG_LM_DDC, lm_ddc);
  455. end:
  456. kfree(ctx->edid);
  457. ctx->edid = (struct edid *)edid;
  458. }
  459. static void sii8620_set_upstream_edid(struct sii8620 *ctx)
  460. {
  461. sii8620_setbits(ctx, REG_DPD, BIT_DPD_PDNRX12 | BIT_DPD_PDIDCK_N
  462. | BIT_DPD_PD_MHL_CLK_N, 0xff);
  463. sii8620_write_seq_static(ctx,
  464. REG_RX_HDMI_CTRL3, 0x00,
  465. REG_PKT_FILTER_0, 0xFF,
  466. REG_PKT_FILTER_1, 0xFF,
  467. REG_ALICE0_BW_I2C, 0x06
  468. );
  469. sii8620_setbits(ctx, REG_RX_HDMI_CLR_BUFFER,
  470. BIT_RX_HDMI_CLR_BUFFER_VSI_CLR_EN, 0xff);
  471. sii8620_write_seq_static(ctx,
  472. REG_EDID_CTRL, BIT_EDID_CTRL_EDID_FIFO_ADDR_AUTO
  473. | BIT_EDID_CTRL_EDID_MODE_EN,
  474. REG_EDID_FIFO_ADDR, 0,
  475. );
  476. sii8620_write_buf(ctx, REG_EDID_FIFO_WR_DATA, (u8 *)ctx->edid,
  477. (ctx->edid->extensions + 1) * EDID_LENGTH);
  478. sii8620_write_seq_static(ctx,
  479. REG_EDID_CTRL, BIT_EDID_CTRL_EDID_PRIME_VALID
  480. | BIT_EDID_CTRL_EDID_FIFO_ADDR_AUTO
  481. | BIT_EDID_CTRL_EDID_MODE_EN,
  482. REG_INTR5_MASK, BIT_INTR_SCDT_CHANGE,
  483. REG_INTR9_MASK, 0
  484. );
  485. }
  486. static void sii8620_xtal_set_rate(struct sii8620 *ctx)
  487. {
  488. static const struct {
  489. unsigned int rate;
  490. u8 div;
  491. u8 tp1;
  492. } rates[] = {
  493. { 19200, 0x04, 0x53 },
  494. { 20000, 0x04, 0x62 },
  495. { 24000, 0x05, 0x75 },
  496. { 30000, 0x06, 0x92 },
  497. { 38400, 0x0c, 0xbc },
  498. };
  499. unsigned long rate = clk_get_rate(ctx->clk_xtal) / 1000;
  500. int i;
  501. for (i = 0; i < ARRAY_SIZE(rates) - 1; ++i)
  502. if (rate <= rates[i].rate)
  503. break;
  504. if (rate != rates[i].rate)
  505. dev_err(ctx->dev, "xtal clock rate(%lukHz) not supported, setting MHL for %ukHz.\n",
  506. rate, rates[i].rate);
  507. sii8620_write(ctx, REG_DIV_CTL_MAIN, rates[i].div);
  508. sii8620_write(ctx, REG_HDCP2X_TP1, rates[i].tp1);
  509. }
  510. static int sii8620_hw_on(struct sii8620 *ctx)
  511. {
  512. int ret;
  513. ret = regulator_bulk_enable(ARRAY_SIZE(ctx->supplies), ctx->supplies);
  514. if (ret)
  515. return ret;
  516. usleep_range(10000, 20000);
  517. return clk_prepare_enable(ctx->clk_xtal);
  518. }
  519. static int sii8620_hw_off(struct sii8620 *ctx)
  520. {
  521. clk_disable_unprepare(ctx->clk_xtal);
  522. gpiod_set_value(ctx->gpio_reset, 1);
  523. return regulator_bulk_disable(ARRAY_SIZE(ctx->supplies), ctx->supplies);
  524. }
  525. static void sii8620_hw_reset(struct sii8620 *ctx)
  526. {
  527. usleep_range(10000, 20000);
  528. gpiod_set_value(ctx->gpio_reset, 0);
  529. usleep_range(5000, 20000);
  530. gpiod_set_value(ctx->gpio_reset, 1);
  531. usleep_range(10000, 20000);
  532. gpiod_set_value(ctx->gpio_reset, 0);
  533. msleep(300);
  534. }
  535. static void sii8620_cbus_reset(struct sii8620 *ctx)
  536. {
  537. sii8620_write_seq_static(ctx,
  538. REG_PWD_SRST, BIT_PWD_SRST_CBUS_RST
  539. | BIT_PWD_SRST_CBUS_RST_SW_EN,
  540. REG_PWD_SRST, BIT_PWD_SRST_CBUS_RST_SW_EN
  541. );
  542. }
  543. static void sii8620_set_auto_zone(struct sii8620 *ctx)
  544. {
  545. if (ctx->mode != CM_MHL1) {
  546. sii8620_write_seq_static(ctx,
  547. REG_TX_ZONE_CTL1, 0x0,
  548. REG_MHL_PLL_CTL0, VAL_MHL_PLL_CTL0_HDMI_CLK_RATIO_1X
  549. | BIT_MHL_PLL_CTL0_CRYSTAL_CLK_SEL
  550. | BIT_MHL_PLL_CTL0_ZONE_MASK_OE
  551. );
  552. } else {
  553. sii8620_write_seq_static(ctx,
  554. REG_TX_ZONE_CTL1, VAL_TX_ZONE_CTL1_TX_ZONE_CTRL_MODE,
  555. REG_MHL_PLL_CTL0, VAL_MHL_PLL_CTL0_HDMI_CLK_RATIO_1X
  556. | BIT_MHL_PLL_CTL0_ZONE_MASK_OE
  557. );
  558. }
  559. }
  560. static void sii8620_stop_video(struct sii8620 *ctx)
  561. {
  562. u8 uninitialized_var(val);
  563. sii8620_write_seq_static(ctx,
  564. REG_TPI_INTR_EN, 0,
  565. REG_HDCP2X_INTR0_MASK, 0,
  566. REG_TPI_COPP_DATA2, 0,
  567. REG_TPI_INTR_ST0, ~0,
  568. );
  569. switch (ctx->sink_type) {
  570. case SINK_DVI:
  571. val = BIT_TPI_SC_REG_TMDS_OE_POWER_DOWN
  572. | BIT_TPI_SC_TPI_AV_MUTE;
  573. break;
  574. case SINK_HDMI:
  575. val = BIT_TPI_SC_REG_TMDS_OE_POWER_DOWN
  576. | BIT_TPI_SC_TPI_AV_MUTE
  577. | BIT_TPI_SC_TPI_OUTPUT_MODE_0_HDMI;
  578. break;
  579. default:
  580. return;
  581. }
  582. sii8620_write(ctx, REG_TPI_SC, val);
  583. }
  584. static void sii8620_start_hdmi(struct sii8620 *ctx)
  585. {
  586. sii8620_write_seq_static(ctx,
  587. REG_RX_HDMI_CTRL2, VAL_RX_HDMI_CTRL2_DEFVAL
  588. | BIT_RX_HDMI_CTRL2_USE_AV_MUTE,
  589. REG_VID_OVRRD, BIT_VID_OVRRD_PP_AUTO_DISABLE
  590. | BIT_VID_OVRRD_M1080P_OVRRD,
  591. REG_VID_MODE, 0,
  592. REG_MHL_TOP_CTL, 0x1,
  593. REG_MHLTX_CTL6, 0xa0,
  594. REG_TPI_INPUT, VAL_TPI_FORMAT(RGB, FULL),
  595. REG_TPI_OUTPUT, VAL_TPI_FORMAT(RGB, FULL),
  596. );
  597. sii8620_mt_write_stat(ctx, MHL_DST_REG(LINK_MODE),
  598. MHL_DST_LM_CLK_MODE_NORMAL |
  599. MHL_DST_LM_PATH_ENABLED);
  600. sii8620_set_auto_zone(ctx);
  601. sii8620_write(ctx, REG_TPI_SC, BIT_TPI_SC_TPI_OUTPUT_MODE_0_HDMI);
  602. sii8620_write_buf(ctx, REG_TPI_AVI_CHSUM, ctx->avif,
  603. ARRAY_SIZE(ctx->avif));
  604. sii8620_write(ctx, REG_PKT_FILTER_0, 0xa1, 0x2);
  605. }
  606. static void sii8620_start_video(struct sii8620 *ctx)
  607. {
  608. if (ctx->mode < CM_MHL3)
  609. sii8620_stop_video(ctx);
  610. switch (ctx->sink_type) {
  611. case SINK_HDMI:
  612. sii8620_start_hdmi(ctx);
  613. break;
  614. case SINK_DVI:
  615. default:
  616. break;
  617. }
  618. }
  619. static void sii8620_disable_hpd(struct sii8620 *ctx)
  620. {
  621. sii8620_setbits(ctx, REG_EDID_CTRL, BIT_EDID_CTRL_EDID_PRIME_VALID, 0);
  622. sii8620_write_seq_static(ctx,
  623. REG_HPD_CTRL, BIT_HPD_CTRL_HPD_OUT_OVR_EN,
  624. REG_INTR8_MASK, 0
  625. );
  626. }
  627. static void sii8620_enable_hpd(struct sii8620 *ctx)
  628. {
  629. sii8620_setbits(ctx, REG_TMDS_CSTAT_P3,
  630. BIT_TMDS_CSTAT_P3_SCDT_CLR_AVI_DIS
  631. | BIT_TMDS_CSTAT_P3_CLR_AVI, ~0);
  632. sii8620_write_seq_static(ctx,
  633. REG_HPD_CTRL, BIT_HPD_CTRL_HPD_OUT_OVR_EN
  634. | BIT_HPD_CTRL_HPD_HIGH,
  635. );
  636. }
  637. static void sii8620_enable_gen2_write_burst(struct sii8620 *ctx)
  638. {
  639. if (ctx->gen2_write_burst)
  640. return;
  641. sii8620_write_seq_static(ctx,
  642. REG_MDT_RCV_TIMEOUT, 100,
  643. REG_MDT_RCV_CTRL, BIT_MDT_RCV_CTRL_MDT_RCV_EN
  644. );
  645. ctx->gen2_write_burst = 1;
  646. }
  647. static void sii8620_disable_gen2_write_burst(struct sii8620 *ctx)
  648. {
  649. if (!ctx->gen2_write_burst)
  650. return;
  651. sii8620_write_seq_static(ctx,
  652. REG_MDT_XMIT_CTRL, 0,
  653. REG_MDT_RCV_CTRL, 0
  654. );
  655. ctx->gen2_write_burst = 0;
  656. }
  657. static void sii8620_start_gen2_write_burst(struct sii8620 *ctx)
  658. {
  659. sii8620_write_seq_static(ctx,
  660. REG_MDT_INT_1_MASK, BIT_MDT_RCV_TIMEOUT
  661. | BIT_MDT_RCV_SM_ABORT_PKT_RCVD | BIT_MDT_RCV_SM_ERROR
  662. | BIT_MDT_XMIT_TIMEOUT | BIT_MDT_XMIT_SM_ABORT_PKT_RCVD
  663. | BIT_MDT_XMIT_SM_ERROR,
  664. REG_MDT_INT_0_MASK, BIT_MDT_XFIFO_EMPTY
  665. | BIT_MDT_IDLE_AFTER_HAWB_DISABLE
  666. | BIT_MDT_RFIFO_DATA_RDY
  667. );
  668. sii8620_enable_gen2_write_burst(ctx);
  669. }
  670. static void sii8620_mhl_discover(struct sii8620 *ctx)
  671. {
  672. sii8620_write_seq_static(ctx,
  673. REG_DISC_CTRL9, BIT_DISC_CTRL9_WAKE_DRVFLT
  674. | BIT_DISC_CTRL9_DISC_PULSE_PROCEED,
  675. REG_DISC_CTRL4, VAL_DISC_CTRL4(VAL_PUP_5K, VAL_PUP_20K),
  676. REG_CBUS_DISC_INTR0_MASK, BIT_MHL3_EST_INT
  677. | BIT_MHL_EST_INT
  678. | BIT_NOT_MHL_EST_INT
  679. | BIT_CBUS_MHL3_DISCON_INT
  680. | BIT_CBUS_MHL12_DISCON_INT
  681. | BIT_RGND_READY_INT,
  682. REG_MHL_PLL_CTL0, VAL_MHL_PLL_CTL0_HDMI_CLK_RATIO_1X
  683. | BIT_MHL_PLL_CTL0_CRYSTAL_CLK_SEL
  684. | BIT_MHL_PLL_CTL0_ZONE_MASK_OE,
  685. REG_MHL_DP_CTL0, BIT_MHL_DP_CTL0_DP_OE
  686. | BIT_MHL_DP_CTL0_TX_OE_OVR,
  687. REG_M3_CTRL, VAL_M3_CTRL_MHL3_VALUE,
  688. REG_MHL_DP_CTL1, 0xA2,
  689. REG_MHL_DP_CTL2, 0x03,
  690. REG_MHL_DP_CTL3, 0x35,
  691. REG_MHL_DP_CTL5, 0x02,
  692. REG_MHL_DP_CTL6, 0x02,
  693. REG_MHL_DP_CTL7, 0x03,
  694. REG_COC_CTLC, 0xFF,
  695. REG_DPD, BIT_DPD_PWRON_PLL | BIT_DPD_PDNTX12
  696. | BIT_DPD_OSC_EN | BIT_DPD_PWRON_HSIC,
  697. REG_COC_INTR_MASK, BIT_COC_PLL_LOCK_STATUS_CHANGE
  698. | BIT_COC_CALIBRATION_DONE,
  699. REG_CBUS_INT_1_MASK, BIT_CBUS_MSC_ABORT_RCVD
  700. | BIT_CBUS_CMD_ABORT,
  701. REG_CBUS_INT_0_MASK, BIT_CBUS_MSC_MT_DONE
  702. | BIT_CBUS_HPD_CHG
  703. | BIT_CBUS_MSC_MR_WRITE_STAT
  704. | BIT_CBUS_MSC_MR_MSC_MSG
  705. | BIT_CBUS_MSC_MR_WRITE_BURST
  706. | BIT_CBUS_MSC_MR_SET_INT
  707. | BIT_CBUS_MSC_MT_DONE_NACK
  708. );
  709. }
  710. static void sii8620_peer_specific_init(struct sii8620 *ctx)
  711. {
  712. if (ctx->mode == CM_MHL3)
  713. sii8620_write_seq_static(ctx,
  714. REG_SYS_CTRL1, BIT_SYS_CTRL1_BLOCK_DDC_BY_HPD,
  715. REG_EMSCINTRMASK1,
  716. BIT_EMSCINTR1_EMSC_TRAINING_COMMA_ERR
  717. );
  718. else
  719. sii8620_write_seq_static(ctx,
  720. REG_HDCP2X_INTR0_MASK, 0x00,
  721. REG_EMSCINTRMASK1, 0x00,
  722. REG_HDCP2X_INTR0, 0xFF,
  723. REG_INTR1, 0xFF,
  724. REG_SYS_CTRL1, BIT_SYS_CTRL1_BLOCK_DDC_BY_HPD
  725. | BIT_SYS_CTRL1_TX_CTRL_HDMI
  726. );
  727. }
  728. #define SII8620_MHL_VERSION 0x32
  729. #define SII8620_SCRATCHPAD_SIZE 16
  730. #define SII8620_INT_STAT_SIZE 0x33
  731. static void sii8620_set_dev_cap(struct sii8620 *ctx)
  732. {
  733. static const u8 devcap[MHL_DCAP_SIZE] = {
  734. [MHL_DCAP_MHL_VERSION] = SII8620_MHL_VERSION,
  735. [MHL_DCAP_CAT] = MHL_DCAP_CAT_SOURCE | MHL_DCAP_CAT_POWER,
  736. [MHL_DCAP_ADOPTER_ID_H] = 0x01,
  737. [MHL_DCAP_ADOPTER_ID_L] = 0x41,
  738. [MHL_DCAP_VID_LINK_MODE] = MHL_DCAP_VID_LINK_RGB444
  739. | MHL_DCAP_VID_LINK_PPIXEL
  740. | MHL_DCAP_VID_LINK_16BPP,
  741. [MHL_DCAP_AUD_LINK_MODE] = MHL_DCAP_AUD_LINK_2CH,
  742. [MHL_DCAP_VIDEO_TYPE] = MHL_DCAP_VT_GRAPHICS,
  743. [MHL_DCAP_LOG_DEV_MAP] = MHL_DCAP_LD_GUI,
  744. [MHL_DCAP_BANDWIDTH] = 0x0f,
  745. [MHL_DCAP_FEATURE_FLAG] = MHL_DCAP_FEATURE_RCP_SUPPORT
  746. | MHL_DCAP_FEATURE_RAP_SUPPORT
  747. | MHL_DCAP_FEATURE_SP_SUPPORT,
  748. [MHL_DCAP_SCRATCHPAD_SIZE] = SII8620_SCRATCHPAD_SIZE,
  749. [MHL_DCAP_INT_STAT_SIZE] = SII8620_INT_STAT_SIZE,
  750. };
  751. static const u8 xdcap[MHL_XDC_SIZE] = {
  752. [MHL_XDC_ECBUS_SPEEDS] = MHL_XDC_ECBUS_S_075
  753. | MHL_XDC_ECBUS_S_8BIT,
  754. [MHL_XDC_TMDS_SPEEDS] = MHL_XDC_TMDS_150
  755. | MHL_XDC_TMDS_300 | MHL_XDC_TMDS_600,
  756. [MHL_XDC_ECBUS_ROLES] = MHL_XDC_DEV_HOST,
  757. [MHL_XDC_LOG_DEV_MAPX] = MHL_XDC_LD_PHONE,
  758. };
  759. sii8620_write_buf(ctx, REG_MHL_DEVCAP_0, devcap, ARRAY_SIZE(devcap));
  760. sii8620_write_buf(ctx, REG_MHL_EXTDEVCAP_0, xdcap, ARRAY_SIZE(xdcap));
  761. }
  762. static void sii8620_mhl_init(struct sii8620 *ctx)
  763. {
  764. sii8620_write_seq_static(ctx,
  765. REG_DISC_CTRL4, VAL_DISC_CTRL4(VAL_PUP_OFF, VAL_PUP_20K),
  766. REG_CBUS_MSC_COMPAT_CTRL,
  767. BIT_CBUS_MSC_COMPAT_CTRL_XDEVCAP_EN,
  768. );
  769. sii8620_peer_specific_init(ctx);
  770. sii8620_disable_hpd(ctx);
  771. sii8620_write_seq_static(ctx,
  772. REG_EDID_CTRL, BIT_EDID_CTRL_EDID_FIFO_ADDR_AUTO,
  773. REG_DISC_CTRL9, BIT_DISC_CTRL9_WAKE_DRVFLT
  774. | BIT_DISC_CTRL9_WAKE_PULSE_BYPASS,
  775. REG_TMDS0_CCTRL1, 0x90,
  776. REG_TMDS_CLK_EN, 0x01,
  777. REG_TMDS_CH_EN, 0x11,
  778. REG_BGR_BIAS, 0x87,
  779. REG_ALICE0_ZONE_CTRL, 0xE8,
  780. REG_ALICE0_MODE_CTRL, 0x04,
  781. );
  782. sii8620_setbits(ctx, REG_LM_DDC, BIT_LM_DDC_SW_TPI_EN_DISABLED, 0);
  783. sii8620_write_seq_static(ctx,
  784. REG_TPI_HW_OPT3, 0x76,
  785. REG_TMDS_CCTRL, BIT_TMDS_CCTRL_TMDS_OE,
  786. REG_TPI_DTD_B2, 79,
  787. );
  788. sii8620_set_dev_cap(ctx);
  789. sii8620_write_seq_static(ctx,
  790. REG_MDT_XMIT_TIMEOUT, 100,
  791. REG_MDT_XMIT_CTRL, 0x03,
  792. REG_MDT_XFIFO_STAT, 0x00,
  793. REG_MDT_RCV_TIMEOUT, 100,
  794. REG_CBUS_LINK_CTRL_8, 0x1D,
  795. );
  796. sii8620_start_gen2_write_burst(ctx);
  797. sii8620_write_seq_static(ctx,
  798. REG_BIST_CTRL, 0x00,
  799. REG_COC_CTL1, 0x10,
  800. REG_COC_CTL2, 0x18,
  801. REG_COC_CTLF, 0x07,
  802. REG_COC_CTL11, 0xF8,
  803. REG_COC_CTL17, 0x61,
  804. REG_COC_CTL18, 0x46,
  805. REG_COC_CTL19, 0x15,
  806. REG_COC_CTL1A, 0x01,
  807. REG_MHL_COC_CTL3, BIT_MHL_COC_CTL3_COC_AECHO_EN,
  808. REG_MHL_COC_CTL4, 0x2D,
  809. REG_MHL_COC_CTL5, 0xF9,
  810. REG_MSC_HEARTBEAT_CTRL, 0x27,
  811. );
  812. sii8620_disable_gen2_write_burst(ctx);
  813. /* currently MHL3 is not supported, so we force version to 0 */
  814. sii8620_mt_write_stat(ctx, MHL_DST_REG(VERSION), 0);
  815. sii8620_mt_write_stat(ctx, MHL_DST_REG(CONNECTED_RDY),
  816. MHL_DST_CONN_DCAP_RDY | MHL_DST_CONN_XDEVCAPP_SUPP
  817. | MHL_DST_CONN_POW_STAT);
  818. sii8620_mt_set_int(ctx, MHL_INT_REG(RCHANGE), MHL_INT_RC_DCAP_CHG);
  819. }
  820. static void sii8620_set_mode(struct sii8620 *ctx, enum sii8620_mode mode)
  821. {
  822. if (ctx->mode == mode)
  823. return;
  824. ctx->mode = mode;
  825. switch (mode) {
  826. case CM_MHL1:
  827. sii8620_write_seq_static(ctx,
  828. REG_CBUS_MSC_COMPAT_CTRL, 0x02,
  829. REG_M3_CTRL, VAL_M3_CTRL_MHL1_2_VALUE,
  830. REG_DPD, BIT_DPD_PWRON_PLL | BIT_DPD_PDNTX12
  831. | BIT_DPD_OSC_EN,
  832. REG_COC_INTR_MASK, 0
  833. );
  834. break;
  835. case CM_MHL3:
  836. sii8620_write_seq_static(ctx,
  837. REG_M3_CTRL, VAL_M3_CTRL_MHL3_VALUE,
  838. REG_COC_CTL0, 0x40,
  839. REG_MHL_COC_CTL1, 0x07
  840. );
  841. break;
  842. case CM_DISCONNECTED:
  843. break;
  844. default:
  845. dev_err(ctx->dev, "%s mode %d not supported\n", __func__, mode);
  846. break;
  847. }
  848. sii8620_set_auto_zone(ctx);
  849. if (mode != CM_MHL1)
  850. return;
  851. sii8620_write_seq_static(ctx,
  852. REG_MHL_DP_CTL0, 0xBC,
  853. REG_MHL_DP_CTL1, 0xBB,
  854. REG_MHL_DP_CTL3, 0x48,
  855. REG_MHL_DP_CTL5, 0x39,
  856. REG_MHL_DP_CTL2, 0x2A,
  857. REG_MHL_DP_CTL6, 0x2A,
  858. REG_MHL_DP_CTL7, 0x08
  859. );
  860. }
  861. static void sii8620_disconnect(struct sii8620 *ctx)
  862. {
  863. sii8620_disable_gen2_write_burst(ctx);
  864. sii8620_stop_video(ctx);
  865. msleep(50);
  866. sii8620_cbus_reset(ctx);
  867. sii8620_set_mode(ctx, CM_DISCONNECTED);
  868. sii8620_write_seq_static(ctx,
  869. REG_COC_CTL0, 0x40,
  870. REG_CBUS3_CNVT, 0x84,
  871. REG_COC_CTL14, 0x00,
  872. REG_COC_CTL0, 0x40,
  873. REG_HRXCTRL3, 0x07,
  874. REG_MHL_PLL_CTL0, VAL_MHL_PLL_CTL0_HDMI_CLK_RATIO_1X
  875. | BIT_MHL_PLL_CTL0_CRYSTAL_CLK_SEL
  876. | BIT_MHL_PLL_CTL0_ZONE_MASK_OE,
  877. REG_MHL_DP_CTL0, BIT_MHL_DP_CTL0_DP_OE
  878. | BIT_MHL_DP_CTL0_TX_OE_OVR,
  879. REG_MHL_DP_CTL1, 0xBB,
  880. REG_MHL_DP_CTL3, 0x48,
  881. REG_MHL_DP_CTL5, 0x3F,
  882. REG_MHL_DP_CTL2, 0x2F,
  883. REG_MHL_DP_CTL6, 0x2A,
  884. REG_MHL_DP_CTL7, 0x03
  885. );
  886. sii8620_disable_hpd(ctx);
  887. sii8620_write_seq_static(ctx,
  888. REG_M3_CTRL, VAL_M3_CTRL_MHL3_VALUE,
  889. REG_MHL_COC_CTL1, 0x07,
  890. REG_DISC_CTRL4, VAL_DISC_CTRL4(VAL_PUP_OFF, VAL_PUP_20K),
  891. REG_DISC_CTRL8, 0x00,
  892. REG_DISC_CTRL9, BIT_DISC_CTRL9_WAKE_DRVFLT
  893. | BIT_DISC_CTRL9_WAKE_PULSE_BYPASS,
  894. REG_INT_CTRL, 0x00,
  895. REG_MSC_HEARTBEAT_CTRL, 0x27,
  896. REG_DISC_CTRL1, 0x25,
  897. REG_CBUS_DISC_INTR0, (u8)~BIT_RGND_READY_INT,
  898. REG_CBUS_DISC_INTR0_MASK, BIT_RGND_READY_INT,
  899. REG_MDT_INT_1, 0xff,
  900. REG_MDT_INT_1_MASK, 0x00,
  901. REG_MDT_INT_0, 0xff,
  902. REG_MDT_INT_0_MASK, 0x00,
  903. REG_COC_INTR, 0xff,
  904. REG_COC_INTR_MASK, 0x00,
  905. REG_TRXINTH, 0xff,
  906. REG_TRXINTMH, 0x00,
  907. REG_CBUS_INT_0, 0xff,
  908. REG_CBUS_INT_0_MASK, 0x00,
  909. REG_CBUS_INT_1, 0xff,
  910. REG_CBUS_INT_1_MASK, 0x00,
  911. REG_EMSCINTR, 0xff,
  912. REG_EMSCINTRMASK, 0x00,
  913. REG_EMSCINTR1, 0xff,
  914. REG_EMSCINTRMASK1, 0x00,
  915. REG_INTR8, 0xff,
  916. REG_INTR8_MASK, 0x00,
  917. REG_TPI_INTR_ST0, 0xff,
  918. REG_TPI_INTR_EN, 0x00,
  919. REG_HDCP2X_INTR0, 0xff,
  920. REG_HDCP2X_INTR0_MASK, 0x00,
  921. REG_INTR9, 0xff,
  922. REG_INTR9_MASK, 0x00,
  923. REG_INTR3, 0xff,
  924. REG_INTR3_MASK, 0x00,
  925. REG_INTR5, 0xff,
  926. REG_INTR5_MASK, 0x00,
  927. REG_INTR2, 0xff,
  928. REG_INTR2_MASK, 0x00,
  929. );
  930. memset(ctx->stat, 0, sizeof(ctx->stat));
  931. memset(ctx->xstat, 0, sizeof(ctx->xstat));
  932. memset(ctx->devcap, 0, sizeof(ctx->devcap));
  933. memset(ctx->xdevcap, 0, sizeof(ctx->xdevcap));
  934. ctx->cbus_status = 0;
  935. ctx->sink_type = SINK_NONE;
  936. kfree(ctx->edid);
  937. ctx->edid = NULL;
  938. sii8620_mt_cleanup(ctx);
  939. }
  940. static void sii8620_mhl_disconnected(struct sii8620 *ctx)
  941. {
  942. sii8620_write_seq_static(ctx,
  943. REG_DISC_CTRL4, VAL_DISC_CTRL4(VAL_PUP_OFF, VAL_PUP_20K),
  944. REG_CBUS_MSC_COMPAT_CTRL,
  945. BIT_CBUS_MSC_COMPAT_CTRL_XDEVCAP_EN
  946. );
  947. sii8620_disconnect(ctx);
  948. }
  949. static void sii8620_irq_disc(struct sii8620 *ctx)
  950. {
  951. u8 stat = sii8620_readb(ctx, REG_CBUS_DISC_INTR0);
  952. if (stat & VAL_CBUS_MHL_DISCON)
  953. sii8620_mhl_disconnected(ctx);
  954. if (stat & BIT_RGND_READY_INT) {
  955. u8 stat2 = sii8620_readb(ctx, REG_DISC_STAT2);
  956. if ((stat2 & MSK_DISC_STAT2_RGND) == VAL_RGND_1K) {
  957. sii8620_mhl_discover(ctx);
  958. } else {
  959. sii8620_write_seq_static(ctx,
  960. REG_DISC_CTRL9, BIT_DISC_CTRL9_WAKE_DRVFLT
  961. | BIT_DISC_CTRL9_NOMHL_EST
  962. | BIT_DISC_CTRL9_WAKE_PULSE_BYPASS,
  963. REG_CBUS_DISC_INTR0_MASK, BIT_RGND_READY_INT
  964. | BIT_CBUS_MHL3_DISCON_INT
  965. | BIT_CBUS_MHL12_DISCON_INT
  966. | BIT_NOT_MHL_EST_INT
  967. );
  968. }
  969. }
  970. if (stat & BIT_MHL_EST_INT)
  971. sii8620_mhl_init(ctx);
  972. sii8620_write(ctx, REG_CBUS_DISC_INTR0, stat);
  973. }
  974. static void sii8620_irq_g2wb(struct sii8620 *ctx)
  975. {
  976. u8 stat = sii8620_readb(ctx, REG_MDT_INT_0);
  977. if (stat & BIT_MDT_IDLE_AFTER_HAWB_DISABLE)
  978. dev_dbg(ctx->dev, "HAWB idle\n");
  979. sii8620_write(ctx, REG_MDT_INT_0, stat);
  980. }
  981. static void sii8620_status_changed_dcap(struct sii8620 *ctx)
  982. {
  983. if (ctx->stat[MHL_DST_CONNECTED_RDY] & MHL_DST_CONN_DCAP_RDY) {
  984. sii8620_set_mode(ctx, CM_MHL1);
  985. sii8620_peer_specific_init(ctx);
  986. sii8620_write(ctx, REG_INTR9_MASK, BIT_INTR9_DEVCAP_DONE
  987. | BIT_INTR9_EDID_DONE | BIT_INTR9_EDID_ERROR);
  988. }
  989. }
  990. static void sii8620_status_changed_path(struct sii8620 *ctx)
  991. {
  992. if (ctx->stat[MHL_DST_LINK_MODE] & MHL_DST_LM_PATH_ENABLED) {
  993. sii8620_mt_write_stat(ctx, MHL_DST_REG(LINK_MODE),
  994. MHL_DST_LM_CLK_MODE_NORMAL
  995. | MHL_DST_LM_PATH_ENABLED);
  996. sii8620_mt_read_devcap(ctx, false);
  997. } else {
  998. sii8620_mt_write_stat(ctx, MHL_DST_REG(LINK_MODE),
  999. MHL_DST_LM_CLK_MODE_NORMAL);
  1000. }
  1001. }
  1002. static void sii8620_msc_mr_write_stat(struct sii8620 *ctx)
  1003. {
  1004. u8 st[MHL_DST_SIZE], xst[MHL_XDS_SIZE];
  1005. sii8620_read_buf(ctx, REG_MHL_STAT_0, st, MHL_DST_SIZE);
  1006. sii8620_read_buf(ctx, REG_MHL_EXTSTAT_0, xst, MHL_XDS_SIZE);
  1007. sii8620_update_array(ctx->stat, st, MHL_DST_SIZE);
  1008. sii8620_update_array(ctx->xstat, xst, MHL_XDS_SIZE);
  1009. if (st[MHL_DST_CONNECTED_RDY] & MHL_DST_CONN_DCAP_RDY)
  1010. sii8620_status_changed_dcap(ctx);
  1011. if (st[MHL_DST_LINK_MODE] & MHL_DST_LM_PATH_ENABLED)
  1012. sii8620_status_changed_path(ctx);
  1013. }
  1014. static void sii8620_msc_mr_set_int(struct sii8620 *ctx)
  1015. {
  1016. u8 ints[MHL_INT_SIZE];
  1017. sii8620_read_buf(ctx, REG_MHL_INT_0, ints, MHL_INT_SIZE);
  1018. sii8620_write_buf(ctx, REG_MHL_INT_0, ints, MHL_INT_SIZE);
  1019. }
  1020. static struct sii8620_mt_msg *sii8620_msc_msg_first(struct sii8620 *ctx)
  1021. {
  1022. struct device *dev = ctx->dev;
  1023. if (list_empty(&ctx->mt_queue)) {
  1024. dev_err(dev, "unexpected MSC MT response\n");
  1025. return NULL;
  1026. }
  1027. return list_first_entry(&ctx->mt_queue, struct sii8620_mt_msg, node);
  1028. }
  1029. static void sii8620_msc_mt_done(struct sii8620 *ctx)
  1030. {
  1031. struct sii8620_mt_msg *msg = sii8620_msc_msg_first(ctx);
  1032. if (!msg)
  1033. return;
  1034. msg->ret = sii8620_readb(ctx, REG_MSC_MT_RCVD_DATA0);
  1035. ctx->mt_state = MT_STATE_DONE;
  1036. }
  1037. static void sii8620_msc_mr_msc_msg(struct sii8620 *ctx)
  1038. {
  1039. struct sii8620_mt_msg *msg = sii8620_msc_msg_first(ctx);
  1040. u8 buf[2];
  1041. if (!msg)
  1042. return;
  1043. sii8620_read_buf(ctx, REG_MSC_MR_MSC_MSG_RCVD_1ST_DATA, buf, 2);
  1044. switch (buf[0]) {
  1045. case MHL_MSC_MSG_RAPK:
  1046. msg->ret = buf[1];
  1047. ctx->mt_state = MT_STATE_DONE;
  1048. break;
  1049. default:
  1050. dev_err(ctx->dev, "%s message type %d,%d not supported",
  1051. __func__, buf[0], buf[1]);
  1052. }
  1053. }
  1054. static void sii8620_irq_msc(struct sii8620 *ctx)
  1055. {
  1056. u8 stat = sii8620_readb(ctx, REG_CBUS_INT_0);
  1057. if (stat & ~BIT_CBUS_HPD_CHG)
  1058. sii8620_write(ctx, REG_CBUS_INT_0, stat & ~BIT_CBUS_HPD_CHG);
  1059. if (stat & BIT_CBUS_HPD_CHG) {
  1060. u8 cbus_stat = sii8620_readb(ctx, REG_CBUS_STATUS);
  1061. if ((cbus_stat ^ ctx->cbus_status) & BIT_CBUS_STATUS_CBUS_HPD) {
  1062. sii8620_write(ctx, REG_CBUS_INT_0, BIT_CBUS_HPD_CHG);
  1063. } else {
  1064. stat ^= BIT_CBUS_STATUS_CBUS_HPD;
  1065. cbus_stat ^= BIT_CBUS_STATUS_CBUS_HPD;
  1066. }
  1067. ctx->cbus_status = cbus_stat;
  1068. }
  1069. if (stat & BIT_CBUS_MSC_MR_WRITE_STAT)
  1070. sii8620_msc_mr_write_stat(ctx);
  1071. if (stat & BIT_CBUS_MSC_MR_SET_INT)
  1072. sii8620_msc_mr_set_int(ctx);
  1073. if (stat & BIT_CBUS_MSC_MT_DONE)
  1074. sii8620_msc_mt_done(ctx);
  1075. if (stat & BIT_CBUS_MSC_MR_MSC_MSG)
  1076. sii8620_msc_mr_msc_msg(ctx);
  1077. }
  1078. static void sii8620_irq_coc(struct sii8620 *ctx)
  1079. {
  1080. u8 stat = sii8620_readb(ctx, REG_COC_INTR);
  1081. sii8620_write(ctx, REG_COC_INTR, stat);
  1082. }
  1083. static void sii8620_irq_merr(struct sii8620 *ctx)
  1084. {
  1085. u8 stat = sii8620_readb(ctx, REG_CBUS_INT_1);
  1086. sii8620_write(ctx, REG_CBUS_INT_1, stat);
  1087. }
  1088. static void sii8620_irq_edid(struct sii8620 *ctx)
  1089. {
  1090. u8 stat = sii8620_readb(ctx, REG_INTR9);
  1091. sii8620_write(ctx, REG_INTR9, stat);
  1092. if (stat & BIT_INTR9_DEVCAP_DONE)
  1093. ctx->mt_state = MT_STATE_DONE;
  1094. }
  1095. static void sii8620_scdt_high(struct sii8620 *ctx)
  1096. {
  1097. sii8620_write_seq_static(ctx,
  1098. REG_INTR8_MASK, BIT_CEA_NEW_AVI | BIT_CEA_NEW_VSI,
  1099. REG_TPI_SC, BIT_TPI_SC_TPI_OUTPUT_MODE_0_HDMI,
  1100. );
  1101. }
  1102. static void sii8620_scdt_low(struct sii8620 *ctx)
  1103. {
  1104. sii8620_write(ctx, REG_TMDS_CSTAT_P3,
  1105. BIT_TMDS_CSTAT_P3_SCDT_CLR_AVI_DIS |
  1106. BIT_TMDS_CSTAT_P3_CLR_AVI);
  1107. sii8620_stop_video(ctx);
  1108. sii8620_write(ctx, REG_INTR8_MASK, 0);
  1109. }
  1110. static void sii8620_irq_scdt(struct sii8620 *ctx)
  1111. {
  1112. u8 stat = sii8620_readb(ctx, REG_INTR5);
  1113. if (stat & BIT_INTR_SCDT_CHANGE) {
  1114. u8 cstat = sii8620_readb(ctx, REG_TMDS_CSTAT_P3);
  1115. if (cstat & BIT_TMDS_CSTAT_P3_SCDT)
  1116. sii8620_scdt_high(ctx);
  1117. else
  1118. sii8620_scdt_low(ctx);
  1119. }
  1120. sii8620_write(ctx, REG_INTR5, stat);
  1121. }
  1122. static void sii8620_new_vsi(struct sii8620 *ctx)
  1123. {
  1124. u8 vsif[11];
  1125. sii8620_write(ctx, REG_RX_HDMI_CTRL2,
  1126. VAL_RX_HDMI_CTRL2_DEFVAL |
  1127. BIT_RX_HDMI_CTRL2_VSI_MON_SEL_VSI);
  1128. sii8620_read_buf(ctx, REG_RX_HDMI_MON_PKT_HEADER1, vsif,
  1129. ARRAY_SIZE(vsif));
  1130. }
  1131. static void sii8620_new_avi(struct sii8620 *ctx)
  1132. {
  1133. sii8620_write(ctx, REG_RX_HDMI_CTRL2, VAL_RX_HDMI_CTRL2_DEFVAL);
  1134. sii8620_read_buf(ctx, REG_RX_HDMI_MON_PKT_HEADER1, ctx->avif,
  1135. ARRAY_SIZE(ctx->avif));
  1136. }
  1137. static void sii8620_irq_infr(struct sii8620 *ctx)
  1138. {
  1139. u8 stat = sii8620_readb(ctx, REG_INTR8)
  1140. & (BIT_CEA_NEW_VSI | BIT_CEA_NEW_AVI);
  1141. sii8620_write(ctx, REG_INTR8, stat);
  1142. if (stat & BIT_CEA_NEW_VSI)
  1143. sii8620_new_vsi(ctx);
  1144. if (stat & BIT_CEA_NEW_AVI)
  1145. sii8620_new_avi(ctx);
  1146. if (stat & (BIT_CEA_NEW_VSI | BIT_CEA_NEW_AVI))
  1147. sii8620_start_video(ctx);
  1148. }
  1149. /* endian agnostic, non-volatile version of test_bit */
  1150. static bool sii8620_test_bit(unsigned int nr, const u8 *addr)
  1151. {
  1152. return 1 & (addr[nr / BITS_PER_BYTE] >> (nr % BITS_PER_BYTE));
  1153. }
  1154. static irqreturn_t sii8620_irq_thread(int irq, void *data)
  1155. {
  1156. static const struct {
  1157. int bit;
  1158. void (*handler)(struct sii8620 *ctx);
  1159. } irq_vec[] = {
  1160. { BIT_FAST_INTR_STAT_DISC, sii8620_irq_disc },
  1161. { BIT_FAST_INTR_STAT_G2WB, sii8620_irq_g2wb },
  1162. { BIT_FAST_INTR_STAT_COC, sii8620_irq_coc },
  1163. { BIT_FAST_INTR_STAT_MSC, sii8620_irq_msc },
  1164. { BIT_FAST_INTR_STAT_MERR, sii8620_irq_merr },
  1165. { BIT_FAST_INTR_STAT_EDID, sii8620_irq_edid },
  1166. { BIT_FAST_INTR_STAT_SCDT, sii8620_irq_scdt },
  1167. { BIT_FAST_INTR_STAT_INFR, sii8620_irq_infr },
  1168. };
  1169. struct sii8620 *ctx = data;
  1170. u8 stats[LEN_FAST_INTR_STAT];
  1171. int i, ret;
  1172. mutex_lock(&ctx->lock);
  1173. sii8620_read_buf(ctx, REG_FAST_INTR_STAT, stats, ARRAY_SIZE(stats));
  1174. for (i = 0; i < ARRAY_SIZE(irq_vec); ++i)
  1175. if (sii8620_test_bit(irq_vec[i].bit, stats))
  1176. irq_vec[i].handler(ctx);
  1177. sii8620_mt_work(ctx);
  1178. ret = sii8620_clear_error(ctx);
  1179. if (ret) {
  1180. dev_err(ctx->dev, "Error during IRQ handling, %d.\n", ret);
  1181. sii8620_mhl_disconnected(ctx);
  1182. }
  1183. mutex_unlock(&ctx->lock);
  1184. return IRQ_HANDLED;
  1185. }
  1186. static void sii8620_cable_in(struct sii8620 *ctx)
  1187. {
  1188. struct device *dev = ctx->dev;
  1189. u8 ver[5];
  1190. int ret;
  1191. ret = sii8620_hw_on(ctx);
  1192. if (ret) {
  1193. dev_err(dev, "Error powering on, %d.\n", ret);
  1194. return;
  1195. }
  1196. sii8620_hw_reset(ctx);
  1197. sii8620_read_buf(ctx, REG_VND_IDL, ver, ARRAY_SIZE(ver));
  1198. ret = sii8620_clear_error(ctx);
  1199. if (ret) {
  1200. dev_err(dev, "Error accessing I2C bus, %d.\n", ret);
  1201. return;
  1202. }
  1203. dev_info(dev, "ChipID %02x%02x:%02x%02x rev %02x.\n", ver[1], ver[0],
  1204. ver[3], ver[2], ver[4]);
  1205. sii8620_write(ctx, REG_DPD,
  1206. BIT_DPD_PWRON_PLL | BIT_DPD_PDNTX12 | BIT_DPD_OSC_EN);
  1207. sii8620_xtal_set_rate(ctx);
  1208. sii8620_disconnect(ctx);
  1209. sii8620_write_seq_static(ctx,
  1210. REG_MHL_CBUS_CTL0, VAL_MHL_CBUS_CTL0_CBUS_DRV_SEL_STRONG
  1211. | VAL_MHL_CBUS_CTL0_CBUS_RGND_VBIAS_734,
  1212. REG_MHL_CBUS_CTL1, VAL_MHL_CBUS_CTL1_1115_OHM,
  1213. REG_DPD, BIT_DPD_PWRON_PLL | BIT_DPD_PDNTX12 | BIT_DPD_OSC_EN,
  1214. );
  1215. ret = sii8620_clear_error(ctx);
  1216. if (ret) {
  1217. dev_err(dev, "Error accessing I2C bus, %d.\n", ret);
  1218. return;
  1219. }
  1220. enable_irq(to_i2c_client(ctx->dev)->irq);
  1221. }
  1222. static inline struct sii8620 *bridge_to_sii8620(struct drm_bridge *bridge)
  1223. {
  1224. return container_of(bridge, struct sii8620, bridge);
  1225. }
  1226. static bool sii8620_mode_fixup(struct drm_bridge *bridge,
  1227. const struct drm_display_mode *mode,
  1228. struct drm_display_mode *adjusted_mode)
  1229. {
  1230. struct sii8620 *ctx = bridge_to_sii8620(bridge);
  1231. bool ret = false;
  1232. int max_clock = 74250;
  1233. mutex_lock(&ctx->lock);
  1234. if (mode->flags & DRM_MODE_FLAG_INTERLACE)
  1235. goto out;
  1236. if (ctx->devcap[MHL_DCAP_VID_LINK_MODE] & MHL_DCAP_VID_LINK_PPIXEL)
  1237. max_clock = 300000;
  1238. ret = mode->clock <= max_clock;
  1239. out:
  1240. mutex_unlock(&ctx->lock);
  1241. return ret;
  1242. }
  1243. static const struct drm_bridge_funcs sii8620_bridge_funcs = {
  1244. .mode_fixup = sii8620_mode_fixup,
  1245. };
  1246. static int sii8620_probe(struct i2c_client *client,
  1247. const struct i2c_device_id *id)
  1248. {
  1249. struct device *dev = &client->dev;
  1250. struct sii8620 *ctx;
  1251. int ret;
  1252. ctx = devm_kzalloc(dev, sizeof(*ctx), GFP_KERNEL);
  1253. if (!ctx)
  1254. return -ENOMEM;
  1255. ctx->dev = dev;
  1256. mutex_init(&ctx->lock);
  1257. INIT_LIST_HEAD(&ctx->mt_queue);
  1258. ctx->clk_xtal = devm_clk_get(dev, "xtal");
  1259. if (IS_ERR(ctx->clk_xtal)) {
  1260. dev_err(dev, "failed to get xtal clock from DT\n");
  1261. return PTR_ERR(ctx->clk_xtal);
  1262. }
  1263. if (!client->irq) {
  1264. dev_err(dev, "no irq provided\n");
  1265. return -EINVAL;
  1266. }
  1267. irq_set_status_flags(client->irq, IRQ_NOAUTOEN);
  1268. ret = devm_request_threaded_irq(dev, client->irq, NULL,
  1269. sii8620_irq_thread,
  1270. IRQF_TRIGGER_HIGH | IRQF_ONESHOT,
  1271. "sii8620", ctx);
  1272. ctx->gpio_reset = devm_gpiod_get(dev, "reset", GPIOD_OUT_HIGH);
  1273. if (IS_ERR(ctx->gpio_reset)) {
  1274. dev_err(dev, "failed to get reset gpio from DT\n");
  1275. return PTR_ERR(ctx->gpio_reset);
  1276. }
  1277. ctx->supplies[0].supply = "cvcc10";
  1278. ctx->supplies[1].supply = "iovcc18";
  1279. ret = devm_regulator_bulk_get(dev, 2, ctx->supplies);
  1280. if (ret)
  1281. return ret;
  1282. i2c_set_clientdata(client, ctx);
  1283. ctx->bridge.funcs = &sii8620_bridge_funcs;
  1284. ctx->bridge.of_node = dev->of_node;
  1285. drm_bridge_add(&ctx->bridge);
  1286. sii8620_cable_in(ctx);
  1287. return 0;
  1288. }
  1289. static int sii8620_remove(struct i2c_client *client)
  1290. {
  1291. struct sii8620 *ctx = i2c_get_clientdata(client);
  1292. disable_irq(to_i2c_client(ctx->dev)->irq);
  1293. drm_bridge_remove(&ctx->bridge);
  1294. sii8620_hw_off(ctx);
  1295. return 0;
  1296. }
  1297. static const struct of_device_id sii8620_dt_match[] = {
  1298. { .compatible = "sil,sii8620" },
  1299. { },
  1300. };
  1301. MODULE_DEVICE_TABLE(of, sii8620_dt_match);
  1302. static const struct i2c_device_id sii8620_id[] = {
  1303. { "sii8620", 0 },
  1304. { },
  1305. };
  1306. MODULE_DEVICE_TABLE(i2c, sii8620_id);
  1307. static struct i2c_driver sii8620_driver = {
  1308. .driver = {
  1309. .name = "sii8620",
  1310. .of_match_table = of_match_ptr(sii8620_dt_match),
  1311. },
  1312. .probe = sii8620_probe,
  1313. .remove = sii8620_remove,
  1314. .id_table = sii8620_id,
  1315. };
  1316. module_i2c_driver(sii8620_driver);
  1317. MODULE_LICENSE("GPL v2");