panel-boe-himax8279d.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916
  1. // SPDX-License-Identifier: GPL-2.0
  2. /*
  3. * Copyright (c) 2019, Huaqin Telecom Technology Co., Ltd
  4. *
  5. * Author: Jerry Han <jerry.han.hq@gmail.com>
  6. *
  7. */
  8. #include <linux/delay.h>
  9. #include <linux/kernel.h>
  10. #include <linux/module.h>
  11. #include <linux/of.h>
  12. #include <linux/gpio/consumer.h>
  13. #include <linux/regulator/consumer.h>
  14. #include <drm/drm_device.h>
  15. #include <drm/drm_mipi_dsi.h>
  16. #include <drm/drm_modes.h>
  17. #include <drm/drm_panel.h>
  18. #include <video/mipi_display.h>
  19. struct panel_cmd {
  20. char cmd;
  21. char data;
  22. };
  23. struct panel_desc {
  24. const struct drm_display_mode *display_mode;
  25. unsigned int bpc;
  26. unsigned int width_mm;
  27. unsigned int height_mm;
  28. unsigned long mode_flags;
  29. enum mipi_dsi_pixel_format format;
  30. unsigned int lanes;
  31. const struct panel_cmd *on_cmds;
  32. unsigned int on_cmds_num;
  33. };
  34. struct panel_info {
  35. struct drm_panel base;
  36. struct mipi_dsi_device *link;
  37. const struct panel_desc *desc;
  38. struct gpio_desc *enable_gpio;
  39. struct gpio_desc *pp33_gpio;
  40. struct gpio_desc *pp18_gpio;
  41. };
  42. static inline struct panel_info *to_panel_info(struct drm_panel *panel)
  43. {
  44. return container_of(panel, struct panel_info, base);
  45. }
  46. static void disable_gpios(struct panel_info *pinfo)
  47. {
  48. gpiod_set_value(pinfo->enable_gpio, 0);
  49. gpiod_set_value(pinfo->pp33_gpio, 0);
  50. gpiod_set_value(pinfo->pp18_gpio, 0);
  51. }
  52. static int send_mipi_cmds(struct drm_panel *panel, const struct panel_cmd *cmds)
  53. {
  54. struct panel_info *pinfo = to_panel_info(panel);
  55. unsigned int i = 0;
  56. int err;
  57. for (i = 0; i < pinfo->desc->on_cmds_num; i++) {
  58. err = mipi_dsi_dcs_write_buffer(pinfo->link, &cmds[i],
  59. sizeof(struct panel_cmd));
  60. if (err < 0)
  61. return err;
  62. }
  63. return 0;
  64. }
  65. static int boe_panel_disable(struct drm_panel *panel)
  66. {
  67. struct panel_info *pinfo = to_panel_info(panel);
  68. int err;
  69. err = mipi_dsi_dcs_set_display_off(pinfo->link);
  70. if (err < 0) {
  71. dev_err(panel->dev, "failed to set display off: %d\n", err);
  72. return err;
  73. }
  74. return 0;
  75. }
  76. static int boe_panel_unprepare(struct drm_panel *panel)
  77. {
  78. struct panel_info *pinfo = to_panel_info(panel);
  79. int err;
  80. err = mipi_dsi_dcs_set_display_off(pinfo->link);
  81. if (err < 0)
  82. dev_err(panel->dev, "failed to set display off: %d\n", err);
  83. err = mipi_dsi_dcs_enter_sleep_mode(pinfo->link);
  84. if (err < 0)
  85. dev_err(panel->dev, "failed to enter sleep mode: %d\n", err);
  86. /* sleep_mode_delay: 1ms - 2ms */
  87. usleep_range(1000, 2000);
  88. disable_gpios(pinfo);
  89. return 0;
  90. }
  91. static int boe_panel_prepare(struct drm_panel *panel)
  92. {
  93. struct panel_info *pinfo = to_panel_info(panel);
  94. int err;
  95. gpiod_set_value(pinfo->pp18_gpio, 1);
  96. /* T1: 5ms - 6ms */
  97. usleep_range(5000, 6000);
  98. gpiod_set_value(pinfo->pp33_gpio, 1);
  99. /* reset sequence */
  100. /* T2: 14ms - 15ms */
  101. usleep_range(14000, 15000);
  102. gpiod_set_value(pinfo->enable_gpio, 1);
  103. /* T3: 1ms - 2ms */
  104. usleep_range(1000, 2000);
  105. gpiod_set_value(pinfo->enable_gpio, 0);
  106. /* T4: 1ms - 2ms */
  107. usleep_range(1000, 2000);
  108. gpiod_set_value(pinfo->enable_gpio, 1);
  109. /* T5: 5ms - 6ms */
  110. usleep_range(5000, 6000);
  111. /* send init code */
  112. err = send_mipi_cmds(panel, pinfo->desc->on_cmds);
  113. if (err < 0) {
  114. dev_err(panel->dev, "failed to send DCS Init Code: %d\n", err);
  115. goto poweroff;
  116. }
  117. err = mipi_dsi_dcs_exit_sleep_mode(pinfo->link);
  118. if (err < 0) {
  119. dev_err(panel->dev, "failed to exit sleep mode: %d\n", err);
  120. goto poweroff;
  121. }
  122. /* T6: 120ms - 121ms */
  123. usleep_range(120000, 121000);
  124. err = mipi_dsi_dcs_set_display_on(pinfo->link);
  125. if (err < 0) {
  126. dev_err(panel->dev, "failed to set display on: %d\n", err);
  127. goto poweroff;
  128. }
  129. /* T7: 20ms - 21ms */
  130. usleep_range(20000, 21000);
  131. return 0;
  132. poweroff:
  133. disable_gpios(pinfo);
  134. return err;
  135. }
  136. static int boe_panel_enable(struct drm_panel *panel)
  137. {
  138. struct panel_info *pinfo = to_panel_info(panel);
  139. int ret;
  140. usleep_range(120000, 121000);
  141. ret = mipi_dsi_dcs_set_display_on(pinfo->link);
  142. if (ret < 0) {
  143. dev_err(panel->dev, "failed to set display on: %d\n", ret);
  144. return ret;
  145. }
  146. return 0;
  147. }
  148. static int boe_panel_get_modes(struct drm_panel *panel,
  149. struct drm_connector *connector)
  150. {
  151. struct panel_info *pinfo = to_panel_info(panel);
  152. const struct drm_display_mode *m = pinfo->desc->display_mode;
  153. struct drm_display_mode *mode;
  154. mode = drm_mode_duplicate(connector->dev, m);
  155. if (!mode) {
  156. dev_err(pinfo->base.dev, "failed to add mode %ux%u@%u\n",
  157. m->hdisplay, m->vdisplay, drm_mode_vrefresh(m));
  158. return -ENOMEM;
  159. }
  160. drm_mode_set_name(mode);
  161. drm_mode_probed_add(connector, mode);
  162. connector->display_info.width_mm = pinfo->desc->width_mm;
  163. connector->display_info.height_mm = pinfo->desc->height_mm;
  164. connector->display_info.bpc = pinfo->desc->bpc;
  165. return 1;
  166. }
  167. static const struct drm_panel_funcs panel_funcs = {
  168. .disable = boe_panel_disable,
  169. .unprepare = boe_panel_unprepare,
  170. .prepare = boe_panel_prepare,
  171. .enable = boe_panel_enable,
  172. .get_modes = boe_panel_get_modes,
  173. };
  174. static const struct drm_display_mode default_display_mode = {
  175. .clock = 159420,
  176. .hdisplay = 1200,
  177. .hsync_start = 1200 + 80,
  178. .hsync_end = 1200 + 80 + 60,
  179. .htotal = 1200 + 80 + 60 + 24,
  180. .vdisplay = 1920,
  181. .vsync_start = 1920 + 10,
  182. .vsync_end = 1920 + 10 + 14,
  183. .vtotal = 1920 + 10 + 14 + 4,
  184. };
  185. /* 8 inch */
  186. static const struct panel_cmd boe_himax8279d8p_on_cmds[] = {
  187. { 0xB0, 0x05 },
  188. { 0xB1, 0xE5 },
  189. { 0xB3, 0x52 },
  190. { 0xC0, 0x00 },
  191. { 0xC2, 0x57 },
  192. { 0xD9, 0x85 },
  193. { 0xB0, 0x01 },
  194. { 0xC8, 0x00 },
  195. { 0xC9, 0x00 },
  196. { 0xCC, 0x26 },
  197. { 0xCD, 0x26 },
  198. { 0xDC, 0x00 },
  199. { 0xDD, 0x00 },
  200. { 0xE0, 0x26 },
  201. { 0xE1, 0x26 },
  202. { 0xB0, 0x03 },
  203. { 0xC3, 0x2A },
  204. { 0xE7, 0x2A },
  205. { 0xC5, 0x2A },
  206. { 0xDE, 0x2A },
  207. { 0xBC, 0x02 },
  208. { 0xCB, 0x02 },
  209. { 0xB0, 0x00 },
  210. { 0xB6, 0x03 },
  211. { 0xBA, 0x8B },
  212. { 0xBF, 0x15 },
  213. { 0xC0, 0x18 },
  214. { 0xC2, 0x14 },
  215. { 0xC3, 0x02 },
  216. { 0xC4, 0x14 },
  217. { 0xC5, 0x02 },
  218. { 0xCC, 0x0A },
  219. { 0xB0, 0x06 },
  220. { 0xC0, 0xA5 },
  221. { 0xD5, 0x20 },
  222. { 0xC0, 0x00 },
  223. { 0xB0, 0x02 },
  224. { 0xC0, 0x00 },
  225. { 0xC1, 0x02 },
  226. { 0xC2, 0x06 },
  227. { 0xC3, 0x16 },
  228. { 0xC4, 0x0E },
  229. { 0xC5, 0x18 },
  230. { 0xC6, 0x26 },
  231. { 0xC7, 0x32 },
  232. { 0xC8, 0x3F },
  233. { 0xC9, 0x3F },
  234. { 0xCA, 0x3F },
  235. { 0xCB, 0x3F },
  236. { 0xCC, 0x3D },
  237. { 0xCD, 0x2F },
  238. { 0xCE, 0x2F },
  239. { 0xCF, 0x2F },
  240. { 0xD0, 0x07 },
  241. { 0xD2, 0x00 },
  242. { 0xD3, 0x02 },
  243. { 0xD4, 0x06 },
  244. { 0xD5, 0x12 },
  245. { 0xD6, 0x0A },
  246. { 0xD7, 0x14 },
  247. { 0xD8, 0x22 },
  248. { 0xD9, 0x2E },
  249. { 0xDA, 0x3D },
  250. { 0xDB, 0x3F },
  251. { 0xDC, 0x3F },
  252. { 0xDD, 0x3F },
  253. { 0xDE, 0x3D },
  254. { 0xDF, 0x2F },
  255. { 0xE0, 0x2F },
  256. { 0xE1, 0x2F },
  257. { 0xE2, 0x07 },
  258. { 0xB0, 0x07 },
  259. { 0xB1, 0x18 },
  260. { 0xB2, 0x19 },
  261. { 0xB3, 0x2E },
  262. { 0xB4, 0x52 },
  263. { 0xB5, 0x72 },
  264. { 0xB6, 0x8C },
  265. { 0xB7, 0xBD },
  266. { 0xB8, 0xEB },
  267. { 0xB9, 0x47 },
  268. { 0xBA, 0x96 },
  269. { 0xBB, 0x1E },
  270. { 0xBC, 0x90 },
  271. { 0xBD, 0x93 },
  272. { 0xBE, 0xFA },
  273. { 0xBF, 0x56 },
  274. { 0xC0, 0x8C },
  275. { 0xC1, 0xB7 },
  276. { 0xC2, 0xCC },
  277. { 0xC3, 0xDF },
  278. { 0xC4, 0xE8 },
  279. { 0xC5, 0xF0 },
  280. { 0xC6, 0xF8 },
  281. { 0xC7, 0xFA },
  282. { 0xC8, 0xFC },
  283. { 0xC9, 0x00 },
  284. { 0xCA, 0x00 },
  285. { 0xCB, 0x5A },
  286. { 0xCC, 0xAF },
  287. { 0xCD, 0xFF },
  288. { 0xCE, 0xFF },
  289. { 0xB0, 0x08 },
  290. { 0xB1, 0x04 },
  291. { 0xB2, 0x15 },
  292. { 0xB3, 0x2D },
  293. { 0xB4, 0x51 },
  294. { 0xB5, 0x72 },
  295. { 0xB6, 0x8D },
  296. { 0xB7, 0xBE },
  297. { 0xB8, 0xED },
  298. { 0xB9, 0x4A },
  299. { 0xBA, 0x9A },
  300. { 0xBB, 0x23 },
  301. { 0xBC, 0x95 },
  302. { 0xBD, 0x98 },
  303. { 0xBE, 0xFF },
  304. { 0xBF, 0x59 },
  305. { 0xC0, 0x8E },
  306. { 0xC1, 0xB9 },
  307. { 0xC2, 0xCD },
  308. { 0xC3, 0xDF },
  309. { 0xC4, 0xE8 },
  310. { 0xC5, 0xF0 },
  311. { 0xC6, 0xF8 },
  312. { 0xC7, 0xFA },
  313. { 0xC8, 0xFC },
  314. { 0xC9, 0x00 },
  315. { 0xCA, 0x00 },
  316. { 0xCB, 0x5A },
  317. { 0xCC, 0xAF },
  318. { 0xCD, 0xFF },
  319. { 0xCE, 0xFF },
  320. { 0xB0, 0x09 },
  321. { 0xB1, 0x04 },
  322. { 0xB2, 0x2C },
  323. { 0xB3, 0x36 },
  324. { 0xB4, 0x53 },
  325. { 0xB5, 0x73 },
  326. { 0xB6, 0x8E },
  327. { 0xB7, 0xC0 },
  328. { 0xB8, 0xEF },
  329. { 0xB9, 0x4C },
  330. { 0xBA, 0x9D },
  331. { 0xBB, 0x25 },
  332. { 0xBC, 0x96 },
  333. { 0xBD, 0x9A },
  334. { 0xBE, 0x01 },
  335. { 0xBF, 0x59 },
  336. { 0xC0, 0x8E },
  337. { 0xC1, 0xB9 },
  338. { 0xC2, 0xCD },
  339. { 0xC3, 0xDF },
  340. { 0xC4, 0xE8 },
  341. { 0xC5, 0xF0 },
  342. { 0xC6, 0xF8 },
  343. { 0xC7, 0xFA },
  344. { 0xC8, 0xFC },
  345. { 0xC9, 0x00 },
  346. { 0xCA, 0x00 },
  347. { 0xCB, 0x5A },
  348. { 0xCC, 0xBF },
  349. { 0xCD, 0xFF },
  350. { 0xCE, 0xFF },
  351. { 0xB0, 0x0A },
  352. { 0xB1, 0x18 },
  353. { 0xB2, 0x19 },
  354. { 0xB3, 0x2E },
  355. { 0xB4, 0x52 },
  356. { 0xB5, 0x72 },
  357. { 0xB6, 0x8C },
  358. { 0xB7, 0xBD },
  359. { 0xB8, 0xEB },
  360. { 0xB9, 0x47 },
  361. { 0xBA, 0x96 },
  362. { 0xBB, 0x1E },
  363. { 0xBC, 0x90 },
  364. { 0xBD, 0x93 },
  365. { 0xBE, 0xFA },
  366. { 0xBF, 0x56 },
  367. { 0xC0, 0x8C },
  368. { 0xC1, 0xB7 },
  369. { 0xC2, 0xCC },
  370. { 0xC3, 0xDF },
  371. { 0xC4, 0xE8 },
  372. { 0xC5, 0xF0 },
  373. { 0xC6, 0xF8 },
  374. { 0xC7, 0xFA },
  375. { 0xC8, 0xFC },
  376. { 0xC9, 0x00 },
  377. { 0xCA, 0x00 },
  378. { 0xCB, 0x5A },
  379. { 0xCC, 0xAF },
  380. { 0xCD, 0xFF },
  381. { 0xCE, 0xFF },
  382. { 0xB0, 0x0B },
  383. { 0xB1, 0x04 },
  384. { 0xB2, 0x15 },
  385. { 0xB3, 0x2D },
  386. { 0xB4, 0x51 },
  387. { 0xB5, 0x72 },
  388. { 0xB6, 0x8D },
  389. { 0xB7, 0xBE },
  390. { 0xB8, 0xED },
  391. { 0xB9, 0x4A },
  392. { 0xBA, 0x9A },
  393. { 0xBB, 0x23 },
  394. { 0xBC, 0x95 },
  395. { 0xBD, 0x98 },
  396. { 0xBE, 0xFF },
  397. { 0xBF, 0x59 },
  398. { 0xC0, 0x8E },
  399. { 0xC1, 0xB9 },
  400. { 0xC2, 0xCD },
  401. { 0xC3, 0xDF },
  402. { 0xC4, 0xE8 },
  403. { 0xC5, 0xF0 },
  404. { 0xC6, 0xF8 },
  405. { 0xC7, 0xFA },
  406. { 0xC8, 0xFC },
  407. { 0xC9, 0x00 },
  408. { 0xCA, 0x00 },
  409. { 0xCB, 0x5A },
  410. { 0xCC, 0xAF },
  411. { 0xCD, 0xFF },
  412. { 0xCE, 0xFF },
  413. { 0xB0, 0x0C },
  414. { 0xB1, 0x04 },
  415. { 0xB2, 0x2C },
  416. { 0xB3, 0x36 },
  417. { 0xB4, 0x53 },
  418. { 0xB5, 0x73 },
  419. { 0xB6, 0x8E },
  420. { 0xB7, 0xC0 },
  421. { 0xB8, 0xEF },
  422. { 0xB9, 0x4C },
  423. { 0xBA, 0x9D },
  424. { 0xBB, 0x25 },
  425. { 0xBC, 0x96 },
  426. { 0xBD, 0x9A },
  427. { 0xBE, 0x01 },
  428. { 0xBF, 0x59 },
  429. { 0xC0, 0x8E },
  430. { 0xC1, 0xB9 },
  431. { 0xC2, 0xCD },
  432. { 0xC3, 0xDF },
  433. { 0xC4, 0xE8 },
  434. { 0xC5, 0xF0 },
  435. { 0xC6, 0xF8 },
  436. { 0xC7, 0xFA },
  437. { 0xC8, 0xFC },
  438. { 0xC9, 0x00 },
  439. { 0xCA, 0x00 },
  440. { 0xCB, 0x5A },
  441. { 0xCC, 0xBF },
  442. { 0xCD, 0xFF },
  443. { 0xCE, 0xFF },
  444. { 0xB0, 0x04 },
  445. { 0xB5, 0x02 },
  446. { 0xB6, 0x01 },
  447. };
  448. static const struct panel_desc boe_himax8279d8p_panel_desc = {
  449. .display_mode = &default_display_mode,
  450. .bpc = 8,
  451. .width_mm = 107,
  452. .height_mm = 172,
  453. .mode_flags = MIPI_DSI_MODE_VIDEO | MIPI_DSI_MODE_VIDEO_SYNC_PULSE |
  454. MIPI_DSI_CLOCK_NON_CONTINUOUS | MIPI_DSI_MODE_LPM,
  455. .format = MIPI_DSI_FMT_RGB888,
  456. .lanes = 4,
  457. .on_cmds = boe_himax8279d8p_on_cmds,
  458. .on_cmds_num = 260,
  459. };
  460. /* 10 inch */
  461. static const struct panel_cmd boe_himax8279d10p_on_cmds[] = {
  462. { 0xB0, 0x05 },
  463. { 0xB1, 0xE5 },
  464. { 0xB3, 0x52 },
  465. { 0xB0, 0x00 },
  466. { 0xB6, 0x03 },
  467. { 0xBA, 0x8B },
  468. { 0xBF, 0x1A },
  469. { 0xC0, 0x0F },
  470. { 0xC2, 0x0C },
  471. { 0xC3, 0x02 },
  472. { 0xC4, 0x0C },
  473. { 0xC5, 0x02 },
  474. { 0xB0, 0x01 },
  475. { 0xE0, 0x26 },
  476. { 0xE1, 0x26 },
  477. { 0xDC, 0x00 },
  478. { 0xDD, 0x00 },
  479. { 0xCC, 0x26 },
  480. { 0xCD, 0x26 },
  481. { 0xC8, 0x00 },
  482. { 0xC9, 0x00 },
  483. { 0xD2, 0x03 },
  484. { 0xD3, 0x03 },
  485. { 0xE6, 0x04 },
  486. { 0xE7, 0x04 },
  487. { 0xC4, 0x09 },
  488. { 0xC5, 0x09 },
  489. { 0xD8, 0x0A },
  490. { 0xD9, 0x0A },
  491. { 0xC2, 0x0B },
  492. { 0xC3, 0x0B },
  493. { 0xD6, 0x0C },
  494. { 0xD7, 0x0C },
  495. { 0xC0, 0x05 },
  496. { 0xC1, 0x05 },
  497. { 0xD4, 0x06 },
  498. { 0xD5, 0x06 },
  499. { 0xCA, 0x07 },
  500. { 0xCB, 0x07 },
  501. { 0xDE, 0x08 },
  502. { 0xDF, 0x08 },
  503. { 0xB0, 0x02 },
  504. { 0xC0, 0x00 },
  505. { 0xC1, 0x0D },
  506. { 0xC2, 0x17 },
  507. { 0xC3, 0x26 },
  508. { 0xC4, 0x31 },
  509. { 0xC5, 0x1C },
  510. { 0xC6, 0x2C },
  511. { 0xC7, 0x33 },
  512. { 0xC8, 0x31 },
  513. { 0xC9, 0x37 },
  514. { 0xCA, 0x37 },
  515. { 0xCB, 0x37 },
  516. { 0xCC, 0x39 },
  517. { 0xCD, 0x2E },
  518. { 0xCE, 0x2F },
  519. { 0xCF, 0x2F },
  520. { 0xD0, 0x07 },
  521. { 0xD2, 0x00 },
  522. { 0xD3, 0x0D },
  523. { 0xD4, 0x17 },
  524. { 0xD5, 0x26 },
  525. { 0xD6, 0x31 },
  526. { 0xD7, 0x3F },
  527. { 0xD8, 0x3F },
  528. { 0xD9, 0x3F },
  529. { 0xDA, 0x3F },
  530. { 0xDB, 0x37 },
  531. { 0xDC, 0x37 },
  532. { 0xDD, 0x37 },
  533. { 0xDE, 0x39 },
  534. { 0xDF, 0x2E },
  535. { 0xE0, 0x2F },
  536. { 0xE1, 0x2F },
  537. { 0xE2, 0x07 },
  538. { 0xB0, 0x03 },
  539. { 0xC8, 0x0B },
  540. { 0xC9, 0x07 },
  541. { 0xC3, 0x00 },
  542. { 0xE7, 0x00 },
  543. { 0xC5, 0x2A },
  544. { 0xDE, 0x2A },
  545. { 0xCA, 0x43 },
  546. { 0xC9, 0x07 },
  547. { 0xE4, 0xC0 },
  548. { 0xE5, 0x0D },
  549. { 0xCB, 0x01 },
  550. { 0xBC, 0x01 },
  551. { 0xB0, 0x06 },
  552. { 0xB8, 0xA5 },
  553. { 0xC0, 0xA5 },
  554. { 0xC7, 0x0F },
  555. { 0xD5, 0x32 },
  556. { 0xB8, 0x00 },
  557. { 0xC0, 0x00 },
  558. { 0xBC, 0x00 },
  559. { 0xB0, 0x07 },
  560. { 0xB1, 0x00 },
  561. { 0xB2, 0x05 },
  562. { 0xB3, 0x10 },
  563. { 0xB4, 0x22 },
  564. { 0xB5, 0x36 },
  565. { 0xB6, 0x4A },
  566. { 0xB7, 0x6C },
  567. { 0xB8, 0x9A },
  568. { 0xB9, 0xD7 },
  569. { 0xBA, 0x17 },
  570. { 0xBB, 0x92 },
  571. { 0xBC, 0x15 },
  572. { 0xBD, 0x18 },
  573. { 0xBE, 0x8C },
  574. { 0xBF, 0x00 },
  575. { 0xC0, 0x3A },
  576. { 0xC1, 0x72 },
  577. { 0xC2, 0x8C },
  578. { 0xC3, 0xA5 },
  579. { 0xC4, 0xB1 },
  580. { 0xC5, 0xBE },
  581. { 0xC6, 0xCA },
  582. { 0xC7, 0xD1 },
  583. { 0xC8, 0xD4 },
  584. { 0xC9, 0x00 },
  585. { 0xCA, 0x00 },
  586. { 0xCB, 0x16 },
  587. { 0xCC, 0xAF },
  588. { 0xCD, 0xFF },
  589. { 0xCE, 0xFF },
  590. { 0xB0, 0x08 },
  591. { 0xB1, 0x04 },
  592. { 0xB2, 0x05 },
  593. { 0xB3, 0x11 },
  594. { 0xB4, 0x24 },
  595. { 0xB5, 0x39 },
  596. { 0xB6, 0x4E },
  597. { 0xB7, 0x72 },
  598. { 0xB8, 0xA3 },
  599. { 0xB9, 0xE1 },
  600. { 0xBA, 0x25 },
  601. { 0xBB, 0xA8 },
  602. { 0xBC, 0x2E },
  603. { 0xBD, 0x32 },
  604. { 0xBE, 0xAD },
  605. { 0xBF, 0x28 },
  606. { 0xC0, 0x63 },
  607. { 0xC1, 0x9B },
  608. { 0xC2, 0xB5 },
  609. { 0xC3, 0xCF },
  610. { 0xC4, 0xDB },
  611. { 0xC5, 0xE8 },
  612. { 0xC6, 0xF5 },
  613. { 0xC7, 0xFA },
  614. { 0xC8, 0xFC },
  615. { 0xC9, 0x00 },
  616. { 0xCA, 0x00 },
  617. { 0xCB, 0x16 },
  618. { 0xCC, 0xAF },
  619. { 0xCD, 0xFF },
  620. { 0xCE, 0xFF },
  621. { 0xB0, 0x09 },
  622. { 0xB1, 0x04 },
  623. { 0xB2, 0x04 },
  624. { 0xB3, 0x0F },
  625. { 0xB4, 0x22 },
  626. { 0xB5, 0x37 },
  627. { 0xB6, 0x4D },
  628. { 0xB7, 0x71 },
  629. { 0xB8, 0xA2 },
  630. { 0xB9, 0xE1 },
  631. { 0xBA, 0x26 },
  632. { 0xBB, 0xA9 },
  633. { 0xBC, 0x2F },
  634. { 0xBD, 0x33 },
  635. { 0xBE, 0xAC },
  636. { 0xBF, 0x24 },
  637. { 0xC0, 0x5D },
  638. { 0xC1, 0x94 },
  639. { 0xC2, 0xAC },
  640. { 0xC3, 0xC5 },
  641. { 0xC4, 0xD1 },
  642. { 0xC5, 0xDC },
  643. { 0xC6, 0xE8 },
  644. { 0xC7, 0xED },
  645. { 0xC8, 0xF0 },
  646. { 0xC9, 0x00 },
  647. { 0xCA, 0x00 },
  648. { 0xCB, 0x16 },
  649. { 0xCC, 0xAF },
  650. { 0xCD, 0xFF },
  651. { 0xCE, 0xFF },
  652. { 0xB0, 0x0A },
  653. { 0xB1, 0x00 },
  654. { 0xB2, 0x05 },
  655. { 0xB3, 0x10 },
  656. { 0xB4, 0x22 },
  657. { 0xB5, 0x36 },
  658. { 0xB6, 0x4A },
  659. { 0xB7, 0x6C },
  660. { 0xB8, 0x9A },
  661. { 0xB9, 0xD7 },
  662. { 0xBA, 0x17 },
  663. { 0xBB, 0x92 },
  664. { 0xBC, 0x15 },
  665. { 0xBD, 0x18 },
  666. { 0xBE, 0x8C },
  667. { 0xBF, 0x00 },
  668. { 0xC0, 0x3A },
  669. { 0xC1, 0x72 },
  670. { 0xC2, 0x8C },
  671. { 0xC3, 0xA5 },
  672. { 0xC4, 0xB1 },
  673. { 0xC5, 0xBE },
  674. { 0xC6, 0xCA },
  675. { 0xC7, 0xD1 },
  676. { 0xC8, 0xD4 },
  677. { 0xC9, 0x00 },
  678. { 0xCA, 0x00 },
  679. { 0xCB, 0x16 },
  680. { 0xCC, 0xAF },
  681. { 0xCD, 0xFF },
  682. { 0xCE, 0xFF },
  683. { 0xB0, 0x0B },
  684. { 0xB1, 0x04 },
  685. { 0xB2, 0x05 },
  686. { 0xB3, 0x11 },
  687. { 0xB4, 0x24 },
  688. { 0xB5, 0x39 },
  689. { 0xB6, 0x4E },
  690. { 0xB7, 0x72 },
  691. { 0xB8, 0xA3 },
  692. { 0xB9, 0xE1 },
  693. { 0xBA, 0x25 },
  694. { 0xBB, 0xA8 },
  695. { 0xBC, 0x2E },
  696. { 0xBD, 0x32 },
  697. { 0xBE, 0xAD },
  698. { 0xBF, 0x28 },
  699. { 0xC0, 0x63 },
  700. { 0xC1, 0x9B },
  701. { 0xC2, 0xB5 },
  702. { 0xC3, 0xCF },
  703. { 0xC4, 0xDB },
  704. { 0xC5, 0xE8 },
  705. { 0xC6, 0xF5 },
  706. { 0xC7, 0xFA },
  707. { 0xC8, 0xFC },
  708. { 0xC9, 0x00 },
  709. { 0xCA, 0x00 },
  710. { 0xCB, 0x16 },
  711. { 0xCC, 0xAF },
  712. { 0xCD, 0xFF },
  713. { 0xCE, 0xFF },
  714. { 0xB0, 0x0C },
  715. { 0xB1, 0x04 },
  716. { 0xB2, 0x04 },
  717. { 0xB3, 0x0F },
  718. { 0xB4, 0x22 },
  719. { 0xB5, 0x37 },
  720. { 0xB6, 0x4D },
  721. { 0xB7, 0x71 },
  722. { 0xB8, 0xA2 },
  723. { 0xB9, 0xE1 },
  724. { 0xBA, 0x26 },
  725. { 0xBB, 0xA9 },
  726. { 0xBC, 0x2F },
  727. { 0xBD, 0x33 },
  728. { 0xBE, 0xAC },
  729. { 0xBF, 0x24 },
  730. { 0xC0, 0x5D },
  731. { 0xC1, 0x94 },
  732. { 0xC2, 0xAC },
  733. { 0xC3, 0xC5 },
  734. { 0xC4, 0xD1 },
  735. { 0xC5, 0xDC },
  736. { 0xC6, 0xE8 },
  737. { 0xC7, 0xED },
  738. { 0xC8, 0xF0 },
  739. { 0xC9, 0x00 },
  740. { 0xCA, 0x00 },
  741. { 0xCB, 0x16 },
  742. { 0xCC, 0xAF },
  743. { 0xCD, 0xFF },
  744. { 0xCE, 0xFF },
  745. };
  746. static const struct panel_desc boe_himax8279d10p_panel_desc = {
  747. .display_mode = &default_display_mode,
  748. .bpc = 8,
  749. .width_mm = 135,
  750. .height_mm = 216,
  751. .mode_flags = MIPI_DSI_MODE_VIDEO | MIPI_DSI_MODE_VIDEO_SYNC_PULSE |
  752. MIPI_DSI_CLOCK_NON_CONTINUOUS | MIPI_DSI_MODE_LPM,
  753. .format = MIPI_DSI_FMT_RGB888,
  754. .lanes = 4,
  755. .on_cmds = boe_himax8279d10p_on_cmds,
  756. .on_cmds_num = 283,
  757. };
  758. static const struct of_device_id panel_of_match[] = {
  759. {
  760. .compatible = "boe,himax8279d8p",
  761. .data = &boe_himax8279d8p_panel_desc,
  762. },
  763. {
  764. .compatible = "boe,himax8279d10p",
  765. .data = &boe_himax8279d10p_panel_desc,
  766. },
  767. {
  768. /* sentinel */
  769. }
  770. };
  771. MODULE_DEVICE_TABLE(of, panel_of_match);
  772. static int panel_add(struct panel_info *pinfo)
  773. {
  774. struct device *dev = &pinfo->link->dev;
  775. int ret;
  776. pinfo->pp18_gpio = devm_gpiod_get(dev, "pp18", GPIOD_OUT_HIGH);
  777. if (IS_ERR(pinfo->pp18_gpio)) {
  778. return dev_err_probe(dev, PTR_ERR(pinfo->pp18_gpio),
  779. "failed to get pp18 gpio\n");
  780. }
  781. pinfo->pp33_gpio = devm_gpiod_get(dev, "pp33", GPIOD_OUT_HIGH);
  782. if (IS_ERR(pinfo->pp33_gpio)) {
  783. return dev_err_probe(dev, PTR_ERR(pinfo->pp33_gpio),
  784. "failed to get pp33 gpio\n");
  785. }
  786. pinfo->enable_gpio = devm_gpiod_get(dev, "enable", GPIOD_OUT_HIGH);
  787. if (IS_ERR(pinfo->enable_gpio)) {
  788. return dev_err_probe(dev, PTR_ERR(pinfo->enable_gpio),
  789. "failed to get enable gpio\n");
  790. }
  791. drm_panel_init(&pinfo->base, dev, &panel_funcs,
  792. DRM_MODE_CONNECTOR_DSI);
  793. ret = drm_panel_of_backlight(&pinfo->base);
  794. if (ret)
  795. return ret;
  796. drm_panel_add(&pinfo->base);
  797. return 0;
  798. }
  799. static int panel_probe(struct mipi_dsi_device *dsi)
  800. {
  801. struct panel_info *pinfo;
  802. const struct panel_desc *desc;
  803. int err;
  804. pinfo = devm_kzalloc(&dsi->dev, sizeof(*pinfo), GFP_KERNEL);
  805. if (!pinfo)
  806. return -ENOMEM;
  807. desc = of_device_get_match_data(&dsi->dev);
  808. dsi->mode_flags = desc->mode_flags;
  809. dsi->format = desc->format;
  810. dsi->lanes = desc->lanes;
  811. pinfo->desc = desc;
  812. pinfo->link = dsi;
  813. mipi_dsi_set_drvdata(dsi, pinfo);
  814. err = panel_add(pinfo);
  815. if (err < 0)
  816. return err;
  817. err = mipi_dsi_attach(dsi);
  818. if (err < 0)
  819. drm_panel_remove(&pinfo->base);
  820. return err;
  821. }
  822. static void panel_remove(struct mipi_dsi_device *dsi)
  823. {
  824. struct panel_info *pinfo = mipi_dsi_get_drvdata(dsi);
  825. int err;
  826. err = mipi_dsi_detach(dsi);
  827. if (err < 0)
  828. dev_err(&dsi->dev, "failed to detach from DSI host: %d\n", err);
  829. drm_panel_remove(&pinfo->base);
  830. }
  831. static struct mipi_dsi_driver panel_driver = {
  832. .driver = {
  833. .name = "panel-boe-himax8279d",
  834. .of_match_table = panel_of_match,
  835. },
  836. .probe = panel_probe,
  837. .remove = panel_remove,
  838. };
  839. module_mipi_dsi_driver(panel_driver);
  840. MODULE_AUTHOR("Jerry Han <jerry.han.hq@gmail.com>");
  841. MODULE_DESCRIPTION("Boe Himax8279d driver");
  842. MODULE_LICENSE("GPL v2");