| .. | .. |
|---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-only |
|---|
| 1 | 2 | /* |
|---|
| 2 | 3 | * (C) COPYRIGHT 2012-2013 ARM Limited. All rights reserved. |
|---|
| 3 | 4 | * |
|---|
| .. | .. |
|---|
| 6 | 7 | * Copyright (c) 2006-2008 Intel Corporation |
|---|
| 7 | 8 | * Copyright (c) 2007 Dave Airlie <airlied@linux.ie> |
|---|
| 8 | 9 | * Copyright (C) 2011 Texas Instruments |
|---|
| 9 | | - * |
|---|
| 10 | | - * This program is free software and is provided to you under the terms of the |
|---|
| 11 | | - * GNU General Public License version 2 as published by the Free Software |
|---|
| 12 | | - * Foundation, and any use by you of this program is subject to the terms of |
|---|
| 13 | | - * such GNU licence. |
|---|
| 14 | | - * |
|---|
| 15 | 10 | */ |
|---|
| 16 | 11 | |
|---|
| 17 | 12 | /** |
|---|
| 18 | | - * DOC: ARM PrimeCell PL111 CLCD Driver |
|---|
| 13 | + * DOC: ARM PrimeCell PL110 and PL111 CLCD Driver |
|---|
| 19 | 14 | * |
|---|
| 20 | | - * The PL111 is a simple LCD controller that can support TFT and STN |
|---|
| 21 | | - * displays. This driver exposes a standard KMS interface for them. |
|---|
| 22 | | - * |
|---|
| 23 | | - * This driver uses the same Device Tree binding as the fbdev CLCD |
|---|
| 24 | | - * driver. While the fbdev driver supports panels that may be |
|---|
| 25 | | - * connected to the CLCD internally to the CLCD driver, in DRM the |
|---|
| 26 | | - * panels get split out to drivers/gpu/drm/panels/. This means that, |
|---|
| 27 | | - * in converting from using fbdev to using DRM, you also need to write |
|---|
| 28 | | - * a panel driver (which may be as simple as an entry in |
|---|
| 29 | | - * panel-simple.c). |
|---|
| 15 | + * The PL110/PL111 is a simple LCD controller that can support TFT |
|---|
| 16 | + * and STN displays. This driver exposes a standard KMS interface |
|---|
| 17 | + * for them. |
|---|
| 30 | 18 | * |
|---|
| 31 | 19 | * The driver currently doesn't expose the cursor. The DRM API for |
|---|
| 32 | 20 | * cursors requires support for 64x64 ARGB8888 cursor images, while |
|---|
| .. | .. |
|---|
| 34 | 22 | * cursors. While one could imagine trying to hack something together |
|---|
| 35 | 23 | * to look at the ARGB8888 and program reasonable in monochrome, we |
|---|
| 36 | 24 | * just don't expose the cursor at all instead, and leave cursor |
|---|
| 37 | | - * support to the X11 software cursor layer. |
|---|
| 25 | + * support to the application software cursor layer. |
|---|
| 38 | 26 | * |
|---|
| 39 | 27 | * TODO: |
|---|
| 40 | 28 | * |
|---|
| 41 | 29 | * - Fix race between setting plane base address and getting IRQ for |
|---|
| 42 | 30 | * vsync firing the pageflip completion. |
|---|
| 43 | | - * |
|---|
| 44 | | - * - Use the "max-memory-bandwidth" DT property to filter the |
|---|
| 45 | | - * supported formats. |
|---|
| 46 | 31 | * |
|---|
| 47 | 32 | * - Read back hardware state at boot to skip reprogramming the |
|---|
| 48 | 33 | * hardware when doing a no-op modeset. |
|---|
| .. | .. |
|---|
| 52 | 37 | */ |
|---|
| 53 | 38 | |
|---|
| 54 | 39 | #include <linux/amba/bus.h> |
|---|
| 55 | | -#include <linux/amba/clcd-regs.h> |
|---|
| 56 | | -#include <linux/version.h> |
|---|
| 57 | | -#include <linux/shmem_fs.h> |
|---|
| 58 | 40 | #include <linux/dma-buf.h> |
|---|
| 59 | 41 | #include <linux/module.h> |
|---|
| 60 | | -#include <linux/slab.h> |
|---|
| 61 | 42 | #include <linux/of.h> |
|---|
| 62 | 43 | #include <linux/of_graph.h> |
|---|
| 63 | 44 | #include <linux/of_reserved_mem.h> |
|---|
| 45 | +#include <linux/shmem_fs.h> |
|---|
| 46 | +#include <linux/slab.h> |
|---|
| 47 | +#include <linux/version.h> |
|---|
| 64 | 48 | |
|---|
| 65 | | -#include <drm/drmP.h> |
|---|
| 66 | 49 | #include <drm/drm_atomic_helper.h> |
|---|
| 67 | | -#include <drm/drm_crtc_helper.h> |
|---|
| 50 | +#include <drm/drm_bridge.h> |
|---|
| 51 | +#include <drm/drm_drv.h> |
|---|
| 52 | +#include <drm/drm_fb_cma_helper.h> |
|---|
| 53 | +#include <drm/drm_fb_helper.h> |
|---|
| 68 | 54 | #include <drm/drm_gem_cma_helper.h> |
|---|
| 69 | 55 | #include <drm/drm_gem_framebuffer_helper.h> |
|---|
| 70 | | -#include <drm/drm_fb_helper.h> |
|---|
| 71 | | -#include <drm/drm_fb_cma_helper.h> |
|---|
| 72 | 56 | #include <drm/drm_of.h> |
|---|
| 73 | | -#include <drm/drm_bridge.h> |
|---|
| 74 | 57 | #include <drm/drm_panel.h> |
|---|
| 58 | +#include <drm/drm_probe_helper.h> |
|---|
| 59 | +#include <drm/drm_vblank.h> |
|---|
| 75 | 60 | |
|---|
| 76 | 61 | #include "pl111_drm.h" |
|---|
| 77 | 62 | #include "pl111_versatile.h" |
|---|
| .. | .. |
|---|
| 94 | 79 | struct drm_panel *panel = NULL; |
|---|
| 95 | 80 | struct drm_bridge *bridge = NULL; |
|---|
| 96 | 81 | bool defer = false; |
|---|
| 97 | | - int ret = 0; |
|---|
| 82 | + int ret; |
|---|
| 98 | 83 | int i; |
|---|
| 99 | 84 | |
|---|
| 100 | | - drm_mode_config_init(dev); |
|---|
| 85 | + ret = drmm_mode_config_init(dev); |
|---|
| 86 | + if (ret) |
|---|
| 87 | + return ret; |
|---|
| 88 | + |
|---|
| 101 | 89 | mode_config = &dev->mode_config; |
|---|
| 102 | 90 | mode_config->funcs = &mode_config_funcs; |
|---|
| 103 | 91 | mode_config->min_width = 1; |
|---|
| .. | .. |
|---|
| 154 | 142 | return -EPROBE_DEFER; |
|---|
| 155 | 143 | |
|---|
| 156 | 144 | if (panel) { |
|---|
| 157 | | - bridge = drm_panel_bridge_add(panel, |
|---|
| 158 | | - DRM_MODE_CONNECTOR_Unknown); |
|---|
| 145 | + bridge = drm_panel_bridge_add_typed(panel, |
|---|
| 146 | + DRM_MODE_CONNECTOR_Unknown); |
|---|
| 159 | 147 | if (IS_ERR(bridge)) { |
|---|
| 160 | 148 | ret = PTR_ERR(bridge); |
|---|
| 161 | | - goto out_config; |
|---|
| 149 | + goto finish; |
|---|
| 162 | 150 | } |
|---|
| 163 | 151 | } else if (bridge) { |
|---|
| 164 | 152 | dev_info(dev->dev, "Using non-panel bridge\n"); |
|---|
| .. | .. |
|---|
| 170 | 158 | priv->bridge = bridge; |
|---|
| 171 | 159 | if (panel) { |
|---|
| 172 | 160 | priv->panel = panel; |
|---|
| 173 | | - priv->connector = panel->connector; |
|---|
| 161 | + priv->connector = drm_panel_bridge_connector(bridge); |
|---|
| 174 | 162 | } |
|---|
| 175 | 163 | |
|---|
| 176 | 164 | ret = pl111_display_init(dev); |
|---|
| .. | .. |
|---|
| 194 | 182 | |
|---|
| 195 | 183 | drm_mode_config_reset(dev); |
|---|
| 196 | 184 | |
|---|
| 197 | | - drm_fb_cma_fbdev_init(dev, priv->variant->fb_bpp, 0); |
|---|
| 198 | | - |
|---|
| 199 | 185 | drm_kms_helper_poll_init(dev); |
|---|
| 200 | 186 | |
|---|
| 201 | 187 | goto finish; |
|---|
| .. | .. |
|---|
| 203 | 189 | out_bridge: |
|---|
| 204 | 190 | if (panel) |
|---|
| 205 | 191 | drm_panel_bridge_remove(bridge); |
|---|
| 206 | | -out_config: |
|---|
| 207 | | - drm_mode_config_cleanup(dev); |
|---|
| 208 | 192 | finish: |
|---|
| 209 | 193 | return ret; |
|---|
| 210 | 194 | } |
|---|
| .. | .. |
|---|
| 231 | 215 | |
|---|
| 232 | 216 | static struct drm_driver pl111_drm_driver = { |
|---|
| 233 | 217 | .driver_features = |
|---|
| 234 | | - DRIVER_MODESET | DRIVER_GEM | DRIVER_PRIME | DRIVER_ATOMIC, |
|---|
| 235 | | - .lastclose = drm_fb_helper_lastclose, |
|---|
| 218 | + DRIVER_MODESET | DRIVER_GEM | DRIVER_ATOMIC, |
|---|
| 236 | 219 | .ioctls = NULL, |
|---|
| 237 | 220 | .fops = &drm_fops, |
|---|
| 238 | 221 | .name = "pl111", |
|---|
| .. | .. |
|---|
| 246 | 229 | .gem_vm_ops = &drm_gem_cma_vm_ops, |
|---|
| 247 | 230 | .prime_handle_to_fd = drm_gem_prime_handle_to_fd, |
|---|
| 248 | 231 | .prime_fd_to_handle = drm_gem_prime_fd_to_handle, |
|---|
| 249 | | - .gem_prime_import = drm_gem_prime_import, |
|---|
| 250 | 232 | .gem_prime_import_sg_table = pl111_gem_import_sg_table, |
|---|
| 251 | | - .gem_prime_export = drm_gem_prime_export, |
|---|
| 252 | 233 | .gem_prime_get_sg_table = drm_gem_cma_prime_get_sg_table, |
|---|
| 253 | 234 | .gem_prime_mmap = drm_gem_cma_prime_mmap, |
|---|
| 254 | 235 | .gem_prime_vmap = drm_gem_cma_prime_vmap, |
|---|
| .. | .. |
|---|
| 332 | 313 | if (ret < 0) |
|---|
| 333 | 314 | goto dev_put; |
|---|
| 334 | 315 | |
|---|
| 316 | + drm_fbdev_generic_setup(drm, priv->variant->fb_bpp); |
|---|
| 317 | + |
|---|
| 335 | 318 | return 0; |
|---|
| 336 | 319 | |
|---|
| 337 | 320 | dev_put: |
|---|
| .. | .. |
|---|
| 341 | 324 | return ret; |
|---|
| 342 | 325 | } |
|---|
| 343 | 326 | |
|---|
| 344 | | -static int pl111_amba_remove(struct amba_device *amba_dev) |
|---|
| 327 | +static void pl111_amba_remove(struct amba_device *amba_dev) |
|---|
| 345 | 328 | { |
|---|
| 346 | 329 | struct device *dev = &amba_dev->dev; |
|---|
| 347 | 330 | struct drm_device *drm = amba_get_drvdata(amba_dev); |
|---|
| 348 | 331 | struct pl111_drm_dev_private *priv = drm->dev_private; |
|---|
| 349 | 332 | |
|---|
| 350 | 333 | drm_dev_unregister(drm); |
|---|
| 351 | | - drm_fb_cma_fbdev_fini(drm); |
|---|
| 352 | 334 | if (priv->panel) |
|---|
| 353 | 335 | drm_panel_bridge_remove(priv->bridge); |
|---|
| 354 | | - drm_mode_config_cleanup(drm); |
|---|
| 355 | 336 | drm_dev_put(drm); |
|---|
| 356 | 337 | of_reserved_mem_device_release(dev); |
|---|
| 357 | | - |
|---|
| 358 | | - return 0; |
|---|
| 359 | 338 | } |
|---|
| 360 | 339 | |
|---|
| 361 | 340 | /* |
|---|
| .. | .. |
|---|
| 452 | 431 | }, |
|---|
| 453 | 432 | {0, 0}, |
|---|
| 454 | 433 | }; |
|---|
| 434 | +MODULE_DEVICE_TABLE(amba, pl111_id_table); |
|---|
| 455 | 435 | |
|---|
| 456 | 436 | static struct amba_driver pl111_amba_driver __maybe_unused = { |
|---|
| 457 | 437 | .drv = { |
|---|