blob: bb9ee2c93eca00e8ef881ac5a787de8d8f298973 [file] [log] [blame]
Rob Clarkcd5351f2011-11-12 12:09:40 -06001/*
Andrew F. Davisbb5cdf82017-12-05 14:29:31 -06002 * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
Rob Clarkcd5351f2011-11-12 12:09:40 -06003 * Author: Rob Clark <rob@ti.com>
4 *
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 as published by
7 * the Free Software Foundation.
8 *
9 * This program is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
12 * more details.
13 *
14 * You should have received a copy of the GNU General Public License along with
15 * this program. If not, see <http://www.gnu.org/licenses/>.
16 */
17
Peter Ujfalusieb5bc1f2018-02-12 11:44:39 +020018#include <linux/of.h>
19#include <linux/sort.h>
Laurent Pinchart6e471fa2017-05-06 02:57:12 +030020#include <linux/sys_soc.h>
21
Laurent Pinchart748471a52015-03-05 23:42:39 +020022#include <drm/drm_atomic.h>
Laurent Pinchartcef77d42015-03-05 21:50:00 +020023#include <drm/drm_atomic_helper.h>
Laurent Pinchart2d278f52015-03-05 21:31:37 +020024#include <drm/drm_crtc_helper.h>
25#include <drm/drm_fb_helper.h>
Rob Clarkcd5351f2011-11-12 12:09:40 -060026
Andy Gross5c137792012-03-05 10:48:39 -060027#include "omap_dmm_tiler.h"
Laurent Pinchart2d278f52015-03-05 21:31:37 +020028#include "omap_drv.h"
Rob Clarkcd5351f2011-11-12 12:09:40 -060029
30#define DRIVER_NAME MODULE_NAME
31#define DRIVER_DESC "OMAP DRM"
32#define DRIVER_DATE "20110917"
33#define DRIVER_MAJOR 1
34#define DRIVER_MINOR 0
35#define DRIVER_PATCHLEVEL 0
36
Rob Clarkcd5351f2011-11-12 12:09:40 -060037/*
38 * mode config funcs
39 */
40
41/* Notes about mapping DSS and DRM entities:
42 * CRTC: overlay
43 * encoder: manager.. with some extension to allow one primary CRTC
44 * and zero or more video CRTC's to be mapped to one encoder?
45 * connector: dssdev.. manager can be attached/detached from different
46 * devices
47 */
48
Tomi Valkeinen5f741b32015-05-29 16:01:18 +030049static void omap_atomic_wait_for_completion(struct drm_device *dev,
50 struct drm_atomic_state *old_state)
51{
Maarten Lankhorst34d88232017-07-19 16:39:17 +020052 struct drm_crtc_state *new_crtc_state;
Tomi Valkeinen5f741b32015-05-29 16:01:18 +030053 struct drm_crtc *crtc;
54 unsigned int i;
55 int ret;
56
Maarten Lankhorst34d88232017-07-19 16:39:17 +020057 for_each_new_crtc_in_state(old_state, crtc, new_crtc_state, i) {
58 if (!new_crtc_state->active)
Tomi Valkeinen5f741b32015-05-29 16:01:18 +030059 continue;
60
61 ret = omap_crtc_wait_pending(crtc);
62
63 if (!ret)
64 dev_warn(dev->dev,
65 "atomic complete timeout (pipe %u)!\n", i);
66 }
67}
68
Laurent Pincharta9e6f9f2017-05-09 01:27:10 +030069static void omap_atomic_commit_tail(struct drm_atomic_state *old_state)
Laurent Pinchart748471a52015-03-05 23:42:39 +020070{
Laurent Pincharta9e6f9f2017-05-09 01:27:10 +030071 struct drm_device *dev = old_state->dev;
Laurent Pinchart748471a52015-03-05 23:42:39 +020072 struct omap_drm_private *priv = dev->dev_private;
Laurent Pinchart748471a52015-03-05 23:42:39 +020073
Laurent Pinchart50638ae2018-02-13 14:00:42 +020074 priv->dispc_ops->runtime_get(priv->dispc);
Laurent Pinchart69fb7c82015-05-28 02:09:56 +030075
Laurent Pincharta9e6f9f2017-05-09 01:27:10 +030076 /* Apply the atomic update. */
Laurent Pinchart748471a52015-03-05 23:42:39 +020077 drm_atomic_helper_commit_modeset_disables(dev, old_state);
Jyri Sarha897145d2017-01-27 12:04:55 +020078
Tomi Valkeinenfc5cc9672017-08-23 12:19:02 +030079 if (priv->omaprev != 0x3430) {
80 /* With the current dss dispc implementation we have to enable
81 * the new modeset before we can commit planes. The dispc ovl
82 * configuration relies on the video mode configuration been
83 * written into the HW when the ovl configuration is
84 * calculated.
85 *
86 * This approach is not ideal because after a mode change the
87 * plane update is executed only after the first vblank
88 * interrupt. The dispc implementation should be fixed so that
89 * it is able use uncommitted drm state information.
90 */
91 drm_atomic_helper_commit_modeset_enables(dev, old_state);
92 omap_atomic_wait_for_completion(dev, old_state);
Jyri Sarha897145d2017-01-27 12:04:55 +020093
Tomi Valkeinenfc5cc9672017-08-23 12:19:02 +030094 drm_atomic_helper_commit_planes(dev, old_state, 0);
Laurent Pinchart748471a52015-03-05 23:42:39 +020095
Tomi Valkeinenfc5cc9672017-08-23 12:19:02 +030096 drm_atomic_helper_commit_hw_done(old_state);
97 } else {
98 /*
99 * OMAP3 DSS seems to have issues with the work-around above,
100 * resulting in endless sync losts if a crtc is enabled without
101 * a plane. For now, skip the WA for OMAP3.
102 */
103 drm_atomic_helper_commit_planes(dev, old_state, 0);
104
105 drm_atomic_helper_commit_modeset_enables(dev, old_state);
106
107 drm_atomic_helper_commit_hw_done(old_state);
108 }
Laurent Pincharta9e6f9f2017-05-09 01:27:10 +0300109
110 /*
111 * Wait for completion of the page flips to ensure that old buffers
112 * can't be touched by the hardware anymore before cleaning up planes.
113 */
Tomi Valkeinen5f741b32015-05-29 16:01:18 +0300114 omap_atomic_wait_for_completion(dev, old_state);
Laurent Pinchart748471a52015-03-05 23:42:39 +0200115
116 drm_atomic_helper_cleanup_planes(dev, old_state);
117
Laurent Pinchart50638ae2018-02-13 14:00:42 +0200118 priv->dispc_ops->runtime_put(priv->dispc);
Laurent Pinchart748471a52015-03-05 23:42:39 +0200119}
120
Laurent Pincharta9e6f9f2017-05-09 01:27:10 +0300121static const struct drm_mode_config_helper_funcs omap_mode_config_helper_funcs = {
122 .atomic_commit_tail = omap_atomic_commit_tail,
123};
Laurent Pinchart748471a52015-03-05 23:42:39 +0200124
Laurent Pincharte6ecefa2012-05-17 13:27:23 +0200125static const struct drm_mode_config_funcs omap_mode_config_funcs = {
Rob Clarkcd5351f2011-11-12 12:09:40 -0600126 .fb_create = omap_framebuffer_create,
Noralf Trønnesef62d302017-12-05 19:25:01 +0100127 .output_poll_changed = drm_fb_helper_output_poll_changed,
Laurent Pinchartcef77d42015-03-05 21:50:00 +0200128 .atomic_check = drm_atomic_helper_check,
Laurent Pincharta9e6f9f2017-05-09 01:27:10 +0300129 .atomic_commit = drm_atomic_helper_commit,
Rob Clarkcd5351f2011-11-12 12:09:40 -0600130};
131
Laurent Pinchart2ee76792018-03-05 15:02:22 +0200132static int get_connector_type(struct omap_dss_device *display)
Rob Clarkcd5351f2011-11-12 12:09:40 -0600133{
Laurent Pinchart2ee76792018-03-05 15:02:22 +0200134 switch (display->type) {
Rob Clarkcd5351f2011-11-12 12:09:40 -0600135 case OMAP_DISPLAY_TYPE_HDMI:
136 return DRM_MODE_CONNECTOR_HDMIA;
Tomi Valkeinen4635c172013-05-14 14:14:15 +0300137 case OMAP_DISPLAY_TYPE_DVI:
138 return DRM_MODE_CONNECTOR_DVID;
Sebastian Reichel4a64b902016-03-08 17:39:36 +0100139 case OMAP_DISPLAY_TYPE_DSI:
140 return DRM_MODE_CONNECTOR_DSI;
Tomi Valkeinen564f88c2017-04-27 13:02:28 +0300141 case OMAP_DISPLAY_TYPE_DPI:
142 case OMAP_DISPLAY_TYPE_DBI:
143 return DRM_MODE_CONNECTOR_DPI;
144 case OMAP_DISPLAY_TYPE_VENC:
145 /* TODO: This could also be composite */
146 return DRM_MODE_CONNECTOR_SVIDEO;
147 case OMAP_DISPLAY_TYPE_SDI:
148 return DRM_MODE_CONNECTOR_LVDS;
Rob Clarkcd5351f2011-11-12 12:09:40 -0600149 default:
150 return DRM_MODE_CONNECTOR_Unknown;
151 }
152}
153
Laurent Pinchart2ee76792018-03-05 15:02:22 +0200154static void omap_disconnect_pipelines(struct drm_device *ddev)
Archit Tanejacc823bd2014-01-02 14:49:52 +0530155{
Peter Ujfalusi52b9ef22018-02-12 11:44:37 +0200156 struct omap_drm_private *priv = ddev->dev_private;
157 unsigned int i;
Archit Tanejacc823bd2014-01-02 14:49:52 +0530158
Laurent Pinchart2ee76792018-03-05 15:02:22 +0200159 for (i = 0; i < priv->num_pipes; i++) {
Laurent Pinchart511afb42018-03-04 23:42:36 +0200160 struct omap_drm_pipeline *pipe = &priv->pipes[i];
Peter Ujfalusi52b9ef22018-02-12 11:44:37 +0200161
Laurent Pinchart511afb42018-03-04 23:42:36 +0200162 omapdss_device_disconnect(NULL, pipe->output);
163
164 omapdss_device_put(pipe->output);
165 omapdss_device_put(pipe->display);
166 pipe->output = NULL;
167 pipe->display = NULL;
Peter Ujfalusi52b9ef22018-02-12 11:44:37 +0200168 }
169
Laurent Pinchart2ee76792018-03-05 15:02:22 +0200170 priv->num_pipes = 0;
Archit Tanejacc823bd2014-01-02 14:49:52 +0530171}
Archit Taneja0d8f3712013-03-26 19:15:19 +0530172
Laurent Pinchart2ee76792018-03-05 15:02:22 +0200173static int omap_compare_pipes(const void *a, const void *b)
Peter Ujfalusieb5bc1f2018-02-12 11:44:39 +0200174{
Laurent Pinchart2ee76792018-03-05 15:02:22 +0200175 const struct omap_drm_pipeline *pipe1 = a;
176 const struct omap_drm_pipeline *pipe2 = b;
Peter Ujfalusieb5bc1f2018-02-12 11:44:39 +0200177
Laurent Pinchart2ee76792018-03-05 15:02:22 +0200178 if (pipe1->display->alias_id > pipe2->display->alias_id)
Peter Ujfalusieb5bc1f2018-02-12 11:44:39 +0200179 return 1;
Laurent Pinchart2ee76792018-03-05 15:02:22 +0200180 else if (pipe1->display->alias_id < pipe2->display->alias_id)
Peter Ujfalusieb5bc1f2018-02-12 11:44:39 +0200181 return -1;
182 return 0;
183}
184
Laurent Pinchart2ee76792018-03-05 15:02:22 +0200185static int omap_connect_pipelines(struct drm_device *ddev)
Archit Taneja3a01ab22014-01-02 14:49:51 +0530186{
Peter Ujfalusi52b9ef22018-02-12 11:44:37 +0200187 struct omap_drm_private *priv = ddev->dev_private;
Laurent Pinchart511afb42018-03-04 23:42:36 +0200188 struct omap_dss_device *output = NULL;
Peter Ujfalusi52b9ef22018-02-12 11:44:37 +0200189 int r;
Peter Ujfalusia09d2bc2016-05-03 22:08:01 +0300190
191 if (!omapdss_stack_is_ready())
192 return -EPROBE_DEFER;
Archit Taneja3a01ab22014-01-02 14:49:51 +0530193
Laurent Pinchart511afb42018-03-04 23:42:36 +0200194 for_each_dss_output(output) {
195 r = omapdss_device_connect(priv->dss, NULL, output);
Archit Taneja3a01ab22014-01-02 14:49:51 +0530196 if (r == -EPROBE_DEFER) {
Laurent Pinchart511afb42018-03-04 23:42:36 +0200197 omapdss_device_put(output);
Archit Taneja3a01ab22014-01-02 14:49:51 +0530198 goto cleanup;
199 } else if (r) {
Laurent Pinchart511afb42018-03-04 23:42:36 +0200200 dev_warn(output->dev, "could not connect output %s\n",
201 output->name);
Peter Ujfalusi52b9ef22018-02-12 11:44:37 +0200202 } else {
Laurent Pinchart511afb42018-03-04 23:42:36 +0200203 struct omap_drm_pipeline *pipe;
204
205 pipe = &priv->pipes[priv->num_pipes++];
206 pipe->output = omapdss_device_get(output);
207 pipe->display = omapdss_display_get(output);
208
Laurent Pinchart2ee76792018-03-05 15:02:22 +0200209 if (priv->num_pipes == ARRAY_SIZE(priv->pipes)) {
Laurent Pinchart511afb42018-03-04 23:42:36 +0200210 /* To balance the 'for_each_dss_output' loop */
211 omapdss_device_put(output);
Peter Ujfalusi52b9ef22018-02-12 11:44:37 +0200212 break;
213 }
Archit Taneja3a01ab22014-01-02 14:49:51 +0530214 }
215 }
216
Peter Ujfalusieb5bc1f2018-02-12 11:44:39 +0200217 /* Sort the list by DT aliases */
Laurent Pinchart2ee76792018-03-05 15:02:22 +0200218 sort(priv->pipes, priv->num_pipes, sizeof(priv->pipes[0]),
219 omap_compare_pipes, NULL);
Peter Ujfalusieb5bc1f2018-02-12 11:44:39 +0200220
Archit Taneja3a01ab22014-01-02 14:49:51 +0530221 return 0;
222
223cleanup:
224 /*
225 * if we are deferring probe, we disconnect the devices we previously
226 * connected
227 */
Laurent Pinchart2ee76792018-03-05 15:02:22 +0200228 omap_disconnect_pipelines(ddev);
Archit Taneja3a01ab22014-01-02 14:49:51 +0530229
230 return r;
231}
Rob Clarkcd5351f2011-11-12 12:09:40 -0600232
Laurent Pincharte2cd09b2015-03-06 17:16:43 +0200233static int omap_modeset_init_properties(struct drm_device *dev)
234{
235 struct omap_drm_private *priv = dev->dev_private;
Laurent Pinchart50638ae2018-02-13 14:00:42 +0200236 unsigned int num_planes = priv->dispc_ops->get_num_ovls(priv->dispc);
Laurent Pincharte2cd09b2015-03-06 17:16:43 +0200237
Laurent Pinchartdff6c242017-05-09 01:27:14 +0300238 priv->zorder_prop = drm_property_create_range(dev, 0, "zorder", 0,
239 num_planes - 1);
Laurent Pincharte2cd09b2015-03-06 17:16:43 +0200240 if (!priv->zorder_prop)
241 return -ENOMEM;
242
243 return 0;
244}
245
Rob Clarkcd5351f2011-11-12 12:09:40 -0600246static int omap_modeset_init(struct drm_device *dev)
247{
Rob Clarkcd5351f2011-11-12 12:09:40 -0600248 struct omap_drm_private *priv = dev->dev_private;
Laurent Pinchart50638ae2018-02-13 14:00:42 +0200249 int num_ovls = priv->dispc_ops->get_num_ovls(priv->dispc);
250 int num_mgrs = priv->dispc_ops->get_num_mgrs(priv->dispc);
Peter Ujfalusi52b9ef22018-02-12 11:44:37 +0200251 unsigned int i;
Laurent Pinchartfb9a35f2015-01-11 16:30:44 +0200252 int ret;
Jyri Sarhae8e13b12017-03-24 16:47:55 +0200253 u32 plane_crtc_mask;
Tomi Valkeinen04b1fc02013-05-14 10:55:19 +0300254
Rob Clarkcd5351f2011-11-12 12:09:40 -0600255 drm_mode_config_init(dev);
256
Laurent Pincharte2cd09b2015-03-06 17:16:43 +0200257 ret = omap_modeset_init_properties(dev);
258 if (ret < 0)
259 return ret;
260
Rob Clarkf5f94542012-12-04 13:59:12 -0600261 /*
Jyri Sarhae8e13b12017-03-24 16:47:55 +0200262 * This function creates exactly one connector, encoder, crtc,
263 * and primary plane per each connected dss-device. Each
264 * connector->encoder->crtc chain is expected to be separate
265 * and each crtc is connect to a single dss-channel. If the
266 * configuration does not match the expectations or exceeds
267 * the available resources, the configuration is rejected.
Rob Clarkf5f94542012-12-04 13:59:12 -0600268 */
Laurent Pinchart2ee76792018-03-05 15:02:22 +0200269 if (priv->num_pipes > num_mgrs || priv->num_pipes > num_ovls) {
Jyri Sarhae8e13b12017-03-24 16:47:55 +0200270 dev_err(dev->dev, "%s(): Too many connected displays\n",
271 __func__);
272 return -EINVAL;
273 }
274
Laurent Pinchartac3b1312018-03-05 19:11:30 +0200275 /* Create all planes first. They can all be put to any CRTC. */
Laurent Pinchart2ee76792018-03-05 15:02:22 +0200276 plane_crtc_mask = (1 << priv->num_pipes) - 1;
Rob Clarkcd5351f2011-11-12 12:09:40 -0600277
Laurent Pinchartac3b1312018-03-05 19:11:30 +0200278 for (i = 0; i < num_ovls; i++) {
Laurent Pinchart2ee76792018-03-05 15:02:22 +0200279 enum drm_plane_type type = i < priv->num_pipes
Laurent Pinchartac3b1312018-03-05 19:11:30 +0200280 ? DRM_PLANE_TYPE_PRIMARY
281 : DRM_PLANE_TYPE_OVERLAY;
282 struct drm_plane *plane;
283
284 if (WARN_ON(priv->num_planes >= ARRAY_SIZE(priv->planes)))
285 return -EINVAL;
286
287 plane = omap_plane_init(dev, i, type, plane_crtc_mask);
288 if (IS_ERR(plane))
289 return PTR_ERR(plane);
290
291 priv->planes[priv->num_planes++] = plane;
292 }
293
294 /* Create the CRTCs, encoders and connectors. */
Laurent Pinchart2ee76792018-03-05 15:02:22 +0200295 for (i = 0; i < priv->num_pipes; i++) {
296 struct omap_drm_pipeline *pipe = &priv->pipes[i];
297 struct omap_dss_device *display = pipe->display;
Rob Clarkf5f94542012-12-04 13:59:12 -0600298 struct drm_connector *connector;
299 struct drm_encoder *encoder;
Jyri Sarhae8e13b12017-03-24 16:47:55 +0200300 struct drm_crtc *crtc;
Rob Clarkf5f94542012-12-04 13:59:12 -0600301
Laurent Pinchart2ee76792018-03-05 15:02:22 +0200302 encoder = omap_encoder_init(dev, display);
Jyri Sarhae8e13b12017-03-24 16:47:55 +0200303 if (!encoder)
Rob Clarkf5f94542012-12-04 13:59:12 -0600304 return -ENOMEM;
Rob Clarkf5f94542012-12-04 13:59:12 -0600305
306 connector = omap_connector_init(dev,
Laurent Pinchart2ee76792018-03-05 15:02:22 +0200307 get_connector_type(display), display, encoder);
Jyri Sarhae8e13b12017-03-24 16:47:55 +0200308 if (!connector)
Rob Clarkf5f94542012-12-04 13:59:12 -0600309 return -ENOMEM;
Rob Clarkf5f94542012-12-04 13:59:12 -0600310
Laurent Pinchart00b30e72018-03-06 23:37:25 +0200311 crtc = omap_crtc_init(dev, pipe, priv->planes[i]);
Jyri Sarhae8e13b12017-03-24 16:47:55 +0200312 if (IS_ERR(crtc))
313 return PTR_ERR(crtc);
314
Daniel Vettercde4c442018-07-09 10:40:07 +0200315 drm_connector_attach_encoder(connector, encoder);
Laurent Pinchartf9699362018-03-05 14:47:47 +0200316 encoder->possible_crtcs = 1 << i;
Jyri Sarhae8e13b12017-03-24 16:47:55 +0200317
Laurent Pinchart2ee76792018-03-05 15:02:22 +0200318 pipe->crtc = crtc;
319 pipe->encoder = encoder;
320 pipe->connector = connector;
Archit Taneja0d8f3712013-03-26 19:15:19 +0530321 }
322
Laurent Pinchart2ee76792018-03-05 15:02:22 +0200323 DBG("registered %u planes, %u crtcs/encoders/connectors\n",
324 priv->num_planes, priv->num_pipes);
Archit Taneja0d8f3712013-03-26 19:15:19 +0530325
Tomi Valkeinen1e907112016-08-23 12:35:39 +0300326 dev->mode_config.min_width = 8;
327 dev->mode_config.min_height = 2;
Rob Clarkcd5351f2011-11-12 12:09:40 -0600328
Tomi Valkeinen1915d7f2018-01-10 11:31:18 +0200329 /*
330 * Note: these values are used for multiple independent things:
331 * connector mode filtering, buffer sizes, crtc sizes...
332 * Use big enough values here to cover all use cases, and do more
333 * specific checking in the respective code paths.
Rob Clarkcd5351f2011-11-12 12:09:40 -0600334 */
Tomi Valkeinen1915d7f2018-01-10 11:31:18 +0200335 dev->mode_config.max_width = 8192;
336 dev->mode_config.max_height = 8192;
Rob Clarkcd5351f2011-11-12 12:09:40 -0600337
Peter Ujfalusi23936ba2018-03-21 12:20:29 +0200338 /* We want the zpos to be normalized */
339 dev->mode_config.normalize_zpos = true;
340
Rob Clarkcd5351f2011-11-12 12:09:40 -0600341 dev->mode_config.funcs = &omap_mode_config_funcs;
Laurent Pincharta9e6f9f2017-05-09 01:27:10 +0300342 dev->mode_config.helper_private = &omap_mode_config_helper_funcs;
Rob Clarkcd5351f2011-11-12 12:09:40 -0600343
Laurent Pinchart69a12262015-03-05 21:38:16 +0200344 drm_mode_config_reset(dev);
345
Laurent Pinchart728ae8d2015-05-28 00:21:29 +0300346 omap_drm_irq_install(dev);
347
Rob Clarkcd5351f2011-11-12 12:09:40 -0600348 return 0;
349}
350
Rob Clarkcd5351f2011-11-12 12:09:40 -0600351/*
Peter Ujfalusi3c596802017-06-02 15:26:35 +0300352 * Enable the HPD in external components if supported
353 */
Peter Ujfalusi52b9ef22018-02-12 11:44:37 +0200354static void omap_modeset_enable_external_hpd(struct drm_device *ddev)
Peter Ujfalusi3c596802017-06-02 15:26:35 +0300355{
Peter Ujfalusi52b9ef22018-02-12 11:44:37 +0200356 struct omap_drm_private *priv = ddev->dev_private;
357 int i;
Peter Ujfalusi3c596802017-06-02 15:26:35 +0300358
Laurent Pinchart2ee76792018-03-05 15:02:22 +0200359 for (i = 0; i < priv->num_pipes; i++) {
360 struct omap_dss_device *display = priv->pipes[i].display;
Peter Ujfalusi52b9ef22018-02-12 11:44:37 +0200361
Laurent Pinchart2ee76792018-03-05 15:02:22 +0200362 if (display->driver->enable_hpd)
363 display->driver->enable_hpd(display);
Peter Ujfalusi3c596802017-06-02 15:26:35 +0300364 }
365}
366
367/*
368 * Disable the HPD in external components if supported
369 */
Peter Ujfalusi52b9ef22018-02-12 11:44:37 +0200370static void omap_modeset_disable_external_hpd(struct drm_device *ddev)
Peter Ujfalusi3c596802017-06-02 15:26:35 +0300371{
Peter Ujfalusi52b9ef22018-02-12 11:44:37 +0200372 struct omap_drm_private *priv = ddev->dev_private;
373 int i;
Peter Ujfalusi3c596802017-06-02 15:26:35 +0300374
Laurent Pinchart2ee76792018-03-05 15:02:22 +0200375 for (i = 0; i < priv->num_pipes; i++) {
376 struct omap_dss_device *display = priv->pipes[i].display;
Peter Ujfalusi52b9ef22018-02-12 11:44:37 +0200377
Laurent Pinchart2ee76792018-03-05 15:02:22 +0200378 if (display->driver->disable_hpd)
379 display->driver->disable_hpd(display);
Peter Ujfalusi3c596802017-06-02 15:26:35 +0300380 }
381}
382
383/*
Rob Clarkcd5351f2011-11-12 12:09:40 -0600384 * drm ioctl funcs
385 */
386
387
388static int ioctl_get_param(struct drm_device *dev, void *data,
389 struct drm_file *file_priv)
390{
Rob Clark5e3b0872012-10-29 09:31:12 +0100391 struct omap_drm_private *priv = dev->dev_private;
Rob Clarkcd5351f2011-11-12 12:09:40 -0600392 struct drm_omap_param *args = data;
393
394 DBG("%p: param=%llu", dev, args->param);
395
396 switch (args->param) {
397 case OMAP_PARAM_CHIPSET_ID:
Rob Clark5e3b0872012-10-29 09:31:12 +0100398 args->value = priv->omaprev;
Rob Clarkcd5351f2011-11-12 12:09:40 -0600399 break;
400 default:
401 DBG("unknown parameter %lld", args->param);
402 return -EINVAL;
403 }
404
405 return 0;
406}
407
408static int ioctl_set_param(struct drm_device *dev, void *data,
409 struct drm_file *file_priv)
410{
411 struct drm_omap_param *args = data;
412
413 switch (args->param) {
414 default:
415 DBG("unknown parameter %lld", args->param);
416 return -EINVAL;
417 }
418
419 return 0;
420}
421
Laurent Pinchartef3f4e92015-12-14 22:39:36 +0200422#define OMAP_BO_USER_MASK 0x00ffffff /* flags settable by userspace */
423
Rob Clarkcd5351f2011-11-12 12:09:40 -0600424static int ioctl_gem_new(struct drm_device *dev, void *data,
425 struct drm_file *file_priv)
426{
427 struct drm_omap_gem_new *args = data;
Laurent Pinchartef3f4e92015-12-14 22:39:36 +0200428 u32 flags = args->flags & OMAP_BO_USER_MASK;
429
Rob Clarkf5f94542012-12-04 13:59:12 -0600430 VERB("%p:%p: size=0x%08x, flags=%08x", dev, file_priv,
Laurent Pinchartef3f4e92015-12-14 22:39:36 +0200431 args->size.bytes, flags);
432
433 return omap_gem_new_handle(dev, file_priv, args->size, flags,
434 &args->handle);
Rob Clarkcd5351f2011-11-12 12:09:40 -0600435}
436
Rob Clarkcd5351f2011-11-12 12:09:40 -0600437static int ioctl_gem_info(struct drm_device *dev, void *data,
438 struct drm_file *file_priv)
439{
440 struct drm_omap_gem_info *args = data;
441 struct drm_gem_object *obj;
442 int ret = 0;
443
Rob Clarkf5f94542012-12-04 13:59:12 -0600444 VERB("%p:%p: handle=%d", dev, file_priv, args->handle);
Rob Clarkcd5351f2011-11-12 12:09:40 -0600445
Chris Wilsona8ad0bd2016-05-09 11:04:54 +0100446 obj = drm_gem_object_lookup(file_priv, args->handle);
YAMANE Toshiakic7f904b2012-11-14 19:30:38 +0900447 if (!obj)
Rob Clarkcd5351f2011-11-12 12:09:40 -0600448 return -ENOENT;
Rob Clarkcd5351f2011-11-12 12:09:40 -0600449
Rob Clarkf7f9f452011-12-05 19:19:22 -0600450 args->size = omap_gem_mmap_size(obj);
Rob Clarkcd5351f2011-11-12 12:09:40 -0600451 args->offset = omap_gem_mmap_offset(obj);
452
453 drm_gem_object_unreference_unlocked(obj);
454
455 return ret;
456}
457
Rob Clarkbaa70942013-08-02 13:27:49 -0400458static const struct drm_ioctl_desc ioctls[DRM_COMMAND_END - DRM_COMMAND_BASE] = {
Hemant Hariyani5f6ab8c2016-06-07 13:23:19 -0500459 DRM_IOCTL_DEF_DRV(OMAP_GET_PARAM, ioctl_get_param,
460 DRM_AUTH | DRM_RENDER_ALLOW),
461 DRM_IOCTL_DEF_DRV(OMAP_SET_PARAM, ioctl_set_param,
462 DRM_AUTH | DRM_MASTER | DRM_ROOT_ONLY),
463 DRM_IOCTL_DEF_DRV(OMAP_GEM_NEW, ioctl_gem_new,
464 DRM_AUTH | DRM_RENDER_ALLOW),
Laurent Pinchartd6f544f2017-05-09 01:27:11 +0300465 /* Deprecated, to be removed. */
466 DRM_IOCTL_DEF_DRV(OMAP_GEM_CPU_PREP, drm_noop,
Hemant Hariyani5f6ab8c2016-06-07 13:23:19 -0500467 DRM_AUTH | DRM_RENDER_ALLOW),
Laurent Pinchartd6f544f2017-05-09 01:27:11 +0300468 /* Deprecated, to be removed. */
469 DRM_IOCTL_DEF_DRV(OMAP_GEM_CPU_FINI, drm_noop,
Hemant Hariyani5f6ab8c2016-06-07 13:23:19 -0500470 DRM_AUTH | DRM_RENDER_ALLOW),
471 DRM_IOCTL_DEF_DRV(OMAP_GEM_INFO, ioctl_gem_info,
472 DRM_AUTH | DRM_RENDER_ALLOW),
Rob Clarkcd5351f2011-11-12 12:09:40 -0600473};
474
475/*
476 * drm driver funcs
477 */
478
Rob Clarkcd5351f2011-11-12 12:09:40 -0600479static int dev_open(struct drm_device *dev, struct drm_file *file)
480{
481 file->driver_priv = NULL;
482
483 DBG("open: dev=%p, file=%p", dev, file);
484
485 return 0;
486}
487
Laurent Pinchart78b68552012-05-17 13:27:22 +0200488static const struct vm_operations_struct omap_gem_vm_ops = {
Rob Clarkcd5351f2011-11-12 12:09:40 -0600489 .fault = omap_gem_fault,
490 .open = drm_gem_vm_open,
491 .close = drm_gem_vm_close,
492};
493
Rob Clarkff4f3872012-01-16 12:51:14 -0600494static const struct file_operations omapdriver_fops = {
Laurent Pinchart222025e2015-01-11 00:02:07 +0200495 .owner = THIS_MODULE,
496 .open = drm_open,
497 .unlocked_ioctl = drm_ioctl,
Tomi Valkeinen9d24159a2017-02-24 13:24:50 +0200498 .compat_ioctl = drm_compat_ioctl,
Laurent Pinchart222025e2015-01-11 00:02:07 +0200499 .release = drm_release,
500 .mmap = omap_gem_mmap,
501 .poll = drm_poll,
502 .read = drm_read,
503 .llseek = noop_llseek,
Rob Clarkff4f3872012-01-16 12:51:14 -0600504};
505
Rob Clarkcd5351f2011-11-12 12:09:40 -0600506static struct drm_driver omap_drm_driver = {
Tomi Valkeinen728fea72015-10-02 11:10:41 +0300507 .driver_features = DRIVER_MODESET | DRIVER_GEM | DRIVER_PRIME |
Hemant Hariyani5f6ab8c2016-06-07 13:23:19 -0500508 DRIVER_ATOMIC | DRIVER_RENDER,
Laurent Pinchart222025e2015-01-11 00:02:07 +0200509 .open = dev_open,
Noralf Trønnesef62d302017-12-05 19:25:01 +0100510 .lastclose = drm_fb_helper_lastclose,
Andy Gross6169a1482011-12-15 21:05:17 -0600511#ifdef CONFIG_DEBUG_FS
Laurent Pinchart222025e2015-01-11 00:02:07 +0200512 .debugfs_init = omap_debugfs_init,
Andy Gross6169a1482011-12-15 21:05:17 -0600513#endif
Laurent Pinchart222025e2015-01-11 00:02:07 +0200514 .prime_handle_to_fd = drm_gem_prime_handle_to_fd,
515 .prime_fd_to_handle = drm_gem_prime_fd_to_handle,
516 .gem_prime_export = omap_gem_prime_export,
517 .gem_prime_import = omap_gem_prime_import,
Daniel Vetterf8466182018-05-25 19:39:25 +0300518 .gem_free_object_unlocked = omap_gem_free_object,
Laurent Pinchart222025e2015-01-11 00:02:07 +0200519 .gem_vm_ops = &omap_gem_vm_ops,
520 .dumb_create = omap_gem_dumb_create,
521 .dumb_map_offset = omap_gem_dumb_map_offset,
Laurent Pinchart222025e2015-01-11 00:02:07 +0200522 .ioctls = ioctls,
523 .num_ioctls = DRM_OMAP_NUM_IOCTLS,
524 .fops = &omapdriver_fops,
525 .name = DRIVER_NAME,
526 .desc = DRIVER_DESC,
527 .date = DRIVER_DATE,
528 .major = DRIVER_MAJOR,
529 .minor = DRIVER_MINOR,
530 .patchlevel = DRIVER_PATCHLEVEL,
Rob Clarkcd5351f2011-11-12 12:09:40 -0600531};
532
Laurent Pinchart6e471fa2017-05-06 02:57:12 +0300533static const struct soc_device_attribute omapdrm_soc_devices[] = {
534 { .family = "OMAP3", .data = (void *)0x3430 },
535 { .family = "OMAP4", .data = (void *)0x4430 },
536 { .family = "OMAP5", .data = (void *)0x5430 },
537 { .family = "DRA7", .data = (void *)0x0752 },
538 { /* sentinel */ }
539};
540
Laurent Pincharta82f03472018-02-13 14:00:19 +0200541static int omapdrm_init(struct omap_drm_private *priv, struct device *dev)
Rob Clarkcd5351f2011-11-12 12:09:40 -0600542{
Laurent Pinchart6e471fa2017-05-06 02:57:12 +0300543 const struct soc_device_attribute *soc;
Laurent Pinchart2f95bc62016-12-12 11:28:47 +0200544 struct drm_device *ddev;
545 unsigned int i;
546 int ret;
547
Laurent Pincharta82f03472018-02-13 14:00:19 +0200548 DBG("%s", dev_name(dev));
Archit Taneja3a01ab22014-01-02 14:49:51 +0530549
Peter Ujfalusifb96b672018-02-12 11:44:36 +0200550 /* Allocate and initialize the DRM device. */
551 ddev = drm_dev_alloc(&omap_drm_driver, dev);
552 if (IS_ERR(ddev))
553 return PTR_ERR(ddev);
554
555 priv->ddev = ddev;
556 ddev->dev_private = priv;
557
Laurent Pincharta82f03472018-02-13 14:00:19 +0200558 priv->dev = dev;
Laurent Pinchartd3541ca2018-02-13 14:00:41 +0200559 priv->dss = omapdss_get_dss();
Laurent Pinchart50638ae2018-02-13 14:00:42 +0200560 priv->dispc = dispc_get_dispc(priv->dss);
Laurent Pinchartd3541ca2018-02-13 14:00:41 +0200561 priv->dispc_ops = dispc_get_ops(priv->dss);
Laurent Pinchart510c74c2017-08-11 16:49:08 +0300562
Laurent Pinchart64cb8172018-02-13 14:00:39 +0200563 omap_crtc_pre_init(priv);
Archit Taneja3a01ab22014-01-02 14:49:51 +0530564
Laurent Pinchart2ee76792018-03-05 15:02:22 +0200565 ret = omap_connect_pipelines(ddev);
Laurent Pinchart2f95bc62016-12-12 11:28:47 +0200566 if (ret)
567 goto err_crtc_uninit;
568
Laurent Pinchart6e471fa2017-05-06 02:57:12 +0300569 soc = soc_device_match(omapdrm_soc_devices);
570 priv->omaprev = soc ? (unsigned int)soc->data : 0;
Laurent Pinchart2f95bc62016-12-12 11:28:47 +0200571 priv->wq = alloc_ordered_workqueue("omapdrm", 0);
572
Daniel Vetter5117bd82018-05-25 19:39:24 +0300573 mutex_init(&priv->list_lock);
Laurent Pinchart2f95bc62016-12-12 11:28:47 +0200574 INIT_LIST_HEAD(&priv->obj_list);
575
Peter Ujfalusia7631c42017-11-30 14:12:37 +0200576 /* Get memory bandwidth limits */
577 if (priv->dispc_ops->get_memory_bandwidth_limit)
578 priv->max_bandwidth =
Laurent Pinchart50638ae2018-02-13 14:00:42 +0200579 priv->dispc_ops->get_memory_bandwidth_limit(priv->dispc);
Peter Ujfalusia7631c42017-11-30 14:12:37 +0200580
Laurent Pinchart2f95bc62016-12-12 11:28:47 +0200581 omap_gem_init(ddev);
582
583 ret = omap_modeset_init(ddev);
584 if (ret) {
Laurent Pincharta82f03472018-02-13 14:00:19 +0200585 dev_err(priv->dev, "omap_modeset_init failed: ret=%d\n", ret);
Peter Ujfalusifb96b672018-02-12 11:44:36 +0200586 goto err_gem_deinit;
Laurent Pinchart2f95bc62016-12-12 11:28:47 +0200587 }
588
589 /* Initialize vblank handling, start with all CRTCs disabled. */
Laurent Pinchart2ee76792018-03-05 15:02:22 +0200590 ret = drm_vblank_init(ddev, priv->num_pipes);
Laurent Pinchart2f95bc62016-12-12 11:28:47 +0200591 if (ret) {
Laurent Pincharta82f03472018-02-13 14:00:19 +0200592 dev_err(priv->dev, "could not init vblank\n");
Laurent Pinchart2f95bc62016-12-12 11:28:47 +0200593 goto err_cleanup_modeset;
594 }
595
Laurent Pinchart2ee76792018-03-05 15:02:22 +0200596 for (i = 0; i < priv->num_pipes; i++)
597 drm_crtc_vblank_off(priv->pipes[i].crtc);
Laurent Pinchart2f95bc62016-12-12 11:28:47 +0200598
Tomi Valkeinenefd1f062018-02-09 09:36:23 +0200599 omap_fbdev_init(ddev);
Laurent Pinchart2f95bc62016-12-12 11:28:47 +0200600
601 drm_kms_helper_poll_init(ddev);
Peter Ujfalusi52b9ef22018-02-12 11:44:37 +0200602 omap_modeset_enable_external_hpd(ddev);
Laurent Pinchart2f95bc62016-12-12 11:28:47 +0200603
604 /*
605 * Register the DRM device with the core and the connectors with
606 * sysfs.
607 */
608 ret = drm_dev_register(ddev, 0);
609 if (ret)
610 goto err_cleanup_helpers;
611
612 return 0;
613
614err_cleanup_helpers:
Peter Ujfalusi52b9ef22018-02-12 11:44:37 +0200615 omap_modeset_disable_external_hpd(ddev);
Laurent Pinchart2f95bc62016-12-12 11:28:47 +0200616 drm_kms_helper_poll_fini(ddev);
Tomi Valkeinenefd1f062018-02-09 09:36:23 +0200617
618 omap_fbdev_fini(ddev);
Laurent Pinchart2f95bc62016-12-12 11:28:47 +0200619err_cleanup_modeset:
620 drm_mode_config_cleanup(ddev);
621 omap_drm_irq_uninstall(ddev);
Peter Ujfalusifb96b672018-02-12 11:44:36 +0200622err_gem_deinit:
Laurent Pinchart2f95bc62016-12-12 11:28:47 +0200623 omap_gem_deinit(ddev);
Laurent Pinchart2f95bc62016-12-12 11:28:47 +0200624 destroy_workqueue(priv->wq);
Laurent Pinchart2ee76792018-03-05 15:02:22 +0200625 omap_disconnect_pipelines(ddev);
Laurent Pinchart2f95bc62016-12-12 11:28:47 +0200626err_crtc_uninit:
Laurent Pinchart845417b2018-03-02 03:05:10 +0200627 omap_crtc_pre_uninit(priv);
Peter Ujfalusifb96b672018-02-12 11:44:36 +0200628 drm_dev_unref(ddev);
Laurent Pinchart2f95bc62016-12-12 11:28:47 +0200629 return ret;
Rob Clarkcd5351f2011-11-12 12:09:40 -0600630}
631
Laurent Pincharta82f03472018-02-13 14:00:19 +0200632static void omapdrm_cleanup(struct omap_drm_private *priv)
Rob Clarkcd5351f2011-11-12 12:09:40 -0600633{
Laurent Pincharta82f03472018-02-13 14:00:19 +0200634 struct drm_device *ddev = priv->ddev;
Laurent Pinchart2f95bc62016-12-12 11:28:47 +0200635
Rob Clarkcd5351f2011-11-12 12:09:40 -0600636 DBG("");
Andy Gross5c137792012-03-05 10:48:39 -0600637
Laurent Pinchart2f95bc62016-12-12 11:28:47 +0200638 drm_dev_unregister(ddev);
639
Peter Ujfalusi52b9ef22018-02-12 11:44:37 +0200640 omap_modeset_disable_external_hpd(ddev);
Laurent Pinchart2f95bc62016-12-12 11:28:47 +0200641 drm_kms_helper_poll_fini(ddev);
642
Tomi Valkeinenefd1f062018-02-09 09:36:23 +0200643 omap_fbdev_fini(ddev);
Laurent Pinchart2f95bc62016-12-12 11:28:47 +0200644
Tomi Valkeinen8a54aa92017-03-27 10:02:22 +0300645 drm_atomic_helper_shutdown(ddev);
646
Laurent Pinchart2f95bc62016-12-12 11:28:47 +0200647 drm_mode_config_cleanup(ddev);
648
649 omap_drm_irq_uninstall(ddev);
650 omap_gem_deinit(ddev);
651
Laurent Pinchart2f95bc62016-12-12 11:28:47 +0200652 destroy_workqueue(priv->wq);
Tomi Valkeinen707cf582014-04-02 13:47:43 +0300653
Laurent Pinchart2ee76792018-03-05 15:02:22 +0200654 omap_disconnect_pipelines(ddev);
Laurent Pinchart845417b2018-03-02 03:05:10 +0200655 omap_crtc_pre_uninit(priv);
Peter Ujfalusifb96b672018-02-12 11:44:36 +0200656
657 drm_dev_unref(ddev);
Laurent Pincharta82f03472018-02-13 14:00:19 +0200658}
659
660static int pdev_probe(struct platform_device *pdev)
661{
662 struct omap_drm_private *priv;
663 int ret;
664
665 if (omapdss_is_initialized() == false)
666 return -EPROBE_DEFER;
667
668 ret = dma_set_coherent_mask(&pdev->dev, DMA_BIT_MASK(32));
669 if (ret) {
670 dev_err(&pdev->dev, "Failed to set the DMA mask\n");
671 return ret;
672 }
673
674 /* Allocate and initialize the driver private structure. */
675 priv = kzalloc(sizeof(*priv), GFP_KERNEL);
676 if (!priv)
677 return -ENOMEM;
678
679 platform_set_drvdata(pdev, priv);
680
681 ret = omapdrm_init(priv, &pdev->dev);
682 if (ret < 0)
683 kfree(priv);
684
685 return ret;
686}
687
688static int pdev_remove(struct platform_device *pdev)
689{
690 struct omap_drm_private *priv = platform_get_drvdata(pdev);
691
692 omapdrm_cleanup(priv);
693 kfree(priv);
Daniel Vetterfd3c0252013-12-11 11:34:26 +0100694
Rob Clarkcd5351f2011-11-12 12:09:40 -0600695 return 0;
696}
697
Grygorii Strashko8450c8d2015-02-26 15:57:17 +0200698#ifdef CONFIG_PM_SLEEP
Peter Ujfalusi52b9ef22018-02-12 11:44:37 +0200699static int omap_drm_suspend_all_displays(struct drm_device *ddev)
Tomi Valkeinen92bf0f92015-10-02 11:10:42 +0300700{
Peter Ujfalusi52b9ef22018-02-12 11:44:37 +0200701 struct omap_drm_private *priv = ddev->dev_private;
702 int i;
Tomi Valkeinen92bf0f92015-10-02 11:10:42 +0300703
Laurent Pinchart2ee76792018-03-05 15:02:22 +0200704 for (i = 0; i < priv->num_pipes; i++) {
705 struct omap_dss_device *display = priv->pipes[i].display;
Peter Ujfalusi52b9ef22018-02-12 11:44:37 +0200706
Laurent Pinchart2ee76792018-03-05 15:02:22 +0200707 if (!display->driver)
Tomi Valkeinen92bf0f92015-10-02 11:10:42 +0300708 continue;
709
Laurent Pinchart2ee76792018-03-05 15:02:22 +0200710 if (display->state == OMAP_DSS_DISPLAY_ACTIVE) {
711 display->driver->disable(display);
712 display->activate_after_resume = true;
Tomi Valkeinen92bf0f92015-10-02 11:10:42 +0300713 } else {
Laurent Pinchart2ee76792018-03-05 15:02:22 +0200714 display->activate_after_resume = false;
Tomi Valkeinen92bf0f92015-10-02 11:10:42 +0300715 }
716 }
717
718 return 0;
719}
720
Peter Ujfalusi52b9ef22018-02-12 11:44:37 +0200721static int omap_drm_resume_all_displays(struct drm_device *ddev)
Tomi Valkeinen92bf0f92015-10-02 11:10:42 +0300722{
Peter Ujfalusi52b9ef22018-02-12 11:44:37 +0200723 struct omap_drm_private *priv = ddev->dev_private;
724 int i;
Tomi Valkeinen92bf0f92015-10-02 11:10:42 +0300725
Laurent Pinchart2ee76792018-03-05 15:02:22 +0200726 for (i = 0; i < priv->num_pipes; i++) {
727 struct omap_dss_device *display = priv->pipes[i].display;
Peter Ujfalusi52b9ef22018-02-12 11:44:37 +0200728
Laurent Pinchart2ee76792018-03-05 15:02:22 +0200729 if (!display->driver)
Tomi Valkeinen92bf0f92015-10-02 11:10:42 +0300730 continue;
731
Laurent Pinchart2ee76792018-03-05 15:02:22 +0200732 if (display->activate_after_resume) {
733 display->driver->enable(display);
734 display->activate_after_resume = false;
Tomi Valkeinen92bf0f92015-10-02 11:10:42 +0300735 }
736 }
737
738 return 0;
739}
740
Tomi Valkeinenccd7b5e2014-11-14 15:18:28 +0200741static int omap_drm_suspend(struct device *dev)
742{
Laurent Pincharta82f03472018-02-13 14:00:19 +0200743 struct omap_drm_private *priv = dev_get_drvdata(dev);
744 struct drm_device *drm_dev = priv->ddev;
Tomi Valkeinenccd7b5e2014-11-14 15:18:28 +0200745
746 drm_kms_helper_poll_disable(drm_dev);
747
Tomi Valkeinen92bf0f92015-10-02 11:10:42 +0300748 drm_modeset_lock_all(drm_dev);
Peter Ujfalusi52b9ef22018-02-12 11:44:37 +0200749 omap_drm_suspend_all_displays(drm_dev);
Tomi Valkeinen92bf0f92015-10-02 11:10:42 +0300750 drm_modeset_unlock_all(drm_dev);
751
Tomi Valkeinenccd7b5e2014-11-14 15:18:28 +0200752 return 0;
753}
754
755static int omap_drm_resume(struct device *dev)
756{
Laurent Pincharta82f03472018-02-13 14:00:19 +0200757 struct omap_drm_private *priv = dev_get_drvdata(dev);
758 struct drm_device *drm_dev = priv->ddev;
Tomi Valkeinenccd7b5e2014-11-14 15:18:28 +0200759
Tomi Valkeinen92bf0f92015-10-02 11:10:42 +0300760 drm_modeset_lock_all(drm_dev);
Peter Ujfalusi52b9ef22018-02-12 11:44:37 +0200761 omap_drm_resume_all_displays(drm_dev);
Tomi Valkeinen92bf0f92015-10-02 11:10:42 +0300762 drm_modeset_unlock_all(drm_dev);
763
Tomi Valkeinenccd7b5e2014-11-14 15:18:28 +0200764 drm_kms_helper_poll_enable(drm_dev);
765
Laurent Pinchart7fb15c42017-10-13 17:58:58 +0300766 return omap_gem_resume(drm_dev);
Tomi Valkeinenccd7b5e2014-11-14 15:18:28 +0200767}
Andy Grosse78edba2012-12-19 14:53:37 -0600768#endif
769
Grygorii Strashko8450c8d2015-02-26 15:57:17 +0200770static SIMPLE_DEV_PM_OPS(omapdrm_pm_ops, omap_drm_suspend, omap_drm_resume);
771
Tomi Valkeinen6717cd22013-04-10 10:44:00 +0300772static struct platform_driver pdev = {
Laurent Pinchart222025e2015-01-11 00:02:07 +0200773 .driver = {
Tomi Valkeinenf64eafa2017-08-16 12:43:55 +0300774 .name = "omapdrm",
Laurent Pinchart222025e2015-01-11 00:02:07 +0200775 .pm = &omapdrm_pm_ops,
Laurent Pinchart222025e2015-01-11 00:02:07 +0200776 },
777 .probe = pdev_probe,
778 .remove = pdev_remove,
Rob Clarkcd5351f2011-11-12 12:09:40 -0600779};
780
Thierry Redinge1c49bd2015-12-02 17:23:31 +0100781static struct platform_driver * const drivers[] = {
782 &omap_dmm_driver,
783 &pdev,
784};
785
Rob Clarkcd5351f2011-11-12 12:09:40 -0600786static int __init omap_drm_init(void)
787{
788 DBG("init");
Tomi Valkeinenea7e3a62014-04-02 14:31:50 +0300789
Thierry Redinge1c49bd2015-12-02 17:23:31 +0100790 return platform_register_drivers(drivers, ARRAY_SIZE(drivers));
Rob Clarkcd5351f2011-11-12 12:09:40 -0600791}
792
793static void __exit omap_drm_fini(void)
794{
795 DBG("fini");
Tomi Valkeinenea7e3a62014-04-02 14:31:50 +0300796
Thierry Redinge1c49bd2015-12-02 17:23:31 +0100797 platform_unregister_drivers(drivers, ARRAY_SIZE(drivers));
Rob Clarkcd5351f2011-11-12 12:09:40 -0600798}
799
800/* need late_initcall() so we load after dss_driver's are loaded */
801late_initcall(omap_drm_init);
802module_exit(omap_drm_fini);
803
804MODULE_AUTHOR("Rob Clark <rob@ti.com>");
805MODULE_DESCRIPTION("OMAP DRM Display Driver");
806MODULE_ALIAS("platform:" DRIVER_NAME);
807MODULE_LICENSE("GPL v2");