dpi.c 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744
  1. /*
  2. * linux/drivers/video/omap2/dss/dpi.c
  3. *
  4. * Copyright (C) 2009 Nokia Corporation
  5. * Author: Tomi Valkeinen <tomi.valkeinen@nokia.com>
  6. *
  7. * Some code and ideas taken from drivers/video/omap/ driver
  8. * by Imre Deak.
  9. *
  10. * This program is free software; you can redistribute it and/or modify it
  11. * under the terms of the GNU General Public License version 2 as published by
  12. * the Free Software Foundation.
  13. *
  14. * This program is distributed in the hope that it will be useful, but WITHOUT
  15. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  16. * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
  17. * more details.
  18. *
  19. * You should have received a copy of the GNU General Public License along with
  20. * this program. If not, see <http://www.gnu.org/licenses/>.
  21. */
  22. #define DSS_SUBSYS_NAME "DPI"
  23. #include <linux/kernel.h>
  24. #include <linux/delay.h>
  25. #include <linux/export.h>
  26. #include <linux/err.h>
  27. #include <linux/errno.h>
  28. #include <linux/platform_device.h>
  29. #include <linux/regulator/consumer.h>
  30. #include <linux/string.h>
  31. #include <video/omapdss.h>
  32. #include "dss.h"
  33. #include "dss_features.h"
  34. static struct {
  35. struct regulator *vdds_dsi_reg;
  36. struct platform_device *dsidev;
  37. struct mutex lock;
  38. struct omap_video_timings timings;
  39. struct dss_lcd_mgr_config mgr_config;
  40. int data_lines;
  41. struct omap_dss_output output;
  42. } dpi;
  43. static struct platform_device *dpi_get_dsidev(enum omap_channel channel)
  44. {
  45. /*
  46. * XXX we can't currently use DSI PLL for DPI with OMAP3, as the DSI PLL
  47. * would also be used for DISPC fclk. Meaning, when the DPI output is
  48. * disabled, DISPC clock will be disabled, and TV out will stop.
  49. */
  50. switch (omapdss_get_version()) {
  51. case OMAPDSS_VER_OMAP24xx:
  52. case OMAPDSS_VER_OMAP34xx_ES1:
  53. case OMAPDSS_VER_OMAP34xx_ES3:
  54. case OMAPDSS_VER_OMAP3630:
  55. case OMAPDSS_VER_AM35xx:
  56. return NULL;
  57. case OMAPDSS_VER_OMAP4430_ES1:
  58. case OMAPDSS_VER_OMAP4430_ES2:
  59. case OMAPDSS_VER_OMAP4:
  60. switch (channel) {
  61. case OMAP_DSS_CHANNEL_LCD:
  62. return dsi_get_dsidev_from_id(0);
  63. case OMAP_DSS_CHANNEL_LCD2:
  64. return dsi_get_dsidev_from_id(1);
  65. default:
  66. return NULL;
  67. }
  68. case OMAPDSS_VER_OMAP5:
  69. switch (channel) {
  70. case OMAP_DSS_CHANNEL_LCD:
  71. return dsi_get_dsidev_from_id(0);
  72. case OMAP_DSS_CHANNEL_LCD3:
  73. return dsi_get_dsidev_from_id(1);
  74. default:
  75. return NULL;
  76. }
  77. default:
  78. return NULL;
  79. }
  80. }
  81. static enum omap_dss_clk_source dpi_get_alt_clk_src(enum omap_channel channel)
  82. {
  83. switch (channel) {
  84. case OMAP_DSS_CHANNEL_LCD:
  85. return OMAP_DSS_CLK_SRC_DSI_PLL_HSDIV_DISPC;
  86. case OMAP_DSS_CHANNEL_LCD2:
  87. return OMAP_DSS_CLK_SRC_DSI2_PLL_HSDIV_DISPC;
  88. default:
  89. /* this shouldn't happen */
  90. WARN_ON(1);
  91. return OMAP_DSS_CLK_SRC_FCK;
  92. }
  93. }
  94. struct dpi_clk_calc_ctx {
  95. struct platform_device *dsidev;
  96. /* inputs */
  97. unsigned long pck_min, pck_max;
  98. /* outputs */
  99. struct dsi_clock_info dsi_cinfo;
  100. struct dss_clock_info dss_cinfo;
  101. struct dispc_clock_info dispc_cinfo;
  102. };
  103. static bool dpi_calc_dispc_cb(int lckd, int pckd, unsigned long lck,
  104. unsigned long pck, void *data)
  105. {
  106. struct dpi_clk_calc_ctx *ctx = data;
  107. /*
  108. * Odd dividers give us uneven duty cycle, causing problem when level
  109. * shifted. So skip all odd dividers when the pixel clock is on the
  110. * higher side.
  111. */
  112. if (ctx->pck_min >= 1000000) {
  113. if (lckd > 1 && lckd % 2 != 0)
  114. return false;
  115. if (pckd > 1 && pckd % 2 != 0)
  116. return false;
  117. }
  118. ctx->dispc_cinfo.lck_div = lckd;
  119. ctx->dispc_cinfo.pck_div = pckd;
  120. ctx->dispc_cinfo.lck = lck;
  121. ctx->dispc_cinfo.pck = pck;
  122. return true;
  123. }
  124. static bool dpi_calc_hsdiv_cb(int regm_dispc, unsigned long dispc,
  125. void *data)
  126. {
  127. struct dpi_clk_calc_ctx *ctx = data;
  128. /*
  129. * Odd dividers give us uneven duty cycle, causing problem when level
  130. * shifted. So skip all odd dividers when the pixel clock is on the
  131. * higher side.
  132. */
  133. if (regm_dispc > 1 && regm_dispc % 2 != 0 && ctx->pck_min >= 1000000)
  134. return false;
  135. ctx->dsi_cinfo.regm_dispc = regm_dispc;
  136. ctx->dsi_cinfo.dsi_pll_hsdiv_dispc_clk = dispc;
  137. return dispc_div_calc(dispc, ctx->pck_min, ctx->pck_max,
  138. dpi_calc_dispc_cb, ctx);
  139. }
  140. static bool dpi_calc_pll_cb(int regn, int regm, unsigned long fint,
  141. unsigned long pll,
  142. void *data)
  143. {
  144. struct dpi_clk_calc_ctx *ctx = data;
  145. ctx->dsi_cinfo.regn = regn;
  146. ctx->dsi_cinfo.regm = regm;
  147. ctx->dsi_cinfo.fint = fint;
  148. ctx->dsi_cinfo.clkin4ddr = pll;
  149. return dsi_hsdiv_calc(ctx->dsidev, pll, ctx->pck_min,
  150. dpi_calc_hsdiv_cb, ctx);
  151. }
  152. static bool dpi_calc_dss_cb(int fckd, unsigned long fck, void *data)
  153. {
  154. struct dpi_clk_calc_ctx *ctx = data;
  155. ctx->dss_cinfo.fck = fck;
  156. ctx->dss_cinfo.fck_div = fckd;
  157. return dispc_div_calc(fck, ctx->pck_min, ctx->pck_max,
  158. dpi_calc_dispc_cb, ctx);
  159. }
  160. static bool dpi_dsi_clk_calc(unsigned long pck, struct dpi_clk_calc_ctx *ctx)
  161. {
  162. unsigned long clkin;
  163. unsigned long pll_min, pll_max;
  164. clkin = dsi_get_pll_clkin(dpi.dsidev);
  165. memset(ctx, 0, sizeof(*ctx));
  166. ctx->dsidev = dpi.dsidev;
  167. ctx->pck_min = pck - 1000;
  168. ctx->pck_max = pck + 1000;
  169. ctx->dsi_cinfo.clkin = clkin;
  170. pll_min = 0;
  171. pll_max = 0;
  172. return dsi_pll_calc(dpi.dsidev, clkin,
  173. pll_min, pll_max,
  174. dpi_calc_pll_cb, ctx);
  175. }
  176. static bool dpi_dss_clk_calc(unsigned long pck, struct dpi_clk_calc_ctx *ctx)
  177. {
  178. int i;
  179. /*
  180. * DSS fck gives us very few possibilities, so finding a good pixel
  181. * clock may not be possible. We try multiple times to find the clock,
  182. * each time widening the pixel clock range we look for, up to
  183. * +/- ~15MHz.
  184. */
  185. for (i = 0; i < 25; ++i) {
  186. bool ok;
  187. memset(ctx, 0, sizeof(*ctx));
  188. if (pck > 1000 * i * i * i)
  189. ctx->pck_min = max(pck - 1000 * i * i * i, 0lu);
  190. else
  191. ctx->pck_min = 0;
  192. ctx->pck_max = pck + 1000 * i * i * i;
  193. ok = dss_div_calc(ctx->pck_min, dpi_calc_dss_cb, ctx);
  194. if (ok)
  195. return ok;
  196. }
  197. return false;
  198. }
  199. static int dpi_set_dsi_clk(enum omap_channel channel,
  200. unsigned long pck_req, unsigned long *fck, int *lck_div,
  201. int *pck_div)
  202. {
  203. struct dpi_clk_calc_ctx ctx;
  204. int r;
  205. bool ok;
  206. ok = dpi_dsi_clk_calc(pck_req, &ctx);
  207. if (!ok)
  208. return -EINVAL;
  209. r = dsi_pll_set_clock_div(dpi.dsidev, &ctx.dsi_cinfo);
  210. if (r)
  211. return r;
  212. dss_select_lcd_clk_source(channel,
  213. dpi_get_alt_clk_src(channel));
  214. dpi.mgr_config.clock_info = ctx.dispc_cinfo;
  215. *fck = ctx.dsi_cinfo.dsi_pll_hsdiv_dispc_clk;
  216. *lck_div = ctx.dispc_cinfo.lck_div;
  217. *pck_div = ctx.dispc_cinfo.pck_div;
  218. return 0;
  219. }
  220. static int dpi_set_dispc_clk(unsigned long pck_req, unsigned long *fck,
  221. int *lck_div, int *pck_div)
  222. {
  223. struct dpi_clk_calc_ctx ctx;
  224. int r;
  225. bool ok;
  226. ok = dpi_dss_clk_calc(pck_req, &ctx);
  227. if (!ok)
  228. return -EINVAL;
  229. r = dss_set_clock_div(&ctx.dss_cinfo);
  230. if (r)
  231. return r;
  232. dpi.mgr_config.clock_info = ctx.dispc_cinfo;
  233. *fck = ctx.dss_cinfo.fck;
  234. *lck_div = ctx.dispc_cinfo.lck_div;
  235. *pck_div = ctx.dispc_cinfo.pck_div;
  236. return 0;
  237. }
  238. static int dpi_set_mode(struct omap_overlay_manager *mgr)
  239. {
  240. struct omap_video_timings *t = &dpi.timings;
  241. int lck_div = 0, pck_div = 0;
  242. unsigned long fck = 0;
  243. unsigned long pck;
  244. int r = 0;
  245. if (dpi.dsidev)
  246. r = dpi_set_dsi_clk(mgr->id, t->pixel_clock * 1000, &fck,
  247. &lck_div, &pck_div);
  248. else
  249. r = dpi_set_dispc_clk(t->pixel_clock * 1000, &fck,
  250. &lck_div, &pck_div);
  251. if (r)
  252. return r;
  253. pck = fck / lck_div / pck_div / 1000;
  254. if (pck != t->pixel_clock) {
  255. DSSWARN("Could not find exact pixel clock. "
  256. "Requested %d kHz, got %lu kHz\n",
  257. t->pixel_clock, pck);
  258. t->pixel_clock = pck;
  259. }
  260. dss_mgr_set_timings(mgr, t);
  261. return 0;
  262. }
  263. static void dpi_config_lcd_manager(struct omap_overlay_manager *mgr)
  264. {
  265. dpi.mgr_config.io_pad_mode = DSS_IO_PAD_MODE_BYPASS;
  266. dpi.mgr_config.stallmode = false;
  267. dpi.mgr_config.fifohandcheck = false;
  268. dpi.mgr_config.video_port_width = dpi.data_lines;
  269. dpi.mgr_config.lcden_sig_polarity = 0;
  270. dss_mgr_set_lcd_config(mgr, &dpi.mgr_config);
  271. }
  272. int omapdss_dpi_display_enable(struct omap_dss_device *dssdev)
  273. {
  274. struct omap_dss_output *out = &dpi.output;
  275. int r;
  276. mutex_lock(&dpi.lock);
  277. if (dss_has_feature(FEAT_DPI_USES_VDDS_DSI) && !dpi.vdds_dsi_reg) {
  278. DSSERR("no VDSS_DSI regulator\n");
  279. r = -ENODEV;
  280. goto err_no_reg;
  281. }
  282. if (out == NULL || out->manager == NULL) {
  283. DSSERR("failed to enable display: no output/manager\n");
  284. r = -ENODEV;
  285. goto err_no_out_mgr;
  286. }
  287. r = omap_dss_start_device(dssdev);
  288. if (r) {
  289. DSSERR("failed to start device\n");
  290. goto err_start_dev;
  291. }
  292. if (dss_has_feature(FEAT_DPI_USES_VDDS_DSI)) {
  293. r = regulator_enable(dpi.vdds_dsi_reg);
  294. if (r)
  295. goto err_reg_enable;
  296. }
  297. r = dispc_runtime_get();
  298. if (r)
  299. goto err_get_dispc;
  300. r = dss_dpi_select_source(out->manager->id);
  301. if (r)
  302. goto err_src_sel;
  303. if (dpi.dsidev) {
  304. r = dsi_runtime_get(dpi.dsidev);
  305. if (r)
  306. goto err_get_dsi;
  307. r = dsi_pll_init(dpi.dsidev, 0, 1);
  308. if (r)
  309. goto err_dsi_pll_init;
  310. }
  311. r = dpi_set_mode(out->manager);
  312. if (r)
  313. goto err_set_mode;
  314. dpi_config_lcd_manager(out->manager);
  315. mdelay(2);
  316. r = dss_mgr_enable(out->manager);
  317. if (r)
  318. goto err_mgr_enable;
  319. mutex_unlock(&dpi.lock);
  320. return 0;
  321. err_mgr_enable:
  322. err_set_mode:
  323. if (dpi.dsidev)
  324. dsi_pll_uninit(dpi.dsidev, true);
  325. err_dsi_pll_init:
  326. if (dpi.dsidev)
  327. dsi_runtime_put(dpi.dsidev);
  328. err_get_dsi:
  329. err_src_sel:
  330. dispc_runtime_put();
  331. err_get_dispc:
  332. if (dss_has_feature(FEAT_DPI_USES_VDDS_DSI))
  333. regulator_disable(dpi.vdds_dsi_reg);
  334. err_reg_enable:
  335. omap_dss_stop_device(dssdev);
  336. err_start_dev:
  337. err_no_out_mgr:
  338. err_no_reg:
  339. mutex_unlock(&dpi.lock);
  340. return r;
  341. }
  342. EXPORT_SYMBOL(omapdss_dpi_display_enable);
  343. void omapdss_dpi_display_disable(struct omap_dss_device *dssdev)
  344. {
  345. struct omap_overlay_manager *mgr = dpi.output.manager;
  346. mutex_lock(&dpi.lock);
  347. dss_mgr_disable(mgr);
  348. if (dpi.dsidev) {
  349. dss_select_lcd_clk_source(mgr->id, OMAP_DSS_CLK_SRC_FCK);
  350. dsi_pll_uninit(dpi.dsidev, true);
  351. dsi_runtime_put(dpi.dsidev);
  352. }
  353. dispc_runtime_put();
  354. if (dss_has_feature(FEAT_DPI_USES_VDDS_DSI))
  355. regulator_disable(dpi.vdds_dsi_reg);
  356. omap_dss_stop_device(dssdev);
  357. mutex_unlock(&dpi.lock);
  358. }
  359. EXPORT_SYMBOL(omapdss_dpi_display_disable);
  360. void omapdss_dpi_set_timings(struct omap_dss_device *dssdev,
  361. struct omap_video_timings *timings)
  362. {
  363. DSSDBG("dpi_set_timings\n");
  364. mutex_lock(&dpi.lock);
  365. dpi.timings = *timings;
  366. mutex_unlock(&dpi.lock);
  367. }
  368. EXPORT_SYMBOL(omapdss_dpi_set_timings);
  369. int dpi_check_timings(struct omap_dss_device *dssdev,
  370. struct omap_video_timings *timings)
  371. {
  372. struct omap_overlay_manager *mgr = dpi.output.manager;
  373. int lck_div, pck_div;
  374. unsigned long fck;
  375. unsigned long pck;
  376. struct dpi_clk_calc_ctx ctx;
  377. bool ok;
  378. if (mgr && !dispc_mgr_timings_ok(mgr->id, timings))
  379. return -EINVAL;
  380. if (timings->pixel_clock == 0)
  381. return -EINVAL;
  382. if (dpi.dsidev) {
  383. ok = dpi_dsi_clk_calc(timings->pixel_clock * 1000, &ctx);
  384. if (!ok)
  385. return -EINVAL;
  386. fck = ctx.dsi_cinfo.dsi_pll_hsdiv_dispc_clk;
  387. } else {
  388. ok = dpi_dss_clk_calc(timings->pixel_clock * 1000, &ctx);
  389. if (!ok)
  390. return -EINVAL;
  391. fck = ctx.dss_cinfo.fck;
  392. }
  393. lck_div = ctx.dispc_cinfo.lck_div;
  394. pck_div = ctx.dispc_cinfo.pck_div;
  395. pck = fck / lck_div / pck_div / 1000;
  396. timings->pixel_clock = pck;
  397. return 0;
  398. }
  399. EXPORT_SYMBOL(dpi_check_timings);
  400. void omapdss_dpi_set_data_lines(struct omap_dss_device *dssdev, int data_lines)
  401. {
  402. mutex_lock(&dpi.lock);
  403. dpi.data_lines = data_lines;
  404. mutex_unlock(&dpi.lock);
  405. }
  406. EXPORT_SYMBOL(omapdss_dpi_set_data_lines);
  407. static int dpi_verify_dsi_pll(struct platform_device *dsidev)
  408. {
  409. int r;
  410. /* do initial setup with the PLL to see if it is operational */
  411. r = dsi_runtime_get(dsidev);
  412. if (r)
  413. return r;
  414. r = dsi_pll_init(dsidev, 0, 1);
  415. if (r) {
  416. dsi_runtime_put(dsidev);
  417. return r;
  418. }
  419. dsi_pll_uninit(dsidev, true);
  420. dsi_runtime_put(dsidev);
  421. return 0;
  422. }
  423. /*
  424. * Return a hardcoded channel for the DPI output. This should work for
  425. * current use cases, but this can be later expanded to either resolve
  426. * the channel in some more dynamic manner, or get the channel as a user
  427. * parameter.
  428. */
  429. static enum omap_channel dpi_get_channel(void)
  430. {
  431. switch (omapdss_get_version()) {
  432. case OMAPDSS_VER_OMAP24xx:
  433. case OMAPDSS_VER_OMAP34xx_ES1:
  434. case OMAPDSS_VER_OMAP34xx_ES3:
  435. case OMAPDSS_VER_OMAP3630:
  436. case OMAPDSS_VER_AM35xx:
  437. return OMAP_DSS_CHANNEL_LCD;
  438. case OMAPDSS_VER_OMAP4430_ES1:
  439. case OMAPDSS_VER_OMAP4430_ES2:
  440. case OMAPDSS_VER_OMAP4:
  441. return OMAP_DSS_CHANNEL_LCD2;
  442. case OMAPDSS_VER_OMAP5:
  443. return OMAP_DSS_CHANNEL_LCD3;
  444. default:
  445. DSSWARN("unsupported DSS version\n");
  446. return OMAP_DSS_CHANNEL_LCD;
  447. }
  448. }
  449. static int dpi_init_display(struct omap_dss_device *dssdev)
  450. {
  451. struct platform_device *dsidev;
  452. DSSDBG("init_display\n");
  453. if (dss_has_feature(FEAT_DPI_USES_VDDS_DSI) &&
  454. dpi.vdds_dsi_reg == NULL) {
  455. struct regulator *vdds_dsi;
  456. vdds_dsi = dss_get_vdds_dsi();
  457. if (IS_ERR(vdds_dsi)) {
  458. DSSERR("can't get VDDS_DSI regulator\n");
  459. return PTR_ERR(vdds_dsi);
  460. }
  461. dpi.vdds_dsi_reg = vdds_dsi;
  462. }
  463. dsidev = dpi_get_dsidev(dpi.output.dispc_channel);
  464. if (dsidev && dpi_verify_dsi_pll(dsidev)) {
  465. dsidev = NULL;
  466. DSSWARN("DSI PLL not operational\n");
  467. }
  468. if (dsidev)
  469. DSSDBG("using DSI PLL for DPI clock\n");
  470. dpi.dsidev = dsidev;
  471. return 0;
  472. }
  473. static struct omap_dss_device *dpi_find_dssdev(struct platform_device *pdev)
  474. {
  475. struct omap_dss_board_info *pdata = pdev->dev.platform_data;
  476. const char *def_disp_name = omapdss_get_default_display_name();
  477. struct omap_dss_device *def_dssdev;
  478. int i;
  479. def_dssdev = NULL;
  480. for (i = 0; i < pdata->num_devices; ++i) {
  481. struct omap_dss_device *dssdev = pdata->devices[i];
  482. if (dssdev->type != OMAP_DISPLAY_TYPE_DPI)
  483. continue;
  484. if (def_dssdev == NULL)
  485. def_dssdev = dssdev;
  486. if (def_disp_name != NULL &&
  487. strcmp(dssdev->name, def_disp_name) == 0) {
  488. def_dssdev = dssdev;
  489. break;
  490. }
  491. }
  492. return def_dssdev;
  493. }
  494. static int dpi_probe_pdata(struct platform_device *dpidev)
  495. {
  496. struct omap_dss_device *plat_dssdev;
  497. struct omap_dss_device *dssdev;
  498. int r;
  499. plat_dssdev = dpi_find_dssdev(dpidev);
  500. if (!plat_dssdev)
  501. return 0;
  502. dssdev = dss_alloc_and_init_device(&dpidev->dev);
  503. if (!dssdev)
  504. return -ENOMEM;
  505. dss_copy_device_pdata(dssdev, plat_dssdev);
  506. r = dpi_init_display(dssdev);
  507. if (r) {
  508. DSSERR("device %s init failed: %d\n", dssdev->name, r);
  509. dss_put_device(dssdev);
  510. return r;
  511. }
  512. r = omapdss_output_set_device(&dpi.output, dssdev);
  513. if (r) {
  514. DSSERR("failed to connect output to new device: %s\n",
  515. dssdev->name);
  516. dss_put_device(dssdev);
  517. return r;
  518. }
  519. r = dss_add_device(dssdev);
  520. if (r) {
  521. DSSERR("device %s register failed: %d\n", dssdev->name, r);
  522. omapdss_output_unset_device(&dpi.output);
  523. dss_put_device(dssdev);
  524. return r;
  525. }
  526. return 0;
  527. }
  528. static void dpi_init_output(struct platform_device *pdev)
  529. {
  530. struct omap_dss_output *out = &dpi.output;
  531. out->pdev = pdev;
  532. out->id = OMAP_DSS_OUTPUT_DPI;
  533. out->type = OMAP_DISPLAY_TYPE_DPI;
  534. out->name = "dpi.0";
  535. out->dispc_channel = dpi_get_channel();
  536. dss_register_output(out);
  537. }
  538. static void __exit dpi_uninit_output(struct platform_device *pdev)
  539. {
  540. struct omap_dss_output *out = &dpi.output;
  541. dss_unregister_output(out);
  542. }
  543. static int omap_dpi_probe(struct platform_device *pdev)
  544. {
  545. int r;
  546. mutex_init(&dpi.lock);
  547. dpi_init_output(pdev);
  548. r = dpi_probe_pdata(pdev);
  549. if (r) {
  550. dpi_uninit_output(pdev);
  551. return r;
  552. }
  553. return 0;
  554. }
  555. static int __exit omap_dpi_remove(struct platform_device *pdev)
  556. {
  557. dss_unregister_child_devices(&pdev->dev);
  558. dpi_uninit_output(pdev);
  559. return 0;
  560. }
  561. static struct platform_driver omap_dpi_driver = {
  562. .probe = omap_dpi_probe,
  563. .remove = __exit_p(omap_dpi_remove),
  564. .driver = {
  565. .name = "omapdss_dpi",
  566. .owner = THIS_MODULE,
  567. },
  568. };
  569. int __init dpi_init_platform_driver(void)
  570. {
  571. return platform_driver_register(&omap_dpi_driver);
  572. }
  573. void __exit dpi_uninit_platform_driver(void)
  574. {
  575. platform_driver_unregister(&omap_dpi_driver);
  576. }