panel-novatek-nt35510.c 32 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097
  1. // SPDX-License-Identifier: GPL-2.0-only
  2. /*
  3. * Novatek NT35510 panel driver
  4. * Copyright (C) 2020 Linus Walleij <[email protected]>
  5. * Based on code by Robert Teather (C) 2012 Samsung
  6. *
  7. * This display driver (and I refer to the physical component NT35510,
  8. * not this Linux kernel software driver) can handle:
  9. * 480x864, 480x854, 480x800, 480x720 and 480x640 pixel displays.
  10. * It has 480x840x24bit SRAM embedded for storing a frame.
  11. * When powered on the display is by default in 480x800 mode.
  12. *
  13. * The actual panels using this component have different names, but
  14. * the code needed to set up and configure the panel will be similar,
  15. * so they should all use the NT35510 driver with appropriate configuration
  16. * per-panel, e.g. for physical size.
  17. *
  18. * This driver is for the DSI interface to panels using the NT35510.
  19. *
  20. * The NT35510 can also use an RGB (DPI) interface combined with an
  21. * I2C or SPI interface for setting up the NT35510. If this is needed
  22. * this panel driver should be refactored to also support that use
  23. * case.
  24. */
  25. #include <linux/backlight.h>
  26. #include <linux/bitops.h>
  27. #include <linux/gpio/consumer.h>
  28. #include <linux/module.h>
  29. #include <linux/of_device.h>
  30. #include <linux/regmap.h>
  31. #include <linux/regulator/consumer.h>
  32. #include <video/mipi_display.h>
  33. #include <drm/drm_mipi_dsi.h>
  34. #include <drm/drm_modes.h>
  35. #include <drm/drm_panel.h>
  36. #define MCS_CMD_MAUCCTR 0xF0 /* Manufacturer command enable */
  37. #define MCS_CMD_READ_ID1 0xDA
  38. #define MCS_CMD_READ_ID2 0xDB
  39. #define MCS_CMD_READ_ID3 0xDC
  40. #define MCS_CMD_MTP_READ_SETTING 0xF8 /* Uncertain about name */
  41. #define MCS_CMD_MTP_READ_PARAM 0xFF /* Uncertain about name */
  42. /*
  43. * These manufacturer commands are available after we enable manufacturer
  44. * command set (MCS) for page 0.
  45. */
  46. #define NT35510_P0_DOPCTR 0xB1
  47. #define NT35510_P0_SDHDTCTR 0xB6
  48. #define NT35510_P0_GSEQCTR 0xB7
  49. #define NT35510_P0_SDEQCTR 0xB8
  50. #define NT35510_P0_SDVPCTR 0xBA
  51. #define NT35510_P0_DPFRCTR1 0xBD
  52. #define NT35510_P0_DPFRCTR2 0xBE
  53. #define NT35510_P0_DPFRCTR3 0xBF
  54. #define NT35510_P0_DPMCTR12 0xCC
  55. #define NT35510_P0_DOPCTR_LEN 2
  56. #define NT35510_P0_GSEQCTR_LEN 2
  57. #define NT35510_P0_SDEQCTR_LEN 4
  58. #define NT35510_P0_SDVPCTR_LEN 1
  59. #define NT35510_P0_DPFRCTR1_LEN 5
  60. #define NT35510_P0_DPFRCTR2_LEN 5
  61. #define NT35510_P0_DPFRCTR3_LEN 5
  62. #define NT35510_P0_DPMCTR12_LEN 3
  63. #define NT35510_DOPCTR_0_RAMKP BIT(7) /* Contents kept in sleep */
  64. #define NT35510_DOPCTR_0_DSITE BIT(6) /* Enable TE signal */
  65. #define NT35510_DOPCTR_0_DSIG BIT(5) /* Enable generic read/write */
  66. #define NT35510_DOPCTR_0_DSIM BIT(4) /* Enable video mode on DSI */
  67. #define NT35510_DOPCTR_0_EOTP BIT(3) /* Support EoTP */
  68. #define NT35510_DOPCTR_0_N565 BIT(2) /* RGB or BGR pixel format */
  69. #define NT35510_DOPCTR_1_TW_PWR_SEL BIT(4) /* TE power selector */
  70. #define NT35510_DOPCTR_1_CRGB BIT(3) /* RGB or BGR byte order */
  71. #define NT35510_DOPCTR_1_CTB BIT(2) /* Vertical scanning direction */
  72. #define NT35510_DOPCTR_1_CRL BIT(1) /* Source driver data shift */
  73. #define NT35510_P0_SDVPCTR_PRG BIT(2) /* 0 = normal operation, 1 = VGLO */
  74. #define NT35510_P0_SDVPCTR_AVDD 0 /* source driver output = AVDD */
  75. #define NT35510_P0_SDVPCTR_OFFCOL 1 /* source driver output = off color */
  76. #define NT35510_P0_SDVPCTR_AVSS 2 /* source driver output = AVSS */
  77. #define NT35510_P0_SDVPCTR_HI_Z 3 /* source driver output = High impedance */
  78. /*
  79. * These manufacturer commands are available after we enable manufacturer
  80. * command set (MCS) for page 1.
  81. */
  82. #define NT35510_P1_SETAVDD 0xB0
  83. #define NT35510_P1_SETAVEE 0xB1
  84. #define NT35510_P1_SETVCL 0xB2
  85. #define NT35510_P1_SETVGH 0xB3
  86. #define NT35510_P1_SETVRGH 0xB4
  87. #define NT35510_P1_SETVGL 0xB5
  88. #define NT35510_P1_BT1CTR 0xB6
  89. #define NT35510_P1_BT2CTR 0xB7
  90. #define NT35510_P1_BT3CTR 0xB8
  91. #define NT35510_P1_BT4CTR 0xB9 /* VGH boosting times/freq */
  92. #define NT35510_P1_BT5CTR 0xBA
  93. #define NT35510_P1_PFMCTR 0xBB
  94. #define NT35510_P1_SETVGP 0xBC
  95. #define NT35510_P1_SETVGN 0xBD
  96. #define NT35510_P1_SETVCMOFF 0xBE
  97. #define NT35510_P1_VGHCTR 0xBF /* VGH output ctrl */
  98. #define NT35510_P1_SET_GAMMA_RED_POS 0xD1
  99. #define NT35510_P1_SET_GAMMA_GREEN_POS 0xD2
  100. #define NT35510_P1_SET_GAMMA_BLUE_POS 0xD3
  101. #define NT35510_P1_SET_GAMMA_RED_NEG 0xD4
  102. #define NT35510_P1_SET_GAMMA_GREEN_NEG 0xD5
  103. #define NT35510_P1_SET_GAMMA_BLUE_NEG 0xD6
  104. /* AVDD and AVEE setting 3 bytes */
  105. #define NT35510_P1_AVDD_LEN 3
  106. #define NT35510_P1_AVEE_LEN 3
  107. #define NT35510_P1_VGH_LEN 3
  108. #define NT35510_P1_VGL_LEN 3
  109. #define NT35510_P1_VGP_LEN 3
  110. #define NT35510_P1_VGN_LEN 3
  111. /* BT1CTR thru BT5CTR setting 3 bytes */
  112. #define NT35510_P1_BT1CTR_LEN 3
  113. #define NT35510_P1_BT2CTR_LEN 3
  114. #define NT35510_P1_BT4CTR_LEN 3
  115. #define NT35510_P1_BT5CTR_LEN 3
  116. /* 52 gamma parameters times two per color: positive and negative */
  117. #define NT35510_P1_GAMMA_LEN 52
  118. /**
  119. * struct nt35510_config - the display-specific NT35510 configuration
  120. *
  121. * Some of the settings provide an array of bytes, A, B C which mean:
  122. * A = normal / idle off mode
  123. * B = idle on mode
  124. * C = partial / idle off mode
  125. *
  126. * Gamma correction arrays are 10bit numbers, two consecutive bytes
  127. * makes out one point on the gamma correction curve. The points are
  128. * not linearly placed along the X axis, we get points 0, 1, 3, 5
  129. * 7, 11, 15, 23, 31, 47, 63, 95, 127, 128, 160, 192, 208, 224, 232,
  130. * 240, 244, 248, 250, 252, 254, 255. The voltages tuples form
  131. * V0, V1, V3 ... V255, with 0x0000 being the lowest voltage and
  132. * 0x03FF being the highest voltage.
  133. *
  134. * Each value must be strictly higher than the previous value forming
  135. * a rising curve like this:
  136. *
  137. * ^
  138. * | V255
  139. * | V254
  140. * | ....
  141. * | V5
  142. * | V3
  143. * | V1
  144. * | V0
  145. * +------------------------------------------->
  146. *
  147. * The details about all settings can be found in the NT35510 Application
  148. * Note.
  149. */
  150. struct nt35510_config {
  151. /**
  152. * @width_mm: physical panel width [mm]
  153. */
  154. u32 width_mm;
  155. /**
  156. * @height_mm: physical panel height [mm]
  157. */
  158. u32 height_mm;
  159. /**
  160. * @mode: the display mode. This is only relevant outside the panel
  161. * in video mode: in command mode this is configuring the internal
  162. * timing in the display controller.
  163. */
  164. const struct drm_display_mode mode;
  165. /**
  166. * @avdd: setting for AVDD ranging from 0x00 = 6.5V to 0x14 = 4.5V
  167. * in 0.1V steps the default is 0x05 which means 6.0V
  168. */
  169. u8 avdd[NT35510_P1_AVDD_LEN];
  170. /**
  171. * @bt1ctr: setting for boost power control for the AVDD step-up
  172. * circuit (1)
  173. * bits 0..2 in the lower nibble controls PCK, the booster clock
  174. * frequency for the step-up circuit:
  175. * 0 = Hsync/32
  176. * 1 = Hsync/16
  177. * 2 = Hsync/8
  178. * 3 = Hsync/4
  179. * 4 = Hsync/2
  180. * 5 = Hsync
  181. * 6 = Hsync x 2
  182. * 7 = Hsync x 4
  183. * bits 4..6 in the upper nibble controls BTP, the boosting
  184. * amplification for the step-up circuit:
  185. * 0 = Disable
  186. * 1 = 1.5 x VDDB
  187. * 2 = 1.66 x VDDB
  188. * 3 = 2 x VDDB
  189. * 4 = 2.5 x VDDB
  190. * 5 = 3 x VDDB
  191. * The defaults are 4 and 4 yielding 0x44
  192. */
  193. u8 bt1ctr[NT35510_P1_BT1CTR_LEN];
  194. /**
  195. * @avee: setting for AVEE ranging from 0x00 = -6.5V to 0x14 = -4.5V
  196. * in 0.1V steps the default is 0x05 which means -6.0V
  197. */
  198. u8 avee[NT35510_P1_AVEE_LEN];
  199. /**
  200. * @bt2ctr: setting for boost power control for the AVEE step-up
  201. * circuit (2)
  202. * bits 0..2 in the lower nibble controls NCK, the booster clock
  203. * frequency, the values are the same as for PCK in @bt1ctr.
  204. * bits 4..5 in the upper nibble controls BTN, the boosting
  205. * amplification for the step-up circuit.
  206. * 0 = Disable
  207. * 1 = -1.5 x VDDB
  208. * 2 = -2 x VDDB
  209. * 3 = -2.5 x VDDB
  210. * 4 = -3 x VDDB
  211. * The defaults are 4 and 3 yielding 0x34
  212. */
  213. u8 bt2ctr[NT35510_P1_BT2CTR_LEN];
  214. /**
  215. * @vgh: setting for VGH ranging from 0x00 = 7.0V to 0x0B = 18.0V
  216. * in 1V steps, the default is 0x08 which means 15V
  217. */
  218. u8 vgh[NT35510_P1_VGH_LEN];
  219. /**
  220. * @bt4ctr: setting for boost power control for the VGH step-up
  221. * circuit (4)
  222. * bits 0..2 in the lower nibble controls HCK, the booster clock
  223. * frequency, the values are the same as for PCK in @bt1ctr.
  224. * bits 4..5 in the upper nibble controls BTH, the boosting
  225. * amplification for the step-up circuit.
  226. * 0 = AVDD + VDDB
  227. * 1 = AVDD - AVEE
  228. * 2 = AVDD - AVEE + VDDB
  229. * 3 = AVDD x 2 - AVEE
  230. * The defaults are 4 and 3 yielding 0x34
  231. */
  232. u8 bt4ctr[NT35510_P1_BT4CTR_LEN];
  233. /**
  234. * @vgl: setting for VGL ranging from 0x00 = -2V to 0x0f = -15V in
  235. * 1V steps, the default is 0x08 which means -10V
  236. */
  237. u8 vgl[NT35510_P1_VGL_LEN];
  238. /**
  239. * @bt5ctr: setting for boost power control for the VGL step-up
  240. * circuit (5)
  241. * bits 0..2 in the lower nibble controls LCK, the booster clock
  242. * frequency, the values are the same as for PCK in @bt1ctr.
  243. * bits 4..5 in the upper nibble controls BTL, the boosting
  244. * amplification for the step-up circuit.
  245. * 0 = AVEE + VCL
  246. * 1 = AVEE - AVDD
  247. * 2 = AVEE + VCL - AVDD
  248. * 3 = AVEE x 2 - AVDD
  249. * The defaults are 3 and 2 yielding 0x32
  250. */
  251. u8 bt5ctr[NT35510_P1_BT5CTR_LEN];
  252. /**
  253. * @vgp: setting for VGP, the positive gamma divider voltages
  254. * VGMP the high voltage and VGSP the low voltage.
  255. * The first byte contains bit 8 of VGMP and VGSP in bits 4 and 0
  256. * The second byte contains bit 0..7 of VGMP
  257. * The third byte contains bit 0..7 of VGSP
  258. * VGMP 0x00 = 3.0V .. 0x108 = 6.3V in steps of 12.5mV
  259. * VGSP 0x00 = 0V .. 0x111 = 3.7V in steps of 12.5mV
  260. */
  261. u8 vgp[NT35510_P1_VGP_LEN];
  262. /**
  263. * @vgn: setting for VGN, the negative gamma divider voltages,
  264. * same layout of bytes as @vgp.
  265. */
  266. u8 vgn[NT35510_P1_VGN_LEN];
  267. /**
  268. * @sdeqctr: Source driver control settings, first byte is
  269. * 0 for mode 1 and 1 for mode 2. Mode 1 uses two steps and
  270. * mode 2 uses three steps meaning EQS3 is not used in mode
  271. * 1. Mode 2 is default. The last three parameters are EQS1, EQS2
  272. * and EQS3, setting the rise time for each equalizer step:
  273. * 0x00 = 0.0 us to 0x0f = 7.5 us in steps of 0.5us. The default
  274. * is 0x07 = 3.5 us.
  275. */
  276. u8 sdeqctr[NT35510_P0_SDEQCTR_LEN];
  277. /**
  278. * @sdvpctr: power/voltage behaviour during vertical porch time
  279. */
  280. u8 sdvpctr;
  281. /**
  282. * @t1: the number of pixel clocks on one scanline, range
  283. * 0x100 (258 ticks) .. 0x3FF (1024 ticks) so the value + 1
  284. * clock ticks.
  285. */
  286. u16 t1;
  287. /**
  288. * @vbp: vertical back porch toward the PANEL note: not toward
  289. * the DSI host; these are separate interfaces, in from DSI host
  290. * and out to the panel.
  291. */
  292. u8 vbp;
  293. /**
  294. * @vfp: vertical front porch toward the PANEL.
  295. */
  296. u8 vfp;
  297. /**
  298. * @psel: pixel clock divisor: 0 = 1, 1 = 2, 2 = 4, 3 = 8.
  299. */
  300. u8 psel;
  301. /**
  302. * @dpmctr12: Display timing control 12
  303. * Byte 1 bit 4 selects LVGL voltage level: 0 = VGLX, 1 = VGL_REG
  304. * Byte 1 bit 1 selects gate signal mode: 0 = non-overlap, 1 = overlap
  305. * Byte 1 bit 0 selects output signal control R/L swap, 0 = normal
  306. * 1 = swap all O->E, L->R
  307. * Byte 2 is CLW delay clock for CK O/E and CKB O/E signals:
  308. * 0x00 = 0us .. 0xFF = 12.75us in 0.05us steps
  309. * Byte 3 is FTI_H0 delay time for STP O/E signals:
  310. * 0x00 = 0us .. 0xFF = 12.75us in 0.05us steps
  311. */
  312. u8 dpmctr12[NT35510_P0_DPMCTR12_LEN];
  313. /**
  314. * @gamma_corr_pos_r: Red gamma correction parameters, positive
  315. */
  316. u8 gamma_corr_pos_r[NT35510_P1_GAMMA_LEN];
  317. /**
  318. * @gamma_corr_pos_g: Green gamma correction parameters, positive
  319. */
  320. u8 gamma_corr_pos_g[NT35510_P1_GAMMA_LEN];
  321. /**
  322. * @gamma_corr_pos_b: Blue gamma correction parameters, positive
  323. */
  324. u8 gamma_corr_pos_b[NT35510_P1_GAMMA_LEN];
  325. /**
  326. * @gamma_corr_neg_r: Red gamma correction parameters, negative
  327. */
  328. u8 gamma_corr_neg_r[NT35510_P1_GAMMA_LEN];
  329. /**
  330. * @gamma_corr_neg_g: Green gamma correction parameters, negative
  331. */
  332. u8 gamma_corr_neg_g[NT35510_P1_GAMMA_LEN];
  333. /**
  334. * @gamma_corr_neg_b: Blue gamma correction parameters, negative
  335. */
  336. u8 gamma_corr_neg_b[NT35510_P1_GAMMA_LEN];
  337. };
  338. /**
  339. * struct nt35510 - state container for the NT35510 panel
  340. */
  341. struct nt35510 {
  342. /**
  343. * @dev: the container device
  344. */
  345. struct device *dev;
  346. /**
  347. * @conf: the specific panel configuration, as the NT35510
  348. * can be combined with many physical panels, they can have
  349. * different physical dimensions and gamma correction etc,
  350. * so this is stored in the config.
  351. */
  352. const struct nt35510_config *conf;
  353. /**
  354. * @panel: the DRM panel object for the instance
  355. */
  356. struct drm_panel panel;
  357. /**
  358. * @supplies: regulators supplying the panel
  359. */
  360. struct regulator_bulk_data supplies[2];
  361. /**
  362. * @reset_gpio: the reset line
  363. */
  364. struct gpio_desc *reset_gpio;
  365. };
  366. /* Manufacturer command has strictly this byte sequence */
  367. static const u8 nt35510_mauc_mtp_read_param[] = { 0xAA, 0x55, 0x25, 0x01 };
  368. static const u8 nt35510_mauc_mtp_read_setting[] = { 0x01, 0x02, 0x00, 0x20,
  369. 0x33, 0x13, 0x00, 0x40,
  370. 0x00, 0x00, 0x23, 0x02 };
  371. static const u8 nt35510_mauc_select_page_0[] = { 0x55, 0xAA, 0x52, 0x08, 0x00 };
  372. static const u8 nt35510_mauc_select_page_1[] = { 0x55, 0xAA, 0x52, 0x08, 0x01 };
  373. static const u8 nt35510_vgh_on[] = { 0x01 };
  374. static inline struct nt35510 *panel_to_nt35510(struct drm_panel *panel)
  375. {
  376. return container_of(panel, struct nt35510, panel);
  377. }
  378. #define NT35510_ROTATE_0_SETTING 0x02
  379. #define NT35510_ROTATE_180_SETTING 0x00
  380. static int nt35510_send_long(struct nt35510 *nt, struct mipi_dsi_device *dsi,
  381. u8 cmd, u8 cmdlen, const u8 *seq)
  382. {
  383. const u8 *seqp = seq;
  384. int cmdwritten = 0;
  385. int chunk = cmdlen;
  386. int ret;
  387. if (chunk > 15)
  388. chunk = 15;
  389. ret = mipi_dsi_dcs_write(dsi, cmd, seqp, chunk);
  390. if (ret < 0) {
  391. dev_err(nt->dev, "error sending DCS command seq cmd %02x\n", cmd);
  392. return ret;
  393. }
  394. cmdwritten += chunk;
  395. seqp += chunk;
  396. while (cmdwritten < cmdlen) {
  397. chunk = cmdlen - cmdwritten;
  398. if (chunk > 15)
  399. chunk = 15;
  400. ret = mipi_dsi_generic_write(dsi, seqp, chunk);
  401. if (ret < 0) {
  402. dev_err(nt->dev, "error sending generic write seq %02x\n", cmd);
  403. return ret;
  404. }
  405. cmdwritten += chunk;
  406. seqp += chunk;
  407. }
  408. dev_dbg(nt->dev, "sent command %02x %02x bytes\n", cmd, cmdlen);
  409. return 0;
  410. }
  411. static int nt35510_read_id(struct nt35510 *nt)
  412. {
  413. struct mipi_dsi_device *dsi = to_mipi_dsi_device(nt->dev);
  414. u8 id1, id2, id3;
  415. int ret;
  416. ret = mipi_dsi_dcs_read(dsi, MCS_CMD_READ_ID1, &id1, 1);
  417. if (ret < 0) {
  418. dev_err(nt->dev, "could not read MTP ID1\n");
  419. return ret;
  420. }
  421. ret = mipi_dsi_dcs_read(dsi, MCS_CMD_READ_ID2, &id2, 1);
  422. if (ret < 0) {
  423. dev_err(nt->dev, "could not read MTP ID2\n");
  424. return ret;
  425. }
  426. ret = mipi_dsi_dcs_read(dsi, MCS_CMD_READ_ID3, &id3, 1);
  427. if (ret < 0) {
  428. dev_err(nt->dev, "could not read MTP ID3\n");
  429. return ret;
  430. }
  431. /*
  432. * Multi-Time Programmable (?) memory contains manufacturer
  433. * ID (e.g. Hydis 0x55), driver ID (e.g. NT35510 0xc0) and
  434. * version.
  435. */
  436. dev_info(nt->dev, "MTP ID manufacturer: %02x version: %02x driver: %02x\n", id1, id2, id3);
  437. return 0;
  438. }
  439. /**
  440. * nt35510_setup_power() - set up power config in page 1
  441. * @nt: the display instance to set up
  442. */
  443. static int nt35510_setup_power(struct nt35510 *nt)
  444. {
  445. struct mipi_dsi_device *dsi = to_mipi_dsi_device(nt->dev);
  446. int ret;
  447. ret = nt35510_send_long(nt, dsi, NT35510_P1_SETAVDD,
  448. NT35510_P1_AVDD_LEN,
  449. nt->conf->avdd);
  450. if (ret)
  451. return ret;
  452. ret = nt35510_send_long(nt, dsi, NT35510_P1_BT1CTR,
  453. NT35510_P1_BT1CTR_LEN,
  454. nt->conf->bt1ctr);
  455. if (ret)
  456. return ret;
  457. ret = nt35510_send_long(nt, dsi, NT35510_P1_SETAVEE,
  458. NT35510_P1_AVEE_LEN,
  459. nt->conf->avee);
  460. if (ret)
  461. return ret;
  462. ret = nt35510_send_long(nt, dsi, NT35510_P1_BT2CTR,
  463. NT35510_P1_BT2CTR_LEN,
  464. nt->conf->bt2ctr);
  465. if (ret)
  466. return ret;
  467. ret = nt35510_send_long(nt, dsi, NT35510_P1_SETVGH,
  468. NT35510_P1_VGH_LEN,
  469. nt->conf->vgh);
  470. if (ret)
  471. return ret;
  472. ret = nt35510_send_long(nt, dsi, NT35510_P1_BT4CTR,
  473. NT35510_P1_BT4CTR_LEN,
  474. nt->conf->bt4ctr);
  475. if (ret)
  476. return ret;
  477. ret = nt35510_send_long(nt, dsi, NT35510_P1_VGHCTR,
  478. ARRAY_SIZE(nt35510_vgh_on),
  479. nt35510_vgh_on);
  480. if (ret)
  481. return ret;
  482. ret = nt35510_send_long(nt, dsi, NT35510_P1_SETVGL,
  483. NT35510_P1_VGL_LEN,
  484. nt->conf->vgl);
  485. if (ret)
  486. return ret;
  487. ret = nt35510_send_long(nt, dsi, NT35510_P1_BT5CTR,
  488. NT35510_P1_BT5CTR_LEN,
  489. nt->conf->bt5ctr);
  490. if (ret)
  491. return ret;
  492. ret = nt35510_send_long(nt, dsi, NT35510_P1_SETVGP,
  493. NT35510_P1_VGP_LEN,
  494. nt->conf->vgp);
  495. if (ret)
  496. return ret;
  497. ret = nt35510_send_long(nt, dsi, NT35510_P1_SETVGN,
  498. NT35510_P1_VGN_LEN,
  499. nt->conf->vgn);
  500. if (ret)
  501. return ret;
  502. /* Typically 10 ms */
  503. usleep_range(10000, 20000);
  504. return 0;
  505. }
  506. /**
  507. * nt35510_setup_display() - set up display config in page 0
  508. * @nt: the display instance to set up
  509. */
  510. static int nt35510_setup_display(struct nt35510 *nt)
  511. {
  512. struct mipi_dsi_device *dsi = to_mipi_dsi_device(nt->dev);
  513. const struct nt35510_config *conf = nt->conf;
  514. u8 dopctr[NT35510_P0_DOPCTR_LEN];
  515. u8 gseqctr[NT35510_P0_GSEQCTR_LEN];
  516. u8 dpfrctr[NT35510_P0_DPFRCTR1_LEN];
  517. /* FIXME: set up any rotation (assume none for now) */
  518. u8 addr_mode = NT35510_ROTATE_0_SETTING;
  519. u8 val;
  520. int ret;
  521. /* Enable TE, EoTP and RGB pixel format */
  522. dopctr[0] = NT35510_DOPCTR_0_DSITE | NT35510_DOPCTR_0_EOTP |
  523. NT35510_DOPCTR_0_N565;
  524. dopctr[1] = NT35510_DOPCTR_1_CTB;
  525. ret = nt35510_send_long(nt, dsi, NT35510_P0_DOPCTR,
  526. NT35510_P0_DOPCTR_LEN,
  527. dopctr);
  528. if (ret)
  529. return ret;
  530. ret = mipi_dsi_dcs_write(dsi, MIPI_DCS_SET_ADDRESS_MODE, &addr_mode,
  531. sizeof(addr_mode));
  532. if (ret < 0)
  533. return ret;
  534. /*
  535. * Source data hold time, default 0x05 = 2.5us
  536. * 0x00..0x3F = 0 .. 31.5us in steps of 0.5us
  537. * 0x0A = 5us
  538. */
  539. val = 0x0A;
  540. ret = mipi_dsi_dcs_write(dsi, NT35510_P0_SDHDTCTR, &val,
  541. sizeof(val));
  542. if (ret < 0)
  543. return ret;
  544. /* EQ control for gate signals, 0x00 = 0 us */
  545. gseqctr[0] = 0x00;
  546. gseqctr[1] = 0x00;
  547. ret = nt35510_send_long(nt, dsi, NT35510_P0_GSEQCTR,
  548. NT35510_P0_GSEQCTR_LEN,
  549. gseqctr);
  550. if (ret)
  551. return ret;
  552. ret = nt35510_send_long(nt, dsi, NT35510_P0_SDEQCTR,
  553. NT35510_P0_SDEQCTR_LEN,
  554. conf->sdeqctr);
  555. if (ret)
  556. return ret;
  557. ret = mipi_dsi_dcs_write(dsi, NT35510_P0_SDVPCTR,
  558. &conf->sdvpctr, 1);
  559. if (ret < 0)
  560. return ret;
  561. /*
  562. * Display timing control for active and idle off mode:
  563. * the first byte contains
  564. * the two high bits of T1A and second byte the low 8 bits, and
  565. * the valid range is 0x100 (257) to 0x3ff (1023) representing
  566. * 258..1024 (+1) pixel clock ticks for one scanline. At 20MHz pixel
  567. * clock this covers the range of 12.90us .. 51.20us in steps of
  568. * 0.05us, the default is 0x184 (388) representing 389 ticks.
  569. * The third byte is VBPDA, vertical back porch display active
  570. * and the fourth VFPDA, vertical front porch display active,
  571. * both given in number of scanlines in the range 0x02..0xff
  572. * for 2..255 scanlines. The fifth byte is 2 bits selecting
  573. * PSEL for active and idle off mode, how much the 20MHz clock
  574. * is divided by 0..3. This needs to be adjusted to get the right
  575. * frame rate.
  576. */
  577. dpfrctr[0] = (conf->t1 >> 8) & 0xFF;
  578. dpfrctr[1] = conf->t1 & 0xFF;
  579. /* Vertical back porch */
  580. dpfrctr[2] = conf->vbp;
  581. /* Vertical front porch */
  582. dpfrctr[3] = conf->vfp;
  583. dpfrctr[4] = conf->psel;
  584. ret = nt35510_send_long(nt, dsi, NT35510_P0_DPFRCTR1,
  585. NT35510_P0_DPFRCTR1_LEN,
  586. dpfrctr);
  587. if (ret)
  588. return ret;
  589. /* For idle and partial idle off mode we decrease front porch by one */
  590. dpfrctr[3]--;
  591. ret = nt35510_send_long(nt, dsi, NT35510_P0_DPFRCTR2,
  592. NT35510_P0_DPFRCTR2_LEN,
  593. dpfrctr);
  594. if (ret)
  595. return ret;
  596. ret = nt35510_send_long(nt, dsi, NT35510_P0_DPFRCTR3,
  597. NT35510_P0_DPFRCTR3_LEN,
  598. dpfrctr);
  599. if (ret)
  600. return ret;
  601. /* Enable TE on vblank */
  602. ret = mipi_dsi_dcs_set_tear_on(dsi, MIPI_DSI_DCS_TEAR_MODE_VBLANK);
  603. if (ret)
  604. return ret;
  605. /* Turn on the pads? */
  606. ret = nt35510_send_long(nt, dsi, NT35510_P0_DPMCTR12,
  607. NT35510_P0_DPMCTR12_LEN,
  608. conf->dpmctr12);
  609. if (ret)
  610. return ret;
  611. return 0;
  612. }
  613. static int nt35510_set_brightness(struct backlight_device *bl)
  614. {
  615. struct nt35510 *nt = bl_get_data(bl);
  616. struct mipi_dsi_device *dsi = to_mipi_dsi_device(nt->dev);
  617. u8 brightness = bl->props.brightness;
  618. int ret;
  619. dev_dbg(nt->dev, "set brightness %d\n", brightness);
  620. ret = mipi_dsi_dcs_write(dsi, MIPI_DCS_SET_DISPLAY_BRIGHTNESS,
  621. &brightness,
  622. sizeof(brightness));
  623. if (ret < 0)
  624. return ret;
  625. return 0;
  626. }
  627. static const struct backlight_ops nt35510_bl_ops = {
  628. .update_status = nt35510_set_brightness,
  629. };
  630. /*
  631. * This power-on sequence
  632. */
  633. static int nt35510_power_on(struct nt35510 *nt)
  634. {
  635. struct mipi_dsi_device *dsi = to_mipi_dsi_device(nt->dev);
  636. int ret;
  637. ret = regulator_bulk_enable(ARRAY_SIZE(nt->supplies), nt->supplies);
  638. if (ret < 0) {
  639. dev_err(nt->dev, "unable to enable regulators\n");
  640. return ret;
  641. }
  642. /* Toggle RESET in accordance with datasheet page 370 */
  643. if (nt->reset_gpio) {
  644. gpiod_set_value(nt->reset_gpio, 1);
  645. /* Active min 10 us according to datasheet, let's say 20 */
  646. usleep_range(20, 1000);
  647. gpiod_set_value(nt->reset_gpio, 0);
  648. /*
  649. * 5 ms during sleep mode, 120 ms during sleep out mode
  650. * according to datasheet, let's use 120-140 ms.
  651. */
  652. usleep_range(120000, 140000);
  653. }
  654. ret = nt35510_send_long(nt, dsi, MCS_CMD_MTP_READ_PARAM,
  655. ARRAY_SIZE(nt35510_mauc_mtp_read_param),
  656. nt35510_mauc_mtp_read_param);
  657. if (ret)
  658. return ret;
  659. ret = nt35510_send_long(nt, dsi, MCS_CMD_MTP_READ_SETTING,
  660. ARRAY_SIZE(nt35510_mauc_mtp_read_setting),
  661. nt35510_mauc_mtp_read_setting);
  662. if (ret)
  663. return ret;
  664. nt35510_read_id(nt);
  665. /* Set up stuff in manufacturer control, page 1 */
  666. ret = nt35510_send_long(nt, dsi, MCS_CMD_MAUCCTR,
  667. ARRAY_SIZE(nt35510_mauc_select_page_1),
  668. nt35510_mauc_select_page_1);
  669. if (ret)
  670. return ret;
  671. ret = nt35510_setup_power(nt);
  672. if (ret)
  673. return ret;
  674. ret = nt35510_send_long(nt, dsi, NT35510_P1_SET_GAMMA_RED_POS,
  675. NT35510_P1_GAMMA_LEN,
  676. nt->conf->gamma_corr_pos_r);
  677. if (ret)
  678. return ret;
  679. ret = nt35510_send_long(nt, dsi, NT35510_P1_SET_GAMMA_GREEN_POS,
  680. NT35510_P1_GAMMA_LEN,
  681. nt->conf->gamma_corr_pos_g);
  682. if (ret)
  683. return ret;
  684. ret = nt35510_send_long(nt, dsi, NT35510_P1_SET_GAMMA_BLUE_POS,
  685. NT35510_P1_GAMMA_LEN,
  686. nt->conf->gamma_corr_pos_b);
  687. if (ret)
  688. return ret;
  689. ret = nt35510_send_long(nt, dsi, NT35510_P1_SET_GAMMA_RED_NEG,
  690. NT35510_P1_GAMMA_LEN,
  691. nt->conf->gamma_corr_neg_r);
  692. if (ret)
  693. return ret;
  694. ret = nt35510_send_long(nt, dsi, NT35510_P1_SET_GAMMA_GREEN_NEG,
  695. NT35510_P1_GAMMA_LEN,
  696. nt->conf->gamma_corr_neg_g);
  697. if (ret)
  698. return ret;
  699. ret = nt35510_send_long(nt, dsi, NT35510_P1_SET_GAMMA_BLUE_NEG,
  700. NT35510_P1_GAMMA_LEN,
  701. nt->conf->gamma_corr_neg_b);
  702. if (ret)
  703. return ret;
  704. /* Set up stuff in manufacturer control, page 0 */
  705. ret = nt35510_send_long(nt, dsi, MCS_CMD_MAUCCTR,
  706. ARRAY_SIZE(nt35510_mauc_select_page_0),
  707. nt35510_mauc_select_page_0);
  708. if (ret)
  709. return ret;
  710. ret = nt35510_setup_display(nt);
  711. if (ret)
  712. return ret;
  713. return 0;
  714. }
  715. static int nt35510_power_off(struct nt35510 *nt)
  716. {
  717. int ret;
  718. ret = regulator_bulk_disable(ARRAY_SIZE(nt->supplies), nt->supplies);
  719. if (ret)
  720. return ret;
  721. if (nt->reset_gpio)
  722. gpiod_set_value(nt->reset_gpio, 1);
  723. return 0;
  724. }
  725. static int nt35510_unprepare(struct drm_panel *panel)
  726. {
  727. struct nt35510 *nt = panel_to_nt35510(panel);
  728. struct mipi_dsi_device *dsi = to_mipi_dsi_device(nt->dev);
  729. int ret;
  730. ret = mipi_dsi_dcs_set_display_off(dsi);
  731. if (ret) {
  732. dev_err(nt->dev, "failed to turn display off (%d)\n", ret);
  733. return ret;
  734. }
  735. usleep_range(10000, 20000);
  736. /* Enter sleep mode */
  737. ret = mipi_dsi_dcs_enter_sleep_mode(dsi);
  738. if (ret) {
  739. dev_err(nt->dev, "failed to enter sleep mode (%d)\n", ret);
  740. return ret;
  741. }
  742. /* Wait 4 frames, how much is that 5ms in the vendor driver */
  743. usleep_range(5000, 10000);
  744. ret = nt35510_power_off(nt);
  745. if (ret)
  746. return ret;
  747. return 0;
  748. }
  749. static int nt35510_prepare(struct drm_panel *panel)
  750. {
  751. struct nt35510 *nt = panel_to_nt35510(panel);
  752. struct mipi_dsi_device *dsi = to_mipi_dsi_device(nt->dev);
  753. int ret;
  754. ret = nt35510_power_on(nt);
  755. if (ret)
  756. return ret;
  757. /* Exit sleep mode */
  758. ret = mipi_dsi_dcs_exit_sleep_mode(dsi);
  759. if (ret) {
  760. dev_err(nt->dev, "failed to exit sleep mode (%d)\n", ret);
  761. return ret;
  762. }
  763. /* Up to 120 ms */
  764. usleep_range(120000, 150000);
  765. ret = mipi_dsi_dcs_set_display_on(dsi);
  766. if (ret) {
  767. dev_err(nt->dev, "failed to turn display on (%d)\n", ret);
  768. return ret;
  769. }
  770. /* Some 10 ms */
  771. usleep_range(10000, 20000);
  772. return 0;
  773. }
  774. static int nt35510_get_modes(struct drm_panel *panel,
  775. struct drm_connector *connector)
  776. {
  777. struct nt35510 *nt = panel_to_nt35510(panel);
  778. struct drm_display_mode *mode;
  779. struct drm_display_info *info;
  780. info = &connector->display_info;
  781. info->width_mm = nt->conf->width_mm;
  782. info->height_mm = nt->conf->height_mm;
  783. mode = drm_mode_duplicate(connector->dev, &nt->conf->mode);
  784. if (!mode) {
  785. dev_err(panel->dev, "bad mode or failed to add mode\n");
  786. return -EINVAL;
  787. }
  788. drm_mode_set_name(mode);
  789. mode->type = DRM_MODE_TYPE_DRIVER | DRM_MODE_TYPE_PREFERRED;
  790. mode->width_mm = nt->conf->width_mm;
  791. mode->height_mm = nt->conf->height_mm;
  792. drm_mode_probed_add(connector, mode);
  793. return 1; /* Number of modes */
  794. }
  795. static const struct drm_panel_funcs nt35510_drm_funcs = {
  796. .unprepare = nt35510_unprepare,
  797. .prepare = nt35510_prepare,
  798. .get_modes = nt35510_get_modes,
  799. };
  800. static int nt35510_probe(struct mipi_dsi_device *dsi)
  801. {
  802. struct device *dev = &dsi->dev;
  803. struct nt35510 *nt;
  804. int ret;
  805. nt = devm_kzalloc(dev, sizeof(struct nt35510), GFP_KERNEL);
  806. if (!nt)
  807. return -ENOMEM;
  808. mipi_dsi_set_drvdata(dsi, nt);
  809. nt->dev = dev;
  810. dsi->lanes = 2;
  811. dsi->format = MIPI_DSI_FMT_RGB888;
  812. /*
  813. * Datasheet suggests max HS rate for NT35510 is 250 MHz
  814. * (period time 4ns, see figure 7.6.4 page 365) and max LP rate is
  815. * 20 MHz (period time 50ns, see figure 7.6.6. page 366).
  816. * However these frequencies appear in source code for the Hydis
  817. * HVA40WV1 panel and setting up the LP frequency makes the panel
  818. * not work.
  819. *
  820. * TODO: if other panels prove to be closer to the datasheet,
  821. * maybe make this a per-panel config in struct nt35510_config?
  822. */
  823. dsi->hs_rate = 349440000;
  824. dsi->lp_rate = 9600000;
  825. dsi->mode_flags = MIPI_DSI_CLOCK_NON_CONTINUOUS;
  826. /*
  827. * Every new incarnation of this display must have a unique
  828. * data entry for the system in this driver.
  829. */
  830. nt->conf = of_device_get_match_data(dev);
  831. if (!nt->conf) {
  832. dev_err(dev, "missing device configuration\n");
  833. return -ENODEV;
  834. }
  835. nt->supplies[0].supply = "vdd"; /* 2.3-4.8 V */
  836. nt->supplies[1].supply = "vddi"; /* 1.65-3.3V */
  837. ret = devm_regulator_bulk_get(dev, ARRAY_SIZE(nt->supplies),
  838. nt->supplies);
  839. if (ret < 0)
  840. return ret;
  841. ret = regulator_set_voltage(nt->supplies[0].consumer,
  842. 2300000, 4800000);
  843. if (ret)
  844. return ret;
  845. ret = regulator_set_voltage(nt->supplies[1].consumer,
  846. 1650000, 3300000);
  847. if (ret)
  848. return ret;
  849. nt->reset_gpio = devm_gpiod_get_optional(dev, "reset", GPIOD_ASIS);
  850. if (IS_ERR(nt->reset_gpio)) {
  851. dev_err(dev, "error getting RESET GPIO\n");
  852. return PTR_ERR(nt->reset_gpio);
  853. }
  854. drm_panel_init(&nt->panel, dev, &nt35510_drm_funcs,
  855. DRM_MODE_CONNECTOR_DSI);
  856. /*
  857. * First, try to locate an external backlight (such as on GPIO)
  858. * if this fails, assume we will want to use the internal backlight
  859. * control.
  860. */
  861. ret = drm_panel_of_backlight(&nt->panel);
  862. if (ret) {
  863. dev_err(dev, "error getting external backlight %d\n", ret);
  864. return ret;
  865. }
  866. if (!nt->panel.backlight) {
  867. struct backlight_device *bl;
  868. bl = devm_backlight_device_register(dev, "nt35510", dev, nt,
  869. &nt35510_bl_ops, NULL);
  870. if (IS_ERR(bl)) {
  871. dev_err(dev, "failed to register backlight device\n");
  872. return PTR_ERR(bl);
  873. }
  874. bl->props.max_brightness = 255;
  875. bl->props.brightness = 255;
  876. bl->props.power = FB_BLANK_POWERDOWN;
  877. nt->panel.backlight = bl;
  878. }
  879. drm_panel_add(&nt->panel);
  880. ret = mipi_dsi_attach(dsi);
  881. if (ret < 0)
  882. drm_panel_remove(&nt->panel);
  883. return 0;
  884. }
  885. static void nt35510_remove(struct mipi_dsi_device *dsi)
  886. {
  887. struct nt35510 *nt = mipi_dsi_get_drvdata(dsi);
  888. int ret;
  889. mipi_dsi_detach(dsi);
  890. /* Power off */
  891. ret = nt35510_power_off(nt);
  892. if (ret)
  893. dev_err(&dsi->dev, "Failed to power off\n");
  894. drm_panel_remove(&nt->panel);
  895. }
  896. /*
  897. * These gamma correction values are 10bit tuples, so only bits 0 and 1 is
  898. * ever used in the first byte. They form a positive and negative gamma
  899. * correction curve for each color, values must be strictly higher for each
  900. * step on the curve. As can be seen these default curves goes from 0x0001
  901. * to 0x03FE.
  902. */
  903. #define NT35510_GAMMA_POS_DEFAULT 0x00, 0x01, 0x00, 0x43, 0x00, \
  904. 0x6B, 0x00, 0x87, 0x00, 0xA3, 0x00, 0xCE, 0x00, 0xF1, 0x01, \
  905. 0x27, 0x01, 0x53, 0x01, 0x98, 0x01, 0xCE, 0x02, 0x22, 0x02, \
  906. 0x83, 0x02, 0x78, 0x02, 0x9E, 0x02, 0xDD, 0x03, 0x00, 0x03, \
  907. 0x2E, 0x03, 0x54, 0x03, 0x7F, 0x03, 0x95, 0x03, 0xB3, 0x03, \
  908. 0xC2, 0x03, 0xE1, 0x03, 0xF1, 0x03, 0xFE
  909. #define NT35510_GAMMA_NEG_DEFAULT 0x00, 0x01, 0x00, 0x43, 0x00, \
  910. 0x6B, 0x00, 0x87, 0x00, 0xA3, 0x00, 0xCE, 0x00, 0xF1, 0x01, \
  911. 0x27, 0x01, 0x53, 0x01, 0x98, 0x01, 0xCE, 0x02, 0x22, 0x02, \
  912. 0x43, 0x02, 0x50, 0x02, 0x9E, 0x02, 0xDD, 0x03, 0x00, 0x03, \
  913. 0x2E, 0x03, 0x54, 0x03, 0x7F, 0x03, 0x95, 0x03, 0xB3, 0x03, \
  914. 0xC2, 0x03, 0xE1, 0x03, 0xF1, 0x03, 0xFE
  915. /*
  916. * The Hydis HVA40WV1 panel
  917. */
  918. static const struct nt35510_config nt35510_hydis_hva40wv1 = {
  919. .width_mm = 52,
  920. .height_mm = 86,
  921. /**
  922. * As the Hydis panel is used in command mode, the porches etc
  923. * are settings programmed internally into the NT35510 controller
  924. * and generated toward the physical display. As the panel is not
  925. * used in video mode, these are not really exposed to the DSI
  926. * host.
  927. *
  928. * Display frame rate control:
  929. * Frame rate = (20 MHz / 1) / (389 * (7 + 50 + 800)) ~= 60 Hz
  930. */
  931. .mode = {
  932. /* The internal pixel clock of the NT35510 is 20 MHz */
  933. .clock = 20000,
  934. .hdisplay = 480,
  935. .hsync_start = 480 + 2, /* HFP = 2 */
  936. .hsync_end = 480 + 2 + 0, /* HSync = 0 */
  937. .htotal = 480 + 2 + 0 + 5, /* HFP = 5 */
  938. .vdisplay = 800,
  939. .vsync_start = 800 + 2, /* VFP = 2 */
  940. .vsync_end = 800 + 2 + 0, /* VSync = 0 */
  941. .vtotal = 800 + 2 + 0 + 5, /* VBP = 5 */
  942. .flags = 0,
  943. },
  944. /* 0x09: AVDD = 5.6V */
  945. .avdd = { 0x09, 0x09, 0x09 },
  946. /* 0x34: PCK = Hsync/2, BTP = 2 x VDDB */
  947. .bt1ctr = { 0x34, 0x34, 0x34 },
  948. /* 0x09: AVEE = -5.6V */
  949. .avee = { 0x09, 0x09, 0x09 },
  950. /* 0x24: NCK = Hsync/2, BTN = -2 x VDDB */
  951. .bt2ctr = { 0x24, 0x24, 0x24 },
  952. /* 0x05 = 12V */
  953. .vgh = { 0x05, 0x05, 0x05 },
  954. /* 0x24: NCKA = Hsync/2, VGH = 2 x AVDD - AVEE */
  955. .bt4ctr = { 0x24, 0x24, 0x24 },
  956. /* 0x0B = -13V */
  957. .vgl = { 0x0B, 0x0B, 0x0B },
  958. /* 0x24: LCKA = Hsync, VGL = AVDD + VCL - AVDD */
  959. .bt5ctr = { 0x24, 0x24, 0x24 },
  960. /* VGMP: 0x0A3 = 5.0375V, VGSP = 0V */
  961. .vgp = { 0x00, 0xA3, 0x00 },
  962. /* VGMP: 0x0A3 = 5.0375V, VGSP = 0V */
  963. .vgn = { 0x00, 0xA3, 0x00 },
  964. /* SDEQCTR: source driver EQ mode 2, 2.5 us rise time on each step */
  965. .sdeqctr = { 0x01, 0x05, 0x05, 0x05 },
  966. /* SDVPCTR: Normal operation off color during v porch */
  967. .sdvpctr = 0x01,
  968. /* T1: number of pixel clocks on one scanline: 0x184 = 389 clocks */
  969. .t1 = 0x0184,
  970. /* VBP: vertical back porch toward the panel */
  971. .vbp = 7,
  972. /* VFP: vertical front porch toward the panel */
  973. .vfp = 50,
  974. /* PSEL: divide pixel clock 20MHz with 1 (no clock downscaling) */
  975. .psel = 0,
  976. /* DPTMCTR12: 0x03: LVGL = VGLX, overlap mode, swap R->L O->E */
  977. .dpmctr12 = { 0x03, 0x00, 0x00, },
  978. /* Default gamma correction values */
  979. .gamma_corr_pos_r = { NT35510_GAMMA_POS_DEFAULT },
  980. .gamma_corr_pos_g = { NT35510_GAMMA_POS_DEFAULT },
  981. .gamma_corr_pos_b = { NT35510_GAMMA_POS_DEFAULT },
  982. .gamma_corr_neg_r = { NT35510_GAMMA_NEG_DEFAULT },
  983. .gamma_corr_neg_g = { NT35510_GAMMA_NEG_DEFAULT },
  984. .gamma_corr_neg_b = { NT35510_GAMMA_NEG_DEFAULT },
  985. };
  986. static const struct of_device_id nt35510_of_match[] = {
  987. {
  988. .compatible = "hydis,hva40wv1",
  989. .data = &nt35510_hydis_hva40wv1,
  990. },
  991. { }
  992. };
  993. MODULE_DEVICE_TABLE(of, nt35510_of_match);
  994. static struct mipi_dsi_driver nt35510_driver = {
  995. .probe = nt35510_probe,
  996. .remove = nt35510_remove,
  997. .driver = {
  998. .name = "panel-novatek-nt35510",
  999. .of_match_table = nt35510_of_match,
  1000. },
  1001. };
  1002. module_mipi_dsi_driver(nt35510_driver);
  1003. MODULE_AUTHOR("Linus Walleij <[email protected]>");
  1004. MODULE_DESCRIPTION("NT35510-based panel driver");
  1005. MODULE_LICENSE("GPL v2");