Skip to content

Commit bed4100

Browse files
TomCookseyArmanholt
authored andcommitted
drm/pl111: Initial drm/kms driver for pl111
This is a modesetting driver for the pl111 CLCD display controller found on various ARM platforms such as the Versatile Express. The driver has only been tested on the bcm911360_entphn platform so far, with PRIME-based buffer sharing between vc4 and clcd. It reuses the existing devicetree binding, while not using quite as many of its properties as the fbdev driver does (those are left for future work). v2: Nearly complete rewrite by anholt, cutting 2/3 of the code thanks to DRM core's excellent new helpers. v3: Don't match pl110 any more, don't attach if we don't have a DRM panel, use DRM_GEM_CMA_FOPS, update MAINTAINERS, use the simple display helper, use drm_gem_cma_dumb_create (same as our wrapper). v4: Change the driver's .name to not clash with fbdev in sysfs, drop platform alias, drop redundant "drm" in DRM driver name, hook up .prepare_fb to the CMA helper so that DMA fences should work. v5: Move register definitions inside the driver directory, fix build in COMPILE_TEST and !AMBA mode. v6: Drop TIM2_CLKSEL for now to be consistent with existing DT bindings, switch back to external register definitions. Signed-off-by: Tom Cooksey <tom.cooksey@arm.com> Signed-off-by: Eric Anholt <eric@anholt.net> Reviewed-by: Linus Walleij <linus.walleij@linaro.org> (v5) Acked-by: Daniel Vetter <daniel.vetter@ffwll.ch> Link: http://patchwork.freedesktop.org/patch/msgid/20170413031746.12921-2-eric@anholt.net
1 parent 73c7346 commit bed4100

11 files changed

Lines changed: 832 additions & 0 deletions

File tree

‎Documentation/gpu/index.rst‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ Linux GPU Driver Developer's Guide
1212
drm-uapi
1313
i915
1414
meson
15+
pl111
1516
tinydrm
1617
vc4
1718
vga-switcheroo

‎Documentation/gpu/pl111.rst‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
==========================================
2+
drm/pl111 ARM PrimeCell PL111 CLCD Driver
3+
==========================================
4+
5+
.. kernel-doc:: drivers/gpu/drm/pl111/pl111_drv.c
6+
:doc: ARM PrimeCell PL111 CLCD Driver

‎MAINTAINERS‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4160,6 +4160,12 @@ F: include/drm/drm*
41604160
F: include/uapi/drm/drm*
41614161
F: include/linux/vga*
41624162

4163+
DRM DRIVER FOR ARM PL111 CLCD
4164+
M: Eric Anholt <eric@anholt.net>
4165+
T: git git://anongit.freedesktop.org/drm/drm-misc
4166+
S: Supported
4167+
F: drivers/gpu/drm/pl111/
4168+
41634169
DRM DRIVER FOR AST SERVER GRAPHICS CHIPS
41644170
M: Dave Airlie <airlied@redhat.com>
41654171
S: Odd Fixes

‎drivers/gpu/drm/Kconfig‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -276,6 +276,8 @@ source "drivers/gpu/drm/meson/Kconfig"
276276

277277
source "drivers/gpu/drm/tinydrm/Kconfig"
278278

279+
source "drivers/gpu/drm/pl111/Kconfig"
280+
279281
# Keep legacy drivers last
280282

281283
menuconfig DRM_LEGACY

‎drivers/gpu/drm/Makefile‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,3 +97,4 @@ obj-y += hisilicon/
9797
obj-$(CONFIG_DRM_ZTE) += zte/
9898
obj-$(CONFIG_DRM_MXSFB) += mxsfb/
9999
obj-$(CONFIG_DRM_TINYDRM) += tinydrm/
100+
obj-$(CONFIG_DRM_PL111) += pl111/

‎drivers/gpu/drm/pl111/Kconfig‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
config DRM_PL111
2+
tristate "DRM Support for PL111 CLCD Controller"
3+
depends on DRM
4+
depends on ARM || ARM64 || COMPILE_TEST
5+
select DRM_KMS_HELPER
6+
select DRM_KMS_CMA_HELPER
7+
select DRM_GEM_CMA_HELPER
8+
select VT_HW_CONSOLE_BINDING if FRAMEBUFFER_CONSOLE
9+
help
10+
Choose this option for DRM support for the PL111 CLCD controller.
11+
If M is selected the module will be called pl111_drm.
12+

‎drivers/gpu/drm/pl111/Makefile‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
pl111_drm-y += pl111_connector.o \
2+
pl111_display.o \
3+
pl111_drv.o
4+
5+
obj-$(CONFIG_DRM_PL111) += pl111_drm.o
Lines changed: 127 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,127 @@
1+
/*
2+
* (C) COPYRIGHT 2012-2013 ARM Limited. All rights reserved.
3+
*
4+
* Parts of this file were based on sources as follows:
5+
*
6+
* Copyright (c) 2006-2008 Intel Corporation
7+
* Copyright (c) 2007 Dave Airlie <airlied@linux.ie>
8+
* 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+
*/
16+
17+
/**
18+
* pl111_drm_connector.c
19+
* Implementation of the connector functions for PL111 DRM
20+
*/
21+
#include <linux/amba/clcd-regs.h>
22+
#include <linux/version.h>
23+
#include <linux/shmem_fs.h>
24+
#include <linux/dma-buf.h>
25+
26+
#include <drm/drmP.h>
27+
#include <drm/drm_atomic_helper.h>
28+
#include <drm/drm_crtc_helper.h>
29+
#include <drm/drm_of.h>
30+
#include <drm/drm_panel.h>
31+
32+
#include "pl111_drm.h"
33+
34+
static void pl111_connector_destroy(struct drm_connector *connector)
35+
{
36+
struct pl111_drm_connector *pl111_connector =
37+
to_pl111_connector(connector);
38+
39+
if (pl111_connector->panel)
40+
drm_panel_detach(pl111_connector->panel);
41+
42+
drm_connector_unregister(connector);
43+
drm_connector_cleanup(connector);
44+
}
45+
46+
static enum drm_connector_status pl111_connector_detect(struct drm_connector
47+
*connector, bool force)
48+
{
49+
struct pl111_drm_connector *pl111_connector =
50+
to_pl111_connector(connector);
51+
52+
return (pl111_connector->panel ?
53+
connector_status_connected :
54+
connector_status_disconnected);
55+
}
56+
57+
static int pl111_connector_helper_get_modes(struct drm_connector *connector)
58+
{
59+
struct pl111_drm_connector *pl111_connector =
60+
to_pl111_connector(connector);
61+
62+
if (!pl111_connector->panel)
63+
return 0;
64+
65+
return drm_panel_get_modes(pl111_connector->panel);
66+
}
67+
68+
const struct drm_connector_funcs connector_funcs = {
69+
.fill_modes = drm_helper_probe_single_connector_modes,
70+
.destroy = pl111_connector_destroy,
71+
.detect = pl111_connector_detect,
72+
.dpms = drm_atomic_helper_connector_dpms,
73+
.reset = drm_atomic_helper_connector_reset,
74+
.atomic_duplicate_state = drm_atomic_helper_connector_duplicate_state,
75+
.atomic_destroy_state = drm_atomic_helper_connector_destroy_state,
76+
};
77+
78+
const struct drm_connector_helper_funcs connector_helper_funcs = {
79+
.get_modes = pl111_connector_helper_get_modes,
80+
};
81+
82+
/* Walks the OF graph to find the panel node and then asks DRM to look
83+
* up the panel.
84+
*/
85+
static struct drm_panel *pl111_get_panel(struct device *dev)
86+
{
87+
struct device_node *endpoint, *panel_node;
88+
struct device_node *np = dev->of_node;
89+
struct drm_panel *panel;
90+
91+
endpoint = of_graph_get_next_endpoint(np, NULL);
92+
if (!endpoint) {
93+
dev_err(dev, "no endpoint to fetch panel\n");
94+
return NULL;
95+
}
96+
97+
/* don't proceed if we have an endpoint but no panel_node tied to it */
98+
panel_node = of_graph_get_remote_port_parent(endpoint);
99+
of_node_put(endpoint);
100+
if (!panel_node) {
101+
dev_err(dev, "no valid panel node\n");
102+
return NULL;
103+
}
104+
105+
panel = of_drm_find_panel(panel_node);
106+
of_node_put(panel_node);
107+
108+
return panel;
109+
}
110+
111+
int pl111_connector_init(struct drm_device *dev)
112+
{
113+
struct pl111_drm_dev_private *priv = dev->dev_private;
114+
struct pl111_drm_connector *pl111_connector = &priv->connector;
115+
struct drm_connector *connector = &pl111_connector->connector;
116+
117+
drm_connector_init(dev, connector, &connector_funcs,
118+
DRM_MODE_CONNECTOR_DPI);
119+
drm_connector_helper_add(connector, &connector_helper_funcs);
120+
121+
pl111_connector->panel = pl111_get_panel(dev->dev);
122+
if (pl111_connector->panel)
123+
drm_panel_attach(pl111_connector->panel, connector);
124+
125+
return 0;
126+
}
127+

0 commit comments

Comments
 (0)