omap_drv.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709
  1. /*
  2. * drivers/gpu/drm/omapdrm/omap_drv.c
  3. *
  4. * Copyright (C) 2011 Texas Instruments
  5. * Author: Rob Clark <rob@ti.com>
  6. *
  7. * This program is free software; you can redistribute it and/or modify it
  8. * under the terms of the GNU General Public License version 2 as published by
  9. * the Free Software Foundation.
  10. *
  11. * This program is distributed in the hope that it will be useful, but WITHOUT
  12. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13. * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
  14. * more details.
  15. *
  16. * You should have received a copy of the GNU General Public License along with
  17. * this program. If not, see <http://www.gnu.org/licenses/>.
  18. */
  19. #include "omap_drv.h"
  20. #include "drm_crtc_helper.h"
  21. #include "drm_fb_helper.h"
  22. #include "omap_dmm_tiler.h"
  23. #define DRIVER_NAME MODULE_NAME
  24. #define DRIVER_DESC "OMAP DRM"
  25. #define DRIVER_DATE "20110917"
  26. #define DRIVER_MAJOR 1
  27. #define DRIVER_MINOR 0
  28. #define DRIVER_PATCHLEVEL 0
  29. static int num_crtc = CONFIG_DRM_OMAP_NUM_CRTCS;
  30. MODULE_PARM_DESC(num_crtc, "Number of overlays to use as CRTCs");
  31. module_param(num_crtc, int, 0600);
  32. /*
  33. * mode config funcs
  34. */
  35. /* Notes about mapping DSS and DRM entities:
  36. * CRTC: overlay
  37. * encoder: manager.. with some extension to allow one primary CRTC
  38. * and zero or more video CRTC's to be mapped to one encoder?
  39. * connector: dssdev.. manager can be attached/detached from different
  40. * devices
  41. */
  42. static void omap_fb_output_poll_changed(struct drm_device *dev)
  43. {
  44. struct omap_drm_private *priv = dev->dev_private;
  45. DBG("dev=%p", dev);
  46. if (priv->fbdev)
  47. drm_fb_helper_hotplug_event(priv->fbdev);
  48. }
  49. static const struct drm_mode_config_funcs omap_mode_config_funcs = {
  50. .fb_create = omap_framebuffer_create,
  51. .output_poll_changed = omap_fb_output_poll_changed,
  52. };
  53. static int get_connector_type(struct omap_dss_device *dssdev)
  54. {
  55. switch (dssdev->type) {
  56. case OMAP_DISPLAY_TYPE_HDMI:
  57. return DRM_MODE_CONNECTOR_HDMIA;
  58. case OMAP_DISPLAY_TYPE_DPI:
  59. if (!strcmp(dssdev->name, "dvi"))
  60. return DRM_MODE_CONNECTOR_DVID;
  61. /* fallthrough */
  62. default:
  63. return DRM_MODE_CONNECTOR_Unknown;
  64. }
  65. }
  66. static bool channel_used(struct drm_device *dev, enum omap_channel channel)
  67. {
  68. struct omap_drm_private *priv = dev->dev_private;
  69. int i;
  70. for (i = 0; i < priv->num_crtcs; i++) {
  71. struct drm_crtc *crtc = priv->crtcs[i];
  72. if (omap_crtc_channel(crtc) == channel)
  73. return true;
  74. }
  75. return false;
  76. }
  77. static int omap_modeset_init(struct drm_device *dev)
  78. {
  79. struct omap_drm_private *priv = dev->dev_private;
  80. struct omap_dss_device *dssdev = NULL;
  81. int num_ovls = dss_feat_get_num_ovls();
  82. int num_mgrs = dss_feat_get_num_mgrs();
  83. int num_crtcs;
  84. int i, id = 0;
  85. drm_mode_config_init(dev);
  86. omap_drm_irq_install(dev);
  87. /*
  88. * We usually don't want to create a CRTC for each manager, at least
  89. * not until we have a way to expose private planes to userspace.
  90. * Otherwise there would not be enough video pipes left for drm planes.
  91. * We use the num_crtc argument to limit the number of crtcs we create.
  92. */
  93. num_crtcs = min3(num_crtc, num_mgrs, num_ovls);
  94. dssdev = NULL;
  95. for_each_dss_dev(dssdev) {
  96. struct drm_connector *connector;
  97. struct drm_encoder *encoder;
  98. enum omap_channel channel;
  99. if (!dssdev->driver) {
  100. dev_warn(dev->dev, "%s has no driver.. skipping it\n",
  101. dssdev->name);
  102. continue;
  103. }
  104. if (!(dssdev->driver->get_timings ||
  105. dssdev->driver->read_edid)) {
  106. dev_warn(dev->dev, "%s driver does not support "
  107. "get_timings or read_edid.. skipping it!\n",
  108. dssdev->name);
  109. continue;
  110. }
  111. encoder = omap_encoder_init(dev, dssdev);
  112. if (!encoder) {
  113. dev_err(dev->dev, "could not create encoder: %s\n",
  114. dssdev->name);
  115. return -ENOMEM;
  116. }
  117. connector = omap_connector_init(dev,
  118. get_connector_type(dssdev), dssdev, encoder);
  119. if (!connector) {
  120. dev_err(dev->dev, "could not create connector: %s\n",
  121. dssdev->name);
  122. return -ENOMEM;
  123. }
  124. BUG_ON(priv->num_encoders >= ARRAY_SIZE(priv->encoders));
  125. BUG_ON(priv->num_connectors >= ARRAY_SIZE(priv->connectors));
  126. priv->encoders[priv->num_encoders++] = encoder;
  127. priv->connectors[priv->num_connectors++] = connector;
  128. drm_mode_connector_attach_encoder(connector, encoder);
  129. /*
  130. * if we have reached the limit of the crtcs we are allowed to
  131. * create, let's not try to look for a crtc for this
  132. * panel/encoder and onwards, we will, of course, populate the
  133. * the possible_crtcs field for all the encoders with the final
  134. * set of crtcs we create
  135. */
  136. if (id == num_crtcs)
  137. continue;
  138. /*
  139. * get the recommended DISPC channel for this encoder. For now,
  140. * we only try to get create a crtc out of the recommended, the
  141. * other possible channels to which the encoder can connect are
  142. * not considered.
  143. */
  144. channel = dssdev->output->dispc_channel;
  145. /*
  146. * if this channel hasn't already been taken by a previously
  147. * allocated crtc, we create a new crtc for it
  148. */
  149. if (!channel_used(dev, channel)) {
  150. struct drm_plane *plane;
  151. struct drm_crtc *crtc;
  152. plane = omap_plane_init(dev, id, true);
  153. crtc = omap_crtc_init(dev, plane, channel, id);
  154. BUG_ON(priv->num_crtcs >= ARRAY_SIZE(priv->crtcs));
  155. priv->crtcs[id] = crtc;
  156. priv->num_crtcs++;
  157. priv->planes[id] = plane;
  158. priv->num_planes++;
  159. id++;
  160. }
  161. }
  162. /*
  163. * we have allocated crtcs according to the need of the panels/encoders,
  164. * adding more crtcs here if needed
  165. */
  166. for (; id < num_crtcs; id++) {
  167. /* find a free manager for this crtc */
  168. for (i = 0; i < num_mgrs; i++) {
  169. if (!channel_used(dev, i)) {
  170. struct drm_plane *plane;
  171. struct drm_crtc *crtc;
  172. plane = omap_plane_init(dev, id, true);
  173. crtc = omap_crtc_init(dev, plane, i, id);
  174. BUG_ON(priv->num_crtcs >=
  175. ARRAY_SIZE(priv->crtcs));
  176. priv->crtcs[id] = crtc;
  177. priv->num_crtcs++;
  178. priv->planes[id] = plane;
  179. priv->num_planes++;
  180. break;
  181. } else {
  182. continue;
  183. }
  184. }
  185. if (i == num_mgrs) {
  186. /* this shouldn't really happen */
  187. dev_err(dev->dev, "no managers left for crtc\n");
  188. return -ENOMEM;
  189. }
  190. }
  191. /*
  192. * Create normal planes for the remaining overlays:
  193. */
  194. for (; id < num_ovls; id++) {
  195. struct drm_plane *plane = omap_plane_init(dev, id, false);
  196. BUG_ON(priv->num_planes >= ARRAY_SIZE(priv->planes));
  197. priv->planes[priv->num_planes++] = plane;
  198. }
  199. for (i = 0; i < priv->num_encoders; i++) {
  200. struct drm_encoder *encoder = priv->encoders[i];
  201. struct omap_dss_device *dssdev =
  202. omap_encoder_get_dssdev(encoder);
  203. /* figure out which crtc's we can connect the encoder to: */
  204. encoder->possible_crtcs = 0;
  205. for (id = 0; id < priv->num_crtcs; id++) {
  206. struct drm_crtc *crtc = priv->crtcs[id];
  207. enum omap_channel crtc_channel;
  208. enum omap_dss_output_id supported_outputs;
  209. crtc_channel = omap_crtc_channel(crtc);
  210. supported_outputs =
  211. dss_feat_get_supported_outputs(crtc_channel);
  212. if (supported_outputs & dssdev->output->id)
  213. encoder->possible_crtcs |= (1 << id);
  214. }
  215. }
  216. DBG("registered %d planes, %d crtcs, %d encoders and %d connectors\n",
  217. priv->num_planes, priv->num_crtcs, priv->num_encoders,
  218. priv->num_connectors);
  219. dev->mode_config.min_width = 32;
  220. dev->mode_config.min_height = 32;
  221. /* note: eventually will need some cpu_is_omapXYZ() type stuff here
  222. * to fill in these limits properly on different OMAP generations..
  223. */
  224. dev->mode_config.max_width = 2048;
  225. dev->mode_config.max_height = 2048;
  226. dev->mode_config.funcs = &omap_mode_config_funcs;
  227. return 0;
  228. }
  229. static void omap_modeset_free(struct drm_device *dev)
  230. {
  231. drm_mode_config_cleanup(dev);
  232. }
  233. /*
  234. * drm ioctl funcs
  235. */
  236. static int ioctl_get_param(struct drm_device *dev, void *data,
  237. struct drm_file *file_priv)
  238. {
  239. struct omap_drm_private *priv = dev->dev_private;
  240. struct drm_omap_param *args = data;
  241. DBG("%p: param=%llu", dev, args->param);
  242. switch (args->param) {
  243. case OMAP_PARAM_CHIPSET_ID:
  244. args->value = priv->omaprev;
  245. break;
  246. default:
  247. DBG("unknown parameter %lld", args->param);
  248. return -EINVAL;
  249. }
  250. return 0;
  251. }
  252. static int ioctl_set_param(struct drm_device *dev, void *data,
  253. struct drm_file *file_priv)
  254. {
  255. struct drm_omap_param *args = data;
  256. switch (args->param) {
  257. default:
  258. DBG("unknown parameter %lld", args->param);
  259. return -EINVAL;
  260. }
  261. return 0;
  262. }
  263. static int ioctl_gem_new(struct drm_device *dev, void *data,
  264. struct drm_file *file_priv)
  265. {
  266. struct drm_omap_gem_new *args = data;
  267. VERB("%p:%p: size=0x%08x, flags=%08x", dev, file_priv,
  268. args->size.bytes, args->flags);
  269. return omap_gem_new_handle(dev, file_priv, args->size,
  270. args->flags, &args->handle);
  271. }
  272. static int ioctl_gem_cpu_prep(struct drm_device *dev, void *data,
  273. struct drm_file *file_priv)
  274. {
  275. struct drm_omap_gem_cpu_prep *args = data;
  276. struct drm_gem_object *obj;
  277. int ret;
  278. VERB("%p:%p: handle=%d, op=%x", dev, file_priv, args->handle, args->op);
  279. obj = drm_gem_object_lookup(dev, file_priv, args->handle);
  280. if (!obj)
  281. return -ENOENT;
  282. ret = omap_gem_op_sync(obj, args->op);
  283. if (!ret)
  284. ret = omap_gem_op_start(obj, args->op);
  285. drm_gem_object_unreference_unlocked(obj);
  286. return ret;
  287. }
  288. static int ioctl_gem_cpu_fini(struct drm_device *dev, void *data,
  289. struct drm_file *file_priv)
  290. {
  291. struct drm_omap_gem_cpu_fini *args = data;
  292. struct drm_gem_object *obj;
  293. int ret;
  294. VERB("%p:%p: handle=%d", dev, file_priv, args->handle);
  295. obj = drm_gem_object_lookup(dev, file_priv, args->handle);
  296. if (!obj)
  297. return -ENOENT;
  298. /* XXX flushy, flushy */
  299. ret = 0;
  300. if (!ret)
  301. ret = omap_gem_op_finish(obj, args->op);
  302. drm_gem_object_unreference_unlocked(obj);
  303. return ret;
  304. }
  305. static int ioctl_gem_info(struct drm_device *dev, void *data,
  306. struct drm_file *file_priv)
  307. {
  308. struct drm_omap_gem_info *args = data;
  309. struct drm_gem_object *obj;
  310. int ret = 0;
  311. VERB("%p:%p: handle=%d", dev, file_priv, args->handle);
  312. obj = drm_gem_object_lookup(dev, file_priv, args->handle);
  313. if (!obj)
  314. return -ENOENT;
  315. args->size = omap_gem_mmap_size(obj);
  316. args->offset = omap_gem_mmap_offset(obj);
  317. drm_gem_object_unreference_unlocked(obj);
  318. return ret;
  319. }
  320. static struct drm_ioctl_desc ioctls[DRM_COMMAND_END - DRM_COMMAND_BASE] = {
  321. DRM_IOCTL_DEF_DRV(OMAP_GET_PARAM, ioctl_get_param, DRM_UNLOCKED|DRM_AUTH),
  322. DRM_IOCTL_DEF_DRV(OMAP_SET_PARAM, ioctl_set_param, DRM_UNLOCKED|DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY),
  323. DRM_IOCTL_DEF_DRV(OMAP_GEM_NEW, ioctl_gem_new, DRM_UNLOCKED|DRM_AUTH),
  324. DRM_IOCTL_DEF_DRV(OMAP_GEM_CPU_PREP, ioctl_gem_cpu_prep, DRM_UNLOCKED|DRM_AUTH),
  325. DRM_IOCTL_DEF_DRV(OMAP_GEM_CPU_FINI, ioctl_gem_cpu_fini, DRM_UNLOCKED|DRM_AUTH),
  326. DRM_IOCTL_DEF_DRV(OMAP_GEM_INFO, ioctl_gem_info, DRM_UNLOCKED|DRM_AUTH),
  327. };
  328. /*
  329. * drm driver funcs
  330. */
  331. /**
  332. * load - setup chip and create an initial config
  333. * @dev: DRM device
  334. * @flags: startup flags
  335. *
  336. * The driver load routine has to do several things:
  337. * - initialize the memory manager
  338. * - allocate initial config memory
  339. * - setup the DRM framebuffer with the allocated memory
  340. */
  341. static int dev_load(struct drm_device *dev, unsigned long flags)
  342. {
  343. struct omap_drm_platform_data *pdata = dev->dev->platform_data;
  344. struct omap_drm_private *priv;
  345. int ret;
  346. DBG("load: dev=%p", dev);
  347. priv = kzalloc(sizeof(*priv), GFP_KERNEL);
  348. if (!priv)
  349. return -ENOMEM;
  350. priv->omaprev = pdata->omaprev;
  351. dev->dev_private = priv;
  352. priv->wq = alloc_ordered_workqueue("omapdrm", 0);
  353. INIT_LIST_HEAD(&priv->obj_list);
  354. omap_gem_init(dev);
  355. ret = omap_modeset_init(dev);
  356. if (ret) {
  357. dev_err(dev->dev, "omap_modeset_init failed: ret=%d\n", ret);
  358. dev->dev_private = NULL;
  359. kfree(priv);
  360. return ret;
  361. }
  362. ret = drm_vblank_init(dev, priv->num_crtcs);
  363. if (ret)
  364. dev_warn(dev->dev, "could not init vblank\n");
  365. priv->fbdev = omap_fbdev_init(dev);
  366. if (!priv->fbdev) {
  367. dev_warn(dev->dev, "omap_fbdev_init failed\n");
  368. /* well, limp along without an fbdev.. maybe X11 will work? */
  369. }
  370. /* store off drm_device for use in pm ops */
  371. dev_set_drvdata(dev->dev, dev);
  372. drm_kms_helper_poll_init(dev);
  373. return 0;
  374. }
  375. static int dev_unload(struct drm_device *dev)
  376. {
  377. struct omap_drm_private *priv = dev->dev_private;
  378. DBG("unload: dev=%p", dev);
  379. drm_kms_helper_poll_fini(dev);
  380. drm_vblank_cleanup(dev);
  381. omap_drm_irq_uninstall(dev);
  382. omap_fbdev_free(dev);
  383. omap_modeset_free(dev);
  384. omap_gem_deinit(dev);
  385. flush_workqueue(priv->wq);
  386. destroy_workqueue(priv->wq);
  387. kfree(dev->dev_private);
  388. dev->dev_private = NULL;
  389. dev_set_drvdata(dev->dev, NULL);
  390. return 0;
  391. }
  392. static int dev_open(struct drm_device *dev, struct drm_file *file)
  393. {
  394. file->driver_priv = NULL;
  395. DBG("open: dev=%p, file=%p", dev, file);
  396. return 0;
  397. }
  398. static int dev_firstopen(struct drm_device *dev)
  399. {
  400. DBG("firstopen: dev=%p", dev);
  401. return 0;
  402. }
  403. /**
  404. * lastclose - clean up after all DRM clients have exited
  405. * @dev: DRM device
  406. *
  407. * Take care of cleaning up after all DRM clients have exited. In the
  408. * mode setting case, we want to restore the kernel's initial mode (just
  409. * in case the last client left us in a bad state).
  410. */
  411. static void dev_lastclose(struct drm_device *dev)
  412. {
  413. int i;
  414. /* we don't support vga-switcheroo.. so just make sure the fbdev
  415. * mode is active
  416. */
  417. struct omap_drm_private *priv = dev->dev_private;
  418. int ret;
  419. DBG("lastclose: dev=%p", dev);
  420. if (priv->rotation_prop) {
  421. /* need to restore default rotation state.. not sure
  422. * if there is a cleaner way to restore properties to
  423. * default state? Maybe a flag that properties should
  424. * automatically be restored to default state on
  425. * lastclose?
  426. */
  427. for (i = 0; i < priv->num_crtcs; i++) {
  428. drm_object_property_set_value(&priv->crtcs[i]->base,
  429. priv->rotation_prop, 0);
  430. }
  431. for (i = 0; i < priv->num_planes; i++) {
  432. drm_object_property_set_value(&priv->planes[i]->base,
  433. priv->rotation_prop, 0);
  434. }
  435. }
  436. drm_modeset_lock_all(dev);
  437. ret = drm_fb_helper_restore_fbdev_mode(priv->fbdev);
  438. drm_modeset_unlock_all(dev);
  439. if (ret)
  440. DBG("failed to restore crtc mode");
  441. }
  442. static void dev_preclose(struct drm_device *dev, struct drm_file *file)
  443. {
  444. DBG("preclose: dev=%p", dev);
  445. }
  446. static void dev_postclose(struct drm_device *dev, struct drm_file *file)
  447. {
  448. DBG("postclose: dev=%p, file=%p", dev, file);
  449. }
  450. static const struct vm_operations_struct omap_gem_vm_ops = {
  451. .fault = omap_gem_fault,
  452. .open = drm_gem_vm_open,
  453. .close = drm_gem_vm_close,
  454. };
  455. static const struct file_operations omapdriver_fops = {
  456. .owner = THIS_MODULE,
  457. .open = drm_open,
  458. .unlocked_ioctl = drm_ioctl,
  459. .release = drm_release,
  460. .mmap = omap_gem_mmap,
  461. .poll = drm_poll,
  462. .fasync = drm_fasync,
  463. .read = drm_read,
  464. .llseek = noop_llseek,
  465. };
  466. static struct drm_driver omap_drm_driver = {
  467. .driver_features =
  468. DRIVER_HAVE_IRQ | DRIVER_MODESET | DRIVER_GEM | DRIVER_PRIME,
  469. .load = dev_load,
  470. .unload = dev_unload,
  471. .open = dev_open,
  472. .firstopen = dev_firstopen,
  473. .lastclose = dev_lastclose,
  474. .preclose = dev_preclose,
  475. .postclose = dev_postclose,
  476. .get_vblank_counter = drm_vblank_count,
  477. .enable_vblank = omap_irq_enable_vblank,
  478. .disable_vblank = omap_irq_disable_vblank,
  479. .irq_preinstall = omap_irq_preinstall,
  480. .irq_postinstall = omap_irq_postinstall,
  481. .irq_uninstall = omap_irq_uninstall,
  482. .irq_handler = omap_irq_handler,
  483. #ifdef CONFIG_DEBUG_FS
  484. .debugfs_init = omap_debugfs_init,
  485. .debugfs_cleanup = omap_debugfs_cleanup,
  486. #endif
  487. .prime_handle_to_fd = drm_gem_prime_handle_to_fd,
  488. .prime_fd_to_handle = drm_gem_prime_fd_to_handle,
  489. .gem_prime_export = omap_gem_prime_export,
  490. .gem_prime_import = omap_gem_prime_import,
  491. .gem_init_object = omap_gem_init_object,
  492. .gem_free_object = omap_gem_free_object,
  493. .gem_vm_ops = &omap_gem_vm_ops,
  494. .dumb_create = omap_gem_dumb_create,
  495. .dumb_map_offset = omap_gem_dumb_map_offset,
  496. .dumb_destroy = omap_gem_dumb_destroy,
  497. .ioctls = ioctls,
  498. .num_ioctls = DRM_OMAP_NUM_IOCTLS,
  499. .fops = &omapdriver_fops,
  500. .name = DRIVER_NAME,
  501. .desc = DRIVER_DESC,
  502. .date = DRIVER_DATE,
  503. .major = DRIVER_MAJOR,
  504. .minor = DRIVER_MINOR,
  505. .patchlevel = DRIVER_PATCHLEVEL,
  506. };
  507. static int pdev_suspend(struct platform_device *pDevice, pm_message_t state)
  508. {
  509. DBG("");
  510. return 0;
  511. }
  512. static int pdev_resume(struct platform_device *device)
  513. {
  514. DBG("");
  515. return 0;
  516. }
  517. static void pdev_shutdown(struct platform_device *device)
  518. {
  519. DBG("");
  520. }
  521. static int pdev_probe(struct platform_device *device)
  522. {
  523. DBG("%s", device->name);
  524. return drm_platform_init(&omap_drm_driver, device);
  525. }
  526. static int pdev_remove(struct platform_device *device)
  527. {
  528. DBG("");
  529. drm_platform_exit(&omap_drm_driver, device);
  530. platform_driver_unregister(&omap_dmm_driver);
  531. return 0;
  532. }
  533. #ifdef CONFIG_PM
  534. static const struct dev_pm_ops omapdrm_pm_ops = {
  535. .resume = omap_gem_resume,
  536. };
  537. #endif
  538. static struct platform_driver pdev = {
  539. .driver = {
  540. .name = DRIVER_NAME,
  541. .owner = THIS_MODULE,
  542. #ifdef CONFIG_PM
  543. .pm = &omapdrm_pm_ops,
  544. #endif
  545. },
  546. .probe = pdev_probe,
  547. .remove = pdev_remove,
  548. .suspend = pdev_suspend,
  549. .resume = pdev_resume,
  550. .shutdown = pdev_shutdown,
  551. };
  552. static int __init omap_drm_init(void)
  553. {
  554. DBG("init");
  555. if (platform_driver_register(&omap_dmm_driver)) {
  556. /* we can continue on without DMM.. so not fatal */
  557. dev_err(NULL, "DMM registration failed\n");
  558. }
  559. return platform_driver_register(&pdev);
  560. }
  561. static void __exit omap_drm_fini(void)
  562. {
  563. DBG("fini");
  564. platform_driver_unregister(&pdev);
  565. }
  566. /* need late_initcall() so we load after dss_driver's are loaded */
  567. late_initcall(omap_drm_init);
  568. module_exit(omap_drm_fini);
  569. MODULE_AUTHOR("Rob Clark <rob@ti.com>");
  570. MODULE_DESCRIPTION("OMAP DRM Display Driver");
  571. MODULE_ALIAS("platform:" DRIVER_NAME);
  572. MODULE_LICENSE("GPL v2");