Skip to contentSkip to conversation

drm/layerscape: Add Freescale DCU DRM driver

PATCH New Jianwei Wang 1 participant 5 messages Apr 3, 2015

Subsystems (7)
lore
Share & tools
lore
#0 lore raw

v4 cover drm/layerscape: Add Freescale DCU DRM driver

@Daniel,
Do you have any other comments for this driver?

@Stefan,
Please help test this driver on vybrid if possible, I have test it on vybrid twr board.

If anyone has any objections, please let me know.

Changed in V4:
-This version doesn't have functionality changed. Just a minor adjustment.

Changed in V3:
- Test driver on Vybrid board and add compatible string
- Remove unused functions
- set default crtc for encoder
- replace legacy functions with atomic help functions
- Set the unique name of the DRM device
- Implement irq handle function for vblank interrupt

Changed in v2:
- Add atomic support
- Modify bindings file
- Rename node for compatibility
- Move platform related code out for compatibility

Added in v1:
- Add support for DCU display controller on the Freescale LS102x SoCs.
- Create a primary plane, a fb created for fbdev, a crtc, a connector for TFT LCD panel, an encoder.

 .../devicetree/bindings/drm/fsl/fsl,dcu.txt        |  50 ++++
 drivers/gpu/drm/Kconfig                            |   2 +
 drivers/gpu/drm/Makefile                           |   1 +
 drivers/gpu/drm/fsl/Kconfig                        |  17 ++
 drivers/gpu/drm/fsl/Makefile                       |   7 +
 drivers/gpu/drm/fsl/fsl_dcu_drm_connector.c        | 194 ++++++++++++
 drivers/gpu/drm/fsl/fsl_dcu_drm_connector.h        |  30 ++
 drivers/gpu/drm/fsl/fsl_dcu_drm_crtc.c             | 165 +++++++++++
 drivers/gpu/drm/fsl/fsl_dcu_drm_crtc.h             |  26 ++
 drivers/gpu/drm/fsl/fsl_dcu_drm_drv.c              | 329 +++++++++++++++++++++
 drivers/gpu/drm/fsl/fsl_dcu_drm_drv.h              | 210 +++++++++++++
 drivers/gpu/drm/fsl/fsl_dcu_drm_fbdev.c            |  26 ++
 drivers/gpu/drm/fsl/fsl_dcu_drm_kms.c              |  42 +++
 drivers/gpu/drm/fsl/fsl_dcu_drm_kms.h              |  17 ++
 drivers/gpu/drm/fsl/fsl_dcu_drm_plane.c            | 192 ++++++++++++
 drivers/gpu/drm/fsl/fsl_dcu_drm_plane.h            |  23 ++
 16 files changed, 1331 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/drm/fsl/fsl,dcu.txt
 create mode 100644 drivers/gpu/drm/fsl/Kconfig
 create mode 100644 drivers/gpu/drm/fsl/Makefile
 create mode 100644 drivers/gpu/drm/fsl/fsl_dcu_drm_connector.c
 create mode 100644 drivers/gpu/drm/fsl/fsl_dcu_drm_connector.h
 create mode 100644 drivers/gpu/drm/fsl/fsl_dcu_drm_crtc.c
 create mode 100644 drivers/gpu/drm/fsl/fsl_dcu_drm_crtc.h
 create mode 100644 drivers/gpu/drm/fsl/fsl_dcu_drm_drv.c
 create mode 100644 drivers/gpu/drm/fsl/fsl_dcu_drm_drv.h
 create mode 100644 drivers/gpu/drm/fsl/fsl_dcu_drm_fbdev.c
 create mode 100644 drivers/gpu/drm/fsl/fsl_dcu_drm_kms.c
 create mode 100644 drivers/gpu/drm/fsl/fsl_dcu_drm_kms.h
 create mode 100644 drivers/gpu/drm/fsl/fsl_dcu_drm_plane.c
 create mode 100644 drivers/gpu/drm/fsl/fsl_dcu_drm_plane.h
#1 lore raw

PATCH v4 1/4 drm/layerscape: Add Freescale DCU DRM driver

This patch add support for Two Dimensional Animation and Compositing Engine (2D-ACE) on the Freescale SoCs.

2D-ACE is a Freescale display controller. 2D-ACE describes the functionality of the module extremely well its name is a value that cannot be used as a token in programming languages. Instead the valid token "DCU" is used to tag the register names and function names.

The Display Controller Unit (DCU) module is a system master that fetches graphics stored in internal or external memory and displays them on a TFT LCD panel. A wide range of panel sizes is supported and the timing of the interface signals is highly configurable. Graphics are read directly from memory and then blended in real-time, which allows for dynamic content creation with minimal CPU intervention.

The features:
(1) Full RGB888 output to TFT LCD panel.
(2) For the current LCD panel, WQVGA "480x272" is supported.
(3) Blending of each pixel using up to 4 source layers dependent on size of panel.
(4) Each graphic layer can be placed with one pixel resolution in either axis.
(5) Each graphic layer support RGB565 and RGB888 direct colors without alpha channel and BGRA8888 direct colors with an alpha channel.
(6) Each graphic layer support alpha blending with 8-bit resolution.

This is a simplified version, only one primary plane, one framebuffer created for fbdev, one crtc, one connector for TFT LCD panel, an encoder.

---
 .../devicetree/bindings/drm/fsl/fsl,dcu.txt        |  50 ++++
 drivers/gpu/drm/Kconfig                            |   2 +
 drivers/gpu/drm/Makefile                           |   1 +
 drivers/gpu/drm/fsl/Kconfig                        |  17 ++
 drivers/gpu/drm/fsl/Makefile                       |   7 +
 drivers/gpu/drm/fsl/fsl_dcu_drm_connector.c        | 194 ++++++++++++
 drivers/gpu/drm/fsl/fsl_dcu_drm_connector.h        |  30 ++
 drivers/gpu/drm/fsl/fsl_dcu_drm_crtc.c             | 165 +++++++++++
 drivers/gpu/drm/fsl/fsl_dcu_drm_crtc.h             |  26 ++
 drivers/gpu/drm/fsl/fsl_dcu_drm_drv.c              | 329 +++++++++++++++++++++
 drivers/gpu/drm/fsl/fsl_dcu_drm_drv.h              | 210 +++++++++++++
 drivers/gpu/drm/fsl/fsl_dcu_drm_fbdev.c            |  26 ++
 drivers/gpu/drm/fsl/fsl_dcu_drm_kms.c              |  42 +++
 drivers/gpu/drm/fsl/fsl_dcu_drm_kms.h              |  17 ++
 drivers/gpu/drm/fsl/fsl_dcu_drm_plane.c            | 192 ++++++++++++
 drivers/gpu/drm/fsl/fsl_dcu_drm_plane.h            |  23 ++
 16 files changed, 1331 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/drm/fsl/fsl,dcu.txt
 create mode 100644 drivers/gpu/drm/fsl/Kconfig
 create mode 100644 drivers/gpu/drm/fsl/Makefile
 create mode 100644 drivers/gpu/drm/fsl/fsl_dcu_drm_connector.c
 create mode 100644 drivers/gpu/drm/fsl/fsl_dcu_drm_connector.h
 create mode 100644 drivers/gpu/drm/fsl/fsl_dcu_drm_crtc.c
 create mode 100644 drivers/gpu/drm/fsl/fsl_dcu_drm_crtc.h
 create mode 100644 drivers/gpu/drm/fsl/fsl_dcu_drm_drv.c
 create mode 100644 drivers/gpu/drm/fsl/fsl_dcu_drm_drv.h
 create mode 100644 drivers/gpu/drm/fsl/fsl_dcu_drm_fbdev.c
 create mode 100644 drivers/gpu/drm/fsl/fsl_dcu_drm_kms.c
 create mode 100644 drivers/gpu/drm/fsl/fsl_dcu_drm_kms.h
 create mode 100644 drivers/gpu/drm/fsl/fsl_dcu_drm_plane.c
 create mode 100644 drivers/gpu/drm/fsl/fsl_dcu_drm_plane.h
Documentation/devicetree/bindings/drm/fsl/fsl,dcu.txt new file +49 -0
new file mode 100644
index 0000000..bdc7d5b
@@ -0,0 +1,49 @@
+Device Tree bindings for Freescale DCU DRM Driver
+
+Required properties:
+- compatible:           Should be one of
+	* "fsl,ls1021a-dcu".
+	* "fsl,vf610-dcu".
+- reg:                  Address and length of the register set for dcu.
+- clocks:               From common clock binding: handle to dcu clock.
+- clock-names:          From common clock binding: Shall be "dcu".
+- display:              The phandle to display node.
+
+Required properties:
+- bits-per-pixel:       <16> for RGB565,
+			<24> for RGB888,
+			<32> for RGB8888.
+
+Required timing node for dispplay sub-node:
+- display-timings:      Refer to binding doc display-timing.txt for details.
+
+Examples:
+dcu: dcu@2ce0000 {
+	compatible = "fsl,ls1021a-dcu";
+	reg = <0x0 0x2ce0000 0x0 0x10000>;
+	clocks = <&platform_clk 0>;
+	clock-names = "dcu";
+	big-endian;
+	display = <&display>;
+
+	display: display@0 {
+		bits-per-pixel = <24>;
+
+		display-timings {
+			native-mode = <&timing0>;
+			timing0: nl4827hc19 {
+				clock-frequency = <10870000>;
+				hactive = <480>;
+				vactive = <272>;
+				hback-porch = <2>;
+				hfront-porch = <2>;
+				vback-porch = <1>;
+				vfront-porch = <1>;
+				hsync-len = <41>;
+				vsync-len = <2>;
+				hsync-active = <1>;
+				vsync-active = <1>;
+			};
+		};
+	};
+};
drivers/gpu/drm/Kconfig +2 -0
index 47f2ce8..464b92e 100644
@@ -208,6 +208,8 @@ source "drivers/gpu/drm/bochs/Kconfig"
 
 source "drivers/gpu/drm/msm/Kconfig"
 
+source "drivers/gpu/drm/fsl/Kconfig"
+
 source "drivers/gpu/drm/tegra/Kconfig"
 
 source "drivers/gpu/drm/panel/Kconfig"
drivers/gpu/drm/Makefile +1 -0
index 7d4944e..7409866 100644
@@ -57,6 +57,7 @@ obj-$(CONFIG_DRM_UDL) += udl/
 obj-$(CONFIG_DRM_AST) += ast/
 obj-$(CONFIG_DRM_ARMADA) += armada/
 obj-$(CONFIG_DRM_ATMEL_HLCDC)	+= atmel-hlcdc/
+obj-$(CONFIG_DRM_FSL_DCU) += fsl/
 obj-$(CONFIG_DRM_RCAR_DU) += rcar-du/
 obj-$(CONFIG_DRM_SHMOBILE) +=shmobile/
 obj-$(CONFIG_DRM_OMAP)	+= omapdrm/
drivers/gpu/drm/fsl/Kconfig new file +17 -0
new file mode 100644
index 0000000..e4f8df0
@@ -0,0 +1,17 @@
+config DRM_FSL_DCU
+	tristate "DRM Support for Freescale DCU"
+	depends on DRM && OF && ARM
+	select DRM_KMS_HELPER
+	select DRM_KMS_CMA_HELPER
+	select VIDEOMODE_HELPERS
+	select BACKLIGHT_CLASS_DEVICE
+	select BACKLIGHT_LCD_SUPPORT
+	select REGMAP_MMIO
+	select DRM_KMS_FB_HELPER
+	select FB_SYS_FILLRECT
+	select FB_SYS_COPYAREA
+	select FB_SYS_IMAGEBLIT
+	select FB_SYS_FOPS
+	help
+	  Choose this option if you have an Freescale DCU chipset.
+	  If M is selected the module will be called fsl-dcu-drm.
drivers/gpu/drm/fsl/Makefile new file +7 -0
new file mode 100644
index 0000000..336b4a6
@@ -0,0 +1,7 @@
+fsl-dcu-drm-y := fsl_dcu_drm_drv.o \
+	       fsl_dcu_drm_kms.o \
+	       fsl_dcu_drm_connector.o \
+	       fsl_dcu_drm_plane.o \
+	       fsl_dcu_drm_crtc.o \
+	       fsl_dcu_drm_fbdev.o
+obj-$(CONFIG_DRM_FSL_DCU)	+= fsl-dcu-drm.o
drivers/gpu/drm/fsl/fsl_dcu_drm_connector.c new file +194 -0

194 lines not on this page · raw message

drivers/gpu/drm/fsl/fsl_dcu_drm_connector.h new file +30 -0
new file mode 100644
index 0000000..bbf6d38
@@ -0,0 +1,30 @@
+/*
+ * Copyright 2015 Freescale Semiconductor, Inc.
+ *
+ * Freescale DCU drm device driver
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ */
+
+#ifndef __FSL_DCU_DRM_CONNECTOR_H__
+#define __FSL_DCU_DRM_CONNECTOR_H__
+
+#include <drm/drmP.h>
+#include <drm/drm_crtc.h>
+#include "fsl_dcu_drm_crtc.h"
+
+struct fsl_dcu_drm_device;
+struct fsl_dcu_drm_connector {
+	struct drm_connector connector;
+	struct drm_encoder *encoder;
+};
+
+int fsl_dcu_drm_encoder_create(struct fsl_dcu_drm_device *fsl_dev,
+			       struct fsl_dcu_drm_crtc *crtc);
+int fsl_dcu_drm_connector_create(struct fsl_dcu_drm_device *fsl_dev,
+				 struct drm_encoder *encoder);
+
+#endif /* __FSL_DCU_DRM_CONNECTOR_H__ */
drivers/gpu/drm/fsl/fsl_dcu_drm_crtc.c new file +165 -0

165 lines not on this page · raw message

drivers/gpu/drm/fsl/fsl_dcu_drm_crtc.h new file +26 -0
new file mode 100644
index 0000000..d44b564
@@ -0,0 +1,26 @@
+/*
+ * Copyright 2015 Freescale Semiconductor, Inc.
+ *
+ * Freescale DCU drm device driver
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ */
+
+#ifndef __FSL_DCU_DRM_CRTC_H__
+#define __FSL_DCU_DRM_CRTC_H__
+
+#include <drm/drmP.h>
+#include <drm/drm_crtc.h>
+
+struct fsl_dcu_drm_device;
+struct fsl_dcu_drm_crtc {
+	struct drm_crtc crtc;
+	int dpms;
+};
+
+int fsl_dcu_drm_crtc_create(struct fsl_dcu_drm_device *fsl_dev);
+
+#endif /* __FSL_DCU_DRM_CRTC_H__ */
drivers/gpu/drm/fsl/fsl_dcu_drm_drv.c new file +329 -0

329 lines not on this page · raw message

drivers/gpu/drm/fsl/fsl_dcu_drm_drv.h new file +210 -0

210 lines not on this page · raw message

drivers/gpu/drm/fsl/fsl_dcu_drm_fbdev.c new file +26 -0
new file mode 100644
index 0000000..f8ef0e1
@@ -0,0 +1,26 @@
+/*
+ * Copyright 2015 Freescale Semiconductor, Inc.
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 as published by
+ * the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
+ * more details.
+ *
+ */
+
+#include <drm/drmP.h>
+#include <drm/drm_fb_cma_helper.h>
+
+#include "fsl_dcu_drm_drv.h"
+
+/* initialize fbdev helper */
+void fsl_dcu_fbdev_init(struct drm_device *dev)
+{
+	struct fsl_dcu_drm_device *fsl_dev = dev_get_drvdata(dev->dev);
+
+	fsl_dev->fbdev = drm_fbdev_cma_init(dev, 24, 1, 1);
+}
drivers/gpu/drm/fsl/fsl_dcu_drm_kms.c new file +42 -0

42 lines not on this page · raw message

drivers/gpu/drm/fsl/fsl_dcu_drm_kms.h new file +17 -0
new file mode 100644
index 0000000..b9bd299
@@ -0,0 +1,17 @@
+/*
+ * Copyright 2015 Freescale Semiconductor, Inc.
+ *
+ * Freescale DCU drm device driver
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ */
+
+#ifndef __FSL_DCU_DRM_KMS_H__
+#define __FSL_DCU_DRM_KMS_H__
+
+int fsl_dcu_drm_modeset_init(struct fsl_dcu_drm_device *fsl_dev);
+
+#endif /* __FSL_DCU_DRM_KMS_H__ */
drivers/gpu/drm/fsl/fsl_dcu_drm_plane.c new file +192 -0

192 lines not on this page · raw message

drivers/gpu/drm/fsl/fsl_dcu_drm_plane.h new file +23 -0
new file mode 100644
index 0000000..ccbfa61
@@ -0,0 +1,23 @@
+/*
+ * Copyright 2015 Freescale Semiconductor, Inc.
+ *
+ * Freescale DCU drm device driver
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ */
+
+#ifndef __FSL_DCU_DRM_PLANE_H__
+#define __FSL_DCU_DRM_PLANE_H__
+
+struct fsl_dcu_drm_device;
+struct fsl_dcu_drm_plane {
+	struct drm_plane plane;
+	unsigned int index;
+};
+
+struct drm_plane *fsl_dcu_drm_primary_create_plane(struct drm_device *dev);
+
+#endif /* __FSL_DCU_DRM_PLANE_H__ */

--
2.1.0.27.g96db324

#2 lore raw

PATCH v4 2/4 arm/layerscape/ls1021a: DCU pixel clock control

In reply to Jianwei Wang

Enable DCU pixel clock when platform devices initinalizing and provide enable and disable pixel clock functions for drm driver

---
 arch/arm/mach-imx/mach-ls1021a.c | 36 ++++++++++++++++++++++++++++++++++++
 include/linux/fsl/dcu.h          | 22 ++++++++++++++++++++++
 2 files changed, 58 insertions(+)
 create mode 100644 include/linux/fsl/dcu.h
arch/arm/mach-imx/mach-ls1021a.c +36 -0
index b89c858..4fb346d 100644
@@ -8,9 +8,44 @@
  */
 
 #include <asm/mach/arch.h>
+#include <linux/of_platform.h>
+#include <linux/mfd/syscon.h>
+#include <linux/regmap.h>
+#include <linux/fsl/dcu.h>
 
 #include "common.h"
 
+void dcu_pixclk_disable(void)
+{
+	struct regmap *scfg_regmap;
+
+	scfg_regmap = syscon_regmap_lookup_by_compatible("fsl,ls1021a-scfg");
+	if (IS_ERR(scfg_regmap)) {
+		pr_err("No syscfg phandle specified\n");
+		return;
+	}
+
+	regmap_write(scfg_regmap, SCFG_PIXCLKCR, PXCK_DISABLE);
+}
+
+void dcu_pixclk_enable(void)
+{
+	struct regmap *scfg_regmap;
+
+	scfg_regmap = syscon_regmap_lookup_by_compatible("fsl,ls1021a-scfg");
+	if (IS_ERR(scfg_regmap)) {
+		pr_err("No syscfg phandle specified\n");
+		return;
+	}
+
+	regmap_write(scfg_regmap, SCFG_PIXCLKCR, PXCK_ENABLE);
+}
+
+static void __init ls1021a_init_machine(void)
+{
+	of_platform_populate(NULL, of_default_bus_match_table, NULL, NULL);
+	dcu_pixclk_enable();
+}
 static const char * const ls1021a_dt_compat[] __initconst = {
 	"fsl,ls1021a",
 	NULL,
@@ -18,5 +53,6 @@ static const char * const ls1021a_dt_compat[] __initconst = {
 
 DT_MACHINE_START(LS1021A, "Freescale LS1021A")
 	.smp		= smp_ops(ls1021a_smp_ops),
+	.init_machine	= ls1021a_init_machine,
 	.dt_compat	= ls1021a_dt_compat,
 MACHINE_END
include/linux/fsl/dcu.h new file +22 -0
new file mode 100644
index 0000000..1873057
@@ -0,0 +1,22 @@
+/*
+ * Copyright 2015 Freescale Semiconductor, Inc.
+ *
+ * Freescale DCU drm device driver
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ */
+
+#ifndef __FSL_DCU_H__
+#define __FSL_DCU_H__
+
+#define SCFG_PIXCLKCR			0x28
+#define PXCK_ENABLE			BIT(31)
+#define PXCK_DISABLE			0
+
+void dcu_pixclk_enable(void);
+void dcu_pixclk_disable(void);
+
+#endif /* __FSL_DCU_H__ */
Signature · 1 line
2.1.0.27.g96db324
#3 lore raw

PATCH v4 3/4 arm/dts/ls1021a: Add DCU dts node

In reply to Jianwei Wang

Add DCU node, DCU is a display controller of Freescale named 2D-ACE.

---
 arch/arm/boot/dts/ls1021a.dtsi | 10 ++++++++++
 1 file changed, 10 insertions(+)
arch/arm/boot/dts/ls1021a.dtsi +10 -0
index c70bb27..6d6e3e2 100644
@@ -383,6 +383,16 @@
 				 <&platform_clk 1>;
 		};
 
+		dcu: dcu@2ce0000 {
+			compatible = "fsl,ls1021a-dcu";
+			reg = <0x0 0x2ce0000 0x0 0x10000>;
+			interrupts = <GIC_SPI 172 IRQ_TYPE_LEVEL_HIGH>;
+			clocks = <&platform_clk 0>;
+			clock-names = "dcu";
+			big-endian;
+			status = "disabled";
+		};
+
 		mdio0: mdio@2d24000 {
 			compatible = "gianfar";
 			device_type = "mdio";
Signature · 1 line
2.1.0.27.g96db324
#4 lore raw

PATCH v4 4/4 arm/dts/ls1021a: Add a TFT LCD panel dts node for DCU

In reply to Jianwei Wang

Add a required display-timings node for the TFT LCD panel the TFT LCD panel is WQVGA "480x272", and the bpp is 24.

---
 arch/arm/boot/dts/ls1021a-twr.dts | 26 ++++++++++++++++++++++++++
 1 file changed, 26 insertions(+)
arch/arm/boot/dts/ls1021a-twr.dts +26 -0
index a2c591e..4780b11 100644
@@ -58,6 +58,32 @@
 	};
 };
 
+&dcu {
+	display = <&display>;
+	status = "okay";
+
+	display: display@0 {
+		bits-per-pixel = <24>;
+
+		display-timings {
+			native-mode = <&timing0>;
+			timing0: nl4827hc19 {
+				clock-frequency = <10870000>;
+				hactive = <480>;
+				vactive = <272>;
+				hback-porch = <2>;
+				hfront-porch = <2>;
+				vback-porch = <2>;
+				vfront-porch = <2>;
+				hsync-len = <41>;
+				vsync-len = <4>;
+				hsync-active = <1>;
+				vsync-active = <1>;
+			};
+		};
+	};
+};
+
 &dspi1 {
 	bus-num = <0>;
 	status = "okay";
Signature · 1 line
2.1.0.27.g96db324