sh_mipi_dsi.c 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618
  1. /*
  2. * Renesas SH-mobile MIPI DSI support
  3. *
  4. * Copyright (C) 2010 Guennadi Liakhovetski <g.liakhovetski@gmx.de>
  5. *
  6. * This is free software; you can redistribute it and/or modify
  7. * it under the terms of version 2 of the GNU General Public License as
  8. * published by the Free Software Foundation.
  9. */
  10. #include <linux/bitmap.h>
  11. #include <linux/clk.h>
  12. #include <linux/delay.h>
  13. #include <linux/init.h>
  14. #include <linux/io.h>
  15. #include <linux/platform_device.h>
  16. #include <linux/pm_runtime.h>
  17. #include <linux/slab.h>
  18. #include <linux/string.h>
  19. #include <linux/types.h>
  20. #include <linux/module.h>
  21. #include <video/mipi_display.h>
  22. #include <video/sh_mipi_dsi.h>
  23. #include <video/sh_mobile_lcdc.h>
  24. #define SYSCTRL 0x0000
  25. #define SYSCONF 0x0004
  26. #define TIMSET 0x0008
  27. #define RESREQSET0 0x0018
  28. #define RESREQSET1 0x001c
  29. #define HSTTOVSET 0x0020
  30. #define LPRTOVSET 0x0024
  31. #define TATOVSET 0x0028
  32. #define PRTOVSET 0x002c
  33. #define DSICTRL 0x0030
  34. #define DSIINTE 0x0060
  35. #define PHYCTRL 0x0070
  36. /* relative to linkbase */
  37. #define DTCTR 0x0000
  38. #define VMCTR1 0x0020
  39. #define VMCTR2 0x0024
  40. #define VMLEN1 0x0028
  41. #define VMLEN2 0x002c
  42. #define CMTSRTREQ 0x0070
  43. #define CMTSRTCTR 0x00d0
  44. /* E.g., sh7372 has 2 MIPI-DSIs - one for each LCDC */
  45. #define MAX_SH_MIPI_DSI 2
  46. struct sh_mipi {
  47. void __iomem *base;
  48. void __iomem *linkbase;
  49. struct clk *dsit_clk;
  50. struct device *dev;
  51. void *next_board_data;
  52. void (*next_display_on)(void *board_data, struct fb_info *info);
  53. void (*next_display_off)(void *board_data);
  54. };
  55. static struct sh_mipi *mipi_dsi[MAX_SH_MIPI_DSI];
  56. /* Protect the above array */
  57. static DEFINE_MUTEX(array_lock);
  58. static struct sh_mipi *sh_mipi_by_handle(int handle)
  59. {
  60. if (handle >= ARRAY_SIZE(mipi_dsi) || handle < 0)
  61. return NULL;
  62. return mipi_dsi[handle];
  63. }
  64. static int sh_mipi_send_short(struct sh_mipi *mipi, u8 dsi_cmd,
  65. u8 cmd, u8 param)
  66. {
  67. u32 data = (dsi_cmd << 24) | (cmd << 16) | (param << 8);
  68. int cnt = 100;
  69. /* transmit a short packet to LCD panel */
  70. iowrite32(1 | data, mipi->linkbase + CMTSRTCTR);
  71. iowrite32(1, mipi->linkbase + CMTSRTREQ);
  72. while ((ioread32(mipi->linkbase + CMTSRTREQ) & 1) && --cnt)
  73. udelay(1);
  74. return cnt ? 0 : -ETIMEDOUT;
  75. }
  76. #define LCD_CHAN2MIPI(c) ((c) < LCDC_CHAN_MAINLCD || (c) > LCDC_CHAN_SUBLCD ? \
  77. -EINVAL : (c) - 1)
  78. static int sh_mipi_dcs(int handle, u8 cmd)
  79. {
  80. struct sh_mipi *mipi = sh_mipi_by_handle(LCD_CHAN2MIPI(handle));
  81. if (!mipi)
  82. return -ENODEV;
  83. return sh_mipi_send_short(mipi, MIPI_DSI_DCS_SHORT_WRITE, cmd, 0);
  84. }
  85. static int sh_mipi_dcs_param(int handle, u8 cmd, u8 param)
  86. {
  87. struct sh_mipi *mipi = sh_mipi_by_handle(LCD_CHAN2MIPI(handle));
  88. if (!mipi)
  89. return -ENODEV;
  90. return sh_mipi_send_short(mipi, MIPI_DSI_DCS_SHORT_WRITE_PARAM, cmd,
  91. param);
  92. }
  93. static void sh_mipi_dsi_enable(struct sh_mipi *mipi, bool enable)
  94. {
  95. /*
  96. * enable LCDC data tx, transition to LPS after completion of each HS
  97. * packet
  98. */
  99. iowrite32(0x00000002 | enable, mipi->linkbase + DTCTR);
  100. }
  101. static void sh_mipi_shutdown(struct platform_device *pdev)
  102. {
  103. struct sh_mipi *mipi = platform_get_drvdata(pdev);
  104. sh_mipi_dsi_enable(mipi, false);
  105. }
  106. static void mipi_display_on(void *arg, struct fb_info *info)
  107. {
  108. struct sh_mipi *mipi = arg;
  109. pm_runtime_get_sync(mipi->dev);
  110. sh_mipi_dsi_enable(mipi, true);
  111. if (mipi->next_display_on)
  112. mipi->next_display_on(mipi->next_board_data, info);
  113. }
  114. static void mipi_display_off(void *arg)
  115. {
  116. struct sh_mipi *mipi = arg;
  117. if (mipi->next_display_off)
  118. mipi->next_display_off(mipi->next_board_data);
  119. sh_mipi_dsi_enable(mipi, false);
  120. pm_runtime_put(mipi->dev);
  121. }
  122. static int __init sh_mipi_setup(struct sh_mipi *mipi,
  123. struct sh_mipi_dsi_info *pdata)
  124. {
  125. void __iomem *base = mipi->base;
  126. struct sh_mobile_lcdc_chan_cfg *ch = pdata->lcd_chan;
  127. u32 pctype, datatype, pixfmt, linelength, vmctr2;
  128. u32 tmp, top, bottom, delay, div;
  129. bool yuv;
  130. int bpp;
  131. /*
  132. * Select data format. MIPI DSI is not hot-pluggable, so, we just use
  133. * the default videomode. If this ever becomes a problem, We'll have to
  134. * move this to mipi_display_on() above and use info->var.xres
  135. */
  136. switch (pdata->data_format) {
  137. case MIPI_RGB888:
  138. pctype = 0;
  139. datatype = MIPI_DSI_PACKED_PIXEL_STREAM_24;
  140. pixfmt = MIPI_DCS_PIXEL_FMT_24BIT;
  141. linelength = ch->lcd_cfg[0].xres * 3;
  142. yuv = false;
  143. break;
  144. case MIPI_RGB565:
  145. pctype = 1;
  146. datatype = MIPI_DSI_PACKED_PIXEL_STREAM_16;
  147. pixfmt = MIPI_DCS_PIXEL_FMT_16BIT;
  148. linelength = ch->lcd_cfg[0].xres * 2;
  149. yuv = false;
  150. break;
  151. case MIPI_RGB666_LP:
  152. pctype = 2;
  153. datatype = MIPI_DSI_PIXEL_STREAM_3BYTE_18;
  154. pixfmt = MIPI_DCS_PIXEL_FMT_24BIT;
  155. linelength = ch->lcd_cfg[0].xres * 3;
  156. yuv = false;
  157. break;
  158. case MIPI_RGB666:
  159. pctype = 3;
  160. datatype = MIPI_DSI_PACKED_PIXEL_STREAM_18;
  161. pixfmt = MIPI_DCS_PIXEL_FMT_18BIT;
  162. linelength = (ch->lcd_cfg[0].xres * 18 + 7) / 8;
  163. yuv = false;
  164. break;
  165. case MIPI_BGR888:
  166. pctype = 8;
  167. datatype = MIPI_DSI_PACKED_PIXEL_STREAM_24;
  168. pixfmt = MIPI_DCS_PIXEL_FMT_24BIT;
  169. linelength = ch->lcd_cfg[0].xres * 3;
  170. yuv = false;
  171. break;
  172. case MIPI_BGR565:
  173. pctype = 9;
  174. datatype = MIPI_DSI_PACKED_PIXEL_STREAM_16;
  175. pixfmt = MIPI_DCS_PIXEL_FMT_16BIT;
  176. linelength = ch->lcd_cfg[0].xres * 2;
  177. yuv = false;
  178. break;
  179. case MIPI_BGR666_LP:
  180. pctype = 0xa;
  181. datatype = MIPI_DSI_PIXEL_STREAM_3BYTE_18;
  182. pixfmt = MIPI_DCS_PIXEL_FMT_24BIT;
  183. linelength = ch->lcd_cfg[0].xres * 3;
  184. yuv = false;
  185. break;
  186. case MIPI_BGR666:
  187. pctype = 0xb;
  188. datatype = MIPI_DSI_PACKED_PIXEL_STREAM_18;
  189. pixfmt = MIPI_DCS_PIXEL_FMT_18BIT;
  190. linelength = (ch->lcd_cfg[0].xres * 18 + 7) / 8;
  191. yuv = false;
  192. break;
  193. case MIPI_YUYV:
  194. pctype = 4;
  195. datatype = MIPI_DSI_PACKED_PIXEL_STREAM_YCBCR16;
  196. pixfmt = MIPI_DCS_PIXEL_FMT_16BIT;
  197. linelength = ch->lcd_cfg[0].xres * 2;
  198. yuv = true;
  199. break;
  200. case MIPI_UYVY:
  201. pctype = 5;
  202. datatype = MIPI_DSI_PACKED_PIXEL_STREAM_YCBCR16;
  203. pixfmt = MIPI_DCS_PIXEL_FMT_16BIT;
  204. linelength = ch->lcd_cfg[0].xres * 2;
  205. yuv = true;
  206. break;
  207. case MIPI_YUV420_L:
  208. pctype = 6;
  209. datatype = MIPI_DSI_PACKED_PIXEL_STREAM_YCBCR12;
  210. pixfmt = MIPI_DCS_PIXEL_FMT_12BIT;
  211. linelength = (ch->lcd_cfg[0].xres * 12 + 7) / 8;
  212. yuv = true;
  213. break;
  214. case MIPI_YUV420:
  215. pctype = 7;
  216. datatype = MIPI_DSI_PACKED_PIXEL_STREAM_YCBCR12;
  217. pixfmt = MIPI_DCS_PIXEL_FMT_12BIT;
  218. /* Length of U/V line */
  219. linelength = (ch->lcd_cfg[0].xres + 1) / 2;
  220. yuv = true;
  221. break;
  222. default:
  223. return -EINVAL;
  224. }
  225. if ((yuv && ch->interface_type != YUV422) ||
  226. (!yuv && ch->interface_type != RGB24))
  227. return -EINVAL;
  228. if (!pdata->lane)
  229. return -EINVAL;
  230. /* reset DSI link */
  231. iowrite32(0x00000001, base + SYSCTRL);
  232. /* Hold reset for 100 cycles of the slowest of bus, HS byte and LP clock */
  233. udelay(50);
  234. iowrite32(0x00000000, base + SYSCTRL);
  235. /* setup DSI link */
  236. /*
  237. * Default = ULPS enable |
  238. * Contention detection enabled |
  239. * EoT packet transmission enable |
  240. * CRC check enable |
  241. * ECC check enable
  242. * additionally enable first two lanes
  243. */
  244. bitmap_fill((unsigned long *)&tmp, pdata->lane);
  245. tmp |= 0x00003700;
  246. iowrite32(tmp, base + SYSCONF);
  247. /*
  248. * T_wakeup = 0x7000
  249. * T_hs-trail = 3
  250. * T_hs-prepare = 3
  251. * T_clk-trail = 3
  252. * T_clk-prepare = 2
  253. */
  254. iowrite32(0x70003332, base + TIMSET);
  255. /* no responses requested */
  256. iowrite32(0x00000000, base + RESREQSET0);
  257. /* request response to packets of type 0x28 */
  258. iowrite32(0x00000100, base + RESREQSET1);
  259. /* High-speed transmission timeout, default 0xffffffff */
  260. iowrite32(0x0fffffff, base + HSTTOVSET);
  261. /* LP reception timeout, default 0xffffffff */
  262. iowrite32(0x0fffffff, base + LPRTOVSET);
  263. /* Turn-around timeout, default 0xffffffff */
  264. iowrite32(0x0fffffff, base + TATOVSET);
  265. /* Peripheral reset timeout, default 0xffffffff */
  266. iowrite32(0x0fffffff, base + PRTOVSET);
  267. /* Enable timeout counters */
  268. iowrite32(0x00000f00, base + DSICTRL);
  269. /* Interrupts not used, disable all */
  270. iowrite32(0, base + DSIINTE);
  271. /* DSI-Tx bias on */
  272. iowrite32(0x00000001, base + PHYCTRL);
  273. udelay(200);
  274. /* Deassert resets, power on */
  275. iowrite32(0x03070001, base + PHYCTRL);
  276. /* setup l-bridge */
  277. /*
  278. * Enable transmission of all packets,
  279. * transmit LPS after each HS packet completion
  280. */
  281. iowrite32(0x00000006, mipi->linkbase + DTCTR);
  282. /* VSYNC width = 2 (<< 17) */
  283. iowrite32((ch->lcd_cfg[0].vsync_len << pdata->vsynw_offset) |
  284. (pdata->clksrc << 16) | (pctype << 12) | datatype,
  285. mipi->linkbase + VMCTR1);
  286. /*
  287. * Non-burst mode with sync pulses: VSE and HSE are output,
  288. * HSA period allowed, no commands in LP
  289. */
  290. vmctr2 = 0;
  291. if (pdata->flags & SH_MIPI_DSI_VSEE)
  292. vmctr2 |= 1 << 23;
  293. if (pdata->flags & SH_MIPI_DSI_HSEE)
  294. vmctr2 |= 1 << 22;
  295. if (pdata->flags & SH_MIPI_DSI_HSAE)
  296. vmctr2 |= 1 << 21;
  297. if (pdata->flags & SH_MIPI_DSI_BL2E)
  298. vmctr2 |= 1 << 17;
  299. if (pdata->flags & SH_MIPI_DSI_HSABM)
  300. vmctr2 |= 1 << 5;
  301. if (pdata->flags & SH_MIPI_DSI_HBPBM)
  302. vmctr2 |= 1 << 4;
  303. if (pdata->flags & SH_MIPI_DSI_HFPBM)
  304. vmctr2 |= 1 << 3;
  305. iowrite32(vmctr2, mipi->linkbase + VMCTR2);
  306. /*
  307. * VMLEN1 = RGBLEN | HSALEN
  308. *
  309. * see
  310. * Video mode - Blanking Packet setting
  311. */
  312. top = linelength << 16; /* RGBLEN */
  313. bottom = 0x00000001;
  314. if (pdata->flags & SH_MIPI_DSI_HSABM) /* HSALEN */
  315. bottom = (pdata->lane * ch->lcd_cfg[0].hsync_len) - 10;
  316. iowrite32(top | bottom , mipi->linkbase + VMLEN1);
  317. /*
  318. * VMLEN2 = HBPLEN | HFPLEN
  319. *
  320. * see
  321. * Video mode - Blanking Packet setting
  322. */
  323. top = 0x00010000;
  324. bottom = 0x00000001;
  325. delay = 0;
  326. div = 1; /* HSbyteCLK is calculation base
  327. * HS4divCLK = HSbyteCLK/2
  328. * HS6divCLK is not supported for now */
  329. if (pdata->flags & SH_MIPI_DSI_HS4divCLK)
  330. div = 2;
  331. if (pdata->flags & SH_MIPI_DSI_HFPBM) { /* HBPLEN */
  332. top = ch->lcd_cfg[0].hsync_len + ch->lcd_cfg[0].left_margin;
  333. top = ((pdata->lane * top / div) - 10) << 16;
  334. }
  335. if (pdata->flags & SH_MIPI_DSI_HBPBM) { /* HFPLEN */
  336. bottom = ch->lcd_cfg[0].right_margin;
  337. bottom = (pdata->lane * bottom / div) - 12;
  338. }
  339. bpp = linelength / ch->lcd_cfg[0].xres; /* byte / pixel */
  340. if ((pdata->lane / div) > bpp) {
  341. tmp = ch->lcd_cfg[0].xres / bpp; /* output cycle */
  342. tmp = ch->lcd_cfg[0].xres - tmp; /* (input - output) cycle */
  343. delay = (pdata->lane * tmp);
  344. }
  345. iowrite32(top | (bottom + delay) , mipi->linkbase + VMLEN2);
  346. msleep(5);
  347. /* setup LCD panel */
  348. /* cf. drivers/video/omap/lcd_mipid.c */
  349. sh_mipi_dcs(ch->chan, MIPI_DCS_EXIT_SLEEP_MODE);
  350. msleep(120);
  351. /*
  352. * [7] - Page Address Mode
  353. * [6] - Column Address Mode
  354. * [5] - Page / Column Address Mode
  355. * [4] - Display Device Line Refresh Order
  356. * [3] - RGB/BGR Order
  357. * [2] - Display Data Latch Data Order
  358. * [1] - Flip Horizontal
  359. * [0] - Flip Vertical
  360. */
  361. sh_mipi_dcs_param(ch->chan, MIPI_DCS_SET_ADDRESS_MODE, 0x00);
  362. /* cf. set_data_lines() */
  363. sh_mipi_dcs_param(ch->chan, MIPI_DCS_SET_PIXEL_FORMAT,
  364. pixfmt << 4);
  365. sh_mipi_dcs(ch->chan, MIPI_DCS_SET_DISPLAY_ON);
  366. return 0;
  367. }
  368. static int __init sh_mipi_probe(struct platform_device *pdev)
  369. {
  370. struct sh_mipi *mipi;
  371. struct sh_mipi_dsi_info *pdata = pdev->dev.platform_data;
  372. struct resource *res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
  373. struct resource *res2 = platform_get_resource(pdev, IORESOURCE_MEM, 1);
  374. unsigned long rate, f_current;
  375. int idx = pdev->id, ret;
  376. if (!res || !res2 || idx >= ARRAY_SIZE(mipi_dsi) || !pdata)
  377. return -ENODEV;
  378. if (!pdata->set_dot_clock)
  379. return -EINVAL;
  380. mutex_lock(&array_lock);
  381. if (idx < 0)
  382. for (idx = 0; idx < ARRAY_SIZE(mipi_dsi) && mipi_dsi[idx]; idx++)
  383. ;
  384. if (idx == ARRAY_SIZE(mipi_dsi)) {
  385. ret = -EBUSY;
  386. goto efindslot;
  387. }
  388. mipi = kzalloc(sizeof(*mipi), GFP_KERNEL);
  389. if (!mipi) {
  390. ret = -ENOMEM;
  391. goto ealloc;
  392. }
  393. if (!request_mem_region(res->start, resource_size(res), pdev->name)) {
  394. dev_err(&pdev->dev, "MIPI register region already claimed\n");
  395. ret = -EBUSY;
  396. goto ereqreg;
  397. }
  398. mipi->base = ioremap(res->start, resource_size(res));
  399. if (!mipi->base) {
  400. ret = -ENOMEM;
  401. goto emap;
  402. }
  403. if (!request_mem_region(res2->start, resource_size(res2), pdev->name)) {
  404. dev_err(&pdev->dev, "MIPI register region 2 already claimed\n");
  405. ret = -EBUSY;
  406. goto ereqreg2;
  407. }
  408. mipi->linkbase = ioremap(res2->start, resource_size(res2));
  409. if (!mipi->linkbase) {
  410. ret = -ENOMEM;
  411. goto emap2;
  412. }
  413. mipi->dev = &pdev->dev;
  414. mipi->dsit_clk = clk_get(&pdev->dev, "dsit_clk");
  415. if (IS_ERR(mipi->dsit_clk)) {
  416. ret = PTR_ERR(mipi->dsit_clk);
  417. goto eclktget;
  418. }
  419. f_current = clk_get_rate(mipi->dsit_clk);
  420. /* 80MHz required by the datasheet */
  421. rate = clk_round_rate(mipi->dsit_clk, 80000000);
  422. if (rate > 0 && rate != f_current)
  423. ret = clk_set_rate(mipi->dsit_clk, rate);
  424. else
  425. ret = rate;
  426. if (ret < 0)
  427. goto esettrate;
  428. dev_dbg(&pdev->dev, "DSI-T clk %lu -> %lu\n", f_current, rate);
  429. ret = clk_enable(mipi->dsit_clk);
  430. if (ret < 0)
  431. goto eclkton;
  432. mipi_dsi[idx] = mipi;
  433. pm_runtime_enable(&pdev->dev);
  434. pm_runtime_resume(&pdev->dev);
  435. ret = sh_mipi_setup(mipi, pdata);
  436. if (ret < 0)
  437. goto emipisetup;
  438. ret = pdata->set_dot_clock(pdev, mipi->base, 1);
  439. if (ret < 0)
  440. goto emipisetup;
  441. mutex_unlock(&array_lock);
  442. platform_set_drvdata(pdev, mipi);
  443. /* Save original LCDC callbacks */
  444. mipi->next_board_data = pdata->lcd_chan->board_cfg.board_data;
  445. mipi->next_display_on = pdata->lcd_chan->board_cfg.display_on;
  446. mipi->next_display_off = pdata->lcd_chan->board_cfg.display_off;
  447. /* Set up LCDC callbacks */
  448. pdata->lcd_chan->board_cfg.board_data = mipi;
  449. pdata->lcd_chan->board_cfg.display_on = mipi_display_on;
  450. pdata->lcd_chan->board_cfg.display_off = mipi_display_off;
  451. pdata->lcd_chan->board_cfg.owner = THIS_MODULE;
  452. return 0;
  453. emipisetup:
  454. mipi_dsi[idx] = NULL;
  455. pm_runtime_disable(&pdev->dev);
  456. clk_disable(mipi->dsit_clk);
  457. eclkton:
  458. esettrate:
  459. clk_put(mipi->dsit_clk);
  460. eclktget:
  461. iounmap(mipi->linkbase);
  462. emap2:
  463. release_mem_region(res2->start, resource_size(res2));
  464. ereqreg2:
  465. iounmap(mipi->base);
  466. emap:
  467. release_mem_region(res->start, resource_size(res));
  468. ereqreg:
  469. kfree(mipi);
  470. ealloc:
  471. efindslot:
  472. mutex_unlock(&array_lock);
  473. return ret;
  474. }
  475. static int __exit sh_mipi_remove(struct platform_device *pdev)
  476. {
  477. struct sh_mipi_dsi_info *pdata = pdev->dev.platform_data;
  478. struct resource *res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
  479. struct resource *res2 = platform_get_resource(pdev, IORESOURCE_MEM, 1);
  480. struct sh_mipi *mipi = platform_get_drvdata(pdev);
  481. int i, ret;
  482. mutex_lock(&array_lock);
  483. for (i = 0; i < ARRAY_SIZE(mipi_dsi) && mipi_dsi[i] != mipi; i++)
  484. ;
  485. if (i == ARRAY_SIZE(mipi_dsi)) {
  486. ret = -EINVAL;
  487. } else {
  488. ret = 0;
  489. mipi_dsi[i] = NULL;
  490. }
  491. mutex_unlock(&array_lock);
  492. if (ret < 0)
  493. return ret;
  494. pdata->lcd_chan->board_cfg.owner = NULL;
  495. pdata->lcd_chan->board_cfg.display_on = NULL;
  496. pdata->lcd_chan->board_cfg.display_off = NULL;
  497. pdata->lcd_chan->board_cfg.board_data = NULL;
  498. pm_runtime_disable(&pdev->dev);
  499. clk_disable(mipi->dsit_clk);
  500. clk_put(mipi->dsit_clk);
  501. pdata->set_dot_clock(pdev, mipi->base, 0);
  502. iounmap(mipi->linkbase);
  503. if (res2)
  504. release_mem_region(res2->start, resource_size(res2));
  505. iounmap(mipi->base);
  506. if (res)
  507. release_mem_region(res->start, resource_size(res));
  508. platform_set_drvdata(pdev, NULL);
  509. kfree(mipi);
  510. return 0;
  511. }
  512. static struct platform_driver sh_mipi_driver = {
  513. .remove = __exit_p(sh_mipi_remove),
  514. .shutdown = sh_mipi_shutdown,
  515. .driver = {
  516. .name = "sh-mipi-dsi",
  517. },
  518. };
  519. static int __init sh_mipi_init(void)
  520. {
  521. return platform_driver_probe(&sh_mipi_driver, sh_mipi_probe);
  522. }
  523. module_init(sh_mipi_init);
  524. static void __exit sh_mipi_exit(void)
  525. {
  526. platform_driver_unregister(&sh_mipi_driver);
  527. }
  528. module_exit(sh_mipi_exit);
  529. MODULE_AUTHOR("Guennadi Liakhovetski <g.liakhovetski@gmx.de>");
  530. MODULE_DESCRIPTION("SuperH / ARM-shmobile MIPI DSI driver");
  531. MODULE_LICENSE("GPL v2");