sun4i_tcon.c 32 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181
  1. /*
  2. * Copyright (C) 2015 Free Electrons
  3. * Copyright (C) 2015 NextThing Co
  4. *
  5. * Maxime Ripard <maxime.ripard@free-electrons.com>
  6. *
  7. * This program is free software; you can redistribute it and/or
  8. * modify it under the terms of the GNU General Public License as
  9. * published by the Free Software Foundation; either version 2 of
  10. * the License, or (at your option) any later version.
  11. */
  12. #include <drm/drmP.h>
  13. #include <drm/drm_atomic_helper.h>
  14. #include <drm/drm_crtc.h>
  15. #include <drm/drm_crtc_helper.h>
  16. #include <drm/drm_encoder.h>
  17. #include <drm/drm_modes.h>
  18. #include <drm/drm_of.h>
  19. #include <uapi/drm/drm_mode.h>
  20. #include <linux/component.h>
  21. #include <linux/ioport.h>
  22. #include <linux/of_address.h>
  23. #include <linux/of_device.h>
  24. #include <linux/of_irq.h>
  25. #include <linux/regmap.h>
  26. #include <linux/reset.h>
  27. #include "sun4i_crtc.h"
  28. #include "sun4i_dotclock.h"
  29. #include "sun4i_drv.h"
  30. #include "sun4i_lvds.h"
  31. #include "sun4i_rgb.h"
  32. #include "sun4i_tcon.h"
  33. #include "sunxi_engine.h"
  34. static struct drm_connector *sun4i_tcon_get_connector(const struct drm_encoder *encoder)
  35. {
  36. struct drm_connector *connector;
  37. struct drm_connector_list_iter iter;
  38. drm_connector_list_iter_begin(encoder->dev, &iter);
  39. drm_for_each_connector_iter(connector, &iter)
  40. if (connector->encoder == encoder) {
  41. drm_connector_list_iter_end(&iter);
  42. return connector;
  43. }
  44. drm_connector_list_iter_end(&iter);
  45. return NULL;
  46. }
  47. static int sun4i_tcon_get_pixel_depth(const struct drm_encoder *encoder)
  48. {
  49. struct drm_connector *connector;
  50. struct drm_display_info *info;
  51. connector = sun4i_tcon_get_connector(encoder);
  52. if (!connector)
  53. return -EINVAL;
  54. info = &connector->display_info;
  55. if (info->num_bus_formats != 1)
  56. return -EINVAL;
  57. switch (info->bus_formats[0]) {
  58. case MEDIA_BUS_FMT_RGB666_1X7X3_SPWG:
  59. return 18;
  60. case MEDIA_BUS_FMT_RGB888_1X7X4_JEIDA:
  61. case MEDIA_BUS_FMT_RGB888_1X7X4_SPWG:
  62. return 24;
  63. }
  64. return -EINVAL;
  65. }
  66. static void sun4i_tcon_channel_set_status(struct sun4i_tcon *tcon, int channel,
  67. bool enabled)
  68. {
  69. struct clk *clk;
  70. switch (channel) {
  71. case 0:
  72. regmap_update_bits(tcon->regs, SUN4I_TCON0_CTL_REG,
  73. SUN4I_TCON0_CTL_TCON_ENABLE,
  74. enabled ? SUN4I_TCON0_CTL_TCON_ENABLE : 0);
  75. clk = tcon->dclk;
  76. break;
  77. case 1:
  78. WARN_ON(!tcon->quirks->has_channel_1);
  79. regmap_update_bits(tcon->regs, SUN4I_TCON1_CTL_REG,
  80. SUN4I_TCON1_CTL_TCON_ENABLE,
  81. enabled ? SUN4I_TCON1_CTL_TCON_ENABLE : 0);
  82. clk = tcon->sclk1;
  83. break;
  84. default:
  85. DRM_WARN("Unknown channel... doing nothing\n");
  86. return;
  87. }
  88. if (enabled) {
  89. clk_prepare_enable(clk);
  90. clk_rate_exclusive_get(clk);
  91. } else {
  92. clk_rate_exclusive_put(clk);
  93. clk_disable_unprepare(clk);
  94. }
  95. }
  96. static void sun4i_tcon_lvds_set_status(struct sun4i_tcon *tcon,
  97. const struct drm_encoder *encoder,
  98. bool enabled)
  99. {
  100. if (enabled) {
  101. u8 val;
  102. regmap_update_bits(tcon->regs, SUN4I_TCON0_LVDS_IF_REG,
  103. SUN4I_TCON0_LVDS_IF_EN,
  104. SUN4I_TCON0_LVDS_IF_EN);
  105. /*
  106. * As their name suggest, these values only apply to the A31
  107. * and later SoCs. We'll have to rework this when merging
  108. * support for the older SoCs.
  109. */
  110. regmap_write(tcon->regs, SUN4I_TCON0_LVDS_ANA0_REG,
  111. SUN6I_TCON0_LVDS_ANA0_C(2) |
  112. SUN6I_TCON0_LVDS_ANA0_V(3) |
  113. SUN6I_TCON0_LVDS_ANA0_PD(2) |
  114. SUN6I_TCON0_LVDS_ANA0_EN_LDO);
  115. udelay(2);
  116. regmap_update_bits(tcon->regs, SUN4I_TCON0_LVDS_ANA0_REG,
  117. SUN6I_TCON0_LVDS_ANA0_EN_MB,
  118. SUN6I_TCON0_LVDS_ANA0_EN_MB);
  119. udelay(2);
  120. regmap_update_bits(tcon->regs, SUN4I_TCON0_LVDS_ANA0_REG,
  121. SUN6I_TCON0_LVDS_ANA0_EN_DRVC,
  122. SUN6I_TCON0_LVDS_ANA0_EN_DRVC);
  123. if (sun4i_tcon_get_pixel_depth(encoder) == 18)
  124. val = 7;
  125. else
  126. val = 0xf;
  127. regmap_write_bits(tcon->regs, SUN4I_TCON0_LVDS_ANA0_REG,
  128. SUN6I_TCON0_LVDS_ANA0_EN_DRVD(0xf),
  129. SUN6I_TCON0_LVDS_ANA0_EN_DRVD(val));
  130. } else {
  131. regmap_update_bits(tcon->regs, SUN4I_TCON0_LVDS_IF_REG,
  132. SUN4I_TCON0_LVDS_IF_EN, 0);
  133. }
  134. }
  135. void sun4i_tcon_set_status(struct sun4i_tcon *tcon,
  136. const struct drm_encoder *encoder,
  137. bool enabled)
  138. {
  139. bool is_lvds = false;
  140. int channel;
  141. switch (encoder->encoder_type) {
  142. case DRM_MODE_ENCODER_LVDS:
  143. is_lvds = true;
  144. /* Fallthrough */
  145. case DRM_MODE_ENCODER_NONE:
  146. channel = 0;
  147. break;
  148. case DRM_MODE_ENCODER_TMDS:
  149. case DRM_MODE_ENCODER_TVDAC:
  150. channel = 1;
  151. break;
  152. default:
  153. DRM_DEBUG_DRIVER("Unknown encoder type, doing nothing...\n");
  154. return;
  155. }
  156. if (is_lvds && !enabled)
  157. sun4i_tcon_lvds_set_status(tcon, encoder, false);
  158. regmap_update_bits(tcon->regs, SUN4I_TCON_GCTL_REG,
  159. SUN4I_TCON_GCTL_TCON_ENABLE,
  160. enabled ? SUN4I_TCON_GCTL_TCON_ENABLE : 0);
  161. if (is_lvds && enabled)
  162. sun4i_tcon_lvds_set_status(tcon, encoder, true);
  163. sun4i_tcon_channel_set_status(tcon, channel, enabled);
  164. }
  165. void sun4i_tcon_enable_vblank(struct sun4i_tcon *tcon, bool enable)
  166. {
  167. u32 mask, val = 0;
  168. DRM_DEBUG_DRIVER("%sabling VBLANK interrupt\n", enable ? "En" : "Dis");
  169. mask = SUN4I_TCON_GINT0_VBLANK_ENABLE(0) |
  170. SUN4I_TCON_GINT0_VBLANK_ENABLE(1);
  171. if (enable)
  172. val = mask;
  173. regmap_update_bits(tcon->regs, SUN4I_TCON_GINT0_REG, mask, val);
  174. }
  175. EXPORT_SYMBOL(sun4i_tcon_enable_vblank);
  176. /*
  177. * This function is a helper for TCON output muxing. The TCON output
  178. * muxing control register in earlier SoCs (without the TCON TOP block)
  179. * are located in TCON0. This helper returns a pointer to TCON0's
  180. * sun4i_tcon structure, or NULL if not found.
  181. */
  182. static struct sun4i_tcon *sun4i_get_tcon0(struct drm_device *drm)
  183. {
  184. struct sun4i_drv *drv = drm->dev_private;
  185. struct sun4i_tcon *tcon;
  186. list_for_each_entry(tcon, &drv->tcon_list, list)
  187. if (tcon->id == 0)
  188. return tcon;
  189. dev_warn(drm->dev,
  190. "TCON0 not found, display output muxing may not work\n");
  191. return NULL;
  192. }
  193. void sun4i_tcon_set_mux(struct sun4i_tcon *tcon, int channel,
  194. const struct drm_encoder *encoder)
  195. {
  196. int ret = -ENOTSUPP;
  197. if (tcon->quirks->set_mux)
  198. ret = tcon->quirks->set_mux(tcon, encoder);
  199. DRM_DEBUG_DRIVER("Muxing encoder %s to CRTC %s: %d\n",
  200. encoder->name, encoder->crtc->name, ret);
  201. }
  202. static int sun4i_tcon_get_clk_delay(const struct drm_display_mode *mode,
  203. int channel)
  204. {
  205. int delay = mode->vtotal - mode->vdisplay;
  206. if (mode->flags & DRM_MODE_FLAG_INTERLACE)
  207. delay /= 2;
  208. if (channel == 1)
  209. delay -= 2;
  210. delay = min(delay, 30);
  211. DRM_DEBUG_DRIVER("TCON %d clock delay %u\n", channel, delay);
  212. return delay;
  213. }
  214. static void sun4i_tcon0_mode_set_common(struct sun4i_tcon *tcon,
  215. const struct drm_display_mode *mode)
  216. {
  217. /* Configure the dot clock */
  218. clk_set_rate(tcon->dclk, mode->crtc_clock * 1000);
  219. /* Set the resolution */
  220. regmap_write(tcon->regs, SUN4I_TCON0_BASIC0_REG,
  221. SUN4I_TCON0_BASIC0_X(mode->crtc_hdisplay) |
  222. SUN4I_TCON0_BASIC0_Y(mode->crtc_vdisplay));
  223. }
  224. static void sun4i_tcon0_mode_set_lvds(struct sun4i_tcon *tcon,
  225. const struct drm_encoder *encoder,
  226. const struct drm_display_mode *mode)
  227. {
  228. unsigned int bp;
  229. u8 clk_delay;
  230. u32 reg, val = 0;
  231. tcon->dclk_min_div = 7;
  232. tcon->dclk_max_div = 7;
  233. sun4i_tcon0_mode_set_common(tcon, mode);
  234. /* Adjust clock delay */
  235. clk_delay = sun4i_tcon_get_clk_delay(mode, 0);
  236. regmap_update_bits(tcon->regs, SUN4I_TCON0_CTL_REG,
  237. SUN4I_TCON0_CTL_CLK_DELAY_MASK,
  238. SUN4I_TCON0_CTL_CLK_DELAY(clk_delay));
  239. /*
  240. * This is called a backporch in the register documentation,
  241. * but it really is the back porch + hsync
  242. */
  243. bp = mode->crtc_htotal - mode->crtc_hsync_start;
  244. DRM_DEBUG_DRIVER("Setting horizontal total %d, backporch %d\n",
  245. mode->crtc_htotal, bp);
  246. /* Set horizontal display timings */
  247. regmap_write(tcon->regs, SUN4I_TCON0_BASIC1_REG,
  248. SUN4I_TCON0_BASIC1_H_TOTAL(mode->htotal) |
  249. SUN4I_TCON0_BASIC1_H_BACKPORCH(bp));
  250. /*
  251. * This is called a backporch in the register documentation,
  252. * but it really is the back porch + hsync
  253. */
  254. bp = mode->crtc_vtotal - mode->crtc_vsync_start;
  255. DRM_DEBUG_DRIVER("Setting vertical total %d, backporch %d\n",
  256. mode->crtc_vtotal, bp);
  257. /* Set vertical display timings */
  258. regmap_write(tcon->regs, SUN4I_TCON0_BASIC2_REG,
  259. SUN4I_TCON0_BASIC2_V_TOTAL(mode->crtc_vtotal * 2) |
  260. SUN4I_TCON0_BASIC2_V_BACKPORCH(bp));
  261. reg = SUN4I_TCON0_LVDS_IF_CLK_SEL_TCON0 |
  262. SUN4I_TCON0_LVDS_IF_DATA_POL_NORMAL |
  263. SUN4I_TCON0_LVDS_IF_CLK_POL_NORMAL;
  264. if (sun4i_tcon_get_pixel_depth(encoder) == 24)
  265. reg |= SUN4I_TCON0_LVDS_IF_BITWIDTH_24BITS;
  266. else
  267. reg |= SUN4I_TCON0_LVDS_IF_BITWIDTH_18BITS;
  268. regmap_write(tcon->regs, SUN4I_TCON0_LVDS_IF_REG, reg);
  269. /* Setup the polarity of the various signals */
  270. if (!(mode->flags & DRM_MODE_FLAG_PHSYNC))
  271. val |= SUN4I_TCON0_IO_POL_HSYNC_POSITIVE;
  272. if (!(mode->flags & DRM_MODE_FLAG_PVSYNC))
  273. val |= SUN4I_TCON0_IO_POL_VSYNC_POSITIVE;
  274. regmap_write(tcon->regs, SUN4I_TCON0_IO_POL_REG, val);
  275. /* Map output pins to channel 0 */
  276. regmap_update_bits(tcon->regs, SUN4I_TCON_GCTL_REG,
  277. SUN4I_TCON_GCTL_IOMAP_MASK,
  278. SUN4I_TCON_GCTL_IOMAP_TCON0);
  279. /* Enable the output on the pins */
  280. regmap_write(tcon->regs, SUN4I_TCON0_IO_TRI_REG, 0xe0000000);
  281. }
  282. static void sun4i_tcon0_mode_set_rgb(struct sun4i_tcon *tcon,
  283. const struct drm_display_mode *mode)
  284. {
  285. unsigned int bp, hsync, vsync;
  286. u8 clk_delay;
  287. u32 val = 0;
  288. tcon->dclk_min_div = 6;
  289. tcon->dclk_max_div = 127;
  290. sun4i_tcon0_mode_set_common(tcon, mode);
  291. /* Adjust clock delay */
  292. clk_delay = sun4i_tcon_get_clk_delay(mode, 0);
  293. regmap_update_bits(tcon->regs, SUN4I_TCON0_CTL_REG,
  294. SUN4I_TCON0_CTL_CLK_DELAY_MASK,
  295. SUN4I_TCON0_CTL_CLK_DELAY(clk_delay));
  296. /*
  297. * This is called a backporch in the register documentation,
  298. * but it really is the back porch + hsync
  299. */
  300. bp = mode->crtc_htotal - mode->crtc_hsync_start;
  301. DRM_DEBUG_DRIVER("Setting horizontal total %d, backporch %d\n",
  302. mode->crtc_htotal, bp);
  303. /* Set horizontal display timings */
  304. regmap_write(tcon->regs, SUN4I_TCON0_BASIC1_REG,
  305. SUN4I_TCON0_BASIC1_H_TOTAL(mode->crtc_htotal) |
  306. SUN4I_TCON0_BASIC1_H_BACKPORCH(bp));
  307. /*
  308. * This is called a backporch in the register documentation,
  309. * but it really is the back porch + hsync
  310. */
  311. bp = mode->crtc_vtotal - mode->crtc_vsync_start;
  312. DRM_DEBUG_DRIVER("Setting vertical total %d, backporch %d\n",
  313. mode->crtc_vtotal, bp);
  314. /* Set vertical display timings */
  315. regmap_write(tcon->regs, SUN4I_TCON0_BASIC2_REG,
  316. SUN4I_TCON0_BASIC2_V_TOTAL(mode->crtc_vtotal * 2) |
  317. SUN4I_TCON0_BASIC2_V_BACKPORCH(bp));
  318. /* Set Hsync and Vsync length */
  319. hsync = mode->crtc_hsync_end - mode->crtc_hsync_start;
  320. vsync = mode->crtc_vsync_end - mode->crtc_vsync_start;
  321. DRM_DEBUG_DRIVER("Setting HSYNC %d, VSYNC %d\n", hsync, vsync);
  322. regmap_write(tcon->regs, SUN4I_TCON0_BASIC3_REG,
  323. SUN4I_TCON0_BASIC3_V_SYNC(vsync) |
  324. SUN4I_TCON0_BASIC3_H_SYNC(hsync));
  325. /* Setup the polarity of the various signals */
  326. if (!(mode->flags & DRM_MODE_FLAG_PHSYNC))
  327. val |= SUN4I_TCON0_IO_POL_HSYNC_POSITIVE;
  328. if (!(mode->flags & DRM_MODE_FLAG_PVSYNC))
  329. val |= SUN4I_TCON0_IO_POL_VSYNC_POSITIVE;
  330. regmap_update_bits(tcon->regs, SUN4I_TCON0_IO_POL_REG,
  331. SUN4I_TCON0_IO_POL_HSYNC_POSITIVE | SUN4I_TCON0_IO_POL_VSYNC_POSITIVE,
  332. val);
  333. /* Map output pins to channel 0 */
  334. regmap_update_bits(tcon->regs, SUN4I_TCON_GCTL_REG,
  335. SUN4I_TCON_GCTL_IOMAP_MASK,
  336. SUN4I_TCON_GCTL_IOMAP_TCON0);
  337. /* Enable the output on the pins */
  338. regmap_write(tcon->regs, SUN4I_TCON0_IO_TRI_REG, 0);
  339. }
  340. static void sun4i_tcon1_mode_set(struct sun4i_tcon *tcon,
  341. const struct drm_display_mode *mode)
  342. {
  343. unsigned int bp, hsync, vsync, vtotal;
  344. u8 clk_delay;
  345. u32 val;
  346. WARN_ON(!tcon->quirks->has_channel_1);
  347. /* Configure the dot clock */
  348. clk_set_rate(tcon->sclk1, mode->crtc_clock * 1000);
  349. /* Adjust clock delay */
  350. clk_delay = sun4i_tcon_get_clk_delay(mode, 1);
  351. regmap_update_bits(tcon->regs, SUN4I_TCON1_CTL_REG,
  352. SUN4I_TCON1_CTL_CLK_DELAY_MASK,
  353. SUN4I_TCON1_CTL_CLK_DELAY(clk_delay));
  354. /* Set interlaced mode */
  355. if (mode->flags & DRM_MODE_FLAG_INTERLACE)
  356. val = SUN4I_TCON1_CTL_INTERLACE_ENABLE;
  357. else
  358. val = 0;
  359. regmap_update_bits(tcon->regs, SUN4I_TCON1_CTL_REG,
  360. SUN4I_TCON1_CTL_INTERLACE_ENABLE,
  361. val);
  362. /* Set the input resolution */
  363. regmap_write(tcon->regs, SUN4I_TCON1_BASIC0_REG,
  364. SUN4I_TCON1_BASIC0_X(mode->crtc_hdisplay) |
  365. SUN4I_TCON1_BASIC0_Y(mode->crtc_vdisplay));
  366. /* Set the upscaling resolution */
  367. regmap_write(tcon->regs, SUN4I_TCON1_BASIC1_REG,
  368. SUN4I_TCON1_BASIC1_X(mode->crtc_hdisplay) |
  369. SUN4I_TCON1_BASIC1_Y(mode->crtc_vdisplay));
  370. /* Set the output resolution */
  371. regmap_write(tcon->regs, SUN4I_TCON1_BASIC2_REG,
  372. SUN4I_TCON1_BASIC2_X(mode->crtc_hdisplay) |
  373. SUN4I_TCON1_BASIC2_Y(mode->crtc_vdisplay));
  374. /* Set horizontal display timings */
  375. bp = mode->crtc_htotal - mode->crtc_hsync_start;
  376. DRM_DEBUG_DRIVER("Setting horizontal total %d, backporch %d\n",
  377. mode->htotal, bp);
  378. regmap_write(tcon->regs, SUN4I_TCON1_BASIC3_REG,
  379. SUN4I_TCON1_BASIC3_H_TOTAL(mode->crtc_htotal) |
  380. SUN4I_TCON1_BASIC3_H_BACKPORCH(bp));
  381. bp = mode->crtc_vtotal - mode->crtc_vsync_start;
  382. DRM_DEBUG_DRIVER("Setting vertical total %d, backporch %d\n",
  383. mode->crtc_vtotal, bp);
  384. /*
  385. * The vertical resolution needs to be doubled in all
  386. * cases. We could use crtc_vtotal and always multiply by two,
  387. * but that leads to a rounding error in interlace when vtotal
  388. * is odd.
  389. *
  390. * This happens with TV's PAL for example, where vtotal will
  391. * be 625, crtc_vtotal 312, and thus crtc_vtotal * 2 will be
  392. * 624, which apparently confuses the hardware.
  393. *
  394. * To work around this, we will always use vtotal, and
  395. * multiply by two only if we're not in interlace.
  396. */
  397. vtotal = mode->vtotal;
  398. if (!(mode->flags & DRM_MODE_FLAG_INTERLACE))
  399. vtotal = vtotal * 2;
  400. /* Set vertical display timings */
  401. regmap_write(tcon->regs, SUN4I_TCON1_BASIC4_REG,
  402. SUN4I_TCON1_BASIC4_V_TOTAL(vtotal) |
  403. SUN4I_TCON1_BASIC4_V_BACKPORCH(bp));
  404. /* Set Hsync and Vsync length */
  405. hsync = mode->crtc_hsync_end - mode->crtc_hsync_start;
  406. vsync = mode->crtc_vsync_end - mode->crtc_vsync_start;
  407. DRM_DEBUG_DRIVER("Setting HSYNC %d, VSYNC %d\n", hsync, vsync);
  408. regmap_write(tcon->regs, SUN4I_TCON1_BASIC5_REG,
  409. SUN4I_TCON1_BASIC5_V_SYNC(vsync) |
  410. SUN4I_TCON1_BASIC5_H_SYNC(hsync));
  411. /* Map output pins to channel 1 */
  412. regmap_update_bits(tcon->regs, SUN4I_TCON_GCTL_REG,
  413. SUN4I_TCON_GCTL_IOMAP_MASK,
  414. SUN4I_TCON_GCTL_IOMAP_TCON1);
  415. }
  416. void sun4i_tcon_mode_set(struct sun4i_tcon *tcon,
  417. const struct drm_encoder *encoder,
  418. const struct drm_display_mode *mode)
  419. {
  420. switch (encoder->encoder_type) {
  421. case DRM_MODE_ENCODER_LVDS:
  422. sun4i_tcon0_mode_set_lvds(tcon, encoder, mode);
  423. break;
  424. case DRM_MODE_ENCODER_NONE:
  425. sun4i_tcon0_mode_set_rgb(tcon, mode);
  426. sun4i_tcon_set_mux(tcon, 0, encoder);
  427. break;
  428. case DRM_MODE_ENCODER_TVDAC:
  429. case DRM_MODE_ENCODER_TMDS:
  430. sun4i_tcon1_mode_set(tcon, mode);
  431. sun4i_tcon_set_mux(tcon, 1, encoder);
  432. break;
  433. default:
  434. DRM_DEBUG_DRIVER("Unknown encoder type, doing nothing...\n");
  435. }
  436. }
  437. EXPORT_SYMBOL(sun4i_tcon_mode_set);
  438. static void sun4i_tcon_finish_page_flip(struct drm_device *dev,
  439. struct sun4i_crtc *scrtc)
  440. {
  441. unsigned long flags;
  442. spin_lock_irqsave(&dev->event_lock, flags);
  443. if (scrtc->event) {
  444. drm_crtc_send_vblank_event(&scrtc->crtc, scrtc->event);
  445. drm_crtc_vblank_put(&scrtc->crtc);
  446. scrtc->event = NULL;
  447. }
  448. spin_unlock_irqrestore(&dev->event_lock, flags);
  449. }
  450. static irqreturn_t sun4i_tcon_handler(int irq, void *private)
  451. {
  452. struct sun4i_tcon *tcon = private;
  453. struct drm_device *drm = tcon->drm;
  454. struct sun4i_crtc *scrtc = tcon->crtc;
  455. unsigned int status;
  456. regmap_read(tcon->regs, SUN4I_TCON_GINT0_REG, &status);
  457. if (!(status & (SUN4I_TCON_GINT0_VBLANK_INT(0) |
  458. SUN4I_TCON_GINT0_VBLANK_INT(1))))
  459. return IRQ_NONE;
  460. drm_crtc_handle_vblank(&scrtc->crtc);
  461. sun4i_tcon_finish_page_flip(drm, scrtc);
  462. /* Acknowledge the interrupt */
  463. regmap_update_bits(tcon->regs, SUN4I_TCON_GINT0_REG,
  464. SUN4I_TCON_GINT0_VBLANK_INT(0) |
  465. SUN4I_TCON_GINT0_VBLANK_INT(1),
  466. 0);
  467. return IRQ_HANDLED;
  468. }
  469. static int sun4i_tcon_init_clocks(struct device *dev,
  470. struct sun4i_tcon *tcon)
  471. {
  472. tcon->clk = devm_clk_get(dev, "ahb");
  473. if (IS_ERR(tcon->clk)) {
  474. dev_err(dev, "Couldn't get the TCON bus clock\n");
  475. return PTR_ERR(tcon->clk);
  476. }
  477. clk_prepare_enable(tcon->clk);
  478. tcon->sclk0 = devm_clk_get(dev, "tcon-ch0");
  479. if (IS_ERR(tcon->sclk0)) {
  480. dev_err(dev, "Couldn't get the TCON channel 0 clock\n");
  481. return PTR_ERR(tcon->sclk0);
  482. }
  483. if (tcon->quirks->has_channel_1) {
  484. tcon->sclk1 = devm_clk_get(dev, "tcon-ch1");
  485. if (IS_ERR(tcon->sclk1)) {
  486. dev_err(dev, "Couldn't get the TCON channel 1 clock\n");
  487. return PTR_ERR(tcon->sclk1);
  488. }
  489. }
  490. return 0;
  491. }
  492. static void sun4i_tcon_free_clocks(struct sun4i_tcon *tcon)
  493. {
  494. clk_disable_unprepare(tcon->clk);
  495. }
  496. static int sun4i_tcon_init_irq(struct device *dev,
  497. struct sun4i_tcon *tcon)
  498. {
  499. struct platform_device *pdev = to_platform_device(dev);
  500. int irq, ret;
  501. irq = platform_get_irq(pdev, 0);
  502. if (irq < 0) {
  503. dev_err(dev, "Couldn't retrieve the TCON interrupt\n");
  504. return irq;
  505. }
  506. ret = devm_request_irq(dev, irq, sun4i_tcon_handler, 0,
  507. dev_name(dev), tcon);
  508. if (ret) {
  509. dev_err(dev, "Couldn't request the IRQ\n");
  510. return ret;
  511. }
  512. return 0;
  513. }
  514. static struct regmap_config sun4i_tcon_regmap_config = {
  515. .reg_bits = 32,
  516. .val_bits = 32,
  517. .reg_stride = 4,
  518. .max_register = 0x800,
  519. };
  520. static int sun4i_tcon_init_regmap(struct device *dev,
  521. struct sun4i_tcon *tcon)
  522. {
  523. struct platform_device *pdev = to_platform_device(dev);
  524. struct resource *res;
  525. void __iomem *regs;
  526. res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
  527. regs = devm_ioremap_resource(dev, res);
  528. if (IS_ERR(regs))
  529. return PTR_ERR(regs);
  530. tcon->regs = devm_regmap_init_mmio(dev, regs,
  531. &sun4i_tcon_regmap_config);
  532. if (IS_ERR(tcon->regs)) {
  533. dev_err(dev, "Couldn't create the TCON regmap\n");
  534. return PTR_ERR(tcon->regs);
  535. }
  536. /* Make sure the TCON is disabled and all IRQs are off */
  537. regmap_write(tcon->regs, SUN4I_TCON_GCTL_REG, 0);
  538. regmap_write(tcon->regs, SUN4I_TCON_GINT0_REG, 0);
  539. regmap_write(tcon->regs, SUN4I_TCON_GINT1_REG, 0);
  540. /* Disable IO lines and set them to tristate */
  541. regmap_write(tcon->regs, SUN4I_TCON0_IO_TRI_REG, ~0);
  542. regmap_write(tcon->regs, SUN4I_TCON1_IO_TRI_REG, ~0);
  543. return 0;
  544. }
  545. /*
  546. * On SoCs with the old display pipeline design (Display Engine 1.0),
  547. * the TCON is always tied to just one backend. Hence we can traverse
  548. * the of_graph upwards to find the backend our tcon is connected to,
  549. * and take its ID as our own.
  550. *
  551. * We can either identify backends from their compatible strings, which
  552. * means maintaining a large list of them. Or, since the backend is
  553. * registered and binded before the TCON, we can just go through the
  554. * list of registered backends and compare the device node.
  555. *
  556. * As the structures now store engines instead of backends, here this
  557. * function in fact searches the corresponding engine, and the ID is
  558. * requested via the get_id function of the engine.
  559. */
  560. static struct sunxi_engine *
  561. sun4i_tcon_find_engine_traverse(struct sun4i_drv *drv,
  562. struct device_node *node)
  563. {
  564. struct device_node *port, *ep, *remote;
  565. struct sunxi_engine *engine = ERR_PTR(-EINVAL);
  566. port = of_graph_get_port_by_id(node, 0);
  567. if (!port)
  568. return ERR_PTR(-EINVAL);
  569. /*
  570. * This only works if there is only one path from the TCON
  571. * to any display engine. Otherwise the probe order of the
  572. * TCONs and display engines is not guaranteed. They may
  573. * either bind to the wrong one, or worse, bind to the same
  574. * one if additional checks are not done.
  575. *
  576. * Bail out if there are multiple input connections.
  577. */
  578. if (of_get_available_child_count(port) != 1)
  579. goto out_put_port;
  580. /* Get the first connection without specifying an ID */
  581. ep = of_get_next_available_child(port, NULL);
  582. if (!ep)
  583. goto out_put_port;
  584. remote = of_graph_get_remote_port_parent(ep);
  585. if (!remote)
  586. goto out_put_ep;
  587. /* does this node match any registered engines? */
  588. list_for_each_entry(engine, &drv->engine_list, list)
  589. if (remote == engine->node)
  590. goto out_put_remote;
  591. /* keep looking through upstream ports */
  592. engine = sun4i_tcon_find_engine_traverse(drv, remote);
  593. out_put_remote:
  594. of_node_put(remote);
  595. out_put_ep:
  596. of_node_put(ep);
  597. out_put_port:
  598. of_node_put(port);
  599. return engine;
  600. }
  601. /*
  602. * The device tree binding says that the remote endpoint ID of any
  603. * connection between components, up to and including the TCON, of
  604. * the display pipeline should be equal to the actual ID of the local
  605. * component. Thus we can look at any one of the input connections of
  606. * the TCONs, and use that connection's remote endpoint ID as our own.
  607. *
  608. * Since the user of this function already finds the input port,
  609. * the port is passed in directly without further checks.
  610. */
  611. static int sun4i_tcon_of_get_id_from_port(struct device_node *port)
  612. {
  613. struct device_node *ep;
  614. int ret = -EINVAL;
  615. /* try finding an upstream endpoint */
  616. for_each_available_child_of_node(port, ep) {
  617. struct device_node *remote;
  618. u32 reg;
  619. remote = of_graph_get_remote_endpoint(ep);
  620. if (!remote)
  621. continue;
  622. ret = of_property_read_u32(remote, "reg", &reg);
  623. if (ret)
  624. continue;
  625. ret = reg;
  626. }
  627. return ret;
  628. }
  629. /*
  630. * Once we know the TCON's id, we can look through the list of
  631. * engines to find a matching one. We assume all engines have
  632. * been probed and added to the list.
  633. */
  634. static struct sunxi_engine *sun4i_tcon_get_engine_by_id(struct sun4i_drv *drv,
  635. int id)
  636. {
  637. struct sunxi_engine *engine;
  638. list_for_each_entry(engine, &drv->engine_list, list)
  639. if (engine->id == id)
  640. return engine;
  641. return ERR_PTR(-EINVAL);
  642. }
  643. /*
  644. * On SoCs with the old display pipeline design (Display Engine 1.0),
  645. * we assumed the TCON was always tied to just one backend. However
  646. * this proved not to be the case. On the A31, the TCON can select
  647. * either backend as its source. On the A20 (and likely on the A10),
  648. * the backend can choose which TCON to output to.
  649. *
  650. * The device tree binding says that the remote endpoint ID of any
  651. * connection between components, up to and including the TCON, of
  652. * the display pipeline should be equal to the actual ID of the local
  653. * component. Thus we should be able to look at any one of the input
  654. * connections of the TCONs, and use that connection's remote endpoint
  655. * ID as our own.
  656. *
  657. * However the connections between the backend and TCON were assumed
  658. * to be always singular, and their endpoit IDs were all incorrectly
  659. * set to 0. This means for these old device trees, we cannot just look
  660. * up the remote endpoint ID of a TCON input endpoint. TCON1 would be
  661. * incorrectly identified as TCON0.
  662. *
  663. * This function first checks if the TCON node has 2 input endpoints.
  664. * If so, then the device tree is a corrected version, and it will use
  665. * sun4i_tcon_of_get_id() and sun4i_tcon_get_engine_by_id() from above
  666. * to fetch the ID and engine directly. If not, then it is likely an
  667. * old device trees, where the endpoint IDs were incorrect, but did not
  668. * have endpoint connections between the backend and TCON across
  669. * different display pipelines. It will fall back to the old method of
  670. * traversing the of_graph to try and find a matching engine by device
  671. * node.
  672. *
  673. * In the case of single display pipeline device trees, either method
  674. * works.
  675. */
  676. static struct sunxi_engine *sun4i_tcon_find_engine(struct sun4i_drv *drv,
  677. struct device_node *node)
  678. {
  679. struct device_node *port;
  680. struct sunxi_engine *engine;
  681. port = of_graph_get_port_by_id(node, 0);
  682. if (!port)
  683. return ERR_PTR(-EINVAL);
  684. /*
  685. * Is this a corrected device tree with cross pipeline
  686. * connections between the backend and TCON?
  687. */
  688. if (of_get_child_count(port) > 1) {
  689. /* Get our ID directly from an upstream endpoint */
  690. int id = sun4i_tcon_of_get_id_from_port(port);
  691. /* Get our engine by matching our ID */
  692. engine = sun4i_tcon_get_engine_by_id(drv, id);
  693. of_node_put(port);
  694. return engine;
  695. }
  696. /* Fallback to old method by traversing input endpoints */
  697. of_node_put(port);
  698. return sun4i_tcon_find_engine_traverse(drv, node);
  699. }
  700. static int sun4i_tcon_bind(struct device *dev, struct device *master,
  701. void *data)
  702. {
  703. struct drm_device *drm = data;
  704. struct sun4i_drv *drv = drm->dev_private;
  705. struct sunxi_engine *engine;
  706. struct device_node *remote;
  707. struct sun4i_tcon *tcon;
  708. bool has_lvds_rst, has_lvds_alt, can_lvds;
  709. int ret;
  710. engine = sun4i_tcon_find_engine(drv, dev->of_node);
  711. if (IS_ERR(engine)) {
  712. dev_err(dev, "Couldn't find matching engine\n");
  713. return -EPROBE_DEFER;
  714. }
  715. tcon = devm_kzalloc(dev, sizeof(*tcon), GFP_KERNEL);
  716. if (!tcon)
  717. return -ENOMEM;
  718. dev_set_drvdata(dev, tcon);
  719. tcon->drm = drm;
  720. tcon->dev = dev;
  721. tcon->id = engine->id;
  722. tcon->quirks = of_device_get_match_data(dev);
  723. tcon->lcd_rst = devm_reset_control_get(dev, "lcd");
  724. if (IS_ERR(tcon->lcd_rst)) {
  725. dev_err(dev, "Couldn't get our reset line\n");
  726. return PTR_ERR(tcon->lcd_rst);
  727. }
  728. /* Make sure our TCON is reset */
  729. ret = reset_control_reset(tcon->lcd_rst);
  730. if (ret) {
  731. dev_err(dev, "Couldn't deassert our reset line\n");
  732. return ret;
  733. }
  734. if (tcon->quirks->supports_lvds) {
  735. /*
  736. * This can only be made optional since we've had DT
  737. * nodes without the LVDS reset properties.
  738. *
  739. * If the property is missing, just disable LVDS, and
  740. * print a warning.
  741. */
  742. tcon->lvds_rst = devm_reset_control_get_optional(dev, "lvds");
  743. if (IS_ERR(tcon->lvds_rst)) {
  744. dev_err(dev, "Couldn't get our reset line\n");
  745. return PTR_ERR(tcon->lvds_rst);
  746. } else if (tcon->lvds_rst) {
  747. has_lvds_rst = true;
  748. reset_control_reset(tcon->lvds_rst);
  749. } else {
  750. has_lvds_rst = false;
  751. }
  752. /*
  753. * This can only be made optional since we've had DT
  754. * nodes without the LVDS reset properties.
  755. *
  756. * If the property is missing, just disable LVDS, and
  757. * print a warning.
  758. */
  759. if (tcon->quirks->has_lvds_alt) {
  760. tcon->lvds_pll = devm_clk_get(dev, "lvds-alt");
  761. if (IS_ERR(tcon->lvds_pll)) {
  762. if (PTR_ERR(tcon->lvds_pll) == -ENOENT) {
  763. has_lvds_alt = false;
  764. } else {
  765. dev_err(dev, "Couldn't get the LVDS PLL\n");
  766. return PTR_ERR(tcon->lvds_pll);
  767. }
  768. } else {
  769. has_lvds_alt = true;
  770. }
  771. }
  772. if (!has_lvds_rst ||
  773. (tcon->quirks->has_lvds_alt && !has_lvds_alt)) {
  774. dev_warn(dev, "Missing LVDS properties, Please upgrade your DT\n");
  775. dev_warn(dev, "LVDS output disabled\n");
  776. can_lvds = false;
  777. } else {
  778. can_lvds = true;
  779. }
  780. } else {
  781. can_lvds = false;
  782. }
  783. ret = sun4i_tcon_init_clocks(dev, tcon);
  784. if (ret) {
  785. dev_err(dev, "Couldn't init our TCON clocks\n");
  786. goto err_assert_reset;
  787. }
  788. ret = sun4i_tcon_init_regmap(dev, tcon);
  789. if (ret) {
  790. dev_err(dev, "Couldn't init our TCON regmap\n");
  791. goto err_free_clocks;
  792. }
  793. ret = sun4i_dclk_create(dev, tcon);
  794. if (ret) {
  795. dev_err(dev, "Couldn't create our TCON dot clock\n");
  796. goto err_free_clocks;
  797. }
  798. ret = sun4i_tcon_init_irq(dev, tcon);
  799. if (ret) {
  800. dev_err(dev, "Couldn't init our TCON interrupts\n");
  801. goto err_free_dotclock;
  802. }
  803. tcon->crtc = sun4i_crtc_init(drm, engine, tcon);
  804. if (IS_ERR(tcon->crtc)) {
  805. dev_err(dev, "Couldn't create our CRTC\n");
  806. ret = PTR_ERR(tcon->crtc);
  807. goto err_free_dotclock;
  808. }
  809. /*
  810. * If we have an LVDS panel connected to the TCON, we should
  811. * just probe the LVDS connector. Otherwise, just probe RGB as
  812. * we used to.
  813. */
  814. remote = of_graph_get_remote_node(dev->of_node, 1, 0);
  815. if (of_device_is_compatible(remote, "panel-lvds"))
  816. if (can_lvds)
  817. ret = sun4i_lvds_init(drm, tcon);
  818. else
  819. ret = -EINVAL;
  820. else
  821. ret = sun4i_rgb_init(drm, tcon);
  822. of_node_put(remote);
  823. if (ret < 0)
  824. goto err_free_dotclock;
  825. if (tcon->quirks->needs_de_be_mux) {
  826. /*
  827. * We assume there is no dynamic muxing of backends
  828. * and TCONs, so we select the backend with same ID.
  829. *
  830. * While dynamic selection might be interesting, since
  831. * the CRTC is tied to the TCON, while the layers are
  832. * tied to the backends, this means, we will need to
  833. * switch between groups of layers. There might not be
  834. * a way to represent this constraint in DRM.
  835. */
  836. regmap_update_bits(tcon->regs, SUN4I_TCON0_CTL_REG,
  837. SUN4I_TCON0_CTL_SRC_SEL_MASK,
  838. tcon->id);
  839. regmap_update_bits(tcon->regs, SUN4I_TCON1_CTL_REG,
  840. SUN4I_TCON1_CTL_SRC_SEL_MASK,
  841. tcon->id);
  842. }
  843. list_add_tail(&tcon->list, &drv->tcon_list);
  844. return 0;
  845. err_free_dotclock:
  846. sun4i_dclk_free(tcon);
  847. err_free_clocks:
  848. sun4i_tcon_free_clocks(tcon);
  849. err_assert_reset:
  850. reset_control_assert(tcon->lcd_rst);
  851. return ret;
  852. }
  853. static void sun4i_tcon_unbind(struct device *dev, struct device *master,
  854. void *data)
  855. {
  856. struct sun4i_tcon *tcon = dev_get_drvdata(dev);
  857. list_del(&tcon->list);
  858. sun4i_dclk_free(tcon);
  859. sun4i_tcon_free_clocks(tcon);
  860. }
  861. static const struct component_ops sun4i_tcon_ops = {
  862. .bind = sun4i_tcon_bind,
  863. .unbind = sun4i_tcon_unbind,
  864. };
  865. static int sun4i_tcon_probe(struct platform_device *pdev)
  866. {
  867. struct device_node *node = pdev->dev.of_node;
  868. struct drm_bridge *bridge;
  869. struct drm_panel *panel;
  870. int ret;
  871. ret = drm_of_find_panel_or_bridge(node, 1, 0, &panel, &bridge);
  872. if (ret == -EPROBE_DEFER)
  873. return ret;
  874. return component_add(&pdev->dev, &sun4i_tcon_ops);
  875. }
  876. static int sun4i_tcon_remove(struct platform_device *pdev)
  877. {
  878. component_del(&pdev->dev, &sun4i_tcon_ops);
  879. return 0;
  880. }
  881. /* platform specific TCON muxing callbacks */
  882. static int sun4i_a10_tcon_set_mux(struct sun4i_tcon *tcon,
  883. const struct drm_encoder *encoder)
  884. {
  885. struct sun4i_tcon *tcon0 = sun4i_get_tcon0(encoder->dev);
  886. u32 shift;
  887. if (!tcon0)
  888. return -EINVAL;
  889. switch (encoder->encoder_type) {
  890. case DRM_MODE_ENCODER_TMDS:
  891. /* HDMI */
  892. shift = 8;
  893. break;
  894. default:
  895. return -EINVAL;
  896. }
  897. regmap_update_bits(tcon0->regs, SUN4I_TCON_MUX_CTRL_REG,
  898. 0x3 << shift, tcon->id << shift);
  899. return 0;
  900. }
  901. static int sun5i_a13_tcon_set_mux(struct sun4i_tcon *tcon,
  902. const struct drm_encoder *encoder)
  903. {
  904. u32 val;
  905. if (encoder->encoder_type == DRM_MODE_ENCODER_TVDAC)
  906. val = 1;
  907. else
  908. val = 0;
  909. /*
  910. * FIXME: Undocumented bits
  911. */
  912. return regmap_write(tcon->regs, SUN4I_TCON_MUX_CTRL_REG, val);
  913. }
  914. static int sun6i_tcon_set_mux(struct sun4i_tcon *tcon,
  915. const struct drm_encoder *encoder)
  916. {
  917. struct sun4i_tcon *tcon0 = sun4i_get_tcon0(encoder->dev);
  918. u32 shift;
  919. if (!tcon0)
  920. return -EINVAL;
  921. switch (encoder->encoder_type) {
  922. case DRM_MODE_ENCODER_TMDS:
  923. /* HDMI */
  924. shift = 8;
  925. break;
  926. default:
  927. /* TODO A31 has MIPI DSI but A31s does not */
  928. return -EINVAL;
  929. }
  930. regmap_update_bits(tcon0->regs, SUN4I_TCON_MUX_CTRL_REG,
  931. 0x3 << shift, tcon->id << shift);
  932. return 0;
  933. }
  934. static const struct sun4i_tcon_quirks sun4i_a10_quirks = {
  935. .has_channel_1 = true,
  936. .set_mux = sun4i_a10_tcon_set_mux,
  937. };
  938. static const struct sun4i_tcon_quirks sun5i_a13_quirks = {
  939. .has_channel_1 = true,
  940. .set_mux = sun5i_a13_tcon_set_mux,
  941. };
  942. static const struct sun4i_tcon_quirks sun6i_a31_quirks = {
  943. .has_channel_1 = true,
  944. .has_lvds_alt = true,
  945. .needs_de_be_mux = true,
  946. .set_mux = sun6i_tcon_set_mux,
  947. };
  948. static const struct sun4i_tcon_quirks sun6i_a31s_quirks = {
  949. .has_channel_1 = true,
  950. .needs_de_be_mux = true,
  951. };
  952. static const struct sun4i_tcon_quirks sun7i_a20_quirks = {
  953. .has_channel_1 = true,
  954. /* Same display pipeline structure as A10 */
  955. .set_mux = sun4i_a10_tcon_set_mux,
  956. };
  957. static const struct sun4i_tcon_quirks sun8i_a33_quirks = {
  958. .has_lvds_alt = true,
  959. };
  960. static const struct sun4i_tcon_quirks sun8i_a83t_lcd_quirks = {
  961. .supports_lvds = true,
  962. };
  963. static const struct sun4i_tcon_quirks sun8i_v3s_quirks = {
  964. /* nothing is supported */
  965. };
  966. /* sun4i_drv uses this list to check if a device node is a TCON */
  967. const struct of_device_id sun4i_tcon_of_table[] = {
  968. { .compatible = "allwinner,sun4i-a10-tcon", .data = &sun4i_a10_quirks },
  969. { .compatible = "allwinner,sun5i-a13-tcon", .data = &sun5i_a13_quirks },
  970. { .compatible = "allwinner,sun6i-a31-tcon", .data = &sun6i_a31_quirks },
  971. { .compatible = "allwinner,sun6i-a31s-tcon", .data = &sun6i_a31s_quirks },
  972. { .compatible = "allwinner,sun7i-a20-tcon", .data = &sun7i_a20_quirks },
  973. { .compatible = "allwinner,sun8i-a33-tcon", .data = &sun8i_a33_quirks },
  974. { .compatible = "allwinner,sun8i-a83t-tcon-lcd", .data = &sun8i_a83t_lcd_quirks },
  975. { .compatible = "allwinner,sun8i-v3s-tcon", .data = &sun8i_v3s_quirks },
  976. { }
  977. };
  978. MODULE_DEVICE_TABLE(of, sun4i_tcon_of_table);
  979. EXPORT_SYMBOL(sun4i_tcon_of_table);
  980. static struct platform_driver sun4i_tcon_platform_driver = {
  981. .probe = sun4i_tcon_probe,
  982. .remove = sun4i_tcon_remove,
  983. .driver = {
  984. .name = "sun4i-tcon",
  985. .of_match_table = sun4i_tcon_of_table,
  986. },
  987. };
  988. module_platform_driver(sun4i_tcon_platform_driver);
  989. MODULE_AUTHOR("Maxime Ripard <maxime.ripard@free-electrons.com>");
  990. MODULE_DESCRIPTION("Allwinner A10 Timing Controller Driver");
  991. MODULE_LICENSE("GPL");