2 * Freescale i.MX drm driver
4 * Copyright (C) 2011 Sascha Hauer, Pengutronix
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version 2
9 * of the License, or (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
17 #include <linux/device.h>
18 #include <linux/platform_device.h>
20 #include <drm/drm_fb_helper.h>
21 #include <drm/drm_crtc_helper.h>
23 #include <linux/module.h>
24 #include <drm/drm_gem_cma_helper.h>
25 #include <drm/drm_fb_cma_helper.h>
34 struct list_head list
;
37 struct imx_drm_device
{
38 struct drm_device
*drm
;
40 struct list_head crtc_list
;
41 struct list_head encoder_list
;
42 struct list_head connector_list
;
45 struct drm_fbdev_cma
*fbhelper
;
49 struct drm_crtc
*crtc
;
50 struct list_head list
;
51 struct imx_drm_device
*imxdrm
;
53 struct imx_drm_crtc_helper_funcs imx_drm_helper_funcs
;
55 struct crtc_cookie cookie
;
58 struct imx_drm_encoder
{
59 struct drm_encoder
*encoder
;
60 struct list_head list
;
62 struct list_head possible_crtcs
;
65 struct imx_drm_connector
{
66 struct drm_connector
*connector
;
67 struct list_head list
;
71 int imx_drm_crtc_id(struct imx_drm_crtc
*crtc
)
75 EXPORT_SYMBOL_GPL(imx_drm_crtc_id
);
77 static void imx_drm_driver_lastclose(struct drm_device
*drm
)
79 struct imx_drm_device
*imxdrm
= drm
->dev_private
;
82 drm_fbdev_cma_restore_mode(imxdrm
->fbhelper
);
85 static int imx_drm_driver_unload(struct drm_device
*drm
)
87 struct imx_drm_device
*imxdrm
= drm
->dev_private
;
91 drm_mode_config_cleanup(imxdrm
->drm
);
92 drm_kms_helper_poll_fini(imxdrm
->drm
);
98 * We don't care at all for crtc numbers, but the core expects the
99 * crtcs to be numbered
101 static struct imx_drm_crtc
*imx_drm_crtc_by_num(struct imx_drm_device
*imxdrm
,
104 struct imx_drm_crtc
*imx_drm_crtc
;
106 list_for_each_entry(imx_drm_crtc
, &imxdrm
->crtc_list
, list
)
107 if (imx_drm_crtc
->pipe
== num
)
112 int imx_drm_crtc_panel_format_pins(struct drm_crtc
*crtc
, u32 encoder_type
,
113 u32 interface_pix_fmt
, int hsync_pin
, int vsync_pin
)
115 struct imx_drm_device
*imxdrm
= crtc
->dev
->dev_private
;
116 struct imx_drm_crtc
*imx_crtc
;
117 struct imx_drm_crtc_helper_funcs
*helper
;
119 list_for_each_entry(imx_crtc
, &imxdrm
->crtc_list
, list
)
120 if (imx_crtc
->crtc
== crtc
)
125 helper
= &imx_crtc
->imx_drm_helper_funcs
;
126 if (helper
->set_interface_pix_fmt
)
127 return helper
->set_interface_pix_fmt(crtc
,
128 encoder_type
, interface_pix_fmt
,
129 hsync_pin
, vsync_pin
);
132 EXPORT_SYMBOL_GPL(imx_drm_crtc_panel_format_pins
);
134 int imx_drm_crtc_panel_format(struct drm_crtc
*crtc
, u32 encoder_type
,
135 u32 interface_pix_fmt
)
137 return imx_drm_crtc_panel_format_pins(crtc
, encoder_type
,
138 interface_pix_fmt
, 2, 3);
140 EXPORT_SYMBOL_GPL(imx_drm_crtc_panel_format
);
142 int imx_drm_crtc_vblank_get(struct imx_drm_crtc
*imx_drm_crtc
)
144 return drm_vblank_get(imx_drm_crtc
->imxdrm
->drm
, imx_drm_crtc
->pipe
);
146 EXPORT_SYMBOL_GPL(imx_drm_crtc_vblank_get
);
148 void imx_drm_crtc_vblank_put(struct imx_drm_crtc
*imx_drm_crtc
)
150 drm_vblank_put(imx_drm_crtc
->imxdrm
->drm
, imx_drm_crtc
->pipe
);
152 EXPORT_SYMBOL_GPL(imx_drm_crtc_vblank_put
);
154 void imx_drm_handle_vblank(struct imx_drm_crtc
*imx_drm_crtc
)
156 drm_handle_vblank(imx_drm_crtc
->imxdrm
->drm
, imx_drm_crtc
->pipe
);
158 EXPORT_SYMBOL_GPL(imx_drm_handle_vblank
);
160 static int imx_drm_enable_vblank(struct drm_device
*drm
, int crtc
)
162 struct imx_drm_device
*imxdrm
= drm
->dev_private
;
163 struct imx_drm_crtc
*imx_drm_crtc
;
166 imx_drm_crtc
= imx_drm_crtc_by_num(imxdrm
, crtc
);
170 if (!imx_drm_crtc
->imx_drm_helper_funcs
.enable_vblank
)
173 ret
= imx_drm_crtc
->imx_drm_helper_funcs
.enable_vblank(
179 static void imx_drm_disable_vblank(struct drm_device
*drm
, int crtc
)
181 struct imx_drm_device
*imxdrm
= drm
->dev_private
;
182 struct imx_drm_crtc
*imx_drm_crtc
;
184 imx_drm_crtc
= imx_drm_crtc_by_num(imxdrm
, crtc
);
188 if (!imx_drm_crtc
->imx_drm_helper_funcs
.disable_vblank
)
191 imx_drm_crtc
->imx_drm_helper_funcs
.disable_vblank(imx_drm_crtc
->crtc
);
194 static void imx_drm_driver_preclose(struct drm_device
*drm
,
195 struct drm_file
*file
)
199 if (!file
->is_master
)
202 for (i
= 0; i
< 4; i
++)
203 imx_drm_disable_vblank(drm
, i
);
206 static const struct file_operations imx_drm_driver_fops
= {
207 .owner
= THIS_MODULE
,
209 .release
= drm_release
,
210 .unlocked_ioctl
= drm_ioctl
,
211 .mmap
= drm_gem_cma_mmap
,
214 .llseek
= noop_llseek
,
217 static struct imx_drm_device
*imx_drm_device
;
219 static struct imx_drm_device
*__imx_drm_device(void)
221 return imx_drm_device
;
224 struct drm_device
*imx_drm_device_get(void)
226 struct imx_drm_device
*imxdrm
= __imx_drm_device();
227 struct imx_drm_encoder
*enc
;
228 struct imx_drm_connector
*con
;
229 struct imx_drm_crtc
*crtc
;
231 list_for_each_entry(enc
, &imxdrm
->encoder_list
, list
) {
232 if (!try_module_get(enc
->owner
)) {
233 dev_err(imxdrm
->dev
, "could not get module %s\n",
234 module_name(enc
->owner
));
239 list_for_each_entry(con
, &imxdrm
->connector_list
, list
) {
240 if (!try_module_get(con
->owner
)) {
241 dev_err(imxdrm
->dev
, "could not get module %s\n",
242 module_name(con
->owner
));
247 list_for_each_entry(crtc
, &imxdrm
->crtc_list
, list
) {
248 if (!try_module_get(crtc
->owner
)) {
249 dev_err(imxdrm
->dev
, "could not get module %s\n",
250 module_name(crtc
->owner
));
258 list_for_each_entry_continue_reverse(crtc
, &imxdrm
->crtc_list
, list
)
259 module_put(crtc
->owner
);
261 list_for_each_entry_continue_reverse(con
, &imxdrm
->connector_list
, list
)
262 module_put(con
->owner
);
264 list_for_each_entry_continue_reverse(enc
, &imxdrm
->encoder_list
, list
)
265 module_put(enc
->owner
);
267 mutex_unlock(&imxdrm
->mutex
);
272 EXPORT_SYMBOL_GPL(imx_drm_device_get
);
274 void imx_drm_device_put(void)
276 struct imx_drm_device
*imxdrm
= __imx_drm_device();
277 struct imx_drm_encoder
*enc
;
278 struct imx_drm_connector
*con
;
279 struct imx_drm_crtc
*crtc
;
281 mutex_lock(&imxdrm
->mutex
);
283 list_for_each_entry(crtc
, &imxdrm
->crtc_list
, list
)
284 module_put(crtc
->owner
);
286 list_for_each_entry(con
, &imxdrm
->connector_list
, list
)
287 module_put(con
->owner
);
289 list_for_each_entry(enc
, &imxdrm
->encoder_list
, list
)
290 module_put(enc
->owner
);
292 mutex_unlock(&imxdrm
->mutex
);
294 EXPORT_SYMBOL_GPL(imx_drm_device_put
);
296 static int drm_mode_group_reinit(struct drm_device
*dev
)
298 struct drm_mode_group
*group
= &dev
->primary
->mode_group
;
299 uint32_t *id_list
= group
->id_list
;
302 ret
= drm_mode_group_init_legacy_group(dev
, group
);
311 * register an encoder to the drm core
313 static int imx_drm_encoder_register(struct imx_drm_encoder
*imx_drm_encoder
)
315 struct imx_drm_device
*imxdrm
= __imx_drm_device();
317 INIT_LIST_HEAD(&imx_drm_encoder
->possible_crtcs
);
319 drm_encoder_init(imxdrm
->drm
, imx_drm_encoder
->encoder
,
320 imx_drm_encoder
->encoder
->funcs
,
321 imx_drm_encoder
->encoder
->encoder_type
);
323 drm_mode_group_reinit(imxdrm
->drm
);
329 * unregister an encoder from the drm core
331 static void imx_drm_encoder_unregister(struct imx_drm_encoder
334 struct imx_drm_device
*imxdrm
= __imx_drm_device();
336 drm_encoder_cleanup(imx_drm_encoder
->encoder
);
338 drm_mode_group_reinit(imxdrm
->drm
);
342 * register a connector to the drm core
344 static int imx_drm_connector_register(
345 struct imx_drm_connector
*imx_drm_connector
)
347 struct imx_drm_device
*imxdrm
= __imx_drm_device();
349 drm_connector_init(imxdrm
->drm
, imx_drm_connector
->connector
,
350 imx_drm_connector
->connector
->funcs
,
351 imx_drm_connector
->connector
->connector_type
);
352 drm_mode_group_reinit(imxdrm
->drm
);
354 return drm_sysfs_connector_add(imx_drm_connector
->connector
);
358 * unregister a connector from the drm core
360 static void imx_drm_connector_unregister(
361 struct imx_drm_connector
*imx_drm_connector
)
363 struct imx_drm_device
*imxdrm
= __imx_drm_device();
365 drm_sysfs_connector_remove(imx_drm_connector
->connector
);
366 drm_connector_cleanup(imx_drm_connector
->connector
);
368 drm_mode_group_reinit(imxdrm
->drm
);
372 * register a crtc to the drm core
374 static int imx_drm_crtc_register(struct imx_drm_crtc
*imx_drm_crtc
)
376 struct imx_drm_device
*imxdrm
= __imx_drm_device();
379 drm_crtc_init(imxdrm
->drm
, imx_drm_crtc
->crtc
,
380 imx_drm_crtc
->imx_drm_helper_funcs
.crtc_funcs
);
381 ret
= drm_mode_crtc_set_gamma_size(imx_drm_crtc
->crtc
, 256);
385 drm_crtc_helper_add(imx_drm_crtc
->crtc
,
386 imx_drm_crtc
->imx_drm_helper_funcs
.crtc_helper_funcs
);
388 drm_mode_group_reinit(imxdrm
->drm
);
394 * Called by the CRTC driver when all CRTCs are registered. This
395 * puts all the pieces together and initializes the driver.
396 * Once this is called no more CRTCs can be registered since
397 * the drm core has hardcoded the number of crtcs in several
400 static int imx_drm_driver_load(struct drm_device
*drm
, unsigned long flags
)
402 struct imx_drm_device
*imxdrm
= __imx_drm_device();
407 drm
->dev_private
= imxdrm
;
410 * enable drm irq mode.
411 * - with irq_enabled = true, we can use the vblank feature.
413 * P.S. note that we wouldn't use drm irq handler but
414 * just specific driver own one instead because
415 * drm framework supports only one irq handler and
416 * drivers can well take care of their interrupts
418 drm
->irq_enabled
= true;
420 drm_mode_config_init(drm
);
421 imx_drm_mode_config_init(drm
);
423 mutex_lock(&imxdrm
->mutex
);
425 drm_kms_helper_poll_init(imxdrm
->drm
);
427 /* setup the grouping for the legacy output */
428 ret
= drm_mode_group_init_legacy_group(imxdrm
->drm
,
429 &imxdrm
->drm
->primary
->mode_group
);
433 ret
= drm_vblank_init(imxdrm
->drm
, MAX_CRTC
);
438 * with vblank_disable_allowed = true, vblank interrupt will be disabled
439 * by drm timer once a current process gives up ownership of
440 * vblank event.(after drm_vblank_put function is called)
442 imxdrm
->drm
->vblank_disable_allowed
= true;
444 if (!imx_drm_device_get())
450 mutex_unlock(&imxdrm
->mutex
);
455 static void imx_drm_update_possible_crtcs(void)
457 struct imx_drm_device
*imxdrm
= __imx_drm_device();
458 struct imx_drm_crtc
*imx_drm_crtc
;
459 struct imx_drm_encoder
*enc
;
460 struct crtc_cookie
*cookie
;
462 list_for_each_entry(enc
, &imxdrm
->encoder_list
, list
) {
463 u32 possible_crtcs
= 0;
465 list_for_each_entry(cookie
, &enc
->possible_crtcs
, list
) {
466 list_for_each_entry(imx_drm_crtc
, &imxdrm
->crtc_list
, list
) {
467 if (imx_drm_crtc
->cookie
.cookie
== cookie
->cookie
&&
468 imx_drm_crtc
->cookie
.id
== cookie
->id
) {
469 possible_crtcs
|= 1 << imx_drm_crtc
->pipe
;
473 enc
->encoder
->possible_crtcs
= possible_crtcs
;
474 enc
->encoder
->possible_clones
= possible_crtcs
;
479 * imx_drm_add_crtc - add a new crtc
481 * The return value if !NULL is a cookie for the caller to pass to
482 * imx_drm_remove_crtc later.
484 int imx_drm_add_crtc(struct drm_crtc
*crtc
,
485 struct imx_drm_crtc
**new_crtc
,
486 const struct imx_drm_crtc_helper_funcs
*imx_drm_helper_funcs
,
487 struct module
*owner
, void *cookie
, int id
)
489 struct imx_drm_device
*imxdrm
= __imx_drm_device();
490 struct imx_drm_crtc
*imx_drm_crtc
;
493 mutex_lock(&imxdrm
->mutex
);
495 if (imxdrm
->drm
->open_count
) {
500 imx_drm_crtc
= kzalloc(sizeof(*imx_drm_crtc
), GFP_KERNEL
);
506 imx_drm_crtc
->imx_drm_helper_funcs
= *imx_drm_helper_funcs
;
507 imx_drm_crtc
->pipe
= imxdrm
->pipes
++;
508 imx_drm_crtc
->cookie
.cookie
= cookie
;
509 imx_drm_crtc
->cookie
.id
= id
;
511 imx_drm_crtc
->crtc
= crtc
;
512 imx_drm_crtc
->imxdrm
= imxdrm
;
514 imx_drm_crtc
->owner
= owner
;
516 list_add_tail(&imx_drm_crtc
->list
, &imxdrm
->crtc_list
);
518 *new_crtc
= imx_drm_crtc
;
520 ret
= imx_drm_crtc_register(imx_drm_crtc
);
524 imx_drm_update_possible_crtcs();
526 mutex_unlock(&imxdrm
->mutex
);
531 list_del(&imx_drm_crtc
->list
);
535 mutex_unlock(&imxdrm
->mutex
);
538 EXPORT_SYMBOL_GPL(imx_drm_add_crtc
);
541 * imx_drm_remove_crtc - remove a crtc
543 int imx_drm_remove_crtc(struct imx_drm_crtc
*imx_drm_crtc
)
545 struct imx_drm_device
*imxdrm
= imx_drm_crtc
->imxdrm
;
547 mutex_lock(&imxdrm
->mutex
);
549 drm_crtc_cleanup(imx_drm_crtc
->crtc
);
551 list_del(&imx_drm_crtc
->list
);
553 drm_mode_group_reinit(imxdrm
->drm
);
555 mutex_unlock(&imxdrm
->mutex
);
561 EXPORT_SYMBOL_GPL(imx_drm_remove_crtc
);
564 * imx_drm_add_encoder - add a new encoder
566 int imx_drm_add_encoder(struct drm_encoder
*encoder
,
567 struct imx_drm_encoder
**newenc
, struct module
*owner
)
569 struct imx_drm_device
*imxdrm
= __imx_drm_device();
570 struct imx_drm_encoder
*imx_drm_encoder
;
573 mutex_lock(&imxdrm
->mutex
);
575 if (imxdrm
->drm
->open_count
) {
580 imx_drm_encoder
= kzalloc(sizeof(*imx_drm_encoder
), GFP_KERNEL
);
581 if (!imx_drm_encoder
) {
586 imx_drm_encoder
->encoder
= encoder
;
587 imx_drm_encoder
->owner
= owner
;
589 ret
= imx_drm_encoder_register(imx_drm_encoder
);
595 list_add_tail(&imx_drm_encoder
->list
, &imxdrm
->encoder_list
);
597 *newenc
= imx_drm_encoder
;
599 mutex_unlock(&imxdrm
->mutex
);
604 kfree(imx_drm_encoder
);
607 mutex_unlock(&imxdrm
->mutex
);
611 EXPORT_SYMBOL_GPL(imx_drm_add_encoder
);
613 int imx_drm_encoder_add_possible_crtcs(
614 struct imx_drm_encoder
*imx_drm_encoder
,
615 struct device_node
*np
)
617 struct imx_drm_device
*imxdrm
= __imx_drm_device();
618 struct of_phandle_args args
;
619 struct crtc_cookie
*c
;
623 if (!list_empty(&imx_drm_encoder
->possible_crtcs
))
626 for (i
= 0; !ret
; i
++) {
627 ret
= of_parse_phandle_with_args(np
, "crtcs",
628 "#crtc-cells", i
, &args
);
632 c
= kzalloc(sizeof(*c
), GFP_KERNEL
);
634 of_node_put(args
.np
);
639 c
->id
= args
.args_count
> 0 ? args
.args
[0] : 0;
641 of_node_put(args
.np
);
643 mutex_lock(&imxdrm
->mutex
);
645 list_add_tail(&c
->list
, &imx_drm_encoder
->possible_crtcs
);
647 mutex_unlock(&imxdrm
->mutex
);
650 imx_drm_update_possible_crtcs();
654 EXPORT_SYMBOL_GPL(imx_drm_encoder_add_possible_crtcs
);
656 int imx_drm_encoder_get_mux_id(struct imx_drm_encoder
*imx_drm_encoder
,
657 struct drm_crtc
*crtc
)
659 struct imx_drm_device
*imxdrm
= __imx_drm_device();
660 struct imx_drm_crtc
*imx_crtc
;
663 list_for_each_entry(imx_crtc
, &imxdrm
->crtc_list
, list
) {
664 if (imx_crtc
->crtc
== crtc
)
673 EXPORT_SYMBOL_GPL(imx_drm_encoder_get_mux_id
);
676 * imx_drm_remove_encoder - remove an encoder
678 int imx_drm_remove_encoder(struct imx_drm_encoder
*imx_drm_encoder
)
680 struct imx_drm_device
*imxdrm
= __imx_drm_device();
681 struct crtc_cookie
*c
, *tmp
;
683 mutex_lock(&imxdrm
->mutex
);
685 imx_drm_encoder_unregister(imx_drm_encoder
);
687 list_del(&imx_drm_encoder
->list
);
689 list_for_each_entry_safe(c
, tmp
, &imx_drm_encoder
->possible_crtcs
,
693 mutex_unlock(&imxdrm
->mutex
);
695 kfree(imx_drm_encoder
);
699 EXPORT_SYMBOL_GPL(imx_drm_remove_encoder
);
702 * imx_drm_add_connector - add a connector
704 int imx_drm_add_connector(struct drm_connector
*connector
,
705 struct imx_drm_connector
**new_con
,
706 struct module
*owner
)
708 struct imx_drm_device
*imxdrm
= __imx_drm_device();
709 struct imx_drm_connector
*imx_drm_connector
;
712 mutex_lock(&imxdrm
->mutex
);
714 if (imxdrm
->drm
->open_count
) {
719 imx_drm_connector
= kzalloc(sizeof(*imx_drm_connector
), GFP_KERNEL
);
720 if (!imx_drm_connector
) {
725 imx_drm_connector
->connector
= connector
;
726 imx_drm_connector
->owner
= owner
;
728 ret
= imx_drm_connector_register(imx_drm_connector
);
732 list_add_tail(&imx_drm_connector
->list
, &imxdrm
->connector_list
);
734 *new_con
= imx_drm_connector
;
736 mutex_unlock(&imxdrm
->mutex
);
741 kfree(imx_drm_connector
);
744 mutex_unlock(&imxdrm
->mutex
);
748 EXPORT_SYMBOL_GPL(imx_drm_add_connector
);
750 void imx_drm_fb_helper_set(struct drm_fbdev_cma
*fbdev_helper
)
752 struct imx_drm_device
*imxdrm
= __imx_drm_device();
754 imxdrm
->fbhelper
= fbdev_helper
;
756 EXPORT_SYMBOL_GPL(imx_drm_fb_helper_set
);
759 * imx_drm_remove_connector - remove a connector
761 int imx_drm_remove_connector(struct imx_drm_connector
*imx_drm_connector
)
763 struct imx_drm_device
*imxdrm
= __imx_drm_device();
765 mutex_lock(&imxdrm
->mutex
);
767 imx_drm_connector_unregister(imx_drm_connector
);
769 list_del(&imx_drm_connector
->list
);
771 mutex_unlock(&imxdrm
->mutex
);
773 kfree(imx_drm_connector
);
777 EXPORT_SYMBOL_GPL(imx_drm_remove_connector
);
779 static const struct drm_ioctl_desc imx_drm_ioctls
[] = {
783 static struct drm_driver imx_drm_driver
= {
784 .driver_features
= DRIVER_MODESET
| DRIVER_GEM
| DRIVER_PRIME
,
785 .load
= imx_drm_driver_load
,
786 .unload
= imx_drm_driver_unload
,
787 .lastclose
= imx_drm_driver_lastclose
,
788 .preclose
= imx_drm_driver_preclose
,
789 .gem_free_object
= drm_gem_cma_free_object
,
790 .gem_vm_ops
= &drm_gem_cma_vm_ops
,
791 .dumb_create
= drm_gem_cma_dumb_create
,
792 .dumb_map_offset
= drm_gem_cma_dumb_map_offset
,
793 .dumb_destroy
= drm_gem_dumb_destroy
,
795 .prime_handle_to_fd
= drm_gem_prime_handle_to_fd
,
796 .prime_fd_to_handle
= drm_gem_prime_fd_to_handle
,
797 .gem_prime_import
= drm_gem_prime_import
,
798 .gem_prime_export
= drm_gem_prime_export
,
799 .gem_prime_get_sg_table
= drm_gem_cma_prime_get_sg_table
,
800 .gem_prime_import_sg_table
= drm_gem_cma_prime_import_sg_table
,
801 .gem_prime_vmap
= drm_gem_cma_prime_vmap
,
802 .gem_prime_vunmap
= drm_gem_cma_prime_vunmap
,
803 .gem_prime_mmap
= drm_gem_cma_prime_mmap
,
804 .get_vblank_counter
= drm_vblank_count
,
805 .enable_vblank
= imx_drm_enable_vblank
,
806 .disable_vblank
= imx_drm_disable_vblank
,
807 .ioctls
= imx_drm_ioctls
,
808 .num_ioctls
= ARRAY_SIZE(imx_drm_ioctls
),
809 .fops
= &imx_drm_driver_fops
,
811 .desc
= "i.MX DRM graphics",
818 static int imx_drm_platform_probe(struct platform_device
*pdev
)
822 ret
= dma_set_coherent_mask(&pdev
->dev
, DMA_BIT_MASK(32));
826 imx_drm_device
->dev
= &pdev
->dev
;
828 return drm_platform_init(&imx_drm_driver
, pdev
);
831 static int imx_drm_platform_remove(struct platform_device
*pdev
)
833 drm_platform_exit(&imx_drm_driver
, pdev
);
838 static struct platform_driver imx_drm_pdrv
= {
839 .probe
= imx_drm_platform_probe
,
840 .remove
= imx_drm_platform_remove
,
842 .owner
= THIS_MODULE
,
847 static struct platform_device
*imx_drm_pdev
;
849 static int __init
imx_drm_init(void)
853 imx_drm_device
= kzalloc(sizeof(*imx_drm_device
), GFP_KERNEL
);
857 mutex_init(&imx_drm_device
->mutex
);
858 INIT_LIST_HEAD(&imx_drm_device
->crtc_list
);
859 INIT_LIST_HEAD(&imx_drm_device
->connector_list
);
860 INIT_LIST_HEAD(&imx_drm_device
->encoder_list
);
862 imx_drm_pdev
= platform_device_register_simple("imx-drm", -1, NULL
, 0);
863 if (IS_ERR(imx_drm_pdev
)) {
864 ret
= PTR_ERR(imx_drm_pdev
);
868 ret
= platform_driver_register(&imx_drm_pdrv
);
875 platform_device_unregister(imx_drm_pdev
);
877 kfree(imx_drm_device
);
882 static void __exit
imx_drm_exit(void)
884 platform_device_unregister(imx_drm_pdev
);
885 platform_driver_unregister(&imx_drm_pdrv
);
887 kfree(imx_drm_device
);
890 module_init(imx_drm_init
);
891 module_exit(imx_drm_exit
);
893 MODULE_AUTHOR("Sascha Hauer <s.hauer@pengutronix.de>");
894 MODULE_DESCRIPTION("i.MX drm driver core");
895 MODULE_LICENSE("GPL");