1 // SPDX-License-Identifier: GPL-2.0-only
2 /*
3 * Copyright (c) 2014-2018, The Linux Foundation. All rights reserved.
4 * Copyright (C) 2013 Red Hat
5 * Author: Rob Clark <robdclark@gmail.com>
6 */
7
8 #define pr_fmt(fmt) "[drm:%s:%d] " fmt, __func__, __LINE__
9
10 #include <linux/debugfs.h>
11 #include <linux/dma-buf.h>
12 #include <linux/of_irq.h>
13 #include <linux/pm_opp.h>
14
15 #include <drm/drm_crtc.h>
16 #include <drm/drm_file.h>
17
18 #include "msm_drv.h"
19 #include "msm_mmu.h"
20 #include "msm_gem.h"
21
22 #include "dpu_kms.h"
23 #include "dpu_core_irq.h"
24 #include "dpu_formats.h"
25 #include "dpu_hw_vbif.h"
26 #include "dpu_vbif.h"
27 #include "dpu_encoder.h"
28 #include "dpu_plane.h"
29 #include "dpu_crtc.h"
30
31 #define CREATE_TRACE_POINTS
32 #include "dpu_trace.h"
33
34 /*
35 * To enable overall DRM driver logging
36 * # echo 0x2 > /sys/module/drm/parameters/debug
37 *
38 * To enable DRM driver h/w logging
39 * # echo <mask> > /sys/kernel/debug/dri/0/debug/hw_log_mask
40 *
41 * See dpu_hw_mdss.h for h/w logging mask definitions (search for DPU_DBG_MASK_)
42 */
43 #define DPU_DEBUGFS_DIR "msm_dpu"
44 #define DPU_DEBUGFS_HWMASKNAME "hw_log_mask"
45
46 static int dpu_kms_hw_init(struct msm_kms *kms);
47 static void _dpu_kms_mmu_destroy(struct dpu_kms *dpu_kms);
48
49 #ifdef CONFIG_DEBUG_FS
_dpu_danger_signal_status(struct seq_file * s,bool danger_status)50 static int _dpu_danger_signal_status(struct seq_file *s,
51 bool danger_status)
52 {
53 struct dpu_kms *kms = (struct dpu_kms *)s->private;
54 struct dpu_danger_safe_status status;
55 int i;
56
57 if (!kms->hw_mdp) {
58 DPU_ERROR("invalid arg(s)\n");
59 return 0;
60 }
61
62 memset(&status, 0, sizeof(struct dpu_danger_safe_status));
63
64 pm_runtime_get_sync(&kms->pdev->dev);
65 if (danger_status) {
66 seq_puts(s, "\nDanger signal status:\n");
67 if (kms->hw_mdp->ops.get_danger_status)
68 kms->hw_mdp->ops.get_danger_status(kms->hw_mdp,
69 &status);
70 } else {
71 seq_puts(s, "\nSafe signal status:\n");
72 if (kms->hw_mdp->ops.get_danger_status)
73 kms->hw_mdp->ops.get_danger_status(kms->hw_mdp,
74 &status);
75 }
76 pm_runtime_put_sync(&kms->pdev->dev);
77
78 seq_printf(s, "MDP : 0x%x\n", status.mdp);
79
80 for (i = SSPP_VIG0; i < SSPP_MAX; i++)
81 seq_printf(s, "SSPP%d : 0x%x \t", i - SSPP_VIG0,
82 status.sspp[i]);
83 seq_puts(s, "\n");
84
85 return 0;
86 }
87
dpu_debugfs_danger_stats_show(struct seq_file * s,void * v)88 static int dpu_debugfs_danger_stats_show(struct seq_file *s, void *v)
89 {
90 return _dpu_danger_signal_status(s, true);
91 }
92 DEFINE_SHOW_ATTRIBUTE(dpu_debugfs_danger_stats);
93
dpu_debugfs_safe_stats_show(struct seq_file * s,void * v)94 static int dpu_debugfs_safe_stats_show(struct seq_file *s, void *v)
95 {
96 return _dpu_danger_signal_status(s, false);
97 }
98 DEFINE_SHOW_ATTRIBUTE(dpu_debugfs_safe_stats);
99
dpu_debugfs_danger_init(struct dpu_kms * dpu_kms,struct dentry * parent)100 static void dpu_debugfs_danger_init(struct dpu_kms *dpu_kms,
101 struct dentry *parent)
102 {
103 struct dentry *entry = debugfs_create_dir("danger", parent);
104
105 debugfs_create_file("danger_status", 0600, entry,
106 dpu_kms, &dpu_debugfs_danger_stats_fops);
107 debugfs_create_file("safe_status", 0600, entry,
108 dpu_kms, &dpu_debugfs_safe_stats_fops);
109 }
110
_dpu_debugfs_show_regset32(struct seq_file * s,void * data)111 static int _dpu_debugfs_show_regset32(struct seq_file *s, void *data)
112 {
113 struct dpu_debugfs_regset32 *regset = s->private;
114 struct dpu_kms *dpu_kms = regset->dpu_kms;
115 void __iomem *base;
116 uint32_t i, addr;
117
118 if (!dpu_kms->mmio)
119 return 0;
120
121 base = dpu_kms->mmio + regset->offset;
122
123 /* insert padding spaces, if needed */
124 if (regset->offset & 0xF) {
125 seq_printf(s, "[%x]", regset->offset & ~0xF);
126 for (i = 0; i < (regset->offset & 0xF); i += 4)
127 seq_puts(s, " ");
128 }
129
130 pm_runtime_get_sync(&dpu_kms->pdev->dev);
131
132 /* main register output */
133 for (i = 0; i < regset->blk_len; i += 4) {
134 addr = regset->offset + i;
135 if ((addr & 0xF) == 0x0)
136 seq_printf(s, i ? "\n[%x]" : "[%x]", addr);
137 seq_printf(s, " %08x", readl_relaxed(base + i));
138 }
139 seq_puts(s, "\n");
140 pm_runtime_put_sync(&dpu_kms->pdev->dev);
141
142 return 0;
143 }
144
dpu_debugfs_open_regset32(struct inode * inode,struct file * file)145 static int dpu_debugfs_open_regset32(struct inode *inode,
146 struct file *file)
147 {
148 return single_open(file, _dpu_debugfs_show_regset32, inode->i_private);
149 }
150
151 static const struct file_operations dpu_fops_regset32 = {
152 .open = dpu_debugfs_open_regset32,
153 .read = seq_read,
154 .llseek = seq_lseek,
155 .release = single_release,
156 };
157
dpu_debugfs_setup_regset32(struct dpu_debugfs_regset32 * regset,uint32_t offset,uint32_t length,struct dpu_kms * dpu_kms)158 void dpu_debugfs_setup_regset32(struct dpu_debugfs_regset32 *regset,
159 uint32_t offset, uint32_t length, struct dpu_kms *dpu_kms)
160 {
161 if (regset) {
162 regset->offset = offset;
163 regset->blk_len = length;
164 regset->dpu_kms = dpu_kms;
165 }
166 }
167
dpu_debugfs_create_regset32(const char * name,umode_t mode,void * parent,struct dpu_debugfs_regset32 * regset)168 void dpu_debugfs_create_regset32(const char *name, umode_t mode,
169 void *parent, struct dpu_debugfs_regset32 *regset)
170 {
171 if (!name || !regset || !regset->dpu_kms || !regset->blk_len)
172 return;
173
174 /* make sure offset is a multiple of 4 */
175 regset->offset = round_down(regset->offset, 4);
176
177 debugfs_create_file(name, mode, parent, regset, &dpu_fops_regset32);
178 }
179
dpu_kms_debugfs_init(struct msm_kms * kms,struct drm_minor * minor)180 static int dpu_kms_debugfs_init(struct msm_kms *kms, struct drm_minor *minor)
181 {
182 struct dpu_kms *dpu_kms = to_dpu_kms(kms);
183 void *p = dpu_hw_util_get_log_mask_ptr();
184 struct dentry *entry;
185 struct drm_device *dev;
186 struct msm_drm_private *priv;
187
188 if (!p)
189 return -EINVAL;
190
191 dev = dpu_kms->dev;
192 priv = dev->dev_private;
193
194 entry = debugfs_create_dir("debug", minor->debugfs_root);
195
196 debugfs_create_x32(DPU_DEBUGFS_HWMASKNAME, 0600, entry, p);
197
198 dpu_debugfs_danger_init(dpu_kms, entry);
199 dpu_debugfs_vbif_init(dpu_kms, entry);
200 dpu_debugfs_core_irq_init(dpu_kms, entry);
201
202 if (priv->dp)
203 msm_dp_debugfs_init(priv->dp, minor);
204
205 return dpu_core_perf_debugfs_init(dpu_kms, entry);
206 }
207 #endif
208
209 /* Global/shared object state funcs */
210
211 /*
212 * This is a helper that returns the private state currently in operation.
213 * Note that this would return the "old_state" if called in the atomic check
214 * path, and the "new_state" after the atomic swap has been done.
215 */
216 struct dpu_global_state *
dpu_kms_get_existing_global_state(struct dpu_kms * dpu_kms)217 dpu_kms_get_existing_global_state(struct dpu_kms *dpu_kms)
218 {
219 return to_dpu_global_state(dpu_kms->global_state.state);
220 }
221
222 /*
223 * This acquires the modeset lock set aside for global state, creates
224 * a new duplicated private object state.
225 */
dpu_kms_get_global_state(struct drm_atomic_state * s)226 struct dpu_global_state *dpu_kms_get_global_state(struct drm_atomic_state *s)
227 {
228 struct msm_drm_private *priv = s->dev->dev_private;
229 struct dpu_kms *dpu_kms = to_dpu_kms(priv->kms);
230 struct drm_private_state *priv_state;
231 int ret;
232
233 ret = drm_modeset_lock(&dpu_kms->global_state_lock, s->acquire_ctx);
234 if (ret)
235 return ERR_PTR(ret);
236
237 priv_state = drm_atomic_get_private_obj_state(s,
238 &dpu_kms->global_state);
239 if (IS_ERR(priv_state))
240 return ERR_CAST(priv_state);
241
242 return to_dpu_global_state(priv_state);
243 }
244
245 static struct drm_private_state *
dpu_kms_global_duplicate_state(struct drm_private_obj * obj)246 dpu_kms_global_duplicate_state(struct drm_private_obj *obj)
247 {
248 struct dpu_global_state *state;
249
250 state = kmemdup(obj->state, sizeof(*state), GFP_KERNEL);
251 if (!state)
252 return NULL;
253
254 __drm_atomic_helper_private_obj_duplicate_state(obj, &state->base);
255
256 return &state->base;
257 }
258
dpu_kms_global_destroy_state(struct drm_private_obj * obj,struct drm_private_state * state)259 static void dpu_kms_global_destroy_state(struct drm_private_obj *obj,
260 struct drm_private_state *state)
261 {
262 struct dpu_global_state *dpu_state = to_dpu_global_state(state);
263
264 kfree(dpu_state);
265 }
266
267 static const struct drm_private_state_funcs dpu_kms_global_state_funcs = {
268 .atomic_duplicate_state = dpu_kms_global_duplicate_state,
269 .atomic_destroy_state = dpu_kms_global_destroy_state,
270 };
271
dpu_kms_global_obj_init(struct dpu_kms * dpu_kms)272 static int dpu_kms_global_obj_init(struct dpu_kms *dpu_kms)
273 {
274 struct dpu_global_state *state;
275
276 drm_modeset_lock_init(&dpu_kms->global_state_lock);
277
278 state = kzalloc(sizeof(*state), GFP_KERNEL);
279 if (!state)
280 return -ENOMEM;
281
282 drm_atomic_private_obj_init(dpu_kms->dev, &dpu_kms->global_state,
283 &state->base,
284 &dpu_kms_global_state_funcs);
285 return 0;
286 }
287
dpu_kms_parse_data_bus_icc_path(struct dpu_kms * dpu_kms)288 static int dpu_kms_parse_data_bus_icc_path(struct dpu_kms *dpu_kms)
289 {
290 struct icc_path *path0;
291 struct icc_path *path1;
292 struct drm_device *dev = dpu_kms->dev;
293
294 path0 = of_icc_get(dev->dev, "mdp0-mem");
295 path1 = of_icc_get(dev->dev, "mdp1-mem");
296
297 if (IS_ERR_OR_NULL(path0))
298 return PTR_ERR_OR_ZERO(path0);
299
300 dpu_kms->path[0] = path0;
301 dpu_kms->num_paths = 1;
302
303 if (!IS_ERR_OR_NULL(path1)) {
304 dpu_kms->path[1] = path1;
305 dpu_kms->num_paths++;
306 }
307 return 0;
308 }
309
dpu_kms_enable_vblank(struct msm_kms * kms,struct drm_crtc * crtc)310 static int dpu_kms_enable_vblank(struct msm_kms *kms, struct drm_crtc *crtc)
311 {
312 return dpu_crtc_vblank(crtc, true);
313 }
314
dpu_kms_disable_vblank(struct msm_kms * kms,struct drm_crtc * crtc)315 static void dpu_kms_disable_vblank(struct msm_kms *kms, struct drm_crtc *crtc)
316 {
317 dpu_crtc_vblank(crtc, false);
318 }
319
dpu_kms_enable_commit(struct msm_kms * kms)320 static void dpu_kms_enable_commit(struct msm_kms *kms)
321 {
322 struct dpu_kms *dpu_kms = to_dpu_kms(kms);
323 pm_runtime_get_sync(&dpu_kms->pdev->dev);
324 }
325
dpu_kms_disable_commit(struct msm_kms * kms)326 static void dpu_kms_disable_commit(struct msm_kms *kms)
327 {
328 struct dpu_kms *dpu_kms = to_dpu_kms(kms);
329 pm_runtime_put_sync(&dpu_kms->pdev->dev);
330 }
331
dpu_kms_vsync_time(struct msm_kms * kms,struct drm_crtc * crtc)332 static ktime_t dpu_kms_vsync_time(struct msm_kms *kms, struct drm_crtc *crtc)
333 {
334 struct drm_encoder *encoder;
335
336 drm_for_each_encoder_mask(encoder, crtc->dev, crtc->state->encoder_mask) {
337 ktime_t vsync_time;
338
339 if (dpu_encoder_vsync_time(encoder, &vsync_time) == 0)
340 return vsync_time;
341 }
342
343 return ktime_get();
344 }
345
dpu_kms_prepare_commit(struct msm_kms * kms,struct drm_atomic_state * state)346 static void dpu_kms_prepare_commit(struct msm_kms *kms,
347 struct drm_atomic_state *state)
348 {
349 struct drm_crtc *crtc;
350 struct drm_crtc_state *crtc_state;
351 struct drm_encoder *encoder;
352 int i;
353
354 if (!kms)
355 return;
356
357 /* Call prepare_commit for all affected encoders */
358 for_each_new_crtc_in_state(state, crtc, crtc_state, i) {
359 drm_for_each_encoder_mask(encoder, crtc->dev,
360 crtc_state->encoder_mask) {
361 dpu_encoder_prepare_commit(encoder);
362 }
363 }
364 }
365
dpu_kms_flush_commit(struct msm_kms * kms,unsigned crtc_mask)366 static void dpu_kms_flush_commit(struct msm_kms *kms, unsigned crtc_mask)
367 {
368 struct dpu_kms *dpu_kms = to_dpu_kms(kms);
369 struct drm_crtc *crtc;
370
371 for_each_crtc_mask(dpu_kms->dev, crtc, crtc_mask) {
372 if (!crtc->state->active)
373 continue;
374
375 trace_dpu_kms_commit(DRMID(crtc));
376 dpu_crtc_commit_kickoff(crtc);
377 }
378 }
379
380 /*
381 * Override the encoder enable since we need to setup the inline rotator and do
382 * some crtc magic before enabling any bridge that might be present.
383 */
dpu_kms_encoder_enable(struct drm_encoder * encoder)384 void dpu_kms_encoder_enable(struct drm_encoder *encoder)
385 {
386 const struct drm_encoder_helper_funcs *funcs = encoder->helper_private;
387 struct drm_device *dev = encoder->dev;
388 struct drm_crtc *crtc;
389
390 /* Forward this enable call to the commit hook */
391 if (funcs && funcs->commit)
392 funcs->commit(encoder);
393
394 drm_for_each_crtc(crtc, dev) {
395 if (!(crtc->state->encoder_mask & drm_encoder_mask(encoder)))
396 continue;
397
398 trace_dpu_kms_enc_enable(DRMID(crtc));
399 }
400 }
401
dpu_kms_complete_commit(struct msm_kms * kms,unsigned crtc_mask)402 static void dpu_kms_complete_commit(struct msm_kms *kms, unsigned crtc_mask)
403 {
404 struct dpu_kms *dpu_kms = to_dpu_kms(kms);
405 struct drm_crtc *crtc;
406
407 DPU_ATRACE_BEGIN("kms_complete_commit");
408
409 for_each_crtc_mask(dpu_kms->dev, crtc, crtc_mask)
410 dpu_crtc_complete_commit(crtc);
411
412 DPU_ATRACE_END("kms_complete_commit");
413 }
414
dpu_kms_wait_for_commit_done(struct msm_kms * kms,struct drm_crtc * crtc)415 static void dpu_kms_wait_for_commit_done(struct msm_kms *kms,
416 struct drm_crtc *crtc)
417 {
418 struct drm_encoder *encoder;
419 struct drm_device *dev;
420 int ret;
421
422 if (!kms || !crtc || !crtc->state) {
423 DPU_ERROR("invalid params\n");
424 return;
425 }
426
427 dev = crtc->dev;
428
429 if (!crtc->state->enable) {
430 DPU_DEBUG("[crtc:%d] not enable\n", crtc->base.id);
431 return;
432 }
433
434 if (!crtc->state->active) {
435 DPU_DEBUG("[crtc:%d] not active\n", crtc->base.id);
436 return;
437 }
438
439 list_for_each_entry(encoder, &dev->mode_config.encoder_list, head) {
440 if (encoder->crtc != crtc)
441 continue;
442 /*
443 * Wait for post-flush if necessary to delay before
444 * plane_cleanup. For example, wait for vsync in case of video
445 * mode panels. This may be a no-op for command mode panels.
446 */
447 trace_dpu_kms_wait_for_commit_done(DRMID(crtc));
448 ret = dpu_encoder_wait_for_event(encoder, MSM_ENC_COMMIT_DONE);
449 if (ret && ret != -EWOULDBLOCK) {
450 DPU_ERROR("wait for commit done returned %d\n", ret);
451 break;
452 }
453 }
454 }
455
dpu_kms_wait_flush(struct msm_kms * kms,unsigned crtc_mask)456 static void dpu_kms_wait_flush(struct msm_kms *kms, unsigned crtc_mask)
457 {
458 struct dpu_kms *dpu_kms = to_dpu_kms(kms);
459 struct drm_crtc *crtc;
460
461 for_each_crtc_mask(dpu_kms->dev, crtc, crtc_mask)
462 dpu_kms_wait_for_commit_done(kms, crtc);
463 }
464
_dpu_kms_initialize_dsi(struct drm_device * dev,struct msm_drm_private * priv,struct dpu_kms * dpu_kms)465 static int _dpu_kms_initialize_dsi(struct drm_device *dev,
466 struct msm_drm_private *priv,
467 struct dpu_kms *dpu_kms)
468 {
469 struct drm_encoder *encoder = NULL;
470 int i, rc = 0;
471
472 if (!(priv->dsi[0] || priv->dsi[1]))
473 return rc;
474
475 /*TODO: Support two independent DSI connectors */
476 encoder = dpu_encoder_init(dev, DRM_MODE_ENCODER_DSI);
477 if (IS_ERR(encoder)) {
478 DPU_ERROR("encoder init failed for dsi display\n");
479 return PTR_ERR(encoder);
480 }
481
482 priv->encoders[priv->num_encoders++] = encoder;
483
484 for (i = 0; i < ARRAY_SIZE(priv->dsi); i++) {
485 if (!priv->dsi[i])
486 continue;
487
488 rc = msm_dsi_modeset_init(priv->dsi[i], dev, encoder);
489 if (rc) {
490 DPU_ERROR("modeset_init failed for dsi[%d], rc = %d\n",
491 i, rc);
492 break;
493 }
494 }
495
496 return rc;
497 }
498
_dpu_kms_initialize_displayport(struct drm_device * dev,struct msm_drm_private * priv,struct dpu_kms * dpu_kms)499 static int _dpu_kms_initialize_displayport(struct drm_device *dev,
500 struct msm_drm_private *priv,
501 struct dpu_kms *dpu_kms)
502 {
503 struct drm_encoder *encoder = NULL;
504 int rc = 0;
505
506 if (!priv->dp)
507 return rc;
508
509 encoder = dpu_encoder_init(dev, DRM_MODE_ENCODER_TMDS);
510 if (IS_ERR(encoder)) {
511 DPU_ERROR("encoder init failed for dsi display\n");
512 return PTR_ERR(encoder);
513 }
514
515 rc = msm_dp_modeset_init(priv->dp, dev, encoder);
516 if (rc) {
517 DPU_ERROR("modeset_init failed for DP, rc = %d\n", rc);
518 drm_encoder_cleanup(encoder);
519 return rc;
520 }
521
522 priv->encoders[priv->num_encoders++] = encoder;
523 return rc;
524 }
525
526 /**
527 * _dpu_kms_setup_displays - create encoders, bridges and connectors
528 * for underlying displays
529 * @dev: Pointer to drm device structure
530 * @priv: Pointer to private drm device data
531 * @dpu_kms: Pointer to dpu kms structure
532 * Returns: Zero on success
533 */
_dpu_kms_setup_displays(struct drm_device * dev,struct msm_drm_private * priv,struct dpu_kms * dpu_kms)534 static int _dpu_kms_setup_displays(struct drm_device *dev,
535 struct msm_drm_private *priv,
536 struct dpu_kms *dpu_kms)
537 {
538 int rc = 0;
539
540 rc = _dpu_kms_initialize_dsi(dev, priv, dpu_kms);
541 if (rc) {
542 DPU_ERROR("initialize_dsi failed, rc = %d\n", rc);
543 return rc;
544 }
545
546 rc = _dpu_kms_initialize_displayport(dev, priv, dpu_kms);
547 if (rc) {
548 DPU_ERROR("initialize_DP failed, rc = %d\n", rc);
549 return rc;
550 }
551
552 return rc;
553 }
554
_dpu_kms_drm_obj_destroy(struct dpu_kms * dpu_kms)555 static void _dpu_kms_drm_obj_destroy(struct dpu_kms *dpu_kms)
556 {
557 struct msm_drm_private *priv;
558 int i;
559
560 priv = dpu_kms->dev->dev_private;
561
562 for (i = 0; i < priv->num_crtcs; i++)
563 priv->crtcs[i]->funcs->destroy(priv->crtcs[i]);
564 priv->num_crtcs = 0;
565
566 for (i = 0; i < priv->num_planes; i++)
567 priv->planes[i]->funcs->destroy(priv->planes[i]);
568 priv->num_planes = 0;
569
570 for (i = 0; i < priv->num_connectors; i++)
571 priv->connectors[i]->funcs->destroy(priv->connectors[i]);
572 priv->num_connectors = 0;
573
574 for (i = 0; i < priv->num_encoders; i++)
575 priv->encoders[i]->funcs->destroy(priv->encoders[i]);
576 priv->num_encoders = 0;
577 }
578
_dpu_kms_drm_obj_init(struct dpu_kms * dpu_kms)579 static int _dpu_kms_drm_obj_init(struct dpu_kms *dpu_kms)
580 {
581 struct drm_device *dev;
582 struct drm_plane *primary_planes[MAX_PLANES], *plane;
583 struct drm_plane *cursor_planes[MAX_PLANES] = { NULL };
584 struct drm_crtc *crtc;
585
586 struct msm_drm_private *priv;
587 struct dpu_mdss_cfg *catalog;
588
589 int primary_planes_idx = 0, cursor_planes_idx = 0, i, ret;
590 int max_crtc_count;
591 dev = dpu_kms->dev;
592 priv = dev->dev_private;
593 catalog = dpu_kms->catalog;
594
595 /*
596 * Create encoder and query display drivers to create
597 * bridges and connectors
598 */
599 ret = _dpu_kms_setup_displays(dev, priv, dpu_kms);
600 if (ret)
601 goto fail;
602
603 max_crtc_count = min(catalog->mixer_count, priv->num_encoders);
604
605 /* Create the planes, keeping track of one primary/cursor per crtc */
606 for (i = 0; i < catalog->sspp_count; i++) {
607 enum drm_plane_type type;
608
609 if ((catalog->sspp[i].features & BIT(DPU_SSPP_CURSOR))
610 && cursor_planes_idx < max_crtc_count)
611 type = DRM_PLANE_TYPE_CURSOR;
612 else if (primary_planes_idx < max_crtc_count)
613 type = DRM_PLANE_TYPE_PRIMARY;
614 else
615 type = DRM_PLANE_TYPE_OVERLAY;
616
617 DPU_DEBUG("Create plane type %d with features %lx (cur %lx)\n",
618 type, catalog->sspp[i].features,
619 catalog->sspp[i].features & BIT(DPU_SSPP_CURSOR));
620
621 plane = dpu_plane_init(dev, catalog->sspp[i].id, type,
622 (1UL << max_crtc_count) - 1, 0);
623 if (IS_ERR(plane)) {
624 DPU_ERROR("dpu_plane_init failed\n");
625 ret = PTR_ERR(plane);
626 goto fail;
627 }
628 priv->planes[priv->num_planes++] = plane;
629
630 if (type == DRM_PLANE_TYPE_CURSOR)
631 cursor_planes[cursor_planes_idx++] = plane;
632 else if (type == DRM_PLANE_TYPE_PRIMARY)
633 primary_planes[primary_planes_idx++] = plane;
634 }
635
636 max_crtc_count = min(max_crtc_count, primary_planes_idx);
637
638 /* Create one CRTC per encoder */
639 for (i = 0; i < max_crtc_count; i++) {
640 crtc = dpu_crtc_init(dev, primary_planes[i], cursor_planes[i]);
641 if (IS_ERR(crtc)) {
642 ret = PTR_ERR(crtc);
643 goto fail;
644 }
645 priv->crtcs[priv->num_crtcs++] = crtc;
646 }
647
648 /* All CRTCs are compatible with all encoders */
649 for (i = 0; i < priv->num_encoders; i++)
650 priv->encoders[i]->possible_crtcs = (1 << priv->num_crtcs) - 1;
651
652 return 0;
653 fail:
654 _dpu_kms_drm_obj_destroy(dpu_kms);
655 return ret;
656 }
657
dpu_kms_round_pixclk(struct msm_kms * kms,unsigned long rate,struct drm_encoder * encoder)658 static long dpu_kms_round_pixclk(struct msm_kms *kms, unsigned long rate,
659 struct drm_encoder *encoder)
660 {
661 return rate;
662 }
663
_dpu_kms_hw_destroy(struct dpu_kms * dpu_kms)664 static void _dpu_kms_hw_destroy(struct dpu_kms *dpu_kms)
665 {
666 int i;
667
668 if (dpu_kms->hw_intr)
669 dpu_hw_intr_destroy(dpu_kms->hw_intr);
670 dpu_kms->hw_intr = NULL;
671
672 /* safe to call these more than once during shutdown */
673 _dpu_kms_mmu_destroy(dpu_kms);
674
675 if (dpu_kms->catalog) {
676 for (i = 0; i < dpu_kms->catalog->vbif_count; i++) {
677 u32 vbif_idx = dpu_kms->catalog->vbif[i].id;
678
679 if ((vbif_idx < VBIF_MAX) && dpu_kms->hw_vbif[vbif_idx])
680 dpu_hw_vbif_destroy(dpu_kms->hw_vbif[vbif_idx]);
681 }
682 }
683
684 if (dpu_kms->rm_init)
685 dpu_rm_destroy(&dpu_kms->rm);
686 dpu_kms->rm_init = false;
687
688 if (dpu_kms->catalog)
689 dpu_hw_catalog_deinit(dpu_kms->catalog);
690 dpu_kms->catalog = NULL;
691
692 if (dpu_kms->vbif[VBIF_NRT])
693 devm_iounmap(&dpu_kms->pdev->dev, dpu_kms->vbif[VBIF_NRT]);
694 dpu_kms->vbif[VBIF_NRT] = NULL;
695
696 if (dpu_kms->vbif[VBIF_RT])
697 devm_iounmap(&dpu_kms->pdev->dev, dpu_kms->vbif[VBIF_RT]);
698 dpu_kms->vbif[VBIF_RT] = NULL;
699
700 if (dpu_kms->hw_mdp)
701 dpu_hw_mdp_destroy(dpu_kms->hw_mdp);
702 dpu_kms->hw_mdp = NULL;
703
704 if (dpu_kms->mmio)
705 devm_iounmap(&dpu_kms->pdev->dev, dpu_kms->mmio);
706 dpu_kms->mmio = NULL;
707 }
708
dpu_kms_destroy(struct msm_kms * kms)709 static void dpu_kms_destroy(struct msm_kms *kms)
710 {
711 struct dpu_kms *dpu_kms;
712
713 if (!kms) {
714 DPU_ERROR("invalid kms\n");
715 return;
716 }
717
718 dpu_kms = to_dpu_kms(kms);
719
720 _dpu_kms_hw_destroy(dpu_kms);
721 }
722
_dpu_kms_set_encoder_mode(struct msm_kms * kms,struct drm_encoder * encoder,bool cmd_mode)723 static void _dpu_kms_set_encoder_mode(struct msm_kms *kms,
724 struct drm_encoder *encoder,
725 bool cmd_mode)
726 {
727 struct msm_display_info info;
728 struct msm_drm_private *priv = encoder->dev->dev_private;
729 int i, rc = 0;
730
731 memset(&info, 0, sizeof(info));
732
733 info.intf_type = encoder->encoder_type;
734 info.capabilities = cmd_mode ? MSM_DISPLAY_CAP_CMD_MODE :
735 MSM_DISPLAY_CAP_VID_MODE;
736
737 switch (info.intf_type) {
738 case DRM_MODE_ENCODER_DSI:
739 /* TODO: No support for DSI swap */
740 for (i = 0; i < ARRAY_SIZE(priv->dsi); i++) {
741 if (priv->dsi[i]) {
742 info.h_tile_instance[info.num_of_h_tiles] = i;
743 info.num_of_h_tiles++;
744 }
745 }
746 break;
747 case DRM_MODE_ENCODER_TMDS:
748 info.num_of_h_tiles = 1;
749 break;
750 };
751
752 rc = dpu_encoder_setup(encoder->dev, encoder, &info);
753 if (rc)
754 DPU_ERROR("failed to setup DPU encoder %d: rc:%d\n",
755 encoder->base.id, rc);
756 }
757
dpu_irq(struct msm_kms * kms)758 static irqreturn_t dpu_irq(struct msm_kms *kms)
759 {
760 struct dpu_kms *dpu_kms = to_dpu_kms(kms);
761
762 return dpu_core_irq(dpu_kms);
763 }
764
dpu_irq_preinstall(struct msm_kms * kms)765 static void dpu_irq_preinstall(struct msm_kms *kms)
766 {
767 struct dpu_kms *dpu_kms = to_dpu_kms(kms);
768
769 dpu_core_irq_preinstall(dpu_kms);
770 }
771
dpu_irq_postinstall(struct msm_kms * kms)772 static int dpu_irq_postinstall(struct msm_kms *kms)
773 {
774 struct msm_drm_private *priv;
775 struct dpu_kms *dpu_kms = to_dpu_kms(kms);
776
777 if (!dpu_kms || !dpu_kms->dev)
778 return -EINVAL;
779
780 priv = dpu_kms->dev->dev_private;
781 if (!priv)
782 return -EINVAL;
783
784 msm_dp_irq_postinstall(priv->dp);
785
786 return 0;
787 }
788
dpu_irq_uninstall(struct msm_kms * kms)789 static void dpu_irq_uninstall(struct msm_kms *kms)
790 {
791 struct dpu_kms *dpu_kms = to_dpu_kms(kms);
792
793 dpu_core_irq_uninstall(dpu_kms);
794 }
795
796 static const struct msm_kms_funcs kms_funcs = {
797 .hw_init = dpu_kms_hw_init,
798 .irq_preinstall = dpu_irq_preinstall,
799 .irq_postinstall = dpu_irq_postinstall,
800 .irq_uninstall = dpu_irq_uninstall,
801 .irq = dpu_irq,
802 .enable_commit = dpu_kms_enable_commit,
803 .disable_commit = dpu_kms_disable_commit,
804 .vsync_time = dpu_kms_vsync_time,
805 .prepare_commit = dpu_kms_prepare_commit,
806 .flush_commit = dpu_kms_flush_commit,
807 .wait_flush = dpu_kms_wait_flush,
808 .complete_commit = dpu_kms_complete_commit,
809 .enable_vblank = dpu_kms_enable_vblank,
810 .disable_vblank = dpu_kms_disable_vblank,
811 .check_modified_format = dpu_format_check_modified_format,
812 .get_format = dpu_get_msm_format,
813 .round_pixclk = dpu_kms_round_pixclk,
814 .destroy = dpu_kms_destroy,
815 .set_encoder_mode = _dpu_kms_set_encoder_mode,
816 #ifdef CONFIG_DEBUG_FS
817 .debugfs_init = dpu_kms_debugfs_init,
818 #endif
819 };
820
_dpu_kms_mmu_destroy(struct dpu_kms * dpu_kms)821 static void _dpu_kms_mmu_destroy(struct dpu_kms *dpu_kms)
822 {
823 struct msm_mmu *mmu;
824
825 if (!dpu_kms->base.aspace)
826 return;
827
828 mmu = dpu_kms->base.aspace->mmu;
829
830 mmu->funcs->detach(mmu);
831 msm_gem_address_space_put(dpu_kms->base.aspace);
832
833 dpu_kms->base.aspace = NULL;
834 }
835
_dpu_kms_mmu_init(struct dpu_kms * dpu_kms)836 static int _dpu_kms_mmu_init(struct dpu_kms *dpu_kms)
837 {
838 struct iommu_domain *domain;
839 struct msm_gem_address_space *aspace;
840 struct msm_mmu *mmu;
841
842 domain = iommu_domain_alloc(&platform_bus_type);
843 if (!domain)
844 return 0;
845
846 mmu = msm_iommu_new(dpu_kms->dev->dev, domain);
847 aspace = msm_gem_address_space_create(mmu, "dpu1",
848 0x1000, 0x100000000 - 0x1000);
849
850 if (IS_ERR(aspace)) {
851 mmu->funcs->destroy(mmu);
852 return PTR_ERR(aspace);
853 }
854
855 dpu_kms->base.aspace = aspace;
856 return 0;
857 }
858
_dpu_kms_get_clk(struct dpu_kms * dpu_kms,char * clock_name)859 static struct dss_clk *_dpu_kms_get_clk(struct dpu_kms *dpu_kms,
860 char *clock_name)
861 {
862 struct dss_module_power *mp = &dpu_kms->mp;
863 int i;
864
865 for (i = 0; i < mp->num_clk; i++) {
866 if (!strcmp(mp->clk_config[i].clk_name, clock_name))
867 return &mp->clk_config[i];
868 }
869
870 return NULL;
871 }
872
dpu_kms_get_clk_rate(struct dpu_kms * dpu_kms,char * clock_name)873 u64 dpu_kms_get_clk_rate(struct dpu_kms *dpu_kms, char *clock_name)
874 {
875 struct dss_clk *clk;
876
877 clk = _dpu_kms_get_clk(dpu_kms, clock_name);
878 if (!clk)
879 return -EINVAL;
880
881 return clk_get_rate(clk->clk);
882 }
883
dpu_kms_hw_init(struct msm_kms * kms)884 static int dpu_kms_hw_init(struct msm_kms *kms)
885 {
886 struct dpu_kms *dpu_kms;
887 struct drm_device *dev;
888 int i, rc = -EINVAL;
889
890 if (!kms) {
891 DPU_ERROR("invalid kms\n");
892 return rc;
893 }
894
895 dpu_kms = to_dpu_kms(kms);
896 dev = dpu_kms->dev;
897
898 rc = dpu_kms_global_obj_init(dpu_kms);
899 if (rc)
900 return rc;
901
902 atomic_set(&dpu_kms->bandwidth_ref, 0);
903
904 dpu_kms->mmio = msm_ioremap(dpu_kms->pdev, "mdp", "mdp");
905 if (IS_ERR(dpu_kms->mmio)) {
906 rc = PTR_ERR(dpu_kms->mmio);
907 DPU_ERROR("mdp register memory map failed: %d\n", rc);
908 dpu_kms->mmio = NULL;
909 goto error;
910 }
911 DRM_DEBUG("mapped dpu address space @%pK\n", dpu_kms->mmio);
912
913 dpu_kms->vbif[VBIF_RT] = msm_ioremap(dpu_kms->pdev, "vbif", "vbif");
914 if (IS_ERR(dpu_kms->vbif[VBIF_RT])) {
915 rc = PTR_ERR(dpu_kms->vbif[VBIF_RT]);
916 DPU_ERROR("vbif register memory map failed: %d\n", rc);
917 dpu_kms->vbif[VBIF_RT] = NULL;
918 goto error;
919 }
920 dpu_kms->vbif[VBIF_NRT] = msm_ioremap_quiet(dpu_kms->pdev, "vbif_nrt", "vbif_nrt");
921 if (IS_ERR(dpu_kms->vbif[VBIF_NRT])) {
922 dpu_kms->vbif[VBIF_NRT] = NULL;
923 DPU_DEBUG("VBIF NRT is not defined");
924 }
925
926 dpu_kms->reg_dma = msm_ioremap_quiet(dpu_kms->pdev, "regdma", "regdma");
927 if (IS_ERR(dpu_kms->reg_dma)) {
928 dpu_kms->reg_dma = NULL;
929 DPU_DEBUG("REG_DMA is not defined");
930 }
931
932 pm_runtime_get_sync(&dpu_kms->pdev->dev);
933
934 dpu_kms->core_rev = readl_relaxed(dpu_kms->mmio + 0x0);
935
936 pr_info("dpu hardware revision:0x%x\n", dpu_kms->core_rev);
937
938 dpu_kms->catalog = dpu_hw_catalog_init(dpu_kms->core_rev);
939 if (IS_ERR_OR_NULL(dpu_kms->catalog)) {
940 rc = PTR_ERR(dpu_kms->catalog);
941 if (!dpu_kms->catalog)
942 rc = -EINVAL;
943 DPU_ERROR("catalog init failed: %d\n", rc);
944 dpu_kms->catalog = NULL;
945 goto power_error;
946 }
947
948 /*
949 * Now we need to read the HW catalog and initialize resources such as
950 * clocks, regulators, GDSC/MMAGIC, ioremap the register ranges etc
951 */
952 rc = _dpu_kms_mmu_init(dpu_kms);
953 if (rc) {
954 DPU_ERROR("dpu_kms_mmu_init failed: %d\n", rc);
955 goto power_error;
956 }
957
958 rc = dpu_rm_init(&dpu_kms->rm, dpu_kms->catalog, dpu_kms->mmio);
959 if (rc) {
960 DPU_ERROR("rm init failed: %d\n", rc);
961 goto power_error;
962 }
963
964 dpu_kms->rm_init = true;
965
966 dpu_kms->hw_mdp = dpu_hw_mdptop_init(MDP_TOP, dpu_kms->mmio,
967 dpu_kms->catalog);
968 if (IS_ERR(dpu_kms->hw_mdp)) {
969 rc = PTR_ERR(dpu_kms->hw_mdp);
970 DPU_ERROR("failed to get hw_mdp: %d\n", rc);
971 dpu_kms->hw_mdp = NULL;
972 goto power_error;
973 }
974
975 for (i = 0; i < dpu_kms->catalog->vbif_count; i++) {
976 u32 vbif_idx = dpu_kms->catalog->vbif[i].id;
977
978 dpu_kms->hw_vbif[i] = dpu_hw_vbif_init(vbif_idx,
979 dpu_kms->vbif[vbif_idx], dpu_kms->catalog);
980 if (IS_ERR_OR_NULL(dpu_kms->hw_vbif[vbif_idx])) {
981 rc = PTR_ERR(dpu_kms->hw_vbif[vbif_idx]);
982 if (!dpu_kms->hw_vbif[vbif_idx])
983 rc = -EINVAL;
984 DPU_ERROR("failed to init vbif %d: %d\n", vbif_idx, rc);
985 dpu_kms->hw_vbif[vbif_idx] = NULL;
986 goto power_error;
987 }
988 }
989
990 rc = dpu_core_perf_init(&dpu_kms->perf, dev, dpu_kms->catalog,
991 _dpu_kms_get_clk(dpu_kms, "core"));
992 if (rc) {
993 DPU_ERROR("failed to init perf %d\n", rc);
994 goto perf_err;
995 }
996
997 dpu_kms->hw_intr = dpu_hw_intr_init(dpu_kms->mmio, dpu_kms->catalog);
998 if (IS_ERR_OR_NULL(dpu_kms->hw_intr)) {
999 rc = PTR_ERR(dpu_kms->hw_intr);
1000 DPU_ERROR("hw_intr init failed: %d\n", rc);
1001 dpu_kms->hw_intr = NULL;
1002 goto hw_intr_init_err;
1003 }
1004
1005 dev->mode_config.min_width = 0;
1006 dev->mode_config.min_height = 0;
1007
1008 /*
1009 * max crtc width is equal to the max mixer width * 2 and max height is
1010 * is 4K
1011 */
1012 dev->mode_config.max_width =
1013 dpu_kms->catalog->caps->max_mixer_width * 2;
1014 dev->mode_config.max_height = 4096;
1015
1016 /*
1017 * Support format modifiers for compression etc.
1018 */
1019 dev->mode_config.allow_fb_modifiers = true;
1020
1021 /*
1022 * _dpu_kms_drm_obj_init should create the DRM related objects
1023 * i.e. CRTCs, planes, encoders, connectors and so forth
1024 */
1025 rc = _dpu_kms_drm_obj_init(dpu_kms);
1026 if (rc) {
1027 DPU_ERROR("modeset init failed: %d\n", rc);
1028 goto drm_obj_init_err;
1029 }
1030
1031 dpu_vbif_init_memtypes(dpu_kms);
1032
1033 if (of_device_is_compatible(dev->dev->of_node, "qcom,sc7180-mdss"))
1034 dpu_kms_parse_data_bus_icc_path(dpu_kms);
1035
1036 pm_runtime_put_sync(&dpu_kms->pdev->dev);
1037
1038 return 0;
1039
1040 drm_obj_init_err:
1041 dpu_core_perf_destroy(&dpu_kms->perf);
1042 hw_intr_init_err:
1043 perf_err:
1044 power_error:
1045 pm_runtime_put_sync(&dpu_kms->pdev->dev);
1046 error:
1047 _dpu_kms_hw_destroy(dpu_kms);
1048
1049 return rc;
1050 }
1051
dpu_kms_init(struct drm_device * dev)1052 struct msm_kms *dpu_kms_init(struct drm_device *dev)
1053 {
1054 struct msm_drm_private *priv;
1055 struct dpu_kms *dpu_kms;
1056 int irq;
1057
1058 if (!dev) {
1059 DPU_ERROR("drm device node invalid\n");
1060 return ERR_PTR(-EINVAL);
1061 }
1062
1063 priv = dev->dev_private;
1064 dpu_kms = to_dpu_kms(priv->kms);
1065
1066 irq = irq_of_parse_and_map(dpu_kms->pdev->dev.of_node, 0);
1067 if (irq < 0) {
1068 DPU_ERROR("failed to get irq: %d\n", irq);
1069 return ERR_PTR(irq);
1070 }
1071 dpu_kms->base.irq = irq;
1072
1073 return &dpu_kms->base;
1074 }
1075
dpu_bind(struct device * dev,struct device * master,void * data)1076 static int dpu_bind(struct device *dev, struct device *master, void *data)
1077 {
1078 struct drm_device *ddev = dev_get_drvdata(master);
1079 struct platform_device *pdev = to_platform_device(dev);
1080 struct msm_drm_private *priv = ddev->dev_private;
1081 struct dpu_kms *dpu_kms;
1082 struct dss_module_power *mp;
1083 int ret = 0;
1084
1085 dpu_kms = devm_kzalloc(&pdev->dev, sizeof(*dpu_kms), GFP_KERNEL);
1086 if (!dpu_kms)
1087 return -ENOMEM;
1088
1089 dpu_kms->opp_table = dev_pm_opp_set_clkname(dev, "core");
1090 if (IS_ERR(dpu_kms->opp_table))
1091 return PTR_ERR(dpu_kms->opp_table);
1092 /* OPP table is optional */
1093 ret = dev_pm_opp_of_add_table(dev);
1094 if (!ret) {
1095 dpu_kms->has_opp_table = true;
1096 } else if (ret != -ENODEV) {
1097 dev_err(dev, "invalid OPP table in device tree\n");
1098 dev_pm_opp_put_clkname(dpu_kms->opp_table);
1099 return ret;
1100 }
1101
1102 mp = &dpu_kms->mp;
1103 ret = msm_dss_parse_clock(pdev, mp);
1104 if (ret) {
1105 DPU_ERROR("failed to parse clocks, ret=%d\n", ret);
1106 goto err;
1107 }
1108
1109 platform_set_drvdata(pdev, dpu_kms);
1110
1111 msm_kms_init(&dpu_kms->base, &kms_funcs);
1112 dpu_kms->dev = ddev;
1113 dpu_kms->pdev = pdev;
1114
1115 pm_runtime_enable(&pdev->dev);
1116 dpu_kms->rpm_enabled = true;
1117
1118 priv->kms = &dpu_kms->base;
1119 return ret;
1120 err:
1121 if (dpu_kms->has_opp_table)
1122 dev_pm_opp_of_remove_table(dev);
1123 dev_pm_opp_put_clkname(dpu_kms->opp_table);
1124 return ret;
1125 }
1126
dpu_unbind(struct device * dev,struct device * master,void * data)1127 static void dpu_unbind(struct device *dev, struct device *master, void *data)
1128 {
1129 struct platform_device *pdev = to_platform_device(dev);
1130 struct dpu_kms *dpu_kms = platform_get_drvdata(pdev);
1131 struct dss_module_power *mp = &dpu_kms->mp;
1132
1133 msm_dss_put_clk(mp->clk_config, mp->num_clk);
1134 devm_kfree(&pdev->dev, mp->clk_config);
1135 mp->num_clk = 0;
1136
1137 if (dpu_kms->rpm_enabled)
1138 pm_runtime_disable(&pdev->dev);
1139
1140 if (dpu_kms->has_opp_table)
1141 dev_pm_opp_of_remove_table(dev);
1142 dev_pm_opp_put_clkname(dpu_kms->opp_table);
1143 }
1144
1145 static const struct component_ops dpu_ops = {
1146 .bind = dpu_bind,
1147 .unbind = dpu_unbind,
1148 };
1149
dpu_dev_probe(struct platform_device * pdev)1150 static int dpu_dev_probe(struct platform_device *pdev)
1151 {
1152 return component_add(&pdev->dev, &dpu_ops);
1153 }
1154
dpu_dev_remove(struct platform_device * pdev)1155 static int dpu_dev_remove(struct platform_device *pdev)
1156 {
1157 component_del(&pdev->dev, &dpu_ops);
1158 return 0;
1159 }
1160
dpu_runtime_suspend(struct device * dev)1161 static int __maybe_unused dpu_runtime_suspend(struct device *dev)
1162 {
1163 int i, rc = -1;
1164 struct platform_device *pdev = to_platform_device(dev);
1165 struct dpu_kms *dpu_kms = platform_get_drvdata(pdev);
1166 struct dss_module_power *mp = &dpu_kms->mp;
1167
1168 /* Drop the performance state vote */
1169 dev_pm_opp_set_rate(dev, 0);
1170 rc = msm_dss_enable_clk(mp->clk_config, mp->num_clk, false);
1171 if (rc)
1172 DPU_ERROR("clock disable failed rc:%d\n", rc);
1173
1174 for (i = 0; i < dpu_kms->num_paths; i++)
1175 icc_set_bw(dpu_kms->path[i], 0, 0);
1176
1177 return rc;
1178 }
1179
dpu_runtime_resume(struct device * dev)1180 static int __maybe_unused dpu_runtime_resume(struct device *dev)
1181 {
1182 int rc = -1;
1183 struct platform_device *pdev = to_platform_device(dev);
1184 struct dpu_kms *dpu_kms = platform_get_drvdata(pdev);
1185 struct drm_encoder *encoder;
1186 struct drm_device *ddev;
1187 struct dss_module_power *mp = &dpu_kms->mp;
1188 int i;
1189
1190 ddev = dpu_kms->dev;
1191
1192 /* Min vote of BW is required before turning on AXI clk */
1193 for (i = 0; i < dpu_kms->num_paths; i++)
1194 icc_set_bw(dpu_kms->path[i], 0,
1195 dpu_kms->catalog->perf.min_dram_ib);
1196
1197 rc = msm_dss_enable_clk(mp->clk_config, mp->num_clk, true);
1198 if (rc) {
1199 DPU_ERROR("clock enable failed rc:%d\n", rc);
1200 return rc;
1201 }
1202
1203 dpu_vbif_init_memtypes(dpu_kms);
1204
1205 drm_for_each_encoder(encoder, ddev)
1206 dpu_encoder_virt_runtime_resume(encoder);
1207
1208 return rc;
1209 }
1210
1211 static const struct dev_pm_ops dpu_pm_ops = {
1212 SET_RUNTIME_PM_OPS(dpu_runtime_suspend, dpu_runtime_resume, NULL)
1213 SET_SYSTEM_SLEEP_PM_OPS(pm_runtime_force_suspend,
1214 pm_runtime_force_resume)
1215 };
1216
1217 static const struct of_device_id dpu_dt_match[] = {
1218 { .compatible = "qcom,sdm845-dpu", },
1219 { .compatible = "qcom,sc7180-dpu", },
1220 {}
1221 };
1222 MODULE_DEVICE_TABLE(of, dpu_dt_match);
1223
1224 static struct platform_driver dpu_driver = {
1225 .probe = dpu_dev_probe,
1226 .remove = dpu_dev_remove,
1227 .driver = {
1228 .name = "msm_dpu",
1229 .of_match_table = dpu_dt_match,
1230 .pm = &dpu_pm_ops,
1231 },
1232 };
1233
msm_dpu_register(void)1234 void __init msm_dpu_register(void)
1235 {
1236 platform_driver_register(&dpu_driver);
1237 }
1238
msm_dpu_unregister(void)1239 void __exit msm_dpu_unregister(void)
1240 {
1241 platform_driver_unregister(&dpu_driver);
1242 }
1243