dsi.c 43 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717
  1. // SPDX-License-Identifier: GPL-2.0-only
  2. /*
  3. * Copyright (C) 2013 NVIDIA Corporation
  4. */
  5. #include <linux/clk.h>
  6. #include <linux/debugfs.h>
  7. #include <linux/delay.h>
  8. #include <linux/host1x.h>
  9. #include <linux/module.h>
  10. #include <linux/of.h>
  11. #include <linux/of_platform.h>
  12. #include <linux/platform_device.h>
  13. #include <linux/pm_runtime.h>
  14. #include <linux/regulator/consumer.h>
  15. #include <linux/reset.h>
  16. #include <video/mipi_display.h>
  17. #include <drm/drm_atomic_helper.h>
  18. #include <drm/drm_debugfs.h>
  19. #include <drm/drm_file.h>
  20. #include <drm/drm_mipi_dsi.h>
  21. #include <drm/drm_panel.h>
  22. #include <drm/drm_simple_kms_helper.h>
  23. #include "dc.h"
  24. #include "drm.h"
  25. #include "dsi.h"
  26. #include "mipi-phy.h"
  27. #include "trace.h"
  28. struct tegra_dsi_state {
  29. struct drm_connector_state base;
  30. struct mipi_dphy_timing timing;
  31. unsigned long period;
  32. unsigned int vrefresh;
  33. unsigned int lanes;
  34. unsigned long pclk;
  35. unsigned long bclk;
  36. enum tegra_dsi_format format;
  37. unsigned int mul;
  38. unsigned int div;
  39. };
  40. static inline struct tegra_dsi_state *
  41. to_dsi_state(struct drm_connector_state *state)
  42. {
  43. return container_of(state, struct tegra_dsi_state, base);
  44. }
  45. struct tegra_dsi {
  46. struct host1x_client client;
  47. struct tegra_output output;
  48. struct device *dev;
  49. void __iomem *regs;
  50. struct reset_control *rst;
  51. struct clk *clk_parent;
  52. struct clk *clk_lp;
  53. struct clk *clk;
  54. struct drm_info_list *debugfs_files;
  55. unsigned long flags;
  56. enum mipi_dsi_pixel_format format;
  57. unsigned int lanes;
  58. struct tegra_mipi_device *mipi;
  59. struct mipi_dsi_host host;
  60. struct regulator *vdd;
  61. unsigned int video_fifo_depth;
  62. unsigned int host_fifo_depth;
  63. /* for ganged-mode support */
  64. struct tegra_dsi *master;
  65. struct tegra_dsi *slave;
  66. };
  67. static inline struct tegra_dsi *
  68. host1x_client_to_dsi(struct host1x_client *client)
  69. {
  70. return container_of(client, struct tegra_dsi, client);
  71. }
  72. static inline struct tegra_dsi *host_to_tegra(struct mipi_dsi_host *host)
  73. {
  74. return container_of(host, struct tegra_dsi, host);
  75. }
  76. static inline struct tegra_dsi *to_dsi(struct tegra_output *output)
  77. {
  78. return container_of(output, struct tegra_dsi, output);
  79. }
  80. static struct tegra_dsi_state *tegra_dsi_get_state(struct tegra_dsi *dsi)
  81. {
  82. return to_dsi_state(dsi->output.connector.state);
  83. }
  84. static inline u32 tegra_dsi_readl(struct tegra_dsi *dsi, unsigned int offset)
  85. {
  86. u32 value = readl(dsi->regs + (offset << 2));
  87. trace_dsi_readl(dsi->dev, offset, value);
  88. return value;
  89. }
  90. static inline void tegra_dsi_writel(struct tegra_dsi *dsi, u32 value,
  91. unsigned int offset)
  92. {
  93. trace_dsi_writel(dsi->dev, offset, value);
  94. writel(value, dsi->regs + (offset << 2));
  95. }
  96. #define DEBUGFS_REG32(_name) { .name = #_name, .offset = _name }
  97. static const struct debugfs_reg32 tegra_dsi_regs[] = {
  98. DEBUGFS_REG32(DSI_INCR_SYNCPT),
  99. DEBUGFS_REG32(DSI_INCR_SYNCPT_CONTROL),
  100. DEBUGFS_REG32(DSI_INCR_SYNCPT_ERROR),
  101. DEBUGFS_REG32(DSI_CTXSW),
  102. DEBUGFS_REG32(DSI_RD_DATA),
  103. DEBUGFS_REG32(DSI_WR_DATA),
  104. DEBUGFS_REG32(DSI_POWER_CONTROL),
  105. DEBUGFS_REG32(DSI_INT_ENABLE),
  106. DEBUGFS_REG32(DSI_INT_STATUS),
  107. DEBUGFS_REG32(DSI_INT_MASK),
  108. DEBUGFS_REG32(DSI_HOST_CONTROL),
  109. DEBUGFS_REG32(DSI_CONTROL),
  110. DEBUGFS_REG32(DSI_SOL_DELAY),
  111. DEBUGFS_REG32(DSI_MAX_THRESHOLD),
  112. DEBUGFS_REG32(DSI_TRIGGER),
  113. DEBUGFS_REG32(DSI_TX_CRC),
  114. DEBUGFS_REG32(DSI_STATUS),
  115. DEBUGFS_REG32(DSI_INIT_SEQ_CONTROL),
  116. DEBUGFS_REG32(DSI_INIT_SEQ_DATA_0),
  117. DEBUGFS_REG32(DSI_INIT_SEQ_DATA_1),
  118. DEBUGFS_REG32(DSI_INIT_SEQ_DATA_2),
  119. DEBUGFS_REG32(DSI_INIT_SEQ_DATA_3),
  120. DEBUGFS_REG32(DSI_INIT_SEQ_DATA_4),
  121. DEBUGFS_REG32(DSI_INIT_SEQ_DATA_5),
  122. DEBUGFS_REG32(DSI_INIT_SEQ_DATA_6),
  123. DEBUGFS_REG32(DSI_INIT_SEQ_DATA_7),
  124. DEBUGFS_REG32(DSI_PKT_SEQ_0_LO),
  125. DEBUGFS_REG32(DSI_PKT_SEQ_0_HI),
  126. DEBUGFS_REG32(DSI_PKT_SEQ_1_LO),
  127. DEBUGFS_REG32(DSI_PKT_SEQ_1_HI),
  128. DEBUGFS_REG32(DSI_PKT_SEQ_2_LO),
  129. DEBUGFS_REG32(DSI_PKT_SEQ_2_HI),
  130. DEBUGFS_REG32(DSI_PKT_SEQ_3_LO),
  131. DEBUGFS_REG32(DSI_PKT_SEQ_3_HI),
  132. DEBUGFS_REG32(DSI_PKT_SEQ_4_LO),
  133. DEBUGFS_REG32(DSI_PKT_SEQ_4_HI),
  134. DEBUGFS_REG32(DSI_PKT_SEQ_5_LO),
  135. DEBUGFS_REG32(DSI_PKT_SEQ_5_HI),
  136. DEBUGFS_REG32(DSI_DCS_CMDS),
  137. DEBUGFS_REG32(DSI_PKT_LEN_0_1),
  138. DEBUGFS_REG32(DSI_PKT_LEN_2_3),
  139. DEBUGFS_REG32(DSI_PKT_LEN_4_5),
  140. DEBUGFS_REG32(DSI_PKT_LEN_6_7),
  141. DEBUGFS_REG32(DSI_PHY_TIMING_0),
  142. DEBUGFS_REG32(DSI_PHY_TIMING_1),
  143. DEBUGFS_REG32(DSI_PHY_TIMING_2),
  144. DEBUGFS_REG32(DSI_BTA_TIMING),
  145. DEBUGFS_REG32(DSI_TIMEOUT_0),
  146. DEBUGFS_REG32(DSI_TIMEOUT_1),
  147. DEBUGFS_REG32(DSI_TO_TALLY),
  148. DEBUGFS_REG32(DSI_PAD_CONTROL_0),
  149. DEBUGFS_REG32(DSI_PAD_CONTROL_CD),
  150. DEBUGFS_REG32(DSI_PAD_CD_STATUS),
  151. DEBUGFS_REG32(DSI_VIDEO_MODE_CONTROL),
  152. DEBUGFS_REG32(DSI_PAD_CONTROL_1),
  153. DEBUGFS_REG32(DSI_PAD_CONTROL_2),
  154. DEBUGFS_REG32(DSI_PAD_CONTROL_3),
  155. DEBUGFS_REG32(DSI_PAD_CONTROL_4),
  156. DEBUGFS_REG32(DSI_GANGED_MODE_CONTROL),
  157. DEBUGFS_REG32(DSI_GANGED_MODE_START),
  158. DEBUGFS_REG32(DSI_GANGED_MODE_SIZE),
  159. DEBUGFS_REG32(DSI_RAW_DATA_BYTE_COUNT),
  160. DEBUGFS_REG32(DSI_ULTRA_LOW_POWER_CONTROL),
  161. DEBUGFS_REG32(DSI_INIT_SEQ_DATA_8),
  162. DEBUGFS_REG32(DSI_INIT_SEQ_DATA_9),
  163. DEBUGFS_REG32(DSI_INIT_SEQ_DATA_10),
  164. DEBUGFS_REG32(DSI_INIT_SEQ_DATA_11),
  165. DEBUGFS_REG32(DSI_INIT_SEQ_DATA_12),
  166. DEBUGFS_REG32(DSI_INIT_SEQ_DATA_13),
  167. DEBUGFS_REG32(DSI_INIT_SEQ_DATA_14),
  168. DEBUGFS_REG32(DSI_INIT_SEQ_DATA_15),
  169. };
  170. static int tegra_dsi_show_regs(struct seq_file *s, void *data)
  171. {
  172. struct drm_info_node *node = s->private;
  173. struct tegra_dsi *dsi = node->info_ent->data;
  174. struct drm_crtc *crtc = dsi->output.encoder.crtc;
  175. struct drm_device *drm = node->minor->dev;
  176. unsigned int i;
  177. int err = 0;
  178. drm_modeset_lock_all(drm);
  179. if (!crtc || !crtc->state->active) {
  180. err = -EBUSY;
  181. goto unlock;
  182. }
  183. for (i = 0; i < ARRAY_SIZE(tegra_dsi_regs); i++) {
  184. unsigned int offset = tegra_dsi_regs[i].offset;
  185. seq_printf(s, "%-32s %#05x %08x\n", tegra_dsi_regs[i].name,
  186. offset, tegra_dsi_readl(dsi, offset));
  187. }
  188. unlock:
  189. drm_modeset_unlock_all(drm);
  190. return err;
  191. }
  192. static struct drm_info_list debugfs_files[] = {
  193. { "regs", tegra_dsi_show_regs, 0, NULL },
  194. };
  195. static int tegra_dsi_late_register(struct drm_connector *connector)
  196. {
  197. struct tegra_output *output = connector_to_output(connector);
  198. unsigned int i, count = ARRAY_SIZE(debugfs_files);
  199. struct drm_minor *minor = connector->dev->primary;
  200. struct dentry *root = connector->debugfs_entry;
  201. struct tegra_dsi *dsi = to_dsi(output);
  202. dsi->debugfs_files = kmemdup(debugfs_files, sizeof(debugfs_files),
  203. GFP_KERNEL);
  204. if (!dsi->debugfs_files)
  205. return -ENOMEM;
  206. for (i = 0; i < count; i++)
  207. dsi->debugfs_files[i].data = dsi;
  208. drm_debugfs_create_files(dsi->debugfs_files, count, root, minor);
  209. return 0;
  210. }
  211. static void tegra_dsi_early_unregister(struct drm_connector *connector)
  212. {
  213. struct tegra_output *output = connector_to_output(connector);
  214. unsigned int count = ARRAY_SIZE(debugfs_files);
  215. struct tegra_dsi *dsi = to_dsi(output);
  216. drm_debugfs_remove_files(dsi->debugfs_files, count,
  217. connector->debugfs_entry,
  218. connector->dev->primary);
  219. kfree(dsi->debugfs_files);
  220. dsi->debugfs_files = NULL;
  221. }
  222. #define PKT_ID0(id) ((((id) & 0x3f) << 3) | (1 << 9))
  223. #define PKT_LEN0(len) (((len) & 0x07) << 0)
  224. #define PKT_ID1(id) ((((id) & 0x3f) << 13) | (1 << 19))
  225. #define PKT_LEN1(len) (((len) & 0x07) << 10)
  226. #define PKT_ID2(id) ((((id) & 0x3f) << 23) | (1 << 29))
  227. #define PKT_LEN2(len) (((len) & 0x07) << 20)
  228. #define PKT_LP (1 << 30)
  229. #define NUM_PKT_SEQ 12
  230. /*
  231. * non-burst mode with sync pulses
  232. */
  233. static const u32 pkt_seq_video_non_burst_sync_pulses[NUM_PKT_SEQ] = {
  234. [ 0] = PKT_ID0(MIPI_DSI_V_SYNC_START) | PKT_LEN0(0) |
  235. PKT_ID1(MIPI_DSI_BLANKING_PACKET) | PKT_LEN1(1) |
  236. PKT_ID2(MIPI_DSI_H_SYNC_END) | PKT_LEN2(0) |
  237. PKT_LP,
  238. [ 1] = 0,
  239. [ 2] = PKT_ID0(MIPI_DSI_V_SYNC_END) | PKT_LEN0(0) |
  240. PKT_ID1(MIPI_DSI_BLANKING_PACKET) | PKT_LEN1(1) |
  241. PKT_ID2(MIPI_DSI_H_SYNC_END) | PKT_LEN2(0) |
  242. PKT_LP,
  243. [ 3] = 0,
  244. [ 4] = PKT_ID0(MIPI_DSI_H_SYNC_START) | PKT_LEN0(0) |
  245. PKT_ID1(MIPI_DSI_BLANKING_PACKET) | PKT_LEN1(1) |
  246. PKT_ID2(MIPI_DSI_H_SYNC_END) | PKT_LEN2(0) |
  247. PKT_LP,
  248. [ 5] = 0,
  249. [ 6] = PKT_ID0(MIPI_DSI_H_SYNC_START) | PKT_LEN0(0) |
  250. PKT_ID1(MIPI_DSI_BLANKING_PACKET) | PKT_LEN1(1) |
  251. PKT_ID2(MIPI_DSI_H_SYNC_END) | PKT_LEN2(0),
  252. [ 7] = PKT_ID0(MIPI_DSI_BLANKING_PACKET) | PKT_LEN0(2) |
  253. PKT_ID1(MIPI_DSI_PACKED_PIXEL_STREAM_24) | PKT_LEN1(3) |
  254. PKT_ID2(MIPI_DSI_BLANKING_PACKET) | PKT_LEN2(4),
  255. [ 8] = PKT_ID0(MIPI_DSI_H_SYNC_START) | PKT_LEN0(0) |
  256. PKT_ID1(MIPI_DSI_BLANKING_PACKET) | PKT_LEN1(1) |
  257. PKT_ID2(MIPI_DSI_H_SYNC_END) | PKT_LEN2(0) |
  258. PKT_LP,
  259. [ 9] = 0,
  260. [10] = PKT_ID0(MIPI_DSI_H_SYNC_START) | PKT_LEN0(0) |
  261. PKT_ID1(MIPI_DSI_BLANKING_PACKET) | PKT_LEN1(1) |
  262. PKT_ID2(MIPI_DSI_H_SYNC_END) | PKT_LEN2(0),
  263. [11] = PKT_ID0(MIPI_DSI_BLANKING_PACKET) | PKT_LEN0(2) |
  264. PKT_ID1(MIPI_DSI_PACKED_PIXEL_STREAM_24) | PKT_LEN1(3) |
  265. PKT_ID2(MIPI_DSI_BLANKING_PACKET) | PKT_LEN2(4),
  266. };
  267. /*
  268. * non-burst mode with sync events
  269. */
  270. static const u32 pkt_seq_video_non_burst_sync_events[NUM_PKT_SEQ] = {
  271. [ 0] = PKT_ID0(MIPI_DSI_V_SYNC_START) | PKT_LEN0(0) |
  272. PKT_ID1(MIPI_DSI_END_OF_TRANSMISSION) | PKT_LEN1(7) |
  273. PKT_LP,
  274. [ 1] = 0,
  275. [ 2] = PKT_ID0(MIPI_DSI_H_SYNC_START) | PKT_LEN0(0) |
  276. PKT_ID1(MIPI_DSI_END_OF_TRANSMISSION) | PKT_LEN1(7) |
  277. PKT_LP,
  278. [ 3] = 0,
  279. [ 4] = PKT_ID0(MIPI_DSI_H_SYNC_START) | PKT_LEN0(0) |
  280. PKT_ID1(MIPI_DSI_END_OF_TRANSMISSION) | PKT_LEN1(7) |
  281. PKT_LP,
  282. [ 5] = 0,
  283. [ 6] = PKT_ID0(MIPI_DSI_H_SYNC_START) | PKT_LEN0(0) |
  284. PKT_ID1(MIPI_DSI_BLANKING_PACKET) | PKT_LEN1(2) |
  285. PKT_ID2(MIPI_DSI_PACKED_PIXEL_STREAM_24) | PKT_LEN2(3),
  286. [ 7] = PKT_ID0(MIPI_DSI_BLANKING_PACKET) | PKT_LEN0(4),
  287. [ 8] = PKT_ID0(MIPI_DSI_H_SYNC_START) | PKT_LEN0(0) |
  288. PKT_ID1(MIPI_DSI_END_OF_TRANSMISSION) | PKT_LEN1(7) |
  289. PKT_LP,
  290. [ 9] = 0,
  291. [10] = PKT_ID0(MIPI_DSI_H_SYNC_START) | PKT_LEN0(0) |
  292. PKT_ID1(MIPI_DSI_BLANKING_PACKET) | PKT_LEN1(2) |
  293. PKT_ID2(MIPI_DSI_PACKED_PIXEL_STREAM_24) | PKT_LEN2(3),
  294. [11] = PKT_ID0(MIPI_DSI_BLANKING_PACKET) | PKT_LEN0(4),
  295. };
  296. static const u32 pkt_seq_command_mode[NUM_PKT_SEQ] = {
  297. [ 0] = 0,
  298. [ 1] = 0,
  299. [ 2] = 0,
  300. [ 3] = 0,
  301. [ 4] = 0,
  302. [ 5] = 0,
  303. [ 6] = PKT_ID0(MIPI_DSI_DCS_LONG_WRITE) | PKT_LEN0(3) | PKT_LP,
  304. [ 7] = 0,
  305. [ 8] = 0,
  306. [ 9] = 0,
  307. [10] = PKT_ID0(MIPI_DSI_DCS_LONG_WRITE) | PKT_LEN0(5) | PKT_LP,
  308. [11] = 0,
  309. };
  310. static void tegra_dsi_set_phy_timing(struct tegra_dsi *dsi,
  311. unsigned long period,
  312. const struct mipi_dphy_timing *timing)
  313. {
  314. u32 value;
  315. value = DSI_TIMING_FIELD(timing->hsexit, period, 1) << 24 |
  316. DSI_TIMING_FIELD(timing->hstrail, period, 0) << 16 |
  317. DSI_TIMING_FIELD(timing->hszero, period, 3) << 8 |
  318. DSI_TIMING_FIELD(timing->hsprepare, period, 1);
  319. tegra_dsi_writel(dsi, value, DSI_PHY_TIMING_0);
  320. value = DSI_TIMING_FIELD(timing->clktrail, period, 1) << 24 |
  321. DSI_TIMING_FIELD(timing->clkpost, period, 1) << 16 |
  322. DSI_TIMING_FIELD(timing->clkzero, period, 1) << 8 |
  323. DSI_TIMING_FIELD(timing->lpx, period, 1);
  324. tegra_dsi_writel(dsi, value, DSI_PHY_TIMING_1);
  325. value = DSI_TIMING_FIELD(timing->clkprepare, period, 1) << 16 |
  326. DSI_TIMING_FIELD(timing->clkpre, period, 1) << 8 |
  327. DSI_TIMING_FIELD(0xff * period, period, 0) << 0;
  328. tegra_dsi_writel(dsi, value, DSI_PHY_TIMING_2);
  329. value = DSI_TIMING_FIELD(timing->taget, period, 1) << 16 |
  330. DSI_TIMING_FIELD(timing->tasure, period, 1) << 8 |
  331. DSI_TIMING_FIELD(timing->tago, period, 1);
  332. tegra_dsi_writel(dsi, value, DSI_BTA_TIMING);
  333. if (dsi->slave)
  334. tegra_dsi_set_phy_timing(dsi->slave, period, timing);
  335. }
  336. static int tegra_dsi_get_muldiv(enum mipi_dsi_pixel_format format,
  337. unsigned int *mulp, unsigned int *divp)
  338. {
  339. switch (format) {
  340. case MIPI_DSI_FMT_RGB666_PACKED:
  341. case MIPI_DSI_FMT_RGB888:
  342. *mulp = 3;
  343. *divp = 1;
  344. break;
  345. case MIPI_DSI_FMT_RGB565:
  346. *mulp = 2;
  347. *divp = 1;
  348. break;
  349. case MIPI_DSI_FMT_RGB666:
  350. *mulp = 9;
  351. *divp = 4;
  352. break;
  353. default:
  354. return -EINVAL;
  355. }
  356. return 0;
  357. }
  358. static int tegra_dsi_get_format(enum mipi_dsi_pixel_format format,
  359. enum tegra_dsi_format *fmt)
  360. {
  361. switch (format) {
  362. case MIPI_DSI_FMT_RGB888:
  363. *fmt = TEGRA_DSI_FORMAT_24P;
  364. break;
  365. case MIPI_DSI_FMT_RGB666:
  366. *fmt = TEGRA_DSI_FORMAT_18NP;
  367. break;
  368. case MIPI_DSI_FMT_RGB666_PACKED:
  369. *fmt = TEGRA_DSI_FORMAT_18P;
  370. break;
  371. case MIPI_DSI_FMT_RGB565:
  372. *fmt = TEGRA_DSI_FORMAT_16P;
  373. break;
  374. default:
  375. return -EINVAL;
  376. }
  377. return 0;
  378. }
  379. static void tegra_dsi_ganged_enable(struct tegra_dsi *dsi, unsigned int start,
  380. unsigned int size)
  381. {
  382. u32 value;
  383. tegra_dsi_writel(dsi, start, DSI_GANGED_MODE_START);
  384. tegra_dsi_writel(dsi, size << 16 | size, DSI_GANGED_MODE_SIZE);
  385. value = DSI_GANGED_MODE_CONTROL_ENABLE;
  386. tegra_dsi_writel(dsi, value, DSI_GANGED_MODE_CONTROL);
  387. }
  388. static void tegra_dsi_enable(struct tegra_dsi *dsi)
  389. {
  390. u32 value;
  391. value = tegra_dsi_readl(dsi, DSI_POWER_CONTROL);
  392. value |= DSI_POWER_CONTROL_ENABLE;
  393. tegra_dsi_writel(dsi, value, DSI_POWER_CONTROL);
  394. if (dsi->slave)
  395. tegra_dsi_enable(dsi->slave);
  396. }
  397. static unsigned int tegra_dsi_get_lanes(struct tegra_dsi *dsi)
  398. {
  399. if (dsi->master)
  400. return dsi->master->lanes + dsi->lanes;
  401. if (dsi->slave)
  402. return dsi->lanes + dsi->slave->lanes;
  403. return dsi->lanes;
  404. }
  405. static void tegra_dsi_configure(struct tegra_dsi *dsi, unsigned int pipe,
  406. const struct drm_display_mode *mode)
  407. {
  408. unsigned int hact, hsw, hbp, hfp, i, mul, div;
  409. struct tegra_dsi_state *state;
  410. const u32 *pkt_seq;
  411. u32 value;
  412. /* XXX: pass in state into this function? */
  413. if (dsi->master)
  414. state = tegra_dsi_get_state(dsi->master);
  415. else
  416. state = tegra_dsi_get_state(dsi);
  417. mul = state->mul;
  418. div = state->div;
  419. if (dsi->flags & MIPI_DSI_MODE_VIDEO_SYNC_PULSE) {
  420. DRM_DEBUG_KMS("Non-burst video mode with sync pulses\n");
  421. pkt_seq = pkt_seq_video_non_burst_sync_pulses;
  422. } else if (dsi->flags & MIPI_DSI_MODE_VIDEO) {
  423. DRM_DEBUG_KMS("Non-burst video mode with sync events\n");
  424. pkt_seq = pkt_seq_video_non_burst_sync_events;
  425. } else {
  426. DRM_DEBUG_KMS("Command mode\n");
  427. pkt_seq = pkt_seq_command_mode;
  428. }
  429. value = DSI_CONTROL_CHANNEL(0) |
  430. DSI_CONTROL_FORMAT(state->format) |
  431. DSI_CONTROL_LANES(dsi->lanes - 1) |
  432. DSI_CONTROL_SOURCE(pipe);
  433. tegra_dsi_writel(dsi, value, DSI_CONTROL);
  434. tegra_dsi_writel(dsi, dsi->video_fifo_depth, DSI_MAX_THRESHOLD);
  435. value = DSI_HOST_CONTROL_HS;
  436. tegra_dsi_writel(dsi, value, DSI_HOST_CONTROL);
  437. value = tegra_dsi_readl(dsi, DSI_CONTROL);
  438. if (dsi->flags & MIPI_DSI_CLOCK_NON_CONTINUOUS)
  439. value |= DSI_CONTROL_HS_CLK_CTRL;
  440. value &= ~DSI_CONTROL_TX_TRIG(3);
  441. /* enable DCS commands for command mode */
  442. if (dsi->flags & MIPI_DSI_MODE_VIDEO)
  443. value &= ~DSI_CONTROL_DCS_ENABLE;
  444. else
  445. value |= DSI_CONTROL_DCS_ENABLE;
  446. value |= DSI_CONTROL_VIDEO_ENABLE;
  447. value &= ~DSI_CONTROL_HOST_ENABLE;
  448. tegra_dsi_writel(dsi, value, DSI_CONTROL);
  449. for (i = 0; i < NUM_PKT_SEQ; i++)
  450. tegra_dsi_writel(dsi, pkt_seq[i], DSI_PKT_SEQ_0_LO + i);
  451. if (dsi->flags & MIPI_DSI_MODE_VIDEO) {
  452. /* horizontal active pixels */
  453. hact = mode->hdisplay * mul / div;
  454. /* horizontal sync width */
  455. hsw = (mode->hsync_end - mode->hsync_start) * mul / div;
  456. /* horizontal back porch */
  457. hbp = (mode->htotal - mode->hsync_end) * mul / div;
  458. if ((dsi->flags & MIPI_DSI_MODE_VIDEO_SYNC_PULSE) == 0)
  459. hbp += hsw;
  460. /* horizontal front porch */
  461. hfp = (mode->hsync_start - mode->hdisplay) * mul / div;
  462. /* subtract packet overhead */
  463. hsw -= 10;
  464. hbp -= 14;
  465. hfp -= 8;
  466. tegra_dsi_writel(dsi, hsw << 16 | 0, DSI_PKT_LEN_0_1);
  467. tegra_dsi_writel(dsi, hact << 16 | hbp, DSI_PKT_LEN_2_3);
  468. tegra_dsi_writel(dsi, hfp, DSI_PKT_LEN_4_5);
  469. tegra_dsi_writel(dsi, 0x0f0f << 16, DSI_PKT_LEN_6_7);
  470. /* set SOL delay (for non-burst mode only) */
  471. tegra_dsi_writel(dsi, 8 * mul / div, DSI_SOL_DELAY);
  472. /* TODO: implement ganged mode */
  473. } else {
  474. u16 bytes;
  475. if (dsi->master || dsi->slave) {
  476. /*
  477. * For ganged mode, assume symmetric left-right mode.
  478. */
  479. bytes = 1 + (mode->hdisplay / 2) * mul / div;
  480. } else {
  481. /* 1 byte (DCS command) + pixel data */
  482. bytes = 1 + mode->hdisplay * mul / div;
  483. }
  484. tegra_dsi_writel(dsi, 0, DSI_PKT_LEN_0_1);
  485. tegra_dsi_writel(dsi, bytes << 16, DSI_PKT_LEN_2_3);
  486. tegra_dsi_writel(dsi, bytes << 16, DSI_PKT_LEN_4_5);
  487. tegra_dsi_writel(dsi, 0, DSI_PKT_LEN_6_7);
  488. value = MIPI_DCS_WRITE_MEMORY_START << 8 |
  489. MIPI_DCS_WRITE_MEMORY_CONTINUE;
  490. tegra_dsi_writel(dsi, value, DSI_DCS_CMDS);
  491. /* set SOL delay */
  492. if (dsi->master || dsi->slave) {
  493. unsigned long delay, bclk, bclk_ganged;
  494. unsigned int lanes = state->lanes;
  495. /* SOL to valid, valid to FIFO and FIFO write delay */
  496. delay = 4 + 4 + 2;
  497. delay = DIV_ROUND_UP(delay * mul, div * lanes);
  498. /* FIFO read delay */
  499. delay = delay + 6;
  500. bclk = DIV_ROUND_UP(mode->htotal * mul, div * lanes);
  501. bclk_ganged = DIV_ROUND_UP(bclk * lanes / 2, lanes);
  502. value = bclk - bclk_ganged + delay + 20;
  503. } else {
  504. /* TODO: revisit for non-ganged mode */
  505. value = 8 * mul / div;
  506. }
  507. tegra_dsi_writel(dsi, value, DSI_SOL_DELAY);
  508. }
  509. if (dsi->slave) {
  510. tegra_dsi_configure(dsi->slave, pipe, mode);
  511. /*
  512. * TODO: Support modes other than symmetrical left-right
  513. * split.
  514. */
  515. tegra_dsi_ganged_enable(dsi, 0, mode->hdisplay / 2);
  516. tegra_dsi_ganged_enable(dsi->slave, mode->hdisplay / 2,
  517. mode->hdisplay / 2);
  518. }
  519. }
  520. static int tegra_dsi_wait_idle(struct tegra_dsi *dsi, unsigned long timeout)
  521. {
  522. u32 value;
  523. timeout = jiffies + msecs_to_jiffies(timeout);
  524. while (time_before(jiffies, timeout)) {
  525. value = tegra_dsi_readl(dsi, DSI_STATUS);
  526. if (value & DSI_STATUS_IDLE)
  527. return 0;
  528. usleep_range(1000, 2000);
  529. }
  530. return -ETIMEDOUT;
  531. }
  532. static void tegra_dsi_video_disable(struct tegra_dsi *dsi)
  533. {
  534. u32 value;
  535. value = tegra_dsi_readl(dsi, DSI_CONTROL);
  536. value &= ~DSI_CONTROL_VIDEO_ENABLE;
  537. tegra_dsi_writel(dsi, value, DSI_CONTROL);
  538. if (dsi->slave)
  539. tegra_dsi_video_disable(dsi->slave);
  540. }
  541. static void tegra_dsi_ganged_disable(struct tegra_dsi *dsi)
  542. {
  543. tegra_dsi_writel(dsi, 0, DSI_GANGED_MODE_START);
  544. tegra_dsi_writel(dsi, 0, DSI_GANGED_MODE_SIZE);
  545. tegra_dsi_writel(dsi, 0, DSI_GANGED_MODE_CONTROL);
  546. }
  547. static int tegra_dsi_pad_enable(struct tegra_dsi *dsi)
  548. {
  549. u32 value;
  550. value = DSI_PAD_CONTROL_VS1_PULLDN(0) | DSI_PAD_CONTROL_VS1_PDIO(0);
  551. tegra_dsi_writel(dsi, value, DSI_PAD_CONTROL_0);
  552. return 0;
  553. }
  554. static int tegra_dsi_pad_calibrate(struct tegra_dsi *dsi)
  555. {
  556. u32 value;
  557. int err;
  558. /*
  559. * XXX Is this still needed? The module reset is deasserted right
  560. * before this function is called.
  561. */
  562. tegra_dsi_writel(dsi, 0, DSI_PAD_CONTROL_0);
  563. tegra_dsi_writel(dsi, 0, DSI_PAD_CONTROL_1);
  564. tegra_dsi_writel(dsi, 0, DSI_PAD_CONTROL_2);
  565. tegra_dsi_writel(dsi, 0, DSI_PAD_CONTROL_3);
  566. tegra_dsi_writel(dsi, 0, DSI_PAD_CONTROL_4);
  567. /* start calibration */
  568. tegra_dsi_pad_enable(dsi);
  569. value = DSI_PAD_SLEW_UP(0x7) | DSI_PAD_SLEW_DN(0x7) |
  570. DSI_PAD_LP_UP(0x1) | DSI_PAD_LP_DN(0x1) |
  571. DSI_PAD_OUT_CLK(0x0);
  572. tegra_dsi_writel(dsi, value, DSI_PAD_CONTROL_2);
  573. value = DSI_PAD_PREEMP_PD_CLK(0x3) | DSI_PAD_PREEMP_PU_CLK(0x3) |
  574. DSI_PAD_PREEMP_PD(0x03) | DSI_PAD_PREEMP_PU(0x3);
  575. tegra_dsi_writel(dsi, value, DSI_PAD_CONTROL_3);
  576. err = tegra_mipi_start_calibration(dsi->mipi);
  577. if (err < 0)
  578. return err;
  579. return tegra_mipi_finish_calibration(dsi->mipi);
  580. }
  581. static void tegra_dsi_set_timeout(struct tegra_dsi *dsi, unsigned long bclk,
  582. unsigned int vrefresh)
  583. {
  584. unsigned int timeout;
  585. u32 value;
  586. /* one frame high-speed transmission timeout */
  587. timeout = (bclk / vrefresh) / 512;
  588. value = DSI_TIMEOUT_LRX(0x2000) | DSI_TIMEOUT_HTX(timeout);
  589. tegra_dsi_writel(dsi, value, DSI_TIMEOUT_0);
  590. /* 2 ms peripheral timeout for panel */
  591. timeout = 2 * bclk / 512 * 1000;
  592. value = DSI_TIMEOUT_PR(timeout) | DSI_TIMEOUT_TA(0x2000);
  593. tegra_dsi_writel(dsi, value, DSI_TIMEOUT_1);
  594. value = DSI_TALLY_TA(0) | DSI_TALLY_LRX(0) | DSI_TALLY_HTX(0);
  595. tegra_dsi_writel(dsi, value, DSI_TO_TALLY);
  596. if (dsi->slave)
  597. tegra_dsi_set_timeout(dsi->slave, bclk, vrefresh);
  598. }
  599. static void tegra_dsi_disable(struct tegra_dsi *dsi)
  600. {
  601. u32 value;
  602. if (dsi->slave) {
  603. tegra_dsi_ganged_disable(dsi->slave);
  604. tegra_dsi_ganged_disable(dsi);
  605. }
  606. value = tegra_dsi_readl(dsi, DSI_POWER_CONTROL);
  607. value &= ~DSI_POWER_CONTROL_ENABLE;
  608. tegra_dsi_writel(dsi, value, DSI_POWER_CONTROL);
  609. if (dsi->slave)
  610. tegra_dsi_disable(dsi->slave);
  611. usleep_range(5000, 10000);
  612. }
  613. static void tegra_dsi_soft_reset(struct tegra_dsi *dsi)
  614. {
  615. u32 value;
  616. value = tegra_dsi_readl(dsi, DSI_POWER_CONTROL);
  617. value &= ~DSI_POWER_CONTROL_ENABLE;
  618. tegra_dsi_writel(dsi, value, DSI_POWER_CONTROL);
  619. usleep_range(300, 1000);
  620. value = tegra_dsi_readl(dsi, DSI_POWER_CONTROL);
  621. value |= DSI_POWER_CONTROL_ENABLE;
  622. tegra_dsi_writel(dsi, value, DSI_POWER_CONTROL);
  623. usleep_range(300, 1000);
  624. value = tegra_dsi_readl(dsi, DSI_TRIGGER);
  625. if (value)
  626. tegra_dsi_writel(dsi, 0, DSI_TRIGGER);
  627. if (dsi->slave)
  628. tegra_dsi_soft_reset(dsi->slave);
  629. }
  630. static void tegra_dsi_connector_reset(struct drm_connector *connector)
  631. {
  632. struct tegra_dsi_state *state = kzalloc(sizeof(*state), GFP_KERNEL);
  633. if (!state)
  634. return;
  635. if (connector->state) {
  636. __drm_atomic_helper_connector_destroy_state(connector->state);
  637. kfree(connector->state);
  638. }
  639. __drm_atomic_helper_connector_reset(connector, &state->base);
  640. }
  641. static struct drm_connector_state *
  642. tegra_dsi_connector_duplicate_state(struct drm_connector *connector)
  643. {
  644. struct tegra_dsi_state *state = to_dsi_state(connector->state);
  645. struct tegra_dsi_state *copy;
  646. copy = kmemdup(state, sizeof(*state), GFP_KERNEL);
  647. if (!copy)
  648. return NULL;
  649. __drm_atomic_helper_connector_duplicate_state(connector,
  650. &copy->base);
  651. return &copy->base;
  652. }
  653. static const struct drm_connector_funcs tegra_dsi_connector_funcs = {
  654. .reset = tegra_dsi_connector_reset,
  655. .detect = tegra_output_connector_detect,
  656. .fill_modes = drm_helper_probe_single_connector_modes,
  657. .destroy = tegra_output_connector_destroy,
  658. .atomic_duplicate_state = tegra_dsi_connector_duplicate_state,
  659. .atomic_destroy_state = drm_atomic_helper_connector_destroy_state,
  660. .late_register = tegra_dsi_late_register,
  661. .early_unregister = tegra_dsi_early_unregister,
  662. };
  663. static enum drm_mode_status
  664. tegra_dsi_connector_mode_valid(struct drm_connector *connector,
  665. struct drm_display_mode *mode)
  666. {
  667. return MODE_OK;
  668. }
  669. static const struct drm_connector_helper_funcs tegra_dsi_connector_helper_funcs = {
  670. .get_modes = tegra_output_connector_get_modes,
  671. .mode_valid = tegra_dsi_connector_mode_valid,
  672. };
  673. static void tegra_dsi_unprepare(struct tegra_dsi *dsi)
  674. {
  675. int err;
  676. if (dsi->slave)
  677. tegra_dsi_unprepare(dsi->slave);
  678. err = tegra_mipi_disable(dsi->mipi);
  679. if (err < 0)
  680. dev_err(dsi->dev, "failed to disable MIPI calibration: %d\n",
  681. err);
  682. err = host1x_client_suspend(&dsi->client);
  683. if (err < 0)
  684. dev_err(dsi->dev, "failed to suspend: %d\n", err);
  685. }
  686. static void tegra_dsi_encoder_disable(struct drm_encoder *encoder)
  687. {
  688. struct tegra_output *output = encoder_to_output(encoder);
  689. struct tegra_dc *dc = to_tegra_dc(encoder->crtc);
  690. struct tegra_dsi *dsi = to_dsi(output);
  691. u32 value;
  692. int err;
  693. if (output->panel)
  694. drm_panel_disable(output->panel);
  695. tegra_dsi_video_disable(dsi);
  696. /*
  697. * The following accesses registers of the display controller, so make
  698. * sure it's only executed when the output is attached to one.
  699. */
  700. if (dc) {
  701. value = tegra_dc_readl(dc, DC_DISP_DISP_WIN_OPTIONS);
  702. value &= ~DSI_ENABLE;
  703. tegra_dc_writel(dc, value, DC_DISP_DISP_WIN_OPTIONS);
  704. tegra_dc_commit(dc);
  705. }
  706. err = tegra_dsi_wait_idle(dsi, 100);
  707. if (err < 0)
  708. dev_dbg(dsi->dev, "failed to idle DSI: %d\n", err);
  709. tegra_dsi_soft_reset(dsi);
  710. if (output->panel)
  711. drm_panel_unprepare(output->panel);
  712. tegra_dsi_disable(dsi);
  713. tegra_dsi_unprepare(dsi);
  714. }
  715. static int tegra_dsi_prepare(struct tegra_dsi *dsi)
  716. {
  717. int err;
  718. err = host1x_client_resume(&dsi->client);
  719. if (err < 0) {
  720. dev_err(dsi->dev, "failed to resume: %d\n", err);
  721. return err;
  722. }
  723. err = tegra_mipi_enable(dsi->mipi);
  724. if (err < 0)
  725. dev_err(dsi->dev, "failed to enable MIPI calibration: %d\n",
  726. err);
  727. err = tegra_dsi_pad_calibrate(dsi);
  728. if (err < 0)
  729. dev_err(dsi->dev, "MIPI calibration failed: %d\n", err);
  730. if (dsi->slave)
  731. tegra_dsi_prepare(dsi->slave);
  732. return 0;
  733. }
  734. static void tegra_dsi_encoder_enable(struct drm_encoder *encoder)
  735. {
  736. struct drm_display_mode *mode = &encoder->crtc->state->adjusted_mode;
  737. struct tegra_output *output = encoder_to_output(encoder);
  738. struct tegra_dc *dc = to_tegra_dc(encoder->crtc);
  739. struct tegra_dsi *dsi = to_dsi(output);
  740. struct tegra_dsi_state *state;
  741. u32 value;
  742. int err;
  743. /* If the bootloader enabled DSI it needs to be disabled
  744. * in order for the panel initialization commands to be
  745. * properly sent.
  746. */
  747. value = tegra_dsi_readl(dsi, DSI_POWER_CONTROL);
  748. if (value & DSI_POWER_CONTROL_ENABLE)
  749. tegra_dsi_disable(dsi);
  750. err = tegra_dsi_prepare(dsi);
  751. if (err < 0) {
  752. dev_err(dsi->dev, "failed to prepare: %d\n", err);
  753. return;
  754. }
  755. state = tegra_dsi_get_state(dsi);
  756. tegra_dsi_set_timeout(dsi, state->bclk, state->vrefresh);
  757. /*
  758. * The D-PHY timing fields are expressed in byte-clock cycles, so
  759. * multiply the period by 8.
  760. */
  761. tegra_dsi_set_phy_timing(dsi, state->period * 8, &state->timing);
  762. if (output->panel)
  763. drm_panel_prepare(output->panel);
  764. tegra_dsi_configure(dsi, dc->pipe, mode);
  765. /* enable display controller */
  766. value = tegra_dc_readl(dc, DC_DISP_DISP_WIN_OPTIONS);
  767. value |= DSI_ENABLE;
  768. tegra_dc_writel(dc, value, DC_DISP_DISP_WIN_OPTIONS);
  769. tegra_dc_commit(dc);
  770. /* enable DSI controller */
  771. tegra_dsi_enable(dsi);
  772. if (output->panel)
  773. drm_panel_enable(output->panel);
  774. }
  775. static int
  776. tegra_dsi_encoder_atomic_check(struct drm_encoder *encoder,
  777. struct drm_crtc_state *crtc_state,
  778. struct drm_connector_state *conn_state)
  779. {
  780. struct tegra_output *output = encoder_to_output(encoder);
  781. struct tegra_dsi_state *state = to_dsi_state(conn_state);
  782. struct tegra_dc *dc = to_tegra_dc(conn_state->crtc);
  783. struct tegra_dsi *dsi = to_dsi(output);
  784. unsigned int scdiv;
  785. unsigned long plld;
  786. int err;
  787. state->pclk = crtc_state->mode.clock * 1000;
  788. err = tegra_dsi_get_muldiv(dsi->format, &state->mul, &state->div);
  789. if (err < 0)
  790. return err;
  791. state->lanes = tegra_dsi_get_lanes(dsi);
  792. err = tegra_dsi_get_format(dsi->format, &state->format);
  793. if (err < 0)
  794. return err;
  795. state->vrefresh = drm_mode_vrefresh(&crtc_state->mode);
  796. /* compute byte clock */
  797. state->bclk = (state->pclk * state->mul) / (state->div * state->lanes);
  798. DRM_DEBUG_KMS("mul: %u, div: %u, lanes: %u\n", state->mul, state->div,
  799. state->lanes);
  800. DRM_DEBUG_KMS("format: %u, vrefresh: %u\n", state->format,
  801. state->vrefresh);
  802. DRM_DEBUG_KMS("bclk: %lu\n", state->bclk);
  803. /*
  804. * Compute bit clock and round up to the next MHz.
  805. */
  806. plld = DIV_ROUND_UP(state->bclk * 8, USEC_PER_SEC) * USEC_PER_SEC;
  807. state->period = DIV_ROUND_CLOSEST(NSEC_PER_SEC, plld);
  808. err = mipi_dphy_timing_get_default(&state->timing, state->period);
  809. if (err < 0)
  810. return err;
  811. err = mipi_dphy_timing_validate(&state->timing, state->period);
  812. if (err < 0) {
  813. dev_err(dsi->dev, "failed to validate D-PHY timing: %d\n", err);
  814. return err;
  815. }
  816. /*
  817. * We divide the frequency by two here, but we make up for that by
  818. * setting the shift clock divider (further below) to half of the
  819. * correct value.
  820. */
  821. plld /= 2;
  822. /*
  823. * Derive pixel clock from bit clock using the shift clock divider.
  824. * Note that this is only half of what we would expect, but we need
  825. * that to make up for the fact that we divided the bit clock by a
  826. * factor of two above.
  827. *
  828. * It's not clear exactly why this is necessary, but the display is
  829. * not working properly otherwise. Perhaps the PLLs cannot generate
  830. * frequencies sufficiently high.
  831. */
  832. scdiv = ((8 * state->mul) / (state->div * state->lanes)) - 2;
  833. err = tegra_dc_state_setup_clock(dc, crtc_state, dsi->clk_parent,
  834. plld, scdiv);
  835. if (err < 0) {
  836. dev_err(output->dev, "failed to setup CRTC state: %d\n", err);
  837. return err;
  838. }
  839. return err;
  840. }
  841. static const struct drm_encoder_helper_funcs tegra_dsi_encoder_helper_funcs = {
  842. .disable = tegra_dsi_encoder_disable,
  843. .enable = tegra_dsi_encoder_enable,
  844. .atomic_check = tegra_dsi_encoder_atomic_check,
  845. };
  846. static int tegra_dsi_init(struct host1x_client *client)
  847. {
  848. struct drm_device *drm = dev_get_drvdata(client->host);
  849. struct tegra_dsi *dsi = host1x_client_to_dsi(client);
  850. int err;
  851. /* Gangsters must not register their own outputs. */
  852. if (!dsi->master) {
  853. dsi->output.dev = client->dev;
  854. drm_connector_init(drm, &dsi->output.connector,
  855. &tegra_dsi_connector_funcs,
  856. DRM_MODE_CONNECTOR_DSI);
  857. drm_connector_helper_add(&dsi->output.connector,
  858. &tegra_dsi_connector_helper_funcs);
  859. dsi->output.connector.dpms = DRM_MODE_DPMS_OFF;
  860. drm_simple_encoder_init(drm, &dsi->output.encoder,
  861. DRM_MODE_ENCODER_DSI);
  862. drm_encoder_helper_add(&dsi->output.encoder,
  863. &tegra_dsi_encoder_helper_funcs);
  864. drm_connector_attach_encoder(&dsi->output.connector,
  865. &dsi->output.encoder);
  866. drm_connector_register(&dsi->output.connector);
  867. err = tegra_output_init(drm, &dsi->output);
  868. if (err < 0)
  869. dev_err(dsi->dev, "failed to initialize output: %d\n",
  870. err);
  871. dsi->output.encoder.possible_crtcs = 0x3;
  872. }
  873. return 0;
  874. }
  875. static int tegra_dsi_exit(struct host1x_client *client)
  876. {
  877. struct tegra_dsi *dsi = host1x_client_to_dsi(client);
  878. tegra_output_exit(&dsi->output);
  879. return 0;
  880. }
  881. static int tegra_dsi_runtime_suspend(struct host1x_client *client)
  882. {
  883. struct tegra_dsi *dsi = host1x_client_to_dsi(client);
  884. struct device *dev = client->dev;
  885. int err;
  886. if (dsi->rst) {
  887. err = reset_control_assert(dsi->rst);
  888. if (err < 0) {
  889. dev_err(dev, "failed to assert reset: %d\n", err);
  890. return err;
  891. }
  892. }
  893. usleep_range(1000, 2000);
  894. clk_disable_unprepare(dsi->clk_lp);
  895. clk_disable_unprepare(dsi->clk);
  896. regulator_disable(dsi->vdd);
  897. pm_runtime_put_sync(dev);
  898. return 0;
  899. }
  900. static int tegra_dsi_runtime_resume(struct host1x_client *client)
  901. {
  902. struct tegra_dsi *dsi = host1x_client_to_dsi(client);
  903. struct device *dev = client->dev;
  904. int err;
  905. err = pm_runtime_resume_and_get(dev);
  906. if (err < 0) {
  907. dev_err(dev, "failed to get runtime PM: %d\n", err);
  908. return err;
  909. }
  910. err = regulator_enable(dsi->vdd);
  911. if (err < 0) {
  912. dev_err(dev, "failed to enable VDD supply: %d\n", err);
  913. goto put_rpm;
  914. }
  915. err = clk_prepare_enable(dsi->clk);
  916. if (err < 0) {
  917. dev_err(dev, "cannot enable DSI clock: %d\n", err);
  918. goto disable_vdd;
  919. }
  920. err = clk_prepare_enable(dsi->clk_lp);
  921. if (err < 0) {
  922. dev_err(dev, "cannot enable low-power clock: %d\n", err);
  923. goto disable_clk;
  924. }
  925. usleep_range(1000, 2000);
  926. if (dsi->rst) {
  927. err = reset_control_deassert(dsi->rst);
  928. if (err < 0) {
  929. dev_err(dev, "cannot assert reset: %d\n", err);
  930. goto disable_clk_lp;
  931. }
  932. }
  933. return 0;
  934. disable_clk_lp:
  935. clk_disable_unprepare(dsi->clk_lp);
  936. disable_clk:
  937. clk_disable_unprepare(dsi->clk);
  938. disable_vdd:
  939. regulator_disable(dsi->vdd);
  940. put_rpm:
  941. pm_runtime_put_sync(dev);
  942. return err;
  943. }
  944. static const struct host1x_client_ops dsi_client_ops = {
  945. .init = tegra_dsi_init,
  946. .exit = tegra_dsi_exit,
  947. .suspend = tegra_dsi_runtime_suspend,
  948. .resume = tegra_dsi_runtime_resume,
  949. };
  950. static int tegra_dsi_setup_clocks(struct tegra_dsi *dsi)
  951. {
  952. struct clk *parent;
  953. int err;
  954. parent = clk_get_parent(dsi->clk);
  955. if (!parent)
  956. return -EINVAL;
  957. err = clk_set_parent(parent, dsi->clk_parent);
  958. if (err < 0)
  959. return err;
  960. return 0;
  961. }
  962. static const char * const error_report[16] = {
  963. "SoT Error",
  964. "SoT Sync Error",
  965. "EoT Sync Error",
  966. "Escape Mode Entry Command Error",
  967. "Low-Power Transmit Sync Error",
  968. "Peripheral Timeout Error",
  969. "False Control Error",
  970. "Contention Detected",
  971. "ECC Error, single-bit",
  972. "ECC Error, multi-bit",
  973. "Checksum Error",
  974. "DSI Data Type Not Recognized",
  975. "DSI VC ID Invalid",
  976. "Invalid Transmission Length",
  977. "Reserved",
  978. "DSI Protocol Violation",
  979. };
  980. static ssize_t tegra_dsi_read_response(struct tegra_dsi *dsi,
  981. const struct mipi_dsi_msg *msg,
  982. size_t count)
  983. {
  984. u8 *rx = msg->rx_buf;
  985. unsigned int i, j, k;
  986. size_t size = 0;
  987. u16 errors;
  988. u32 value;
  989. /* read and parse packet header */
  990. value = tegra_dsi_readl(dsi, DSI_RD_DATA);
  991. switch (value & 0x3f) {
  992. case MIPI_DSI_RX_ACKNOWLEDGE_AND_ERROR_REPORT:
  993. errors = (value >> 8) & 0xffff;
  994. dev_dbg(dsi->dev, "Acknowledge and error report: %04x\n",
  995. errors);
  996. for (i = 0; i < ARRAY_SIZE(error_report); i++)
  997. if (errors & BIT(i))
  998. dev_dbg(dsi->dev, " %2u: %s\n", i,
  999. error_report[i]);
  1000. break;
  1001. case MIPI_DSI_RX_DCS_SHORT_READ_RESPONSE_1BYTE:
  1002. rx[0] = (value >> 8) & 0xff;
  1003. size = 1;
  1004. break;
  1005. case MIPI_DSI_RX_DCS_SHORT_READ_RESPONSE_2BYTE:
  1006. rx[0] = (value >> 8) & 0xff;
  1007. rx[1] = (value >> 16) & 0xff;
  1008. size = 2;
  1009. break;
  1010. case MIPI_DSI_RX_DCS_LONG_READ_RESPONSE:
  1011. size = ((value >> 8) & 0xff00) | ((value >> 8) & 0xff);
  1012. break;
  1013. case MIPI_DSI_RX_GENERIC_LONG_READ_RESPONSE:
  1014. size = ((value >> 8) & 0xff00) | ((value >> 8) & 0xff);
  1015. break;
  1016. default:
  1017. dev_err(dsi->dev, "unhandled response type: %02x\n",
  1018. value & 0x3f);
  1019. return -EPROTO;
  1020. }
  1021. size = min(size, msg->rx_len);
  1022. if (msg->rx_buf && size > 0) {
  1023. for (i = 0, j = 0; i < count - 1; i++, j += 4) {
  1024. u8 *rx = msg->rx_buf + j;
  1025. value = tegra_dsi_readl(dsi, DSI_RD_DATA);
  1026. for (k = 0; k < 4 && (j + k) < msg->rx_len; k++)
  1027. rx[j + k] = (value >> (k << 3)) & 0xff;
  1028. }
  1029. }
  1030. return size;
  1031. }
  1032. static int tegra_dsi_transmit(struct tegra_dsi *dsi, unsigned long timeout)
  1033. {
  1034. tegra_dsi_writel(dsi, DSI_TRIGGER_HOST, DSI_TRIGGER);
  1035. timeout = jiffies + msecs_to_jiffies(timeout);
  1036. while (time_before(jiffies, timeout)) {
  1037. u32 value = tegra_dsi_readl(dsi, DSI_TRIGGER);
  1038. if ((value & DSI_TRIGGER_HOST) == 0)
  1039. return 0;
  1040. usleep_range(1000, 2000);
  1041. }
  1042. DRM_DEBUG_KMS("timeout waiting for transmission to complete\n");
  1043. return -ETIMEDOUT;
  1044. }
  1045. static int tegra_dsi_wait_for_response(struct tegra_dsi *dsi,
  1046. unsigned long timeout)
  1047. {
  1048. timeout = jiffies + msecs_to_jiffies(250);
  1049. while (time_before(jiffies, timeout)) {
  1050. u32 value = tegra_dsi_readl(dsi, DSI_STATUS);
  1051. u8 count = value & 0x1f;
  1052. if (count > 0)
  1053. return count;
  1054. usleep_range(1000, 2000);
  1055. }
  1056. DRM_DEBUG_KMS("peripheral returned no data\n");
  1057. return -ETIMEDOUT;
  1058. }
  1059. static void tegra_dsi_writesl(struct tegra_dsi *dsi, unsigned long offset,
  1060. const void *buffer, size_t size)
  1061. {
  1062. const u8 *buf = buffer;
  1063. size_t i, j;
  1064. u32 value;
  1065. for (j = 0; j < size; j += 4) {
  1066. value = 0;
  1067. for (i = 0; i < 4 && j + i < size; i++)
  1068. value |= buf[j + i] << (i << 3);
  1069. tegra_dsi_writel(dsi, value, DSI_WR_DATA);
  1070. }
  1071. }
  1072. static ssize_t tegra_dsi_host_transfer(struct mipi_dsi_host *host,
  1073. const struct mipi_dsi_msg *msg)
  1074. {
  1075. struct tegra_dsi *dsi = host_to_tegra(host);
  1076. struct mipi_dsi_packet packet;
  1077. const u8 *header;
  1078. size_t count;
  1079. ssize_t err;
  1080. u32 value;
  1081. err = mipi_dsi_create_packet(&packet, msg);
  1082. if (err < 0)
  1083. return err;
  1084. header = packet.header;
  1085. /* maximum FIFO depth is 1920 words */
  1086. if (packet.size > dsi->video_fifo_depth * 4)
  1087. return -ENOSPC;
  1088. /* reset underflow/overflow flags */
  1089. value = tegra_dsi_readl(dsi, DSI_STATUS);
  1090. if (value & (DSI_STATUS_UNDERFLOW | DSI_STATUS_OVERFLOW)) {
  1091. value = DSI_HOST_CONTROL_FIFO_RESET;
  1092. tegra_dsi_writel(dsi, value, DSI_HOST_CONTROL);
  1093. usleep_range(10, 20);
  1094. }
  1095. value = tegra_dsi_readl(dsi, DSI_POWER_CONTROL);
  1096. value |= DSI_POWER_CONTROL_ENABLE;
  1097. tegra_dsi_writel(dsi, value, DSI_POWER_CONTROL);
  1098. usleep_range(5000, 10000);
  1099. value = DSI_HOST_CONTROL_CRC_RESET | DSI_HOST_CONTROL_TX_TRIG_HOST |
  1100. DSI_HOST_CONTROL_CS | DSI_HOST_CONTROL_ECC;
  1101. if ((msg->flags & MIPI_DSI_MSG_USE_LPM) == 0)
  1102. value |= DSI_HOST_CONTROL_HS;
  1103. /*
  1104. * The host FIFO has a maximum of 64 words, so larger transmissions
  1105. * need to use the video FIFO.
  1106. */
  1107. if (packet.size > dsi->host_fifo_depth * 4)
  1108. value |= DSI_HOST_CONTROL_FIFO_SEL;
  1109. tegra_dsi_writel(dsi, value, DSI_HOST_CONTROL);
  1110. /*
  1111. * For reads and messages with explicitly requested ACK, generate a
  1112. * BTA sequence after the transmission of the packet.
  1113. */
  1114. if ((msg->flags & MIPI_DSI_MSG_REQ_ACK) ||
  1115. (msg->rx_buf && msg->rx_len > 0)) {
  1116. value = tegra_dsi_readl(dsi, DSI_HOST_CONTROL);
  1117. value |= DSI_HOST_CONTROL_PKT_BTA;
  1118. tegra_dsi_writel(dsi, value, DSI_HOST_CONTROL);
  1119. }
  1120. value = DSI_CONTROL_LANES(0) | DSI_CONTROL_HOST_ENABLE;
  1121. tegra_dsi_writel(dsi, value, DSI_CONTROL);
  1122. /* write packet header, ECC is generated by hardware */
  1123. value = header[2] << 16 | header[1] << 8 | header[0];
  1124. tegra_dsi_writel(dsi, value, DSI_WR_DATA);
  1125. /* write payload (if any) */
  1126. if (packet.payload_length > 0)
  1127. tegra_dsi_writesl(dsi, DSI_WR_DATA, packet.payload,
  1128. packet.payload_length);
  1129. err = tegra_dsi_transmit(dsi, 250);
  1130. if (err < 0)
  1131. return err;
  1132. if ((msg->flags & MIPI_DSI_MSG_REQ_ACK) ||
  1133. (msg->rx_buf && msg->rx_len > 0)) {
  1134. err = tegra_dsi_wait_for_response(dsi, 250);
  1135. if (err < 0)
  1136. return err;
  1137. count = err;
  1138. value = tegra_dsi_readl(dsi, DSI_RD_DATA);
  1139. switch (value) {
  1140. case 0x84:
  1141. /*
  1142. dev_dbg(dsi->dev, "ACK\n");
  1143. */
  1144. break;
  1145. case 0x87:
  1146. /*
  1147. dev_dbg(dsi->dev, "ESCAPE\n");
  1148. */
  1149. break;
  1150. default:
  1151. dev_err(dsi->dev, "unknown status: %08x\n", value);
  1152. break;
  1153. }
  1154. if (count > 1) {
  1155. err = tegra_dsi_read_response(dsi, msg, count);
  1156. if (err < 0)
  1157. dev_err(dsi->dev,
  1158. "failed to parse response: %zd\n",
  1159. err);
  1160. else {
  1161. /*
  1162. * For read commands, return the number of
  1163. * bytes returned by the peripheral.
  1164. */
  1165. count = err;
  1166. }
  1167. }
  1168. } else {
  1169. /*
  1170. * For write commands, we have transmitted the 4-byte header
  1171. * plus the variable-length payload.
  1172. */
  1173. count = 4 + packet.payload_length;
  1174. }
  1175. return count;
  1176. }
  1177. static int tegra_dsi_ganged_setup(struct tegra_dsi *dsi)
  1178. {
  1179. struct clk *parent;
  1180. int err;
  1181. /* make sure both DSI controllers share the same PLL */
  1182. parent = clk_get_parent(dsi->slave->clk);
  1183. if (!parent)
  1184. return -EINVAL;
  1185. err = clk_set_parent(parent, dsi->clk_parent);
  1186. if (err < 0)
  1187. return err;
  1188. return 0;
  1189. }
  1190. static int tegra_dsi_host_attach(struct mipi_dsi_host *host,
  1191. struct mipi_dsi_device *device)
  1192. {
  1193. struct tegra_dsi *dsi = host_to_tegra(host);
  1194. dsi->flags = device->mode_flags;
  1195. dsi->format = device->format;
  1196. dsi->lanes = device->lanes;
  1197. if (dsi->slave) {
  1198. int err;
  1199. dev_dbg(dsi->dev, "attaching dual-channel device %s\n",
  1200. dev_name(&device->dev));
  1201. err = tegra_dsi_ganged_setup(dsi);
  1202. if (err < 0) {
  1203. dev_err(dsi->dev, "failed to set up ganged mode: %d\n",
  1204. err);
  1205. return err;
  1206. }
  1207. }
  1208. /*
  1209. * Slaves don't have a panel associated with them, so they provide
  1210. * merely the second channel.
  1211. */
  1212. if (!dsi->master) {
  1213. struct tegra_output *output = &dsi->output;
  1214. output->panel = of_drm_find_panel(device->dev.of_node);
  1215. if (IS_ERR(output->panel))
  1216. output->panel = NULL;
  1217. if (output->panel && output->connector.dev)
  1218. drm_helper_hpd_irq_event(output->connector.dev);
  1219. }
  1220. return 0;
  1221. }
  1222. static int tegra_dsi_host_detach(struct mipi_dsi_host *host,
  1223. struct mipi_dsi_device *device)
  1224. {
  1225. struct tegra_dsi *dsi = host_to_tegra(host);
  1226. struct tegra_output *output = &dsi->output;
  1227. if (output->panel && &device->dev == output->panel->dev) {
  1228. output->panel = NULL;
  1229. if (output->connector.dev)
  1230. drm_helper_hpd_irq_event(output->connector.dev);
  1231. }
  1232. return 0;
  1233. }
  1234. static const struct mipi_dsi_host_ops tegra_dsi_host_ops = {
  1235. .attach = tegra_dsi_host_attach,
  1236. .detach = tegra_dsi_host_detach,
  1237. .transfer = tegra_dsi_host_transfer,
  1238. };
  1239. static int tegra_dsi_ganged_probe(struct tegra_dsi *dsi)
  1240. {
  1241. struct device_node *np;
  1242. np = of_parse_phandle(dsi->dev->of_node, "nvidia,ganged-mode", 0);
  1243. if (np) {
  1244. struct platform_device *gangster = of_find_device_by_node(np);
  1245. of_node_put(np);
  1246. if (!gangster)
  1247. return -EPROBE_DEFER;
  1248. dsi->slave = platform_get_drvdata(gangster);
  1249. if (!dsi->slave) {
  1250. put_device(&gangster->dev);
  1251. return -EPROBE_DEFER;
  1252. }
  1253. dsi->slave->master = dsi;
  1254. }
  1255. return 0;
  1256. }
  1257. static int tegra_dsi_probe(struct platform_device *pdev)
  1258. {
  1259. struct tegra_dsi *dsi;
  1260. struct resource *regs;
  1261. int err;
  1262. dsi = devm_kzalloc(&pdev->dev, sizeof(*dsi), GFP_KERNEL);
  1263. if (!dsi)
  1264. return -ENOMEM;
  1265. dsi->output.dev = dsi->dev = &pdev->dev;
  1266. dsi->video_fifo_depth = 1920;
  1267. dsi->host_fifo_depth = 64;
  1268. err = tegra_dsi_ganged_probe(dsi);
  1269. if (err < 0)
  1270. return err;
  1271. err = tegra_output_probe(&dsi->output);
  1272. if (err < 0)
  1273. return err;
  1274. dsi->output.connector.polled = DRM_CONNECTOR_POLL_HPD;
  1275. /*
  1276. * Assume these values by default. When a DSI peripheral driver
  1277. * attaches to the DSI host, the parameters will be taken from
  1278. * the attached device.
  1279. */
  1280. dsi->flags = MIPI_DSI_MODE_VIDEO;
  1281. dsi->format = MIPI_DSI_FMT_RGB888;
  1282. dsi->lanes = 4;
  1283. if (!pdev->dev.pm_domain) {
  1284. dsi->rst = devm_reset_control_get(&pdev->dev, "dsi");
  1285. if (IS_ERR(dsi->rst)) {
  1286. err = PTR_ERR(dsi->rst);
  1287. goto remove;
  1288. }
  1289. }
  1290. dsi->clk = devm_clk_get(&pdev->dev, NULL);
  1291. if (IS_ERR(dsi->clk)) {
  1292. err = dev_err_probe(&pdev->dev, PTR_ERR(dsi->clk),
  1293. "cannot get DSI clock\n");
  1294. goto remove;
  1295. }
  1296. dsi->clk_lp = devm_clk_get(&pdev->dev, "lp");
  1297. if (IS_ERR(dsi->clk_lp)) {
  1298. err = dev_err_probe(&pdev->dev, PTR_ERR(dsi->clk_lp),
  1299. "cannot get low-power clock\n");
  1300. goto remove;
  1301. }
  1302. dsi->clk_parent = devm_clk_get(&pdev->dev, "parent");
  1303. if (IS_ERR(dsi->clk_parent)) {
  1304. err = dev_err_probe(&pdev->dev, PTR_ERR(dsi->clk_parent),
  1305. "cannot get parent clock\n");
  1306. goto remove;
  1307. }
  1308. dsi->vdd = devm_regulator_get(&pdev->dev, "avdd-dsi-csi");
  1309. if (IS_ERR(dsi->vdd)) {
  1310. err = dev_err_probe(&pdev->dev, PTR_ERR(dsi->vdd),
  1311. "cannot get VDD supply\n");
  1312. goto remove;
  1313. }
  1314. err = tegra_dsi_setup_clocks(dsi);
  1315. if (err < 0) {
  1316. dev_err(&pdev->dev, "cannot setup clocks\n");
  1317. goto remove;
  1318. }
  1319. regs = platform_get_resource(pdev, IORESOURCE_MEM, 0);
  1320. dsi->regs = devm_ioremap_resource(&pdev->dev, regs);
  1321. if (IS_ERR(dsi->regs)) {
  1322. err = PTR_ERR(dsi->regs);
  1323. goto remove;
  1324. }
  1325. dsi->mipi = tegra_mipi_request(&pdev->dev, pdev->dev.of_node);
  1326. if (IS_ERR(dsi->mipi)) {
  1327. err = PTR_ERR(dsi->mipi);
  1328. goto remove;
  1329. }
  1330. dsi->host.ops = &tegra_dsi_host_ops;
  1331. dsi->host.dev = &pdev->dev;
  1332. err = mipi_dsi_host_register(&dsi->host);
  1333. if (err < 0) {
  1334. dev_err(&pdev->dev, "failed to register DSI host: %d\n", err);
  1335. goto mipi_free;
  1336. }
  1337. platform_set_drvdata(pdev, dsi);
  1338. pm_runtime_enable(&pdev->dev);
  1339. INIT_LIST_HEAD(&dsi->client.list);
  1340. dsi->client.ops = &dsi_client_ops;
  1341. dsi->client.dev = &pdev->dev;
  1342. err = host1x_client_register(&dsi->client);
  1343. if (err < 0) {
  1344. dev_err(&pdev->dev, "failed to register host1x client: %d\n",
  1345. err);
  1346. goto unregister;
  1347. }
  1348. return 0;
  1349. unregister:
  1350. pm_runtime_disable(&pdev->dev);
  1351. mipi_dsi_host_unregister(&dsi->host);
  1352. mipi_free:
  1353. tegra_mipi_free(dsi->mipi);
  1354. remove:
  1355. tegra_output_remove(&dsi->output);
  1356. return err;
  1357. }
  1358. static void tegra_dsi_remove(struct platform_device *pdev)
  1359. {
  1360. struct tegra_dsi *dsi = platform_get_drvdata(pdev);
  1361. pm_runtime_disable(&pdev->dev);
  1362. host1x_client_unregister(&dsi->client);
  1363. tegra_output_remove(&dsi->output);
  1364. mipi_dsi_host_unregister(&dsi->host);
  1365. tegra_mipi_free(dsi->mipi);
  1366. }
  1367. static const struct of_device_id tegra_dsi_of_match[] = {
  1368. { .compatible = "nvidia,tegra210-dsi", },
  1369. { .compatible = "nvidia,tegra132-dsi", },
  1370. { .compatible = "nvidia,tegra124-dsi", },
  1371. { .compatible = "nvidia,tegra114-dsi", },
  1372. { },
  1373. };
  1374. MODULE_DEVICE_TABLE(of, tegra_dsi_of_match);
  1375. struct platform_driver tegra_dsi_driver = {
  1376. .driver = {
  1377. .name = "tegra-dsi",
  1378. .of_match_table = tegra_dsi_of_match,
  1379. },
  1380. .probe = tegra_dsi_probe,
  1381. .remove_new = tegra_dsi_remove,
  1382. };