]> git.proxmox.com Git - mirror_ubuntu-hirsute-kernel.git/blame - drivers/gpu/drm/imx/imx-drm-core.c
Merge remote-tracking branches 'spi/topic/dw', 'spi/topic/dw-mid', 'spi/topic/fsl...
[mirror_ubuntu-hirsute-kernel.git] / drivers / gpu / drm / imx / imx-drm-core.c
CommitLineData
e692da4d
SH
1/*
2 * Freescale i.MX drm driver
3 *
4 * Copyright (C) 2011 Sascha Hauer, Pengutronix
5 *
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.
14 *
15 */
17b5001b 16#include <linux/component.h>
e692da4d 17#include <linux/device.h>
e7d6231e
RK
18#include <linux/fb.h>
19#include <linux/module.h>
655b43cc 20#include <linux/of_graph.h>
e692da4d
SH
21#include <linux/platform_device.h>
22#include <drm/drmP.h>
23#include <drm/drm_fb_helper.h>
24#include <drm/drm_crtc_helper.h>
e692da4d
SH
25#include <drm/drm_gem_cma_helper.h>
26#include <drm/drm_fb_cma_helper.h>
3cb9ae4f 27#include <drm/drm_plane_helper.h>
6457b971 28#include <drm/drm_of.h>
e692da4d
SH
29
30#include "imx-drm.h"
31
32#define MAX_CRTC 4
33
655b43cc
PZ
34struct imx_drm_component {
35 struct device_node *of_node;
36 struct list_head list;
37};
38
e692da4d
SH
39struct imx_drm_device {
40 struct drm_device *drm;
887eceac 41 struct imx_drm_crtc *crtc[MAX_CRTC];
e692da4d
SH
42 int pipes;
43 struct drm_fbdev_cma *fbhelper;
44};
45
46struct imx_drm_crtc {
47 struct drm_crtc *crtc;
e692da4d
SH
48 int pipe;
49 struct imx_drm_crtc_helper_funcs imx_drm_helper_funcs;
e692da4d
SH
50};
51
8acba02f
RK
52static int legacyfb_depth = 16;
53module_param(legacyfb_depth, int, 0444);
54
b8d181e4
PZ
55int imx_drm_crtc_id(struct imx_drm_crtc *crtc)
56{
57 return crtc->pipe;
58}
9c74360f 59EXPORT_SYMBOL_GPL(imx_drm_crtc_id);
b8d181e4 60
e692da4d
SH
61static void imx_drm_driver_lastclose(struct drm_device *drm)
62{
8acba02f 63#if IS_ENABLED(CONFIG_DRM_IMX_FB_HELPER)
e692da4d
SH
64 struct imx_drm_device *imxdrm = drm->dev_private;
65
3f3a7280 66 drm_fbdev_cma_restore_mode(imxdrm->fbhelper);
8acba02f 67#endif
e692da4d
SH
68}
69
70static int imx_drm_driver_unload(struct drm_device *drm)
71{
8acba02f 72#if IS_ENABLED(CONFIG_DRM_IMX_FB_HELPER)
e692da4d 73 struct imx_drm_device *imxdrm = drm->dev_private;
3e68439b
RK
74#endif
75
76 drm_kms_helper_poll_fini(drm);
e692da4d 77
3e68439b 78#if IS_ENABLED(CONFIG_DRM_IMX_FB_HELPER)
8acba02f
RK
79 if (imxdrm->fbhelper)
80 drm_fbdev_cma_fini(imxdrm->fbhelper);
81#endif
82
17b5001b
RK
83 component_unbind_all(drm->dev, drm);
84
020a9ea7 85 drm_vblank_cleanup(drm);
020a9ea7 86 drm_mode_config_cleanup(drm);
e692da4d 87
bfe945c8
SG
88 platform_set_drvdata(drm->platformdev, NULL);
89
e692da4d
SH
90 return 0;
91}
92
fdffa6f2 93static struct imx_drm_crtc *imx_drm_find_crtc(struct drm_crtc *crtc)
e692da4d 94{
32266b45 95 struct imx_drm_device *imxdrm = crtc->dev->dev_private;
887eceac
RK
96 unsigned i;
97
98 for (i = 0; i < MAX_CRTC; i++)
99 if (imxdrm->crtc[i] && imxdrm->crtc[i]->crtc == crtc)
100 return imxdrm->crtc[i];
e692da4d 101
e692da4d
SH
102 return NULL;
103}
104
2872c807
PZ
105int imx_drm_set_bus_format_pins(struct drm_encoder *encoder, u32 bus_format,
106 int hsync_pin, int vsync_pin)
e692da4d 107{
e692da4d 108 struct imx_drm_crtc_helper_funcs *helper;
887eceac 109 struct imx_drm_crtc *imx_crtc;
e692da4d 110
f2d66aad 111 imx_crtc = imx_drm_find_crtc(encoder->crtc);
887eceac
RK
112 if (!imx_crtc)
113 return -EINVAL;
e692da4d 114
e692da4d
SH
115 helper = &imx_crtc->imx_drm_helper_funcs;
116 if (helper->set_interface_pix_fmt)
f2d66aad 117 return helper->set_interface_pix_fmt(encoder->crtc,
2872c807 118 bus_format, hsync_pin, vsync_pin);
e692da4d
SH
119 return 0;
120}
2872c807 121EXPORT_SYMBOL_GPL(imx_drm_set_bus_format_pins);
2ea42608 122
2872c807 123int imx_drm_set_bus_format(struct drm_encoder *encoder, u32 bus_format)
2ea42608 124{
2872c807 125 return imx_drm_set_bus_format_pins(encoder, bus_format, 2, 3);
2ea42608 126}
2872c807 127EXPORT_SYMBOL_GPL(imx_drm_set_bus_format);
e692da4d
SH
128
129int imx_drm_crtc_vblank_get(struct imx_drm_crtc *imx_drm_crtc)
130{
b5ea1492 131 return drm_vblank_get(imx_drm_crtc->crtc->dev, imx_drm_crtc->pipe);
e692da4d
SH
132}
133EXPORT_SYMBOL_GPL(imx_drm_crtc_vblank_get);
134
135void imx_drm_crtc_vblank_put(struct imx_drm_crtc *imx_drm_crtc)
136{
b5ea1492 137 drm_vblank_put(imx_drm_crtc->crtc->dev, imx_drm_crtc->pipe);
e692da4d
SH
138}
139EXPORT_SYMBOL_GPL(imx_drm_crtc_vblank_put);
140
141void imx_drm_handle_vblank(struct imx_drm_crtc *imx_drm_crtc)
142{
b5ea1492 143 drm_handle_vblank(imx_drm_crtc->crtc->dev, imx_drm_crtc->pipe);
e692da4d
SH
144}
145EXPORT_SYMBOL_GPL(imx_drm_handle_vblank);
146
88e72717 147static int imx_drm_enable_vblank(struct drm_device *drm, unsigned int pipe)
e692da4d
SH
148{
149 struct imx_drm_device *imxdrm = drm->dev_private;
88e72717 150 struct imx_drm_crtc *imx_drm_crtc = imxdrm->crtc[pipe];
e692da4d
SH
151 int ret;
152
e692da4d
SH
153 if (!imx_drm_crtc)
154 return -EINVAL;
155
156 if (!imx_drm_crtc->imx_drm_helper_funcs.enable_vblank)
157 return -ENOSYS;
158
159 ret = imx_drm_crtc->imx_drm_helper_funcs.enable_vblank(
160 imx_drm_crtc->crtc);
161
162 return ret;
163}
164
88e72717 165static void imx_drm_disable_vblank(struct drm_device *drm, unsigned int pipe)
e692da4d
SH
166{
167 struct imx_drm_device *imxdrm = drm->dev_private;
88e72717 168 struct imx_drm_crtc *imx_drm_crtc = imxdrm->crtc[pipe];
e692da4d 169
e692da4d
SH
170 if (!imx_drm_crtc)
171 return;
172
173 if (!imx_drm_crtc->imx_drm_helper_funcs.disable_vblank)
174 return;
175
176 imx_drm_crtc->imx_drm_helper_funcs.disable_vblank(imx_drm_crtc->crtc);
177}
178
6ee4d7fe
SH
179static void imx_drm_driver_preclose(struct drm_device *drm,
180 struct drm_file *file)
181{
182 int i;
183
184 if (!file->is_master)
185 return;
186
942325c8
RK
187 for (i = 0; i < MAX_CRTC; i++)
188 imx_drm_disable_vblank(drm, i);
6ee4d7fe
SH
189}
190
e692da4d
SH
191static const struct file_operations imx_drm_driver_fops = {
192 .owner = THIS_MODULE,
193 .open = drm_open,
194 .release = drm_release,
195 .unlocked_ioctl = drm_ioctl,
196 .mmap = drm_gem_cma_mmap,
197 .poll = drm_poll,
e692da4d
SH
198 .read = drm_read,
199 .llseek = noop_llseek,
200};
201
8a51a33b
RK
202void imx_drm_connector_destroy(struct drm_connector *connector)
203{
34ea3d38 204 drm_connector_unregister(connector);
8a51a33b
RK
205 drm_connector_cleanup(connector);
206}
207EXPORT_SYMBOL_GPL(imx_drm_connector_destroy);
208
209void imx_drm_encoder_destroy(struct drm_encoder *encoder)
210{
211 drm_encoder_cleanup(encoder);
212}
213EXPORT_SYMBOL_GPL(imx_drm_encoder_destroy);
214
3e68439b
RK
215static void imx_drm_output_poll_changed(struct drm_device *drm)
216{
217#if IS_ENABLED(CONFIG_DRM_IMX_FB_HELPER)
218 struct imx_drm_device *imxdrm = drm->dev_private;
219
220 drm_fbdev_cma_hotplug_event(imxdrm->fbhelper);
221#endif
222}
223
1df8b530
RK
224static struct drm_mode_config_funcs imx_drm_mode_config_funcs = {
225 .fb_create = drm_fb_cma_create,
3e68439b 226 .output_poll_changed = imx_drm_output_poll_changed,
1df8b530
RK
227};
228
e692da4d 229/*
17b5001b
RK
230 * Main DRM initialisation. This binds, initialises and registers
231 * with DRM the subcomponents of the driver.
e692da4d
SH
232 */
233static int imx_drm_driver_load(struct drm_device *drm, unsigned long flags)
234{
b85f2b5d 235 struct imx_drm_device *imxdrm;
e355e7dd 236 struct drm_connector *connector;
e692da4d
SH
237 int ret;
238
b85f2b5d
RK
239 imxdrm = devm_kzalloc(drm->dev, sizeof(*imxdrm), GFP_KERNEL);
240 if (!imxdrm)
241 return -ENOMEM;
242
e692da4d
SH
243 imxdrm->drm = drm;
244
245 drm->dev_private = imxdrm;
246
247 /*
248 * enable drm irq mode.
4423843c 249 * - with irq_enabled = true, we can use the vblank feature.
e692da4d
SH
250 *
251 * P.S. note that we wouldn't use drm irq handler but
252 * just specific driver own one instead because
253 * drm framework supports only one irq handler and
254 * drivers can well take care of their interrupts
255 */
4423843c 256 drm->irq_enabled = true;
e692da4d 257
1df8b530
RK
258 /*
259 * set max width and height as default value(4096x4096).
260 * this value would be used to check framebuffer size limitation
261 * at drm_mode_addfb().
262 */
263 drm->mode_config.min_width = 64;
264 drm->mode_config.min_height = 64;
265 drm->mode_config.max_width = 4096;
266 drm->mode_config.max_height = 4096;
267 drm->mode_config.funcs = &imx_drm_mode_config_funcs;
268
e692da4d 269 drm_mode_config_init(drm);
e692da4d 270
020a9ea7 271 ret = drm_vblank_init(drm, MAX_CRTC);
e692da4d 272 if (ret)
8007875f 273 goto err_kms;
e692da4d
SH
274
275 /*
e7d6231e
RK
276 * with vblank_disable_allowed = true, vblank interrupt will be
277 * disabled by drm timer once a current process gives up ownership
278 * of vblank event. (after drm_vblank_put function is called)
e692da4d 279 */
020a9ea7 280 drm->vblank_disable_allowed = true;
e692da4d 281
a72f8bee 282 platform_set_drvdata(drm->platformdev, drm);
8d71de61 283
17b5001b
RK
284 /* Now try and bind all our sub-components */
285 ret = component_bind_all(drm->dev, drm);
286 if (ret)
ccec7f62 287 goto err_vblank;
e355e7dd
RK
288
289 /*
290 * All components are now added, we can publish the connector sysfs
291 * entries to userspace. This will generate hotplug events and so
292 * userspace will expect to be able to access DRM at this point.
293 */
294 list_for_each_entry(connector, &drm->mode_config.connector_list, head) {
34ea3d38 295 ret = drm_connector_register(connector);
e355e7dd
RK
296 if (ret) {
297 dev_err(drm->dev,
34ea3d38 298 "[CONNECTOR:%d:%s] drm_connector_register failed: %d\n",
e355e7dd 299 connector->base.id,
4a2a450f 300 connector->name, ret);
e355e7dd
RK
301 goto err_unbind;
302 }
303 }
304
8acba02f
RK
305 /*
306 * All components are now initialised, so setup the fb helper.
307 * The fb helper takes copies of key hardware information, so the
308 * crtcs/connectors/encoders must not change after this point.
309 */
310#if IS_ENABLED(CONFIG_DRM_IMX_FB_HELPER)
311 if (legacyfb_depth != 16 && legacyfb_depth != 32) {
312 dev_warn(drm->dev, "Invalid legacyfb_depth. Defaulting to 16bpp\n");
313 legacyfb_depth = 16;
314 }
315 imxdrm->fbhelper = drm_fbdev_cma_init(drm, legacyfb_depth,
316 drm->mode_config.num_crtc, MAX_CRTC);
317 if (IS_ERR(imxdrm->fbhelper)) {
318 ret = PTR_ERR(imxdrm->fbhelper);
319 imxdrm->fbhelper = NULL;
320 goto err_unbind;
321 }
322#endif
3e68439b
RK
323
324 drm_kms_helper_poll_init(drm);
325
8007875f 326 return 0;
a72f8bee 327
e355e7dd
RK
328err_unbind:
329 component_unbind_all(drm->dev, drm);
ccec7f62 330err_vblank:
8007875f
RK
331 drm_vblank_cleanup(drm);
332err_kms:
8007875f 333 drm_mode_config_cleanup(drm);
e692da4d
SH
334
335 return ret;
336}
337
e692da4d
SH
338/*
339 * imx_drm_add_crtc - add a new crtc
e692da4d 340 */
32266b45 341int imx_drm_add_crtc(struct drm_device *drm, struct drm_crtc *crtc,
43895599 342 struct imx_drm_crtc **new_crtc, struct drm_plane *primary_plane,
e692da4d 343 const struct imx_drm_crtc_helper_funcs *imx_drm_helper_funcs,
655b43cc 344 struct device_node *port)
e692da4d 345{
32266b45 346 struct imx_drm_device *imxdrm = drm->dev_private;
e692da4d 347 struct imx_drm_crtc *imx_drm_crtc;
e692da4d
SH
348 int ret;
349
fd6040ed
RK
350 /*
351 * The vblank arrays are dimensioned by MAX_CRTC - we can't
352 * pass IDs greater than this to those functions.
353 */
e7d6231e
RK
354 if (imxdrm->pipes >= MAX_CRTC)
355 return -EINVAL;
fd6040ed 356
e7d6231e
RK
357 if (imxdrm->drm->open_count)
358 return -EBUSY;
e692da4d
SH
359
360 imx_drm_crtc = kzalloc(sizeof(*imx_drm_crtc), GFP_KERNEL);
e7d6231e
RK
361 if (!imx_drm_crtc)
362 return -ENOMEM;
e692da4d
SH
363
364 imx_drm_crtc->imx_drm_helper_funcs = *imx_drm_helper_funcs;
365 imx_drm_crtc->pipe = imxdrm->pipes++;
e692da4d 366 imx_drm_crtc->crtc = crtc;
e692da4d 367
6457b971
RK
368 crtc->port = port;
369
887eceac 370 imxdrm->crtc[imx_drm_crtc->pipe] = imx_drm_crtc;
e692da4d
SH
371
372 *new_crtc = imx_drm_crtc;
373
ec9557d7 374 ret = drm_mode_crtc_set_gamma_size(imx_drm_crtc->crtc, 256);
e692da4d
SH
375 if (ret)
376 goto err_register;
377
ec9557d7
RK
378 drm_crtc_helper_add(crtc,
379 imx_drm_crtc->imx_drm_helper_funcs.crtc_helper_funcs);
380
43895599 381 drm_crtc_init_with_planes(drm, crtc, primary_plane, NULL,
ec9557d7
RK
382 imx_drm_crtc->imx_drm_helper_funcs.crtc_funcs);
383
e692da4d
SH
384 return 0;
385
386err_register:
887eceac 387 imxdrm->crtc[imx_drm_crtc->pipe] = NULL;
e692da4d 388 kfree(imx_drm_crtc);
e692da4d
SH
389 return ret;
390}
391EXPORT_SYMBOL_GPL(imx_drm_add_crtc);
392
393/*
394 * imx_drm_remove_crtc - remove a crtc
395 */
396int imx_drm_remove_crtc(struct imx_drm_crtc *imx_drm_crtc)
397{
ccec7f62 398 struct imx_drm_device *imxdrm = imx_drm_crtc->crtc->dev->dev_private;
e692da4d
SH
399
400 drm_crtc_cleanup(imx_drm_crtc->crtc);
401
887eceac 402 imxdrm->crtc[imx_drm_crtc->pipe] = NULL;
e692da4d 403
e692da4d
SH
404 kfree(imx_drm_crtc);
405
406 return 0;
407}
408EXPORT_SYMBOL_GPL(imx_drm_remove_crtc);
409
6457b971
RK
410int imx_drm_encoder_parse_of(struct drm_device *drm,
411 struct drm_encoder *encoder, struct device_node *np)
9e2d410d 412{
6457b971 413 uint32_t crtc_mask = drm_of_find_possible_crtcs(drm, np);
9e2d410d 414
6457b971
RK
415 /*
416 * If we failed to find the CRTC(s) which this encoder is
417 * supposed to be connected to, it's because the CRTC has
418 * not been registered yet. Defer probing, and hope that
419 * the required CRTC is added later.
420 */
421 if (crtc_mask == 0)
422 return -EPROBE_DEFER;
655b43cc 423
6457b971 424 encoder->possible_crtcs = crtc_mask;
63bc5164 425
6457b971
RK
426 /* FIXME: this is the mask of outputs which can clone this output. */
427 encoder->possible_clones = ~0;
9e2d410d
RK
428
429 return 0;
430}
6457b971 431EXPORT_SYMBOL_GPL(imx_drm_encoder_parse_of);
9e2d410d 432
655b43cc
PZ
433/*
434 * @node: device tree node containing encoder input ports
435 * @encoder: drm_encoder
436 */
437int imx_drm_encoder_get_mux_id(struct device_node *node,
438 struct drm_encoder *encoder)
e692da4d 439{
887eceac 440 struct imx_drm_crtc *imx_crtc = imx_drm_find_crtc(encoder->crtc);
539bb6a2 441 struct device_node *ep;
b6babdd9 442 struct of_endpoint endpoint;
655b43cc 443 struct device_node *port;
b6babdd9 444 int ret;
e692da4d 445
655b43cc
PZ
446 if (!node || !imx_crtc)
447 return -EINVAL;
448
539bb6a2 449 for_each_endpoint_of_node(node, ep) {
655b43cc
PZ
450 port = of_graph_get_remote_port(ep);
451 of_node_put(port);
6457b971 452 if (port == imx_crtc->crtc->port) {
b6babdd9 453 ret = of_graph_parse_endpoint(ep, &endpoint);
539bb6a2 454 of_node_put(ep);
c509bdc2 455 return ret ? ret : endpoint.port;
655b43cc 456 }
539bb6a2 457 }
e692da4d 458
655b43cc 459 return -EINVAL;
e692da4d 460}
ea8d1583 461EXPORT_SYMBOL_GPL(imx_drm_encoder_get_mux_id);
e692da4d 462
baa70943 463static const struct drm_ioctl_desc imx_drm_ioctls[] = {
e692da4d
SH
464 /* none so far */
465};
466
467static struct drm_driver imx_drm_driver = {
bd3665c9 468 .driver_features = DRIVER_MODESET | DRIVER_GEM | DRIVER_PRIME,
e692da4d
SH
469 .load = imx_drm_driver_load,
470 .unload = imx_drm_driver_unload,
e692da4d 471 .lastclose = imx_drm_driver_lastclose,
6ee4d7fe 472 .preclose = imx_drm_driver_preclose,
915b4d11 473 .set_busid = drm_platform_set_busid,
e692da4d
SH
474 .gem_free_object = drm_gem_cma_free_object,
475 .gem_vm_ops = &drm_gem_cma_vm_ops,
476 .dumb_create = drm_gem_cma_dumb_create,
477 .dumb_map_offset = drm_gem_cma_dumb_map_offset,
43387b37 478 .dumb_destroy = drm_gem_dumb_destroy,
e692da4d 479
bd3665c9
PZ
480 .prime_handle_to_fd = drm_gem_prime_handle_to_fd,
481 .prime_fd_to_handle = drm_gem_prime_fd_to_handle,
482 .gem_prime_import = drm_gem_prime_import,
483 .gem_prime_export = drm_gem_prime_export,
484 .gem_prime_get_sg_table = drm_gem_cma_prime_get_sg_table,
485 .gem_prime_import_sg_table = drm_gem_cma_prime_import_sg_table,
486 .gem_prime_vmap = drm_gem_cma_prime_vmap,
487 .gem_prime_vunmap = drm_gem_cma_prime_vunmap,
488 .gem_prime_mmap = drm_gem_cma_prime_mmap,
b44f8408 489 .get_vblank_counter = drm_vblank_no_hw_counter,
e692da4d
SH
490 .enable_vblank = imx_drm_enable_vblank,
491 .disable_vblank = imx_drm_disable_vblank,
492 .ioctls = imx_drm_ioctls,
493 .num_ioctls = ARRAY_SIZE(imx_drm_ioctls),
494 .fops = &imx_drm_driver_fops,
495 .name = "imx-drm",
496 .desc = "i.MX DRM graphics",
497 .date = "20120507",
498 .major = 1,
499 .minor = 0,
500 .patchlevel = 0,
501};
502
17b5001b
RK
503static int compare_of(struct device *dev, void *data)
504{
655b43cc 505 struct device_node *np = data;
17b5001b 506
655b43cc
PZ
507 /* Special case for LDB, one device for two channels */
508 if (of_node_cmp(np->name, "lvds-channel") == 0) {
509 np = of_get_parent(np);
510 of_node_put(np);
17b5001b
RK
511 }
512
655b43cc
PZ
513 return dev->of_node == np;
514}
17b5001b 515
17b5001b
RK
516static int imx_drm_bind(struct device *dev)
517{
518 return drm_platform_init(&imx_drm_driver, to_platform_device(dev));
519}
520
521static void imx_drm_unbind(struct device *dev)
522{
523 drm_put_dev(dev_get_drvdata(dev));
524}
525
526static const struct component_master_ops imx_drm_ops = {
17b5001b
RK
527 .bind = imx_drm_bind,
528 .unbind = imx_drm_unbind,
529};
530
e692da4d
SH
531static int imx_drm_platform_probe(struct platform_device *pdev)
532{
9cace32f 533 int ret = drm_of_component_probe(&pdev->dev, compare_of, &imx_drm_ops);
655b43cc 534
9cace32f
LD
535 if (!ret)
536 ret = dma_set_coherent_mask(&pdev->dev, DMA_BIT_MASK(32));
655b43cc 537
9cace32f 538 return ret;
e692da4d
SH
539}
540
541static int imx_drm_platform_remove(struct platform_device *pdev)
542{
17b5001b 543 component_master_del(&pdev->dev, &imx_drm_ops);
e692da4d
SH
544 return 0;
545}
546
bfe945c8
SG
547#ifdef CONFIG_PM_SLEEP
548static int imx_drm_suspend(struct device *dev)
549{
550 struct drm_device *drm_dev = dev_get_drvdata(dev);
551
552 /* The drm_dev is NULL before .load hook is called */
553 if (drm_dev == NULL)
554 return 0;
555
556 drm_kms_helper_poll_disable(drm_dev);
557
558 return 0;
559}
560
561static int imx_drm_resume(struct device *dev)
562{
563 struct drm_device *drm_dev = dev_get_drvdata(dev);
564
565 if (drm_dev == NULL)
566 return 0;
567
568 drm_helper_resume_force_mode(drm_dev);
569 drm_kms_helper_poll_enable(drm_dev);
570
571 return 0;
572}
573#endif
574
575static SIMPLE_DEV_PM_OPS(imx_drm_pm_ops, imx_drm_suspend, imx_drm_resume);
576
17b5001b 577static const struct of_device_id imx_drm_dt_ids[] = {
655b43cc 578 { .compatible = "fsl,imx-display-subsystem", },
17b5001b
RK
579 { /* sentinel */ },
580};
581MODULE_DEVICE_TABLE(of, imx_drm_dt_ids);
582
e692da4d
SH
583static struct platform_driver imx_drm_pdrv = {
584 .probe = imx_drm_platform_probe,
99c28f10 585 .remove = imx_drm_platform_remove,
e692da4d 586 .driver = {
e692da4d 587 .name = "imx-drm",
bfe945c8 588 .pm = &imx_drm_pm_ops,
17b5001b 589 .of_match_table = imx_drm_dt_ids,
e692da4d
SH
590 },
591};
b85f2b5d 592module_platform_driver(imx_drm_pdrv);
e692da4d
SH
593
594MODULE_AUTHOR("Sascha Hauer <s.hauer@pengutronix.de>");
595MODULE_DESCRIPTION("i.MX drm driver core");
596MODULE_LICENSE("GPL");