ite-it66121.c 42 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656
  1. // SPDX-License-Identifier: GPL-2.0-only
  2. /*
  3. * Copyright (C) 2020 BayLibre, SAS
  4. * Author: Phong LE <ple@baylibre.com>
  5. * Copyright (C) 2018-2019, Artem Mygaiev
  6. * Copyright (C) 2017, Fresco Logic, Incorporated.
  7. *
  8. */
  9. #include <linux/media-bus-format.h>
  10. #include <linux/module.h>
  11. #include <linux/device.h>
  12. #include <linux/interrupt.h>
  13. #include <linux/i2c.h>
  14. #include <linux/bitfield.h>
  15. #include <linux/property.h>
  16. #include <linux/regmap.h>
  17. #include <linux/of_graph.h>
  18. #include <linux/gpio/consumer.h>
  19. #include <linux/pinctrl/consumer.h>
  20. #include <linux/regulator/consumer.h>
  21. #include <drm/drm_atomic_helper.h>
  22. #include <drm/drm_bridge.h>
  23. #include <drm/drm_edid.h>
  24. #include <drm/drm_modes.h>
  25. #include <drm/drm_print.h>
  26. #include <drm/drm_probe_helper.h>
  27. #include <sound/hdmi-codec.h>
  28. #define IT66121_VENDOR_ID0_REG 0x00
  29. #define IT66121_VENDOR_ID1_REG 0x01
  30. #define IT66121_DEVICE_ID0_REG 0x02
  31. #define IT66121_DEVICE_ID1_REG 0x03
  32. #define IT66121_REVISION_MASK GENMASK(7, 4)
  33. #define IT66121_DEVICE_ID1_MASK GENMASK(3, 0)
  34. #define IT66121_MASTER_SEL_REG 0x10
  35. #define IT66121_MASTER_SEL_HOST BIT(0)
  36. #define IT66121_AFE_DRV_REG 0x61
  37. #define IT66121_AFE_DRV_RST BIT(4)
  38. #define IT66121_AFE_DRV_PWD BIT(5)
  39. #define IT66121_INPUT_MODE_REG 0x70
  40. #define IT66121_INPUT_MODE_RGB (0 << 6)
  41. #define IT66121_INPUT_MODE_YUV422 BIT(6)
  42. #define IT66121_INPUT_MODE_YUV444 (2 << 6)
  43. #define IT66121_INPUT_MODE_CCIR656 BIT(4)
  44. #define IT66121_INPUT_MODE_SYNCEMB BIT(3)
  45. #define IT66121_INPUT_MODE_DDR BIT(2)
  46. #define IT66121_INPUT_CSC_REG 0x72
  47. #define IT66121_INPUT_CSC_ENDITHER BIT(7)
  48. #define IT66121_INPUT_CSC_ENUDFILTER BIT(6)
  49. #define IT66121_INPUT_CSC_DNFREE_GO BIT(5)
  50. #define IT66121_INPUT_CSC_RGB_TO_YUV 0x02
  51. #define IT66121_INPUT_CSC_YUV_TO_RGB 0x03
  52. #define IT66121_INPUT_CSC_NO_CONV 0x00
  53. #define IT66121_AFE_XP_REG 0x62
  54. #define IT66121_AFE_XP_GAINBIT BIT(7)
  55. #define IT66121_AFE_XP_PWDPLL BIT(6)
  56. #define IT66121_AFE_XP_ENI BIT(5)
  57. #define IT66121_AFE_XP_ENO BIT(4)
  58. #define IT66121_AFE_XP_RESETB BIT(3)
  59. #define IT66121_AFE_XP_PWDI BIT(2)
  60. #define IT6610_AFE_XP_BYPASS BIT(0)
  61. #define IT66121_AFE_IP_REG 0x64
  62. #define IT66121_AFE_IP_GAINBIT BIT(7)
  63. #define IT66121_AFE_IP_PWDPLL BIT(6)
  64. #define IT66121_AFE_IP_CKSEL_05 (0 << 4)
  65. #define IT66121_AFE_IP_CKSEL_1 BIT(4)
  66. #define IT66121_AFE_IP_CKSEL_2 (2 << 4)
  67. #define IT66121_AFE_IP_CKSEL_2OR4 (3 << 4)
  68. #define IT66121_AFE_IP_ER0 BIT(3)
  69. #define IT66121_AFE_IP_RESETB BIT(2)
  70. #define IT66121_AFE_IP_ENC BIT(1)
  71. #define IT66121_AFE_IP_EC1 BIT(0)
  72. #define IT66121_AFE_XP_EC1_REG 0x68
  73. #define IT66121_AFE_XP_EC1_LOWCLK BIT(4)
  74. #define IT66121_SW_RST_REG 0x04
  75. #define IT66121_SW_RST_REF BIT(5)
  76. #define IT66121_SW_RST_AREF BIT(4)
  77. #define IT66121_SW_RST_VID BIT(3)
  78. #define IT66121_SW_RST_AUD BIT(2)
  79. #define IT66121_SW_RST_HDCP BIT(0)
  80. #define IT66121_DDC_COMMAND_REG 0x15
  81. #define IT66121_DDC_COMMAND_BURST_READ 0x0
  82. #define IT66121_DDC_COMMAND_EDID_READ 0x3
  83. #define IT66121_DDC_COMMAND_FIFO_CLR 0x9
  84. #define IT66121_DDC_COMMAND_SCL_PULSE 0xA
  85. #define IT66121_DDC_COMMAND_ABORT 0xF
  86. #define IT66121_HDCP_REG 0x20
  87. #define IT66121_HDCP_CPDESIRED BIT(0)
  88. #define IT66121_HDCP_EN1P1FEAT BIT(1)
  89. #define IT66121_INT_STATUS1_REG 0x06
  90. #define IT66121_INT_STATUS1_AUD_OVF BIT(7)
  91. #define IT66121_INT_STATUS1_DDC_NOACK BIT(5)
  92. #define IT66121_INT_STATUS1_DDC_FIFOERR BIT(4)
  93. #define IT66121_INT_STATUS1_DDC_BUSHANG BIT(2)
  94. #define IT66121_INT_STATUS1_RX_SENS_STATUS BIT(1)
  95. #define IT66121_INT_STATUS1_HPD_STATUS BIT(0)
  96. #define IT66121_DDC_HEADER_REG 0x11
  97. #define IT66121_DDC_HEADER_HDCP 0x74
  98. #define IT66121_DDC_HEADER_EDID 0xA0
  99. #define IT66121_DDC_OFFSET_REG 0x12
  100. #define IT66121_DDC_BYTE_REG 0x13
  101. #define IT66121_DDC_SEGMENT_REG 0x14
  102. #define IT66121_DDC_RD_FIFO_REG 0x17
  103. #define IT66121_CLK_BANK_REG 0x0F
  104. #define IT66121_CLK_BANK_PWROFF_RCLK BIT(6)
  105. #define IT66121_CLK_BANK_PWROFF_ACLK BIT(5)
  106. #define IT66121_CLK_BANK_PWROFF_TXCLK BIT(4)
  107. #define IT66121_CLK_BANK_PWROFF_CRCLK BIT(3)
  108. #define IT66121_CLK_BANK_0 0
  109. #define IT66121_CLK_BANK_1 1
  110. #define IT66121_INT_REG 0x05
  111. #define IT66121_INT_ACTIVE_HIGH BIT(7)
  112. #define IT66121_INT_OPEN_DRAIN BIT(6)
  113. #define IT66121_INT_TX_CLK_OFF BIT(0)
  114. #define IT66121_INT_MASK1_REG 0x09
  115. #define IT66121_INT_MASK1_AUD_OVF BIT(7)
  116. #define IT66121_INT_MASK1_DDC_NOACK BIT(5)
  117. #define IT66121_INT_MASK1_DDC_FIFOERR BIT(4)
  118. #define IT66121_INT_MASK1_DDC_BUSHANG BIT(2)
  119. #define IT66121_INT_MASK1_RX_SENS BIT(1)
  120. #define IT66121_INT_MASK1_HPD BIT(0)
  121. #define IT66121_INT_CLR1_REG 0x0C
  122. #define IT66121_INT_CLR1_PKTACP BIT(7)
  123. #define IT66121_INT_CLR1_PKTNULL BIT(6)
  124. #define IT66121_INT_CLR1_PKTGEN BIT(5)
  125. #define IT66121_INT_CLR1_KSVLISTCHK BIT(4)
  126. #define IT66121_INT_CLR1_AUTHDONE BIT(3)
  127. #define IT66121_INT_CLR1_AUTHFAIL BIT(2)
  128. #define IT66121_INT_CLR1_RX_SENS BIT(1)
  129. #define IT66121_INT_CLR1_HPD BIT(0)
  130. #define IT66121_AV_MUTE_REG 0xC1
  131. #define IT66121_AV_MUTE_ON BIT(0)
  132. #define IT66121_AV_MUTE_BLUESCR BIT(1)
  133. #define IT66121_PKT_CTS_CTRL_REG 0xC5
  134. #define IT66121_PKT_CTS_CTRL_SEL BIT(1)
  135. #define IT66121_PKT_GEN_CTRL_REG 0xC6
  136. #define IT66121_PKT_GEN_CTRL_ON BIT(0)
  137. #define IT66121_PKT_GEN_CTRL_RPT BIT(1)
  138. #define IT66121_AVIINFO_DB1_REG 0x158
  139. #define IT66121_AVIINFO_DB2_REG 0x159
  140. #define IT66121_AVIINFO_DB3_REG 0x15A
  141. #define IT66121_AVIINFO_DB4_REG 0x15B
  142. #define IT66121_AVIINFO_DB5_REG 0x15C
  143. #define IT66121_AVIINFO_CSUM_REG 0x15D
  144. #define IT66121_AVIINFO_DB6_REG 0x15E
  145. #define IT66121_AVIINFO_DB7_REG 0x15F
  146. #define IT66121_AVIINFO_DB8_REG 0x160
  147. #define IT66121_AVIINFO_DB9_REG 0x161
  148. #define IT66121_AVIINFO_DB10_REG 0x162
  149. #define IT66121_AVIINFO_DB11_REG 0x163
  150. #define IT66121_AVIINFO_DB12_REG 0x164
  151. #define IT66121_AVIINFO_DB13_REG 0x165
  152. #define IT66121_AVI_INFO_PKT_REG 0xCD
  153. #define IT66121_AVI_INFO_PKT_ON BIT(0)
  154. #define IT66121_AVI_INFO_PKT_RPT BIT(1)
  155. #define IT66121_HDMI_MODE_REG 0xC0
  156. #define IT66121_HDMI_MODE_HDMI BIT(0)
  157. #define IT66121_SYS_STATUS_REG 0x0E
  158. #define IT66121_SYS_STATUS_ACTIVE_IRQ BIT(7)
  159. #define IT66121_SYS_STATUS_HPDETECT BIT(6)
  160. #define IT66121_SYS_STATUS_SENDECTECT BIT(5)
  161. #define IT66121_SYS_STATUS_VID_STABLE BIT(4)
  162. #define IT66121_SYS_STATUS_AUD_CTS_CLR BIT(1)
  163. #define IT66121_SYS_STATUS_CLEAR_IRQ BIT(0)
  164. #define IT66121_DDC_STATUS_REG 0x16
  165. #define IT66121_DDC_STATUS_TX_DONE BIT(7)
  166. #define IT66121_DDC_STATUS_ACTIVE BIT(6)
  167. #define IT66121_DDC_STATUS_NOACK BIT(5)
  168. #define IT66121_DDC_STATUS_WAIT_BUS BIT(4)
  169. #define IT66121_DDC_STATUS_ARBI_LOSE BIT(3)
  170. #define IT66121_DDC_STATUS_FIFO_FULL BIT(2)
  171. #define IT66121_DDC_STATUS_FIFO_EMPTY BIT(1)
  172. #define IT66121_DDC_STATUS_FIFO_VALID BIT(0)
  173. #define IT66121_EDID_SLEEP_US 20000
  174. #define IT66121_EDID_TIMEOUT_US 200000
  175. #define IT66121_EDID_FIFO_SIZE 32
  176. #define IT66121_CLK_CTRL0_REG 0x58
  177. #define IT66121_CLK_CTRL0_AUTO_OVER_SAMPLING BIT(4)
  178. #define IT66121_CLK_CTRL0_EXT_MCLK_MASK GENMASK(3, 2)
  179. #define IT66121_CLK_CTRL0_EXT_MCLK_128FS (0 << 2)
  180. #define IT66121_CLK_CTRL0_EXT_MCLK_256FS BIT(2)
  181. #define IT66121_CLK_CTRL0_EXT_MCLK_512FS (2 << 2)
  182. #define IT66121_CLK_CTRL0_EXT_MCLK_1024FS (3 << 2)
  183. #define IT66121_CLK_CTRL0_AUTO_IPCLK BIT(0)
  184. #define IT66121_CLK_STATUS1_REG 0x5E
  185. #define IT66121_CLK_STATUS2_REG 0x5F
  186. #define IT66121_AUD_CTRL0_REG 0xE0
  187. #define IT66121_AUD_SWL (3 << 6)
  188. #define IT66121_AUD_16BIT (0 << 6)
  189. #define IT66121_AUD_18BIT BIT(6)
  190. #define IT66121_AUD_20BIT (2 << 6)
  191. #define IT66121_AUD_24BIT (3 << 6)
  192. #define IT66121_AUD_SPDIFTC BIT(5)
  193. #define IT66121_AUD_SPDIF BIT(4)
  194. #define IT66121_AUD_I2S (0 << 4)
  195. #define IT66121_AUD_EN_I2S3 BIT(3)
  196. #define IT66121_AUD_EN_I2S2 BIT(2)
  197. #define IT66121_AUD_EN_I2S1 BIT(1)
  198. #define IT66121_AUD_EN_I2S0 BIT(0)
  199. #define IT66121_AUD_CTRL0_AUD_SEL BIT(4)
  200. #define IT66121_AUD_CTRL1_REG 0xE1
  201. #define IT66121_AUD_FIFOMAP_REG 0xE2
  202. #define IT66121_AUD_CTRL3_REG 0xE3
  203. #define IT66121_AUD_SRCVALID_FLAT_REG 0xE4
  204. #define IT66121_AUD_FLAT_SRC0 BIT(4)
  205. #define IT66121_AUD_FLAT_SRC1 BIT(5)
  206. #define IT66121_AUD_FLAT_SRC2 BIT(6)
  207. #define IT66121_AUD_FLAT_SRC3 BIT(7)
  208. #define IT66121_AUD_HDAUDIO_REG 0xE5
  209. #define IT66121_AUD_PKT_CTS0_REG 0x130
  210. #define IT66121_AUD_PKT_CTS1_REG 0x131
  211. #define IT66121_AUD_PKT_CTS2_REG 0x132
  212. #define IT66121_AUD_PKT_N0_REG 0x133
  213. #define IT66121_AUD_PKT_N1_REG 0x134
  214. #define IT66121_AUD_PKT_N2_REG 0x135
  215. #define IT66121_AUD_CHST_MODE_REG 0x191
  216. #define IT66121_AUD_CHST_CAT_REG 0x192
  217. #define IT66121_AUD_CHST_SRCNUM_REG 0x193
  218. #define IT66121_AUD_CHST_CHTNUM_REG 0x194
  219. #define IT66121_AUD_CHST_CA_FS_REG 0x198
  220. #define IT66121_AUD_CHST_OFS_WL_REG 0x199
  221. #define IT66121_AUD_PKT_CTS_CNT0_REG 0x1A0
  222. #define IT66121_AUD_PKT_CTS_CNT1_REG 0x1A1
  223. #define IT66121_AUD_PKT_CTS_CNT2_REG 0x1A2
  224. #define IT66121_AUD_FS_22P05K 0x4
  225. #define IT66121_AUD_FS_44P1K 0x0
  226. #define IT66121_AUD_FS_88P2K 0x8
  227. #define IT66121_AUD_FS_176P4K 0xC
  228. #define IT66121_AUD_FS_24K 0x6
  229. #define IT66121_AUD_FS_48K 0x2
  230. #define IT66121_AUD_FS_96K 0xA
  231. #define IT66121_AUD_FS_192K 0xE
  232. #define IT66121_AUD_FS_768K 0x9
  233. #define IT66121_AUD_FS_32K 0x3
  234. #define IT66121_AUD_FS_OTHER 0x1
  235. #define IT66121_AUD_SWL_21BIT 0xD
  236. #define IT66121_AUD_SWL_24BIT 0xB
  237. #define IT66121_AUD_SWL_23BIT 0x9
  238. #define IT66121_AUD_SWL_22BIT 0x5
  239. #define IT66121_AUD_SWL_20BIT 0x3
  240. #define IT66121_AUD_SWL_17BIT 0xC
  241. #define IT66121_AUD_SWL_19BIT 0x8
  242. #define IT66121_AUD_SWL_18BIT 0x4
  243. #define IT66121_AUD_SWL_16BIT 0x2
  244. #define IT66121_AUD_SWL_NOT_INDICATED 0x0
  245. #define IT66121_AFE_CLK_HIGH 80000 /* Khz */
  246. enum chip_id {
  247. ID_IT6610,
  248. ID_IT66121,
  249. };
  250. struct it66121_chip_info {
  251. enum chip_id id;
  252. u16 vid, pid;
  253. };
  254. struct it66121_ctx {
  255. struct regmap *regmap;
  256. struct drm_bridge bridge;
  257. struct drm_bridge *next_bridge;
  258. struct drm_connector *connector;
  259. struct device *dev;
  260. struct gpio_desc *gpio_reset;
  261. struct i2c_client *client;
  262. u32 bus_width;
  263. struct mutex lock; /* Protects fields below and device registers */
  264. struct hdmi_avi_infoframe hdmi_avi_infoframe;
  265. struct {
  266. struct platform_device *pdev;
  267. u8 ch_enable;
  268. u8 fs;
  269. u8 swl;
  270. bool auto_cts;
  271. } audio;
  272. const struct it66121_chip_info *info;
  273. };
  274. static const struct regmap_range_cfg it66121_regmap_banks[] = {
  275. {
  276. .name = "it66121",
  277. .range_min = 0x00,
  278. .range_max = 0x1FF,
  279. .selector_reg = IT66121_CLK_BANK_REG,
  280. .selector_mask = 0x1,
  281. .selector_shift = 0,
  282. .window_start = 0x00,
  283. .window_len = 0x100,
  284. },
  285. };
  286. static const struct regmap_config it66121_regmap_config = {
  287. .val_bits = 8,
  288. .reg_bits = 8,
  289. .max_register = 0x1FF,
  290. .ranges = it66121_regmap_banks,
  291. .num_ranges = ARRAY_SIZE(it66121_regmap_banks),
  292. };
  293. static void it66121_hw_reset(struct it66121_ctx *ctx)
  294. {
  295. gpiod_set_value(ctx->gpio_reset, 1);
  296. msleep(20);
  297. gpiod_set_value(ctx->gpio_reset, 0);
  298. }
  299. static inline int it66121_preamble_ddc(struct it66121_ctx *ctx)
  300. {
  301. return regmap_write(ctx->regmap, IT66121_MASTER_SEL_REG, IT66121_MASTER_SEL_HOST);
  302. }
  303. static inline int it66121_fire_afe(struct it66121_ctx *ctx)
  304. {
  305. return regmap_write(ctx->regmap, IT66121_AFE_DRV_REG, 0);
  306. }
  307. /* TOFIX: Handle YCbCr Input & Output */
  308. static int it66121_configure_input(struct it66121_ctx *ctx)
  309. {
  310. int ret;
  311. u8 mode = IT66121_INPUT_MODE_RGB;
  312. if (ctx->bus_width == 12)
  313. mode |= IT66121_INPUT_MODE_DDR;
  314. ret = regmap_write(ctx->regmap, IT66121_INPUT_MODE_REG, mode);
  315. if (ret)
  316. return ret;
  317. return regmap_write(ctx->regmap, IT66121_INPUT_CSC_REG, IT66121_INPUT_CSC_NO_CONV);
  318. }
  319. /**
  320. * it66121_configure_afe() - Configure the analog front end
  321. * @ctx: it66121_ctx object
  322. * @mode: mode to configure
  323. *
  324. * RETURNS:
  325. * zero if success, a negative error code otherwise.
  326. */
  327. static int it66121_configure_afe(struct it66121_ctx *ctx,
  328. const struct drm_display_mode *mode)
  329. {
  330. int ret;
  331. ret = regmap_write(ctx->regmap, IT66121_AFE_DRV_REG,
  332. IT66121_AFE_DRV_RST);
  333. if (ret)
  334. return ret;
  335. if (mode->clock > IT66121_AFE_CLK_HIGH) {
  336. ret = regmap_write_bits(ctx->regmap, IT66121_AFE_XP_REG,
  337. IT66121_AFE_XP_GAINBIT |
  338. IT66121_AFE_XP_ENO,
  339. IT66121_AFE_XP_GAINBIT);
  340. if (ret)
  341. return ret;
  342. ret = regmap_write_bits(ctx->regmap, IT66121_AFE_IP_REG,
  343. IT66121_AFE_IP_GAINBIT |
  344. IT66121_AFE_IP_ER0,
  345. IT66121_AFE_IP_GAINBIT);
  346. if (ret)
  347. return ret;
  348. if (ctx->info->id == ID_IT66121) {
  349. ret = regmap_write_bits(ctx->regmap, IT66121_AFE_IP_REG,
  350. IT66121_AFE_IP_EC1, 0);
  351. if (ret)
  352. return ret;
  353. ret = regmap_write_bits(ctx->regmap, IT66121_AFE_XP_EC1_REG,
  354. IT66121_AFE_XP_EC1_LOWCLK, 0x80);
  355. if (ret)
  356. return ret;
  357. }
  358. } else {
  359. ret = regmap_write_bits(ctx->regmap, IT66121_AFE_XP_REG,
  360. IT66121_AFE_XP_GAINBIT |
  361. IT66121_AFE_XP_ENO,
  362. IT66121_AFE_XP_ENO);
  363. if (ret)
  364. return ret;
  365. ret = regmap_write_bits(ctx->regmap, IT66121_AFE_IP_REG,
  366. IT66121_AFE_IP_GAINBIT |
  367. IT66121_AFE_IP_ER0,
  368. IT66121_AFE_IP_ER0);
  369. if (ret)
  370. return ret;
  371. if (ctx->info->id == ID_IT66121) {
  372. ret = regmap_write_bits(ctx->regmap, IT66121_AFE_IP_REG,
  373. IT66121_AFE_IP_EC1,
  374. IT66121_AFE_IP_EC1);
  375. if (ret)
  376. return ret;
  377. ret = regmap_write_bits(ctx->regmap, IT66121_AFE_XP_EC1_REG,
  378. IT66121_AFE_XP_EC1_LOWCLK,
  379. IT66121_AFE_XP_EC1_LOWCLK);
  380. if (ret)
  381. return ret;
  382. }
  383. }
  384. /* Clear reset flags */
  385. ret = regmap_write_bits(ctx->regmap, IT66121_SW_RST_REG,
  386. IT66121_SW_RST_REF | IT66121_SW_RST_VID, 0);
  387. if (ret)
  388. return ret;
  389. if (ctx->info->id == ID_IT6610) {
  390. ret = regmap_write_bits(ctx->regmap, IT66121_AFE_XP_REG,
  391. IT6610_AFE_XP_BYPASS,
  392. IT6610_AFE_XP_BYPASS);
  393. if (ret)
  394. return ret;
  395. }
  396. return it66121_fire_afe(ctx);
  397. }
  398. static inline int it66121_wait_ddc_ready(struct it66121_ctx *ctx)
  399. {
  400. int ret, val;
  401. u32 error = IT66121_DDC_STATUS_NOACK | IT66121_DDC_STATUS_WAIT_BUS |
  402. IT66121_DDC_STATUS_ARBI_LOSE;
  403. u32 done = IT66121_DDC_STATUS_TX_DONE;
  404. ret = regmap_read_poll_timeout(ctx->regmap, IT66121_DDC_STATUS_REG, val,
  405. val & (error | done), IT66121_EDID_SLEEP_US,
  406. IT66121_EDID_TIMEOUT_US);
  407. if (ret)
  408. return ret;
  409. if (val & error)
  410. return -EAGAIN;
  411. return 0;
  412. }
  413. static int it66121_abort_ddc_ops(struct it66121_ctx *ctx)
  414. {
  415. int ret;
  416. unsigned int swreset, cpdesire;
  417. ret = regmap_read(ctx->regmap, IT66121_SW_RST_REG, &swreset);
  418. if (ret)
  419. return ret;
  420. ret = regmap_read(ctx->regmap, IT66121_HDCP_REG, &cpdesire);
  421. if (ret)
  422. return ret;
  423. ret = regmap_write(ctx->regmap, IT66121_HDCP_REG,
  424. cpdesire & (~IT66121_HDCP_CPDESIRED & 0xFF));
  425. if (ret)
  426. return ret;
  427. ret = regmap_write(ctx->regmap, IT66121_SW_RST_REG,
  428. (swreset | IT66121_SW_RST_HDCP));
  429. if (ret)
  430. return ret;
  431. ret = it66121_preamble_ddc(ctx);
  432. if (ret)
  433. return ret;
  434. ret = regmap_write(ctx->regmap, IT66121_DDC_COMMAND_REG,
  435. IT66121_DDC_COMMAND_ABORT);
  436. if (ret)
  437. return ret;
  438. return it66121_wait_ddc_ready(ctx);
  439. }
  440. static int it66121_get_edid_block(void *context, u8 *buf,
  441. unsigned int block, size_t len)
  442. {
  443. struct it66121_ctx *ctx = context;
  444. int remain = len;
  445. int offset = 0;
  446. int ret, cnt;
  447. offset = (block % 2) * len;
  448. block = block / 2;
  449. while (remain > 0) {
  450. cnt = (remain > IT66121_EDID_FIFO_SIZE) ?
  451. IT66121_EDID_FIFO_SIZE : remain;
  452. ret = regmap_write(ctx->regmap, IT66121_DDC_COMMAND_REG,
  453. IT66121_DDC_COMMAND_FIFO_CLR);
  454. if (ret)
  455. return ret;
  456. ret = it66121_wait_ddc_ready(ctx);
  457. if (ret)
  458. return ret;
  459. ret = regmap_write(ctx->regmap, IT66121_DDC_OFFSET_REG, offset);
  460. if (ret)
  461. return ret;
  462. ret = regmap_write(ctx->regmap, IT66121_DDC_BYTE_REG, cnt);
  463. if (ret)
  464. return ret;
  465. ret = regmap_write(ctx->regmap, IT66121_DDC_SEGMENT_REG, block);
  466. if (ret)
  467. return ret;
  468. ret = regmap_write(ctx->regmap, IT66121_DDC_COMMAND_REG,
  469. IT66121_DDC_COMMAND_EDID_READ);
  470. if (ret)
  471. return ret;
  472. offset += cnt;
  473. remain -= cnt;
  474. ret = it66121_wait_ddc_ready(ctx);
  475. if (ret) {
  476. it66121_abort_ddc_ops(ctx);
  477. return ret;
  478. }
  479. ret = regmap_noinc_read(ctx->regmap, IT66121_DDC_RD_FIFO_REG,
  480. buf, cnt);
  481. if (ret)
  482. return ret;
  483. buf += cnt;
  484. }
  485. return 0;
  486. }
  487. static bool it66121_is_hpd_detect(struct it66121_ctx *ctx)
  488. {
  489. int val;
  490. if (regmap_read(ctx->regmap, IT66121_SYS_STATUS_REG, &val))
  491. return false;
  492. return val & IT66121_SYS_STATUS_HPDETECT;
  493. }
  494. static int it66121_bridge_attach(struct drm_bridge *bridge,
  495. enum drm_bridge_attach_flags flags)
  496. {
  497. struct it66121_ctx *ctx = container_of(bridge, struct it66121_ctx, bridge);
  498. int ret;
  499. if (!(flags & DRM_BRIDGE_ATTACH_NO_CONNECTOR))
  500. return -EINVAL;
  501. ret = drm_bridge_attach(bridge->encoder, ctx->next_bridge, bridge, flags);
  502. if (ret)
  503. return ret;
  504. if (ctx->info->id == ID_IT66121) {
  505. ret = regmap_write_bits(ctx->regmap, IT66121_CLK_BANK_REG,
  506. IT66121_CLK_BANK_PWROFF_RCLK, 0);
  507. if (ret)
  508. return ret;
  509. }
  510. ret = regmap_write_bits(ctx->regmap, IT66121_INT_REG,
  511. IT66121_INT_TX_CLK_OFF, 0);
  512. if (ret)
  513. return ret;
  514. ret = regmap_write_bits(ctx->regmap, IT66121_AFE_DRV_REG,
  515. IT66121_AFE_DRV_PWD, 0);
  516. if (ret)
  517. return ret;
  518. ret = regmap_write_bits(ctx->regmap, IT66121_AFE_XP_REG,
  519. IT66121_AFE_XP_PWDI | IT66121_AFE_XP_PWDPLL, 0);
  520. if (ret)
  521. return ret;
  522. ret = regmap_write_bits(ctx->regmap, IT66121_AFE_IP_REG,
  523. IT66121_AFE_IP_PWDPLL, 0);
  524. if (ret)
  525. return ret;
  526. ret = regmap_write_bits(ctx->regmap, IT66121_AFE_DRV_REG,
  527. IT66121_AFE_DRV_RST, 0);
  528. if (ret)
  529. return ret;
  530. ret = regmap_write_bits(ctx->regmap, IT66121_AFE_XP_REG,
  531. IT66121_AFE_XP_RESETB, IT66121_AFE_XP_RESETB);
  532. if (ret)
  533. return ret;
  534. ret = regmap_write_bits(ctx->regmap, IT66121_AFE_IP_REG,
  535. IT66121_AFE_IP_RESETB, IT66121_AFE_IP_RESETB);
  536. if (ret)
  537. return ret;
  538. ret = regmap_write_bits(ctx->regmap, IT66121_SW_RST_REG,
  539. IT66121_SW_RST_REF,
  540. IT66121_SW_RST_REF);
  541. if (ret)
  542. return ret;
  543. /* Per programming manual, sleep here for bridge to settle */
  544. msleep(50);
  545. return 0;
  546. }
  547. static int it66121_set_mute(struct it66121_ctx *ctx, bool mute)
  548. {
  549. int ret;
  550. unsigned int val = 0;
  551. if (mute)
  552. val = IT66121_AV_MUTE_ON;
  553. ret = regmap_write_bits(ctx->regmap, IT66121_AV_MUTE_REG, IT66121_AV_MUTE_ON, val);
  554. if (ret)
  555. return ret;
  556. return regmap_write(ctx->regmap, IT66121_PKT_GEN_CTRL_REG,
  557. IT66121_PKT_GEN_CTRL_ON | IT66121_PKT_GEN_CTRL_RPT);
  558. }
  559. #define MAX_OUTPUT_SEL_FORMATS 1
  560. static u32 *it66121_bridge_atomic_get_output_bus_fmts(struct drm_bridge *bridge,
  561. struct drm_bridge_state *bridge_state,
  562. struct drm_crtc_state *crtc_state,
  563. struct drm_connector_state *conn_state,
  564. unsigned int *num_output_fmts)
  565. {
  566. u32 *output_fmts;
  567. output_fmts = kcalloc(MAX_OUTPUT_SEL_FORMATS, sizeof(*output_fmts),
  568. GFP_KERNEL);
  569. if (!output_fmts)
  570. return NULL;
  571. /* TOFIX handle more than MEDIA_BUS_FMT_RGB888_1X24 as output format */
  572. output_fmts[0] = MEDIA_BUS_FMT_RGB888_1X24;
  573. *num_output_fmts = 1;
  574. return output_fmts;
  575. }
  576. #define MAX_INPUT_SEL_FORMATS 1
  577. static u32 *it66121_bridge_atomic_get_input_bus_fmts(struct drm_bridge *bridge,
  578. struct drm_bridge_state *bridge_state,
  579. struct drm_crtc_state *crtc_state,
  580. struct drm_connector_state *conn_state,
  581. u32 output_fmt,
  582. unsigned int *num_input_fmts)
  583. {
  584. struct it66121_ctx *ctx = container_of(bridge, struct it66121_ctx, bridge);
  585. u32 *input_fmts;
  586. *num_input_fmts = 0;
  587. input_fmts = kcalloc(MAX_INPUT_SEL_FORMATS, sizeof(*input_fmts),
  588. GFP_KERNEL);
  589. if (!input_fmts)
  590. return NULL;
  591. if (ctx->bus_width == 12)
  592. /* IT66121FN Datasheet specifies Little-Endian ordering */
  593. input_fmts[0] = MEDIA_BUS_FMT_RGB888_2X12_LE;
  594. else
  595. /* TOFIX support more input bus formats in 24bit width */
  596. input_fmts[0] = MEDIA_BUS_FMT_RGB888_1X24;
  597. *num_input_fmts = 1;
  598. return input_fmts;
  599. }
  600. static void it66121_bridge_enable(struct drm_bridge *bridge,
  601. struct drm_bridge_state *bridge_state)
  602. {
  603. struct it66121_ctx *ctx = container_of(bridge, struct it66121_ctx, bridge);
  604. struct drm_atomic_state *state = bridge_state->base.state;
  605. ctx->connector = drm_atomic_get_new_connector_for_encoder(state, bridge->encoder);
  606. it66121_set_mute(ctx, false);
  607. }
  608. static void it66121_bridge_disable(struct drm_bridge *bridge,
  609. struct drm_bridge_state *bridge_state)
  610. {
  611. struct it66121_ctx *ctx = container_of(bridge, struct it66121_ctx, bridge);
  612. it66121_set_mute(ctx, true);
  613. ctx->connector = NULL;
  614. }
  615. static int it66121_bridge_check(struct drm_bridge *bridge,
  616. struct drm_bridge_state *bridge_state,
  617. struct drm_crtc_state *crtc_state,
  618. struct drm_connector_state *conn_state)
  619. {
  620. struct it66121_ctx *ctx = container_of(bridge, struct it66121_ctx, bridge);
  621. if (ctx->info->id == ID_IT6610) {
  622. /* The IT6610 only supports these settings */
  623. bridge_state->input_bus_cfg.flags |= DRM_BUS_FLAG_DE_HIGH |
  624. DRM_BUS_FLAG_PIXDATA_DRIVE_NEGEDGE;
  625. bridge_state->input_bus_cfg.flags &=
  626. ~DRM_BUS_FLAG_PIXDATA_DRIVE_POSEDGE;
  627. }
  628. return 0;
  629. }
  630. static
  631. void it66121_bridge_mode_set(struct drm_bridge *bridge,
  632. const struct drm_display_mode *mode,
  633. const struct drm_display_mode *adjusted_mode)
  634. {
  635. u8 buf[HDMI_INFOFRAME_SIZE(AVI)];
  636. struct it66121_ctx *ctx = container_of(bridge, struct it66121_ctx, bridge);
  637. int ret;
  638. mutex_lock(&ctx->lock);
  639. hdmi_avi_infoframe_init(&ctx->hdmi_avi_infoframe);
  640. ret = drm_hdmi_avi_infoframe_from_display_mode(&ctx->hdmi_avi_infoframe, ctx->connector,
  641. adjusted_mode);
  642. if (ret) {
  643. DRM_ERROR("Failed to setup AVI infoframe: %d\n", ret);
  644. goto unlock;
  645. }
  646. ret = hdmi_avi_infoframe_pack(&ctx->hdmi_avi_infoframe, buf, sizeof(buf));
  647. if (ret < 0) {
  648. DRM_ERROR("Failed to pack infoframe: %d\n", ret);
  649. goto unlock;
  650. }
  651. /* Write new AVI infoframe packet */
  652. ret = regmap_bulk_write(ctx->regmap, IT66121_AVIINFO_DB1_REG,
  653. &buf[HDMI_INFOFRAME_HEADER_SIZE],
  654. HDMI_AVI_INFOFRAME_SIZE);
  655. if (ret)
  656. goto unlock;
  657. if (regmap_write(ctx->regmap, IT66121_AVIINFO_CSUM_REG, buf[3]))
  658. goto unlock;
  659. /* Enable AVI infoframe */
  660. if (regmap_write(ctx->regmap, IT66121_AVI_INFO_PKT_REG,
  661. IT66121_AVI_INFO_PKT_ON | IT66121_AVI_INFO_PKT_RPT))
  662. goto unlock;
  663. /* Set TX mode to HDMI */
  664. if (regmap_write(ctx->regmap, IT66121_HDMI_MODE_REG, IT66121_HDMI_MODE_HDMI))
  665. goto unlock;
  666. if (ctx->info->id == ID_IT66121 &&
  667. regmap_write_bits(ctx->regmap, IT66121_CLK_BANK_REG,
  668. IT66121_CLK_BANK_PWROFF_TXCLK,
  669. IT66121_CLK_BANK_PWROFF_TXCLK)) {
  670. goto unlock;
  671. }
  672. if (it66121_configure_input(ctx))
  673. goto unlock;
  674. if (it66121_configure_afe(ctx, adjusted_mode))
  675. goto unlock;
  676. if (ctx->info->id == ID_IT66121 &&
  677. regmap_write_bits(ctx->regmap, IT66121_CLK_BANK_REG,
  678. IT66121_CLK_BANK_PWROFF_TXCLK, 0)) {
  679. goto unlock;
  680. }
  681. unlock:
  682. mutex_unlock(&ctx->lock);
  683. }
  684. static enum drm_mode_status it66121_bridge_mode_valid(struct drm_bridge *bridge,
  685. const struct drm_display_info *info,
  686. const struct drm_display_mode *mode)
  687. {
  688. struct it66121_ctx *ctx = container_of(bridge, struct it66121_ctx, bridge);
  689. unsigned long max_clock;
  690. max_clock = (ctx->bus_width == 12) ? 74250 : 148500;
  691. if (mode->clock > max_clock)
  692. return MODE_CLOCK_HIGH;
  693. if (mode->clock < 25000)
  694. return MODE_CLOCK_LOW;
  695. return MODE_OK;
  696. }
  697. static enum drm_connector_status it66121_bridge_detect(struct drm_bridge *bridge)
  698. {
  699. struct it66121_ctx *ctx = container_of(bridge, struct it66121_ctx, bridge);
  700. return it66121_is_hpd_detect(ctx) ? connector_status_connected
  701. : connector_status_disconnected;
  702. }
  703. static void it66121_bridge_hpd_enable(struct drm_bridge *bridge)
  704. {
  705. struct it66121_ctx *ctx = container_of(bridge, struct it66121_ctx, bridge);
  706. int ret;
  707. ret = regmap_write_bits(ctx->regmap, IT66121_INT_MASK1_REG, IT66121_INT_MASK1_HPD, 0);
  708. if (ret)
  709. dev_err(ctx->dev, "failed to enable HPD IRQ\n");
  710. }
  711. static void it66121_bridge_hpd_disable(struct drm_bridge *bridge)
  712. {
  713. struct it66121_ctx *ctx = container_of(bridge, struct it66121_ctx, bridge);
  714. int ret;
  715. ret = regmap_write_bits(ctx->regmap, IT66121_INT_MASK1_REG,
  716. IT66121_INT_MASK1_HPD, IT66121_INT_MASK1_HPD);
  717. if (ret)
  718. dev_err(ctx->dev, "failed to disable HPD IRQ\n");
  719. }
  720. static const struct drm_edid *it66121_bridge_edid_read(struct drm_bridge *bridge,
  721. struct drm_connector *connector)
  722. {
  723. struct it66121_ctx *ctx = container_of(bridge, struct it66121_ctx, bridge);
  724. const struct drm_edid *drm_edid;
  725. int ret;
  726. mutex_lock(&ctx->lock);
  727. ret = it66121_preamble_ddc(ctx);
  728. if (ret) {
  729. drm_edid = NULL;
  730. goto out_unlock;
  731. }
  732. ret = regmap_write(ctx->regmap, IT66121_DDC_HEADER_REG,
  733. IT66121_DDC_HEADER_EDID);
  734. if (ret) {
  735. drm_edid = NULL;
  736. goto out_unlock;
  737. }
  738. drm_edid = drm_edid_read_custom(connector, it66121_get_edid_block, ctx);
  739. out_unlock:
  740. mutex_unlock(&ctx->lock);
  741. return drm_edid;
  742. }
  743. static const struct drm_bridge_funcs it66121_bridge_funcs = {
  744. .atomic_duplicate_state = drm_atomic_helper_bridge_duplicate_state,
  745. .atomic_destroy_state = drm_atomic_helper_bridge_destroy_state,
  746. .atomic_reset = drm_atomic_helper_bridge_reset,
  747. .attach = it66121_bridge_attach,
  748. .atomic_get_output_bus_fmts = it66121_bridge_atomic_get_output_bus_fmts,
  749. .atomic_get_input_bus_fmts = it66121_bridge_atomic_get_input_bus_fmts,
  750. .atomic_enable = it66121_bridge_enable,
  751. .atomic_disable = it66121_bridge_disable,
  752. .atomic_check = it66121_bridge_check,
  753. .mode_set = it66121_bridge_mode_set,
  754. .mode_valid = it66121_bridge_mode_valid,
  755. .detect = it66121_bridge_detect,
  756. .edid_read = it66121_bridge_edid_read,
  757. .hpd_enable = it66121_bridge_hpd_enable,
  758. .hpd_disable = it66121_bridge_hpd_disable,
  759. };
  760. static irqreturn_t it66121_irq_threaded_handler(int irq, void *dev_id)
  761. {
  762. int ret;
  763. unsigned int val;
  764. struct it66121_ctx *ctx = dev_id;
  765. struct device *dev = ctx->dev;
  766. enum drm_connector_status status;
  767. bool event = false;
  768. mutex_lock(&ctx->lock);
  769. ret = regmap_read(ctx->regmap, IT66121_SYS_STATUS_REG, &val);
  770. if (ret)
  771. goto unlock;
  772. if (!(val & IT66121_SYS_STATUS_ACTIVE_IRQ))
  773. goto unlock;
  774. ret = regmap_read(ctx->regmap, IT66121_INT_STATUS1_REG, &val);
  775. if (ret) {
  776. dev_err(dev, "Cannot read STATUS1_REG %d\n", ret);
  777. } else if (val & IT66121_INT_STATUS1_HPD_STATUS) {
  778. regmap_write_bits(ctx->regmap, IT66121_INT_CLR1_REG,
  779. IT66121_INT_CLR1_HPD, IT66121_INT_CLR1_HPD);
  780. status = it66121_is_hpd_detect(ctx) ? connector_status_connected
  781. : connector_status_disconnected;
  782. event = true;
  783. }
  784. regmap_write_bits(ctx->regmap, IT66121_SYS_STATUS_REG,
  785. IT66121_SYS_STATUS_CLEAR_IRQ,
  786. IT66121_SYS_STATUS_CLEAR_IRQ);
  787. unlock:
  788. mutex_unlock(&ctx->lock);
  789. if (event)
  790. drm_bridge_hpd_notify(&ctx->bridge, status);
  791. return IRQ_HANDLED;
  792. }
  793. static int it661221_set_chstat(struct it66121_ctx *ctx, u8 iec60958_chstat[])
  794. {
  795. int ret;
  796. ret = regmap_write(ctx->regmap, IT66121_AUD_CHST_MODE_REG, iec60958_chstat[0] & 0x7C);
  797. if (ret)
  798. return ret;
  799. ret = regmap_write(ctx->regmap, IT66121_AUD_CHST_CAT_REG, iec60958_chstat[1]);
  800. if (ret)
  801. return ret;
  802. ret = regmap_write(ctx->regmap, IT66121_AUD_CHST_SRCNUM_REG, iec60958_chstat[2] & 0x0F);
  803. if (ret)
  804. return ret;
  805. ret = regmap_write(ctx->regmap, IT66121_AUD_CHST_CHTNUM_REG,
  806. (iec60958_chstat[2] >> 4) & 0x0F);
  807. if (ret)
  808. return ret;
  809. ret = regmap_write(ctx->regmap, IT66121_AUD_CHST_CA_FS_REG, iec60958_chstat[3]);
  810. if (ret)
  811. return ret;
  812. return regmap_write(ctx->regmap, IT66121_AUD_CHST_OFS_WL_REG, iec60958_chstat[4]);
  813. }
  814. static int it661221_set_lpcm_audio(struct it66121_ctx *ctx, u8 audio_src_num, u8 audio_swl)
  815. {
  816. int ret;
  817. unsigned int audio_enable = 0;
  818. unsigned int audio_format = 0;
  819. switch (audio_swl) {
  820. case 16:
  821. audio_enable |= IT66121_AUD_16BIT;
  822. break;
  823. case 18:
  824. audio_enable |= IT66121_AUD_18BIT;
  825. break;
  826. case 20:
  827. audio_enable |= IT66121_AUD_20BIT;
  828. break;
  829. case 24:
  830. default:
  831. audio_enable |= IT66121_AUD_24BIT;
  832. break;
  833. }
  834. audio_format |= 0x40;
  835. switch (audio_src_num) {
  836. case 4:
  837. audio_enable |= IT66121_AUD_EN_I2S3 | IT66121_AUD_EN_I2S2 |
  838. IT66121_AUD_EN_I2S1 | IT66121_AUD_EN_I2S0;
  839. break;
  840. case 3:
  841. audio_enable |= IT66121_AUD_EN_I2S2 | IT66121_AUD_EN_I2S1 |
  842. IT66121_AUD_EN_I2S0;
  843. break;
  844. case 2:
  845. audio_enable |= IT66121_AUD_EN_I2S1 | IT66121_AUD_EN_I2S0;
  846. break;
  847. case 1:
  848. default:
  849. audio_format &= ~0x40;
  850. audio_enable |= IT66121_AUD_EN_I2S0;
  851. break;
  852. }
  853. audio_format |= 0x01;
  854. ctx->audio.ch_enable = audio_enable;
  855. ret = regmap_write(ctx->regmap, IT66121_AUD_CTRL0_REG, audio_enable & 0xF0);
  856. if (ret)
  857. return ret;
  858. ret = regmap_write(ctx->regmap, IT66121_AUD_CTRL1_REG, audio_format);
  859. if (ret)
  860. return ret;
  861. ret = regmap_write(ctx->regmap, IT66121_AUD_FIFOMAP_REG, 0xE4);
  862. if (ret)
  863. return ret;
  864. ret = regmap_write(ctx->regmap, IT66121_AUD_CTRL3_REG, 0x00);
  865. if (ret)
  866. return ret;
  867. ret = regmap_write(ctx->regmap, IT66121_AUD_SRCVALID_FLAT_REG, 0x00);
  868. if (ret)
  869. return ret;
  870. return regmap_write(ctx->regmap, IT66121_AUD_HDAUDIO_REG, 0x00);
  871. }
  872. static int it661221_set_ncts(struct it66121_ctx *ctx, u8 fs)
  873. {
  874. int ret;
  875. unsigned int n;
  876. switch (fs) {
  877. case IT66121_AUD_FS_32K:
  878. n = 4096;
  879. break;
  880. case IT66121_AUD_FS_44P1K:
  881. n = 6272;
  882. break;
  883. case IT66121_AUD_FS_48K:
  884. n = 6144;
  885. break;
  886. case IT66121_AUD_FS_88P2K:
  887. n = 12544;
  888. break;
  889. case IT66121_AUD_FS_96K:
  890. n = 12288;
  891. break;
  892. case IT66121_AUD_FS_176P4K:
  893. n = 25088;
  894. break;
  895. case IT66121_AUD_FS_192K:
  896. n = 24576;
  897. break;
  898. case IT66121_AUD_FS_768K:
  899. n = 24576;
  900. break;
  901. default:
  902. n = 6144;
  903. break;
  904. }
  905. ret = regmap_write(ctx->regmap, IT66121_AUD_PKT_N0_REG, (u8)((n) & 0xFF));
  906. if (ret)
  907. return ret;
  908. ret = regmap_write(ctx->regmap, IT66121_AUD_PKT_N1_REG, (u8)((n >> 8) & 0xFF));
  909. if (ret)
  910. return ret;
  911. ret = regmap_write(ctx->regmap, IT66121_AUD_PKT_N2_REG, (u8)((n >> 16) & 0xF));
  912. if (ret)
  913. return ret;
  914. if (ctx->audio.auto_cts) {
  915. u8 loop_cnt = 255;
  916. u8 cts_stable_cnt = 0;
  917. unsigned int sum_cts = 0;
  918. unsigned int cts = 0;
  919. unsigned int last_cts = 0;
  920. unsigned int diff;
  921. unsigned int val;
  922. while (loop_cnt--) {
  923. msleep(30);
  924. regmap_read(ctx->regmap, IT66121_AUD_PKT_CTS_CNT2_REG, &val);
  925. cts = val << 12;
  926. regmap_read(ctx->regmap, IT66121_AUD_PKT_CTS_CNT1_REG, &val);
  927. cts |= val << 4;
  928. regmap_read(ctx->regmap, IT66121_AUD_PKT_CTS_CNT0_REG, &val);
  929. cts |= val >> 4;
  930. if (cts == 0) {
  931. continue;
  932. } else {
  933. if (last_cts > cts)
  934. diff = last_cts - cts;
  935. else
  936. diff = cts - last_cts;
  937. last_cts = cts;
  938. if (diff < 5) {
  939. cts_stable_cnt++;
  940. sum_cts += cts;
  941. } else {
  942. cts_stable_cnt = 0;
  943. sum_cts = 0;
  944. continue;
  945. }
  946. if (cts_stable_cnt >= 32) {
  947. last_cts = (sum_cts >> 5);
  948. break;
  949. }
  950. }
  951. }
  952. regmap_write(ctx->regmap, IT66121_AUD_PKT_CTS0_REG, (u8)((last_cts) & 0xFF));
  953. regmap_write(ctx->regmap, IT66121_AUD_PKT_CTS1_REG, (u8)((last_cts >> 8) & 0xFF));
  954. regmap_write(ctx->regmap, IT66121_AUD_PKT_CTS2_REG, (u8)((last_cts >> 16) & 0x0F));
  955. }
  956. ret = regmap_write(ctx->regmap, 0xF8, 0xC3);
  957. if (ret)
  958. return ret;
  959. ret = regmap_write(ctx->regmap, 0xF8, 0xA5);
  960. if (ret)
  961. return ret;
  962. if (ctx->audio.auto_cts) {
  963. ret = regmap_write_bits(ctx->regmap, IT66121_PKT_CTS_CTRL_REG,
  964. IT66121_PKT_CTS_CTRL_SEL,
  965. 1);
  966. } else {
  967. ret = regmap_write_bits(ctx->regmap, IT66121_PKT_CTS_CTRL_REG,
  968. IT66121_PKT_CTS_CTRL_SEL,
  969. 0);
  970. }
  971. if (ret)
  972. return ret;
  973. return regmap_write(ctx->regmap, 0xF8, 0xFF);
  974. }
  975. static int it661221_audio_output_enable(struct it66121_ctx *ctx, bool enable)
  976. {
  977. int ret;
  978. if (enable) {
  979. ret = regmap_write_bits(ctx->regmap, IT66121_SW_RST_REG,
  980. IT66121_SW_RST_AUD | IT66121_SW_RST_AREF,
  981. 0);
  982. if (ret)
  983. return ret;
  984. ret = regmap_write_bits(ctx->regmap, IT66121_AUD_CTRL0_REG,
  985. IT66121_AUD_EN_I2S3 | IT66121_AUD_EN_I2S2 |
  986. IT66121_AUD_EN_I2S1 | IT66121_AUD_EN_I2S0,
  987. ctx->audio.ch_enable);
  988. } else {
  989. ret = regmap_write_bits(ctx->regmap, IT66121_AUD_CTRL0_REG,
  990. IT66121_AUD_EN_I2S3 | IT66121_AUD_EN_I2S2 |
  991. IT66121_AUD_EN_I2S1 | IT66121_AUD_EN_I2S0,
  992. ctx->audio.ch_enable & 0xF0);
  993. if (ret)
  994. return ret;
  995. ret = regmap_write_bits(ctx->regmap, IT66121_SW_RST_REG,
  996. IT66121_SW_RST_AUD | IT66121_SW_RST_AREF,
  997. IT66121_SW_RST_AUD | IT66121_SW_RST_AREF);
  998. }
  999. return ret;
  1000. }
  1001. static int it661221_audio_ch_enable(struct it66121_ctx *ctx, bool enable)
  1002. {
  1003. int ret;
  1004. if (enable) {
  1005. ret = regmap_write(ctx->regmap, IT66121_AUD_SRCVALID_FLAT_REG, 0);
  1006. if (ret)
  1007. return ret;
  1008. ret = regmap_write(ctx->regmap, IT66121_AUD_CTRL0_REG, ctx->audio.ch_enable);
  1009. } else {
  1010. ret = regmap_write(ctx->regmap, IT66121_AUD_CTRL0_REG, ctx->audio.ch_enable & 0xF0);
  1011. }
  1012. return ret;
  1013. }
  1014. static int it66121_audio_hw_params(struct device *dev, void *data,
  1015. struct hdmi_codec_daifmt *daifmt,
  1016. struct hdmi_codec_params *params)
  1017. {
  1018. u8 fs;
  1019. u8 swl;
  1020. int ret;
  1021. struct it66121_ctx *ctx = dev_get_drvdata(dev);
  1022. static u8 iec60958_chstat[5];
  1023. unsigned int channels = params->channels;
  1024. unsigned int sample_rate = params->sample_rate;
  1025. unsigned int sample_width = params->sample_width;
  1026. mutex_lock(&ctx->lock);
  1027. dev_dbg(dev, "%s: %u, %u, %u, %u\n", __func__,
  1028. daifmt->fmt, sample_rate, sample_width, channels);
  1029. switch (daifmt->fmt) {
  1030. case HDMI_I2S:
  1031. dev_dbg(dev, "Using HDMI I2S\n");
  1032. break;
  1033. default:
  1034. dev_err(dev, "Invalid or unsupported DAI format %d\n", daifmt->fmt);
  1035. ret = -EINVAL;
  1036. goto out;
  1037. }
  1038. // Set audio clock recovery (N/CTS)
  1039. ret = regmap_write(ctx->regmap, IT66121_CLK_CTRL0_REG,
  1040. IT66121_CLK_CTRL0_AUTO_OVER_SAMPLING |
  1041. IT66121_CLK_CTRL0_EXT_MCLK_256FS |
  1042. IT66121_CLK_CTRL0_AUTO_IPCLK);
  1043. if (ret)
  1044. goto out;
  1045. ret = regmap_write_bits(ctx->regmap, IT66121_AUD_CTRL0_REG,
  1046. IT66121_AUD_CTRL0_AUD_SEL, 0); // remove spdif selection
  1047. if (ret)
  1048. goto out;
  1049. switch (sample_rate) {
  1050. case 44100L:
  1051. fs = IT66121_AUD_FS_44P1K;
  1052. break;
  1053. case 88200L:
  1054. fs = IT66121_AUD_FS_88P2K;
  1055. break;
  1056. case 176400L:
  1057. fs = IT66121_AUD_FS_176P4K;
  1058. break;
  1059. case 32000L:
  1060. fs = IT66121_AUD_FS_32K;
  1061. break;
  1062. case 48000L:
  1063. fs = IT66121_AUD_FS_48K;
  1064. break;
  1065. case 96000L:
  1066. fs = IT66121_AUD_FS_96K;
  1067. break;
  1068. case 192000L:
  1069. fs = IT66121_AUD_FS_192K;
  1070. break;
  1071. case 768000L:
  1072. fs = IT66121_AUD_FS_768K;
  1073. break;
  1074. default:
  1075. fs = IT66121_AUD_FS_48K;
  1076. break;
  1077. }
  1078. ctx->audio.fs = fs;
  1079. ret = it661221_set_ncts(ctx, fs);
  1080. if (ret) {
  1081. dev_err(dev, "Failed to set N/CTS: %d\n", ret);
  1082. goto out;
  1083. }
  1084. // Set audio format register (except audio channel enable)
  1085. ret = it661221_set_lpcm_audio(ctx, (channels + 1) / 2, sample_width);
  1086. if (ret) {
  1087. dev_err(dev, "Failed to set LPCM audio: %d\n", ret);
  1088. goto out;
  1089. }
  1090. // Set audio channel status
  1091. iec60958_chstat[0] = 0;
  1092. if ((channels + 1) / 2 == 1)
  1093. iec60958_chstat[0] |= 0x1;
  1094. iec60958_chstat[0] &= ~(1 << 1);
  1095. iec60958_chstat[1] = 0;
  1096. iec60958_chstat[2] = (channels + 1) / 2;
  1097. iec60958_chstat[2] |= (channels << 4) & 0xF0;
  1098. iec60958_chstat[3] = fs;
  1099. switch (sample_width) {
  1100. case 21L:
  1101. swl = IT66121_AUD_SWL_21BIT;
  1102. break;
  1103. case 24L:
  1104. swl = IT66121_AUD_SWL_24BIT;
  1105. break;
  1106. case 23L:
  1107. swl = IT66121_AUD_SWL_23BIT;
  1108. break;
  1109. case 22L:
  1110. swl = IT66121_AUD_SWL_22BIT;
  1111. break;
  1112. case 20L:
  1113. swl = IT66121_AUD_SWL_20BIT;
  1114. break;
  1115. case 17L:
  1116. swl = IT66121_AUD_SWL_17BIT;
  1117. break;
  1118. case 19L:
  1119. swl = IT66121_AUD_SWL_19BIT;
  1120. break;
  1121. case 18L:
  1122. swl = IT66121_AUD_SWL_18BIT;
  1123. break;
  1124. case 16L:
  1125. swl = IT66121_AUD_SWL_16BIT;
  1126. break;
  1127. default:
  1128. swl = IT66121_AUD_SWL_NOT_INDICATED;
  1129. break;
  1130. }
  1131. iec60958_chstat[4] = (((~fs) << 4) & 0xF0) | swl;
  1132. ret = it661221_set_chstat(ctx, iec60958_chstat);
  1133. if (ret) {
  1134. dev_err(dev, "Failed to set channel status: %d\n", ret);
  1135. goto out;
  1136. }
  1137. // Enable audio channel enable while input clock stable (if SPDIF).
  1138. ret = it661221_audio_ch_enable(ctx, true);
  1139. if (ret) {
  1140. dev_err(dev, "Failed to enable audio channel: %d\n", ret);
  1141. goto out;
  1142. }
  1143. ret = regmap_write_bits(ctx->regmap, IT66121_INT_MASK1_REG,
  1144. IT66121_INT_MASK1_AUD_OVF,
  1145. 0);
  1146. if (ret)
  1147. goto out;
  1148. dev_dbg(dev, "HDMI audio enabled.\n");
  1149. out:
  1150. mutex_unlock(&ctx->lock);
  1151. return ret;
  1152. }
  1153. static int it66121_audio_startup(struct device *dev, void *data)
  1154. {
  1155. int ret;
  1156. struct it66121_ctx *ctx = dev_get_drvdata(dev);
  1157. dev_dbg(dev, "%s\n", __func__);
  1158. mutex_lock(&ctx->lock);
  1159. ret = it661221_audio_output_enable(ctx, true);
  1160. if (ret)
  1161. dev_err(dev, "Failed to enable audio output: %d\n", ret);
  1162. mutex_unlock(&ctx->lock);
  1163. return ret;
  1164. }
  1165. static void it66121_audio_shutdown(struct device *dev, void *data)
  1166. {
  1167. int ret;
  1168. struct it66121_ctx *ctx = dev_get_drvdata(dev);
  1169. dev_dbg(dev, "%s\n", __func__);
  1170. mutex_lock(&ctx->lock);
  1171. ret = it661221_audio_output_enable(ctx, false);
  1172. if (ret)
  1173. dev_err(dev, "Failed to disable audio output: %d\n", ret);
  1174. mutex_unlock(&ctx->lock);
  1175. }
  1176. static int it66121_audio_mute(struct device *dev, void *data,
  1177. bool enable, int direction)
  1178. {
  1179. int ret;
  1180. struct it66121_ctx *ctx = dev_get_drvdata(dev);
  1181. dev_dbg(dev, "%s: enable=%s, direction=%d\n",
  1182. __func__, enable ? "true" : "false", direction);
  1183. mutex_lock(&ctx->lock);
  1184. if (enable) {
  1185. ret = regmap_write_bits(ctx->regmap, IT66121_AUD_SRCVALID_FLAT_REG,
  1186. IT66121_AUD_FLAT_SRC0 | IT66121_AUD_FLAT_SRC1 |
  1187. IT66121_AUD_FLAT_SRC2 | IT66121_AUD_FLAT_SRC3,
  1188. IT66121_AUD_FLAT_SRC0 | IT66121_AUD_FLAT_SRC1 |
  1189. IT66121_AUD_FLAT_SRC2 | IT66121_AUD_FLAT_SRC3);
  1190. } else {
  1191. ret = regmap_write_bits(ctx->regmap, IT66121_AUD_SRCVALID_FLAT_REG,
  1192. IT66121_AUD_FLAT_SRC0 | IT66121_AUD_FLAT_SRC1 |
  1193. IT66121_AUD_FLAT_SRC2 | IT66121_AUD_FLAT_SRC3,
  1194. 0);
  1195. }
  1196. mutex_unlock(&ctx->lock);
  1197. return ret;
  1198. }
  1199. static int it66121_audio_get_eld(struct device *dev, void *data,
  1200. u8 *buf, size_t len)
  1201. {
  1202. struct it66121_ctx *ctx = dev_get_drvdata(dev);
  1203. mutex_lock(&ctx->lock);
  1204. if (!ctx->connector) {
  1205. /* Pass en empty ELD if connector not available */
  1206. dev_dbg(dev, "No connector present, passing empty EDID data");
  1207. memset(buf, 0, len);
  1208. } else {
  1209. mutex_lock(&ctx->connector->eld_mutex);
  1210. memcpy(buf, ctx->connector->eld,
  1211. min(sizeof(ctx->connector->eld), len));
  1212. mutex_unlock(&ctx->connector->eld_mutex);
  1213. }
  1214. mutex_unlock(&ctx->lock);
  1215. return 0;
  1216. }
  1217. static const struct hdmi_codec_ops it66121_audio_codec_ops = {
  1218. .hw_params = it66121_audio_hw_params,
  1219. .audio_startup = it66121_audio_startup,
  1220. .audio_shutdown = it66121_audio_shutdown,
  1221. .mute_stream = it66121_audio_mute,
  1222. .get_eld = it66121_audio_get_eld,
  1223. .no_capture_mute = 1,
  1224. };
  1225. static int it66121_audio_codec_init(struct it66121_ctx *ctx, struct device *dev)
  1226. {
  1227. struct hdmi_codec_pdata codec_data = {
  1228. .ops = &it66121_audio_codec_ops,
  1229. .i2s = 1, /* Only i2s support for now */
  1230. .spdif = 0,
  1231. .max_i2s_channels = 8,
  1232. };
  1233. dev_dbg(dev, "%s\n", __func__);
  1234. if (!of_property_read_bool(dev->of_node, "#sound-dai-cells")) {
  1235. dev_info(dev, "No \"#sound-dai-cells\", no audio\n");
  1236. return 0;
  1237. }
  1238. ctx->audio.pdev = platform_device_register_data(dev,
  1239. HDMI_CODEC_DRV_NAME,
  1240. PLATFORM_DEVID_AUTO,
  1241. &codec_data,
  1242. sizeof(codec_data));
  1243. if (IS_ERR(ctx->audio.pdev)) {
  1244. dev_err(dev, "Failed to initialize HDMI audio codec: %d\n",
  1245. PTR_ERR_OR_ZERO(ctx->audio.pdev));
  1246. }
  1247. return PTR_ERR_OR_ZERO(ctx->audio.pdev);
  1248. }
  1249. static const char * const it66121_supplies[] = {
  1250. "vcn33", "vcn18", "vrf12"
  1251. };
  1252. static int it66121_probe(struct i2c_client *client)
  1253. {
  1254. u32 revision_id, vendor_ids[2] = { 0 }, device_ids[2] = { 0 };
  1255. struct device_node *ep;
  1256. int ret;
  1257. struct it66121_ctx *ctx;
  1258. struct device *dev = &client->dev;
  1259. if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) {
  1260. dev_err(dev, "I2C check functionality failed.\n");
  1261. return -ENXIO;
  1262. }
  1263. ctx = devm_kzalloc(dev, sizeof(*ctx), GFP_KERNEL);
  1264. if (!ctx)
  1265. return -ENOMEM;
  1266. ep = of_graph_get_endpoint_by_regs(dev->of_node, 0, 0);
  1267. if (!ep)
  1268. return -EINVAL;
  1269. ctx->dev = dev;
  1270. ctx->client = client;
  1271. ctx->info = i2c_get_match_data(client);
  1272. of_property_read_u32(ep, "bus-width", &ctx->bus_width);
  1273. of_node_put(ep);
  1274. if (ctx->bus_width != 12 && ctx->bus_width != 24)
  1275. return -EINVAL;
  1276. ep = of_graph_get_remote_node(dev->of_node, 1, -1);
  1277. if (!ep) {
  1278. dev_err(ctx->dev, "The endpoint is unconnected\n");
  1279. return -EINVAL;
  1280. }
  1281. ctx->next_bridge = of_drm_find_bridge(ep);
  1282. of_node_put(ep);
  1283. if (!ctx->next_bridge) {
  1284. dev_dbg(ctx->dev, "Next bridge not found, deferring probe\n");
  1285. return -EPROBE_DEFER;
  1286. }
  1287. i2c_set_clientdata(client, ctx);
  1288. mutex_init(&ctx->lock);
  1289. ret = devm_regulator_bulk_get_enable(dev, ARRAY_SIZE(it66121_supplies),
  1290. it66121_supplies);
  1291. if (ret) {
  1292. dev_err(dev, "Failed to enable power supplies\n");
  1293. return ret;
  1294. }
  1295. it66121_hw_reset(ctx);
  1296. ctx->regmap = devm_regmap_init_i2c(client, &it66121_regmap_config);
  1297. if (IS_ERR(ctx->regmap))
  1298. return PTR_ERR(ctx->regmap);
  1299. regmap_read(ctx->regmap, IT66121_VENDOR_ID0_REG, &vendor_ids[0]);
  1300. regmap_read(ctx->regmap, IT66121_VENDOR_ID1_REG, &vendor_ids[1]);
  1301. regmap_read(ctx->regmap, IT66121_DEVICE_ID0_REG, &device_ids[0]);
  1302. regmap_read(ctx->regmap, IT66121_DEVICE_ID1_REG, &device_ids[1]);
  1303. /* Revision is shared with DEVICE_ID1 */
  1304. revision_id = FIELD_GET(IT66121_REVISION_MASK, device_ids[1]);
  1305. device_ids[1] &= IT66121_DEVICE_ID1_MASK;
  1306. if ((vendor_ids[1] << 8 | vendor_ids[0]) != ctx->info->vid ||
  1307. (device_ids[1] << 8 | device_ids[0]) != ctx->info->pid) {
  1308. return -ENODEV;
  1309. }
  1310. ctx->bridge.funcs = &it66121_bridge_funcs;
  1311. ctx->bridge.of_node = dev->of_node;
  1312. ctx->bridge.type = DRM_MODE_CONNECTOR_HDMIA;
  1313. ctx->bridge.ops = DRM_BRIDGE_OP_DETECT | DRM_BRIDGE_OP_EDID;
  1314. if (client->irq > 0) {
  1315. ctx->bridge.ops |= DRM_BRIDGE_OP_HPD;
  1316. ret = devm_request_threaded_irq(dev, client->irq, NULL,
  1317. it66121_irq_threaded_handler,
  1318. IRQF_ONESHOT, dev_name(dev),
  1319. ctx);
  1320. if (ret < 0) {
  1321. dev_err(dev, "Failed to request irq %d:%d\n", client->irq, ret);
  1322. return ret;
  1323. }
  1324. }
  1325. it66121_audio_codec_init(ctx, dev);
  1326. drm_bridge_add(&ctx->bridge);
  1327. dev_info(ctx->dev, "IT66121 revision %d probed\n", revision_id);
  1328. return 0;
  1329. }
  1330. static void it66121_remove(struct i2c_client *client)
  1331. {
  1332. struct it66121_ctx *ctx = i2c_get_clientdata(client);
  1333. drm_bridge_remove(&ctx->bridge);
  1334. mutex_destroy(&ctx->lock);
  1335. }
  1336. static const struct it66121_chip_info it66121_chip_info = {
  1337. .id = ID_IT66121,
  1338. .vid = 0x4954,
  1339. .pid = 0x0612,
  1340. };
  1341. static const struct it66121_chip_info it6610_chip_info = {
  1342. .id = ID_IT6610,
  1343. .vid = 0xca00,
  1344. .pid = 0x0611,
  1345. };
  1346. static const struct of_device_id it66121_dt_match[] = {
  1347. { .compatible = "ite,it66121", &it66121_chip_info },
  1348. { .compatible = "ite,it6610", &it6610_chip_info },
  1349. { }
  1350. };
  1351. MODULE_DEVICE_TABLE(of, it66121_dt_match);
  1352. static const struct i2c_device_id it66121_id[] = {
  1353. { "it66121", (kernel_ulong_t) &it66121_chip_info },
  1354. { "it6610", (kernel_ulong_t) &it6610_chip_info },
  1355. { }
  1356. };
  1357. MODULE_DEVICE_TABLE(i2c, it66121_id);
  1358. static struct i2c_driver it66121_driver = {
  1359. .driver = {
  1360. .name = "it66121",
  1361. .of_match_table = it66121_dt_match,
  1362. },
  1363. .probe = it66121_probe,
  1364. .remove = it66121_remove,
  1365. .id_table = it66121_id,
  1366. };
  1367. module_i2c_driver(it66121_driver);
  1368. MODULE_AUTHOR("Phong LE");
  1369. MODULE_DESCRIPTION("IT66121 HDMI transmitter driver");
  1370. MODULE_LICENSE("GPL v2");