tilcdc_drv.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688
  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. if (priv->crtc)
  151. tilcdc_crtc_shutdown(priv->crtc);
  152. if (priv->is_registered)
  153. drm_dev_unregister(dev);
  154. drm_kms_helper_poll_fini(dev);
  155. drm_fb_cma_fbdev_fini(dev);
  156. drm_irq_uninstall(dev);
  157. drm_mode_config_cleanup(dev);
  158. tilcdc_remove_external_device(dev);
  159. #ifdef CONFIG_CPU_FREQ
  160. if (priv->freq_transition.notifier_call)
  161. cpufreq_unregister_notifier(&priv->freq_transition,
  162. CPUFREQ_TRANSITION_NOTIFIER);
  163. #endif
  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. dev_err(dev, "failed to allocate private data\n");
  188. return -ENOMEM;
  189. }
  190. ddev = drm_dev_alloc(ddrv, dev);
  191. if (IS_ERR(ddev))
  192. return PTR_ERR(ddev);
  193. ddev->dev_private = priv;
  194. platform_set_drvdata(pdev, ddev);
  195. drm_mode_config_init(ddev);
  196. priv->is_componentized =
  197. tilcdc_get_external_components(dev, NULL) > 0;
  198. priv->wq = alloc_ordered_workqueue("tilcdc", 0);
  199. if (!priv->wq) {
  200. ret = -ENOMEM;
  201. goto init_failed;
  202. }
  203. res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
  204. if (!res) {
  205. dev_err(dev, "failed to get memory resource\n");
  206. ret = -EINVAL;
  207. goto init_failed;
  208. }
  209. priv->mmio = ioremap_nocache(res->start, resource_size(res));
  210. if (!priv->mmio) {
  211. dev_err(dev, "failed to ioremap\n");
  212. ret = -ENOMEM;
  213. goto init_failed;
  214. }
  215. priv->clk = clk_get(dev, "fck");
  216. if (IS_ERR(priv->clk)) {
  217. dev_err(dev, "failed to get functional clock\n");
  218. ret = -ENODEV;
  219. goto init_failed;
  220. }
  221. #ifdef CONFIG_CPU_FREQ
  222. priv->freq_transition.notifier_call = cpufreq_transition;
  223. ret = cpufreq_register_notifier(&priv->freq_transition,
  224. CPUFREQ_TRANSITION_NOTIFIER);
  225. if (ret) {
  226. dev_err(dev, "failed to register cpufreq notifier\n");
  227. priv->freq_transition.notifier_call = NULL;
  228. goto init_failed;
  229. }
  230. #endif
  231. if (of_property_read_u32(node, "max-bandwidth", &priv->max_bandwidth))
  232. priv->max_bandwidth = TILCDC_DEFAULT_MAX_BANDWIDTH;
  233. DBG("Maximum Bandwidth Value %d", priv->max_bandwidth);
  234. if (of_property_read_u32(node, "max-width", &priv->max_width))
  235. priv->max_width = TILCDC_DEFAULT_MAX_WIDTH;
  236. DBG("Maximum Horizontal Pixel Width Value %dpixels", priv->max_width);
  237. if (of_property_read_u32(node, "max-pixelclock",
  238. &priv->max_pixelclock))
  239. priv->max_pixelclock = TILCDC_DEFAULT_MAX_PIXELCLOCK;
  240. DBG("Maximum Pixel Clock Value %dKHz", priv->max_pixelclock);
  241. pm_runtime_enable(dev);
  242. /* Determine LCD IP Version */
  243. pm_runtime_get_sync(dev);
  244. switch (tilcdc_read(ddev, LCDC_PID_REG)) {
  245. case 0x4c100102:
  246. priv->rev = 1;
  247. break;
  248. case 0x4f200800:
  249. case 0x4f201000:
  250. priv->rev = 2;
  251. break;
  252. default:
  253. dev_warn(dev, "Unknown PID Reg value 0x%08x, "
  254. "defaulting to LCD revision 1\n",
  255. tilcdc_read(ddev, LCDC_PID_REG));
  256. priv->rev = 1;
  257. break;
  258. }
  259. pm_runtime_put_sync(dev);
  260. if (priv->rev == 1) {
  261. DBG("Revision 1 LCDC supports only RGB565 format");
  262. priv->pixelformats = tilcdc_rev1_formats;
  263. priv->num_pixelformats = ARRAY_SIZE(tilcdc_rev1_formats);
  264. bpp = 16;
  265. } else {
  266. const char *str = "\0";
  267. of_property_read_string(node, "blue-and-red-wiring", &str);
  268. if (0 == strcmp(str, "crossed")) {
  269. DBG("Configured for crossed blue and red wires");
  270. priv->pixelformats = tilcdc_crossed_formats;
  271. priv->num_pixelformats =
  272. ARRAY_SIZE(tilcdc_crossed_formats);
  273. bpp = 32; /* Choose bpp with RGB support for fbdef */
  274. } else if (0 == strcmp(str, "straight")) {
  275. DBG("Configured for straight blue and red wires");
  276. priv->pixelformats = tilcdc_straight_formats;
  277. priv->num_pixelformats =
  278. ARRAY_SIZE(tilcdc_straight_formats);
  279. bpp = 16; /* Choose bpp with RGB support for fbdef */
  280. } else {
  281. DBG("Blue and red wiring '%s' unknown, use legacy mode",
  282. str);
  283. priv->pixelformats = tilcdc_legacy_formats;
  284. priv->num_pixelformats =
  285. ARRAY_SIZE(tilcdc_legacy_formats);
  286. bpp = 16; /* This is just a guess */
  287. }
  288. }
  289. ret = tilcdc_crtc_create(ddev);
  290. if (ret < 0) {
  291. dev_err(dev, "failed to create crtc\n");
  292. goto init_failed;
  293. }
  294. modeset_init(ddev);
  295. if (priv->is_componentized) {
  296. ret = component_bind_all(dev, ddev);
  297. if (ret < 0)
  298. goto init_failed;
  299. ret = tilcdc_add_component_encoder(ddev);
  300. if (ret < 0)
  301. goto init_failed;
  302. } else {
  303. ret = tilcdc_attach_external_device(ddev);
  304. if (ret)
  305. goto init_failed;
  306. }
  307. if (!priv->external_connector &&
  308. ((priv->num_encoders == 0) || (priv->num_connectors == 0))) {
  309. dev_err(dev, "no encoders/connectors found\n");
  310. ret = -ENXIO;
  311. goto init_failed;
  312. }
  313. ret = drm_vblank_init(ddev, 1);
  314. if (ret < 0) {
  315. dev_err(dev, "failed to initialize vblank\n");
  316. goto init_failed;
  317. }
  318. ret = drm_irq_install(ddev, platform_get_irq(pdev, 0));
  319. if (ret < 0) {
  320. dev_err(dev, "failed to install IRQ handler\n");
  321. goto init_failed;
  322. }
  323. drm_mode_config_reset(ddev);
  324. ret = drm_fb_cma_fbdev_init(ddev, bpp, 0);
  325. if (ret)
  326. goto init_failed;
  327. drm_kms_helper_poll_init(ddev);
  328. ret = drm_dev_register(ddev, 0);
  329. if (ret)
  330. goto init_failed;
  331. priv->is_registered = true;
  332. return 0;
  333. init_failed:
  334. tilcdc_fini(ddev);
  335. return ret;
  336. }
  337. static irqreturn_t tilcdc_irq(int irq, void *arg)
  338. {
  339. struct drm_device *dev = arg;
  340. struct tilcdc_drm_private *priv = dev->dev_private;
  341. return tilcdc_crtc_irq(priv->crtc);
  342. }
  343. #if defined(CONFIG_DEBUG_FS)
  344. static const struct {
  345. const char *name;
  346. uint8_t rev;
  347. uint8_t save;
  348. uint32_t reg;
  349. } registers[] = {
  350. #define REG(rev, save, reg) { #reg, rev, save, reg }
  351. /* exists in revision 1: */
  352. REG(1, false, LCDC_PID_REG),
  353. REG(1, true, LCDC_CTRL_REG),
  354. REG(1, false, LCDC_STAT_REG),
  355. REG(1, true, LCDC_RASTER_CTRL_REG),
  356. REG(1, true, LCDC_RASTER_TIMING_0_REG),
  357. REG(1, true, LCDC_RASTER_TIMING_1_REG),
  358. REG(1, true, LCDC_RASTER_TIMING_2_REG),
  359. REG(1, true, LCDC_DMA_CTRL_REG),
  360. REG(1, true, LCDC_DMA_FB_BASE_ADDR_0_REG),
  361. REG(1, true, LCDC_DMA_FB_CEILING_ADDR_0_REG),
  362. REG(1, true, LCDC_DMA_FB_BASE_ADDR_1_REG),
  363. REG(1, true, LCDC_DMA_FB_CEILING_ADDR_1_REG),
  364. /* new in revision 2: */
  365. REG(2, false, LCDC_RAW_STAT_REG),
  366. REG(2, false, LCDC_MASKED_STAT_REG),
  367. REG(2, true, LCDC_INT_ENABLE_SET_REG),
  368. REG(2, false, LCDC_INT_ENABLE_CLR_REG),
  369. REG(2, false, LCDC_END_OF_INT_IND_REG),
  370. REG(2, true, LCDC_CLK_ENABLE_REG),
  371. #undef REG
  372. };
  373. #endif
  374. #ifdef CONFIG_DEBUG_FS
  375. static int tilcdc_regs_show(struct seq_file *m, void *arg)
  376. {
  377. struct drm_info_node *node = (struct drm_info_node *) m->private;
  378. struct drm_device *dev = node->minor->dev;
  379. struct tilcdc_drm_private *priv = dev->dev_private;
  380. unsigned i;
  381. pm_runtime_get_sync(dev->dev);
  382. seq_printf(m, "revision: %d\n", priv->rev);
  383. for (i = 0; i < ARRAY_SIZE(registers); i++)
  384. if (priv->rev >= registers[i].rev)
  385. seq_printf(m, "%s:\t %08x\n", registers[i].name,
  386. tilcdc_read(dev, registers[i].reg));
  387. pm_runtime_put_sync(dev->dev);
  388. return 0;
  389. }
  390. static int tilcdc_mm_show(struct seq_file *m, void *arg)
  391. {
  392. struct drm_info_node *node = (struct drm_info_node *) m->private;
  393. struct drm_device *dev = node->minor->dev;
  394. struct drm_printer p = drm_seq_file_printer(m);
  395. drm_mm_print(&dev->vma_offset_manager->vm_addr_space_mm, &p);
  396. return 0;
  397. }
  398. static struct drm_info_list tilcdc_debugfs_list[] = {
  399. { "regs", tilcdc_regs_show, 0 },
  400. { "mm", tilcdc_mm_show, 0 },
  401. };
  402. static int tilcdc_debugfs_init(struct drm_minor *minor)
  403. {
  404. struct drm_device *dev = minor->dev;
  405. struct tilcdc_module *mod;
  406. int ret;
  407. ret = drm_debugfs_create_files(tilcdc_debugfs_list,
  408. ARRAY_SIZE(tilcdc_debugfs_list),
  409. minor->debugfs_root, minor);
  410. list_for_each_entry(mod, &module_list, list)
  411. if (mod->funcs->debugfs_init)
  412. mod->funcs->debugfs_init(mod, minor);
  413. if (ret) {
  414. dev_err(dev->dev, "could not install tilcdc_debugfs_list\n");
  415. return ret;
  416. }
  417. return ret;
  418. }
  419. #endif
  420. DEFINE_DRM_GEM_CMA_FOPS(fops);
  421. static struct drm_driver tilcdc_driver = {
  422. .driver_features = (DRIVER_HAVE_IRQ | DRIVER_GEM | DRIVER_MODESET |
  423. DRIVER_PRIME | DRIVER_ATOMIC),
  424. .lastclose = drm_fb_helper_lastclose,
  425. .irq_handler = tilcdc_irq,
  426. .gem_free_object_unlocked = drm_gem_cma_free_object,
  427. .gem_print_info = drm_gem_cma_print_info,
  428. .gem_vm_ops = &drm_gem_cma_vm_ops,
  429. .dumb_create = drm_gem_cma_dumb_create,
  430. .prime_handle_to_fd = drm_gem_prime_handle_to_fd,
  431. .prime_fd_to_handle = drm_gem_prime_fd_to_handle,
  432. .gem_prime_import = drm_gem_prime_import,
  433. .gem_prime_export = drm_gem_prime_export,
  434. .gem_prime_get_sg_table = drm_gem_cma_prime_get_sg_table,
  435. .gem_prime_import_sg_table = drm_gem_cma_prime_import_sg_table,
  436. .gem_prime_vmap = drm_gem_cma_prime_vmap,
  437. .gem_prime_vunmap = drm_gem_cma_prime_vunmap,
  438. .gem_prime_mmap = drm_gem_cma_prime_mmap,
  439. #ifdef CONFIG_DEBUG_FS
  440. .debugfs_init = tilcdc_debugfs_init,
  441. #endif
  442. .fops = &fops,
  443. .name = "tilcdc",
  444. .desc = "TI LCD Controller DRM",
  445. .date = "20121205",
  446. .major = 1,
  447. .minor = 0,
  448. };
  449. /*
  450. * Power management:
  451. */
  452. #ifdef CONFIG_PM_SLEEP
  453. static int tilcdc_pm_suspend(struct device *dev)
  454. {
  455. struct drm_device *ddev = dev_get_drvdata(dev);
  456. struct tilcdc_drm_private *priv = ddev->dev_private;
  457. priv->saved_state = drm_atomic_helper_suspend(ddev);
  458. /* Select sleep pin state */
  459. pinctrl_pm_select_sleep_state(dev);
  460. return 0;
  461. }
  462. static int tilcdc_pm_resume(struct device *dev)
  463. {
  464. struct drm_device *ddev = dev_get_drvdata(dev);
  465. struct tilcdc_drm_private *priv = ddev->dev_private;
  466. int ret = 0;
  467. /* Select default pin state */
  468. pinctrl_pm_select_default_state(dev);
  469. if (priv->saved_state)
  470. ret = drm_atomic_helper_resume(ddev, priv->saved_state);
  471. return ret;
  472. }
  473. #endif
  474. static const struct dev_pm_ops tilcdc_pm_ops = {
  475. SET_SYSTEM_SLEEP_PM_OPS(tilcdc_pm_suspend, tilcdc_pm_resume)
  476. };
  477. /*
  478. * Platform driver:
  479. */
  480. static int tilcdc_bind(struct device *dev)
  481. {
  482. return tilcdc_init(&tilcdc_driver, dev);
  483. }
  484. static void tilcdc_unbind(struct device *dev)
  485. {
  486. struct drm_device *ddev = dev_get_drvdata(dev);
  487. /* Check if a subcomponent has already triggered the unloading. */
  488. if (!ddev->dev_private)
  489. return;
  490. tilcdc_fini(dev_get_drvdata(dev));
  491. }
  492. static const struct component_master_ops tilcdc_comp_ops = {
  493. .bind = tilcdc_bind,
  494. .unbind = tilcdc_unbind,
  495. };
  496. static int tilcdc_pdev_probe(struct platform_device *pdev)
  497. {
  498. struct component_match *match = NULL;
  499. int ret;
  500. /* bail out early if no DT data: */
  501. if (!pdev->dev.of_node) {
  502. dev_err(&pdev->dev, "device-tree data is missing\n");
  503. return -ENXIO;
  504. }
  505. ret = tilcdc_get_external_components(&pdev->dev, &match);
  506. if (ret < 0)
  507. return ret;
  508. else if (ret == 0)
  509. return tilcdc_init(&tilcdc_driver, &pdev->dev);
  510. else
  511. return component_master_add_with_match(&pdev->dev,
  512. &tilcdc_comp_ops,
  513. match);
  514. }
  515. static int tilcdc_pdev_remove(struct platform_device *pdev)
  516. {
  517. int ret;
  518. ret = tilcdc_get_external_components(&pdev->dev, NULL);
  519. if (ret < 0)
  520. return ret;
  521. else if (ret == 0)
  522. tilcdc_fini(platform_get_drvdata(pdev));
  523. else
  524. component_master_del(&pdev->dev, &tilcdc_comp_ops);
  525. return 0;
  526. }
  527. static struct of_device_id tilcdc_of_match[] = {
  528. { .compatible = "ti,am33xx-tilcdc", },
  529. { .compatible = "ti,da850-tilcdc", },
  530. { },
  531. };
  532. MODULE_DEVICE_TABLE(of, tilcdc_of_match);
  533. static struct platform_driver tilcdc_platform_driver = {
  534. .probe = tilcdc_pdev_probe,
  535. .remove = tilcdc_pdev_remove,
  536. .driver = {
  537. .name = "tilcdc",
  538. .pm = &tilcdc_pm_ops,
  539. .of_match_table = tilcdc_of_match,
  540. },
  541. };
  542. static int __init tilcdc_drm_init(void)
  543. {
  544. DBG("init");
  545. tilcdc_tfp410_init();
  546. tilcdc_panel_init();
  547. return platform_driver_register(&tilcdc_platform_driver);
  548. }
  549. static void __exit tilcdc_drm_fini(void)
  550. {
  551. DBG("fini");
  552. platform_driver_unregister(&tilcdc_platform_driver);
  553. tilcdc_panel_fini();
  554. tilcdc_tfp410_fini();
  555. }
  556. module_init(tilcdc_drm_init);
  557. module_exit(tilcdc_drm_fini);
  558. MODULE_AUTHOR("Rob Clark <robdclark@gmail.com");
  559. MODULE_DESCRIPTION("TI LCD Controller DRM Driver");
  560. MODULE_LICENSE("GPL");