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
;
39 struct imx_drm_device
{
40 struct drm_device
*drm
;
42 struct imx_drm_crtc
*crtc
[MAX_CRTC
];
43 struct list_head encoder_list
;
44 struct list_head connector_list
;
47 struct drm_fbdev_cma
*fbhelper
;
51 struct drm_crtc
*crtc
;
52 struct imx_drm_device
*imxdrm
;
54 struct imx_drm_crtc_helper_funcs imx_drm_helper_funcs
;
56 struct crtc_cookie cookie
;
60 struct imx_drm_encoder
{
61 struct drm_encoder
*encoder
;
62 struct list_head list
;
64 struct list_head possible_crtcs
;
67 struct imx_drm_connector
{
68 struct drm_connector
*connector
;
69 struct list_head list
;
73 static struct imx_drm_device
*__imx_drm_device(void);
75 int imx_drm_crtc_id(struct imx_drm_crtc
*crtc
)
79 EXPORT_SYMBOL_GPL(imx_drm_crtc_id
);
81 static void imx_drm_driver_lastclose(struct drm_device
*drm
)
83 struct imx_drm_device
*imxdrm
= drm
->dev_private
;
86 drm_fbdev_cma_restore_mode(imxdrm
->fbhelper
);
89 static int imx_drm_driver_unload(struct drm_device
*drm
)
91 struct imx_drm_device
*imxdrm
= drm
->dev_private
;
95 drm_vblank_cleanup(drm
);
96 drm_kms_helper_poll_fini(drm
);
97 drm_mode_config_cleanup(drm
);
102 struct imx_drm_crtc
*imx_drm_find_crtc(struct drm_crtc
*crtc
)
104 struct imx_drm_device
*imxdrm
= __imx_drm_device();
107 for (i
= 0; i
< MAX_CRTC
; i
++)
108 if (imxdrm
->crtc
[i
] && imxdrm
->crtc
[i
]->crtc
== crtc
)
109 return imxdrm
->crtc
[i
];
114 int imx_drm_crtc_panel_format_pins(struct drm_crtc
*crtc
, u32 encoder_type
,
115 u32 interface_pix_fmt
, int hsync_pin
, int vsync_pin
)
117 struct imx_drm_crtc_helper_funcs
*helper
;
118 struct imx_drm_crtc
*imx_crtc
;
120 imx_crtc
= imx_drm_find_crtc(crtc
);
124 helper
= &imx_crtc
->imx_drm_helper_funcs
;
125 if (helper
->set_interface_pix_fmt
)
126 return helper
->set_interface_pix_fmt(crtc
,
127 encoder_type
, interface_pix_fmt
,
128 hsync_pin
, vsync_pin
);
131 EXPORT_SYMBOL_GPL(imx_drm_crtc_panel_format_pins
);
133 int imx_drm_crtc_panel_format(struct drm_crtc
*crtc
, u32 encoder_type
,
134 u32 interface_pix_fmt
)
136 return imx_drm_crtc_panel_format_pins(crtc
, encoder_type
,
137 interface_pix_fmt
, 2, 3);
139 EXPORT_SYMBOL_GPL(imx_drm_crtc_panel_format
);
141 int imx_drm_crtc_vblank_get(struct imx_drm_crtc
*imx_drm_crtc
)
143 return drm_vblank_get(imx_drm_crtc
->crtc
->dev
, imx_drm_crtc
->pipe
);
145 EXPORT_SYMBOL_GPL(imx_drm_crtc_vblank_get
);
147 void imx_drm_crtc_vblank_put(struct imx_drm_crtc
*imx_drm_crtc
)
149 drm_vblank_put(imx_drm_crtc
->crtc
->dev
, imx_drm_crtc
->pipe
);
151 EXPORT_SYMBOL_GPL(imx_drm_crtc_vblank_put
);
153 void imx_drm_handle_vblank(struct imx_drm_crtc
*imx_drm_crtc
)
155 drm_handle_vblank(imx_drm_crtc
->crtc
->dev
, imx_drm_crtc
->pipe
);
157 EXPORT_SYMBOL_GPL(imx_drm_handle_vblank
);
159 static int imx_drm_enable_vblank(struct drm_device
*drm
, int crtc
)
161 struct imx_drm_device
*imxdrm
= drm
->dev_private
;
162 struct imx_drm_crtc
*imx_drm_crtc
= imxdrm
->crtc
[crtc
];
168 if (!imx_drm_crtc
->imx_drm_helper_funcs
.enable_vblank
)
171 ret
= imx_drm_crtc
->imx_drm_helper_funcs
.enable_vblank(
177 static void imx_drm_disable_vblank(struct drm_device
*drm
, int crtc
)
179 struct imx_drm_device
*imxdrm
= drm
->dev_private
;
180 struct imx_drm_crtc
*imx_drm_crtc
= imxdrm
->crtc
[crtc
];
185 if (!imx_drm_crtc
->imx_drm_helper_funcs
.disable_vblank
)
188 imx_drm_crtc
->imx_drm_helper_funcs
.disable_vblank(imx_drm_crtc
->crtc
);
191 static void imx_drm_driver_preclose(struct drm_device
*drm
,
192 struct drm_file
*file
)
196 if (!file
->is_master
)
199 for (i
= 0; i
< MAX_CRTC
; i
++)
200 imx_drm_disable_vblank(drm
, i
);
203 static const struct file_operations imx_drm_driver_fops
= {
204 .owner
= THIS_MODULE
,
206 .release
= drm_release
,
207 .unlocked_ioctl
= drm_ioctl
,
208 .mmap
= drm_gem_cma_mmap
,
211 .llseek
= noop_llseek
,
214 static struct imx_drm_device
*imx_drm_device
;
216 static struct imx_drm_device
*__imx_drm_device(void)
218 return imx_drm_device
;
221 struct drm_device
*imx_drm_device_get(void)
223 struct imx_drm_device
*imxdrm
= __imx_drm_device();
224 struct imx_drm_encoder
*enc
;
225 struct imx_drm_connector
*con
;
226 struct imx_drm_crtc
*crtc
;
228 list_for_each_entry(enc
, &imxdrm
->encoder_list
, list
) {
229 if (!try_module_get(enc
->owner
)) {
230 dev_err(imxdrm
->dev
, "could not get module %s\n",
231 module_name(enc
->owner
));
236 list_for_each_entry(con
, &imxdrm
->connector_list
, list
) {
237 if (!try_module_get(con
->owner
)) {
238 dev_err(imxdrm
->dev
, "could not get module %s\n",
239 module_name(con
->owner
));
244 list_for_each_entry(crtc
, &imxdrm
->crtc_list
, list
) {
245 if (!try_module_get(crtc
->owner
)) {
246 dev_err(imxdrm
->dev
, "could not get module %s\n",
247 module_name(crtc
->owner
));
255 list_for_each_entry_continue_reverse(crtc
, &imxdrm
->crtc_list
, list
)
256 module_put(crtc
->owner
);
258 list_for_each_entry_continue_reverse(con
, &imxdrm
->connector_list
, list
)
259 module_put(con
->owner
);
261 list_for_each_entry_continue_reverse(enc
, &imxdrm
->encoder_list
, list
)
262 module_put(enc
->owner
);
264 mutex_unlock(&imxdrm
->mutex
);
269 EXPORT_SYMBOL_GPL(imx_drm_device_get
);
271 void imx_drm_device_put(void)
273 struct imx_drm_device
*imxdrm
= __imx_drm_device();
274 struct imx_drm_encoder
*enc
;
275 struct imx_drm_connector
*con
;
276 struct imx_drm_crtc
*crtc
;
278 mutex_lock(&imxdrm
->mutex
);
280 list_for_each_entry(crtc
, &imxdrm
->crtc_list
, list
)
281 module_put(crtc
->owner
);
283 list_for_each_entry(con
, &imxdrm
->connector_list
, list
)
284 module_put(con
->owner
);
286 list_for_each_entry(enc
, &imxdrm
->encoder_list
, list
)
287 module_put(enc
->owner
);
289 mutex_unlock(&imxdrm
->mutex
);
291 EXPORT_SYMBOL_GPL(imx_drm_device_put
);
293 static int drm_mode_group_reinit(struct drm_device
*dev
)
295 struct drm_mode_group
*group
= &dev
->primary
->mode_group
;
296 uint32_t *id_list
= group
->id_list
;
299 ret
= drm_mode_group_init_legacy_group(dev
, group
);
308 * register an encoder to the drm core
310 static int imx_drm_encoder_register(struct imx_drm_encoder
*imx_drm_encoder
)
312 struct imx_drm_device
*imxdrm
= __imx_drm_device();
314 INIT_LIST_HEAD(&imx_drm_encoder
->possible_crtcs
);
316 drm_encoder_init(imxdrm
->drm
, imx_drm_encoder
->encoder
,
317 imx_drm_encoder
->encoder
->funcs
,
318 imx_drm_encoder
->encoder
->encoder_type
);
320 drm_mode_group_reinit(imxdrm
->drm
);
326 * unregister an encoder from the drm core
328 static void imx_drm_encoder_unregister(struct imx_drm_encoder
331 struct imx_drm_device
*imxdrm
= __imx_drm_device();
333 drm_encoder_cleanup(imx_drm_encoder
->encoder
);
335 drm_mode_group_reinit(imxdrm
->drm
);
339 * register a connector to the drm core
341 static int imx_drm_connector_register(
342 struct imx_drm_connector
*imx_drm_connector
)
344 struct imx_drm_device
*imxdrm
= __imx_drm_device();
346 drm_connector_init(imxdrm
->drm
, imx_drm_connector
->connector
,
347 imx_drm_connector
->connector
->funcs
,
348 imx_drm_connector
->connector
->connector_type
);
349 drm_mode_group_reinit(imxdrm
->drm
);
351 return drm_sysfs_connector_add(imx_drm_connector
->connector
);
355 * unregister a connector from the drm core
357 static void imx_drm_connector_unregister(
358 struct imx_drm_connector
*imx_drm_connector
)
360 struct imx_drm_device
*imxdrm
= __imx_drm_device();
362 drm_sysfs_connector_remove(imx_drm_connector
->connector
);
363 drm_connector_cleanup(imx_drm_connector
->connector
);
365 drm_mode_group_reinit(imxdrm
->drm
);
369 * Called by the CRTC driver when all CRTCs are registered. This
370 * puts all the pieces together and initializes the driver.
371 * Once this is called no more CRTCs can be registered since
372 * the drm core has hardcoded the number of crtcs in several
375 static int imx_drm_driver_load(struct drm_device
*drm
, unsigned long flags
)
377 struct imx_drm_device
*imxdrm
= __imx_drm_device();
382 drm
->dev_private
= imxdrm
;
385 * enable drm irq mode.
386 * - with irq_enabled = true, we can use the vblank feature.
388 * P.S. note that we wouldn't use drm irq handler but
389 * just specific driver own one instead because
390 * drm framework supports only one irq handler and
391 * drivers can well take care of their interrupts
393 drm
->irq_enabled
= true;
395 drm_mode_config_init(drm
);
396 imx_drm_mode_config_init(drm
);
398 mutex_lock(&imxdrm
->mutex
);
400 drm_kms_helper_poll_init(drm
);
402 /* setup the grouping for the legacy output */
403 ret
= drm_mode_group_init_legacy_group(drm
,
404 &drm
->primary
->mode_group
);
408 ret
= drm_vblank_init(drm
, MAX_CRTC
);
413 * with vblank_disable_allowed = true, vblank interrupt will be disabled
414 * by drm timer once a current process gives up ownership of
415 * vblank event.(after drm_vblank_put function is called)
417 drm
->vblank_disable_allowed
= true;
419 if (!imx_drm_device_get()) {
424 platform_set_drvdata(drm
->platformdev
, drm
);
425 mutex_unlock(&imxdrm
->mutex
);
429 drm_vblank_cleanup(drm
);
431 drm_kms_helper_poll_fini(drm
);
432 drm_mode_config_cleanup(drm
);
433 mutex_unlock(&imxdrm
->mutex
);
438 static void imx_drm_update_possible_crtcs(void)
440 struct imx_drm_device
*imxdrm
= __imx_drm_device();
441 struct imx_drm_crtc
*imx_drm_crtc
;
442 struct imx_drm_encoder
*enc
;
443 struct crtc_cookie
*cookie
;
445 list_for_each_entry(enc
, &imxdrm
->encoder_list
, list
) {
446 u32 possible_crtcs
= 0;
448 list_for_each_entry(cookie
, &enc
->possible_crtcs
, list
) {
449 list_for_each_entry(imx_drm_crtc
, &imxdrm
->crtc_list
, list
) {
450 if (imx_drm_crtc
->cookie
.cookie
== cookie
->cookie
&&
451 imx_drm_crtc
->cookie
.id
== cookie
->id
) {
452 possible_crtcs
|= 1 << imx_drm_crtc
->pipe
;
456 enc
->encoder
->possible_crtcs
= possible_crtcs
;
457 enc
->encoder
->possible_clones
= possible_crtcs
;
462 * imx_drm_add_crtc - add a new crtc
464 * The return value if !NULL is a cookie for the caller to pass to
465 * imx_drm_remove_crtc later.
467 int imx_drm_add_crtc(struct drm_crtc
*crtc
,
468 struct imx_drm_crtc
**new_crtc
,
469 const struct imx_drm_crtc_helper_funcs
*imx_drm_helper_funcs
,
470 struct module
*owner
, void *cookie
, int id
)
472 struct imx_drm_device
*imxdrm
= __imx_drm_device();
473 struct imx_drm_crtc
*imx_drm_crtc
;
476 mutex_lock(&imxdrm
->mutex
);
479 * The vblank arrays are dimensioned by MAX_CRTC - we can't
480 * pass IDs greater than this to those functions.
482 if (imxdrm
->pipes
>= MAX_CRTC
) {
487 if (imxdrm
->drm
->open_count
) {
492 imx_drm_crtc
= kzalloc(sizeof(*imx_drm_crtc
), GFP_KERNEL
);
498 imx_drm_crtc
->imx_drm_helper_funcs
= *imx_drm_helper_funcs
;
499 imx_drm_crtc
->pipe
= imxdrm
->pipes
++;
500 imx_drm_crtc
->cookie
.cookie
= cookie
;
501 imx_drm_crtc
->cookie
.id
= id
;
502 imx_drm_crtc
->mux_id
= imx_drm_crtc
->pipe
;
503 imx_drm_crtc
->crtc
= crtc
;
504 imx_drm_crtc
->imxdrm
= imxdrm
;
506 imx_drm_crtc
->owner
= owner
;
508 imxdrm
->crtc
[imx_drm_crtc
->pipe
] = imx_drm_crtc
;
510 *new_crtc
= imx_drm_crtc
;
512 ret
= drm_mode_crtc_set_gamma_size(imx_drm_crtc
->crtc
, 256);
516 drm_crtc_helper_add(crtc
,
517 imx_drm_crtc
->imx_drm_helper_funcs
.crtc_helper_funcs
);
519 drm_crtc_init(imxdrm
->drm
, crtc
,
520 imx_drm_crtc
->imx_drm_helper_funcs
.crtc_funcs
);
522 drm_mode_group_reinit(imxdrm
->drm
);
524 imx_drm_update_possible_crtcs();
526 mutex_unlock(&imxdrm
->mutex
);
531 imxdrm
->crtc
[imx_drm_crtc
->pipe
] = NULL
;
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 imxdrm
->crtc
[imx_drm_crtc
->pipe
] = NULL
;
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 drm_encoder
*encoder
)
658 struct imx_drm_crtc
*imx_crtc
= imx_drm_find_crtc(encoder
->crtc
);
660 return imx_crtc
? imx_crtc
->mux_id
: -EINVAL
;
662 EXPORT_SYMBOL_GPL(imx_drm_encoder_get_mux_id
);
665 * imx_drm_remove_encoder - remove an encoder
667 int imx_drm_remove_encoder(struct imx_drm_encoder
*imx_drm_encoder
)
669 struct imx_drm_device
*imxdrm
= __imx_drm_device();
670 struct crtc_cookie
*c
, *tmp
;
672 mutex_lock(&imxdrm
->mutex
);
674 imx_drm_encoder_unregister(imx_drm_encoder
);
676 list_del(&imx_drm_encoder
->list
);
678 list_for_each_entry_safe(c
, tmp
, &imx_drm_encoder
->possible_crtcs
,
682 mutex_unlock(&imxdrm
->mutex
);
684 kfree(imx_drm_encoder
);
688 EXPORT_SYMBOL_GPL(imx_drm_remove_encoder
);
691 * imx_drm_add_connector - add a connector
693 int imx_drm_add_connector(struct drm_connector
*connector
,
694 struct imx_drm_connector
**new_con
,
695 struct module
*owner
)
697 struct imx_drm_device
*imxdrm
= __imx_drm_device();
698 struct imx_drm_connector
*imx_drm_connector
;
701 mutex_lock(&imxdrm
->mutex
);
703 if (imxdrm
->drm
->open_count
) {
708 imx_drm_connector
= kzalloc(sizeof(*imx_drm_connector
), GFP_KERNEL
);
709 if (!imx_drm_connector
) {
714 imx_drm_connector
->connector
= connector
;
715 imx_drm_connector
->owner
= owner
;
717 ret
= imx_drm_connector_register(imx_drm_connector
);
721 list_add_tail(&imx_drm_connector
->list
, &imxdrm
->connector_list
);
723 *new_con
= imx_drm_connector
;
725 mutex_unlock(&imxdrm
->mutex
);
730 kfree(imx_drm_connector
);
733 mutex_unlock(&imxdrm
->mutex
);
737 EXPORT_SYMBOL_GPL(imx_drm_add_connector
);
739 void imx_drm_fb_helper_set(struct drm_fbdev_cma
*fbdev_helper
)
741 struct imx_drm_device
*imxdrm
= __imx_drm_device();
743 imxdrm
->fbhelper
= fbdev_helper
;
745 EXPORT_SYMBOL_GPL(imx_drm_fb_helper_set
);
748 * imx_drm_remove_connector - remove a connector
750 int imx_drm_remove_connector(struct imx_drm_connector
*imx_drm_connector
)
752 struct imx_drm_device
*imxdrm
= __imx_drm_device();
754 mutex_lock(&imxdrm
->mutex
);
756 imx_drm_connector_unregister(imx_drm_connector
);
758 list_del(&imx_drm_connector
->list
);
760 mutex_unlock(&imxdrm
->mutex
);
762 kfree(imx_drm_connector
);
766 EXPORT_SYMBOL_GPL(imx_drm_remove_connector
);
768 static const struct drm_ioctl_desc imx_drm_ioctls
[] = {
772 static struct drm_driver imx_drm_driver
= {
773 .driver_features
= DRIVER_MODESET
| DRIVER_GEM
| DRIVER_PRIME
,
774 .load
= imx_drm_driver_load
,
775 .unload
= imx_drm_driver_unload
,
776 .lastclose
= imx_drm_driver_lastclose
,
777 .preclose
= imx_drm_driver_preclose
,
778 .gem_free_object
= drm_gem_cma_free_object
,
779 .gem_vm_ops
= &drm_gem_cma_vm_ops
,
780 .dumb_create
= drm_gem_cma_dumb_create
,
781 .dumb_map_offset
= drm_gem_cma_dumb_map_offset
,
782 .dumb_destroy
= drm_gem_dumb_destroy
,
784 .prime_handle_to_fd
= drm_gem_prime_handle_to_fd
,
785 .prime_fd_to_handle
= drm_gem_prime_fd_to_handle
,
786 .gem_prime_import
= drm_gem_prime_import
,
787 .gem_prime_export
= drm_gem_prime_export
,
788 .gem_prime_get_sg_table
= drm_gem_cma_prime_get_sg_table
,
789 .gem_prime_import_sg_table
= drm_gem_cma_prime_import_sg_table
,
790 .gem_prime_vmap
= drm_gem_cma_prime_vmap
,
791 .gem_prime_vunmap
= drm_gem_cma_prime_vunmap
,
792 .gem_prime_mmap
= drm_gem_cma_prime_mmap
,
793 .get_vblank_counter
= drm_vblank_count
,
794 .enable_vblank
= imx_drm_enable_vblank
,
795 .disable_vblank
= imx_drm_disable_vblank
,
796 .ioctls
= imx_drm_ioctls
,
797 .num_ioctls
= ARRAY_SIZE(imx_drm_ioctls
),
798 .fops
= &imx_drm_driver_fops
,
800 .desc
= "i.MX DRM graphics",
807 static int imx_drm_platform_probe(struct platform_device
*pdev
)
811 ret
= dma_set_coherent_mask(&pdev
->dev
, DMA_BIT_MASK(32));
815 imx_drm_device
->dev
= &pdev
->dev
;
817 return drm_platform_init(&imx_drm_driver
, pdev
);
820 static int imx_drm_platform_remove(struct platform_device
*pdev
)
822 drm_put_dev(platform_get_drvdata(pdev
));
827 static struct platform_driver imx_drm_pdrv
= {
828 .probe
= imx_drm_platform_probe
,
829 .remove
= imx_drm_platform_remove
,
831 .owner
= THIS_MODULE
,
836 static struct platform_device
*imx_drm_pdev
;
838 static int __init
imx_drm_init(void)
842 imx_drm_device
= kzalloc(sizeof(*imx_drm_device
), GFP_KERNEL
);
846 mutex_init(&imx_drm_device
->mutex
);
847 INIT_LIST_HEAD(&imx_drm_device
->connector_list
);
848 INIT_LIST_HEAD(&imx_drm_device
->encoder_list
);
850 imx_drm_pdev
= platform_device_register_simple("imx-drm", -1, NULL
, 0);
851 if (IS_ERR(imx_drm_pdev
)) {
852 ret
= PTR_ERR(imx_drm_pdev
);
856 ret
= platform_driver_register(&imx_drm_pdrv
);
863 platform_device_unregister(imx_drm_pdev
);
865 kfree(imx_drm_device
);
870 static void __exit
imx_drm_exit(void)
872 platform_device_unregister(imx_drm_pdev
);
873 platform_driver_unregister(&imx_drm_pdrv
);
875 kfree(imx_drm_device
);
878 module_init(imx_drm_init
);
879 module_exit(imx_drm_exit
);
881 MODULE_AUTHOR("Sascha Hauer <s.hauer@pengutronix.de>");
882 MODULE_DESCRIPTION("i.MX drm driver core");
883 MODULE_LICENSE("GPL");