Rob Clark | c8afe68 | 2013-06-26 12:44:06 -0400 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2013 Red Hat |
| 3 | * Author: Rob Clark <robdclark@gmail.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 | |
| 18 | #include "msm_drv.h" |
Rob Clark | edcd60c | 2016-03-16 12:56:12 -0400 | [diff] [blame] | 19 | #include "msm_debugfs.h" |
Rob Clark | fde5de6 | 2016-03-15 15:35:08 -0400 | [diff] [blame] | 20 | #include "msm_fence.h" |
Rob Clark | 7198e6b | 2013-07-19 12:59:32 -0400 | [diff] [blame] | 21 | #include "msm_gpu.h" |
Rob Clark | dd2da6e | 2013-11-30 16:12:10 -0500 | [diff] [blame] | 22 | #include "msm_kms.h" |
Rob Clark | c8afe68 | 2013-06-26 12:44:06 -0400 | [diff] [blame] | 23 | |
Rob Clark | a8d854c | 2016-06-01 14:02:02 -0400 | [diff] [blame] | 24 | |
| 25 | /* |
| 26 | * MSM driver version: |
| 27 | * - 1.0.0 - initial interface |
| 28 | * - 1.1.0 - adds madvise, and support for submits with > 4 cmd buffers |
Rob Clark | 7a3bcc0 | 2016-09-16 18:37:44 -0400 | [diff] [blame] | 29 | * - 1.2.0 - adds explicit fence support for submit ioctl |
Rob Clark | a8d854c | 2016-06-01 14:02:02 -0400 | [diff] [blame] | 30 | */ |
| 31 | #define MSM_VERSION_MAJOR 1 |
Rob Clark | 7a3bcc0 | 2016-09-16 18:37:44 -0400 | [diff] [blame] | 32 | #define MSM_VERSION_MINOR 2 |
Rob Clark | a8d854c | 2016-06-01 14:02:02 -0400 | [diff] [blame] | 33 | #define MSM_VERSION_PATCHLEVEL 0 |
| 34 | |
Rob Clark | c8afe68 | 2013-06-26 12:44:06 -0400 | [diff] [blame] | 35 | static void msm_fb_output_poll_changed(struct drm_device *dev) |
| 36 | { |
| 37 | struct msm_drm_private *priv = dev->dev_private; |
| 38 | if (priv->fbdev) |
| 39 | drm_fb_helper_hotplug_event(priv->fbdev); |
| 40 | } |
| 41 | |
| 42 | static const struct drm_mode_config_funcs mode_config_funcs = { |
| 43 | .fb_create = msm_framebuffer_create, |
| 44 | .output_poll_changed = msm_fb_output_poll_changed, |
Daniel Vetter | b4274fb | 2014-11-26 17:02:18 +0100 | [diff] [blame] | 45 | .atomic_check = msm_atomic_check, |
Rob Clark | cf3a7e4 | 2014-11-08 13:21:06 -0500 | [diff] [blame] | 46 | .atomic_commit = msm_atomic_commit, |
Rob Clark | c8afe68 | 2013-06-26 12:44:06 -0400 | [diff] [blame] | 47 | }; |
| 48 | |
Rob Clark | 871d812 | 2013-11-16 12:56:06 -0500 | [diff] [blame] | 49 | int msm_register_mmu(struct drm_device *dev, struct msm_mmu *mmu) |
Rob Clark | c8afe68 | 2013-06-26 12:44:06 -0400 | [diff] [blame] | 50 | { |
| 51 | struct msm_drm_private *priv = dev->dev_private; |
Rob Clark | 871d812 | 2013-11-16 12:56:06 -0500 | [diff] [blame] | 52 | int idx = priv->num_mmus++; |
Rob Clark | c8afe68 | 2013-06-26 12:44:06 -0400 | [diff] [blame] | 53 | |
Rob Clark | 871d812 | 2013-11-16 12:56:06 -0500 | [diff] [blame] | 54 | if (WARN_ON(idx >= ARRAY_SIZE(priv->mmus))) |
Rob Clark | c8afe68 | 2013-06-26 12:44:06 -0400 | [diff] [blame] | 55 | return -EINVAL; |
| 56 | |
Rob Clark | 871d812 | 2013-11-16 12:56:06 -0500 | [diff] [blame] | 57 | priv->mmus[idx] = mmu; |
Rob Clark | c8afe68 | 2013-06-26 12:44:06 -0400 | [diff] [blame] | 58 | |
| 59 | return idx; |
| 60 | } |
| 61 | |
Rob Clark | c8afe68 | 2013-06-26 12:44:06 -0400 | [diff] [blame] | 62 | #ifdef CONFIG_DRM_MSM_REGISTER_LOGGING |
| 63 | static bool reglog = false; |
| 64 | MODULE_PARM_DESC(reglog, "Enable register read/write logging"); |
| 65 | module_param(reglog, bool, 0600); |
| 66 | #else |
| 67 | #define reglog 0 |
| 68 | #endif |
| 69 | |
Archit Taneja | a9ee34b | 2015-07-13 12:12:07 +0530 | [diff] [blame] | 70 | #ifdef CONFIG_DRM_FBDEV_EMULATION |
Rob Clark | e90dfec | 2015-01-30 17:05:41 -0500 | [diff] [blame] | 71 | static bool fbdev = true; |
| 72 | MODULE_PARM_DESC(fbdev, "Enable fbdev compat layer"); |
| 73 | module_param(fbdev, bool, 0600); |
| 74 | #endif |
| 75 | |
Rob Clark | 3a10ba8 | 2014-09-08 14:24:57 -0400 | [diff] [blame] | 76 | static char *vram = "16m"; |
Rob Clark | 4313c74 | 2016-02-03 14:02:04 -0500 | [diff] [blame] | 77 | MODULE_PARM_DESC(vram, "Configure VRAM size (for devices without IOMMU/GPUMMU)"); |
Rob Clark | 871d812 | 2013-11-16 12:56:06 -0500 | [diff] [blame] | 78 | module_param(vram, charp, 0); |
| 79 | |
Rob Clark | 060530f | 2014-03-03 14:19:12 -0500 | [diff] [blame] | 80 | /* |
| 81 | * Util/helpers: |
| 82 | */ |
| 83 | |
Rob Clark | c8afe68 | 2013-06-26 12:44:06 -0400 | [diff] [blame] | 84 | void __iomem *msm_ioremap(struct platform_device *pdev, const char *name, |
| 85 | const char *dbgname) |
| 86 | { |
| 87 | struct resource *res; |
| 88 | unsigned long size; |
| 89 | void __iomem *ptr; |
| 90 | |
| 91 | if (name) |
| 92 | res = platform_get_resource_byname(pdev, IORESOURCE_MEM, name); |
| 93 | else |
| 94 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); |
| 95 | |
| 96 | if (!res) { |
| 97 | dev_err(&pdev->dev, "failed to get memory resource: %s\n", name); |
| 98 | return ERR_PTR(-EINVAL); |
| 99 | } |
| 100 | |
| 101 | size = resource_size(res); |
| 102 | |
| 103 | ptr = devm_ioremap_nocache(&pdev->dev, res->start, size); |
| 104 | if (!ptr) { |
| 105 | dev_err(&pdev->dev, "failed to ioremap: %s\n", name); |
| 106 | return ERR_PTR(-ENOMEM); |
| 107 | } |
| 108 | |
| 109 | if (reglog) |
Thierry Reding | fc99f97 | 2015-04-09 16:39:51 +0200 | [diff] [blame] | 110 | printk(KERN_DEBUG "IO:region %s %p %08lx\n", dbgname, ptr, size); |
Rob Clark | c8afe68 | 2013-06-26 12:44:06 -0400 | [diff] [blame] | 111 | |
| 112 | return ptr; |
| 113 | } |
| 114 | |
| 115 | void msm_writel(u32 data, void __iomem *addr) |
| 116 | { |
| 117 | if (reglog) |
Thierry Reding | fc99f97 | 2015-04-09 16:39:51 +0200 | [diff] [blame] | 118 | printk(KERN_DEBUG "IO:W %p %08x\n", addr, data); |
Rob Clark | c8afe68 | 2013-06-26 12:44:06 -0400 | [diff] [blame] | 119 | writel(data, addr); |
| 120 | } |
| 121 | |
| 122 | u32 msm_readl(const void __iomem *addr) |
| 123 | { |
| 124 | u32 val = readl(addr); |
| 125 | if (reglog) |
Thierry Reding | fc99f97 | 2015-04-09 16:39:51 +0200 | [diff] [blame] | 126 | printk(KERN_ERR "IO:R %p %08x\n", addr, val); |
Rob Clark | c8afe68 | 2013-06-26 12:44:06 -0400 | [diff] [blame] | 127 | return val; |
| 128 | } |
| 129 | |
Hai Li | 78b1d47 | 2015-07-27 13:49:45 -0400 | [diff] [blame] | 130 | struct vblank_event { |
| 131 | struct list_head node; |
| 132 | int crtc_id; |
| 133 | bool enable; |
| 134 | }; |
| 135 | |
| 136 | static void vblank_ctrl_worker(struct work_struct *work) |
| 137 | { |
| 138 | struct msm_vblank_ctrl *vbl_ctrl = container_of(work, |
| 139 | struct msm_vblank_ctrl, work); |
| 140 | struct msm_drm_private *priv = container_of(vbl_ctrl, |
| 141 | struct msm_drm_private, vblank_ctrl); |
| 142 | struct msm_kms *kms = priv->kms; |
| 143 | struct vblank_event *vbl_ev, *tmp; |
| 144 | unsigned long flags; |
| 145 | |
| 146 | spin_lock_irqsave(&vbl_ctrl->lock, flags); |
| 147 | list_for_each_entry_safe(vbl_ev, tmp, &vbl_ctrl->event_list, node) { |
| 148 | list_del(&vbl_ev->node); |
| 149 | spin_unlock_irqrestore(&vbl_ctrl->lock, flags); |
| 150 | |
| 151 | if (vbl_ev->enable) |
| 152 | kms->funcs->enable_vblank(kms, |
| 153 | priv->crtcs[vbl_ev->crtc_id]); |
| 154 | else |
| 155 | kms->funcs->disable_vblank(kms, |
| 156 | priv->crtcs[vbl_ev->crtc_id]); |
| 157 | |
| 158 | kfree(vbl_ev); |
| 159 | |
| 160 | spin_lock_irqsave(&vbl_ctrl->lock, flags); |
| 161 | } |
| 162 | |
| 163 | spin_unlock_irqrestore(&vbl_ctrl->lock, flags); |
| 164 | } |
| 165 | |
| 166 | static int vblank_ctrl_queue_work(struct msm_drm_private *priv, |
| 167 | int crtc_id, bool enable) |
| 168 | { |
| 169 | struct msm_vblank_ctrl *vbl_ctrl = &priv->vblank_ctrl; |
| 170 | struct vblank_event *vbl_ev; |
| 171 | unsigned long flags; |
| 172 | |
| 173 | vbl_ev = kzalloc(sizeof(*vbl_ev), GFP_ATOMIC); |
| 174 | if (!vbl_ev) |
| 175 | return -ENOMEM; |
| 176 | |
| 177 | vbl_ev->crtc_id = crtc_id; |
| 178 | vbl_ev->enable = enable; |
| 179 | |
| 180 | spin_lock_irqsave(&vbl_ctrl->lock, flags); |
| 181 | list_add_tail(&vbl_ev->node, &vbl_ctrl->event_list); |
| 182 | spin_unlock_irqrestore(&vbl_ctrl->lock, flags); |
| 183 | |
| 184 | queue_work(priv->wq, &vbl_ctrl->work); |
| 185 | |
| 186 | return 0; |
| 187 | } |
| 188 | |
Archit Taneja | 2b66987 | 2016-05-02 11:05:54 +0530 | [diff] [blame] | 189 | static int msm_drm_uninit(struct device *dev) |
Rob Clark | c8afe68 | 2013-06-26 12:44:06 -0400 | [diff] [blame] | 190 | { |
Archit Taneja | 2b66987 | 2016-05-02 11:05:54 +0530 | [diff] [blame] | 191 | struct platform_device *pdev = to_platform_device(dev); |
| 192 | struct drm_device *ddev = platform_get_drvdata(pdev); |
| 193 | struct msm_drm_private *priv = ddev->dev_private; |
Rob Clark | c8afe68 | 2013-06-26 12:44:06 -0400 | [diff] [blame] | 194 | struct msm_kms *kms = priv->kms; |
Rob Clark | 7198e6b | 2013-07-19 12:59:32 -0400 | [diff] [blame] | 195 | struct msm_gpu *gpu = priv->gpu; |
Hai Li | 78b1d47 | 2015-07-27 13:49:45 -0400 | [diff] [blame] | 196 | struct msm_vblank_ctrl *vbl_ctrl = &priv->vblank_ctrl; |
| 197 | struct vblank_event *vbl_ev, *tmp; |
| 198 | |
| 199 | /* We must cancel and cleanup any pending vblank enable/disable |
| 200 | * work before drm_irq_uninstall() to avoid work re-enabling an |
| 201 | * irq after uninstall has disabled it. |
| 202 | */ |
| 203 | cancel_work_sync(&vbl_ctrl->work); |
| 204 | list_for_each_entry_safe(vbl_ev, tmp, &vbl_ctrl->event_list, node) { |
| 205 | list_del(&vbl_ev->node); |
| 206 | kfree(vbl_ev); |
| 207 | } |
Rob Clark | c8afe68 | 2013-06-26 12:44:06 -0400 | [diff] [blame] | 208 | |
Rob Clark | 6820939 | 2016-05-17 16:19:32 -0400 | [diff] [blame] | 209 | msm_gem_shrinker_cleanup(ddev); |
| 210 | |
Archit Taneja | 2b66987 | 2016-05-02 11:05:54 +0530 | [diff] [blame] | 211 | drm_kms_helper_poll_fini(ddev); |
Archit Taneja | 1aaa57f | 2016-02-25 11:19:45 +0530 | [diff] [blame] | 212 | |
Archit Taneja | 2b66987 | 2016-05-02 11:05:54 +0530 | [diff] [blame] | 213 | drm_dev_unregister(ddev); |
Archit Taneja | 8208ed9 | 2016-05-02 11:05:53 +0530 | [diff] [blame] | 214 | |
Archit Taneja | 1aaa57f | 2016-02-25 11:19:45 +0530 | [diff] [blame] | 215 | #ifdef CONFIG_DRM_FBDEV_EMULATION |
| 216 | if (fbdev && priv->fbdev) |
Archit Taneja | 2b66987 | 2016-05-02 11:05:54 +0530 | [diff] [blame] | 217 | msm_fbdev_free(ddev); |
Archit Taneja | 1aaa57f | 2016-02-25 11:19:45 +0530 | [diff] [blame] | 218 | #endif |
Archit Taneja | 2b66987 | 2016-05-02 11:05:54 +0530 | [diff] [blame] | 219 | drm_mode_config_cleanup(ddev); |
Rob Clark | c8afe68 | 2013-06-26 12:44:06 -0400 | [diff] [blame] | 220 | |
Archit Taneja | 2b66987 | 2016-05-02 11:05:54 +0530 | [diff] [blame] | 221 | pm_runtime_get_sync(dev); |
| 222 | drm_irq_uninstall(ddev); |
| 223 | pm_runtime_put_sync(dev); |
Rob Clark | c8afe68 | 2013-06-26 12:44:06 -0400 | [diff] [blame] | 224 | |
| 225 | flush_workqueue(priv->wq); |
| 226 | destroy_workqueue(priv->wq); |
| 227 | |
Rob Clark | ba00c3f | 2016-03-16 18:18:17 -0400 | [diff] [blame] | 228 | flush_workqueue(priv->atomic_wq); |
| 229 | destroy_workqueue(priv->atomic_wq); |
| 230 | |
Archit Taneja | 1697608 | 2016-11-03 17:36:18 +0530 | [diff] [blame] | 231 | if (kms && kms->funcs) |
Rob Clark | c8afe68 | 2013-06-26 12:44:06 -0400 | [diff] [blame] | 232 | kms->funcs->destroy(kms); |
Rob Clark | c8afe68 | 2013-06-26 12:44:06 -0400 | [diff] [blame] | 233 | |
Rob Clark | 7198e6b | 2013-07-19 12:59:32 -0400 | [diff] [blame] | 234 | if (gpu) { |
Archit Taneja | 2b66987 | 2016-05-02 11:05:54 +0530 | [diff] [blame] | 235 | mutex_lock(&ddev->struct_mutex); |
Rob Clark | 7198e6b | 2013-07-19 12:59:32 -0400 | [diff] [blame] | 236 | gpu->funcs->pm_suspend(gpu); |
Archit Taneja | 2b66987 | 2016-05-02 11:05:54 +0530 | [diff] [blame] | 237 | mutex_unlock(&ddev->struct_mutex); |
Rob Clark | 774449e | 2015-05-15 09:19:36 -0400 | [diff] [blame] | 238 | gpu->funcs->destroy(gpu); |
Rob Clark | 7198e6b | 2013-07-19 12:59:32 -0400 | [diff] [blame] | 239 | } |
Rob Clark | c8afe68 | 2013-06-26 12:44:06 -0400 | [diff] [blame] | 240 | |
Rob Clark | 871d812 | 2013-11-16 12:56:06 -0500 | [diff] [blame] | 241 | if (priv->vram.paddr) { |
Krzysztof Kozlowski | 00085f1 | 2016-08-03 13:46:00 -0700 | [diff] [blame] | 242 | unsigned long attrs = DMA_ATTR_NO_KERNEL_MAPPING; |
Rob Clark | 871d812 | 2013-11-16 12:56:06 -0500 | [diff] [blame] | 243 | drm_mm_takedown(&priv->vram.mm); |
Archit Taneja | 2b66987 | 2016-05-02 11:05:54 +0530 | [diff] [blame] | 244 | dma_free_attrs(dev, priv->vram.size, NULL, |
Krzysztof Kozlowski | 00085f1 | 2016-08-03 13:46:00 -0700 | [diff] [blame] | 245 | priv->vram.paddr, attrs); |
Rob Clark | 871d812 | 2013-11-16 12:56:06 -0500 | [diff] [blame] | 246 | } |
| 247 | |
Archit Taneja | 2b66987 | 2016-05-02 11:05:54 +0530 | [diff] [blame] | 248 | component_unbind_all(dev, ddev); |
Rob Clark | 060530f | 2014-03-03 14:19:12 -0500 | [diff] [blame] | 249 | |
Archit Taneja | 0a6030d | 2016-05-08 21:36:28 +0530 | [diff] [blame] | 250 | msm_mdss_destroy(ddev); |
| 251 | |
Archit Taneja | 2b66987 | 2016-05-02 11:05:54 +0530 | [diff] [blame] | 252 | ddev->dev_private = NULL; |
| 253 | drm_dev_unref(ddev); |
Rob Clark | c8afe68 | 2013-06-26 12:44:06 -0400 | [diff] [blame] | 254 | |
| 255 | kfree(priv); |
| 256 | |
| 257 | return 0; |
| 258 | } |
| 259 | |
Narendra Muppalla | 1b0b335 | 2015-09-29 10:16:51 -0700 | [diff] [blame] | 260 | #define KMS_MDP4 0 |
| 261 | #define KMS_MDP5 1 |
| 262 | #define KMS_SDE 2 |
| 263 | |
Rob Clark | 06c0dd9 | 2013-11-30 17:51:47 -0500 | [diff] [blame] | 264 | static int get_mdp_ver(struct platform_device *pdev) |
| 265 | { |
Narendra Muppalla | 1b0b335 | 2015-09-29 10:16:51 -0700 | [diff] [blame] | 266 | #ifdef CONFIG_OF |
| 267 | static const struct of_device_id match_types[] = { { |
| 268 | .compatible = "qcom,mdss_mdp", |
| 269 | .data = (void *)KMS_MDP5, |
| 270 | }, |
| 271 | { |
| 272 | .compatible = "qcom,sde-kms", |
| 273 | .data = (void *)KMS_SDE, |
| 274 | /* end node */ |
| 275 | } }; |
Rob Clark | 06c0dd9 | 2013-11-30 17:51:47 -0500 | [diff] [blame] | 276 | struct device *dev = &pdev->dev; |
Narendra Muppalla | 1b0b335 | 2015-09-29 10:16:51 -0700 | [diff] [blame] | 277 | const struct of_device_id *match; |
Archit Taneja | e9fbdaf | 2015-11-18 12:15:14 +0530 | [diff] [blame] | 278 | |
Narendra Muppalla | 1b0b335 | 2015-09-29 10:16:51 -0700 | [diff] [blame] | 279 | match = of_match_node(match_types, dev->of_node); |
| 280 | if (match) |
| 281 | return (int)(unsigned long)match->data; |
| 282 | #endif |
| 283 | return KMS_MDP4; |
Rob Clark | 06c0dd9 | 2013-11-30 17:51:47 -0500 | [diff] [blame] | 284 | } |
| 285 | |
Rob Clark | 072f1f9 | 2015-03-03 15:04:25 -0500 | [diff] [blame] | 286 | #include <linux/of_address.h> |
| 287 | |
Rob Clark | 5bf9c0b | 2015-03-03 15:04:24 -0500 | [diff] [blame] | 288 | static int msm_init_vram(struct drm_device *dev) |
Rob Clark | c8afe68 | 2013-06-26 12:44:06 -0400 | [diff] [blame] | 289 | { |
Rob Clark | 5bf9c0b | 2015-03-03 15:04:24 -0500 | [diff] [blame] | 290 | struct msm_drm_private *priv = dev->dev_private; |
Archit Taneja | e9fbdaf | 2015-11-18 12:15:14 +0530 | [diff] [blame] | 291 | struct device_node *node; |
Rob Clark | 072f1f9 | 2015-03-03 15:04:25 -0500 | [diff] [blame] | 292 | unsigned long size = 0; |
| 293 | int ret = 0; |
| 294 | |
Rob Clark | 072f1f9 | 2015-03-03 15:04:25 -0500 | [diff] [blame] | 295 | /* In the device-tree world, we could have a 'memory-region' |
| 296 | * phandle, which gives us a link to our "vram". Allocating |
| 297 | * is all nicely abstracted behind the dma api, but we need |
| 298 | * to know the entire size to allocate it all in one go. There |
| 299 | * are two cases: |
| 300 | * 1) device with no IOMMU, in which case we need exclusive |
| 301 | * access to a VRAM carveout big enough for all gpu |
| 302 | * buffers |
| 303 | * 2) device with IOMMU, but where the bootloader puts up |
| 304 | * a splash screen. In this case, the VRAM carveout |
| 305 | * need only be large enough for fbdev fb. But we need |
| 306 | * exclusive access to the buffer to avoid the kernel |
| 307 | * using those pages for other purposes (which appears |
| 308 | * as corruption on screen before we have a chance to |
| 309 | * load and do initial modeset) |
| 310 | */ |
Rob Clark | 072f1f9 | 2015-03-03 15:04:25 -0500 | [diff] [blame] | 311 | |
| 312 | node = of_parse_phandle(dev->dev->of_node, "memory-region", 0); |
| 313 | if (node) { |
| 314 | struct resource r; |
| 315 | ret = of_address_to_resource(node, 0, &r); |
Peter Chen | 2ca41c17 | 2016-07-04 16:49:50 +0800 | [diff] [blame] | 316 | of_node_put(node); |
Rob Clark | 072f1f9 | 2015-03-03 15:04:25 -0500 | [diff] [blame] | 317 | if (ret) |
| 318 | return ret; |
| 319 | size = r.end - r.start; |
Thierry Reding | fc99f97 | 2015-04-09 16:39:51 +0200 | [diff] [blame] | 320 | DRM_INFO("using VRAM carveout: %lx@%pa\n", size, &r.start); |
Rob Clark | c8afe68 | 2013-06-26 12:44:06 -0400 | [diff] [blame] | 321 | |
Archit Taneja | e9fbdaf | 2015-11-18 12:15:14 +0530 | [diff] [blame] | 322 | /* if we have no IOMMU, then we need to use carveout allocator. |
| 323 | * Grab the entire CMA chunk carved out in early startup in |
| 324 | * mach-msm: |
| 325 | */ |
| 326 | } else if (!iommu_present(&platform_bus_type)) { |
Rob Clark | 072f1f9 | 2015-03-03 15:04:25 -0500 | [diff] [blame] | 327 | DRM_INFO("using %s VRAM carveout\n", vram); |
| 328 | size = memparse(vram, NULL); |
| 329 | } |
| 330 | |
| 331 | if (size) { |
Krzysztof Kozlowski | 00085f1 | 2016-08-03 13:46:00 -0700 | [diff] [blame] | 332 | unsigned long attrs = 0; |
Rob Clark | 871d812 | 2013-11-16 12:56:06 -0500 | [diff] [blame] | 333 | void *p; |
| 334 | |
Rob Clark | 871d812 | 2013-11-16 12:56:06 -0500 | [diff] [blame] | 335 | priv->vram.size = size; |
| 336 | |
| 337 | drm_mm_init(&priv->vram.mm, 0, (size >> PAGE_SHIFT) - 1); |
| 338 | |
Krzysztof Kozlowski | 00085f1 | 2016-08-03 13:46:00 -0700 | [diff] [blame] | 339 | attrs |= DMA_ATTR_NO_KERNEL_MAPPING; |
| 340 | attrs |= DMA_ATTR_WRITE_COMBINE; |
Rob Clark | 871d812 | 2013-11-16 12:56:06 -0500 | [diff] [blame] | 341 | |
| 342 | /* note that for no-kernel-mapping, the vaddr returned |
| 343 | * is bogus, but non-null if allocation succeeded: |
| 344 | */ |
| 345 | p = dma_alloc_attrs(dev->dev, size, |
Krzysztof Kozlowski | 00085f1 | 2016-08-03 13:46:00 -0700 | [diff] [blame] | 346 | &priv->vram.paddr, GFP_KERNEL, attrs); |
Rob Clark | 871d812 | 2013-11-16 12:56:06 -0500 | [diff] [blame] | 347 | if (!p) { |
| 348 | dev_err(dev->dev, "failed to allocate VRAM\n"); |
| 349 | priv->vram.paddr = 0; |
Rob Clark | 5bf9c0b | 2015-03-03 15:04:24 -0500 | [diff] [blame] | 350 | return -ENOMEM; |
Rob Clark | 871d812 | 2013-11-16 12:56:06 -0500 | [diff] [blame] | 351 | } |
| 352 | |
| 353 | dev_info(dev->dev, "VRAM: %08x->%08x\n", |
| 354 | (uint32_t)priv->vram.paddr, |
| 355 | (uint32_t)(priv->vram.paddr + size)); |
| 356 | } |
| 357 | |
Rob Clark | 072f1f9 | 2015-03-03 15:04:25 -0500 | [diff] [blame] | 358 | return ret; |
Rob Clark | 5bf9c0b | 2015-03-03 15:04:24 -0500 | [diff] [blame] | 359 | } |
| 360 | |
Archit Taneja | 2b66987 | 2016-05-02 11:05:54 +0530 | [diff] [blame] | 361 | static int msm_drm_init(struct device *dev, struct drm_driver *drv) |
Rob Clark | 5bf9c0b | 2015-03-03 15:04:24 -0500 | [diff] [blame] | 362 | { |
Archit Taneja | 2b66987 | 2016-05-02 11:05:54 +0530 | [diff] [blame] | 363 | struct platform_device *pdev = to_platform_device(dev); |
| 364 | struct drm_device *ddev; |
Rob Clark | 5bf9c0b | 2015-03-03 15:04:24 -0500 | [diff] [blame] | 365 | struct msm_drm_private *priv; |
| 366 | struct msm_kms *kms; |
| 367 | int ret; |
| 368 | |
Archit Taneja | 2b66987 | 2016-05-02 11:05:54 +0530 | [diff] [blame] | 369 | ddev = drm_dev_alloc(drv, dev); |
Tom Gundersen | 0f28860 | 2016-09-21 16:59:19 +0200 | [diff] [blame] | 370 | if (IS_ERR(ddev)) { |
Archit Taneja | 2b66987 | 2016-05-02 11:05:54 +0530 | [diff] [blame] | 371 | dev_err(dev, "failed to allocate drm_device\n"); |
Tom Gundersen | 0f28860 | 2016-09-21 16:59:19 +0200 | [diff] [blame] | 372 | return PTR_ERR(ddev); |
Rob Clark | 5bf9c0b | 2015-03-03 15:04:24 -0500 | [diff] [blame] | 373 | } |
| 374 | |
Archit Taneja | 2b66987 | 2016-05-02 11:05:54 +0530 | [diff] [blame] | 375 | platform_set_drvdata(pdev, ddev); |
| 376 | ddev->platformdev = pdev; |
| 377 | |
| 378 | priv = kzalloc(sizeof(*priv), GFP_KERNEL); |
| 379 | if (!priv) { |
| 380 | drm_dev_unref(ddev); |
| 381 | return -ENOMEM; |
| 382 | } |
| 383 | |
| 384 | ddev->dev_private = priv; |
Rob Clark | 6820939 | 2016-05-17 16:19:32 -0400 | [diff] [blame] | 385 | priv->dev = ddev; |
Rob Clark | 5bf9c0b | 2015-03-03 15:04:24 -0500 | [diff] [blame] | 386 | |
Archit Taneja | 0a6030d | 2016-05-08 21:36:28 +0530 | [diff] [blame] | 387 | ret = msm_mdss_init(ddev); |
| 388 | if (ret) { |
| 389 | kfree(priv); |
| 390 | drm_dev_unref(ddev); |
| 391 | return ret; |
| 392 | } |
| 393 | |
Rob Clark | 5bf9c0b | 2015-03-03 15:04:24 -0500 | [diff] [blame] | 394 | priv->wq = alloc_ordered_workqueue("msm", 0); |
Rob Clark | ba00c3f | 2016-03-16 18:18:17 -0400 | [diff] [blame] | 395 | priv->atomic_wq = alloc_ordered_workqueue("msm:atomic", 0); |
Rob Clark | 5bf9c0b | 2015-03-03 15:04:24 -0500 | [diff] [blame] | 396 | init_waitqueue_head(&priv->pending_crtcs_event); |
| 397 | |
| 398 | INIT_LIST_HEAD(&priv->inactive_list); |
Hai Li | 78b1d47 | 2015-07-27 13:49:45 -0400 | [diff] [blame] | 399 | INIT_LIST_HEAD(&priv->vblank_ctrl.event_list); |
| 400 | INIT_WORK(&priv->vblank_ctrl.work, vblank_ctrl_worker); |
| 401 | spin_lock_init(&priv->vblank_ctrl.lock); |
Rob Clark | 5bf9c0b | 2015-03-03 15:04:24 -0500 | [diff] [blame] | 402 | |
Archit Taneja | 2b66987 | 2016-05-02 11:05:54 +0530 | [diff] [blame] | 403 | drm_mode_config_init(ddev); |
Rob Clark | 060530f | 2014-03-03 14:19:12 -0500 | [diff] [blame] | 404 | |
| 405 | /* Bind all our sub-components: */ |
Archit Taneja | 2b66987 | 2016-05-02 11:05:54 +0530 | [diff] [blame] | 406 | ret = component_bind_all(dev, ddev); |
| 407 | if (ret) { |
Archit Taneja | 0a6030d | 2016-05-08 21:36:28 +0530 | [diff] [blame] | 408 | msm_mdss_destroy(ddev); |
Archit Taneja | 2b66987 | 2016-05-02 11:05:54 +0530 | [diff] [blame] | 409 | kfree(priv); |
| 410 | drm_dev_unref(ddev); |
Rob Clark | 060530f | 2014-03-03 14:19:12 -0500 | [diff] [blame] | 411 | return ret; |
Archit Taneja | 2b66987 | 2016-05-02 11:05:54 +0530 | [diff] [blame] | 412 | } |
Rob Clark | 060530f | 2014-03-03 14:19:12 -0500 | [diff] [blame] | 413 | |
Archit Taneja | 2b66987 | 2016-05-02 11:05:54 +0530 | [diff] [blame] | 414 | ret = msm_init_vram(ddev); |
Rob Clark | 13f1556 | 2015-05-07 15:20:13 -0400 | [diff] [blame] | 415 | if (ret) |
| 416 | goto fail; |
| 417 | |
Rob Clark | 6820939 | 2016-05-17 16:19:32 -0400 | [diff] [blame] | 418 | msm_gem_shrinker_init(ddev); |
| 419 | |
Rob Clark | 06c0dd9 | 2013-11-30 17:51:47 -0500 | [diff] [blame] | 420 | switch (get_mdp_ver(pdev)) { |
Narendra Muppalla | 1b0b335 | 2015-09-29 10:16:51 -0700 | [diff] [blame] | 421 | case KMS_MDP4: |
| 422 | kms = mdp4_kms_init(dev); |
Rob Clark | 06c0dd9 | 2013-11-30 17:51:47 -0500 | [diff] [blame] | 423 | break; |
Narendra Muppalla | 1b0b335 | 2015-09-29 10:16:51 -0700 | [diff] [blame] | 424 | case KMS_MDP5: |
| 425 | kms = mdp5_kms_init(dev); |
| 426 | break; |
| 427 | case KMS_SDE: |
| 428 | kms = sde_kms_init(dev); |
Rob Clark | 06c0dd9 | 2013-11-30 17:51:47 -0500 | [diff] [blame] | 429 | break; |
| 430 | default: |
| 431 | kms = ERR_PTR(-ENODEV); |
| 432 | break; |
| 433 | } |
| 434 | |
Rob Clark | c8afe68 | 2013-06-26 12:44:06 -0400 | [diff] [blame] | 435 | if (IS_ERR(kms)) { |
| 436 | /* |
| 437 | * NOTE: once we have GPU support, having no kms should not |
| 438 | * be considered fatal.. ideally we would still support gpu |
| 439 | * and (for example) use dmabuf/prime to share buffers with |
| 440 | * imx drm driver on iMX5 |
| 441 | */ |
Archit Taneja | 2b66987 | 2016-05-02 11:05:54 +0530 | [diff] [blame] | 442 | dev_err(dev, "failed to load kms\n"); |
Thomas Meyer | e4826a9 | 2013-09-16 23:19:54 +0200 | [diff] [blame] | 443 | ret = PTR_ERR(kms); |
Rob Clark | c8afe68 | 2013-06-26 12:44:06 -0400 | [diff] [blame] | 444 | goto fail; |
| 445 | } |
| 446 | |
Rob Clark | c8afe68 | 2013-06-26 12:44:06 -0400 | [diff] [blame] | 447 | if (kms) { |
Rob Clark | c8afe68 | 2013-06-26 12:44:06 -0400 | [diff] [blame] | 448 | ret = kms->funcs->hw_init(kms); |
| 449 | if (ret) { |
Archit Taneja | 2b66987 | 2016-05-02 11:05:54 +0530 | [diff] [blame] | 450 | dev_err(dev, "kms hw init failed: %d\n", ret); |
Rob Clark | c8afe68 | 2013-06-26 12:44:06 -0400 | [diff] [blame] | 451 | goto fail; |
| 452 | } |
| 453 | } |
| 454 | |
Archit Taneja | 2b66987 | 2016-05-02 11:05:54 +0530 | [diff] [blame] | 455 | ddev->mode_config.funcs = &mode_config_funcs; |
Rob Clark | c8afe68 | 2013-06-26 12:44:06 -0400 | [diff] [blame] | 456 | |
Archit Taneja | 2b66987 | 2016-05-02 11:05:54 +0530 | [diff] [blame] | 457 | ret = drm_vblank_init(ddev, priv->num_crtcs); |
Rob Clark | c8afe68 | 2013-06-26 12:44:06 -0400 | [diff] [blame] | 458 | if (ret < 0) { |
Archit Taneja | 2b66987 | 2016-05-02 11:05:54 +0530 | [diff] [blame] | 459 | dev_err(dev, "failed to initialize vblank\n"); |
Rob Clark | c8afe68 | 2013-06-26 12:44:06 -0400 | [diff] [blame] | 460 | goto fail; |
| 461 | } |
| 462 | |
Archit Taneja | a2b3a55 | 2016-05-18 15:06:03 +0530 | [diff] [blame] | 463 | if (kms) { |
| 464 | pm_runtime_get_sync(dev); |
| 465 | ret = drm_irq_install(ddev, kms->irq); |
| 466 | pm_runtime_put_sync(dev); |
| 467 | if (ret < 0) { |
| 468 | dev_err(dev, "failed to install IRQ handler\n"); |
| 469 | goto fail; |
| 470 | } |
Rob Clark | c8afe68 | 2013-06-26 12:44:06 -0400 | [diff] [blame] | 471 | } |
| 472 | |
Archit Taneja | 2b66987 | 2016-05-02 11:05:54 +0530 | [diff] [blame] | 473 | ret = drm_dev_register(ddev, 0); |
Rob Clark | a7d3c95 | 2014-05-30 14:47:38 -0400 | [diff] [blame] | 474 | if (ret) |
| 475 | goto fail; |
| 476 | |
Archit Taneja | 2b66987 | 2016-05-02 11:05:54 +0530 | [diff] [blame] | 477 | drm_mode_config_reset(ddev); |
| 478 | |
| 479 | #ifdef CONFIG_DRM_FBDEV_EMULATION |
| 480 | if (fbdev) |
| 481 | priv->fbdev = msm_fbdev_init(ddev); |
| 482 | #endif |
| 483 | |
| 484 | ret = msm_debugfs_late_init(ddev); |
| 485 | if (ret) |
| 486 | goto fail; |
| 487 | |
| 488 | drm_kms_helper_poll_init(ddev); |
Rob Clark | c8afe68 | 2013-06-26 12:44:06 -0400 | [diff] [blame] | 489 | |
| 490 | return 0; |
| 491 | |
| 492 | fail: |
Archit Taneja | 2b66987 | 2016-05-02 11:05:54 +0530 | [diff] [blame] | 493 | msm_drm_uninit(dev); |
Rob Clark | c8afe68 | 2013-06-26 12:44:06 -0400 | [diff] [blame] | 494 | return ret; |
| 495 | } |
| 496 | |
Archit Taneja | 2b66987 | 2016-05-02 11:05:54 +0530 | [diff] [blame] | 497 | /* |
| 498 | * DRM operations: |
| 499 | */ |
| 500 | |
Rob Clark | 7198e6b | 2013-07-19 12:59:32 -0400 | [diff] [blame] | 501 | static void load_gpu(struct drm_device *dev) |
| 502 | { |
Rob Clark | a1ad352 | 2014-07-11 11:59:22 -0400 | [diff] [blame] | 503 | static DEFINE_MUTEX(init_lock); |
Rob Clark | 7198e6b | 2013-07-19 12:59:32 -0400 | [diff] [blame] | 504 | struct msm_drm_private *priv = dev->dev_private; |
Rob Clark | 7198e6b | 2013-07-19 12:59:32 -0400 | [diff] [blame] | 505 | |
Rob Clark | a1ad352 | 2014-07-11 11:59:22 -0400 | [diff] [blame] | 506 | mutex_lock(&init_lock); |
Rob Clark | 7198e6b | 2013-07-19 12:59:32 -0400 | [diff] [blame] | 507 | |
Rob Clark | e2550b7 | 2014-09-05 13:30:27 -0400 | [diff] [blame] | 508 | if (!priv->gpu) |
| 509 | priv->gpu = adreno_load_gpu(dev); |
Rob Clark | a1ad352 | 2014-07-11 11:59:22 -0400 | [diff] [blame] | 510 | |
Rob Clark | a1ad352 | 2014-07-11 11:59:22 -0400 | [diff] [blame] | 511 | mutex_unlock(&init_lock); |
Rob Clark | 7198e6b | 2013-07-19 12:59:32 -0400 | [diff] [blame] | 512 | } |
| 513 | |
| 514 | static int msm_open(struct drm_device *dev, struct drm_file *file) |
| 515 | { |
| 516 | struct msm_file_private *ctx; |
| 517 | |
| 518 | /* For now, load gpu on open.. to avoid the requirement of having |
| 519 | * firmware in the initrd. |
| 520 | */ |
| 521 | load_gpu(dev); |
| 522 | |
| 523 | ctx = kzalloc(sizeof(*ctx), GFP_KERNEL); |
| 524 | if (!ctx) |
| 525 | return -ENOMEM; |
| 526 | |
| 527 | file->driver_priv = ctx; |
| 528 | |
| 529 | return 0; |
| 530 | } |
| 531 | |
Rob Clark | c8afe68 | 2013-06-26 12:44:06 -0400 | [diff] [blame] | 532 | static void msm_preclose(struct drm_device *dev, struct drm_file *file) |
| 533 | { |
| 534 | struct msm_drm_private *priv = dev->dev_private; |
Rob Clark | 7198e6b | 2013-07-19 12:59:32 -0400 | [diff] [blame] | 535 | struct msm_file_private *ctx = file->driver_priv; |
Rob Clark | 7198e6b | 2013-07-19 12:59:32 -0400 | [diff] [blame] | 536 | |
Rob Clark | 7198e6b | 2013-07-19 12:59:32 -0400 | [diff] [blame] | 537 | mutex_lock(&dev->struct_mutex); |
| 538 | if (ctx == priv->lastctx) |
| 539 | priv->lastctx = NULL; |
| 540 | mutex_unlock(&dev->struct_mutex); |
| 541 | |
| 542 | kfree(ctx); |
Rob Clark | c8afe68 | 2013-06-26 12:44:06 -0400 | [diff] [blame] | 543 | } |
| 544 | |
| 545 | static void msm_lastclose(struct drm_device *dev) |
| 546 | { |
| 547 | struct msm_drm_private *priv = dev->dev_private; |
Rob Clark | 5ea1f75 | 2014-05-30 12:29:48 -0400 | [diff] [blame] | 548 | if (priv->fbdev) |
| 549 | drm_fb_helper_restore_fbdev_mode_unlocked(priv->fbdev); |
Rob Clark | c8afe68 | 2013-06-26 12:44:06 -0400 | [diff] [blame] | 550 | } |
| 551 | |
Daniel Vetter | e9f0d76 | 2013-12-11 11:34:42 +0100 | [diff] [blame] | 552 | static irqreturn_t msm_irq(int irq, void *arg) |
Rob Clark | c8afe68 | 2013-06-26 12:44:06 -0400 | [diff] [blame] | 553 | { |
| 554 | struct drm_device *dev = arg; |
| 555 | struct msm_drm_private *priv = dev->dev_private; |
| 556 | struct msm_kms *kms = priv->kms; |
| 557 | BUG_ON(!kms); |
| 558 | return kms->funcs->irq(kms); |
| 559 | } |
| 560 | |
| 561 | static void msm_irq_preinstall(struct drm_device *dev) |
| 562 | { |
| 563 | struct msm_drm_private *priv = dev->dev_private; |
| 564 | struct msm_kms *kms = priv->kms; |
| 565 | BUG_ON(!kms); |
| 566 | kms->funcs->irq_preinstall(kms); |
| 567 | } |
| 568 | |
| 569 | static int msm_irq_postinstall(struct drm_device *dev) |
| 570 | { |
| 571 | struct msm_drm_private *priv = dev->dev_private; |
| 572 | struct msm_kms *kms = priv->kms; |
| 573 | BUG_ON(!kms); |
| 574 | return kms->funcs->irq_postinstall(kms); |
| 575 | } |
| 576 | |
| 577 | static void msm_irq_uninstall(struct drm_device *dev) |
| 578 | { |
| 579 | struct msm_drm_private *priv = dev->dev_private; |
| 580 | struct msm_kms *kms = priv->kms; |
| 581 | BUG_ON(!kms); |
| 582 | kms->funcs->irq_uninstall(kms); |
| 583 | } |
| 584 | |
Thierry Reding | 88e7271 | 2015-09-24 18:35:31 +0200 | [diff] [blame] | 585 | static int msm_enable_vblank(struct drm_device *dev, unsigned int pipe) |
Rob Clark | c8afe68 | 2013-06-26 12:44:06 -0400 | [diff] [blame] | 586 | { |
| 587 | struct msm_drm_private *priv = dev->dev_private; |
| 588 | struct msm_kms *kms = priv->kms; |
| 589 | if (!kms) |
| 590 | return -ENXIO; |
Thierry Reding | 88e7271 | 2015-09-24 18:35:31 +0200 | [diff] [blame] | 591 | DBG("dev=%p, crtc=%u", dev, pipe); |
| 592 | return vblank_ctrl_queue_work(priv, pipe, true); |
Rob Clark | c8afe68 | 2013-06-26 12:44:06 -0400 | [diff] [blame] | 593 | } |
| 594 | |
Thierry Reding | 88e7271 | 2015-09-24 18:35:31 +0200 | [diff] [blame] | 595 | static void msm_disable_vblank(struct drm_device *dev, unsigned int pipe) |
Rob Clark | c8afe68 | 2013-06-26 12:44:06 -0400 | [diff] [blame] | 596 | { |
| 597 | struct msm_drm_private *priv = dev->dev_private; |
| 598 | struct msm_kms *kms = priv->kms; |
| 599 | if (!kms) |
| 600 | return; |
Thierry Reding | 88e7271 | 2015-09-24 18:35:31 +0200 | [diff] [blame] | 601 | DBG("dev=%p, crtc=%u", dev, pipe); |
| 602 | vblank_ctrl_queue_work(priv, pipe, false); |
Rob Clark | c8afe68 | 2013-06-26 12:44:06 -0400 | [diff] [blame] | 603 | } |
| 604 | |
| 605 | /* |
Rob Clark | 7198e6b | 2013-07-19 12:59:32 -0400 | [diff] [blame] | 606 | * DRM ioctls: |
| 607 | */ |
| 608 | |
| 609 | static int msm_ioctl_get_param(struct drm_device *dev, void *data, |
| 610 | struct drm_file *file) |
| 611 | { |
| 612 | struct msm_drm_private *priv = dev->dev_private; |
| 613 | struct drm_msm_param *args = data; |
| 614 | struct msm_gpu *gpu; |
| 615 | |
| 616 | /* for now, we just have 3d pipe.. eventually this would need to |
| 617 | * be more clever to dispatch to appropriate gpu module: |
| 618 | */ |
| 619 | if (args->pipe != MSM_PIPE_3D0) |
| 620 | return -EINVAL; |
| 621 | |
| 622 | gpu = priv->gpu; |
| 623 | |
| 624 | if (!gpu) |
| 625 | return -ENXIO; |
| 626 | |
| 627 | return gpu->funcs->get_param(gpu, args->param, &args->value); |
| 628 | } |
| 629 | |
| 630 | static int msm_ioctl_gem_new(struct drm_device *dev, void *data, |
| 631 | struct drm_file *file) |
| 632 | { |
| 633 | struct drm_msm_gem_new *args = data; |
Rob Clark | 93ddb0d | 2014-03-03 09:42:33 -0500 | [diff] [blame] | 634 | |
| 635 | if (args->flags & ~MSM_BO_FLAGS) { |
| 636 | DRM_ERROR("invalid flags: %08x\n", args->flags); |
| 637 | return -EINVAL; |
| 638 | } |
| 639 | |
Rob Clark | 7198e6b | 2013-07-19 12:59:32 -0400 | [diff] [blame] | 640 | return msm_gem_new_handle(dev, file, args->size, |
| 641 | args->flags, &args->handle); |
| 642 | } |
| 643 | |
Rob Clark | 56c2da8 | 2015-05-11 11:50:03 -0400 | [diff] [blame] | 644 | static inline ktime_t to_ktime(struct drm_msm_timespec timeout) |
| 645 | { |
| 646 | return ktime_set(timeout.tv_sec, timeout.tv_nsec); |
| 647 | } |
Rob Clark | 7198e6b | 2013-07-19 12:59:32 -0400 | [diff] [blame] | 648 | |
| 649 | static int msm_ioctl_gem_cpu_prep(struct drm_device *dev, void *data, |
| 650 | struct drm_file *file) |
| 651 | { |
| 652 | struct drm_msm_gem_cpu_prep *args = data; |
| 653 | struct drm_gem_object *obj; |
Rob Clark | 56c2da8 | 2015-05-11 11:50:03 -0400 | [diff] [blame] | 654 | ktime_t timeout = to_ktime(args->timeout); |
Rob Clark | 7198e6b | 2013-07-19 12:59:32 -0400 | [diff] [blame] | 655 | int ret; |
| 656 | |
Rob Clark | 93ddb0d | 2014-03-03 09:42:33 -0500 | [diff] [blame] | 657 | if (args->op & ~MSM_PREP_FLAGS) { |
| 658 | DRM_ERROR("invalid op: %08x\n", args->op); |
| 659 | return -EINVAL; |
| 660 | } |
| 661 | |
Chris Wilson | a8ad0bd | 2016-05-09 11:04:54 +0100 | [diff] [blame] | 662 | obj = drm_gem_object_lookup(file, args->handle); |
Rob Clark | 7198e6b | 2013-07-19 12:59:32 -0400 | [diff] [blame] | 663 | if (!obj) |
| 664 | return -ENOENT; |
| 665 | |
Rob Clark | 56c2da8 | 2015-05-11 11:50:03 -0400 | [diff] [blame] | 666 | ret = msm_gem_cpu_prep(obj, args->op, &timeout); |
Rob Clark | 7198e6b | 2013-07-19 12:59:32 -0400 | [diff] [blame] | 667 | |
| 668 | drm_gem_object_unreference_unlocked(obj); |
| 669 | |
| 670 | return ret; |
| 671 | } |
| 672 | |
| 673 | static int msm_ioctl_gem_cpu_fini(struct drm_device *dev, void *data, |
| 674 | struct drm_file *file) |
| 675 | { |
| 676 | struct drm_msm_gem_cpu_fini *args = data; |
| 677 | struct drm_gem_object *obj; |
| 678 | int ret; |
| 679 | |
Chris Wilson | a8ad0bd | 2016-05-09 11:04:54 +0100 | [diff] [blame] | 680 | obj = drm_gem_object_lookup(file, args->handle); |
Rob Clark | 7198e6b | 2013-07-19 12:59:32 -0400 | [diff] [blame] | 681 | if (!obj) |
| 682 | return -ENOENT; |
| 683 | |
| 684 | ret = msm_gem_cpu_fini(obj); |
| 685 | |
| 686 | drm_gem_object_unreference_unlocked(obj); |
| 687 | |
| 688 | return ret; |
| 689 | } |
| 690 | |
| 691 | static int msm_ioctl_gem_info(struct drm_device *dev, void *data, |
| 692 | struct drm_file *file) |
| 693 | { |
| 694 | struct drm_msm_gem_info *args = data; |
| 695 | struct drm_gem_object *obj; |
| 696 | int ret = 0; |
| 697 | |
| 698 | if (args->pad) |
| 699 | return -EINVAL; |
| 700 | |
Chris Wilson | a8ad0bd | 2016-05-09 11:04:54 +0100 | [diff] [blame] | 701 | obj = drm_gem_object_lookup(file, args->handle); |
Rob Clark | 7198e6b | 2013-07-19 12:59:32 -0400 | [diff] [blame] | 702 | if (!obj) |
| 703 | return -ENOENT; |
| 704 | |
| 705 | args->offset = msm_gem_mmap_offset(obj); |
| 706 | |
| 707 | drm_gem_object_unreference_unlocked(obj); |
| 708 | |
| 709 | return ret; |
| 710 | } |
| 711 | |
| 712 | static int msm_ioctl_wait_fence(struct drm_device *dev, void *data, |
| 713 | struct drm_file *file) |
| 714 | { |
Rob Clark | ca762a8 | 2016-03-15 17:22:13 -0400 | [diff] [blame] | 715 | struct msm_drm_private *priv = dev->dev_private; |
Rob Clark | 7198e6b | 2013-07-19 12:59:32 -0400 | [diff] [blame] | 716 | struct drm_msm_wait_fence *args = data; |
Rob Clark | 56c2da8 | 2015-05-11 11:50:03 -0400 | [diff] [blame] | 717 | ktime_t timeout = to_ktime(args->timeout); |
Rob Clark | 93ddb0d | 2014-03-03 09:42:33 -0500 | [diff] [blame] | 718 | |
| 719 | if (args->pad) { |
| 720 | DRM_ERROR("invalid pad: %08x\n", args->pad); |
| 721 | return -EINVAL; |
| 722 | } |
| 723 | |
Rob Clark | ca762a8 | 2016-03-15 17:22:13 -0400 | [diff] [blame] | 724 | if (!priv->gpu) |
| 725 | return 0; |
| 726 | |
| 727 | return msm_wait_fence(priv->gpu->fctx, args->fence, &timeout, true); |
Rob Clark | 7198e6b | 2013-07-19 12:59:32 -0400 | [diff] [blame] | 728 | } |
| 729 | |
Rob Clark | 4cd33c4 | 2016-05-17 15:44:49 -0400 | [diff] [blame] | 730 | static int msm_ioctl_gem_madvise(struct drm_device *dev, void *data, |
| 731 | struct drm_file *file) |
| 732 | { |
| 733 | struct drm_msm_gem_madvise *args = data; |
| 734 | struct drm_gem_object *obj; |
| 735 | int ret; |
| 736 | |
| 737 | switch (args->madv) { |
| 738 | case MSM_MADV_DONTNEED: |
| 739 | case MSM_MADV_WILLNEED: |
| 740 | break; |
| 741 | default: |
| 742 | return -EINVAL; |
| 743 | } |
| 744 | |
| 745 | ret = mutex_lock_interruptible(&dev->struct_mutex); |
| 746 | if (ret) |
| 747 | return ret; |
| 748 | |
| 749 | obj = drm_gem_object_lookup(file, args->handle); |
| 750 | if (!obj) { |
| 751 | ret = -ENOENT; |
| 752 | goto unlock; |
| 753 | } |
| 754 | |
| 755 | ret = msm_gem_madvise(obj, args->madv); |
| 756 | if (ret >= 0) { |
| 757 | args->retained = ret; |
| 758 | ret = 0; |
| 759 | } |
| 760 | |
| 761 | drm_gem_object_unreference(obj); |
| 762 | |
| 763 | unlock: |
| 764 | mutex_unlock(&dev->struct_mutex); |
| 765 | return ret; |
| 766 | } |
| 767 | |
Rob Clark | 7198e6b | 2013-07-19 12:59:32 -0400 | [diff] [blame] | 768 | static const struct drm_ioctl_desc msm_ioctls[] = { |
Daniel Vetter | f8c4714 | 2015-09-08 13:56:30 +0200 | [diff] [blame] | 769 | DRM_IOCTL_DEF_DRV(MSM_GET_PARAM, msm_ioctl_get_param, DRM_AUTH|DRM_RENDER_ALLOW), |
| 770 | DRM_IOCTL_DEF_DRV(MSM_GEM_NEW, msm_ioctl_gem_new, DRM_AUTH|DRM_RENDER_ALLOW), |
| 771 | DRM_IOCTL_DEF_DRV(MSM_GEM_INFO, msm_ioctl_gem_info, DRM_AUTH|DRM_RENDER_ALLOW), |
| 772 | DRM_IOCTL_DEF_DRV(MSM_GEM_CPU_PREP, msm_ioctl_gem_cpu_prep, DRM_AUTH|DRM_RENDER_ALLOW), |
| 773 | DRM_IOCTL_DEF_DRV(MSM_GEM_CPU_FINI, msm_ioctl_gem_cpu_fini, DRM_AUTH|DRM_RENDER_ALLOW), |
| 774 | DRM_IOCTL_DEF_DRV(MSM_GEM_SUBMIT, msm_ioctl_gem_submit, DRM_AUTH|DRM_RENDER_ALLOW), |
| 775 | DRM_IOCTL_DEF_DRV(MSM_WAIT_FENCE, msm_ioctl_wait_fence, DRM_AUTH|DRM_RENDER_ALLOW), |
Rob Clark | 4cd33c4 | 2016-05-17 15:44:49 -0400 | [diff] [blame] | 776 | DRM_IOCTL_DEF_DRV(MSM_GEM_MADVISE, msm_ioctl_gem_madvise, DRM_AUTH|DRM_RENDER_ALLOW), |
Rob Clark | 7198e6b | 2013-07-19 12:59:32 -0400 | [diff] [blame] | 777 | }; |
| 778 | |
Rob Clark | c8afe68 | 2013-06-26 12:44:06 -0400 | [diff] [blame] | 779 | static const struct vm_operations_struct vm_ops = { |
| 780 | .fault = msm_gem_fault, |
| 781 | .open = drm_gem_vm_open, |
| 782 | .close = drm_gem_vm_close, |
| 783 | }; |
| 784 | |
| 785 | static const struct file_operations fops = { |
| 786 | .owner = THIS_MODULE, |
| 787 | .open = drm_open, |
| 788 | .release = drm_release, |
| 789 | .unlocked_ioctl = drm_ioctl, |
| 790 | #ifdef CONFIG_COMPAT |
| 791 | .compat_ioctl = drm_compat_ioctl, |
| 792 | #endif |
| 793 | .poll = drm_poll, |
| 794 | .read = drm_read, |
| 795 | .llseek = no_llseek, |
| 796 | .mmap = msm_gem_mmap, |
| 797 | }; |
| 798 | |
| 799 | static struct drm_driver msm_driver = { |
Rob Clark | 05b8491 | 2013-09-28 11:28:35 -0400 | [diff] [blame] | 800 | .driver_features = DRIVER_HAVE_IRQ | |
| 801 | DRIVER_GEM | |
| 802 | DRIVER_PRIME | |
Rob Clark | b4b15c8 | 2013-09-28 12:01:25 -0400 | [diff] [blame] | 803 | DRIVER_RENDER | |
Rob Clark | a5436e1 | 2015-06-04 10:12:22 -0400 | [diff] [blame] | 804 | DRIVER_ATOMIC | |
Rob Clark | 05b8491 | 2013-09-28 11:28:35 -0400 | [diff] [blame] | 805 | DRIVER_MODESET, |
Rob Clark | 7198e6b | 2013-07-19 12:59:32 -0400 | [diff] [blame] | 806 | .open = msm_open, |
Rob Clark | c8afe68 | 2013-06-26 12:44:06 -0400 | [diff] [blame] | 807 | .preclose = msm_preclose, |
| 808 | .lastclose = msm_lastclose, |
| 809 | .irq_handler = msm_irq, |
| 810 | .irq_preinstall = msm_irq_preinstall, |
| 811 | .irq_postinstall = msm_irq_postinstall, |
| 812 | .irq_uninstall = msm_irq_uninstall, |
Ville Syrjälä | b44f840 | 2015-09-30 16:46:48 +0300 | [diff] [blame] | 813 | .get_vblank_counter = drm_vblank_no_hw_counter, |
Rob Clark | c8afe68 | 2013-06-26 12:44:06 -0400 | [diff] [blame] | 814 | .enable_vblank = msm_enable_vblank, |
| 815 | .disable_vblank = msm_disable_vblank, |
| 816 | .gem_free_object = msm_gem_free_object, |
| 817 | .gem_vm_ops = &vm_ops, |
| 818 | .dumb_create = msm_gem_dumb_create, |
| 819 | .dumb_map_offset = msm_gem_dumb_map_offset, |
Rob Clark | 30600a909 | 2013-09-28 10:13:04 -0400 | [diff] [blame] | 820 | .dumb_destroy = drm_gem_dumb_destroy, |
Rob Clark | 05b8491 | 2013-09-28 11:28:35 -0400 | [diff] [blame] | 821 | .prime_handle_to_fd = drm_gem_prime_handle_to_fd, |
| 822 | .prime_fd_to_handle = drm_gem_prime_fd_to_handle, |
| 823 | .gem_prime_export = drm_gem_prime_export, |
| 824 | .gem_prime_import = drm_gem_prime_import, |
| 825 | .gem_prime_pin = msm_gem_prime_pin, |
| 826 | .gem_prime_unpin = msm_gem_prime_unpin, |
| 827 | .gem_prime_get_sg_table = msm_gem_prime_get_sg_table, |
| 828 | .gem_prime_import_sg_table = msm_gem_prime_import_sg_table, |
| 829 | .gem_prime_vmap = msm_gem_prime_vmap, |
| 830 | .gem_prime_vunmap = msm_gem_prime_vunmap, |
Daniel Thompson | 77a147e | 2014-11-12 11:38:14 +0000 | [diff] [blame] | 831 | .gem_prime_mmap = msm_gem_prime_mmap, |
Rob Clark | c8afe68 | 2013-06-26 12:44:06 -0400 | [diff] [blame] | 832 | #ifdef CONFIG_DEBUG_FS |
| 833 | .debugfs_init = msm_debugfs_init, |
| 834 | .debugfs_cleanup = msm_debugfs_cleanup, |
| 835 | #endif |
Rob Clark | 7198e6b | 2013-07-19 12:59:32 -0400 | [diff] [blame] | 836 | .ioctls = msm_ioctls, |
| 837 | .num_ioctls = DRM_MSM_NUM_IOCTLS, |
Rob Clark | c8afe68 | 2013-06-26 12:44:06 -0400 | [diff] [blame] | 838 | .fops = &fops, |
| 839 | .name = "msm", |
| 840 | .desc = "MSM Snapdragon DRM", |
| 841 | .date = "20130625", |
Rob Clark | a8d854c | 2016-06-01 14:02:02 -0400 | [diff] [blame] | 842 | .major = MSM_VERSION_MAJOR, |
| 843 | .minor = MSM_VERSION_MINOR, |
| 844 | .patchlevel = MSM_VERSION_PATCHLEVEL, |
Rob Clark | c8afe68 | 2013-06-26 12:44:06 -0400 | [diff] [blame] | 845 | }; |
| 846 | |
| 847 | #ifdef CONFIG_PM_SLEEP |
| 848 | static int msm_pm_suspend(struct device *dev) |
| 849 | { |
| 850 | struct drm_device *ddev = dev_get_drvdata(dev); |
| 851 | |
| 852 | drm_kms_helper_poll_disable(ddev); |
| 853 | |
| 854 | return 0; |
| 855 | } |
| 856 | |
| 857 | static int msm_pm_resume(struct device *dev) |
| 858 | { |
| 859 | struct drm_device *ddev = dev_get_drvdata(dev); |
| 860 | |
| 861 | drm_kms_helper_poll_enable(ddev); |
| 862 | |
| 863 | return 0; |
| 864 | } |
| 865 | #endif |
| 866 | |
| 867 | static const struct dev_pm_ops msm_pm_ops = { |
| 868 | SET_SYSTEM_SLEEP_PM_OPS(msm_pm_suspend, msm_pm_resume) |
| 869 | }; |
| 870 | |
| 871 | /* |
Rob Clark | 060530f | 2014-03-03 14:19:12 -0500 | [diff] [blame] | 872 | * Componentized driver support: |
| 873 | */ |
| 874 | |
Archit Taneja | e9fbdaf | 2015-11-18 12:15:14 +0530 | [diff] [blame] | 875 | /* |
| 876 | * NOTE: duplication of the same code as exynos or imx (or probably any other). |
| 877 | * so probably some room for some helpers |
Rob Clark | 060530f | 2014-03-03 14:19:12 -0500 | [diff] [blame] | 878 | */ |
| 879 | static int compare_of(struct device *dev, void *data) |
| 880 | { |
| 881 | return dev->of_node == data; |
| 882 | } |
Rob Clark | 41e6977 | 2013-12-15 16:23:05 -0500 | [diff] [blame] | 883 | |
Archit Taneja | 812070e | 2016-05-19 10:38:39 +0530 | [diff] [blame] | 884 | /* |
| 885 | * Identify what components need to be added by parsing what remote-endpoints |
| 886 | * our MDP output ports are connected to. In the case of LVDS on MDP4, there |
| 887 | * is no external component that we need to add since LVDS is within MDP4 |
| 888 | * itself. |
| 889 | */ |
| 890 | static int add_components_mdp(struct device *mdp_dev, |
| 891 | struct component_match **matchptr) |
| 892 | { |
| 893 | struct device_node *np = mdp_dev->of_node; |
| 894 | struct device_node *ep_node; |
Archit Taneja | 54011e2 | 2016-06-06 13:45:34 +0530 | [diff] [blame] | 895 | struct device *master_dev; |
| 896 | |
| 897 | /* |
| 898 | * on MDP4 based platforms, the MDP platform device is the component |
| 899 | * master that adds other display interface components to itself. |
| 900 | * |
| 901 | * on MDP5 based platforms, the MDSS platform device is the component |
| 902 | * master that adds MDP5 and other display interface components to |
| 903 | * itself. |
| 904 | */ |
| 905 | if (of_device_is_compatible(np, "qcom,mdp4")) |
| 906 | master_dev = mdp_dev; |
| 907 | else |
| 908 | master_dev = mdp_dev->parent; |
Archit Taneja | 812070e | 2016-05-19 10:38:39 +0530 | [diff] [blame] | 909 | |
| 910 | for_each_endpoint_of_node(np, ep_node) { |
| 911 | struct device_node *intf; |
| 912 | struct of_endpoint ep; |
| 913 | int ret; |
| 914 | |
| 915 | ret = of_graph_parse_endpoint(ep_node, &ep); |
| 916 | if (ret) { |
| 917 | dev_err(mdp_dev, "unable to parse port endpoint\n"); |
| 918 | of_node_put(ep_node); |
| 919 | return ret; |
| 920 | } |
| 921 | |
| 922 | /* |
| 923 | * The LCDC/LVDS port on MDP4 is a speacial case where the |
| 924 | * remote-endpoint isn't a component that we need to add |
| 925 | */ |
| 926 | if (of_device_is_compatible(np, "qcom,mdp4") && |
| 927 | ep.port == 0) { |
| 928 | of_node_put(ep_node); |
| 929 | continue; |
| 930 | } |
| 931 | |
| 932 | /* |
| 933 | * It's okay if some of the ports don't have a remote endpoint |
| 934 | * specified. It just means that the port isn't connected to |
| 935 | * any external interface. |
| 936 | */ |
| 937 | intf = of_graph_get_remote_port_parent(ep_node); |
| 938 | if (!intf) { |
| 939 | of_node_put(ep_node); |
| 940 | continue; |
| 941 | } |
| 942 | |
Archit Taneja | 54011e2 | 2016-06-06 13:45:34 +0530 | [diff] [blame] | 943 | component_match_add(master_dev, matchptr, compare_of, intf); |
Archit Taneja | 812070e | 2016-05-19 10:38:39 +0530 | [diff] [blame] | 944 | |
| 945 | of_node_put(intf); |
| 946 | of_node_put(ep_node); |
| 947 | } |
| 948 | |
| 949 | return 0; |
| 950 | } |
| 951 | |
Archit Taneja | 54011e2 | 2016-06-06 13:45:34 +0530 | [diff] [blame] | 952 | static int compare_name_mdp(struct device *dev, void *data) |
| 953 | { |
| 954 | return (strstr(dev_name(dev), "mdp") != NULL); |
| 955 | } |
| 956 | |
Archit Taneja | 7d526fc | 2016-05-19 10:33:57 +0530 | [diff] [blame] | 957 | static int add_display_components(struct device *dev, |
| 958 | struct component_match **matchptr) |
| 959 | { |
Archit Taneja | 54011e2 | 2016-06-06 13:45:34 +0530 | [diff] [blame] | 960 | struct device *mdp_dev; |
| 961 | int ret; |
| 962 | |
| 963 | /* |
| 964 | * MDP5 based devices don't have a flat hierarchy. There is a top level |
| 965 | * parent: MDSS, and children: MDP5, DSI, HDMI, eDP etc. Populate the |
| 966 | * children devices, find the MDP5 node, and then add the interfaces |
| 967 | * to our components list. |
| 968 | */ |
| 969 | if (of_device_is_compatible(dev->of_node, "qcom,mdss")) { |
| 970 | ret = of_platform_populate(dev->of_node, NULL, NULL, dev); |
| 971 | if (ret) { |
| 972 | dev_err(dev, "failed to populate children devices\n"); |
| 973 | return ret; |
| 974 | } |
| 975 | |
| 976 | mdp_dev = device_find_child(dev, NULL, compare_name_mdp); |
| 977 | if (!mdp_dev) { |
| 978 | dev_err(dev, "failed to find MDSS MDP node\n"); |
| 979 | of_platform_depopulate(dev); |
| 980 | return -ENODEV; |
| 981 | } |
| 982 | |
| 983 | put_device(mdp_dev); |
| 984 | |
| 985 | /* add the MDP component itself */ |
| 986 | component_match_add(dev, matchptr, compare_of, |
| 987 | mdp_dev->of_node); |
| 988 | } else { |
| 989 | /* MDP4 */ |
| 990 | mdp_dev = dev; |
| 991 | } |
| 992 | |
| 993 | ret = add_components_mdp(mdp_dev, matchptr); |
| 994 | if (ret) |
| 995 | of_platform_depopulate(dev); |
| 996 | |
| 997 | return ret; |
Archit Taneja | 7d526fc | 2016-05-19 10:33:57 +0530 | [diff] [blame] | 998 | } |
| 999 | |
Archit Taneja | dc3ea26 | 2016-05-19 13:33:52 +0530 | [diff] [blame] | 1000 | /* |
| 1001 | * We don't know what's the best binding to link the gpu with the drm device. |
| 1002 | * Fow now, we just hunt for all the possible gpus that we support, and add them |
| 1003 | * as components. |
| 1004 | */ |
| 1005 | static const struct of_device_id msm_gpu_match[] = { |
| 1006 | { .compatible = "qcom,adreno-3xx" }, |
| 1007 | { .compatible = "qcom,kgsl-3d0" }, |
| 1008 | { }, |
| 1009 | }; |
| 1010 | |
Archit Taneja | 7d526fc | 2016-05-19 10:33:57 +0530 | [diff] [blame] | 1011 | static int add_gpu_components(struct device *dev, |
| 1012 | struct component_match **matchptr) |
| 1013 | { |
Archit Taneja | dc3ea26 | 2016-05-19 13:33:52 +0530 | [diff] [blame] | 1014 | struct device_node *np; |
| 1015 | |
| 1016 | np = of_find_matching_node(NULL, msm_gpu_match); |
| 1017 | if (!np) |
| 1018 | return 0; |
| 1019 | |
| 1020 | component_match_add(dev, matchptr, compare_of, np); |
| 1021 | |
| 1022 | of_node_put(np); |
| 1023 | |
| 1024 | return 0; |
Archit Taneja | 7d526fc | 2016-05-19 10:33:57 +0530 | [diff] [blame] | 1025 | } |
| 1026 | |
Russell King | 8444828 | 2014-04-19 11:20:42 +0100 | [diff] [blame] | 1027 | static int msm_drm_bind(struct device *dev) |
| 1028 | { |
Archit Taneja | 2b66987 | 2016-05-02 11:05:54 +0530 | [diff] [blame] | 1029 | return msm_drm_init(dev, &msm_driver); |
Russell King | 8444828 | 2014-04-19 11:20:42 +0100 | [diff] [blame] | 1030 | } |
| 1031 | |
| 1032 | static void msm_drm_unbind(struct device *dev) |
| 1033 | { |
Archit Taneja | 2b66987 | 2016-05-02 11:05:54 +0530 | [diff] [blame] | 1034 | msm_drm_uninit(dev); |
Russell King | 8444828 | 2014-04-19 11:20:42 +0100 | [diff] [blame] | 1035 | } |
| 1036 | |
| 1037 | static const struct component_master_ops msm_drm_ops = { |
| 1038 | .bind = msm_drm_bind, |
| 1039 | .unbind = msm_drm_unbind, |
| 1040 | }; |
| 1041 | |
| 1042 | /* |
| 1043 | * Platform driver: |
| 1044 | */ |
| 1045 | |
| 1046 | static int msm_pdev_probe(struct platform_device *pdev) |
| 1047 | { |
| 1048 | struct component_match *match = NULL; |
Archit Taneja | 7d526fc | 2016-05-19 10:33:57 +0530 | [diff] [blame] | 1049 | int ret; |
Archit Taneja | e9fbdaf | 2015-11-18 12:15:14 +0530 | [diff] [blame] | 1050 | |
Archit Taneja | 7d526fc | 2016-05-19 10:33:57 +0530 | [diff] [blame] | 1051 | ret = add_display_components(&pdev->dev, &match); |
| 1052 | if (ret) |
| 1053 | return ret; |
| 1054 | |
| 1055 | ret = add_gpu_components(&pdev->dev, &match); |
| 1056 | if (ret) |
| 1057 | return ret; |
Rob Clark | 060530f | 2014-03-03 14:19:12 -0500 | [diff] [blame] | 1058 | |
Rob Clark | 871d812 | 2013-11-16 12:56:06 -0500 | [diff] [blame] | 1059 | pdev->dev.coherent_dma_mask = DMA_BIT_MASK(32); |
Russell King | 8444828 | 2014-04-19 11:20:42 +0100 | [diff] [blame] | 1060 | return component_master_add_with_match(&pdev->dev, &msm_drm_ops, match); |
Rob Clark | c8afe68 | 2013-06-26 12:44:06 -0400 | [diff] [blame] | 1061 | } |
| 1062 | |
| 1063 | static int msm_pdev_remove(struct platform_device *pdev) |
| 1064 | { |
Rob Clark | 060530f | 2014-03-03 14:19:12 -0500 | [diff] [blame] | 1065 | component_master_del(&pdev->dev, &msm_drm_ops); |
Archit Taneja | 54011e2 | 2016-06-06 13:45:34 +0530 | [diff] [blame] | 1066 | of_platform_depopulate(&pdev->dev); |
Rob Clark | c8afe68 | 2013-06-26 12:44:06 -0400 | [diff] [blame] | 1067 | |
| 1068 | return 0; |
| 1069 | } |
| 1070 | |
Rob Clark | 06c0dd9 | 2013-11-30 17:51:47 -0500 | [diff] [blame] | 1071 | static const struct of_device_id dt_match[] = { |
Narendra Muppalla | 1b0b335 | 2015-09-29 10:16:51 -0700 | [diff] [blame] | 1072 | { .compatible = "qcom,mdp" }, /* mdp4 */ |
| 1073 | { .compatible = "qcom,mdss_mdp" }, /* mdp5 */ |
| 1074 | { .compatible = "qcom,sde-kms" }, /* sde */ |
Rob Clark | 06c0dd9 | 2013-11-30 17:51:47 -0500 | [diff] [blame] | 1075 | {} |
| 1076 | }; |
| 1077 | MODULE_DEVICE_TABLE(of, dt_match); |
| 1078 | |
Rob Clark | c8afe68 | 2013-06-26 12:44:06 -0400 | [diff] [blame] | 1079 | static struct platform_driver msm_platform_driver = { |
| 1080 | .probe = msm_pdev_probe, |
| 1081 | .remove = msm_pdev_remove, |
| 1082 | .driver = { |
Rob Clark | c8afe68 | 2013-06-26 12:44:06 -0400 | [diff] [blame] | 1083 | .name = "msm", |
Rob Clark | 06c0dd9 | 2013-11-30 17:51:47 -0500 | [diff] [blame] | 1084 | .of_match_table = dt_match, |
Rob Clark | c8afe68 | 2013-06-26 12:44:06 -0400 | [diff] [blame] | 1085 | .pm = &msm_pm_ops, |
| 1086 | }, |
Rob Clark | c8afe68 | 2013-06-26 12:44:06 -0400 | [diff] [blame] | 1087 | }; |
| 1088 | |
| 1089 | static int __init msm_drm_register(void) |
| 1090 | { |
| 1091 | DBG("init"); |
Archit Taneja | 1dd0a0b | 2016-05-30 16:36:50 +0530 | [diff] [blame] | 1092 | msm_mdp_register(); |
Hai Li | d5af49c | 2015-03-26 19:25:17 -0400 | [diff] [blame] | 1093 | msm_dsi_register(); |
Hai Li | 0045398 | 2014-12-12 14:41:17 -0500 | [diff] [blame] | 1094 | msm_edp_register(); |
Arnd Bergmann | fcda50c | 2016-02-22 22:08:35 +0100 | [diff] [blame] | 1095 | msm_hdmi_register(); |
Rob Clark | bfd28b1 | 2014-09-05 13:06:37 -0400 | [diff] [blame] | 1096 | adreno_register(); |
Rob Clark | c8afe68 | 2013-06-26 12:44:06 -0400 | [diff] [blame] | 1097 | return platform_driver_register(&msm_platform_driver); |
| 1098 | } |
| 1099 | |
| 1100 | static void __exit msm_drm_unregister(void) |
| 1101 | { |
| 1102 | DBG("fini"); |
| 1103 | platform_driver_unregister(&msm_platform_driver); |
Arnd Bergmann | fcda50c | 2016-02-22 22:08:35 +0100 | [diff] [blame] | 1104 | msm_hdmi_unregister(); |
Rob Clark | bfd28b1 | 2014-09-05 13:06:37 -0400 | [diff] [blame] | 1105 | adreno_unregister(); |
Hai Li | 0045398 | 2014-12-12 14:41:17 -0500 | [diff] [blame] | 1106 | msm_edp_unregister(); |
Hai Li | d5af49c | 2015-03-26 19:25:17 -0400 | [diff] [blame] | 1107 | msm_dsi_unregister(); |
Archit Taneja | 1dd0a0b | 2016-05-30 16:36:50 +0530 | [diff] [blame] | 1108 | msm_mdp_unregister(); |
Rob Clark | c8afe68 | 2013-06-26 12:44:06 -0400 | [diff] [blame] | 1109 | } |
| 1110 | |
| 1111 | module_init(msm_drm_register); |
| 1112 | module_exit(msm_drm_unregister); |
| 1113 | |
| 1114 | MODULE_AUTHOR("Rob Clark <robdclark@gmail.com"); |
| 1115 | MODULE_DESCRIPTION("MSM DRM Driver"); |
| 1116 | MODULE_LICENSE("GPL"); |