sh_mipi_dsi.c 15 KB

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