panel-truly-nt35597.c 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631
  1. // SPDX-License-Identifier: GPL-2.0
  2. /*
  3. * Copyright (c) 2018, The Linux Foundation. All rights reserved.
  4. */
  5. #include <linux/backlight.h>
  6. #include <linux/delay.h>
  7. #include <linux/gpio/consumer.h>
  8. #include <linux/module.h>
  9. #include <linux/of.h>
  10. #include <linux/of_graph.h>
  11. #include <linux/pinctrl/consumer.h>
  12. #include <linux/regulator/consumer.h>
  13. #include <video/mipi_display.h>
  14. #include <drm/drm_mipi_dsi.h>
  15. #include <drm/drm_modes.h>
  16. #include <drm/drm_panel.h>
  17. static const char * const regulator_names[] = {
  18. "vdda",
  19. "vdispp",
  20. "vdispn",
  21. };
  22. static unsigned long const regulator_enable_loads[] = {
  23. 62000,
  24. 100000,
  25. 100000,
  26. };
  27. static unsigned long const regulator_disable_loads[] = {
  28. 80,
  29. 100,
  30. 100,
  31. };
  32. struct cmd_set {
  33. u8 commands[4];
  34. u8 size;
  35. };
  36. struct nt35597_config {
  37. u32 width_mm;
  38. u32 height_mm;
  39. const char *panel_name;
  40. const struct cmd_set *panel_on_cmds;
  41. u32 num_on_cmds;
  42. const struct drm_display_mode *dm;
  43. };
  44. struct truly_nt35597 {
  45. struct device *dev;
  46. struct drm_panel panel;
  47. struct regulator_bulk_data supplies[ARRAY_SIZE(regulator_names)];
  48. struct gpio_desc *reset_gpio;
  49. struct gpio_desc *mode_gpio;
  50. struct backlight_device *backlight;
  51. struct mipi_dsi_device *dsi[2];
  52. const struct nt35597_config *config;
  53. };
  54. static inline struct truly_nt35597 *panel_to_ctx(struct drm_panel *panel)
  55. {
  56. return container_of(panel, struct truly_nt35597, panel);
  57. }
  58. static const struct cmd_set qcom_2k_panel_magic_cmds[] = {
  59. /* CMD2_P0 */
  60. { { 0xff, 0x20 }, 2 },
  61. { { 0xfb, 0x01 }, 2 },
  62. { { 0x00, 0x01 }, 2 },
  63. { { 0x01, 0x55 }, 2 },
  64. { { 0x02, 0x45 }, 2 },
  65. { { 0x05, 0x40 }, 2 },
  66. { { 0x06, 0x19 }, 2 },
  67. { { 0x07, 0x1e }, 2 },
  68. { { 0x0b, 0x73 }, 2 },
  69. { { 0x0c, 0x73 }, 2 },
  70. { { 0x0e, 0xb0 }, 2 },
  71. { { 0x0f, 0xae }, 2 },
  72. { { 0x11, 0xb8 }, 2 },
  73. { { 0x13, 0x00 }, 2 },
  74. { { 0x58, 0x80 }, 2 },
  75. { { 0x59, 0x01 }, 2 },
  76. { { 0x5a, 0x00 }, 2 },
  77. { { 0x5b, 0x01 }, 2 },
  78. { { 0x5c, 0x80 }, 2 },
  79. { { 0x5d, 0x81 }, 2 },
  80. { { 0x5e, 0x00 }, 2 },
  81. { { 0x5f, 0x01 }, 2 },
  82. { { 0x72, 0x11 }, 2 },
  83. { { 0x68, 0x03 }, 2 },
  84. /* CMD2_P4 */
  85. { { 0xFF, 0x24 }, 2 },
  86. { { 0xFB, 0x01 }, 2 },
  87. { { 0x00, 0x1C }, 2 },
  88. { { 0x01, 0x0B }, 2 },
  89. { { 0x02, 0x0C }, 2 },
  90. { { 0x03, 0x01 }, 2 },
  91. { { 0x04, 0x0F }, 2 },
  92. { { 0x05, 0x10 }, 2 },
  93. { { 0x06, 0x10 }, 2 },
  94. { { 0x07, 0x10 }, 2 },
  95. { { 0x08, 0x89 }, 2 },
  96. { { 0x09, 0x8A }, 2 },
  97. { { 0x0A, 0x13 }, 2 },
  98. { { 0x0B, 0x13 }, 2 },
  99. { { 0x0C, 0x15 }, 2 },
  100. { { 0x0D, 0x15 }, 2 },
  101. { { 0x0E, 0x17 }, 2 },
  102. { { 0x0F, 0x17 }, 2 },
  103. { { 0x10, 0x1C }, 2 },
  104. { { 0x11, 0x0B }, 2 },
  105. { { 0x12, 0x0C }, 2 },
  106. { { 0x13, 0x01 }, 2 },
  107. { { 0x14, 0x0F }, 2 },
  108. { { 0x15, 0x10 }, 2 },
  109. { { 0x16, 0x10 }, 2 },
  110. { { 0x17, 0x10 }, 2 },
  111. { { 0x18, 0x89 }, 2 },
  112. { { 0x19, 0x8A }, 2 },
  113. { { 0x1A, 0x13 }, 2 },
  114. { { 0x1B, 0x13 }, 2 },
  115. { { 0x1C, 0x15 }, 2 },
  116. { { 0x1D, 0x15 }, 2 },
  117. { { 0x1E, 0x17 }, 2 },
  118. { { 0x1F, 0x17 }, 2 },
  119. /* STV */
  120. { { 0x20, 0x40 }, 2 },
  121. { { 0x21, 0x01 }, 2 },
  122. { { 0x22, 0x00 }, 2 },
  123. { { 0x23, 0x40 }, 2 },
  124. { { 0x24, 0x40 }, 2 },
  125. { { 0x25, 0x6D }, 2 },
  126. { { 0x26, 0x40 }, 2 },
  127. { { 0x27, 0x40 }, 2 },
  128. /* Vend */
  129. { { 0xE0, 0x00 }, 2 },
  130. { { 0xDC, 0x21 }, 2 },
  131. { { 0xDD, 0x22 }, 2 },
  132. { { 0xDE, 0x07 }, 2 },
  133. { { 0xDF, 0x07 }, 2 },
  134. { { 0xE3, 0x6D }, 2 },
  135. { { 0xE1, 0x07 }, 2 },
  136. { { 0xE2, 0x07 }, 2 },
  137. /* UD */
  138. { { 0x29, 0xD8 }, 2 },
  139. { { 0x2A, 0x2A }, 2 },
  140. /* CLK */
  141. { { 0x4B, 0x03 }, 2 },
  142. { { 0x4C, 0x11 }, 2 },
  143. { { 0x4D, 0x10 }, 2 },
  144. { { 0x4E, 0x01 }, 2 },
  145. { { 0x4F, 0x01 }, 2 },
  146. { { 0x50, 0x10 }, 2 },
  147. { { 0x51, 0x00 }, 2 },
  148. { { 0x52, 0x80 }, 2 },
  149. { { 0x53, 0x00 }, 2 },
  150. { { 0x56, 0x00 }, 2 },
  151. { { 0x54, 0x07 }, 2 },
  152. { { 0x58, 0x07 }, 2 },
  153. { { 0x55, 0x25 }, 2 },
  154. /* Reset XDONB */
  155. { { 0x5B, 0x43 }, 2 },
  156. { { 0x5C, 0x00 }, 2 },
  157. { { 0x5F, 0x73 }, 2 },
  158. { { 0x60, 0x73 }, 2 },
  159. { { 0x63, 0x22 }, 2 },
  160. { { 0x64, 0x00 }, 2 },
  161. { { 0x67, 0x08 }, 2 },
  162. { { 0x68, 0x04 }, 2 },
  163. /* Resolution:1440x2560 */
  164. { { 0x72, 0x02 }, 2 },
  165. /* mux */
  166. { { 0x7A, 0x80 }, 2 },
  167. { { 0x7B, 0x91 }, 2 },
  168. { { 0x7C, 0xD8 }, 2 },
  169. { { 0x7D, 0x60 }, 2 },
  170. { { 0x7F, 0x15 }, 2 },
  171. { { 0x75, 0x15 }, 2 },
  172. /* ABOFF */
  173. { { 0xB3, 0xC0 }, 2 },
  174. { { 0xB4, 0x00 }, 2 },
  175. { { 0xB5, 0x00 }, 2 },
  176. /* Source EQ */
  177. { { 0x78, 0x00 }, 2 },
  178. { { 0x79, 0x00 }, 2 },
  179. { { 0x80, 0x00 }, 2 },
  180. { { 0x83, 0x00 }, 2 },
  181. /* FP BP */
  182. { { 0x93, 0x0A }, 2 },
  183. { { 0x94, 0x0A }, 2 },
  184. /* Inversion Type */
  185. { { 0x8A, 0x00 }, 2 },
  186. { { 0x9B, 0xFF }, 2 },
  187. /* IMGSWAP =1 @PortSwap=1 */
  188. { { 0x9D, 0xB0 }, 2 },
  189. { { 0x9F, 0x63 }, 2 },
  190. { { 0x98, 0x10 }, 2 },
  191. /* FRM */
  192. { { 0xEC, 0x00 }, 2 },
  193. /* CMD1 */
  194. { { 0xFF, 0x10 }, 2 },
  195. /* VBP+VSA=,VFP = 10H */
  196. { { 0x3B, 0x03, 0x0A, 0x0A }, 4 },
  197. /* FTE on */
  198. { { 0x35, 0x00 }, 2 },
  199. /* EN_BK =1(auto black) */
  200. { { 0xE5, 0x01 }, 2 },
  201. /* CMD mode(10) VDO mode(03) */
  202. { { 0xBB, 0x03 }, 2 },
  203. /* Non Reload MTP */
  204. { { 0xFB, 0x01 }, 2 },
  205. };
  206. static int truly_dcs_write(struct drm_panel *panel, u32 command)
  207. {
  208. struct truly_nt35597 *ctx = panel_to_ctx(panel);
  209. int i, ret;
  210. for (i = 0; i < ARRAY_SIZE(ctx->dsi); i++) {
  211. ret = mipi_dsi_dcs_write(ctx->dsi[i], command, NULL, 0);
  212. if (ret < 0) {
  213. dev_err(ctx->dev, "cmd 0x%x failed for dsi = %d\n", command, i);
  214. }
  215. }
  216. return ret;
  217. }
  218. static int truly_dcs_write_buf(struct drm_panel *panel,
  219. u32 size, const u8 *buf)
  220. {
  221. struct truly_nt35597 *ctx = panel_to_ctx(panel);
  222. int ret = 0;
  223. int i;
  224. for (i = 0; i < ARRAY_SIZE(ctx->dsi); i++) {
  225. ret = mipi_dsi_dcs_write_buffer(ctx->dsi[i], buf, size);
  226. if (ret < 0) {
  227. dev_err(ctx->dev, "failed to tx cmd [%d], err: %d\n", i, ret);
  228. return ret;
  229. }
  230. }
  231. return ret;
  232. }
  233. static int truly_35597_power_on(struct truly_nt35597 *ctx)
  234. {
  235. int ret, i;
  236. for (i = 0; i < ARRAY_SIZE(ctx->supplies); i++) {
  237. ret = regulator_set_load(ctx->supplies[i].consumer,
  238. regulator_enable_loads[i]);
  239. if (ret)
  240. return ret;
  241. }
  242. ret = regulator_bulk_enable(ARRAY_SIZE(ctx->supplies), ctx->supplies);
  243. if (ret < 0)
  244. return ret;
  245. /*
  246. * Reset sequence of truly panel requires the panel to be
  247. * out of reset for 10ms, followed by being held in reset
  248. * for 10ms and then out again
  249. */
  250. gpiod_set_value(ctx->reset_gpio, 0);
  251. usleep_range(10000, 20000);
  252. gpiod_set_value(ctx->reset_gpio, 1);
  253. usleep_range(10000, 20000);
  254. gpiod_set_value(ctx->reset_gpio, 0);
  255. usleep_range(10000, 20000);
  256. return 0;
  257. }
  258. static int truly_nt35597_power_off(struct truly_nt35597 *ctx)
  259. {
  260. int ret = 0;
  261. int i;
  262. gpiod_set_value(ctx->reset_gpio, 1);
  263. for (i = 0; i < ARRAY_SIZE(ctx->supplies); i++) {
  264. ret = regulator_set_load(ctx->supplies[i].consumer,
  265. regulator_disable_loads[i]);
  266. if (ret) {
  267. dev_err(ctx->dev, "regulator_set_load failed %d\n", ret);
  268. return ret;
  269. }
  270. }
  271. ret = regulator_bulk_disable(ARRAY_SIZE(ctx->supplies), ctx->supplies);
  272. if (ret) {
  273. dev_err(ctx->dev, "regulator_bulk_disable failed %d\n", ret);
  274. }
  275. return ret;
  276. }
  277. static int truly_nt35597_disable(struct drm_panel *panel)
  278. {
  279. struct truly_nt35597 *ctx = panel_to_ctx(panel);
  280. int ret;
  281. if (ctx->backlight) {
  282. ret = backlight_disable(ctx->backlight);
  283. if (ret < 0)
  284. dev_err(ctx->dev, "backlight disable failed %d\n", ret);
  285. }
  286. return 0;
  287. }
  288. static int truly_nt35597_unprepare(struct drm_panel *panel)
  289. {
  290. struct truly_nt35597 *ctx = panel_to_ctx(panel);
  291. int ret = 0;
  292. ctx->dsi[0]->mode_flags = 0;
  293. ctx->dsi[1]->mode_flags = 0;
  294. ret = truly_dcs_write(panel, MIPI_DCS_SET_DISPLAY_OFF);
  295. if (ret < 0) {
  296. dev_err(ctx->dev, "set_display_off cmd failed ret = %d\n", ret);
  297. }
  298. /* 120ms delay required here as per DCS spec */
  299. msleep(120);
  300. ret = truly_dcs_write(panel, MIPI_DCS_ENTER_SLEEP_MODE);
  301. if (ret < 0) {
  302. dev_err(ctx->dev, "enter_sleep cmd failed ret = %d\n", ret);
  303. }
  304. ret = truly_nt35597_power_off(ctx);
  305. if (ret < 0)
  306. dev_err(ctx->dev, "power_off failed ret = %d\n", ret);
  307. return ret;
  308. }
  309. static int truly_nt35597_prepare(struct drm_panel *panel)
  310. {
  311. struct truly_nt35597 *ctx = panel_to_ctx(panel);
  312. int ret;
  313. int i;
  314. const struct cmd_set *panel_on_cmds;
  315. const struct nt35597_config *config;
  316. u32 num_cmds;
  317. ret = truly_35597_power_on(ctx);
  318. if (ret < 0)
  319. return ret;
  320. ctx->dsi[0]->mode_flags |= MIPI_DSI_MODE_LPM;
  321. ctx->dsi[1]->mode_flags |= MIPI_DSI_MODE_LPM;
  322. config = ctx->config;
  323. panel_on_cmds = config->panel_on_cmds;
  324. num_cmds = config->num_on_cmds;
  325. for (i = 0; i < num_cmds; i++) {
  326. ret = truly_dcs_write_buf(panel,
  327. panel_on_cmds[i].size,
  328. panel_on_cmds[i].commands);
  329. if (ret < 0) {
  330. dev_err(ctx->dev, "cmd set tx failed i = %d ret = %d\n", i, ret);
  331. goto power_off;
  332. }
  333. }
  334. ret = truly_dcs_write(panel, MIPI_DCS_EXIT_SLEEP_MODE);
  335. if (ret < 0) {
  336. dev_err(ctx->dev, "exit_sleep_mode cmd failed ret = %d\n", ret);
  337. goto power_off;
  338. }
  339. /* Per DSI spec wait 120ms after sending exit sleep DCS command */
  340. msleep(120);
  341. ret = truly_dcs_write(panel, MIPI_DCS_SET_DISPLAY_ON);
  342. if (ret < 0) {
  343. dev_err(ctx->dev, "set_display_on cmd failed ret = %d\n", ret);
  344. goto power_off;
  345. }
  346. /* Per DSI spec wait 120ms after sending set_display_on DCS command */
  347. msleep(120);
  348. return 0;
  349. power_off:
  350. if (truly_nt35597_power_off(ctx))
  351. dev_err(ctx->dev, "power_off failed\n");
  352. return ret;
  353. }
  354. static int truly_nt35597_enable(struct drm_panel *panel)
  355. {
  356. struct truly_nt35597 *ctx = panel_to_ctx(panel);
  357. int ret;
  358. if (ctx->backlight) {
  359. ret = backlight_enable(ctx->backlight);
  360. if (ret < 0)
  361. dev_err(ctx->dev, "backlight enable failed %d\n", ret);
  362. }
  363. return 0;
  364. }
  365. static int truly_nt35597_get_modes(struct drm_panel *panel,
  366. struct drm_connector *connector)
  367. {
  368. struct truly_nt35597 *ctx = panel_to_ctx(panel);
  369. struct drm_display_mode *mode;
  370. const struct nt35597_config *config;
  371. config = ctx->config;
  372. mode = drm_mode_duplicate(connector->dev, config->dm);
  373. if (!mode) {
  374. dev_err(ctx->dev, "failed to create a new display mode\n");
  375. return 0;
  376. }
  377. connector->display_info.width_mm = config->width_mm;
  378. connector->display_info.height_mm = config->height_mm;
  379. mode->type = DRM_MODE_TYPE_DRIVER | DRM_MODE_TYPE_PREFERRED;
  380. drm_mode_probed_add(connector, mode);
  381. return 1;
  382. }
  383. static const struct drm_panel_funcs truly_nt35597_drm_funcs = {
  384. .disable = truly_nt35597_disable,
  385. .unprepare = truly_nt35597_unprepare,
  386. .prepare = truly_nt35597_prepare,
  387. .enable = truly_nt35597_enable,
  388. .get_modes = truly_nt35597_get_modes,
  389. };
  390. static int truly_nt35597_panel_add(struct truly_nt35597 *ctx)
  391. {
  392. struct device *dev = ctx->dev;
  393. int ret, i;
  394. for (i = 0; i < ARRAY_SIZE(ctx->supplies); i++)
  395. ctx->supplies[i].supply = regulator_names[i];
  396. ret = devm_regulator_bulk_get(dev, ARRAY_SIZE(ctx->supplies),
  397. ctx->supplies);
  398. if (ret < 0)
  399. return ret;
  400. ctx->reset_gpio = devm_gpiod_get(dev, "reset", GPIOD_OUT_LOW);
  401. if (IS_ERR(ctx->reset_gpio)) {
  402. dev_err(dev, "cannot get reset gpio %ld\n", PTR_ERR(ctx->reset_gpio));
  403. return PTR_ERR(ctx->reset_gpio);
  404. }
  405. ctx->mode_gpio = devm_gpiod_get(dev, "mode", GPIOD_OUT_LOW);
  406. if (IS_ERR(ctx->mode_gpio)) {
  407. dev_err(dev, "cannot get mode gpio %ld\n", PTR_ERR(ctx->mode_gpio));
  408. return PTR_ERR(ctx->mode_gpio);
  409. }
  410. /* dual port */
  411. gpiod_set_value(ctx->mode_gpio, 0);
  412. drm_panel_init(&ctx->panel, dev, &truly_nt35597_drm_funcs,
  413. DRM_MODE_CONNECTOR_DSI);
  414. drm_panel_add(&ctx->panel);
  415. return 0;
  416. }
  417. static const struct drm_display_mode qcom_sdm845_mtp_2k_mode = {
  418. .name = "1440x2560",
  419. .clock = 268316,
  420. .hdisplay = 1440,
  421. .hsync_start = 1440 + 200,
  422. .hsync_end = 1440 + 200 + 32,
  423. .htotal = 1440 + 200 + 32 + 64,
  424. .vdisplay = 2560,
  425. .vsync_start = 2560 + 8,
  426. .vsync_end = 2560 + 8 + 1,
  427. .vtotal = 2560 + 8 + 1 + 7,
  428. .flags = 0,
  429. };
  430. static const struct nt35597_config nt35597_dir = {
  431. .width_mm = 74,
  432. .height_mm = 131,
  433. .panel_name = "qcom_sdm845_mtp_2k_panel",
  434. .dm = &qcom_sdm845_mtp_2k_mode,
  435. .panel_on_cmds = qcom_2k_panel_magic_cmds,
  436. .num_on_cmds = ARRAY_SIZE(qcom_2k_panel_magic_cmds),
  437. };
  438. static int truly_nt35597_probe(struct mipi_dsi_device *dsi)
  439. {
  440. struct device *dev = &dsi->dev;
  441. struct truly_nt35597 *ctx;
  442. struct mipi_dsi_device *dsi1_device;
  443. struct device_node *dsi1;
  444. struct mipi_dsi_host *dsi1_host;
  445. struct mipi_dsi_device *dsi_dev;
  446. int ret = 0;
  447. int i;
  448. const struct mipi_dsi_device_info info = {
  449. .type = "trulynt35597",
  450. .channel = 0,
  451. .node = NULL,
  452. };
  453. ctx = devm_kzalloc(dev, sizeof(*ctx), GFP_KERNEL);
  454. if (!ctx)
  455. return -ENOMEM;
  456. /*
  457. * This device represents itself as one with two input ports which are
  458. * fed by the output ports of the two DSI controllers . The DSI0 is
  459. * the master controller and has most of the panel related info in its
  460. * child node.
  461. */
  462. ctx->config = of_device_get_match_data(dev);
  463. if (!ctx->config) {
  464. dev_err(dev, "missing device configuration\n");
  465. return -ENODEV;
  466. }
  467. dsi1 = of_graph_get_remote_node(dsi->dev.of_node, 1, -1);
  468. if (!dsi1) {
  469. dev_err(dev, "failed to get remote node for dsi1_device\n");
  470. return -ENODEV;
  471. }
  472. dsi1_host = of_find_mipi_dsi_host_by_node(dsi1);
  473. of_node_put(dsi1);
  474. if (!dsi1_host)
  475. return dev_err_probe(dev, -EPROBE_DEFER, "failed to find dsi host\n");
  476. /* register the second DSI device */
  477. dsi1_device = mipi_dsi_device_register_full(dsi1_host, &info);
  478. if (IS_ERR(dsi1_device)) {
  479. dev_err(dev, "failed to create dsi device\n");
  480. return PTR_ERR(dsi1_device);
  481. }
  482. mipi_dsi_set_drvdata(dsi, ctx);
  483. ctx->dev = dev;
  484. ctx->dsi[0] = dsi;
  485. ctx->dsi[1] = dsi1_device;
  486. ret = truly_nt35597_panel_add(ctx);
  487. if (ret) {
  488. dev_err(dev, "failed to add panel\n");
  489. goto err_panel_add;
  490. }
  491. for (i = 0; i < ARRAY_SIZE(ctx->dsi); i++) {
  492. dsi_dev = ctx->dsi[i];
  493. dsi_dev->lanes = 4;
  494. dsi_dev->format = MIPI_DSI_FMT_RGB888;
  495. dsi_dev->mode_flags = MIPI_DSI_MODE_VIDEO | MIPI_DSI_MODE_LPM |
  496. MIPI_DSI_CLOCK_NON_CONTINUOUS;
  497. ret = mipi_dsi_attach(dsi_dev);
  498. if (ret < 0) {
  499. dev_err(dev, "dsi attach failed i = %d\n", i);
  500. goto err_dsi_attach;
  501. }
  502. }
  503. return 0;
  504. err_dsi_attach:
  505. drm_panel_remove(&ctx->panel);
  506. err_panel_add:
  507. mipi_dsi_device_unregister(dsi1_device);
  508. return ret;
  509. }
  510. static void truly_nt35597_remove(struct mipi_dsi_device *dsi)
  511. {
  512. struct truly_nt35597 *ctx = mipi_dsi_get_drvdata(dsi);
  513. if (ctx->dsi[0])
  514. mipi_dsi_detach(ctx->dsi[0]);
  515. if (ctx->dsi[1]) {
  516. mipi_dsi_detach(ctx->dsi[1]);
  517. mipi_dsi_device_unregister(ctx->dsi[1]);
  518. }
  519. drm_panel_remove(&ctx->panel);
  520. }
  521. static const struct of_device_id truly_nt35597_of_match[] = {
  522. {
  523. .compatible = "truly,nt35597-2K-display",
  524. .data = &nt35597_dir,
  525. },
  526. { }
  527. };
  528. MODULE_DEVICE_TABLE(of, truly_nt35597_of_match);
  529. static struct mipi_dsi_driver truly_nt35597_driver = {
  530. .driver = {
  531. .name = "panel-truly-nt35597",
  532. .of_match_table = truly_nt35597_of_match,
  533. },
  534. .probe = truly_nt35597_probe,
  535. .remove = truly_nt35597_remove,
  536. };
  537. module_mipi_dsi_driver(truly_nt35597_driver);
  538. MODULE_DESCRIPTION("Truly NT35597 DSI Panel Driver");
  539. MODULE_LICENSE("GPL v2");