blob: 5e67d58cbc281c1d8e2bd5b8ddd66f82073bdb7b [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 void omap_disconnect_pipelines(struct drm_device *ddev)
Archit Tanejacc823bd2014-01-02 14:49:52 +0530133{
Peter Ujfalusi52b9ef22018-02-12 11:44:37 +0200134 struct omap_drm_private *priv = ddev->dev_private;
135 unsigned int i;
Archit Tanejacc823bd2014-01-02 14:49:52 +0530136
Laurent Pinchart2ee76792018-03-05 15:02:22 +0200137 for (i = 0; i < priv->num_pipes; i++) {
Laurent Pinchart511afb42018-03-04 23:42:36 +0200138 struct omap_drm_pipeline *pipe = &priv->pipes[i];
Peter Ujfalusi52b9ef22018-02-12 11:44:37 +0200139
Laurent Pinchart511afb42018-03-04 23:42:36 +0200140 omapdss_device_disconnect(NULL, pipe->output);
141
142 omapdss_device_put(pipe->output);
143 omapdss_device_put(pipe->display);
144 pipe->output = NULL;
145 pipe->display = NULL;
Peter Ujfalusi52b9ef22018-02-12 11:44:37 +0200146 }
147
Laurent Pincharte48f9f12018-03-07 00:01:33 +0200148 memset(&priv->channels, 0, sizeof(priv->channels));
149
Laurent Pinchart2ee76792018-03-05 15:02:22 +0200150 priv->num_pipes = 0;
Archit Tanejacc823bd2014-01-02 14:49:52 +0530151}
Archit Taneja0d8f3712013-03-26 19:15:19 +0530152
Laurent Pinchart2ee76792018-03-05 15:02:22 +0200153static int omap_compare_pipes(const void *a, const void *b)
Peter Ujfalusieb5bc1f2018-02-12 11:44:39 +0200154{
Laurent Pinchart2ee76792018-03-05 15:02:22 +0200155 const struct omap_drm_pipeline *pipe1 = a;
156 const struct omap_drm_pipeline *pipe2 = b;
Peter Ujfalusieb5bc1f2018-02-12 11:44:39 +0200157
Laurent Pinchart2ee76792018-03-05 15:02:22 +0200158 if (pipe1->display->alias_id > pipe2->display->alias_id)
Peter Ujfalusieb5bc1f2018-02-12 11:44:39 +0200159 return 1;
Laurent Pinchart2ee76792018-03-05 15:02:22 +0200160 else if (pipe1->display->alias_id < pipe2->display->alias_id)
Peter Ujfalusieb5bc1f2018-02-12 11:44:39 +0200161 return -1;
162 return 0;
163}
164
Laurent Pinchart2ee76792018-03-05 15:02:22 +0200165static int omap_connect_pipelines(struct drm_device *ddev)
Archit Taneja3a01ab22014-01-02 14:49:51 +0530166{
Peter Ujfalusi52b9ef22018-02-12 11:44:37 +0200167 struct omap_drm_private *priv = ddev->dev_private;
Laurent Pinchart511afb42018-03-04 23:42:36 +0200168 struct omap_dss_device *output = NULL;
Laurent Pincharte48f9f12018-03-07 00:01:33 +0200169 unsigned int i;
Peter Ujfalusi52b9ef22018-02-12 11:44:37 +0200170 int r;
Peter Ujfalusia09d2bc2016-05-03 22:08:01 +0300171
172 if (!omapdss_stack_is_ready())
173 return -EPROBE_DEFER;
Archit Taneja3a01ab22014-01-02 14:49:51 +0530174
Laurent Pinchart511afb42018-03-04 23:42:36 +0200175 for_each_dss_output(output) {
176 r = omapdss_device_connect(priv->dss, NULL, output);
Archit Taneja3a01ab22014-01-02 14:49:51 +0530177 if (r == -EPROBE_DEFER) {
Laurent Pinchart511afb42018-03-04 23:42:36 +0200178 omapdss_device_put(output);
Archit Taneja3a01ab22014-01-02 14:49:51 +0530179 goto cleanup;
180 } else if (r) {
Laurent Pinchart511afb42018-03-04 23:42:36 +0200181 dev_warn(output->dev, "could not connect output %s\n",
182 output->name);
Peter Ujfalusi52b9ef22018-02-12 11:44:37 +0200183 } else {
Laurent Pinchart511afb42018-03-04 23:42:36 +0200184 struct omap_drm_pipeline *pipe;
185
186 pipe = &priv->pipes[priv->num_pipes++];
187 pipe->output = omapdss_device_get(output);
188 pipe->display = omapdss_display_get(output);
189
Laurent Pinchart2ee76792018-03-05 15:02:22 +0200190 if (priv->num_pipes == ARRAY_SIZE(priv->pipes)) {
Laurent Pinchart511afb42018-03-04 23:42:36 +0200191 /* To balance the 'for_each_dss_output' loop */
192 omapdss_device_put(output);
Peter Ujfalusi52b9ef22018-02-12 11:44:37 +0200193 break;
194 }
Archit Taneja3a01ab22014-01-02 14:49:51 +0530195 }
196 }
197
Peter Ujfalusieb5bc1f2018-02-12 11:44:39 +0200198 /* Sort the list by DT aliases */
Laurent Pinchart2ee76792018-03-05 15:02:22 +0200199 sort(priv->pipes, priv->num_pipes, sizeof(priv->pipes[0]),
200 omap_compare_pipes, NULL);
Peter Ujfalusieb5bc1f2018-02-12 11:44:39 +0200201
Laurent Pincharte48f9f12018-03-07 00:01:33 +0200202 /*
203 * Populate the pipeline lookup table by DISPC channel. Only one display
204 * is allowed per channel.
205 */
206 for (i = 0; i < priv->num_pipes; ++i) {
207 struct omap_drm_pipeline *pipe = &priv->pipes[i];
208 enum omap_channel channel = pipe->output->dispc_channel;
209
210 if (WARN_ON(priv->channels[channel] != NULL)) {
211 r = -EINVAL;
212 goto cleanup;
213 }
214
215 priv->channels[channel] = pipe;
216 }
217
Archit Taneja3a01ab22014-01-02 14:49:51 +0530218 return 0;
219
220cleanup:
221 /*
222 * if we are deferring probe, we disconnect the devices we previously
223 * connected
224 */
Laurent Pinchart2ee76792018-03-05 15:02:22 +0200225 omap_disconnect_pipelines(ddev);
Archit Taneja3a01ab22014-01-02 14:49:51 +0530226
227 return r;
228}
Rob Clarkcd5351f2011-11-12 12:09:40 -0600229
Laurent Pincharte2cd09b2015-03-06 17:16:43 +0200230static int omap_modeset_init_properties(struct drm_device *dev)
231{
232 struct omap_drm_private *priv = dev->dev_private;
Laurent Pinchart50638ae2018-02-13 14:00:42 +0200233 unsigned int num_planes = priv->dispc_ops->get_num_ovls(priv->dispc);
Laurent Pincharte2cd09b2015-03-06 17:16:43 +0200234
Laurent Pinchartdff6c242017-05-09 01:27:14 +0300235 priv->zorder_prop = drm_property_create_range(dev, 0, "zorder", 0,
236 num_planes - 1);
Laurent Pincharte2cd09b2015-03-06 17:16:43 +0200237 if (!priv->zorder_prop)
238 return -ENOMEM;
239
240 return 0;
241}
242
Rob Clarkcd5351f2011-11-12 12:09:40 -0600243static int omap_modeset_init(struct drm_device *dev)
244{
Rob Clarkcd5351f2011-11-12 12:09:40 -0600245 struct omap_drm_private *priv = dev->dev_private;
Laurent Pinchart50638ae2018-02-13 14:00:42 +0200246 int num_ovls = priv->dispc_ops->get_num_ovls(priv->dispc);
247 int num_mgrs = priv->dispc_ops->get_num_mgrs(priv->dispc);
Peter Ujfalusi52b9ef22018-02-12 11:44:37 +0200248 unsigned int i;
Laurent Pinchartfb9a35f2015-01-11 16:30:44 +0200249 int ret;
Jyri Sarhae8e13b12017-03-24 16:47:55 +0200250 u32 plane_crtc_mask;
Tomi Valkeinen04b1fc02013-05-14 10:55:19 +0300251
Rob Clarkcd5351f2011-11-12 12:09:40 -0600252 drm_mode_config_init(dev);
253
Laurent Pincharte2cd09b2015-03-06 17:16:43 +0200254 ret = omap_modeset_init_properties(dev);
255 if (ret < 0)
256 return ret;
257
Rob Clarkf5f94542012-12-04 13:59:12 -0600258 /*
Jyri Sarhae8e13b12017-03-24 16:47:55 +0200259 * This function creates exactly one connector, encoder, crtc,
260 * and primary plane per each connected dss-device. Each
261 * connector->encoder->crtc chain is expected to be separate
262 * and each crtc is connect to a single dss-channel. If the
263 * configuration does not match the expectations or exceeds
264 * the available resources, the configuration is rejected.
Rob Clarkf5f94542012-12-04 13:59:12 -0600265 */
Laurent Pinchart2ee76792018-03-05 15:02:22 +0200266 if (priv->num_pipes > num_mgrs || priv->num_pipes > num_ovls) {
Jyri Sarhae8e13b12017-03-24 16:47:55 +0200267 dev_err(dev->dev, "%s(): Too many connected displays\n",
268 __func__);
269 return -EINVAL;
270 }
271
Laurent Pinchartac3b1312018-03-05 19:11:30 +0200272 /* Create all planes first. They can all be put to any CRTC. */
Laurent Pinchart2ee76792018-03-05 15:02:22 +0200273 plane_crtc_mask = (1 << priv->num_pipes) - 1;
Rob Clarkcd5351f2011-11-12 12:09:40 -0600274
Laurent Pinchartac3b1312018-03-05 19:11:30 +0200275 for (i = 0; i < num_ovls; i++) {
Laurent Pinchart2ee76792018-03-05 15:02:22 +0200276 enum drm_plane_type type = i < priv->num_pipes
Laurent Pinchartac3b1312018-03-05 19:11:30 +0200277 ? DRM_PLANE_TYPE_PRIMARY
278 : DRM_PLANE_TYPE_OVERLAY;
279 struct drm_plane *plane;
280
281 if (WARN_ON(priv->num_planes >= ARRAY_SIZE(priv->planes)))
282 return -EINVAL;
283
284 plane = omap_plane_init(dev, i, type, plane_crtc_mask);
285 if (IS_ERR(plane))
286 return PTR_ERR(plane);
287
288 priv->planes[priv->num_planes++] = plane;
289 }
290
291 /* Create the CRTCs, encoders and connectors. */
Laurent Pinchart2ee76792018-03-05 15:02:22 +0200292 for (i = 0; i < priv->num_pipes; i++) {
293 struct omap_drm_pipeline *pipe = &priv->pipes[i];
294 struct omap_dss_device *display = pipe->display;
Rob Clarkf5f94542012-12-04 13:59:12 -0600295 struct drm_connector *connector;
296 struct drm_encoder *encoder;
Jyri Sarhae8e13b12017-03-24 16:47:55 +0200297 struct drm_crtc *crtc;
Rob Clarkf5f94542012-12-04 13:59:12 -0600298
Laurent Pinchartd96aaad2018-05-31 23:14:43 +0300299 encoder = omap_encoder_init(dev, pipe->output, display);
Jyri Sarhae8e13b12017-03-24 16:47:55 +0200300 if (!encoder)
Rob Clarkf5f94542012-12-04 13:59:12 -0600301 return -ENOMEM;
Rob Clarkf5f94542012-12-04 13:59:12 -0600302
Laurent Pinchart52c5dd22018-06-06 00:31:57 +0300303 connector = omap_connector_init(dev, pipe->output, display,
304 encoder);
Jyri Sarhae8e13b12017-03-24 16:47:55 +0200305 if (!connector)
Rob Clarkf5f94542012-12-04 13:59:12 -0600306 return -ENOMEM;
Rob Clarkf5f94542012-12-04 13:59:12 -0600307
Laurent Pinchart00b30e72018-03-06 23:37:25 +0200308 crtc = omap_crtc_init(dev, pipe, priv->planes[i]);
Jyri Sarhae8e13b12017-03-24 16:47:55 +0200309 if (IS_ERR(crtc))
310 return PTR_ERR(crtc);
311
Daniel Vettercde4c442018-07-09 10:40:07 +0200312 drm_connector_attach_encoder(connector, encoder);
Laurent Pinchartf9699362018-03-05 14:47:47 +0200313 encoder->possible_crtcs = 1 << i;
Jyri Sarhae8e13b12017-03-24 16:47:55 +0200314
Laurent Pinchart2ee76792018-03-05 15:02:22 +0200315 pipe->crtc = crtc;
316 pipe->encoder = encoder;
317 pipe->connector = connector;
Archit Taneja0d8f3712013-03-26 19:15:19 +0530318 }
319
Laurent Pinchart2ee76792018-03-05 15:02:22 +0200320 DBG("registered %u planes, %u crtcs/encoders/connectors\n",
321 priv->num_planes, priv->num_pipes);
Archit Taneja0d8f3712013-03-26 19:15:19 +0530322
Tomi Valkeinen1e907112016-08-23 12:35:39 +0300323 dev->mode_config.min_width = 8;
324 dev->mode_config.min_height = 2;
Rob Clarkcd5351f2011-11-12 12:09:40 -0600325
Tomi Valkeinen1915d7f2018-01-10 11:31:18 +0200326 /*
327 * Note: these values are used for multiple independent things:
328 * connector mode filtering, buffer sizes, crtc sizes...
329 * Use big enough values here to cover all use cases, and do more
330 * specific checking in the respective code paths.
Rob Clarkcd5351f2011-11-12 12:09:40 -0600331 */
Tomi Valkeinen1915d7f2018-01-10 11:31:18 +0200332 dev->mode_config.max_width = 8192;
333 dev->mode_config.max_height = 8192;
Rob Clarkcd5351f2011-11-12 12:09:40 -0600334
Peter Ujfalusi23936ba2018-03-21 12:20:29 +0200335 /* We want the zpos to be normalized */
336 dev->mode_config.normalize_zpos = true;
337
Rob Clarkcd5351f2011-11-12 12:09:40 -0600338 dev->mode_config.funcs = &omap_mode_config_funcs;
Laurent Pincharta9e6f9f2017-05-09 01:27:10 +0300339 dev->mode_config.helper_private = &omap_mode_config_helper_funcs;
Rob Clarkcd5351f2011-11-12 12:09:40 -0600340
Laurent Pinchart69a12262015-03-05 21:38:16 +0200341 drm_mode_config_reset(dev);
342
Laurent Pinchart728ae8d2015-05-28 00:21:29 +0300343 omap_drm_irq_install(dev);
344
Rob Clarkcd5351f2011-11-12 12:09:40 -0600345 return 0;
346}
347
Rob Clarkcd5351f2011-11-12 12:09:40 -0600348/*
Peter Ujfalusi3c596802017-06-02 15:26:35 +0300349 * Enable the HPD in external components if supported
350 */
Peter Ujfalusi52b9ef22018-02-12 11:44:37 +0200351static void omap_modeset_enable_external_hpd(struct drm_device *ddev)
Peter Ujfalusi3c596802017-06-02 15:26:35 +0300352{
Peter Ujfalusi52b9ef22018-02-12 11:44:37 +0200353 struct omap_drm_private *priv = ddev->dev_private;
354 int i;
Peter Ujfalusi3c596802017-06-02 15:26:35 +0300355
Laurent Pinchart18412b62018-05-30 21:46:44 +0300356 for (i = 0; i < priv->num_pipes; i++)
357 omap_connector_enable_hpd(priv->pipes[i].connector);
Peter Ujfalusi3c596802017-06-02 15:26:35 +0300358}
359
360/*
361 * Disable the HPD in external components if supported
362 */
Peter Ujfalusi52b9ef22018-02-12 11:44:37 +0200363static void omap_modeset_disable_external_hpd(struct drm_device *ddev)
Peter Ujfalusi3c596802017-06-02 15:26:35 +0300364{
Peter Ujfalusi52b9ef22018-02-12 11:44:37 +0200365 struct omap_drm_private *priv = ddev->dev_private;
366 int i;
Peter Ujfalusi3c596802017-06-02 15:26:35 +0300367
Laurent Pinchart18412b62018-05-30 21:46:44 +0300368 for (i = 0; i < priv->num_pipes; i++)
369 omap_connector_disable_hpd(priv->pipes[i].connector);
Peter Ujfalusi3c596802017-06-02 15:26:35 +0300370}
371
372/*
Rob Clarkcd5351f2011-11-12 12:09:40 -0600373 * drm ioctl funcs
374 */
375
376
377static int ioctl_get_param(struct drm_device *dev, void *data,
378 struct drm_file *file_priv)
379{
Rob Clark5e3b0872012-10-29 09:31:12 +0100380 struct omap_drm_private *priv = dev->dev_private;
Rob Clarkcd5351f2011-11-12 12:09:40 -0600381 struct drm_omap_param *args = data;
382
383 DBG("%p: param=%llu", dev, args->param);
384
385 switch (args->param) {
386 case OMAP_PARAM_CHIPSET_ID:
Rob Clark5e3b0872012-10-29 09:31:12 +0100387 args->value = priv->omaprev;
Rob Clarkcd5351f2011-11-12 12:09:40 -0600388 break;
389 default:
390 DBG("unknown parameter %lld", args->param);
391 return -EINVAL;
392 }
393
394 return 0;
395}
396
397static int ioctl_set_param(struct drm_device *dev, void *data,
398 struct drm_file *file_priv)
399{
400 struct drm_omap_param *args = data;
401
402 switch (args->param) {
403 default:
404 DBG("unknown parameter %lld", args->param);
405 return -EINVAL;
406 }
407
408 return 0;
409}
410
Laurent Pinchartef3f4e92015-12-14 22:39:36 +0200411#define OMAP_BO_USER_MASK 0x00ffffff /* flags settable by userspace */
412
Rob Clarkcd5351f2011-11-12 12:09:40 -0600413static int ioctl_gem_new(struct drm_device *dev, void *data,
414 struct drm_file *file_priv)
415{
416 struct drm_omap_gem_new *args = data;
Laurent Pinchartef3f4e92015-12-14 22:39:36 +0200417 u32 flags = args->flags & OMAP_BO_USER_MASK;
418
Rob Clarkf5f94542012-12-04 13:59:12 -0600419 VERB("%p:%p: size=0x%08x, flags=%08x", dev, file_priv,
Laurent Pinchartef3f4e92015-12-14 22:39:36 +0200420 args->size.bytes, flags);
421
422 return omap_gem_new_handle(dev, file_priv, args->size, flags,
423 &args->handle);
Rob Clarkcd5351f2011-11-12 12:09:40 -0600424}
425
Rob Clarkcd5351f2011-11-12 12:09:40 -0600426static int ioctl_gem_info(struct drm_device *dev, void *data,
427 struct drm_file *file_priv)
428{
429 struct drm_omap_gem_info *args = data;
430 struct drm_gem_object *obj;
431 int ret = 0;
432
Rob Clarkf5f94542012-12-04 13:59:12 -0600433 VERB("%p:%p: handle=%d", dev, file_priv, args->handle);
Rob Clarkcd5351f2011-11-12 12:09:40 -0600434
Chris Wilsona8ad0bd2016-05-09 11:04:54 +0100435 obj = drm_gem_object_lookup(file_priv, args->handle);
YAMANE Toshiakic7f904b2012-11-14 19:30:38 +0900436 if (!obj)
Rob Clarkcd5351f2011-11-12 12:09:40 -0600437 return -ENOENT;
Rob Clarkcd5351f2011-11-12 12:09:40 -0600438
Rob Clarkf7f9f452011-12-05 19:19:22 -0600439 args->size = omap_gem_mmap_size(obj);
Rob Clarkcd5351f2011-11-12 12:09:40 -0600440 args->offset = omap_gem_mmap_offset(obj);
441
Thomas Zimmermanne64d0222018-06-18 15:07:26 +0200442 drm_gem_object_put_unlocked(obj);
Rob Clarkcd5351f2011-11-12 12:09:40 -0600443
444 return ret;
445}
446
Rob Clarkbaa70942013-08-02 13:27:49 -0400447static const struct drm_ioctl_desc ioctls[DRM_COMMAND_END - DRM_COMMAND_BASE] = {
Hemant Hariyani5f6ab8c2016-06-07 13:23:19 -0500448 DRM_IOCTL_DEF_DRV(OMAP_GET_PARAM, ioctl_get_param,
449 DRM_AUTH | DRM_RENDER_ALLOW),
450 DRM_IOCTL_DEF_DRV(OMAP_SET_PARAM, ioctl_set_param,
451 DRM_AUTH | DRM_MASTER | DRM_ROOT_ONLY),
452 DRM_IOCTL_DEF_DRV(OMAP_GEM_NEW, ioctl_gem_new,
453 DRM_AUTH | DRM_RENDER_ALLOW),
Laurent Pinchartd6f544f2017-05-09 01:27:11 +0300454 /* Deprecated, to be removed. */
455 DRM_IOCTL_DEF_DRV(OMAP_GEM_CPU_PREP, drm_noop,
Hemant Hariyani5f6ab8c2016-06-07 13:23:19 -0500456 DRM_AUTH | DRM_RENDER_ALLOW),
Laurent Pinchartd6f544f2017-05-09 01:27:11 +0300457 /* Deprecated, to be removed. */
458 DRM_IOCTL_DEF_DRV(OMAP_GEM_CPU_FINI, drm_noop,
Hemant Hariyani5f6ab8c2016-06-07 13:23:19 -0500459 DRM_AUTH | DRM_RENDER_ALLOW),
460 DRM_IOCTL_DEF_DRV(OMAP_GEM_INFO, ioctl_gem_info,
461 DRM_AUTH | DRM_RENDER_ALLOW),
Rob Clarkcd5351f2011-11-12 12:09:40 -0600462};
463
464/*
465 * drm driver funcs
466 */
467
Rob Clarkcd5351f2011-11-12 12:09:40 -0600468static int dev_open(struct drm_device *dev, struct drm_file *file)
469{
470 file->driver_priv = NULL;
471
472 DBG("open: dev=%p, file=%p", dev, file);
473
474 return 0;
475}
476
Laurent Pinchart78b68552012-05-17 13:27:22 +0200477static const struct vm_operations_struct omap_gem_vm_ops = {
Rob Clarkcd5351f2011-11-12 12:09:40 -0600478 .fault = omap_gem_fault,
479 .open = drm_gem_vm_open,
480 .close = drm_gem_vm_close,
481};
482
Rob Clarkff4f3872012-01-16 12:51:14 -0600483static const struct file_operations omapdriver_fops = {
Laurent Pinchart222025e2015-01-11 00:02:07 +0200484 .owner = THIS_MODULE,
485 .open = drm_open,
486 .unlocked_ioctl = drm_ioctl,
Tomi Valkeinen9d24159a2017-02-24 13:24:50 +0200487 .compat_ioctl = drm_compat_ioctl,
Laurent Pinchart222025e2015-01-11 00:02:07 +0200488 .release = drm_release,
489 .mmap = omap_gem_mmap,
490 .poll = drm_poll,
491 .read = drm_read,
492 .llseek = noop_llseek,
Rob Clarkff4f3872012-01-16 12:51:14 -0600493};
494
Rob Clarkcd5351f2011-11-12 12:09:40 -0600495static struct drm_driver omap_drm_driver = {
Tomi Valkeinen728fea72015-10-02 11:10:41 +0300496 .driver_features = DRIVER_MODESET | DRIVER_GEM | DRIVER_PRIME |
Hemant Hariyani5f6ab8c2016-06-07 13:23:19 -0500497 DRIVER_ATOMIC | DRIVER_RENDER,
Laurent Pinchart222025e2015-01-11 00:02:07 +0200498 .open = dev_open,
Noralf Trønnesef62d302017-12-05 19:25:01 +0100499 .lastclose = drm_fb_helper_lastclose,
Andy Gross6169a1482011-12-15 21:05:17 -0600500#ifdef CONFIG_DEBUG_FS
Laurent Pinchart222025e2015-01-11 00:02:07 +0200501 .debugfs_init = omap_debugfs_init,
Andy Gross6169a1482011-12-15 21:05:17 -0600502#endif
Laurent Pinchart222025e2015-01-11 00:02:07 +0200503 .prime_handle_to_fd = drm_gem_prime_handle_to_fd,
504 .prime_fd_to_handle = drm_gem_prime_fd_to_handle,
505 .gem_prime_export = omap_gem_prime_export,
506 .gem_prime_import = omap_gem_prime_import,
Daniel Vetterf8466182018-05-25 19:39:25 +0300507 .gem_free_object_unlocked = omap_gem_free_object,
Laurent Pinchart222025e2015-01-11 00:02:07 +0200508 .gem_vm_ops = &omap_gem_vm_ops,
509 .dumb_create = omap_gem_dumb_create,
510 .dumb_map_offset = omap_gem_dumb_map_offset,
Laurent Pinchart222025e2015-01-11 00:02:07 +0200511 .ioctls = ioctls,
512 .num_ioctls = DRM_OMAP_NUM_IOCTLS,
513 .fops = &omapdriver_fops,
514 .name = DRIVER_NAME,
515 .desc = DRIVER_DESC,
516 .date = DRIVER_DATE,
517 .major = DRIVER_MAJOR,
518 .minor = DRIVER_MINOR,
519 .patchlevel = DRIVER_PATCHLEVEL,
Rob Clarkcd5351f2011-11-12 12:09:40 -0600520};
521
Laurent Pinchart6e471fa2017-05-06 02:57:12 +0300522static const struct soc_device_attribute omapdrm_soc_devices[] = {
523 { .family = "OMAP3", .data = (void *)0x3430 },
524 { .family = "OMAP4", .data = (void *)0x4430 },
525 { .family = "OMAP5", .data = (void *)0x5430 },
526 { .family = "DRA7", .data = (void *)0x0752 },
527 { /* sentinel */ }
528};
529
Laurent Pincharta82f03472018-02-13 14:00:19 +0200530static int omapdrm_init(struct omap_drm_private *priv, struct device *dev)
Rob Clarkcd5351f2011-11-12 12:09:40 -0600531{
Laurent Pinchart6e471fa2017-05-06 02:57:12 +0300532 const struct soc_device_attribute *soc;
Laurent Pinchart2f95bc62016-12-12 11:28:47 +0200533 struct drm_device *ddev;
534 unsigned int i;
535 int ret;
536
Laurent Pincharta82f03472018-02-13 14:00:19 +0200537 DBG("%s", dev_name(dev));
Archit Taneja3a01ab22014-01-02 14:49:51 +0530538
Peter Ujfalusifb96b672018-02-12 11:44:36 +0200539 /* Allocate and initialize the DRM device. */
540 ddev = drm_dev_alloc(&omap_drm_driver, dev);
541 if (IS_ERR(ddev))
542 return PTR_ERR(ddev);
543
544 priv->ddev = ddev;
545 ddev->dev_private = priv;
546
Laurent Pincharta82f03472018-02-13 14:00:19 +0200547 priv->dev = dev;
Laurent Pinchartd3541ca2018-02-13 14:00:41 +0200548 priv->dss = omapdss_get_dss();
Laurent Pinchart50638ae2018-02-13 14:00:42 +0200549 priv->dispc = dispc_get_dispc(priv->dss);
Laurent Pinchartd3541ca2018-02-13 14:00:41 +0200550 priv->dispc_ops = dispc_get_ops(priv->dss);
Laurent Pinchart510c74c2017-08-11 16:49:08 +0300551
Laurent Pinchart64cb8172018-02-13 14:00:39 +0200552 omap_crtc_pre_init(priv);
Archit Taneja3a01ab22014-01-02 14:49:51 +0530553
Laurent Pinchart2ee76792018-03-05 15:02:22 +0200554 ret = omap_connect_pipelines(ddev);
Laurent Pinchart2f95bc62016-12-12 11:28:47 +0200555 if (ret)
556 goto err_crtc_uninit;
557
Laurent Pinchart6e471fa2017-05-06 02:57:12 +0300558 soc = soc_device_match(omapdrm_soc_devices);
559 priv->omaprev = soc ? (unsigned int)soc->data : 0;
Laurent Pinchart2f95bc62016-12-12 11:28:47 +0200560 priv->wq = alloc_ordered_workqueue("omapdrm", 0);
561
Daniel Vetter5117bd82018-05-25 19:39:24 +0300562 mutex_init(&priv->list_lock);
Laurent Pinchart2f95bc62016-12-12 11:28:47 +0200563 INIT_LIST_HEAD(&priv->obj_list);
564
Peter Ujfalusia7631c42017-11-30 14:12:37 +0200565 /* Get memory bandwidth limits */
566 if (priv->dispc_ops->get_memory_bandwidth_limit)
567 priv->max_bandwidth =
Laurent Pinchart50638ae2018-02-13 14:00:42 +0200568 priv->dispc_ops->get_memory_bandwidth_limit(priv->dispc);
Peter Ujfalusia7631c42017-11-30 14:12:37 +0200569
Laurent Pinchart2f95bc62016-12-12 11:28:47 +0200570 omap_gem_init(ddev);
571
572 ret = omap_modeset_init(ddev);
573 if (ret) {
Laurent Pincharta82f03472018-02-13 14:00:19 +0200574 dev_err(priv->dev, "omap_modeset_init failed: ret=%d\n", ret);
Peter Ujfalusifb96b672018-02-12 11:44:36 +0200575 goto err_gem_deinit;
Laurent Pinchart2f95bc62016-12-12 11:28:47 +0200576 }
577
578 /* Initialize vblank handling, start with all CRTCs disabled. */
Laurent Pinchart2ee76792018-03-05 15:02:22 +0200579 ret = drm_vblank_init(ddev, priv->num_pipes);
Laurent Pinchart2f95bc62016-12-12 11:28:47 +0200580 if (ret) {
Laurent Pincharta82f03472018-02-13 14:00:19 +0200581 dev_err(priv->dev, "could not init vblank\n");
Laurent Pinchart2f95bc62016-12-12 11:28:47 +0200582 goto err_cleanup_modeset;
583 }
584
Laurent Pinchart2ee76792018-03-05 15:02:22 +0200585 for (i = 0; i < priv->num_pipes; i++)
586 drm_crtc_vblank_off(priv->pipes[i].crtc);
Laurent Pinchart2f95bc62016-12-12 11:28:47 +0200587
Tomi Valkeinenefd1f062018-02-09 09:36:23 +0200588 omap_fbdev_init(ddev);
Laurent Pinchart2f95bc62016-12-12 11:28:47 +0200589
590 drm_kms_helper_poll_init(ddev);
Peter Ujfalusi52b9ef22018-02-12 11:44:37 +0200591 omap_modeset_enable_external_hpd(ddev);
Laurent Pinchart2f95bc62016-12-12 11:28:47 +0200592
593 /*
594 * Register the DRM device with the core and the connectors with
595 * sysfs.
596 */
597 ret = drm_dev_register(ddev, 0);
598 if (ret)
599 goto err_cleanup_helpers;
600
601 return 0;
602
603err_cleanup_helpers:
Peter Ujfalusi52b9ef22018-02-12 11:44:37 +0200604 omap_modeset_disable_external_hpd(ddev);
Laurent Pinchart2f95bc62016-12-12 11:28:47 +0200605 drm_kms_helper_poll_fini(ddev);
Tomi Valkeinenefd1f062018-02-09 09:36:23 +0200606
607 omap_fbdev_fini(ddev);
Laurent Pinchart2f95bc62016-12-12 11:28:47 +0200608err_cleanup_modeset:
609 drm_mode_config_cleanup(ddev);
610 omap_drm_irq_uninstall(ddev);
Peter Ujfalusifb96b672018-02-12 11:44:36 +0200611err_gem_deinit:
Laurent Pinchart2f95bc62016-12-12 11:28:47 +0200612 omap_gem_deinit(ddev);
Laurent Pinchart2f95bc62016-12-12 11:28:47 +0200613 destroy_workqueue(priv->wq);
Laurent Pinchart2ee76792018-03-05 15:02:22 +0200614 omap_disconnect_pipelines(ddev);
Laurent Pinchart2f95bc62016-12-12 11:28:47 +0200615err_crtc_uninit:
Laurent Pinchart845417b2018-03-02 03:05:10 +0200616 omap_crtc_pre_uninit(priv);
Thomas Zimmermann08bafff2018-06-18 15:07:27 +0200617 drm_dev_put(ddev);
Laurent Pinchart2f95bc62016-12-12 11:28:47 +0200618 return ret;
Rob Clarkcd5351f2011-11-12 12:09:40 -0600619}
620
Laurent Pincharta82f03472018-02-13 14:00:19 +0200621static void omapdrm_cleanup(struct omap_drm_private *priv)
Rob Clarkcd5351f2011-11-12 12:09:40 -0600622{
Laurent Pincharta82f03472018-02-13 14:00:19 +0200623 struct drm_device *ddev = priv->ddev;
Laurent Pinchart2f95bc62016-12-12 11:28:47 +0200624
Rob Clarkcd5351f2011-11-12 12:09:40 -0600625 DBG("");
Andy Gross5c137792012-03-05 10:48:39 -0600626
Laurent Pinchart2f95bc62016-12-12 11:28:47 +0200627 drm_dev_unregister(ddev);
628
Peter Ujfalusi52b9ef22018-02-12 11:44:37 +0200629 omap_modeset_disable_external_hpd(ddev);
Laurent Pinchart2f95bc62016-12-12 11:28:47 +0200630 drm_kms_helper_poll_fini(ddev);
631
Tomi Valkeinenefd1f062018-02-09 09:36:23 +0200632 omap_fbdev_fini(ddev);
Laurent Pinchart2f95bc62016-12-12 11:28:47 +0200633
Tomi Valkeinen8a54aa92017-03-27 10:02:22 +0300634 drm_atomic_helper_shutdown(ddev);
635
Laurent Pinchart2f95bc62016-12-12 11:28:47 +0200636 drm_mode_config_cleanup(ddev);
637
638 omap_drm_irq_uninstall(ddev);
639 omap_gem_deinit(ddev);
640
Laurent Pinchart2f95bc62016-12-12 11:28:47 +0200641 destroy_workqueue(priv->wq);
Tomi Valkeinen707cf582014-04-02 13:47:43 +0300642
Laurent Pinchart2ee76792018-03-05 15:02:22 +0200643 omap_disconnect_pipelines(ddev);
Laurent Pinchart845417b2018-03-02 03:05:10 +0200644 omap_crtc_pre_uninit(priv);
Peter Ujfalusifb96b672018-02-12 11:44:36 +0200645
Thomas Zimmermann08bafff2018-06-18 15:07:27 +0200646 drm_dev_put(ddev);
Laurent Pincharta82f03472018-02-13 14:00:19 +0200647}
648
649static int pdev_probe(struct platform_device *pdev)
650{
651 struct omap_drm_private *priv;
652 int ret;
653
654 if (omapdss_is_initialized() == false)
655 return -EPROBE_DEFER;
656
657 ret = dma_set_coherent_mask(&pdev->dev, DMA_BIT_MASK(32));
658 if (ret) {
659 dev_err(&pdev->dev, "Failed to set the DMA mask\n");
660 return ret;
661 }
662
663 /* Allocate and initialize the driver private structure. */
664 priv = kzalloc(sizeof(*priv), GFP_KERNEL);
665 if (!priv)
666 return -ENOMEM;
667
668 platform_set_drvdata(pdev, priv);
669
670 ret = omapdrm_init(priv, &pdev->dev);
671 if (ret < 0)
672 kfree(priv);
673
674 return ret;
675}
676
677static int pdev_remove(struct platform_device *pdev)
678{
679 struct omap_drm_private *priv = platform_get_drvdata(pdev);
680
681 omapdrm_cleanup(priv);
682 kfree(priv);
Daniel Vetterfd3c0252013-12-11 11:34:26 +0100683
Rob Clarkcd5351f2011-11-12 12:09:40 -0600684 return 0;
685}
686
Grygorii Strashko8450c8d2015-02-26 15:57:17 +0200687#ifdef CONFIG_PM_SLEEP
Peter Ujfalusi52b9ef22018-02-12 11:44:37 +0200688static int omap_drm_suspend_all_displays(struct drm_device *ddev)
Tomi Valkeinen92bf0f92015-10-02 11:10:42 +0300689{
Peter Ujfalusi52b9ef22018-02-12 11:44:37 +0200690 struct omap_drm_private *priv = ddev->dev_private;
691 int i;
Tomi Valkeinen92bf0f92015-10-02 11:10:42 +0300692
Laurent Pinchart2ee76792018-03-05 15:02:22 +0200693 for (i = 0; i < priv->num_pipes; i++) {
694 struct omap_dss_device *display = priv->pipes[i].display;
Peter Ujfalusi52b9ef22018-02-12 11:44:37 +0200695
Laurent Pinchart2ee76792018-03-05 15:02:22 +0200696 if (display->state == OMAP_DSS_DISPLAY_ACTIVE) {
Laurent Pinchart83910ad2018-06-01 19:45:01 +0300697 display->ops->disable(display);
Laurent Pinchart2ee76792018-03-05 15:02:22 +0200698 display->activate_after_resume = true;
Tomi Valkeinen92bf0f92015-10-02 11:10:42 +0300699 } else {
Laurent Pinchart2ee76792018-03-05 15:02:22 +0200700 display->activate_after_resume = false;
Tomi Valkeinen92bf0f92015-10-02 11:10:42 +0300701 }
702 }
703
704 return 0;
705}
706
Peter Ujfalusi52b9ef22018-02-12 11:44:37 +0200707static int omap_drm_resume_all_displays(struct drm_device *ddev)
Tomi Valkeinen92bf0f92015-10-02 11:10:42 +0300708{
Peter Ujfalusi52b9ef22018-02-12 11:44:37 +0200709 struct omap_drm_private *priv = ddev->dev_private;
710 int i;
Tomi Valkeinen92bf0f92015-10-02 11:10:42 +0300711
Laurent Pinchart2ee76792018-03-05 15:02:22 +0200712 for (i = 0; i < priv->num_pipes; i++) {
713 struct omap_dss_device *display = priv->pipes[i].display;
Peter Ujfalusi52b9ef22018-02-12 11:44:37 +0200714
Laurent Pinchart2ee76792018-03-05 15:02:22 +0200715 if (display->activate_after_resume) {
Laurent Pinchart83910ad2018-06-01 19:45:01 +0300716 display->ops->enable(display);
Laurent Pinchart2ee76792018-03-05 15:02:22 +0200717 display->activate_after_resume = false;
Tomi Valkeinen92bf0f92015-10-02 11:10:42 +0300718 }
719 }
720
721 return 0;
722}
723
Tomi Valkeinenccd7b5e2014-11-14 15:18:28 +0200724static int omap_drm_suspend(struct device *dev)
725{
Laurent Pincharta82f03472018-02-13 14:00:19 +0200726 struct omap_drm_private *priv = dev_get_drvdata(dev);
727 struct drm_device *drm_dev = priv->ddev;
Tomi Valkeinenccd7b5e2014-11-14 15:18:28 +0200728
729 drm_kms_helper_poll_disable(drm_dev);
730
Tomi Valkeinen92bf0f92015-10-02 11:10:42 +0300731 drm_modeset_lock_all(drm_dev);
Peter Ujfalusi52b9ef22018-02-12 11:44:37 +0200732 omap_drm_suspend_all_displays(drm_dev);
Tomi Valkeinen92bf0f92015-10-02 11:10:42 +0300733 drm_modeset_unlock_all(drm_dev);
734
Tomi Valkeinenccd7b5e2014-11-14 15:18:28 +0200735 return 0;
736}
737
738static int omap_drm_resume(struct device *dev)
739{
Laurent Pincharta82f03472018-02-13 14:00:19 +0200740 struct omap_drm_private *priv = dev_get_drvdata(dev);
741 struct drm_device *drm_dev = priv->ddev;
Tomi Valkeinenccd7b5e2014-11-14 15:18:28 +0200742
Tomi Valkeinen92bf0f92015-10-02 11:10:42 +0300743 drm_modeset_lock_all(drm_dev);
Peter Ujfalusi52b9ef22018-02-12 11:44:37 +0200744 omap_drm_resume_all_displays(drm_dev);
Tomi Valkeinen92bf0f92015-10-02 11:10:42 +0300745 drm_modeset_unlock_all(drm_dev);
746
Tomi Valkeinenccd7b5e2014-11-14 15:18:28 +0200747 drm_kms_helper_poll_enable(drm_dev);
748
Laurent Pinchart7fb15c42017-10-13 17:58:58 +0300749 return omap_gem_resume(drm_dev);
Tomi Valkeinenccd7b5e2014-11-14 15:18:28 +0200750}
Andy Grosse78edba2012-12-19 14:53:37 -0600751#endif
752
Grygorii Strashko8450c8d2015-02-26 15:57:17 +0200753static SIMPLE_DEV_PM_OPS(omapdrm_pm_ops, omap_drm_suspend, omap_drm_resume);
754
Tomi Valkeinen6717cd22013-04-10 10:44:00 +0300755static struct platform_driver pdev = {
Laurent Pinchart222025e2015-01-11 00:02:07 +0200756 .driver = {
Tomi Valkeinenf64eafa2017-08-16 12:43:55 +0300757 .name = "omapdrm",
Laurent Pinchart222025e2015-01-11 00:02:07 +0200758 .pm = &omapdrm_pm_ops,
Laurent Pinchart222025e2015-01-11 00:02:07 +0200759 },
760 .probe = pdev_probe,
761 .remove = pdev_remove,
Rob Clarkcd5351f2011-11-12 12:09:40 -0600762};
763
Thierry Redinge1c49bd2015-12-02 17:23:31 +0100764static struct platform_driver * const drivers[] = {
765 &omap_dmm_driver,
766 &pdev,
767};
768
Rob Clarkcd5351f2011-11-12 12:09:40 -0600769static int __init omap_drm_init(void)
770{
771 DBG("init");
Tomi Valkeinenea7e3a62014-04-02 14:31:50 +0300772
Thierry Redinge1c49bd2015-12-02 17:23:31 +0100773 return platform_register_drivers(drivers, ARRAY_SIZE(drivers));
Rob Clarkcd5351f2011-11-12 12:09:40 -0600774}
775
776static void __exit omap_drm_fini(void)
777{
778 DBG("fini");
Tomi Valkeinenea7e3a62014-04-02 14:31:50 +0300779
Thierry Redinge1c49bd2015-12-02 17:23:31 +0100780 platform_unregister_drivers(drivers, ARRAY_SIZE(drivers));
Rob Clarkcd5351f2011-11-12 12:09:40 -0600781}
782
783/* need late_initcall() so we load after dss_driver's are loaded */
784late_initcall(omap_drm_init);
785module_exit(omap_drm_fini);
786
787MODULE_AUTHOR("Rob Clark <rob@ti.com>");
788MODULE_DESCRIPTION("OMAP DRM Display Driver");
789MODULE_ALIAS("platform:" DRIVER_NAME);
790MODULE_LICENSE("GPL v2");