tilcdc_drv.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687
  1. /*
  2. * Copyright (C) 2012 Texas Instruments
  3. * Author: Rob Clark <robdclark@gmail.com>
  4. *
  5. * This program is free software; you can redistribute it and/or modify it
  6. * under the terms of the GNU General Public License version 2 as published by
  7. * the Free Software Foundation.
  8. *
  9. * This program is distributed in the hope that it will be useful, but WITHOUT
  10. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11. * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
  12. * more details.
  13. *
  14. * You should have received a copy of the GNU General Public License along with
  15. * this program. If not, see <http://www.gnu.org/licenses/>.
  16. */
  17. /* LCDC DRM driver, based on da8xx-fb */
  18. #include <linux/component.h>
  19. #include <linux/pinctrl/consumer.h>
  20. #include <linux/suspend.h>
  21. #include <drm/drm_atomic.h>
  22. #include <drm/drm_atomic_helper.h>
  23. #include <drm/drm_fb_helper.h>
  24. #include <drm/drm_gem_framebuffer_helper.h>
  25. #include "tilcdc_drv.h"
  26. #include "tilcdc_regs.h"
  27. #include "tilcdc_tfp410.h"
  28. #include "tilcdc_panel.h"
  29. #include "tilcdc_external.h"
  30. static LIST_HEAD(module_list);
  31. static const u32 tilcdc_rev1_formats[] = { DRM_FORMAT_RGB565 };
  32. static const u32 tilcdc_straight_formats[] = { DRM_FORMAT_RGB565,
  33. DRM_FORMAT_BGR888,
  34. DRM_FORMAT_XBGR8888 };
  35. static const u32 tilcdc_crossed_formats[] = { DRM_FORMAT_BGR565,
  36. DRM_FORMAT_RGB888,
  37. DRM_FORMAT_XRGB8888 };
  38. static const u32 tilcdc_legacy_formats[] = { DRM_FORMAT_RGB565,
  39. DRM_FORMAT_RGB888,
  40. DRM_FORMAT_XRGB8888 };
  41. void tilcdc_module_init(struct tilcdc_module *mod, const char *name,
  42. const struct tilcdc_module_ops *funcs)
  43. {
  44. mod->name = name;
  45. mod->funcs = funcs;
  46. INIT_LIST_HEAD(&mod->list);
  47. list_add(&mod->list, &module_list);
  48. }
  49. void tilcdc_module_cleanup(struct tilcdc_module *mod)
  50. {
  51. list_del(&mod->list);
  52. }
  53. static struct of_device_id tilcdc_of_match[];
  54. static struct drm_framebuffer *tilcdc_fb_create(struct drm_device *dev,
  55. struct drm_file *file_priv, const struct drm_mode_fb_cmd2 *mode_cmd)
  56. {
  57. return drm_gem_fb_create(dev, file_priv, mode_cmd);
  58. }
  59. static int tilcdc_atomic_check(struct drm_device *dev,
  60. struct drm_atomic_state *state)
  61. {
  62. int ret;
  63. ret = drm_atomic_helper_check_modeset(dev, state);
  64. if (ret)
  65. return ret;
  66. ret = drm_atomic_helper_check_planes(dev, state);
  67. if (ret)
  68. return ret;
  69. /*
  70. * tilcdc ->atomic_check can update ->mode_changed if pixel format
  71. * changes, hence will we check modeset changes again.
  72. */
  73. ret = drm_atomic_helper_check_modeset(dev, state);
  74. if (ret)
  75. return ret;
  76. return ret;
  77. }
  78. static int tilcdc_commit(struct drm_device *dev,
  79. struct drm_atomic_state *state,
  80. bool async)
  81. {
  82. int ret;
  83. ret = drm_atomic_helper_prepare_planes(dev, state);
  84. if (ret)
  85. return ret;
  86. ret = drm_atomic_helper_swap_state(state, true);
  87. if (ret) {
  88. drm_atomic_helper_cleanup_planes(dev, state);
  89. return ret;
  90. }
  91. /*
  92. * Everything below can be run asynchronously without the need to grab
  93. * any modeset locks at all under one condition: It must be guaranteed
  94. * that the asynchronous work has either been cancelled (if the driver
  95. * supports it, which at least requires that the framebuffers get
  96. * cleaned up with drm_atomic_helper_cleanup_planes()) or completed
  97. * before the new state gets committed on the software side with
  98. * drm_atomic_helper_swap_state().
  99. *
  100. * This scheme allows new atomic state updates to be prepared and
  101. * checked in parallel to the asynchronous completion of the previous
  102. * update. Which is important since compositors need to figure out the
  103. * composition of the next frame right after having submitted the
  104. * current layout.
  105. */
  106. drm_atomic_helper_commit_modeset_disables(dev, state);
  107. drm_atomic_helper_commit_planes(dev, state, 0);
  108. drm_atomic_helper_commit_modeset_enables(dev, state);
  109. drm_atomic_helper_wait_for_vblanks(dev, state);
  110. drm_atomic_helper_cleanup_planes(dev, state);
  111. return 0;
  112. }
  113. static const struct drm_mode_config_funcs mode_config_funcs = {
  114. .fb_create = tilcdc_fb_create,
  115. .output_poll_changed = drm_fb_helper_output_poll_changed,
  116. .atomic_check = tilcdc_atomic_check,
  117. .atomic_commit = tilcdc_commit,
  118. };
  119. static void modeset_init(struct drm_device *dev)
  120. {
  121. struct tilcdc_drm_private *priv = dev->dev_private;
  122. struct tilcdc_module *mod;
  123. list_for_each_entry(mod, &module_list, list) {
  124. DBG("loading module: %s", mod->name);
  125. mod->funcs->modeset_init(mod, dev);
  126. }
  127. dev->mode_config.min_width = 0;
  128. dev->mode_config.min_height = 0;
  129. dev->mode_config.max_width = tilcdc_crtc_max_width(priv->crtc);
  130. dev->mode_config.max_height = 2048;
  131. dev->mode_config.funcs = &mode_config_funcs;
  132. }
  133. #ifdef CONFIG_CPU_FREQ
  134. static int cpufreq_transition(struct notifier_block *nb,
  135. unsigned long val, void *data)
  136. {
  137. struct tilcdc_drm_private *priv = container_of(nb,
  138. struct tilcdc_drm_private, freq_transition);
  139. if (val == CPUFREQ_POSTCHANGE)
  140. tilcdc_crtc_update_clk(priv->crtc);
  141. return 0;
  142. }
  143. #endif
  144. /*
  145. * DRM operations:
  146. */
  147. static void tilcdc_fini(struct drm_device *dev)
  148. {
  149. struct tilcdc_drm_private *priv = dev->dev_private;
  150. #ifdef CONFIG_CPU_FREQ
  151. if (priv->freq_transition.notifier_call)
  152. cpufreq_unregister_notifier(&priv->freq_transition,
  153. CPUFREQ_TRANSITION_NOTIFIER);
  154. #endif
  155. if (priv->crtc)
  156. tilcdc_crtc_shutdown(priv->crtc);
  157. if (priv->is_registered)
  158. drm_dev_unregister(dev);
  159. drm_kms_helper_poll_fini(dev);
  160. drm_fb_cma_fbdev_fini(dev);
  161. drm_irq_uninstall(dev);
  162. drm_mode_config_cleanup(dev);
  163. tilcdc_remove_external_device(dev);
  164. if (priv->clk)
  165. clk_put(priv->clk);
  166. if (priv->mmio)
  167. iounmap(priv->mmio);
  168. if (priv->wq) {
  169. flush_workqueue(priv->wq);
  170. destroy_workqueue(priv->wq);
  171. }
  172. dev->dev_private = NULL;
  173. pm_runtime_disable(dev->dev);
  174. drm_dev_put(dev);
  175. }
  176. static int tilcdc_init(struct drm_driver *ddrv, struct device *dev)
  177. {
  178. struct drm_device *ddev;
  179. struct platform_device *pdev = to_platform_device(dev);
  180. struct device_node *node = dev->of_node;
  181. struct tilcdc_drm_private *priv;
  182. struct resource *res;
  183. u32 bpp = 0;
  184. int ret;
  185. priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL);
  186. if (!priv)
  187. return -ENOMEM;
  188. ddev = drm_dev_alloc(ddrv, dev);
  189. if (IS_ERR(ddev))
  190. return PTR_ERR(ddev);
  191. ddev->dev_private = priv;
  192. platform_set_drvdata(pdev, ddev);
  193. drm_mode_config_init(ddev);
  194. priv->is_componentized =
  195. tilcdc_get_external_components(dev, NULL) > 0;
  196. priv->wq = alloc_ordered_workqueue("tilcdc", 0);
  197. if (!priv->wq) {
  198. ret = -ENOMEM;
  199. goto init_failed;
  200. }
  201. res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
  202. if (!res) {
  203. dev_err(dev, "failed to get memory resource\n");
  204. ret = -EINVAL;
  205. goto init_failed;
  206. }
  207. priv->mmio = ioremap_nocache(res->start, resource_size(res));
  208. if (!priv->mmio) {
  209. dev_err(dev, "failed to ioremap\n");
  210. ret = -ENOMEM;
  211. goto init_failed;
  212. }
  213. priv->clk = clk_get(dev, "fck");
  214. if (IS_ERR(priv->clk)) {
  215. dev_err(dev, "failed to get functional clock\n");
  216. ret = -ENODEV;
  217. goto init_failed;
  218. }
  219. if (of_property_read_u32(node, "max-bandwidth", &priv->max_bandwidth))
  220. priv->max_bandwidth = TILCDC_DEFAULT_MAX_BANDWIDTH;
  221. DBG("Maximum Bandwidth Value %d", priv->max_bandwidth);
  222. if (of_property_read_u32(node, "max-width", &priv->max_width))
  223. priv->max_width = TILCDC_DEFAULT_MAX_WIDTH;
  224. DBG("Maximum Horizontal Pixel Width Value %dpixels", priv->max_width);
  225. if (of_property_read_u32(node, "max-pixelclock",
  226. &priv->max_pixelclock))
  227. priv->max_pixelclock = TILCDC_DEFAULT_MAX_PIXELCLOCK;
  228. DBG("Maximum Pixel Clock Value %dKHz", priv->max_pixelclock);
  229. pm_runtime_enable(dev);
  230. /* Determine LCD IP Version */
  231. pm_runtime_get_sync(dev);
  232. switch (tilcdc_read(ddev, LCDC_PID_REG)) {
  233. case 0x4c100102:
  234. priv->rev = 1;
  235. break;
  236. case 0x4f200800:
  237. case 0x4f201000:
  238. priv->rev = 2;
  239. break;
  240. default:
  241. dev_warn(dev, "Unknown PID Reg value 0x%08x, "
  242. "defaulting to LCD revision 1\n",
  243. tilcdc_read(ddev, LCDC_PID_REG));
  244. priv->rev = 1;
  245. break;
  246. }
  247. pm_runtime_put_sync(dev);
  248. if (priv->rev == 1) {
  249. DBG("Revision 1 LCDC supports only RGB565 format");
  250. priv->pixelformats = tilcdc_rev1_formats;
  251. priv->num_pixelformats = ARRAY_SIZE(tilcdc_rev1_formats);
  252. bpp = 16;
  253. } else {
  254. const char *str = "\0";
  255. of_property_read_string(node, "blue-and-red-wiring", &str);
  256. if (0 == strcmp(str, "crossed")) {
  257. DBG("Configured for crossed blue and red wires");
  258. priv->pixelformats = tilcdc_crossed_formats;
  259. priv->num_pixelformats =
  260. ARRAY_SIZE(tilcdc_crossed_formats);
  261. bpp = 32; /* Choose bpp with RGB support for fbdef */
  262. } else if (0 == strcmp(str, "straight")) {
  263. DBG("Configured for straight blue and red wires");
  264. priv->pixelformats = tilcdc_straight_formats;
  265. priv->num_pixelformats =
  266. ARRAY_SIZE(tilcdc_straight_formats);
  267. bpp = 16; /* Choose bpp with RGB support for fbdef */
  268. } else {
  269. DBG("Blue and red wiring '%s' unknown, use legacy mode",
  270. str);
  271. priv->pixelformats = tilcdc_legacy_formats;
  272. priv->num_pixelformats =
  273. ARRAY_SIZE(tilcdc_legacy_formats);
  274. bpp = 16; /* This is just a guess */
  275. }
  276. }
  277. ret = tilcdc_crtc_create(ddev);
  278. if (ret < 0) {
  279. dev_err(dev, "failed to create crtc\n");
  280. goto init_failed;
  281. }
  282. modeset_init(ddev);
  283. #ifdef CONFIG_CPU_FREQ
  284. priv->freq_transition.notifier_call = cpufreq_transition;
  285. ret = cpufreq_register_notifier(&priv->freq_transition,
  286. CPUFREQ_TRANSITION_NOTIFIER);
  287. if (ret) {
  288. dev_err(dev, "failed to register cpufreq notifier\n");
  289. priv->freq_transition.notifier_call = NULL;
  290. goto init_failed;
  291. }
  292. #endif
  293. if (priv->is_componentized) {
  294. ret = component_bind_all(dev, ddev);
  295. if (ret < 0)
  296. goto init_failed;
  297. ret = tilcdc_add_component_encoder(ddev);
  298. if (ret < 0)
  299. goto init_failed;
  300. } else {
  301. ret = tilcdc_attach_external_device(ddev);
  302. if (ret)
  303. goto init_failed;
  304. }
  305. if (!priv->external_connector &&
  306. ((priv->num_encoders == 0) || (priv->num_connectors == 0))) {
  307. dev_err(dev, "no encoders/connectors found\n");
  308. ret = -EPROBE_DEFER;
  309. goto init_failed;
  310. }
  311. ret = drm_vblank_init(ddev, 1);
  312. if (ret < 0) {
  313. dev_err(dev, "failed to initialize vblank\n");
  314. goto init_failed;
  315. }
  316. ret = drm_irq_install(ddev, platform_get_irq(pdev, 0));
  317. if (ret < 0) {
  318. dev_err(dev, "failed to install IRQ handler\n");
  319. goto init_failed;
  320. }
  321. drm_mode_config_reset(ddev);
  322. ret = drm_fb_cma_fbdev_init(ddev, bpp, 0);
  323. if (ret)
  324. goto init_failed;
  325. drm_kms_helper_poll_init(ddev);
  326. ret = drm_dev_register(ddev, 0);
  327. if (ret)
  328. goto init_failed;
  329. priv->is_registered = true;
  330. return 0;
  331. init_failed:
  332. tilcdc_fini(ddev);
  333. return ret;
  334. }
  335. static irqreturn_t tilcdc_irq(int irq, void *arg)
  336. {
  337. struct drm_device *dev = arg;
  338. struct tilcdc_drm_private *priv = dev->dev_private;
  339. return tilcdc_crtc_irq(priv->crtc);
  340. }
  341. #if defined(CONFIG_DEBUG_FS)
  342. static const struct {
  343. const char *name;
  344. uint8_t rev;
  345. uint8_t save;
  346. uint32_t reg;
  347. } registers[] = {
  348. #define REG(rev, save, reg) { #reg, rev, save, reg }
  349. /* exists in revision 1: */
  350. REG(1, false, LCDC_PID_REG),
  351. REG(1, true, LCDC_CTRL_REG),
  352. REG(1, false, LCDC_STAT_REG),
  353. REG(1, true, LCDC_RASTER_CTRL_REG),
  354. REG(1, true, LCDC_RASTER_TIMING_0_REG),
  355. REG(1, true, LCDC_RASTER_TIMING_1_REG),
  356. REG(1, true, LCDC_RASTER_TIMING_2_REG),
  357. REG(1, true, LCDC_DMA_CTRL_REG),
  358. REG(1, true, LCDC_DMA_FB_BASE_ADDR_0_REG),
  359. REG(1, true, LCDC_DMA_FB_CEILING_ADDR_0_REG),
  360. REG(1, true, LCDC_DMA_FB_BASE_ADDR_1_REG),
  361. REG(1, true, LCDC_DMA_FB_CEILING_ADDR_1_REG),
  362. /* new in revision 2: */
  363. REG(2, false, LCDC_RAW_STAT_REG),
  364. REG(2, false, LCDC_MASKED_STAT_REG),
  365. REG(2, true, LCDC_INT_ENABLE_SET_REG),
  366. REG(2, false, LCDC_INT_ENABLE_CLR_REG),
  367. REG(2, false, LCDC_END_OF_INT_IND_REG),
  368. REG(2, true, LCDC_CLK_ENABLE_REG),
  369. #undef REG
  370. };
  371. #endif
  372. #ifdef CONFIG_DEBUG_FS
  373. static int tilcdc_regs_show(struct seq_file *m, void *arg)
  374. {
  375. struct drm_info_node *node = (struct drm_info_node *) m->private;
  376. struct drm_device *dev = node->minor->dev;
  377. struct tilcdc_drm_private *priv = dev->dev_private;
  378. unsigned i;
  379. pm_runtime_get_sync(dev->dev);
  380. seq_printf(m, "revision: %d\n", priv->rev);
  381. for (i = 0; i < ARRAY_SIZE(registers); i++)
  382. if (priv->rev >= registers[i].rev)
  383. seq_printf(m, "%s:\t %08x\n", registers[i].name,
  384. tilcdc_read(dev, registers[i].reg));
  385. pm_runtime_put_sync(dev->dev);
  386. return 0;
  387. }
  388. static int tilcdc_mm_show(struct seq_file *m, void *arg)
  389. {
  390. struct drm_info_node *node = (struct drm_info_node *) m->private;
  391. struct drm_device *dev = node->minor->dev;
  392. struct drm_printer p = drm_seq_file_printer(m);
  393. drm_mm_print(&dev->vma_offset_manager->vm_addr_space_mm, &p);
  394. return 0;
  395. }
  396. static struct drm_info_list tilcdc_debugfs_list[] = {
  397. { "regs", tilcdc_regs_show, 0 },
  398. { "mm", tilcdc_mm_show, 0 },
  399. };
  400. static int tilcdc_debugfs_init(struct drm_minor *minor)
  401. {
  402. struct drm_device *dev = minor->dev;
  403. struct tilcdc_module *mod;
  404. int ret;
  405. ret = drm_debugfs_create_files(tilcdc_debugfs_list,
  406. ARRAY_SIZE(tilcdc_debugfs_list),
  407. minor->debugfs_root, minor);
  408. list_for_each_entry(mod, &module_list, list)
  409. if (mod->funcs->debugfs_init)
  410. mod->funcs->debugfs_init(mod, minor);
  411. if (ret) {
  412. dev_err(dev->dev, "could not install tilcdc_debugfs_list\n");
  413. return ret;
  414. }
  415. return ret;
  416. }
  417. #endif
  418. DEFINE_DRM_GEM_CMA_FOPS(fops);
  419. static struct drm_driver tilcdc_driver = {
  420. .driver_features = (DRIVER_HAVE_IRQ | DRIVER_GEM | DRIVER_MODESET |
  421. DRIVER_PRIME | DRIVER_ATOMIC),
  422. .lastclose = drm_fb_helper_lastclose,
  423. .irq_handler = tilcdc_irq,
  424. .gem_free_object_unlocked = drm_gem_cma_free_object,
  425. .gem_print_info = drm_gem_cma_print_info,
  426. .gem_vm_ops = &drm_gem_cma_vm_ops,
  427. .dumb_create = drm_gem_cma_dumb_create,
  428. .prime_handle_to_fd = drm_gem_prime_handle_to_fd,
  429. .prime_fd_to_handle = drm_gem_prime_fd_to_handle,
  430. .gem_prime_import = drm_gem_prime_import,
  431. .gem_prime_export = drm_gem_prime_export,
  432. .gem_prime_get_sg_table = drm_gem_cma_prime_get_sg_table,
  433. .gem_prime_import_sg_table = drm_gem_cma_prime_import_sg_table,
  434. .gem_prime_vmap = drm_gem_cma_prime_vmap,
  435. .gem_prime_vunmap = drm_gem_cma_prime_vunmap,
  436. .gem_prime_mmap = drm_gem_cma_prime_mmap,
  437. #ifdef CONFIG_DEBUG_FS
  438. .debugfs_init = tilcdc_debugfs_init,
  439. #endif
  440. .fops = &fops,
  441. .name = "tilcdc",
  442. .desc = "TI LCD Controller DRM",
  443. .date = "20121205",
  444. .major = 1,
  445. .minor = 0,
  446. };
  447. /*
  448. * Power management:
  449. */
  450. #ifdef CONFIG_PM_SLEEP
  451. static int tilcdc_pm_suspend(struct device *dev)
  452. {
  453. struct drm_device *ddev = dev_get_drvdata(dev);
  454. struct tilcdc_drm_private *priv = ddev->dev_private;
  455. priv->saved_state = drm_atomic_helper_suspend(ddev);
  456. /* Select sleep pin state */
  457. pinctrl_pm_select_sleep_state(dev);
  458. return 0;
  459. }
  460. static int tilcdc_pm_resume(struct device *dev)
  461. {
  462. struct drm_device *ddev = dev_get_drvdata(dev);
  463. struct tilcdc_drm_private *priv = ddev->dev_private;
  464. int ret = 0;
  465. /* Select default pin state */
  466. pinctrl_pm_select_default_state(dev);
  467. if (priv->saved_state)
  468. ret = drm_atomic_helper_resume(ddev, priv->saved_state);
  469. return ret;
  470. }
  471. #endif
  472. static const struct dev_pm_ops tilcdc_pm_ops = {
  473. SET_SYSTEM_SLEEP_PM_OPS(tilcdc_pm_suspend, tilcdc_pm_resume)
  474. };
  475. /*
  476. * Platform driver:
  477. */
  478. static int tilcdc_bind(struct device *dev)
  479. {
  480. return tilcdc_init(&tilcdc_driver, dev);
  481. }
  482. static void tilcdc_unbind(struct device *dev)
  483. {
  484. struct drm_device *ddev = dev_get_drvdata(dev);
  485. /* Check if a subcomponent has already triggered the unloading. */
  486. if (!ddev->dev_private)
  487. return;
  488. tilcdc_fini(dev_get_drvdata(dev));
  489. }
  490. static const struct component_master_ops tilcdc_comp_ops = {
  491. .bind = tilcdc_bind,
  492. .unbind = tilcdc_unbind,
  493. };
  494. static int tilcdc_pdev_probe(struct platform_device *pdev)
  495. {
  496. struct component_match *match = NULL;
  497. int ret;
  498. /* bail out early if no DT data: */
  499. if (!pdev->dev.of_node) {
  500. dev_err(&pdev->dev, "device-tree data is missing\n");
  501. return -ENXIO;
  502. }
  503. ret = tilcdc_get_external_components(&pdev->dev, &match);
  504. if (ret < 0)
  505. return ret;
  506. else if (ret == 0)
  507. return tilcdc_init(&tilcdc_driver, &pdev->dev);
  508. else
  509. return component_master_add_with_match(&pdev->dev,
  510. &tilcdc_comp_ops,
  511. match);
  512. }
  513. static int tilcdc_pdev_remove(struct platform_device *pdev)
  514. {
  515. int ret;
  516. ret = tilcdc_get_external_components(&pdev->dev, NULL);
  517. if (ret < 0)
  518. return ret;
  519. else if (ret == 0)
  520. tilcdc_fini(platform_get_drvdata(pdev));
  521. else
  522. component_master_del(&pdev->dev, &tilcdc_comp_ops);
  523. return 0;
  524. }
  525. static struct of_device_id tilcdc_of_match[] = {
  526. { .compatible = "ti,am33xx-tilcdc", },
  527. { .compatible = "ti,da850-tilcdc", },
  528. { },
  529. };
  530. MODULE_DEVICE_TABLE(of, tilcdc_of_match);
  531. static struct platform_driver tilcdc_platform_driver = {
  532. .probe = tilcdc_pdev_probe,
  533. .remove = tilcdc_pdev_remove,
  534. .driver = {
  535. .name = "tilcdc",
  536. .pm = &tilcdc_pm_ops,
  537. .of_match_table = tilcdc_of_match,
  538. },
  539. };
  540. static int __init tilcdc_drm_init(void)
  541. {
  542. DBG("init");
  543. tilcdc_tfp410_init();
  544. tilcdc_panel_init();
  545. return platform_driver_register(&tilcdc_platform_driver);
  546. }
  547. static void __exit tilcdc_drm_fini(void)
  548. {
  549. DBG("fini");
  550. platform_driver_unregister(&tilcdc_platform_driver);
  551. tilcdc_panel_fini();
  552. tilcdc_tfp410_fini();
  553. }
  554. module_init(tilcdc_drm_init);
  555. module_exit(tilcdc_drm_fini);
  556. MODULE_AUTHOR("Rob Clark <robdclark@gmail.com");
  557. MODULE_DESCRIPTION("TI LCD Controller DRM Driver");
  558. MODULE_LICENSE("GPL");