Skip to contentSkip to conversation

drm/layerscape: Add fsl dcu DRM driver

PATCH In review Jianwei Wang 5 participants 12 messages Feb 13, 2015 – Mar 26, 2015

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

PATCH 1/3 drm/layerscape: Add fsl dcu DRM driver

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

2D-ACE is a Freescale display controller. It supports at most four plane and provide an hardware cursor.

This is a simplified version, only a primary plane, a fb created for fbdev, a crtc, a connector for TFT LCD panel, an encoder, and the encoder is not in use. Now this drver support fbdev only.

---
 .../devicetree/bindings/video/fsl,dcfb.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_crtc.c             | 412 +++++++++++++++++++++
 drivers/gpu/drm/fsl/fsl_dcu_drm_crtc.h             |  40 ++
 drivers/gpu/drm/fsl/fsl_dcu_drm_drv.c              | 323 ++++++++++++++++
 drivers/gpu/drm/fsl/fsl_dcu_drm_drv.h              | 167 +++++++++
 drivers/gpu/drm/fsl/fsl_dcu_drm_fbdev.c            |  43 +++
 drivers/gpu/drm/fsl/fsl_dcu_drm_kms.c              |  45 +++
 drivers/gpu/drm/fsl/fsl_dcu_drm_kms.h              |  22 ++
 drivers/gpu/drm/fsl/fsl_dcu_drm_plane.c            | 124 +++++++
 drivers/gpu/drm/fsl/fsl_dcu_drm_plane.h            |  28 ++
 14 files changed, 1281 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/video/fsl,dcfb.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_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/video/fsl,dcfb.txt new file +50 -0
new file mode 100644
index 0000000..de7da97
@@ -0,0 +1,50 @@
+* Freescale Simple Display Controller FB Driver
+
+Required properties:
+- compatible:		Should be one of "fsl,ls1021a-dcfb".
+- reg:			Address and length of the register set for dcfb.
+- clocks:		From common clock binding: handle to dcfb clock.
+- clock-names:		From common clock binding: Shall be "dcfb".
+- display:		The phandle to display node.
+
+Optional properties:
+- scfg-controller:	The phandle of scfg 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:
+dcfb: dcfb@2ce0000 {
+	compatible = "fsl,ls1021a-dcfb";
+	reg = <0x0 0x2ce0000 0x0 0x10000>;
+	clocks = <&platform_clk 0>;
+	clock-names = "dcfb";
+	scfg-controller = <&scfg>;
+	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 151a050..a6957aa 100644
@@ -199,6 +199,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 2c239b9..ab5b9ef 100644
@@ -56,6 +56,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..51c3e1f
@@ -0,0 +1,7 @@
+fsl-dcu-drm-y := fsl_dcu_drm_drv.o \
+	       fsl_dcu_drm_kms.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_crtc.c new file +412 -0

412 lines not on this page · raw message

drivers/gpu/drm/fsl/fsl_dcu_drm_crtc.h new file +40 -0
new file mode 100644
index 0000000..ad59992
@@ -0,0 +1,40 @@
+/*
+ * 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_MODSET_H__
+#define __FSL_DCU_DRM_MODSET_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;
+};
+
+struct fsl_dcu_drm_encoder {
+	struct drm_encoder encoder;
+	int dpms;
+};
+
+struct fsl_dcu_drm_connector {
+	struct drm_connector connector;
+	struct drm_encoder *encoder;
+};
+
+int fsl_dcu_drm_crtc_create(struct fsl_dcu_drm_device *fsl_dev);
+int fsl_dcu_drm_encoder_create(struct fsl_dcu_drm_device *fsl_dev);
+int fsl_dcu_drm_connector_create(struct fsl_dcu_drm_device *fsl_dev,
+				 struct drm_encoder *encoder);
+
+#endif /* __FSL_DCU_DRM_MODSET_H__ */
drivers/gpu/drm/fsl/fsl_dcu_drm_drv.c new file +323 -0

323 lines not on this page · raw message

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

167 lines not on this page · raw message

drivers/gpu/drm/fsl/fsl_dcu_drm_fbdev.c new file +43 -0

43 lines not on this page · raw message

drivers/gpu/drm/fsl/fsl_dcu_drm_kms.c new file +45 -0

45 lines not on this page · raw message

drivers/gpu/drm/fsl/fsl_dcu_drm_kms.h new file +22 -0
new file mode 100644
index 0000000..9d5b798
@@ -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_DRM_KMS_H__
+#define __FSL_DCU_DRM_KMS_H__
+
+#include <linux/types.h>
+
+struct drm_gem_cma_object;
+struct fsl_dcu_drm_device;
+
+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 +124 -0

124 lines not on this page · raw message

drivers/gpu/drm/fsl/fsl_dcu_drm_plane.h new file +28 -0
new file mode 100644
index 0000000..da88d1c
@@ -0,0 +1,28 @@
+/*
+ * 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;
+
+void fsl_dcu_drm_plane_setup(struct drm_plane *plane);
+int fsl_dcu_drm_plane_update(struct drm_plane *plane,
+			     struct drm_crtc *crtc,
+			     struct drm_framebuffer *fb,
+			     int crtc_x, int crtc_y,
+			     unsigned int crtc_w, unsigned int crtc_h,
+			     uint32_t src_x, uint32_t src_y,
+			     uint32_t src_w, uint32_t src_h);
+int fsl_dcu_drm_plane_disable(struct drm_plane *plane);
+void fsl_dcu_drm_plane_destroy(struct drm_plane *plane);
+
+#endif /* __FSL_DCU_DRM_PLANE_H__ */
Signature · 1 line
2.1.0.27.g96db324
#1 lore raw

PATCH 2/3 arm/dts/ls1021a: Add DCU dts node

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

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

PATCH 3/3 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..3602286 100644
@@ -58,6 +58,32 @@
 	};
 };
 
+&dcfb {
+	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
#2 lore raw

Re: [PATCH 2/3] arm/dts/ls1021a: Add DCU dts node

In reply to Jianwei Wang
Quoted 18 lines · Jianwei Wang

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

---
 arch/arm/boot/dts/ls1021a.dtsi | 11 +++++++++++
 1 file changed, 11 insertions(+)
arch/arm/boot/dts/ls1021a.dtsi +0 -0
index c70bb27..28c37f1 100644
@@ -383,6 +383,17 @@
 				 <&platform_clk 1>;
 		};
 

arch/arm/boot/dts/ls1021a.dtsi line 395

Quoted 10 lines
arch/arm/boot/dts/ls1021a.dtsi +10 -0
+		dcfb: dcfb@2ce0000 {
+			compatible = "fsl,ls1021a-dcfb";
+			reg = <0x0 0x2ce0000 0x0 0x10000>;
+			interrupts = <GIC_SPI 172 IRQ_TYPE_LEVEL_HIGH>;
+			clocks = <&platform_clk 0>;
+			clock-names = "dcfb";
+			scfg-controller = <&scfg>;
+			big-endian;
+			status = "disabled";
+		};

I don't see "big-endian" in the dcfb binding.

-Scott

#3 lore raw

Re: [PATCH 2/3] arm/dts/ls1021a: Add DCU dts node

My careless, I'll add "big—endia" to fsl,dcfb.txt next version.
________________________________________
发件人: Wood Scott-B07421
发送时间: 2015年2月14日 1:28:08
收件人: Wang Jianwei-B52261
抄送: [email protected]; [email protected]; [email protected]; [email protected]; Wang Huan-B18965; Xiubo Li 主题: Re: [PATCH 2/3] arm/dts/ls1021a: Add DCU dts node

Quoted 18 lines · Jianwei Wang

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

---
 arch/arm/boot/dts/ls1021a.dtsi | 11 +++++++++++
 1 file changed, 11 insertions(+)
arch/arm/boot/dts/ls1021a.dtsi +0 -0
index c70bb27..28c37f1 100644
@@ -383,6 +383,17 @@
                               <&platform_clk 1>;
              };
 

arch/arm/boot/dts/ls1021a.dtsi line 395

Quoted 10 lines
arch/arm/boot/dts/ls1021a.dtsi +10 -0
+             dcfb: dcfb@2ce0000 {
+                     compatible = "fsl,ls1021a-dcfb";
+                     reg = <0x0 0x2ce0000 0x0 0x10000>;
+                     interrupts = <GIC_SPI 172 IRQ_TYPE_LEVEL_HIGH>;
+                     clocks = <&platform_clk 0>;
+                     clock-names = "dcfb";
+                     scfg-controller = <&scfg>;
+                     big-endian;
+                     status = "disabled";
+             };

I don't see "big-endian" in the dcfb binding.

-Scott

#5 lore raw
In reply to Jianwei Wang
Quoted 6 lines · Jianwei Wang

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

2D-ACE is a Freescale display controller. It supports at most four plane and provide an hardware cursor.

Quoted 7 lines

This is a simplified version, only a primary plane, a fb created for fbdev, a crtc, a connector for TFT LCD panel, an encoder, and the encoder is not in use. Now this drver support fbdev only.

Imo adding a new driver without primary plane support (use drm_crtc_init_with_planes) and without atomic support doesn't make sense any more.

Also, what do you mean with "support fbdev only"?
-Daniel

Quoted 1,411 lines
---
 .../devicetree/bindings/video/fsl,dcfb.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_crtc.c             | 412 +++++++++++++++++++++
 drivers/gpu/drm/fsl/fsl_dcu_drm_crtc.h             |  40 ++
 drivers/gpu/drm/fsl/fsl_dcu_drm_drv.c              | 323 ++++++++++++++++
 drivers/gpu/drm/fsl/fsl_dcu_drm_drv.h              | 167 +++++++++
 drivers/gpu/drm/fsl/fsl_dcu_drm_fbdev.c            |  43 +++
 drivers/gpu/drm/fsl/fsl_dcu_drm_kms.c              |  45 +++
 drivers/gpu/drm/fsl/fsl_dcu_drm_kms.h              |  22 ++
 drivers/gpu/drm/fsl/fsl_dcu_drm_plane.c            | 124 +++++++
 drivers/gpu/drm/fsl/fsl_dcu_drm_plane.h            |  28 ++
 14 files changed, 1281 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/video/fsl,dcfb.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_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/video/fsl,dcfb.txt new file +50 -0
new file mode 100644
index 0000000..de7da97
@@ -0,0 +1,50 @@
+* Freescale Simple Display Controller FB Driver
+
+Required properties:
+- compatible:		Should be one of "fsl,ls1021a-dcfb".
+- reg:			Address and length of the register set for dcfb.
+- clocks:		From common clock binding: handle to dcfb clock.
+- clock-names:		From common clock binding: Shall be "dcfb".
+- display:		The phandle to display node.
+
+Optional properties:
+- scfg-controller:	The phandle of scfg 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:
+dcfb: dcfb@2ce0000 {
+	compatible = "fsl,ls1021a-dcfb";
+	reg = <0x0 0x2ce0000 0x0 0x10000>;
+	clocks = <&platform_clk 0>;
+	clock-names = "dcfb";
+	scfg-controller = <&scfg>;
+	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 151a050..a6957aa 100644
@@ -199,6 +199,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 2c239b9..ab5b9ef 100644
@@ -56,6 +56,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..51c3e1f
@@ -0,0 +1,7 @@
+fsl-dcu-drm-y := fsl_dcu_drm_drv.o \
+	       fsl_dcu_drm_kms.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_crtc.c new file +412 -0
new file mode 100644
index 0000000..9f5ba86
@@ -0,0 +1,412 @@
+/*
+ * 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.
+ */
+
+#include <linux/backlight.h>
+#include <linux/clk.h>
+#include <linux/regmap.h>
+
+#include <drm/drmP.h>
+#include <drm/drm_atomic_helper.h>
+#include <drm/drm_crtc.h>
+#include <drm/drm_crtc_helper.h>
+#include <drm/drm_fb_cma_helper.h>
+#include <drm/drm_gem_cma_helper.h>
+#include <drm/drm_plane_helper.h>
+#include <video/of_display_timing.h>
+
+#include "fsl_dcu_drm_crtc.h"
+#include "fsl_dcu_drm_drv.h"
+#include "fsl_dcu_drm_kms.h"
+#include "fsl_dcu_drm_plane.h"
+
+#define to_fsl_dcu_crtc(c)	container_of(c, struct fsl_dcu_drm_crtc, crtc)
+
+static void fsl_dcu_drm_crtc_start(struct drm_crtc *crtc)
+{
+	fsl_dcu_drm_plane_setup(crtc->primary);
+}
+
+static void fsl_dcu_drm_crtc_stop(struct drm_crtc *crtc)
+{
+}
+
+void fsl_dcu_drm_crtc_suspend(struct drm_crtc *crtc)
+{
+	fsl_dcu_drm_crtc_stop(crtc);
+}
+
+void fsl_dcu_drm_crtc_resume(struct drm_crtc *crtc)
+{
+	struct fsl_dcu_drm_crtc *fsl_crtc = to_fsl_dcu_crtc(crtc);
+
+	if (fsl_crtc->dpms != DRM_MODE_DPMS_ON)
+		return;
+
+	fsl_dcu_drm_crtc_start(crtc);
+}
+
+static void fsl_dcu_drm_crtc_update_base(struct drm_crtc *crtc)
+{
+}
+
+static void fsl_dcu_drm_crtc_dpms(struct drm_crtc *crtc, int mode)
+{
+	struct fsl_dcu_drm_crtc *fsl_crtc = to_fsl_dcu_crtc(crtc);
+
+	if (fsl_crtc->dpms == mode)
+		return;
+
+	if (mode == DRM_MODE_DPMS_ON)
+		fsl_dcu_drm_crtc_start(crtc);
+	else
+		fsl_dcu_drm_crtc_stop(crtc);
+
+	fsl_crtc->dpms = mode;
+}
+
+static bool fsl_dcu_drm_crtc_mode_fixup(struct drm_crtc *crtc,
+					const struct drm_display_mode *mode,
+					struct drm_display_mode *adjusted_mode)
+{
+	return true;
+}
+
+static void fsl_dcu_drm_crtc_mode_prepare(struct drm_crtc *crtc)
+{
+		fsl_dcu_drm_crtc_stop(crtc);
+}
+
+static int fsl_dcu_drm_crtc_mode_set(struct drm_crtc *crtc,
+				     struct drm_display_mode *mode,
+				     struct drm_display_mode *adjusted_mode,
+				     int x, int y,
+				     struct drm_framebuffer *old_fb)
+{
+	struct drm_device *dev = crtc->dev;
+	struct fsl_dcu_drm_device *fsl_dev = dev->dev_private;
+	uint32_t hbp, hfp, hsw, vbp, vfp, vsw, div, index;
+
+	DBG(": set mode: %d:\"%s\" %d %d %d %d %d %d %d %d %d %d 0x%x 0x%x",
+	    mode->base.id, mode->name,
+	    mode->vrefresh, mode->clock,
+	    mode->hdisplay, mode->hsync_start,
+	    mode->hsync_end, mode->htotal,
+	    mode->vdisplay, mode->vsync_start,
+	    mode->vsync_end, mode->vtotal,
+	    mode->type, mode->flags);
+
+	index = drm_crtc_index(crtc);
+	div = (uint32_t)clk_get_rate(fsl_dev->clk) / crtc->mode.clock / 1000;
+
+	/* Configure timings: */
+	hbp = mode->htotal - mode->hsync_end;
+	hfp = mode->hsync_start - mode->hdisplay;
+	hsw = mode->hsync_end - mode->hsync_start;
+	vbp = mode->vtotal - mode->vsync_end;
+	vfp = mode->vsync_start - mode->vdisplay;
+	vsw = mode->vsync_end - mode->vsync_start;
+
+	regmap_write(fsl_dev->regmap, DCU_HSYN_PARA,
+		     DCU_HSYN_PARA_BP(hbp) |
+		     DCU_HSYN_PARA_PW(hsw) |
+		     DCU_HSYN_PARA_FP(hfp));
+	regmap_write(fsl_dev->regmap, DCU_VSYN_PARA,
+		     DCU_VSYN_PARA_BP(vbp) |
+		     DCU_VSYN_PARA_PW(vsw) |
+		     DCU_VSYN_PARA_FP(vfp));
+	regmap_write(fsl_dev->regmap, DCU_DISP_SIZE,
+		     DCU_DISP_SIZE_DELTA_Y(mode->vdisplay) |
+		     DCU_DISP_SIZE_DELTA_X(mode->hdisplay));
+	regmap_write(fsl_dev->regmap, DCU_CTRLDESCLN_1(index),
+		     DCU_CTRLDESCLN_1_HEIGHT(mode->vdisplay) |
+		     DCU_CTRLDESCLN_1_WIDTH(mode->hdisplay));
+	regmap_write(fsl_dev->regmap, DCU_CTRLDESCLN_2(index),
+		     DCU_CTRLDESCLN_2_POSY(y) |
+		     DCU_CTRLDESCLN_2_POSX(x));
+	regmap_write(fsl_dev->regmap, DCU_DIV_RATIO, div);
+	regmap_write(fsl_dev->regmap, DCU_UPDATE_MODE, DCU_UPDATE_MODE_READREG);
+
+	return 0;
+}
+
+static void fsl_dcu_drm_crtc_mode_commit(struct drm_crtc *crtc)
+{
+		fsl_dcu_drm_crtc_start(crtc);
+}
+
+static int fsl_dcu_drm_crtc_mode_set_base(struct drm_crtc *crtc, int x, int y,
+					  struct drm_framebuffer *old_fb)
+{
+	fsl_dcu_drm_crtc_update_base(crtc);
+
+	return 0;
+}
+
+static const struct drm_crtc_helper_funcs crtc_helper_funcs = {
+	.dpms = fsl_dcu_drm_crtc_dpms,
+	.mode_fixup = fsl_dcu_drm_crtc_mode_fixup,
+	.prepare = fsl_dcu_drm_crtc_mode_prepare,
+	.commit = fsl_dcu_drm_crtc_mode_commit,
+	.mode_set = fsl_dcu_drm_crtc_mode_set,
+	.mode_set_base = fsl_dcu_drm_crtc_mode_set_base,
+};
+
+static int fsl_dcu_drm_crtc_page_flip(struct drm_crtc *crtc,
+				      struct drm_framebuffer *fb,
+				      struct drm_pending_vblank_event *event,
+				      uint32_t page_flip_flags)
+{
+	return 0;
+}
+
+static const struct drm_plane_funcs fsl_dcu_drm_plane_funcs = {
+	.update_plane = fsl_dcu_drm_plane_update,
+	.disable_plane = fsl_dcu_drm_plane_disable,
+	.destroy = fsl_dcu_drm_plane_destroy,
+};
+
+static const struct drm_crtc_funcs crtc_funcs = {
+	.destroy = drm_crtc_cleanup,
+	.set_config = drm_crtc_helper_set_config,
+	.page_flip = fsl_dcu_drm_crtc_page_flip,
+};
+
+int fsl_dcu_drm_crtc_create(struct fsl_dcu_drm_device *fsl_dev)
+{
+	struct drm_crtc *crtc = &fsl_dev->crtc.crtc;
+	int ret;
+
+	fsl_dev->crtc.dpms = DRM_MODE_DPMS_OFF;
+
+	ret = drm_crtc_init(fsl_dev->ddev, crtc, &crtc_funcs);
+	if (ret < 0)
+		return ret;
+
+	crtc->primary->funcs = &fsl_dcu_drm_plane_funcs;
+
+	drm_crtc_helper_add(crtc, &crtc_helper_funcs);
+
+	regmap_write(fsl_dev->regmap, DCU_SYN_POL,
+		     DCU_SYN_POL_INV_VS_LOW | DCU_SYN_POL_INV_HS_LOW);
+	regmap_write(fsl_dev->regmap, DCU_BGND, DCU_BGND_R(0) |
+		     DCU_BGND_G(0) | DCU_BGND_B(0));
+	regmap_write(fsl_dev->regmap, DCU_DCU_MODE,
+		     DCU_MODE_BLEND_ITER(1) | DCU_MODE_RASTER_EN);
+	regmap_write(fsl_dev->regmap, DCU_THRESHOLD,
+		     DCU_THRESHOLD_LS_BF_VS(BF_VS_VAL) |
+		     DCU_THRESHOLD_OUT_BUF_HIGH(BUF_MAX_VAL) |
+		     DCU_THRESHOLD_OUT_BUF_LOW(BUF_MIN_VAL));
+	regmap_update_bits(fsl_dev->regmap, DCU_DCU_MODE,
+			   DCU_MODE_DCU_MODE_MASK,
+			   DCU_MODE_DCU_MODE(DCU_MODE_NORMAL));
+	regmap_write(fsl_dev->regmap, DCU_UPDATE_MODE, DCU_UPDATE_MODE_READREG);
+	return 0;
+}
+
+/*
+ * Encoder
+ */
+
+#define to_fsl_dcu_encoder(e) \
+	container_of(e, struct fsl_dcu_drm_encoder, encoder)
+
+static void fsl_dcu_drm_encoder_dpms(struct drm_encoder *encoder, int mode)
+{
+	struct fsl_dcu_drm_encoder *fsl_enc = to_fsl_dcu_encoder(encoder);
+
+	if (fsl_enc->dpms == mode)
+		return;
+
+	fsl_enc->dpms = mode;
+}
+
+static bool fsl_dcu_drm_encoder_mode_fixup
+		(struct drm_encoder *encoder,
+		const struct drm_display_mode *mode,
+		struct drm_display_mode *adjusted_mode)
+{
+	struct drm_device *dev = encoder->dev;
+	struct fsl_dcu_drm_device *fsl_dev = dev->dev_private;
+	struct drm_connector *connector = &fsl_dev->connector.connector;
+	const struct drm_display_mode *panel_mode;
+
+	if (list_empty(&connector->modes)) {
+		dev_dbg(dev->dev, "mode_fixup: empty modes list\n");
+		return false;
+	}
+
+	/* The flat panel mode is fixed, just copy it to the adjusted mode. */
+	panel_mode = list_first_entry(&connector->modes,
+				      struct drm_display_mode, head);
+	drm_mode_copy(adjusted_mode, panel_mode);
+
+	return true;
+}
+
+static void fsl_dcu_drm_encoder_mode_prepare(struct drm_encoder *encoder)
+{
+}
+
+static void fsl_dcu_drm_encoder_mode_set(struct drm_encoder *encoder,
+					 struct drm_display_mode *mode,
+					 struct drm_display_mode *adjusted_mode)
+{
+}
+
+static void fsl_dcu_drm_encoder_mode_commit(struct drm_encoder *encoder)
+{
+	;
+}
+
+static const struct drm_encoder_helper_funcs encoder_helper_funcs = {
+	.dpms = fsl_dcu_drm_encoder_dpms,
+	.mode_fixup = fsl_dcu_drm_encoder_mode_fixup,
+	.prepare = fsl_dcu_drm_encoder_mode_prepare,
+	.commit = fsl_dcu_drm_encoder_mode_commit,
+	.mode_set = fsl_dcu_drm_encoder_mode_set,
+};
+
+static void fsl_dcu_drm_encoder_destroy(struct drm_encoder *encoder)
+{
+	drm_encoder_cleanup(encoder);
+}
+
+static const struct drm_encoder_funcs encoder_funcs = {
+	.destroy = fsl_dcu_drm_encoder_destroy,
+};
+
+int fsl_dcu_drm_encoder_create(struct fsl_dcu_drm_device *fsl_dev)
+{
+	struct drm_encoder *encoder = &fsl_dev->encoder.encoder;
+	int ret;
+
+	fsl_dev->encoder.dpms = DRM_MODE_DPMS_OFF;
+
+	encoder->possible_crtcs = 1;
+
+	ret = drm_encoder_init(fsl_dev->ddev, encoder, &encoder_funcs,
+			       DRM_MODE_ENCODER_LVDS);
+	if (ret < 0)
+		return ret;
+
+	drm_encoder_helper_add(encoder, &encoder_helper_funcs);
+
+	return 0;
+}
+
+/*
+ * Connector
+ */
+
+#define to_fsl_dcu_connector(c) \
+	container_of(c, struct fsl_dcu_drm_connector, connector)
+
+static int fsl_dcu_drm_connector_get_modes(struct drm_connector *connector)
+{
+	struct drm_device *dev = connector->dev;
+	struct device_node *display_np, *np = dev->dev->of_node;
+	struct drm_display_mode *mode = drm_mode_create(connector->dev);
+	int num_modes = 0;
+
+	if (np) {
+		display_np = of_parse_phandle(np, "display", 0);
+		if (!display_np) {
+			dev_err(dev->dev, "failed to find display phandle\n");
+			return num_modes;
+		}
+		of_get_drm_display_mode(display_np, mode, OF_USE_NATIVE_MODE);
+		mode->type |= DRM_MODE_TYPE_DRIVER | DRM_MODE_TYPE_PREFERRED,
+		drm_mode_probed_add(connector, mode);
+		num_modes++;
+	}
+
+	return num_modes;
+}
+
+static int fsl_dcu_drm_connector_mode_valid(struct drm_connector *connector,
+					    struct drm_display_mode *mode)
+{
+	return MODE_OK;
+}
+
+static struct drm_encoder *
+fsl_dcu_drm_connector_best_encoder(struct drm_connector *connector)
+{
+	struct fsl_dcu_drm_connector *fsl_con = to_fsl_dcu_connector(connector);
+
+	return fsl_con->encoder;
+}
+
+static const struct drm_connector_helper_funcs connector_helper_funcs = {
+	.get_modes = fsl_dcu_drm_connector_get_modes,
+	.mode_valid = fsl_dcu_drm_connector_mode_valid,
+	.best_encoder = fsl_dcu_drm_connector_best_encoder,
+};
+
+static void fsl_dcu_drm_connector_destroy(struct drm_connector *connector)
+{
+	drm_connector_unregister(connector);
+	drm_connector_cleanup(connector);
+}
+
+static enum drm_connector_status
+fsl_dcu_drm_connector_detect(struct drm_connector *connector, bool force)
+{
+	return connector_status_connected;
+}
+
+static const struct drm_connector_funcs connector_funcs = {
+	.dpms = drm_helper_connector_dpms,
+	.detect = fsl_dcu_drm_connector_detect,
+	.fill_modes = drm_helper_probe_single_connector_modes,
+	.destroy = fsl_dcu_drm_connector_destroy,
+};
+
+int fsl_dcu_drm_connector_create(struct fsl_dcu_drm_device *fsl_dev,
+				 struct drm_encoder *encoder)
+{
+	struct drm_connector *connector = &fsl_dev->connector.connector;
+	int ret;
+
+	fsl_dev->connector.encoder = encoder;
+
+	connector->display_info.width_mm = 0;
+	connector->display_info.height_mm = 0;
+
+	ret = drm_connector_init(fsl_dev->ddev, connector, &connector_funcs,
+				 DRM_MODE_CONNECTOR_LVDS);
+	if (ret < 0)
+		return ret;
+
+	drm_connector_helper_add(connector, &connector_helper_funcs);
+	ret = drm_connector_register(connector);
+	if (ret < 0)
+		goto err_cleanup;
+
+	ret = drm_mode_connector_attach_encoder(connector, encoder);
+	if (ret < 0)
+		goto err_sysfs;
+
+	connector->encoder = encoder;
+
+	drm_helper_connector_dpms(connector, DRM_MODE_DPMS_OFF);
+	drm_object_property_set_value
+		(&connector->base, fsl_dev->ddev->mode_config.dpms_property,
+		DRM_MODE_DPMS_OFF);
+
+	return 0;
+
+err_sysfs:
+	drm_connector_unregister(connector);
+err_cleanup:
+	drm_connector_cleanup(connector);
+	return ret;
+}
drivers/gpu/drm/fsl/fsl_dcu_drm_crtc.h new file +40 -0
new file mode 100644
index 0000000..ad59992
@@ -0,0 +1,40 @@
+/*
+ * 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_MODSET_H__
+#define __FSL_DCU_DRM_MODSET_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;
+};
+
+struct fsl_dcu_drm_encoder {
+	struct drm_encoder encoder;
+	int dpms;
+};
+
+struct fsl_dcu_drm_connector {
+	struct drm_connector connector;
+	struct drm_encoder *encoder;
+};
+
+int fsl_dcu_drm_crtc_create(struct fsl_dcu_drm_device *fsl_dev);
+int fsl_dcu_drm_encoder_create(struct fsl_dcu_drm_device *fsl_dev);
+int fsl_dcu_drm_connector_create(struct fsl_dcu_drm_device *fsl_dev,
+				 struct drm_encoder *encoder);
+
+#endif /* __FSL_DCU_DRM_MODSET_H__ */
drivers/gpu/drm/fsl/fsl_dcu_drm_drv.c new file +323 -0
new file mode 100644
index 0000000..1bca45a
@@ -0,0 +1,323 @@
+/*
+ * 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.
+ */
+
+#include <linux/clk.h>
+#include <linux/io.h>
+#include <linux/mm.h>
+#include <linux/module.h>
+#include <linux/of_platform.h>
+#include <linux/platform_device.h>
+#include <linux/pm.h>
+#include <linux/pm_runtime.h>
+#include <linux/regmap.h>
+#include <linux/slab.h>
+
+#include <drm/drmP.h>
+#include "fsl_dcu_drm_drv.h"
+#include "fsl_dcu_drm_kms.h"
+
+static int fsl_dcu_unload(struct drm_device *dev)
+{
+	drm_mode_config_cleanup(dev);
+	drm_vblank_cleanup(dev);
+	drm_irq_uninstall(dev);
+
+	dev->dev_private = NULL;
+
+	return 0;
+}
+
+static struct regmap_config fsl_dcu_regmap_config = {
+	.reg_bits = 32,
+	.reg_stride = 4,
+	.val_bits = 32,
+};
+
+static int fsl_dcu_bypass_tcon(struct fsl_dcu_drm_device *fsl_dev,
+			       struct device_node *np)
+{
+	struct device_node *tcon_np;
+	struct platform_device *pdev;
+	struct clk *tcon_clk;
+	struct resource *res;
+	void __iomem *base;
+
+	tcon_np = of_parse_phandle(np, "tcon-controller", 0);
+	if (!tcon_np)
+		return -EINVAL;
+
+	pdev = of_find_device_by_node(tcon_np);
+	if (!pdev)
+		return -EINVAL;
+
+	tcon_clk = devm_clk_get(&pdev->dev, "tcon");
+	if (IS_ERR(tcon_clk))
+		return PTR_ERR(tcon_clk);
+	clk_prepare_enable(tcon_clk);
+
+	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+	if (!res)
+		return -ENODEV;
+
+	base = devm_ioremap_resource(&pdev->dev, res);
+	if (IS_ERR(base))
+		return PTR_ERR(base);
+
+	fsl_dev->tcon_regmap = devm_regmap_init_mmio_clk(&pdev->dev,
+			"tcon", base, &fsl_dcu_regmap_config);
+	if (IS_ERR(fsl_dev->tcon_regmap)) {
+		dev_err(&pdev->dev, "regmap init failed\n");
+		return PTR_ERR(fsl_dev->tcon_regmap);
+	}
+
+	regmap_write(fsl_dev->tcon_regmap, TCON_CTRL1, TCON_BYPASS_ENABLE);
+	return 0;
+}
+
+static int fsl_dcu_scfg_config(struct fsl_dcu_drm_device *fsl_dev,
+			       struct device_node *np)
+{
+	struct device_node *scfg_np;
+	struct platform_device *pdev;
+	struct resource *res;
+	void __iomem *base;
+
+	scfg_np = of_parse_phandle(np, "scfg-controller", 0);
+	if (!scfg_np)
+		return 0;
+
+	pdev = of_find_device_by_node(scfg_np);
+	if (!pdev)
+		return -EINVAL;
+
+	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+	if (!res)
+		return -ENODEV;
+
+	base = devm_ioremap_resource(&pdev->dev, res);
+	if (IS_ERR(base))
+		return PTR_ERR(base);
+
+	fsl_dev->scfg_regmap = devm_regmap_init_mmio_clk(&pdev->dev,
+			NULL, base, &fsl_dcu_regmap_config);
+	if (IS_ERR(fsl_dev->scfg_regmap)) {
+		dev_err(&pdev->dev, "regmap init failed\n");
+		return PTR_ERR(fsl_dev->scfg_regmap);
+	}
+
+	regmap_write(fsl_dev->scfg_regmap, 0x28, 0x80000000);
+
+	return 0;
+}
+
+static int fsl_dcu_load(struct drm_device *dev, unsigned long flags)
+{
+	struct platform_device *pdev = dev->platformdev;
+	struct fsl_dcu_drm_device *fsl_dev;
+	struct resource *res;
+	void __iomem *base;
+	int ret;
+
+	fsl_dev = devm_kzalloc(&pdev->dev, sizeof(*fsl_dev), GFP_KERNEL);
+	if (!fsl_dev)
+		return -ENOMEM;
+
+	fsl_dev->dev = &pdev->dev;
+	fsl_dev->ddev = dev;
+	dev->dev_private = fsl_dev;
+
+	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+	base = devm_ioremap_resource(&pdev->dev, res);
+	if (IS_ERR(base)) {
+		ret = PTR_ERR(base);
+		return ret;
+	}
+
+	fsl_dev->regmap = devm_regmap_init_mmio(&pdev->dev,
+			base, &fsl_dcu_regmap_config);
+	if (IS_ERR(fsl_dev->regmap)) {
+		dev_err(&pdev->dev, "regmap init failed\n");
+		return PTR_ERR(fsl_dev->regmap);
+	}
+
+	ret = fsl_dcu_drm_modeset_init(fsl_dev);
+	if (ret < 0) {
+		dev_err(&pdev->dev, "failed to initialize mode setting\n");
+		return ret;
+	}
+
+	ret = drm_vblank_init(dev, 1);
+	if (ret < 0) {
+		dev_err(&pdev->dev, "failed to initialize vblank\n");
+		goto done;
+	}
+
+	ret = drm_irq_install(dev, platform_get_irq(dev->platformdev, 0));
+	if (ret < 0) {
+		dev_err(&pdev->dev, "failed to install IRQ handler\n");
+		goto done;
+	}
+
+	/* Put TCON in bypass mode, so the input signals from DCU are passed
+	 * through TCON unchanged */
+	fsl_dcu_bypass_tcon(fsl_dev, pdev->dev.of_node);
+	fsl_dcu_scfg_config(fsl_dev, pdev->dev.of_node);
+
+	fsl_dev->clk = devm_clk_get(&pdev->dev, "dcfb");
+	if (IS_ERR(fsl_dev->clk)) {
+		ret = PTR_ERR(fsl_dev->clk);
+		dev_err(&pdev->dev, "could not get clock\n");
+		return ret;
+	}
+	clk_prepare_enable(fsl_dev->clk);
+
+	dev_set_drvdata(dev->dev, fsl_dev);
+
+	fsl_dcu_fbdev_init(dev);
+
+	return 0;
+done:
+	if (ret)
+		fsl_dcu_unload(dev);
+
+	return ret;
+}
+
+static void fsl_dcu_drm_preclose(struct drm_device *dev, struct drm_file *file)
+{
+	;
+}
+
+static irqreturn_t fsl_dcu_drm_irq(int irq, void *arg)
+{
+	return IRQ_HANDLED;
+}
+
+static int fsl_dcu_drm_enable_vblank(struct drm_device *dev, int crtc)
+{
+	return 0;
+}
+
+static void fsl_dcu_drm_disable_vblank(struct drm_device *dev, int crtc)
+{
+	;
+}
+
+static const struct file_operations fsl_dcu_drm_fops = {
+	.owner		= THIS_MODULE,
+	.open		= drm_open,
+	.release	= drm_release,
+	.unlocked_ioctl	= drm_ioctl,
+#ifdef CONFIG_COMPAT
+	.compat_ioctl	= drm_compat_ioctl,
+#endif
+	.poll		= drm_poll,
+	.read		= drm_read,
+	.llseek		= no_llseek,
+	.mmap		= drm_gem_cma_mmap,
+};
+
+static struct drm_driver fsl_dcu_drm_driver = {
+	.driver_features	= DRIVER_HAVE_IRQ | DRIVER_GEM | DRIVER_MODESET
+				| DRIVER_PRIME,
+	.load			= fsl_dcu_load,
+	.unload			= fsl_dcu_unload,
+	.preclose		= fsl_dcu_drm_preclose,
+	.irq_handler		= fsl_dcu_drm_irq,
+	.get_vblank_counter	= drm_vblank_count,
+	.enable_vblank		= fsl_dcu_drm_enable_vblank,
+	.disable_vblank		= fsl_dcu_drm_disable_vblank,
+	.gem_free_object	= drm_gem_cma_free_object,
+	.gem_vm_ops		= &drm_gem_cma_vm_ops,
+	.prime_handle_to_fd	= drm_gem_prime_handle_to_fd,
+	.prime_fd_to_handle	= drm_gem_prime_fd_to_handle,
+	.gem_prime_import	= drm_gem_prime_import,
+	.gem_prime_export	= drm_gem_prime_export,
+	.gem_prime_get_sg_table	= drm_gem_cma_prime_get_sg_table,
+	.gem_prime_import_sg_table = drm_gem_cma_prime_import_sg_table,
+	.gem_prime_vmap		= drm_gem_cma_prime_vmap,
+	.gem_prime_vunmap	= drm_gem_cma_prime_vunmap,
+	.gem_prime_mmap		= drm_gem_cma_prime_mmap,
+	.dumb_create		= drm_gem_cma_dumb_create,
+	.dumb_map_offset	= drm_gem_cma_dumb_map_offset,
+	.dumb_destroy		= drm_gem_dumb_destroy,
+	.fops			= &fsl_dcu_drm_fops,
+	.name			= "fsl-dcu-drm",
+	.desc			= "Freescale DCU DRM",
+	.date			= "20150213",
+	.major			= 1,
+	.minor			= 0,
+};
+
+#ifdef CONFIG_PM_SLEEP
+static int fsl_dcu_drm_pm_suspend(struct device *dev)
+{
+	struct fsl_dcu_drm_device *fsl_dev = dev_get_drvdata(dev);
+
+	drm_kms_helper_poll_disable(fsl_dev->ddev);
+	fsl_dcu_drm_crtc_suspend(&fsl_dev->crtc);
+
+	return 0;
+}
+
+static int fsl_dcu_drm_pm_resume(struct device *dev)
+{
+	struct fsl_dcu_drm_device *fsl_dev = dev_get_drvdata(dev);
+
+	drm_modeset_lock_all(fsl_dev->ddev);
+	fsl_dcu_drm_crtc_resume(&fsl_dev->crtc);
+	drm_modeset_unlock_all(fsl_dev->ddev);
+
+	drm_kms_helper_poll_enable(fsl_dev->ddev);
+	return 0;
+}
+#endif
+
+static const struct dev_pm_ops fsl_dcu_drm_pm_ops = {
+	SET_SYSTEM_SLEEP_PM_OPS(fsl_dcu_drm_pm_suspend, fsl_dcu_drm_pm_resume)
+};
+
+static int fsl_dcu_drm_probe(struct platform_device *pdev)
+{
+	return drm_platform_init(&fsl_dcu_drm_driver, pdev);
+}
+
+static int fsl_dcu_drm_remove(struct platform_device *pdev)
+{
+	struct fsl_dcu_drm_device *fsl_dev = platform_get_drvdata(pdev);
+
+	drm_put_dev(fsl_dev->ddev);
+
+	return 0;
+}
+
+static struct of_device_id fsl_dcu_of_match[] = {
+		{ .compatible = "fsl,ls1021a-dcfb", },
+		{ },
+};
+MODULE_DEVICE_TABLE(of, fsl_dcu_of_match);
+
+static struct platform_driver fsl_dcu_drm_platform_driver = {
+	.probe		= fsl_dcu_drm_probe,
+	.remove		= fsl_dcu_drm_remove,
+	.driver		= {
+		.owner	= THIS_MODULE,
+		.name	= "fsl,ls1021a-dcfb",
+		.pm	= &fsl_dcu_drm_pm_ops,
+		.of_match_table = fsl_dcu_of_match,
+	},
+};
+
+module_platform_driver(fsl_dcu_drm_platform_driver);
+
+MODULE_ALIAS("platform:fsl-dcu-drm");
+MODULE_DESCRIPTION("Freescale DCU DRM Driver");
+MODULE_LICENSE("GPL");
drivers/gpu/drm/fsl/fsl_dcu_drm_drv.h new file +167 -0
new file mode 100644
index 0000000..8dc7c10
@@ -0,0 +1,167 @@
+/*
+ * 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_DRV_H__
+#define __FSL_DCU_DRM_DRV_H__
+
+#include <linux/kernel.h>
+#include <linux/spinlock.h>
+#include <stddef.h>
+#include <drm/drm.h>
+#include <drm/drmP.h>
+#include <drm/drm_fb_helper.h>
+#include <drm/drm_crtc_helper.h>
+#include <drm/drm_gem_cma_helper.h>
+#include <drm/drm_fb_cma_helper.h>
+
+#include "fsl_dcu_drm_crtc.h"
+#define DRIVER_NAME			"fsl-dcu-fb"
+
+#define DCU_DCU_MODE			0x0010
+#define DCU_MODE_BLEND_ITER(x)		((x) << 20)
+#define DCU_MODE_RASTER_EN		BIT(14)
+#define DCU_MODE_DCU_MODE(x)		(x)
+#define DCU_MODE_DCU_MODE_MASK		0x03
+#define DCU_MODE_OFF			0
+#define DCU_MODE_NORMAL			1
+#define DCU_MODE_TEST			2
+#define DCU_MODE_COLORBAR		3
+
+#define DCU_BGND			0x0014
+#define DCU_BGND_R(x)			((x) << 16)
+#define DCU_BGND_G(x)			((x) << 8)
+#define DCU_BGND_B(x)			(x)
+
+#define DCU_DISP_SIZE			0x0018
+#define DCU_DISP_SIZE_DELTA_Y(x)	((x) << 16)
+/*Regisiter value 1/16 of horizontal resolution*/
+#define DCU_DISP_SIZE_DELTA_X(x)	((x) >> 4)
+
+#define DCU_HSYN_PARA			0x001c
+#define DCU_HSYN_PARA_BP(x)		((x) << 22)
+#define DCU_HSYN_PARA_PW(x)		((x) << 11)
+#define DCU_HSYN_PARA_FP(x)		(x)
+
+#define DCU_VSYN_PARA			0x0020
+#define DCU_VSYN_PARA_BP(x)		((x) << 22)
+#define DCU_VSYN_PARA_PW(x)		((x) << 11)
+#define DCU_VSYN_PARA_FP(x)		(x)
+
+#define DCU_SYN_POL			0x0024
+#define DCU_SYN_POL_INV_PXCK_FALL	(0 << 6)
+#define DCU_SYN_POL_NEG_REMAIN		(0 << 5)
+#define DCU_SYN_POL_INV_VS_LOW		BIT(1)
+#define DCU_SYN_POL_INV_HS_LOW		(1)
+
+#define DCU_THRESHOLD			0x0028
+#define DCU_THRESHOLD_LS_BF_VS(x)	((x) << 16)
+#define DCU_THRESHOLD_OUT_BUF_HIGH(x)	((x) << 8)
+#define DCU_THRESHOLD_OUT_BUF_LOW(x)	(x)
+#define BF_VS_VAL			0x03
+#define BUF_MAX_VAL			0x78
+#define BUF_MIN_VAL			0x0a
+
+#define DCU_INT_STATUS			0x002C
+#define DCU_INT_STATUS_UNDRUN		BIT(1)
+
+#define DCU_INT_MASK			0x0030
+#define DCU_INT_MASK_UNDRUN		BIT(1)
+#define DCU_INT_MASK_VBLANK		BIT(3)
+
+#define DCU_DIV_RATIO			0x0054
+
+#define DCU_UPDATE_MODE			0x00cc
+#define DCU_UPDATE_MODE_MODE		BIT(31)
+#define DCU_UPDATE_MODE_READREG		BIT(30)
+
+#define DCU_DCFB_MAX			0x300
+
+#define DCU_CTRLDESCLN_1(x)		(0x200 + (x) * 0x40)
+#define DCU_CTRLDESCLN_1_HEIGHT(x)	((x) << 16)
+#define DCU_CTRLDESCLN_1_WIDTH(x)	(x)
+
+#define DCU_CTRLDESCLN_2(x)		(0x204 + (x) * 0x40)
+#define DCU_CTRLDESCLN_2_POSY(x)	((x) << 16)
+#define DCU_CTRLDESCLN_2_POSX(x)	(x)
+
+#define DCU_CTRLDESCLN_3(x)		(0x208 + (x) * 0x40)
+
+#define DCU_CTRLDESCLN_4(x)		(0x20c + (x) * 0x40)
+#define DCU_CTRLDESCLN_4_EN		BIT(31)
+#define DCU_CTRLDESCLN_4_TILE_EN	BIT(30)
+#define DCU_CTRLDESCLN_4_DATA_SEL_CLUT	BIT(29)
+#define DCU_CTRLDESCLN_4_SAFETY_EN	BIT(28)
+#define DCU_CTRLDESCLN_4_TRANS(x)	((x) << 20)
+#define DCU_CTRLDESCLN_4_BPP(x)		((x) << 16)
+#define DCU_CTRLDESCLN_4_RLE_EN		BIT(15)
+#define DCU_CTRLDESCLN_4_LUOFFS(x)	((x) << 4)
+#define DCU_CTRLDESCLN_4_BB_ON		BIT(2)
+#define DCU_CTRLDESCLN_4_AB(x)		(x)
+
+#define DCU_CTRLDESCLN_5(x)		(0x210 + (x) * 0x40)
+#define DCU_CTRLDESCLN_5_CKMAX_R(x)	((x) << 16)
+#define DCU_CTRLDESCLN_5_CKMAX_G(x)	((x) << 8)
+#define DCU_CTRLDESCLN_5_CKMAX_B(x)	(x)
+
+#define DCU_CTRLDESCLN_6(x)		(0x214 + (x) * 0x40)
+#define DCU_CTRLDESCLN_6_CKMIN_R(x)	((x) << 16)
+#define DCU_CTRLDESCLN_6_CKMIN_G(x)	((x) << 8)
+#define DCU_CTRLDESCLN_6_CKMIN_B(x)	(x)
+
+#define DCU_CTRLDESCLN_7(x)		(0x218 + (x) * 0x40)
+#define DCU_CTRLDESCLN_7_TILE_VER(x)	((x) << 16)
+#define DCU_CTRLDESCLN_7_TILE_HOR(x)	(x)
+
+#define DCU_CTRLDESCLN_8(x)		(0x21c + (x) * 0x40)
+#define DCU_CTRLDESCLN_8_FG_FCOLOR(x)	(x)
+
+#define DCU_CTRLDESCLN_9(x)		(0x220 + (x) * 0x40)
+#define DCU_CTRLDESCLN_9_BG_BCOLOR(x)	(x)
+
+#define DCU_CTRLDESCLN_10(x)		(0x224 + (x) * 0x40)
+#define DCU_CTRLDESCLN_10_POST_SKIP(x)	((x) << 16)
+#define DCU_CTRLDESCLN_10_PRE_SKIP(x)	(x)
+
+#define FSL_DCU_RGB565			4
+#define FSL_DCU_RGB888			5
+#define FSL_DCU_ARGB8888		6
+#define FSL_DCU_ARGB1555		11
+#define FSL_DCU_ARGB4444		12
+#define FSL_DCU_YUV422			14
+
+#define TCON_CTRL1			0x0000
+#define TCON_BYPASS_ENABLE		BIT(29)
+
+#define DBG(fmt, ...) DRM_DEBUG(fmt"\n", ##__VA_ARGS__)
+
+struct clk;
+struct device;
+struct drm_device;
+
+struct fsl_dcu_drm_device {
+	struct device *dev;
+	struct regmap *regmap;
+	struct regmap *tcon_regmap;
+	struct regmap *scfg_regmap;
+	unsigned int irq;
+	struct clk *clk;
+	/*protects hardware register*/
+	spinlock_t irq_lock;
+	struct drm_device *ddev;
+	struct drm_fbdev_cma *fbdev;
+	struct fsl_dcu_drm_crtc crtc;
+	struct fsl_dcu_drm_encoder encoder;
+	struct fsl_dcu_drm_connector connector;
+};
+
+void fsl_dcu_fbdev_init(struct drm_device *dev);
+
+#endif /* __FSL_DCU_DRM_DRV_H__ */
drivers/gpu/drm/fsl/fsl_dcu_drm_fbdev.c new file +43 -0
new file mode 100644
index 0000000..6729f92
@@ -0,0 +1,43 @@
+/*
+ * 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_crtc.h>
+#include <drm/drm_fb_helper.h>
+#include <drm/drm_crtc_helper.h>
+#include <drm/drm_fb_cma_helper.h>
+#include <drm/drm_gem_cma_helper.h>
+#include <linux/clk.h>
+#include <linux/delay.h>
+#include <linux/dma-mapping.h>
+#include <linux/fb.h>
+#include <linux/interrupt.h>
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/of_platform.h>
+#include <linux/regmap.h>
+#include <video/of_display_timing.h>
+#include <video/videomode.h>
+#include <linux/uaccess.h>
+
+#include "fsl_dcu_drm_drv.h"
+#include "fsl_dcu_drm_crtc.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 +45 -0
new file mode 100644
index 0000000..0eb0652
@@ -0,0 +1,45 @@
+/*
+ * 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.
+ */
+
+#include <drm/drmP.h>
+#include <drm/drm_crtc.h>
+#include <drm/drm_crtc_helper.h>
+#include <drm/drm_fb_cma_helper.h>
+#include <drm/drm_gem_cma_helper.h>
+
+#include "fsl_dcu_drm_crtc.h"
+#include "fsl_dcu_drm_drv.h"
+#include "fsl_dcu_drm_kms.h"
+
+static const struct drm_mode_config_funcs fsl_dcu_drm_mode_config_funcs = {
+	.fb_create = drm_fb_cma_create,
+};
+
+int fsl_dcu_drm_modeset_init(struct fsl_dcu_drm_device *fsl_dev)
+{
+	drm_mode_config_init(fsl_dev->ddev);
+
+	fsl_dev->ddev->mode_config.min_width = 0;
+	fsl_dev->ddev->mode_config.min_height = 0;
+	fsl_dev->ddev->mode_config.max_width = 2031;
+	fsl_dev->ddev->mode_config.max_height = 2047;
+	fsl_dev->ddev->mode_config.funcs = &fsl_dcu_drm_mode_config_funcs;
+
+	fsl_dcu_drm_crtc_create(fsl_dev);
+	fsl_dcu_drm_encoder_create(fsl_dev);
+	fsl_dcu_drm_connector_create(fsl_dev, &fsl_dev->encoder.encoder);
+
+	drm_kms_helper_poll_init(fsl_dev->ddev);
+
+	drm_helper_disable_unused_functions(fsl_dev->ddev);
+
+	return 0;
+}
drivers/gpu/drm/fsl/fsl_dcu_drm_kms.h new file +22 -0
new file mode 100644
index 0000000..9d5b798
@@ -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_DRM_KMS_H__
+#define __FSL_DCU_DRM_KMS_H__
+
+#include <linux/types.h>
+
+struct drm_gem_cma_object;
+struct fsl_dcu_drm_device;
+
+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 +124 -0
new file mode 100644
index 0000000..d725594
@@ -0,0 +1,124 @@
+/*
+ * 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.
+ */
+
+#include <drm/drmP.h>
+#include <drm/drm_crtc.h>
+#include <drm/drm_crtc_helper.h>
+#include <drm/drm_fb_cma_helper.h>
+#include <drm/drm_gem_cma_helper.h>
+#include <linux/regmap.h>
+
+#include "fsl_dcu_drm_drv.h"
+#include "fsl_dcu_drm_kms.h"
+#include "fsl_dcu_drm_plane.h"
+
+static void __fsl_dcu_drm_plane_setup(struct drm_plane *plane,
+				      struct drm_framebuffer *fb)
+{
+	struct fsl_dcu_drm_device *fsl_dev = plane->dev->dev_private;
+	u32 plane_num = 0, alpha, bpp;
+	struct drm_gem_cma_object *gem;
+
+	while (plane->possible_crtcs >> 1)
+		plane_num++;
+
+	gem = drm_fb_cma_get_gem_obj(fb, 0);
+
+	switch (fb->pixel_format) {
+	case DRM_FORMAT_RGB565:
+		bpp = FSL_DCU_RGB565;
+		alpha = 0xff;
+		break;
+	case DRM_FORMAT_RGB888:
+		bpp = FSL_DCU_RGB888;
+		alpha = 0xff;
+		break;
+	case DRM_FORMAT_ARGB8888:
+		bpp = FSL_DCU_ARGB8888;
+		alpha = 0xff;
+		break;
+	case DRM_FORMAT_BGRA4444:
+		bpp = FSL_DCU_ARGB4444;
+		alpha = 0xff;
+		break;
+	case DRM_FORMAT_ARGB1555:
+		bpp = FSL_DCU_ARGB1555;
+		alpha = 0xff;
+		break;
+	case DRM_FORMAT_YUV422:
+		bpp = FSL_DCU_YUV422;
+		alpha = 0xff;
+		break;
+	default:
+		return;
+	}
+
+	regmap_write(fsl_dev->regmap, DCU_CTRLDESCLN_3(plane_num), gem->paddr);
+	regmap_write(fsl_dev->regmap, DCU_CTRLDESCLN_4(plane_num),
+		     DCU_CTRLDESCLN_4_EN |
+		     DCU_CTRLDESCLN_4_TRANS(alpha) |
+		     DCU_CTRLDESCLN_4_BPP(bpp) |
+		     DCU_CTRLDESCLN_4_AB(2));
+	regmap_write(fsl_dev->regmap, DCU_CTRLDESCLN_5(plane_num),
+		     DCU_CTRLDESCLN_5_CKMAX_R(0xFF) |
+		     DCU_CTRLDESCLN_5_CKMAX_G(0xFF) |
+		     DCU_CTRLDESCLN_5_CKMAX_B(0xFF));
+	regmap_write(fsl_dev->regmap, DCU_CTRLDESCLN_6(plane_num),
+		     DCU_CTRLDESCLN_6_CKMIN_R(0) |
+		     DCU_CTRLDESCLN_6_CKMIN_G(0) |
+		     DCU_CTRLDESCLN_6_CKMIN_B(0));
+	regmap_write(fsl_dev->regmap, DCU_CTRLDESCLN_8(plane_num),
+		     DCU_CTRLDESCLN_8_FG_FCOLOR(0));
+	regmap_write(fsl_dev->regmap, DCU_CTRLDESCLN_9(plane_num),
+		     DCU_CTRLDESCLN_9_BG_BCOLOR(0));
+	regmap_write(fsl_dev->regmap, DCU_CTRLDESCLN_10(plane_num),
+		     DCU_CTRLDESCLN_10_POST_SKIP(0) |
+		     DCU_CTRLDESCLN_10_PRE_SKIP(0));
+	regmap_write(fsl_dev->regmap, DCU_UPDATE_MODE, DCU_UPDATE_MODE_READREG);
+}
+
+void fsl_dcu_drm_plane_setup(struct drm_plane *plane)
+{
+	if (!plane->fb)
+		return;
+
+	__fsl_dcu_drm_plane_setup(plane, plane->fb);
+}
+
+int fsl_dcu_drm_plane_update(struct drm_plane *plane, struct drm_crtc *crtc,
+			     struct drm_framebuffer *fb, int crtc_x, int crtc_y,
+			    unsigned int crtc_w, unsigned int crtc_h,
+			    uint32_t src_x, uint32_t src_y,
+			    uint32_t src_w, uint32_t src_h)
+{
+	__fsl_dcu_drm_plane_setup(plane, fb);
+	return 0;
+}
+
+int fsl_dcu_drm_plane_disable(struct drm_plane *plane)
+{
+	return 0;
+}
+
+void fsl_dcu_drm_plane_destroy(struct drm_plane *plane)
+{
+	fsl_dcu_drm_plane_disable(plane);
+	drm_plane_cleanup(plane);
+}
+
+static const uint32_t formats[] = {
+	DRM_FORMAT_RGB565,
+	DRM_FORMAT_RGB888,
+	DRM_FORMAT_ARGB8888,
+	DRM_FORMAT_ARGB4444,
+	DRM_FORMAT_ARGB1555,
+	DRM_FORMAT_YUV422,
+};
drivers/gpu/drm/fsl/fsl_dcu_drm_plane.h new file +28 -0
new file mode 100644
index 0000000..da88d1c
@@ -0,0 +1,28 @@
+/*
+ * 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;
+
+void fsl_dcu_drm_plane_setup(struct drm_plane *plane);
+int fsl_dcu_drm_plane_update(struct drm_plane *plane,
+			     struct drm_crtc *crtc,
+			     struct drm_framebuffer *fb,
+			     int crtc_x, int crtc_y,
+			     unsigned int crtc_w, unsigned int crtc_h,
+			     uint32_t src_x, uint32_t src_y,
+			     uint32_t src_w, uint32_t src_h);
+int fsl_dcu_drm_plane_disable(struct drm_plane *plane);
+void fsl_dcu_drm_plane_destroy(struct drm_plane *plane);
+
+#endif /* __FSL_DCU_DRM_PLANE_H__ */
Signature · 6 lines
2.1.0.27.g96db324

_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
Signature · 7 lines
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch
_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
#6 lore raw
Quoted 25 lines

-----Original Message-----
From: Daniel Vetter [mailto:[email protected]] On Behalf Of Daniel Vetter
Sent: Sunday, February 22, 2015 7:35 PM
To: Wang Jianwei-B52261
Cc: [email protected]; [email protected]; Wood Scott-B07421; Xiubo Li; Wang Huan-B18965; [email protected]; [email protected]
Subject: Re: [PATCH 1/3] drm/layerscape: Add fsl dcu DRM driver

Quoted 6 lines · Jianwei Wang

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

2D-ACE is a Freescale display controller. It supports at most four plane and provide an hardware cursor.

Quoted 7 lines

This is a simplified version, only a primary plane, a fb created for fbdev, a crtc, a connector for TFT LCD panel, an encoder, and the encoder is not in use. Now this drver support fbdev only.

Quoted 7 lines

Imo adding a new driver without primary plane support (use drm_crtc_init_with_planes) and without atomic support doesn't make sense any more.

Also, what do you mean with "support fbdev only"?
-Daniel

Daniel,

This driver has supported primary plane (use drm_crtc_init_with_planes) Already.
If atomic support is a must? 2D-ACE is a simple display Controller and this is a simplified version. If atomic support is not a must, I want to add it with patches, is it ok?

" Now this drver support fbdev only." if this sentence confuses you, I'd like remove it. In fact I mean that this driver only create a framebuffer dev (use drm_fbdev_cma_init).

Thanks
Regards,
Wang Jianwei

Quoted 1,419 lines
Quoted 7 lines
---
 .../devicetree/bindings/video/fsl,dcfb.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_crtc.c             | 412

+++++++++++++++++++++

Quoted 2 lines
 drivers/gpu/drm/fsl/fsl_dcu_drm_crtc.h             |  40 ++
 drivers/gpu/drm/fsl/fsl_dcu_drm_drv.c              | 323

++++++++++++++++

Quoted 37 lines
 drivers/gpu/drm/fsl/fsl_dcu_drm_drv.h              | 167 +++++++++
 drivers/gpu/drm/fsl/fsl_dcu_drm_fbdev.c            |  43 +++
 drivers/gpu/drm/fsl/fsl_dcu_drm_kms.c              |  45 +++
 drivers/gpu/drm/fsl/fsl_dcu_drm_kms.h              |  22 ++
 drivers/gpu/drm/fsl/fsl_dcu_drm_plane.c            | 124 +++++++
 drivers/gpu/drm/fsl/fsl_dcu_drm_plane.h            |  28 ++
 14 files changed, 1281 insertions(+)
 create mode 100644
Documentation/devicetree/bindings/video/fsl,dcfb.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_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/video/fsl,dcfb.txt new file +9 -0
new file mode 100644
index 0000000..de7da97
@@ -0,0 +1,50 @@
+* Freescale Simple Display Controller FB Driver
+
+Required properties:
+- compatible:		Should be one of "fsl,ls1021a-dcfb".
+- reg:			Address and length of the register set for dcfb.
+- clocks:		From common clock binding: handle to dcfb clock.
+- clock-names:		From common clock binding: Shall be "dcfb".
+- display:		The phandle to display node.
+

Documentation/devicetree/bindings/video/fsl,dcfb.txt line 19

Quoted 10 lines
Documentation/devicetree/bindings/video/fsl,dcfb.txt new file +10 -0
+Optional properties:
+- scfg-controller:	The phandle of scfg 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.

Quoted 120 lines
Documentation/devicetree/bindings/video/fsl,dcfb.txt new file +31 -0
+
+Examples:
+dcfb: dcfb@2ce0000 {
+	compatible = "fsl,ls1021a-dcfb";
+	reg = <0x0 0x2ce0000 0x0 0x10000>;
+	clocks = <&platform_clk 0>;
+	clock-names = "dcfb";
+	scfg-controller = <&scfg>;
+	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 index renamed from drivers/gpu/drm/Kconfig +0 -0

151a050..a6957aa 100644

drivers/gpu/drm/Kconfig +2 -0
@@ -199,6 +199,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 index renamed from drivers/gpu/drm/Makefile +0 -0

2c239b9..ab5b9ef 100644

drivers/gpu/drm/Makefile +1 -0
@@ -56,6 +56,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.
(quoted diff) +0 -0

b/drivers/gpu/drm/fsl/Makefile new file mode 100644 index 0000000..51c3e1f

drivers/gpu/drm/fsl/Makefile new file +7 -0
@@ -0,0 +1,7 @@
+fsl-dcu-drm-y := fsl_dcu_drm_drv.o \
+	       fsl_dcu_drm_kms.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_crtc.c new file +22 -0
new file mode 100644
index 0000000..9f5ba86
@@ -0,0 +1,412 @@
+/*
+ * 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.
+ */
+
+#include <linux/backlight.h>
+#include <linux/clk.h>
+#include <linux/regmap.h>
+
+#include <drm/drmP.h>
+#include <drm/drm_atomic_helper.h>
+#include <drm/drm_crtc.h>
+#include <drm/drm_crtc_helper.h>
+#include <drm/drm_fb_cma_helper.h>

drivers/gpu/drm/fsl/fsl_dcu_drm_crtc.c line 32

Quoted 10 lines
drivers/gpu/drm/fsl/fsl_dcu_drm_crtc.c new file +10 -0
+#include <drm/drm_gem_cma_helper.h>
+#include <drm/drm_plane_helper.h>
+#include <video/of_display_timing.h>
+
+#include "fsl_dcu_drm_crtc.h"
+#include "fsl_dcu_drm_drv.h"
+#include "fsl_dcu_drm_kms.h"
+#include "fsl_dcu_drm_plane.h"
+
+#define to_fsl_dcu_crtc(c)	container_of(c, struct fsl_dcu_drm_crtc,

crtc)

Quoted 95 lines
drivers/gpu/drm/fsl/fsl_dcu_drm_crtc.c new file +95 -0
+
+static void fsl_dcu_drm_crtc_start(struct drm_crtc *crtc) {
+	fsl_dcu_drm_plane_setup(crtc->primary);
+}
+
+static void fsl_dcu_drm_crtc_stop(struct drm_crtc *crtc) { }
+
+void fsl_dcu_drm_crtc_suspend(struct drm_crtc *crtc) {
+	fsl_dcu_drm_crtc_stop(crtc);
+}
+
+void fsl_dcu_drm_crtc_resume(struct drm_crtc *crtc) {
+	struct fsl_dcu_drm_crtc *fsl_crtc = to_fsl_dcu_crtc(crtc);
+
+	if (fsl_crtc->dpms != DRM_MODE_DPMS_ON)
+		return;
+
+	fsl_dcu_drm_crtc_start(crtc);
+}
+
+static void fsl_dcu_drm_crtc_update_base(struct drm_crtc *crtc) { }
+
+static void fsl_dcu_drm_crtc_dpms(struct drm_crtc *crtc, int mode) {
+	struct fsl_dcu_drm_crtc *fsl_crtc = to_fsl_dcu_crtc(crtc);
+
+	if (fsl_crtc->dpms == mode)
+		return;
+
+	if (mode == DRM_MODE_DPMS_ON)
+		fsl_dcu_drm_crtc_start(crtc);
+	else
+		fsl_dcu_drm_crtc_stop(crtc);
+
+	fsl_crtc->dpms = mode;
+}
+
+static bool fsl_dcu_drm_crtc_mode_fixup(struct drm_crtc *crtc,
+					const struct drm_display_mode *mode,
+					struct drm_display_mode *adjusted_mode) {
+	return true;
+}
+
+static void fsl_dcu_drm_crtc_mode_prepare(struct drm_crtc *crtc) {
+		fsl_dcu_drm_crtc_stop(crtc);
+}
+
+static int fsl_dcu_drm_crtc_mode_set(struct drm_crtc *crtc,
+				     struct drm_display_mode *mode,
+				     struct drm_display_mode *adjusted_mode,
+				     int x, int y,
+				     struct drm_framebuffer *old_fb) {
+	struct drm_device *dev = crtc->dev;
+	struct fsl_dcu_drm_device *fsl_dev = dev->dev_private;
+	uint32_t hbp, hfp, hsw, vbp, vfp, vsw, div, index;
+
+	DBG(": set mode: %d:\"%s\" %d %d %d %d %d %d %d %d %d %d 0x%x 0x%x",
+	    mode->base.id, mode->name,
+	    mode->vrefresh, mode->clock,
+	    mode->hdisplay, mode->hsync_start,
+	    mode->hsync_end, mode->htotal,
+	    mode->vdisplay, mode->vsync_start,
+	    mode->vsync_end, mode->vtotal,
+	    mode->type, mode->flags);
+
+	index = drm_crtc_index(crtc);
+	div = (uint32_t)clk_get_rate(fsl_dev->clk) / crtc->mode.clock /
+1000;
+
+	/* Configure timings: */
+	hbp = mode->htotal - mode->hsync_end;
+	hfp = mode->hsync_start - mode->hdisplay;
+	hsw = mode->hsync_end - mode->hsync_start;
+	vbp = mode->vtotal - mode->vsync_end;
+	vfp = mode->vsync_start - mode->vdisplay;
+	vsw = mode->vsync_end - mode->vsync_start;
+
+	regmap_write(fsl_dev->regmap, DCU_HSYN_PARA,
+		     DCU_HSYN_PARA_BP(hbp) |
+		     DCU_HSYN_PARA_PW(hsw) |
+		     DCU_HSYN_PARA_FP(hfp));
+	regmap_write(fsl_dev->regmap, DCU_VSYN_PARA,
+		     DCU_VSYN_PARA_BP(vbp) |
+		     DCU_VSYN_PARA_PW(vsw) |
+		     DCU_VSYN_PARA_FP(vfp));
+	regmap_write(fsl_dev->regmap, DCU_DISP_SIZE,
+		     DCU_DISP_SIZE_DELTA_Y(mode->vdisplay) |
+		     DCU_DISP_SIZE_DELTA_X(mode->hdisplay));
+	regmap_write(fsl_dev->regmap, DCU_CTRLDESCLN_1(index),
+		     DCU_CTRLDESCLN_1_HEIGHT(mode->vdisplay) |
+		     DCU_CTRLDESCLN_1_WIDTH(mode->hdisplay));
+	regmap_write(fsl_dev->regmap, DCU_CTRLDESCLN_2(index),
+		     DCU_CTRLDESCLN_2_POSY(y) |
+		     DCU_CTRLDESCLN_2_POSX(x));
+	regmap_write(fsl_dev->regmap, DCU_DIV_RATIO, div);
+	regmap_write(fsl_dev->regmap, DCU_UPDATE_MODE,

drivers/gpu/drm/fsl/fsl_dcu_drm_crtc.c

Quoted 10 lines
drivers/gpu/drm/fsl/fsl_dcu_drm_crtc.c new file +10 -0
+DCU_UPDATE_MODE_READREG);
+
+	return 0;
+}
+
+static void fsl_dcu_drm_crtc_mode_commit(struct drm_crtc *crtc) {
+		fsl_dcu_drm_crtc_start(crtc);
+}
+
+static int fsl_dcu_drm_crtc_mode_set_base(struct drm_crtc *crtc, int x,

int y,

Quoted 50 lines
drivers/gpu/drm/fsl/fsl_dcu_drm_crtc.c new file +50 -0
+					  struct drm_framebuffer *old_fb) {
+	fsl_dcu_drm_crtc_update_base(crtc);
+
+	return 0;
+}
+
+static const struct drm_crtc_helper_funcs crtc_helper_funcs = {
+	.dpms = fsl_dcu_drm_crtc_dpms,
+	.mode_fixup = fsl_dcu_drm_crtc_mode_fixup,
+	.prepare = fsl_dcu_drm_crtc_mode_prepare,
+	.commit = fsl_dcu_drm_crtc_mode_commit,
+	.mode_set = fsl_dcu_drm_crtc_mode_set,
+	.mode_set_base = fsl_dcu_drm_crtc_mode_set_base, };
+
+static int fsl_dcu_drm_crtc_page_flip(struct drm_crtc *crtc,
+				      struct drm_framebuffer *fb,
+				      struct drm_pending_vblank_event *event,
+				      uint32_t page_flip_flags)
+{
+	return 0;
+}
+
+static const struct drm_plane_funcs fsl_dcu_drm_plane_funcs = {
+	.update_plane = fsl_dcu_drm_plane_update,
+	.disable_plane = fsl_dcu_drm_plane_disable,
+	.destroy = fsl_dcu_drm_plane_destroy, };
+
+static const struct drm_crtc_funcs crtc_funcs = {
+	.destroy = drm_crtc_cleanup,
+	.set_config = drm_crtc_helper_set_config,
+	.page_flip = fsl_dcu_drm_crtc_page_flip, };
+
+int fsl_dcu_drm_crtc_create(struct fsl_dcu_drm_device *fsl_dev) {
+	struct drm_crtc *crtc = &fsl_dev->crtc.crtc;
+	int ret;
+
+	fsl_dev->crtc.dpms = DRM_MODE_DPMS_OFF;
+
+	ret = drm_crtc_init(fsl_dev->ddev, crtc, &crtc_funcs);
+	if (ret < 0)
+		return ret;
+
+	crtc->primary->funcs = &fsl_dcu_drm_plane_funcs;
+
+	drm_crtc_helper_add(crtc, &crtc_helper_funcs);
+
+	regmap_write(fsl_dev->regmap, DCU_SYN_POL,
+		     DCU_SYN_POL_INV_VS_LOW | DCU_SYN_POL_INV_HS_LOW);
+	regmap_write(fsl_dev->regmap, DCU_BGND, DCU_BGND_R(0) |
+		     DCU_BGND_G(0) | DCU_BGND_B(0));

drivers/gpu/drm/fsl/fsl_dcu_drm_crtc.c

Quoted 10 lines
drivers/gpu/drm/fsl/fsl_dcu_drm_crtc.c new file +10 -0
+	regmap_write(fsl_dev->regmap, DCU_DCU_MODE,
+		     DCU_MODE_BLEND_ITER(1) | DCU_MODE_RASTER_EN);
+	regmap_write(fsl_dev->regmap, DCU_THRESHOLD,
+		     DCU_THRESHOLD_LS_BF_VS(BF_VS_VAL) |
+		     DCU_THRESHOLD_OUT_BUF_HIGH(BUF_MAX_VAL) |
+		     DCU_THRESHOLD_OUT_BUF_LOW(BUF_MIN_VAL));
+	regmap_update_bits(fsl_dev->regmap, DCU_DCU_MODE,
+			   DCU_MODE_DCU_MODE_MASK,
+			   DCU_MODE_DCU_MODE(DCU_MODE_NORMAL));
+	regmap_write(fsl_dev->regmap, DCU_UPDATE_MODE,

DCU_UPDATE_MODE_READREG);

Quoted 25 lines
drivers/gpu/drm/fsl/fsl_dcu_drm_crtc.c new file +25 -0
+	return 0;
+}
+
+/*
+ * Encoder
+ */
+
+#define to_fsl_dcu_encoder(e) \
+	container_of(e, struct fsl_dcu_drm_encoder, encoder)
+
+static void fsl_dcu_drm_encoder_dpms(struct drm_encoder *encoder, int
+mode) {
+	struct fsl_dcu_drm_encoder *fsl_enc = to_fsl_dcu_encoder(encoder);
+
+	if (fsl_enc->dpms == mode)
+		return;
+
+	fsl_enc->dpms = mode;
+}
+
+static bool fsl_dcu_drm_encoder_mode_fixup
+		(struct drm_encoder *encoder,
+		const struct drm_display_mode *mode,
+		struct drm_display_mode *adjusted_mode) {
+	struct drm_device *dev = encoder->dev;

drivers/gpu/drm/fsl/fsl_dcu_drm_crtc.c

Quoted 10 lines
drivers/gpu/drm/fsl/fsl_dcu_drm_crtc.c new file +10 -0
+	struct fsl_dcu_drm_device *fsl_dev = dev->dev_private;
+	struct drm_connector *connector = &fsl_dev->connector.connector;
+	const struct drm_display_mode *panel_mode;
+
+	if (list_empty(&connector->modes)) {
+		dev_dbg(dev->dev, "mode_fixup: empty modes list\n");
+		return false;
+	}
+
+	/* The flat panel mode is fixed, just copy it to the adjusted mode.

*/

Quoted 72 lines
drivers/gpu/drm/fsl/fsl_dcu_drm_crtc.c new file +72 -0
+	panel_mode = list_first_entry(&connector->modes,
+				      struct drm_display_mode, head);
+	drm_mode_copy(adjusted_mode, panel_mode);
+
+	return true;
+}
+
+static void fsl_dcu_drm_encoder_mode_prepare(struct drm_encoder
+*encoder) { }
+
+static void fsl_dcu_drm_encoder_mode_set(struct drm_encoder *encoder,
+					 struct drm_display_mode *mode,
+					 struct drm_display_mode *adjusted_mode) { }
+
+static void fsl_dcu_drm_encoder_mode_commit(struct drm_encoder
+*encoder) {
+	;
+}
+
+static const struct drm_encoder_helper_funcs encoder_helper_funcs = {
+	.dpms = fsl_dcu_drm_encoder_dpms,
+	.mode_fixup = fsl_dcu_drm_encoder_mode_fixup,
+	.prepare = fsl_dcu_drm_encoder_mode_prepare,
+	.commit = fsl_dcu_drm_encoder_mode_commit,
+	.mode_set = fsl_dcu_drm_encoder_mode_set, };
+
+static void fsl_dcu_drm_encoder_destroy(struct drm_encoder *encoder)
+{
+	drm_encoder_cleanup(encoder);
+}
+
+static const struct drm_encoder_funcs encoder_funcs = {
+	.destroy = fsl_dcu_drm_encoder_destroy, };
+
+int fsl_dcu_drm_encoder_create(struct fsl_dcu_drm_device *fsl_dev) {
+	struct drm_encoder *encoder = &fsl_dev->encoder.encoder;
+	int ret;
+
+	fsl_dev->encoder.dpms = DRM_MODE_DPMS_OFF;
+
+	encoder->possible_crtcs = 1;
+
+	ret = drm_encoder_init(fsl_dev->ddev, encoder, &encoder_funcs,
+			       DRM_MODE_ENCODER_LVDS);
+	if (ret < 0)
+		return ret;
+
+	drm_encoder_helper_add(encoder, &encoder_helper_funcs);
+
+	return 0;
+}
+
+/*
+ * Connector
+ */
+
+#define to_fsl_dcu_connector(c) \
+	container_of(c, struct fsl_dcu_drm_connector, connector)
+
+static int fsl_dcu_drm_connector_get_modes(struct drm_connector
+*connector) {
+	struct drm_device *dev = connector->dev;
+	struct device_node *display_np, *np = dev->dev->of_node;
+	struct drm_display_mode *mode = drm_mode_create(connector->dev);
+	int num_modes = 0;
+
+	if (np) {
+		display_np = of_parse_phandle(np, "display", 0);
+		if (!display_np) {
+			dev_err(dev->dev, "failed to find display phandle\n");
+			return num_modes;
+		}

drivers/gpu/drm/fsl/fsl_dcu_drm_crtc.c

Quoted 10 lines
drivers/gpu/drm/fsl/fsl_dcu_drm_crtc.c new file +10 -0
+		of_get_drm_display_mode(display_np, mode, OF_USE_NATIVE_MODE);
+		mode->type |= DRM_MODE_TYPE_DRIVER | DRM_MODE_TYPE_PREFERRED,
+		drm_mode_probed_add(connector, mode);
+		num_modes++;
+	}
+
+	return num_modes;
+}
+
+static int fsl_dcu_drm_connector_mode_valid(struct drm_connector

*connector,

drivers/gpu/drm/fsl/fsl_dcu_drm_crtc.c

Quoted 13 lines
drivers/gpu/drm/fsl/fsl_dcu_drm_crtc.c new file +13 -0
+					    struct drm_display_mode *mode) {
+	return MODE_OK;
+}
+
+static struct drm_encoder *
+fsl_dcu_drm_connector_best_encoder(struct drm_connector *connector) {
+	struct fsl_dcu_drm_connector *fsl_con =
+to_fsl_dcu_connector(connector);
+
+	return fsl_con->encoder;
+}
+
+static const struct drm_connector_helper_funcs connector_helper_funcs

= {

Quoted 279 lines
drivers/gpu/drm/fsl/fsl_dcu_drm_crtc.c new file +63 -0
+	.get_modes = fsl_dcu_drm_connector_get_modes,
+	.mode_valid = fsl_dcu_drm_connector_mode_valid,
+	.best_encoder = fsl_dcu_drm_connector_best_encoder,
+};
+
+static void fsl_dcu_drm_connector_destroy(struct drm_connector
+*connector) {
+	drm_connector_unregister(connector);
+	drm_connector_cleanup(connector);
+}
+
+static enum drm_connector_status
+fsl_dcu_drm_connector_detect(struct drm_connector *connector, bool
+force) {
+	return connector_status_connected;
+}
+
+static const struct drm_connector_funcs connector_funcs = {
+	.dpms = drm_helper_connector_dpms,
+	.detect = fsl_dcu_drm_connector_detect,
+	.fill_modes = drm_helper_probe_single_connector_modes,
+	.destroy = fsl_dcu_drm_connector_destroy, };
+
+int fsl_dcu_drm_connector_create(struct fsl_dcu_drm_device *fsl_dev,
+				 struct drm_encoder *encoder)
+{
+	struct drm_connector *connector = &fsl_dev->connector.connector;
+	int ret;
+
+	fsl_dev->connector.encoder = encoder;
+
+	connector->display_info.width_mm = 0;
+	connector->display_info.height_mm = 0;
+
+	ret = drm_connector_init(fsl_dev->ddev, connector, &connector_funcs,
+				 DRM_MODE_CONNECTOR_LVDS);
+	if (ret < 0)
+		return ret;
+
+	drm_connector_helper_add(connector, &connector_helper_funcs);
+	ret = drm_connector_register(connector);
+	if (ret < 0)
+		goto err_cleanup;
+
+	ret = drm_mode_connector_attach_encoder(connector, encoder);
+	if (ret < 0)
+		goto err_sysfs;
+
+	connector->encoder = encoder;
+
+	drm_helper_connector_dpms(connector, DRM_MODE_DPMS_OFF);
+	drm_object_property_set_value
+		(&connector->base, fsl_dev->ddev->mode_config.dpms_property,
+		DRM_MODE_DPMS_OFF);
+
+	return 0;
+
+err_sysfs:
+	drm_connector_unregister(connector);
+err_cleanup:
+	drm_connector_cleanup(connector);
+	return ret;
+}
drivers/gpu/drm/fsl/fsl_dcu_drm_crtc.h new file +42 -0
new file mode 100644
index 0000000..ad59992
@@ -0,0 +1,40 @@
+/*
+ * 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_MODSET_H__
+#define __FSL_DCU_DRM_MODSET_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;
+};
+
+struct fsl_dcu_drm_encoder {
+	struct drm_encoder encoder;
+	int dpms;
+};
+
+struct fsl_dcu_drm_connector {
+	struct drm_connector connector;
+	struct drm_encoder *encoder;
+};
+
+int fsl_dcu_drm_crtc_create(struct fsl_dcu_drm_device *fsl_dev); int
+fsl_dcu_drm_encoder_create(struct fsl_dcu_drm_device *fsl_dev); int
+fsl_dcu_drm_connector_create(struct fsl_dcu_drm_device *fsl_dev,
+				 struct drm_encoder *encoder);
+
+#endif /* __FSL_DCU_DRM_MODSET_H__ */
drivers/gpu/drm/fsl/fsl_dcu_drm_drv.c new file +160 -0
new file mode 100644
index 0000000..1bca45a
@@ -0,0 +1,323 @@
+/*
+ * 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.
+ */
+
+#include <linux/clk.h>
+#include <linux/io.h>
+#include <linux/mm.h>
+#include <linux/module.h>
+#include <linux/of_platform.h>
+#include <linux/platform_device.h>
+#include <linux/pm.h>
+#include <linux/pm_runtime.h>
+#include <linux/regmap.h>
+#include <linux/slab.h>
+
+#include <drm/drmP.h>
+#include "fsl_dcu_drm_drv.h"
+#include "fsl_dcu_drm_kms.h"
+
+static int fsl_dcu_unload(struct drm_device *dev) {
+	drm_mode_config_cleanup(dev);
+	drm_vblank_cleanup(dev);
+	drm_irq_uninstall(dev);
+
+	dev->dev_private = NULL;
+
+	return 0;
+}
+
+static struct regmap_config fsl_dcu_regmap_config = {
+	.reg_bits = 32,
+	.reg_stride = 4,
+	.val_bits = 32,
+};
+
+static int fsl_dcu_bypass_tcon(struct fsl_dcu_drm_device *fsl_dev,
+			       struct device_node *np)
+{
+	struct device_node *tcon_np;
+	struct platform_device *pdev;
+	struct clk *tcon_clk;
+	struct resource *res;
+	void __iomem *base;
+
+	tcon_np = of_parse_phandle(np, "tcon-controller", 0);
+	if (!tcon_np)
+		return -EINVAL;
+
+	pdev = of_find_device_by_node(tcon_np);
+	if (!pdev)
+		return -EINVAL;
+
+	tcon_clk = devm_clk_get(&pdev->dev, "tcon");
+	if (IS_ERR(tcon_clk))
+		return PTR_ERR(tcon_clk);
+	clk_prepare_enable(tcon_clk);
+
+	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+	if (!res)
+		return -ENODEV;
+
+	base = devm_ioremap_resource(&pdev->dev, res);
+	if (IS_ERR(base))
+		return PTR_ERR(base);
+
+	fsl_dev->tcon_regmap = devm_regmap_init_mmio_clk(&pdev->dev,
+			"tcon", base, &fsl_dcu_regmap_config);
+	if (IS_ERR(fsl_dev->tcon_regmap)) {
+		dev_err(&pdev->dev, "regmap init failed\n");
+		return PTR_ERR(fsl_dev->tcon_regmap);
+	}
+
+	regmap_write(fsl_dev->tcon_regmap, TCON_CTRL1, TCON_BYPASS_ENABLE);
+	return 0;
+}
+
+static int fsl_dcu_scfg_config(struct fsl_dcu_drm_device *fsl_dev,
+			       struct device_node *np)
+{
+	struct device_node *scfg_np;
+	struct platform_device *pdev;
+	struct resource *res;
+	void __iomem *base;
+
+	scfg_np = of_parse_phandle(np, "scfg-controller", 0);
+	if (!scfg_np)
+		return 0;
+
+	pdev = of_find_device_by_node(scfg_np);
+	if (!pdev)
+		return -EINVAL;
+
+	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+	if (!res)
+		return -ENODEV;
+
+	base = devm_ioremap_resource(&pdev->dev, res);
+	if (IS_ERR(base))
+		return PTR_ERR(base);
+
+	fsl_dev->scfg_regmap = devm_regmap_init_mmio_clk(&pdev->dev,
+			NULL, base, &fsl_dcu_regmap_config);
+	if (IS_ERR(fsl_dev->scfg_regmap)) {
+		dev_err(&pdev->dev, "regmap init failed\n");
+		return PTR_ERR(fsl_dev->scfg_regmap);
+	}
+
+	regmap_write(fsl_dev->scfg_regmap, 0x28, 0x80000000);
+
+	return 0;
+}
+
+static int fsl_dcu_load(struct drm_device *dev, unsigned long flags)
+{
+	struct platform_device *pdev = dev->platformdev;
+	struct fsl_dcu_drm_device *fsl_dev;
+	struct resource *res;
+	void __iomem *base;
+	int ret;
+
+	fsl_dev = devm_kzalloc(&pdev->dev, sizeof(*fsl_dev), GFP_KERNEL);
+	if (!fsl_dev)
+		return -ENOMEM;
+
+	fsl_dev->dev = &pdev->dev;
+	fsl_dev->ddev = dev;
+	dev->dev_private = fsl_dev;
+
+	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+	base = devm_ioremap_resource(&pdev->dev, res);
+	if (IS_ERR(base)) {
+		ret = PTR_ERR(base);
+		return ret;
+	}
+
+	fsl_dev->regmap = devm_regmap_init_mmio(&pdev->dev,
+			base, &fsl_dcu_regmap_config);
+	if (IS_ERR(fsl_dev->regmap)) {
+		dev_err(&pdev->dev, "regmap init failed\n");
+		return PTR_ERR(fsl_dev->regmap);
+	}
+
+	ret = fsl_dcu_drm_modeset_init(fsl_dev);
+	if (ret < 0) {
+		dev_err(&pdev->dev, "failed to initialize mode setting\n");
+		return ret;
+	}
+
+	ret = drm_vblank_init(dev, 1);
+	if (ret < 0) {
+		dev_err(&pdev->dev, "failed to initialize vblank\n");

drivers/gpu/drm/fsl/fsl_dcu_drm_drv.c line 170

Quoted 10 lines
drivers/gpu/drm/fsl/fsl_dcu_drm_drv.c new file +10 -0
+		goto done;
+	}
+
+	ret = drm_irq_install(dev, platform_get_irq(dev->platformdev, 0));
+	if (ret < 0) {
+		dev_err(&pdev->dev, "failed to install IRQ handler\n");
+		goto done;
+	}
+
+	/* Put TCON in bypass mode, so the input signals from DCU are

passed

Quoted 397 lines
drivers/gpu/drm/fsl/fsl_dcu_drm_drv.c new file +148 -0
+	 * through TCON unchanged */
+	fsl_dcu_bypass_tcon(fsl_dev, pdev->dev.of_node);
+	fsl_dcu_scfg_config(fsl_dev, pdev->dev.of_node);
+
+	fsl_dev->clk = devm_clk_get(&pdev->dev, "dcfb");
+	if (IS_ERR(fsl_dev->clk)) {
+		ret = PTR_ERR(fsl_dev->clk);
+		dev_err(&pdev->dev, "could not get clock\n");
+		return ret;
+	}
+	clk_prepare_enable(fsl_dev->clk);
+
+	dev_set_drvdata(dev->dev, fsl_dev);
+
+	fsl_dcu_fbdev_init(dev);
+
+	return 0;
+done:
+	if (ret)
+		fsl_dcu_unload(dev);
+
+	return ret;
+}
+
+static void fsl_dcu_drm_preclose(struct drm_device *dev, struct
+drm_file *file) {
+	;
+}
+
+static irqreturn_t fsl_dcu_drm_irq(int irq, void *arg) {
+	return IRQ_HANDLED;
+}
+
+static int fsl_dcu_drm_enable_vblank(struct drm_device *dev, int
+crtc) {
+	return 0;
+}
+
+static void fsl_dcu_drm_disable_vblank(struct drm_device *dev, int
+crtc) {
+	;
+}
+
+static const struct file_operations fsl_dcu_drm_fops = {
+	.owner		= THIS_MODULE,
+	.open		= drm_open,
+	.release	= drm_release,
+	.unlocked_ioctl	= drm_ioctl,
+#ifdef CONFIG_COMPAT
+	.compat_ioctl	= drm_compat_ioctl,
+#endif
+	.poll		= drm_poll,
+	.read		= drm_read,
+	.llseek		= no_llseek,
+	.mmap		= drm_gem_cma_mmap,
+};
+
+static struct drm_driver fsl_dcu_drm_driver = {
+	.driver_features	= DRIVER_HAVE_IRQ | DRIVER_GEM | DRIVER_MODESET
+				| DRIVER_PRIME,
+	.load			= fsl_dcu_load,
+	.unload			= fsl_dcu_unload,
+	.preclose		= fsl_dcu_drm_preclose,
+	.irq_handler		= fsl_dcu_drm_irq,
+	.get_vblank_counter	= drm_vblank_count,
+	.enable_vblank		= fsl_dcu_drm_enable_vblank,
+	.disable_vblank		= fsl_dcu_drm_disable_vblank,
+	.gem_free_object	= drm_gem_cma_free_object,
+	.gem_vm_ops		= &drm_gem_cma_vm_ops,
+	.prime_handle_to_fd	= drm_gem_prime_handle_to_fd,
+	.prime_fd_to_handle	= drm_gem_prime_fd_to_handle,
+	.gem_prime_import	= drm_gem_prime_import,
+	.gem_prime_export	= drm_gem_prime_export,
+	.gem_prime_get_sg_table	= drm_gem_cma_prime_get_sg_table,
+	.gem_prime_import_sg_table = drm_gem_cma_prime_import_sg_table,
+	.gem_prime_vmap		= drm_gem_cma_prime_vmap,
+	.gem_prime_vunmap	= drm_gem_cma_prime_vunmap,
+	.gem_prime_mmap		= drm_gem_cma_prime_mmap,
+	.dumb_create		= drm_gem_cma_dumb_create,
+	.dumb_map_offset	= drm_gem_cma_dumb_map_offset,
+	.dumb_destroy		= drm_gem_dumb_destroy,
+	.fops			= &fsl_dcu_drm_fops,
+	.name			= "fsl-dcu-drm",
+	.desc			= "Freescale DCU DRM",
+	.date			= "20150213",
+	.major			= 1,
+	.minor			= 0,
+};
+
+#ifdef CONFIG_PM_SLEEP
+static int fsl_dcu_drm_pm_suspend(struct device *dev) {
+	struct fsl_dcu_drm_device *fsl_dev = dev_get_drvdata(dev);
+
+	drm_kms_helper_poll_disable(fsl_dev->ddev);
+	fsl_dcu_drm_crtc_suspend(&fsl_dev->crtc);
+
+	return 0;
+}
+
+static int fsl_dcu_drm_pm_resume(struct device *dev) {
+	struct fsl_dcu_drm_device *fsl_dev = dev_get_drvdata(dev);
+
+	drm_modeset_lock_all(fsl_dev->ddev);
+	fsl_dcu_drm_crtc_resume(&fsl_dev->crtc);
+	drm_modeset_unlock_all(fsl_dev->ddev);
+
+	drm_kms_helper_poll_enable(fsl_dev->ddev);
+	return 0;
+}
+#endif
+
+static const struct dev_pm_ops fsl_dcu_drm_pm_ops = {
+	SET_SYSTEM_SLEEP_PM_OPS(fsl_dcu_drm_pm_suspend,
+fsl_dcu_drm_pm_resume) };
+
+static int fsl_dcu_drm_probe(struct platform_device *pdev) {
+	return drm_platform_init(&fsl_dcu_drm_driver, pdev); }
+
+static int fsl_dcu_drm_remove(struct platform_device *pdev) {
+	struct fsl_dcu_drm_device *fsl_dev = platform_get_drvdata(pdev);
+
+	drm_put_dev(fsl_dev->ddev);
+
+	return 0;
+}
+
+static struct of_device_id fsl_dcu_of_match[] = {
+		{ .compatible = "fsl,ls1021a-dcfb", },
+		{ },
+};
+MODULE_DEVICE_TABLE(of, fsl_dcu_of_match);
+
+static struct platform_driver fsl_dcu_drm_platform_driver = {
+	.probe		= fsl_dcu_drm_probe,
+	.remove		= fsl_dcu_drm_remove,
+	.driver		= {
+		.owner	= THIS_MODULE,
+		.name	= "fsl,ls1021a-dcfb",
+		.pm	= &fsl_dcu_drm_pm_ops,
+		.of_match_table = fsl_dcu_of_match,
+	},
+};
+
+module_platform_driver(fsl_dcu_drm_platform_driver);
+
+MODULE_ALIAS("platform:fsl-dcu-drm");
+MODULE_DESCRIPTION("Freescale DCU DRM Driver");
+MODULE_LICENSE("GPL");
drivers/gpu/drm/fsl/fsl_dcu_drm_drv.h new file +168 -0
new file mode 100644
index 0000000..8dc7c10
@@ -0,0 +1,167 @@
+/*
+ * 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_DRV_H__
+#define __FSL_DCU_DRM_DRV_H__
+
+#include <linux/kernel.h>
+#include <linux/spinlock.h>
+#include <stddef.h>
+#include <drm/drm.h>
+#include <drm/drmP.h>
+#include <drm/drm_fb_helper.h>
+#include <drm/drm_crtc_helper.h>
+#include <drm/drm_gem_cma_helper.h>
+#include <drm/drm_fb_cma_helper.h>
+
+#include "fsl_dcu_drm_crtc.h"
+#define DRIVER_NAME			"fsl-dcu-fb"
+
+#define DCU_DCU_MODE			0x0010
+#define DCU_MODE_BLEND_ITER(x)		((x) << 20)
+#define DCU_MODE_RASTER_EN		BIT(14)
+#define DCU_MODE_DCU_MODE(x)		(x)
+#define DCU_MODE_DCU_MODE_MASK		0x03
+#define DCU_MODE_OFF			0
+#define DCU_MODE_NORMAL			1
+#define DCU_MODE_TEST			2
+#define DCU_MODE_COLORBAR		3
+
+#define DCU_BGND			0x0014
+#define DCU_BGND_R(x)			((x) << 16)
+#define DCU_BGND_G(x)			((x) << 8)
+#define DCU_BGND_B(x)			(x)
+
+#define DCU_DISP_SIZE			0x0018
+#define DCU_DISP_SIZE_DELTA_Y(x)	((x) << 16)
+/*Regisiter value 1/16 of horizontal resolution*/
+#define DCU_DISP_SIZE_DELTA_X(x)	((x) >> 4)
+
+#define DCU_HSYN_PARA			0x001c
+#define DCU_HSYN_PARA_BP(x)		((x) << 22)
+#define DCU_HSYN_PARA_PW(x)		((x) << 11)
+#define DCU_HSYN_PARA_FP(x)		(x)
+
+#define DCU_VSYN_PARA			0x0020
+#define DCU_VSYN_PARA_BP(x)		((x) << 22)
+#define DCU_VSYN_PARA_PW(x)		((x) << 11)
+#define DCU_VSYN_PARA_FP(x)		(x)
+
+#define DCU_SYN_POL			0x0024
+#define DCU_SYN_POL_INV_PXCK_FALL	(0 << 6)
+#define DCU_SYN_POL_NEG_REMAIN		(0 << 5)
+#define DCU_SYN_POL_INV_VS_LOW		BIT(1)
+#define DCU_SYN_POL_INV_HS_LOW		(1)
+
+#define DCU_THRESHOLD			0x0028
+#define DCU_THRESHOLD_LS_BF_VS(x)	((x) << 16)
+#define DCU_THRESHOLD_OUT_BUF_HIGH(x)	((x) << 8)
+#define DCU_THRESHOLD_OUT_BUF_LOW(x)	(x)
+#define BF_VS_VAL			0x03
+#define BUF_MAX_VAL			0x78
+#define BUF_MIN_VAL			0x0a
+
+#define DCU_INT_STATUS			0x002C
+#define DCU_INT_STATUS_UNDRUN		BIT(1)
+
+#define DCU_INT_MASK			0x0030
+#define DCU_INT_MASK_UNDRUN		BIT(1)
+#define DCU_INT_MASK_VBLANK		BIT(3)
+
+#define DCU_DIV_RATIO			0x0054
+
+#define DCU_UPDATE_MODE			0x00cc
+#define DCU_UPDATE_MODE_MODE		BIT(31)
+#define DCU_UPDATE_MODE_READREG		BIT(30)
+
+#define DCU_DCFB_MAX			0x300
+
+#define DCU_CTRLDESCLN_1(x)		(0x200 + (x) * 0x40)
+#define DCU_CTRLDESCLN_1_HEIGHT(x)	((x) << 16)
+#define DCU_CTRLDESCLN_1_WIDTH(x)	(x)
+
+#define DCU_CTRLDESCLN_2(x)		(0x204 + (x) * 0x40)
+#define DCU_CTRLDESCLN_2_POSY(x)	((x) << 16)
+#define DCU_CTRLDESCLN_2_POSX(x)	(x)
+
+#define DCU_CTRLDESCLN_3(x)		(0x208 + (x) * 0x40)
+
+#define DCU_CTRLDESCLN_4(x)		(0x20c + (x) * 0x40)
+#define DCU_CTRLDESCLN_4_EN		BIT(31)
+#define DCU_CTRLDESCLN_4_TILE_EN	BIT(30)
+#define DCU_CTRLDESCLN_4_DATA_SEL_CLUT	BIT(29)
+#define DCU_CTRLDESCLN_4_SAFETY_EN	BIT(28)
+#define DCU_CTRLDESCLN_4_TRANS(x)	((x) << 20)
+#define DCU_CTRLDESCLN_4_BPP(x)		((x) << 16)
+#define DCU_CTRLDESCLN_4_RLE_EN		BIT(15)
+#define DCU_CTRLDESCLN_4_LUOFFS(x)	((x) << 4)
+#define DCU_CTRLDESCLN_4_BB_ON		BIT(2)
+#define DCU_CTRLDESCLN_4_AB(x)		(x)
+
+#define DCU_CTRLDESCLN_5(x)		(0x210 + (x) * 0x40)
+#define DCU_CTRLDESCLN_5_CKMAX_R(x)	((x) << 16)
+#define DCU_CTRLDESCLN_5_CKMAX_G(x)	((x) << 8)
+#define DCU_CTRLDESCLN_5_CKMAX_B(x)	(x)
+
+#define DCU_CTRLDESCLN_6(x)		(0x214 + (x) * 0x40)
+#define DCU_CTRLDESCLN_6_CKMIN_R(x)	((x) << 16)
+#define DCU_CTRLDESCLN_6_CKMIN_G(x)	((x) << 8)
+#define DCU_CTRLDESCLN_6_CKMIN_B(x)	(x)
+
+#define DCU_CTRLDESCLN_7(x)		(0x218 + (x) * 0x40)
+#define DCU_CTRLDESCLN_7_TILE_VER(x)	((x) << 16)
+#define DCU_CTRLDESCLN_7_TILE_HOR(x)	(x)
+
+#define DCU_CTRLDESCLN_8(x)		(0x21c + (x) * 0x40)
+#define DCU_CTRLDESCLN_8_FG_FCOLOR(x)	(x)
+
+#define DCU_CTRLDESCLN_9(x)		(0x220 + (x) * 0x40)
+#define DCU_CTRLDESCLN_9_BG_BCOLOR(x)	(x)
+
+#define DCU_CTRLDESCLN_10(x)		(0x224 + (x) * 0x40)
+#define DCU_CTRLDESCLN_10_POST_SKIP(x)	((x) << 16)
+#define DCU_CTRLDESCLN_10_PRE_SKIP(x)	(x)
+
+#define FSL_DCU_RGB565			4
+#define FSL_DCU_RGB888			5
+#define FSL_DCU_ARGB8888		6
+#define FSL_DCU_ARGB1555		11
+#define FSL_DCU_ARGB4444		12
+#define FSL_DCU_YUV422			14
+
+#define TCON_CTRL1			0x0000
+#define TCON_BYPASS_ENABLE		BIT(29)
+
+#define DBG(fmt, ...) DRM_DEBUG(fmt"\n", ##__VA_ARGS__)
+
+struct clk;
+struct device;
+struct drm_device;
+
+struct fsl_dcu_drm_device {
+	struct device *dev;
+	struct regmap *regmap;
+	struct regmap *tcon_regmap;
+	struct regmap *scfg_regmap;
+	unsigned int irq;
+	struct clk *clk;
+	/*protects hardware register*/
+	spinlock_t irq_lock;
+	struct drm_device *ddev;
+	struct drm_fbdev_cma *fbdev;
+	struct fsl_dcu_drm_crtc crtc;
+	struct fsl_dcu_drm_encoder encoder;
+	struct fsl_dcu_drm_connector connector; };
+
+void fsl_dcu_fbdev_init(struct drm_device *dev);
+
+#endif /* __FSL_DCU_DRM_DRV_H__ */
drivers/gpu/drm/fsl/fsl_dcu_drm_fbdev.c new file +46 -0
new file mode 100644
index 0000000..6729f92
@@ -0,0 +1,43 @@
+/*
+ * 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_crtc.h>
+#include <drm/drm_fb_helper.h>
+#include <drm/drm_crtc_helper.h>
+#include <drm/drm_fb_cma_helper.h>
+#include <drm/drm_gem_cma_helper.h>
+#include <linux/clk.h>
+#include <linux/delay.h>
+#include <linux/dma-mapping.h>
+#include <linux/fb.h>
+#include <linux/interrupt.h>
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/of_platform.h>
+#include <linux/regmap.h>
+#include <video/of_display_timing.h>
+#include <video/videomode.h>
+#include <linux/uaccess.h>
+
+#include "fsl_dcu_drm_drv.h"
+#include "fsl_dcu_drm_crtc.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 +14 -0
new file mode 100644
index 0000000..0eb0652
@@ -0,0 +1,45 @@
+/*
+ * 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.
+ */
+
+#include <drm/drmP.h>

drivers/gpu/drm/fsl/fsl_dcu_drm_kms.c line 24

Quoted 10 lines
drivers/gpu/drm/fsl/fsl_dcu_drm_kms.c new file +10 -0
+#include <drm/drm_crtc.h>
+#include <drm/drm_crtc_helper.h>
+#include <drm/drm_fb_cma_helper.h>
+#include <drm/drm_gem_cma_helper.h>
+
+#include "fsl_dcu_drm_crtc.h"
+#include "fsl_dcu_drm_drv.h"
+#include "fsl_dcu_drm_kms.h"
+
+static const struct drm_mode_config_funcs

fsl_dcu_drm_mode_config_funcs = {

Quoted 146 lines
drivers/gpu/drm/fsl/fsl_dcu_drm_kms.c new file +22 -0
+	.fb_create = drm_fb_cma_create,
+};
+
+int fsl_dcu_drm_modeset_init(struct fsl_dcu_drm_device *fsl_dev) {
+	drm_mode_config_init(fsl_dev->ddev);
+
+	fsl_dev->ddev->mode_config.min_width = 0;
+	fsl_dev->ddev->mode_config.min_height = 0;
+	fsl_dev->ddev->mode_config.max_width = 2031;
+	fsl_dev->ddev->mode_config.max_height = 2047;
+	fsl_dev->ddev->mode_config.funcs = &fsl_dcu_drm_mode_config_funcs;
+
+	fsl_dcu_drm_crtc_create(fsl_dev);
+	fsl_dcu_drm_encoder_create(fsl_dev);
+	fsl_dcu_drm_connector_create(fsl_dev, &fsl_dev->encoder.encoder);
+
+	drm_kms_helper_poll_init(fsl_dev->ddev);
+
+	drm_helper_disable_unused_functions(fsl_dev->ddev);
+
+	return 0;
+}
drivers/gpu/drm/fsl/fsl_dcu_drm_kms.h new file +24 -0
new file mode 100644
index 0000000..9d5b798
@@ -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_DRM_KMS_H__
+#define __FSL_DCU_DRM_KMS_H__
+
+#include <linux/types.h>
+
+struct drm_gem_cma_object;
+struct fsl_dcu_drm_device;
+
+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 +65 -0
new file mode 100644
index 0000000..d725594
@@ -0,0 +1,124 @@
+/*
+ * 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.
+ */
+
+#include <drm/drmP.h>
+#include <drm/drm_crtc.h>
+#include <drm/drm_crtc_helper.h>
+#include <drm/drm_fb_cma_helper.h>
+#include <drm/drm_gem_cma_helper.h>
+#include <linux/regmap.h>
+
+#include "fsl_dcu_drm_drv.h"
+#include "fsl_dcu_drm_kms.h"
+#include "fsl_dcu_drm_plane.h"
+
+static void __fsl_dcu_drm_plane_setup(struct drm_plane *plane,
+				      struct drm_framebuffer *fb) {
+	struct fsl_dcu_drm_device *fsl_dev = plane->dev->dev_private;
+	u32 plane_num = 0, alpha, bpp;
+	struct drm_gem_cma_object *gem;
+
+	while (plane->possible_crtcs >> 1)
+		plane_num++;
+
+	gem = drm_fb_cma_get_gem_obj(fb, 0);
+
+	switch (fb->pixel_format) {
+	case DRM_FORMAT_RGB565:
+		bpp = FSL_DCU_RGB565;
+		alpha = 0xff;
+		break;
+	case DRM_FORMAT_RGB888:
+		bpp = FSL_DCU_RGB888;
+		alpha = 0xff;
+		break;
+	case DRM_FORMAT_ARGB8888:
+		bpp = FSL_DCU_ARGB8888;
+		alpha = 0xff;
+		break;
+	case DRM_FORMAT_BGRA4444:
+		bpp = FSL_DCU_ARGB4444;
+		alpha = 0xff;
+		break;
+	case DRM_FORMAT_ARGB1555:
+		bpp = FSL_DCU_ARGB1555;
+		alpha = 0xff;
+		break;
+	case DRM_FORMAT_YUV422:
+		bpp = FSL_DCU_YUV422;
+		alpha = 0xff;
+		break;
+	default:
+		return;
+	}
+
+	regmap_write(fsl_dev->regmap, DCU_CTRLDESCLN_3(plane_num), gem-

paddr);

drivers/gpu/drm/fsl/fsl_dcu_drm_plane.c new file +20 -0
+	regmap_write(fsl_dev->regmap, DCU_CTRLDESCLN_4(plane_num),
+		     DCU_CTRLDESCLN_4_EN |
+		     DCU_CTRLDESCLN_4_TRANS(alpha) |
+		     DCU_CTRLDESCLN_4_BPP(bpp) |
+		     DCU_CTRLDESCLN_4_AB(2));
+	regmap_write(fsl_dev->regmap, DCU_CTRLDESCLN_5(plane_num),
+		     DCU_CTRLDESCLN_5_CKMAX_R(0xFF) |
+		     DCU_CTRLDESCLN_5_CKMAX_G(0xFF) |
+		     DCU_CTRLDESCLN_5_CKMAX_B(0xFF));
+	regmap_write(fsl_dev->regmap, DCU_CTRLDESCLN_6(plane_num),
+		     DCU_CTRLDESCLN_6_CKMIN_R(0) |
+		     DCU_CTRLDESCLN_6_CKMIN_G(0) |
+		     DCU_CTRLDESCLN_6_CKMIN_B(0));
+	regmap_write(fsl_dev->regmap, DCU_CTRLDESCLN_8(plane_num),
+		     DCU_CTRLDESCLN_8_FG_FCOLOR(0));
+	regmap_write(fsl_dev->regmap, DCU_CTRLDESCLN_9(plane_num),
+		     DCU_CTRLDESCLN_9_BG_BCOLOR(0));
+	regmap_write(fsl_dev->regmap, DCU_CTRLDESCLN_10(plane_num),
+		     DCU_CTRLDESCLN_10_POST_SKIP(0) |
+		     DCU_CTRLDESCLN_10_PRE_SKIP(0));

drivers/gpu/drm/fsl/fsl_dcu_drm_plane.c

Quoted 10 lines
drivers/gpu/drm/fsl/fsl_dcu_drm_plane.c new file +10 -0
+	regmap_write(fsl_dev->regmap, DCU_UPDATE_MODE,
+DCU_UPDATE_MODE_READREG); }
+
+void fsl_dcu_drm_plane_setup(struct drm_plane *plane) {
+	if (!plane->fb)
+		return;
+
+	__fsl_dcu_drm_plane_setup(plane, plane->fb); }
+
+int fsl_dcu_drm_plane_update(struct drm_plane *plane, struct drm_crtc

*crtc,

Quoted 65 lines
drivers/gpu/drm/fsl/fsl_dcu_drm_plane.c new file +25 -0
+			     struct drm_framebuffer *fb, int crtc_x, int crtc_y,
+			    unsigned int crtc_w, unsigned int crtc_h,
+			    uint32_t src_x, uint32_t src_y,
+			    uint32_t src_w, uint32_t src_h) {
+	__fsl_dcu_drm_plane_setup(plane, fb);
+	return 0;
+}
+
+int fsl_dcu_drm_plane_disable(struct drm_plane *plane) {
+	return 0;
+}
+
+void fsl_dcu_drm_plane_destroy(struct drm_plane *plane) {
+	fsl_dcu_drm_plane_disable(plane);
+	drm_plane_cleanup(plane);
+}
+
+static const uint32_t formats[] = {
+	DRM_FORMAT_RGB565,
+	DRM_FORMAT_RGB888,
+	DRM_FORMAT_ARGB8888,
+	DRM_FORMAT_ARGB4444,
+	DRM_FORMAT_ARGB1555,
+	DRM_FORMAT_YUV422,
+};
drivers/gpu/drm/fsl/fsl_dcu_drm_plane.h new file +30 -1
new file mode 100644
index 0000000..da88d1c
@@ -0,0 +1,28 @@
+/*
+ * 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;
+
+void fsl_dcu_drm_plane_setup(struct drm_plane *plane); int
+fsl_dcu_drm_plane_update(struct drm_plane *plane,
+			     struct drm_crtc *crtc,
+			     struct drm_framebuffer *fb,
+			     int crtc_x, int crtc_y,
+			     unsigned int crtc_w, unsigned int crtc_h,
+			     uint32_t src_x, uint32_t src_y,
+			     uint32_t src_w, uint32_t src_h); int
+fsl_dcu_drm_plane_disable(struct drm_plane *plane); void
+fsl_dcu_drm_plane_destroy(struct drm_plane *plane);
+
+#endif /* __FSL_DCU_DRM_PLANE_H__ */
--

2.1.0.27.g96db324

Quoted 4 lines

_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel

--
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch

#7 lore raw
Quoted 33 lines · On Tue, Mar 03, 2015 at 10:06:57AM +0000, [email protected] wrote:
Quoted 25 lines

-----Original Message-----
From: Daniel Vetter [mailto:[email protected]] On Behalf Of Daniel Vetter
Sent: Sunday, February 22, 2015 7:35 PM
To: Wang Jianwei-B52261
Cc: [email protected]; [email protected]; Wood Scott-B07421; Xiubo Li; Wang Huan-B18965; [email protected]; [email protected]
Subject: Re: [PATCH 1/3] drm/layerscape: Add fsl dcu DRM driver

Quoted 6 lines · Jianwei Wang

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

2D-ACE is a Freescale display controller. It supports at most four plane and provide an hardware cursor.

Quoted 7 lines

This is a simplified version, only a primary plane, a fb created for fbdev, a crtc, a connector for TFT LCD panel, an encoder, and the encoder is not in use. Now this drver support fbdev only.

Quoted 7 lines

Imo adding a new driver without primary plane support (use drm_crtc_init_with_planes) and without atomic support doesn't make sense any more.

Also, what do you mean with "support fbdev only"?
-Daniel

Quoted 7 lines

Daniel,

This driver has supported primary plane (use drm_crtc_init_with_planes) Already.
If atomic support is a must? 2D-ACE is a simple display Controller and this is a simplified version. If atomic support is not a must, I want to add it with patches, is it ok?

atomic is the new way the drm display subsystem works, not supporting it in new drivers makes this transition even longer. Since I guess if you don't want to do the conversion now no one else will do it anytime later, and then we're stuck with this driver as-is. On top of that atomic should simplify testing for your driver a lot (since a few things are take care of for you in the generic atomic code).
-Daniel

Quoted 1,428 lines

" Now this drver support fbdev only." if this sentence confuses you, I'd like remove it. In fact I mean that this driver only create a framebuffer dev (use drm_fbdev_cma_init).

Thanks
Regards,
Wang Jianwei

Quoted 1,419 lines
Quoted 7 lines
---
 .../devicetree/bindings/video/fsl,dcfb.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_crtc.c             | 412

+++++++++++++++++++++

Quoted 2 lines
 drivers/gpu/drm/fsl/fsl_dcu_drm_crtc.h             |  40 ++
 drivers/gpu/drm/fsl/fsl_dcu_drm_drv.c              | 323

++++++++++++++++

Quoted 37 lines
 drivers/gpu/drm/fsl/fsl_dcu_drm_drv.h              | 167 +++++++++
 drivers/gpu/drm/fsl/fsl_dcu_drm_fbdev.c            |  43 +++
 drivers/gpu/drm/fsl/fsl_dcu_drm_kms.c              |  45 +++
 drivers/gpu/drm/fsl/fsl_dcu_drm_kms.h              |  22 ++
 drivers/gpu/drm/fsl/fsl_dcu_drm_plane.c            | 124 +++++++
 drivers/gpu/drm/fsl/fsl_dcu_drm_plane.h            |  28 ++
 14 files changed, 1281 insertions(+)
 create mode 100644
Documentation/devicetree/bindings/video/fsl,dcfb.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_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/video/fsl,dcfb.txt new file +9 -0
new file mode 100644
index 0000000..de7da97
@@ -0,0 +1,50 @@
+* Freescale Simple Display Controller FB Driver
+
+Required properties:
+- compatible:		Should be one of "fsl,ls1021a-dcfb".
+- reg:			Address and length of the register set for dcfb.
+- clocks:		From common clock binding: handle to dcfb clock.
+- clock-names:		From common clock binding: Shall be "dcfb".
+- display:		The phandle to display node.
+

Documentation/devicetree/bindings/video/fsl,dcfb.txt line 19

Quoted 10 lines
Documentation/devicetree/bindings/video/fsl,dcfb.txt new file +10 -0
+Optional properties:
+- scfg-controller:	The phandle of scfg 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.

Quoted 120 lines
Documentation/devicetree/bindings/video/fsl,dcfb.txt new file +31 -0
+
+Examples:
+dcfb: dcfb@2ce0000 {
+	compatible = "fsl,ls1021a-dcfb";
+	reg = <0x0 0x2ce0000 0x0 0x10000>;
+	clocks = <&platform_clk 0>;
+	clock-names = "dcfb";
+	scfg-controller = <&scfg>;
+	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 index renamed from drivers/gpu/drm/Kconfig +0 -0

151a050..a6957aa 100644

drivers/gpu/drm/Kconfig +2 -0
@@ -199,6 +199,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 index renamed from drivers/gpu/drm/Makefile +0 -0

2c239b9..ab5b9ef 100644

drivers/gpu/drm/Makefile +1 -0
@@ -56,6 +56,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.
(quoted diff) +0 -0

b/drivers/gpu/drm/fsl/Makefile new file mode 100644 index 0000000..51c3e1f

drivers/gpu/drm/fsl/Makefile new file +7 -0
@@ -0,0 +1,7 @@
+fsl-dcu-drm-y := fsl_dcu_drm_drv.o \
+	       fsl_dcu_drm_kms.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_crtc.c new file +22 -0
new file mode 100644
index 0000000..9f5ba86
@@ -0,0 +1,412 @@
+/*
+ * 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.
+ */
+
+#include <linux/backlight.h>
+#include <linux/clk.h>
+#include <linux/regmap.h>
+
+#include <drm/drmP.h>
+#include <drm/drm_atomic_helper.h>
+#include <drm/drm_crtc.h>
+#include <drm/drm_crtc_helper.h>
+#include <drm/drm_fb_cma_helper.h>

drivers/gpu/drm/fsl/fsl_dcu_drm_crtc.c line 32

Quoted 10 lines
drivers/gpu/drm/fsl/fsl_dcu_drm_crtc.c new file +10 -0
+#include <drm/drm_gem_cma_helper.h>
+#include <drm/drm_plane_helper.h>
+#include <video/of_display_timing.h>
+
+#include "fsl_dcu_drm_crtc.h"
+#include "fsl_dcu_drm_drv.h"
+#include "fsl_dcu_drm_kms.h"
+#include "fsl_dcu_drm_plane.h"
+
+#define to_fsl_dcu_crtc(c)	container_of(c, struct fsl_dcu_drm_crtc,

crtc)

Quoted 95 lines
drivers/gpu/drm/fsl/fsl_dcu_drm_crtc.c new file +95 -0
+
+static void fsl_dcu_drm_crtc_start(struct drm_crtc *crtc) {
+	fsl_dcu_drm_plane_setup(crtc->primary);
+}
+
+static void fsl_dcu_drm_crtc_stop(struct drm_crtc *crtc) { }
+
+void fsl_dcu_drm_crtc_suspend(struct drm_crtc *crtc) {
+	fsl_dcu_drm_crtc_stop(crtc);
+}
+
+void fsl_dcu_drm_crtc_resume(struct drm_crtc *crtc) {
+	struct fsl_dcu_drm_crtc *fsl_crtc = to_fsl_dcu_crtc(crtc);
+
+	if (fsl_crtc->dpms != DRM_MODE_DPMS_ON)
+		return;
+
+	fsl_dcu_drm_crtc_start(crtc);
+}
+
+static void fsl_dcu_drm_crtc_update_base(struct drm_crtc *crtc) { }
+
+static void fsl_dcu_drm_crtc_dpms(struct drm_crtc *crtc, int mode) {
+	struct fsl_dcu_drm_crtc *fsl_crtc = to_fsl_dcu_crtc(crtc);
+
+	if (fsl_crtc->dpms == mode)
+		return;
+
+	if (mode == DRM_MODE_DPMS_ON)
+		fsl_dcu_drm_crtc_start(crtc);
+	else
+		fsl_dcu_drm_crtc_stop(crtc);
+
+	fsl_crtc->dpms = mode;
+}
+
+static bool fsl_dcu_drm_crtc_mode_fixup(struct drm_crtc *crtc,
+					const struct drm_display_mode *mode,
+					struct drm_display_mode *adjusted_mode) {
+	return true;
+}
+
+static void fsl_dcu_drm_crtc_mode_prepare(struct drm_crtc *crtc) {
+		fsl_dcu_drm_crtc_stop(crtc);
+}
+
+static int fsl_dcu_drm_crtc_mode_set(struct drm_crtc *crtc,
+				     struct drm_display_mode *mode,
+				     struct drm_display_mode *adjusted_mode,
+				     int x, int y,
+				     struct drm_framebuffer *old_fb) {
+	struct drm_device *dev = crtc->dev;
+	struct fsl_dcu_drm_device *fsl_dev = dev->dev_private;
+	uint32_t hbp, hfp, hsw, vbp, vfp, vsw, div, index;
+
+	DBG(": set mode: %d:\"%s\" %d %d %d %d %d %d %d %d %d %d 0x%x 0x%x",
+	    mode->base.id, mode->name,
+	    mode->vrefresh, mode->clock,
+	    mode->hdisplay, mode->hsync_start,
+	    mode->hsync_end, mode->htotal,
+	    mode->vdisplay, mode->vsync_start,
+	    mode->vsync_end, mode->vtotal,
+	    mode->type, mode->flags);
+
+	index = drm_crtc_index(crtc);
+	div = (uint32_t)clk_get_rate(fsl_dev->clk) / crtc->mode.clock /
+1000;
+
+	/* Configure timings: */
+	hbp = mode->htotal - mode->hsync_end;
+	hfp = mode->hsync_start - mode->hdisplay;
+	hsw = mode->hsync_end - mode->hsync_start;
+	vbp = mode->vtotal - mode->vsync_end;
+	vfp = mode->vsync_start - mode->vdisplay;
+	vsw = mode->vsync_end - mode->vsync_start;
+
+	regmap_write(fsl_dev->regmap, DCU_HSYN_PARA,
+		     DCU_HSYN_PARA_BP(hbp) |
+		     DCU_HSYN_PARA_PW(hsw) |
+		     DCU_HSYN_PARA_FP(hfp));
+	regmap_write(fsl_dev->regmap, DCU_VSYN_PARA,
+		     DCU_VSYN_PARA_BP(vbp) |
+		     DCU_VSYN_PARA_PW(vsw) |
+		     DCU_VSYN_PARA_FP(vfp));
+	regmap_write(fsl_dev->regmap, DCU_DISP_SIZE,
+		     DCU_DISP_SIZE_DELTA_Y(mode->vdisplay) |
+		     DCU_DISP_SIZE_DELTA_X(mode->hdisplay));
+	regmap_write(fsl_dev->regmap, DCU_CTRLDESCLN_1(index),
+		     DCU_CTRLDESCLN_1_HEIGHT(mode->vdisplay) |
+		     DCU_CTRLDESCLN_1_WIDTH(mode->hdisplay));
+	regmap_write(fsl_dev->regmap, DCU_CTRLDESCLN_2(index),
+		     DCU_CTRLDESCLN_2_POSY(y) |
+		     DCU_CTRLDESCLN_2_POSX(x));
+	regmap_write(fsl_dev->regmap, DCU_DIV_RATIO, div);
+	regmap_write(fsl_dev->regmap, DCU_UPDATE_MODE,

drivers/gpu/drm/fsl/fsl_dcu_drm_crtc.c

Quoted 10 lines
drivers/gpu/drm/fsl/fsl_dcu_drm_crtc.c new file +10 -0
+DCU_UPDATE_MODE_READREG);
+
+	return 0;
+}
+
+static void fsl_dcu_drm_crtc_mode_commit(struct drm_crtc *crtc) {
+		fsl_dcu_drm_crtc_start(crtc);
+}
+
+static int fsl_dcu_drm_crtc_mode_set_base(struct drm_crtc *crtc, int x,

int y,

Quoted 50 lines
drivers/gpu/drm/fsl/fsl_dcu_drm_crtc.c new file +50 -0
+					  struct drm_framebuffer *old_fb) {
+	fsl_dcu_drm_crtc_update_base(crtc);
+
+	return 0;
+}
+
+static const struct drm_crtc_helper_funcs crtc_helper_funcs = {
+	.dpms = fsl_dcu_drm_crtc_dpms,
+	.mode_fixup = fsl_dcu_drm_crtc_mode_fixup,
+	.prepare = fsl_dcu_drm_crtc_mode_prepare,
+	.commit = fsl_dcu_drm_crtc_mode_commit,
+	.mode_set = fsl_dcu_drm_crtc_mode_set,
+	.mode_set_base = fsl_dcu_drm_crtc_mode_set_base, };
+
+static int fsl_dcu_drm_crtc_page_flip(struct drm_crtc *crtc,
+				      struct drm_framebuffer *fb,
+				      struct drm_pending_vblank_event *event,
+				      uint32_t page_flip_flags)
+{
+	return 0;
+}
+
+static const struct drm_plane_funcs fsl_dcu_drm_plane_funcs = {
+	.update_plane = fsl_dcu_drm_plane_update,
+	.disable_plane = fsl_dcu_drm_plane_disable,
+	.destroy = fsl_dcu_drm_plane_destroy, };
+
+static const struct drm_crtc_funcs crtc_funcs = {
+	.destroy = drm_crtc_cleanup,
+	.set_config = drm_crtc_helper_set_config,
+	.page_flip = fsl_dcu_drm_crtc_page_flip, };
+
+int fsl_dcu_drm_crtc_create(struct fsl_dcu_drm_device *fsl_dev) {
+	struct drm_crtc *crtc = &fsl_dev->crtc.crtc;
+	int ret;
+
+	fsl_dev->crtc.dpms = DRM_MODE_DPMS_OFF;
+
+	ret = drm_crtc_init(fsl_dev->ddev, crtc, &crtc_funcs);
+	if (ret < 0)
+		return ret;
+
+	crtc->primary->funcs = &fsl_dcu_drm_plane_funcs;
+
+	drm_crtc_helper_add(crtc, &crtc_helper_funcs);
+
+	regmap_write(fsl_dev->regmap, DCU_SYN_POL,
+		     DCU_SYN_POL_INV_VS_LOW | DCU_SYN_POL_INV_HS_LOW);
+	regmap_write(fsl_dev->regmap, DCU_BGND, DCU_BGND_R(0) |
+		     DCU_BGND_G(0) | DCU_BGND_B(0));

drivers/gpu/drm/fsl/fsl_dcu_drm_crtc.c

Quoted 10 lines
drivers/gpu/drm/fsl/fsl_dcu_drm_crtc.c new file +10 -0
+	regmap_write(fsl_dev->regmap, DCU_DCU_MODE,
+		     DCU_MODE_BLEND_ITER(1) | DCU_MODE_RASTER_EN);
+	regmap_write(fsl_dev->regmap, DCU_THRESHOLD,
+		     DCU_THRESHOLD_LS_BF_VS(BF_VS_VAL) |
+		     DCU_THRESHOLD_OUT_BUF_HIGH(BUF_MAX_VAL) |
+		     DCU_THRESHOLD_OUT_BUF_LOW(BUF_MIN_VAL));
+	regmap_update_bits(fsl_dev->regmap, DCU_DCU_MODE,
+			   DCU_MODE_DCU_MODE_MASK,
+			   DCU_MODE_DCU_MODE(DCU_MODE_NORMAL));
+	regmap_write(fsl_dev->regmap, DCU_UPDATE_MODE,

DCU_UPDATE_MODE_READREG);

Quoted 25 lines
drivers/gpu/drm/fsl/fsl_dcu_drm_crtc.c new file +25 -0
+	return 0;
+}
+
+/*
+ * Encoder
+ */
+
+#define to_fsl_dcu_encoder(e) \
+	container_of(e, struct fsl_dcu_drm_encoder, encoder)
+
+static void fsl_dcu_drm_encoder_dpms(struct drm_encoder *encoder, int
+mode) {
+	struct fsl_dcu_drm_encoder *fsl_enc = to_fsl_dcu_encoder(encoder);
+
+	if (fsl_enc->dpms == mode)
+		return;
+
+	fsl_enc->dpms = mode;
+}
+
+static bool fsl_dcu_drm_encoder_mode_fixup
+		(struct drm_encoder *encoder,
+		const struct drm_display_mode *mode,
+		struct drm_display_mode *adjusted_mode) {
+	struct drm_device *dev = encoder->dev;

drivers/gpu/drm/fsl/fsl_dcu_drm_crtc.c

Quoted 10 lines
drivers/gpu/drm/fsl/fsl_dcu_drm_crtc.c new file +10 -0
+	struct fsl_dcu_drm_device *fsl_dev = dev->dev_private;
+	struct drm_connector *connector = &fsl_dev->connector.connector;
+	const struct drm_display_mode *panel_mode;
+
+	if (list_empty(&connector->modes)) {
+		dev_dbg(dev->dev, "mode_fixup: empty modes list\n");
+		return false;
+	}
+
+	/* The flat panel mode is fixed, just copy it to the adjusted mode.

*/

Quoted 72 lines
drivers/gpu/drm/fsl/fsl_dcu_drm_crtc.c new file +72 -0
+	panel_mode = list_first_entry(&connector->modes,
+				      struct drm_display_mode, head);
+	drm_mode_copy(adjusted_mode, panel_mode);
+
+	return true;
+}
+
+static void fsl_dcu_drm_encoder_mode_prepare(struct drm_encoder
+*encoder) { }
+
+static void fsl_dcu_drm_encoder_mode_set(struct drm_encoder *encoder,
+					 struct drm_display_mode *mode,
+					 struct drm_display_mode *adjusted_mode) { }
+
+static void fsl_dcu_drm_encoder_mode_commit(struct drm_encoder
+*encoder) {
+	;
+}
+
+static const struct drm_encoder_helper_funcs encoder_helper_funcs = {
+	.dpms = fsl_dcu_drm_encoder_dpms,
+	.mode_fixup = fsl_dcu_drm_encoder_mode_fixup,
+	.prepare = fsl_dcu_drm_encoder_mode_prepare,
+	.commit = fsl_dcu_drm_encoder_mode_commit,
+	.mode_set = fsl_dcu_drm_encoder_mode_set, };
+
+static void fsl_dcu_drm_encoder_destroy(struct drm_encoder *encoder)
+{
+	drm_encoder_cleanup(encoder);
+}
+
+static const struct drm_encoder_funcs encoder_funcs = {
+	.destroy = fsl_dcu_drm_encoder_destroy, };
+
+int fsl_dcu_drm_encoder_create(struct fsl_dcu_drm_device *fsl_dev) {
+	struct drm_encoder *encoder = &fsl_dev->encoder.encoder;
+	int ret;
+
+	fsl_dev->encoder.dpms = DRM_MODE_DPMS_OFF;
+
+	encoder->possible_crtcs = 1;
+
+	ret = drm_encoder_init(fsl_dev->ddev, encoder, &encoder_funcs,
+			       DRM_MODE_ENCODER_LVDS);
+	if (ret < 0)
+		return ret;
+
+	drm_encoder_helper_add(encoder, &encoder_helper_funcs);
+
+	return 0;
+}
+
+/*
+ * Connector
+ */
+
+#define to_fsl_dcu_connector(c) \
+	container_of(c, struct fsl_dcu_drm_connector, connector)
+
+static int fsl_dcu_drm_connector_get_modes(struct drm_connector
+*connector) {
+	struct drm_device *dev = connector->dev;
+	struct device_node *display_np, *np = dev->dev->of_node;
+	struct drm_display_mode *mode = drm_mode_create(connector->dev);
+	int num_modes = 0;
+
+	if (np) {
+		display_np = of_parse_phandle(np, "display", 0);
+		if (!display_np) {
+			dev_err(dev->dev, "failed to find display phandle\n");
+			return num_modes;
+		}

drivers/gpu/drm/fsl/fsl_dcu_drm_crtc.c

Quoted 10 lines
drivers/gpu/drm/fsl/fsl_dcu_drm_crtc.c new file +10 -0
+		of_get_drm_display_mode(display_np, mode, OF_USE_NATIVE_MODE);
+		mode->type |= DRM_MODE_TYPE_DRIVER | DRM_MODE_TYPE_PREFERRED,
+		drm_mode_probed_add(connector, mode);
+		num_modes++;
+	}
+
+	return num_modes;
+}
+
+static int fsl_dcu_drm_connector_mode_valid(struct drm_connector

*connector,

drivers/gpu/drm/fsl/fsl_dcu_drm_crtc.c

Quoted 13 lines
drivers/gpu/drm/fsl/fsl_dcu_drm_crtc.c new file +13 -0
+					    struct drm_display_mode *mode) {
+	return MODE_OK;
+}
+
+static struct drm_encoder *
+fsl_dcu_drm_connector_best_encoder(struct drm_connector *connector) {
+	struct fsl_dcu_drm_connector *fsl_con =
+to_fsl_dcu_connector(connector);
+
+	return fsl_con->encoder;
+}
+
+static const struct drm_connector_helper_funcs connector_helper_funcs

= {

Quoted 279 lines
drivers/gpu/drm/fsl/fsl_dcu_drm_crtc.c new file +63 -0
+	.get_modes = fsl_dcu_drm_connector_get_modes,
+	.mode_valid = fsl_dcu_drm_connector_mode_valid,
+	.best_encoder = fsl_dcu_drm_connector_best_encoder,
+};
+
+static void fsl_dcu_drm_connector_destroy(struct drm_connector
+*connector) {
+	drm_connector_unregister(connector);
+	drm_connector_cleanup(connector);
+}
+
+static enum drm_connector_status
+fsl_dcu_drm_connector_detect(struct drm_connector *connector, bool
+force) {
+	return connector_status_connected;
+}
+
+static const struct drm_connector_funcs connector_funcs = {
+	.dpms = drm_helper_connector_dpms,
+	.detect = fsl_dcu_drm_connector_detect,
+	.fill_modes = drm_helper_probe_single_connector_modes,
+	.destroy = fsl_dcu_drm_connector_destroy, };
+
+int fsl_dcu_drm_connector_create(struct fsl_dcu_drm_device *fsl_dev,
+				 struct drm_encoder *encoder)
+{
+	struct drm_connector *connector = &fsl_dev->connector.connector;
+	int ret;
+
+	fsl_dev->connector.encoder = encoder;
+
+	connector->display_info.width_mm = 0;
+	connector->display_info.height_mm = 0;
+
+	ret = drm_connector_init(fsl_dev->ddev, connector, &connector_funcs,
+				 DRM_MODE_CONNECTOR_LVDS);
+	if (ret < 0)
+		return ret;
+
+	drm_connector_helper_add(connector, &connector_helper_funcs);
+	ret = drm_connector_register(connector);
+	if (ret < 0)
+		goto err_cleanup;
+
+	ret = drm_mode_connector_attach_encoder(connector, encoder);
+	if (ret < 0)
+		goto err_sysfs;
+
+	connector->encoder = encoder;
+
+	drm_helper_connector_dpms(connector, DRM_MODE_DPMS_OFF);
+	drm_object_property_set_value
+		(&connector->base, fsl_dev->ddev->mode_config.dpms_property,
+		DRM_MODE_DPMS_OFF);
+
+	return 0;
+
+err_sysfs:
+	drm_connector_unregister(connector);
+err_cleanup:
+	drm_connector_cleanup(connector);
+	return ret;
+}
drivers/gpu/drm/fsl/fsl_dcu_drm_crtc.h new file +42 -0
new file mode 100644
index 0000000..ad59992
@@ -0,0 +1,40 @@
+/*
+ * 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_MODSET_H__
+#define __FSL_DCU_DRM_MODSET_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;
+};
+
+struct fsl_dcu_drm_encoder {
+	struct drm_encoder encoder;
+	int dpms;
+};
+
+struct fsl_dcu_drm_connector {
+	struct drm_connector connector;
+	struct drm_encoder *encoder;
+};
+
+int fsl_dcu_drm_crtc_create(struct fsl_dcu_drm_device *fsl_dev); int
+fsl_dcu_drm_encoder_create(struct fsl_dcu_drm_device *fsl_dev); int
+fsl_dcu_drm_connector_create(struct fsl_dcu_drm_device *fsl_dev,
+				 struct drm_encoder *encoder);
+
+#endif /* __FSL_DCU_DRM_MODSET_H__ */
drivers/gpu/drm/fsl/fsl_dcu_drm_drv.c new file +160 -0
new file mode 100644
index 0000000..1bca45a
@@ -0,0 +1,323 @@
+/*
+ * 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.
+ */
+
+#include <linux/clk.h>
+#include <linux/io.h>
+#include <linux/mm.h>
+#include <linux/module.h>
+#include <linux/of_platform.h>
+#include <linux/platform_device.h>
+#include <linux/pm.h>
+#include <linux/pm_runtime.h>
+#include <linux/regmap.h>
+#include <linux/slab.h>
+
+#include <drm/drmP.h>
+#include "fsl_dcu_drm_drv.h"
+#include "fsl_dcu_drm_kms.h"
+
+static int fsl_dcu_unload(struct drm_device *dev) {
+	drm_mode_config_cleanup(dev);
+	drm_vblank_cleanup(dev);
+	drm_irq_uninstall(dev);
+
+	dev->dev_private = NULL;
+
+	return 0;
+}
+
+static struct regmap_config fsl_dcu_regmap_config = {
+	.reg_bits = 32,
+	.reg_stride = 4,
+	.val_bits = 32,
+};
+
+static int fsl_dcu_bypass_tcon(struct fsl_dcu_drm_device *fsl_dev,
+			       struct device_node *np)
+{
+	struct device_node *tcon_np;
+	struct platform_device *pdev;
+	struct clk *tcon_clk;
+	struct resource *res;
+	void __iomem *base;
+
+	tcon_np = of_parse_phandle(np, "tcon-controller", 0);
+	if (!tcon_np)
+		return -EINVAL;
+
+	pdev = of_find_device_by_node(tcon_np);
+	if (!pdev)
+		return -EINVAL;
+
+	tcon_clk = devm_clk_get(&pdev->dev, "tcon");
+	if (IS_ERR(tcon_clk))
+		return PTR_ERR(tcon_clk);
+	clk_prepare_enable(tcon_clk);
+
+	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+	if (!res)
+		return -ENODEV;
+
+	base = devm_ioremap_resource(&pdev->dev, res);
+	if (IS_ERR(base))
+		return PTR_ERR(base);
+
+	fsl_dev->tcon_regmap = devm_regmap_init_mmio_clk(&pdev->dev,
+			"tcon", base, &fsl_dcu_regmap_config);
+	if (IS_ERR(fsl_dev->tcon_regmap)) {
+		dev_err(&pdev->dev, "regmap init failed\n");
+		return PTR_ERR(fsl_dev->tcon_regmap);
+	}
+
+	regmap_write(fsl_dev->tcon_regmap, TCON_CTRL1, TCON_BYPASS_ENABLE);
+	return 0;
+}
+
+static int fsl_dcu_scfg_config(struct fsl_dcu_drm_device *fsl_dev,
+			       struct device_node *np)
+{
+	struct device_node *scfg_np;
+	struct platform_device *pdev;
+	struct resource *res;
+	void __iomem *base;
+
+	scfg_np = of_parse_phandle(np, "scfg-controller", 0);
+	if (!scfg_np)
+		return 0;
+
+	pdev = of_find_device_by_node(scfg_np);
+	if (!pdev)
+		return -EINVAL;
+
+	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+	if (!res)
+		return -ENODEV;
+
+	base = devm_ioremap_resource(&pdev->dev, res);
+	if (IS_ERR(base))
+		return PTR_ERR(base);
+
+	fsl_dev->scfg_regmap = devm_regmap_init_mmio_clk(&pdev->dev,
+			NULL, base, &fsl_dcu_regmap_config);
+	if (IS_ERR(fsl_dev->scfg_regmap)) {
+		dev_err(&pdev->dev, "regmap init failed\n");
+		return PTR_ERR(fsl_dev->scfg_regmap);
+	}
+
+	regmap_write(fsl_dev->scfg_regmap, 0x28, 0x80000000);
+
+	return 0;
+}
+
+static int fsl_dcu_load(struct drm_device *dev, unsigned long flags)
+{
+	struct platform_device *pdev = dev->platformdev;
+	struct fsl_dcu_drm_device *fsl_dev;
+	struct resource *res;
+	void __iomem *base;
+	int ret;
+
+	fsl_dev = devm_kzalloc(&pdev->dev, sizeof(*fsl_dev), GFP_KERNEL);
+	if (!fsl_dev)
+		return -ENOMEM;
+
+	fsl_dev->dev = &pdev->dev;
+	fsl_dev->ddev = dev;
+	dev->dev_private = fsl_dev;
+
+	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+	base = devm_ioremap_resource(&pdev->dev, res);
+	if (IS_ERR(base)) {
+		ret = PTR_ERR(base);
+		return ret;
+	}
+
+	fsl_dev->regmap = devm_regmap_init_mmio(&pdev->dev,
+			base, &fsl_dcu_regmap_config);
+	if (IS_ERR(fsl_dev->regmap)) {
+		dev_err(&pdev->dev, "regmap init failed\n");
+		return PTR_ERR(fsl_dev->regmap);
+	}
+
+	ret = fsl_dcu_drm_modeset_init(fsl_dev);
+	if (ret < 0) {
+		dev_err(&pdev->dev, "failed to initialize mode setting\n");
+		return ret;
+	}
+
+	ret = drm_vblank_init(dev, 1);
+	if (ret < 0) {
+		dev_err(&pdev->dev, "failed to initialize vblank\n");

drivers/gpu/drm/fsl/fsl_dcu_drm_drv.c line 170

Quoted 10 lines
drivers/gpu/drm/fsl/fsl_dcu_drm_drv.c new file +10 -0
+		goto done;
+	}
+
+	ret = drm_irq_install(dev, platform_get_irq(dev->platformdev, 0));
+	if (ret < 0) {
+		dev_err(&pdev->dev, "failed to install IRQ handler\n");
+		goto done;
+	}
+
+	/* Put TCON in bypass mode, so the input signals from DCU are

passed

Quoted 397 lines
drivers/gpu/drm/fsl/fsl_dcu_drm_drv.c new file +148 -0
+	 * through TCON unchanged */
+	fsl_dcu_bypass_tcon(fsl_dev, pdev->dev.of_node);
+	fsl_dcu_scfg_config(fsl_dev, pdev->dev.of_node);
+
+	fsl_dev->clk = devm_clk_get(&pdev->dev, "dcfb");
+	if (IS_ERR(fsl_dev->clk)) {
+		ret = PTR_ERR(fsl_dev->clk);
+		dev_err(&pdev->dev, "could not get clock\n");
+		return ret;
+	}
+	clk_prepare_enable(fsl_dev->clk);
+
+	dev_set_drvdata(dev->dev, fsl_dev);
+
+	fsl_dcu_fbdev_init(dev);
+
+	return 0;
+done:
+	if (ret)
+		fsl_dcu_unload(dev);
+
+	return ret;
+}
+
+static void fsl_dcu_drm_preclose(struct drm_device *dev, struct
+drm_file *file) {
+	;
+}
+
+static irqreturn_t fsl_dcu_drm_irq(int irq, void *arg) {
+	return IRQ_HANDLED;
+}
+
+static int fsl_dcu_drm_enable_vblank(struct drm_device *dev, int
+crtc) {
+	return 0;
+}
+
+static void fsl_dcu_drm_disable_vblank(struct drm_device *dev, int
+crtc) {
+	;
+}
+
+static const struct file_operations fsl_dcu_drm_fops = {
+	.owner		= THIS_MODULE,
+	.open		= drm_open,
+	.release	= drm_release,
+	.unlocked_ioctl	= drm_ioctl,
+#ifdef CONFIG_COMPAT
+	.compat_ioctl	= drm_compat_ioctl,
+#endif
+	.poll		= drm_poll,
+	.read		= drm_read,
+	.llseek		= no_llseek,
+	.mmap		= drm_gem_cma_mmap,
+};
+
+static struct drm_driver fsl_dcu_drm_driver = {
+	.driver_features	= DRIVER_HAVE_IRQ | DRIVER_GEM | DRIVER_MODESET
+				| DRIVER_PRIME,
+	.load			= fsl_dcu_load,
+	.unload			= fsl_dcu_unload,
+	.preclose		= fsl_dcu_drm_preclose,
+	.irq_handler		= fsl_dcu_drm_irq,
+	.get_vblank_counter	= drm_vblank_count,
+	.enable_vblank		= fsl_dcu_drm_enable_vblank,
+	.disable_vblank		= fsl_dcu_drm_disable_vblank,
+	.gem_free_object	= drm_gem_cma_free_object,
+	.gem_vm_ops		= &drm_gem_cma_vm_ops,
+	.prime_handle_to_fd	= drm_gem_prime_handle_to_fd,
+	.prime_fd_to_handle	= drm_gem_prime_fd_to_handle,
+	.gem_prime_import	= drm_gem_prime_import,
+	.gem_prime_export	= drm_gem_prime_export,
+	.gem_prime_get_sg_table	= drm_gem_cma_prime_get_sg_table,
+	.gem_prime_import_sg_table = drm_gem_cma_prime_import_sg_table,
+	.gem_prime_vmap		= drm_gem_cma_prime_vmap,
+	.gem_prime_vunmap	= drm_gem_cma_prime_vunmap,
+	.gem_prime_mmap		= drm_gem_cma_prime_mmap,
+	.dumb_create		= drm_gem_cma_dumb_create,
+	.dumb_map_offset	= drm_gem_cma_dumb_map_offset,
+	.dumb_destroy		= drm_gem_dumb_destroy,
+	.fops			= &fsl_dcu_drm_fops,
+	.name			= "fsl-dcu-drm",
+	.desc			= "Freescale DCU DRM",
+	.date			= "20150213",
+	.major			= 1,
+	.minor			= 0,
+};
+
+#ifdef CONFIG_PM_SLEEP
+static int fsl_dcu_drm_pm_suspend(struct device *dev) {
+	struct fsl_dcu_drm_device *fsl_dev = dev_get_drvdata(dev);
+
+	drm_kms_helper_poll_disable(fsl_dev->ddev);
+	fsl_dcu_drm_crtc_suspend(&fsl_dev->crtc);
+
+	return 0;
+}
+
+static int fsl_dcu_drm_pm_resume(struct device *dev) {
+	struct fsl_dcu_drm_device *fsl_dev = dev_get_drvdata(dev);
+
+	drm_modeset_lock_all(fsl_dev->ddev);
+	fsl_dcu_drm_crtc_resume(&fsl_dev->crtc);
+	drm_modeset_unlock_all(fsl_dev->ddev);
+
+	drm_kms_helper_poll_enable(fsl_dev->ddev);
+	return 0;
+}
+#endif
+
+static const struct dev_pm_ops fsl_dcu_drm_pm_ops = {
+	SET_SYSTEM_SLEEP_PM_OPS(fsl_dcu_drm_pm_suspend,
+fsl_dcu_drm_pm_resume) };
+
+static int fsl_dcu_drm_probe(struct platform_device *pdev) {
+	return drm_platform_init(&fsl_dcu_drm_driver, pdev); }
+
+static int fsl_dcu_drm_remove(struct platform_device *pdev) {
+	struct fsl_dcu_drm_device *fsl_dev = platform_get_drvdata(pdev);
+
+	drm_put_dev(fsl_dev->ddev);
+
+	return 0;
+}
+
+static struct of_device_id fsl_dcu_of_match[] = {
+		{ .compatible = "fsl,ls1021a-dcfb", },
+		{ },
+};
+MODULE_DEVICE_TABLE(of, fsl_dcu_of_match);
+
+static struct platform_driver fsl_dcu_drm_platform_driver = {
+	.probe		= fsl_dcu_drm_probe,
+	.remove		= fsl_dcu_drm_remove,
+	.driver		= {
+		.owner	= THIS_MODULE,
+		.name	= "fsl,ls1021a-dcfb",
+		.pm	= &fsl_dcu_drm_pm_ops,
+		.of_match_table = fsl_dcu_of_match,
+	},
+};
+
+module_platform_driver(fsl_dcu_drm_platform_driver);
+
+MODULE_ALIAS("platform:fsl-dcu-drm");
+MODULE_DESCRIPTION("Freescale DCU DRM Driver");
+MODULE_LICENSE("GPL");
drivers/gpu/drm/fsl/fsl_dcu_drm_drv.h new file +168 -0
new file mode 100644
index 0000000..8dc7c10
@@ -0,0 +1,167 @@
+/*
+ * 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_DRV_H__
+#define __FSL_DCU_DRM_DRV_H__
+
+#include <linux/kernel.h>
+#include <linux/spinlock.h>
+#include <stddef.h>
+#include <drm/drm.h>
+#include <drm/drmP.h>
+#include <drm/drm_fb_helper.h>
+#include <drm/drm_crtc_helper.h>
+#include <drm/drm_gem_cma_helper.h>
+#include <drm/drm_fb_cma_helper.h>
+
+#include "fsl_dcu_drm_crtc.h"
+#define DRIVER_NAME			"fsl-dcu-fb"
+
+#define DCU_DCU_MODE			0x0010
+#define DCU_MODE_BLEND_ITER(x)		((x) << 20)
+#define DCU_MODE_RASTER_EN		BIT(14)
+#define DCU_MODE_DCU_MODE(x)		(x)
+#define DCU_MODE_DCU_MODE_MASK		0x03
+#define DCU_MODE_OFF			0
+#define DCU_MODE_NORMAL			1
+#define DCU_MODE_TEST			2
+#define DCU_MODE_COLORBAR		3
+
+#define DCU_BGND			0x0014
+#define DCU_BGND_R(x)			((x) << 16)
+#define DCU_BGND_G(x)			((x) << 8)
+#define DCU_BGND_B(x)			(x)
+
+#define DCU_DISP_SIZE			0x0018
+#define DCU_DISP_SIZE_DELTA_Y(x)	((x) << 16)
+/*Regisiter value 1/16 of horizontal resolution*/
+#define DCU_DISP_SIZE_DELTA_X(x)	((x) >> 4)
+
+#define DCU_HSYN_PARA			0x001c
+#define DCU_HSYN_PARA_BP(x)		((x) << 22)
+#define DCU_HSYN_PARA_PW(x)		((x) << 11)
+#define DCU_HSYN_PARA_FP(x)		(x)
+
+#define DCU_VSYN_PARA			0x0020
+#define DCU_VSYN_PARA_BP(x)		((x) << 22)
+#define DCU_VSYN_PARA_PW(x)		((x) << 11)
+#define DCU_VSYN_PARA_FP(x)		(x)
+
+#define DCU_SYN_POL			0x0024
+#define DCU_SYN_POL_INV_PXCK_FALL	(0 << 6)
+#define DCU_SYN_POL_NEG_REMAIN		(0 << 5)
+#define DCU_SYN_POL_INV_VS_LOW		BIT(1)
+#define DCU_SYN_POL_INV_HS_LOW		(1)
+
+#define DCU_THRESHOLD			0x0028
+#define DCU_THRESHOLD_LS_BF_VS(x)	((x) << 16)
+#define DCU_THRESHOLD_OUT_BUF_HIGH(x)	((x) << 8)
+#define DCU_THRESHOLD_OUT_BUF_LOW(x)	(x)
+#define BF_VS_VAL			0x03
+#define BUF_MAX_VAL			0x78
+#define BUF_MIN_VAL			0x0a
+
+#define DCU_INT_STATUS			0x002C
+#define DCU_INT_STATUS_UNDRUN		BIT(1)
+
+#define DCU_INT_MASK			0x0030
+#define DCU_INT_MASK_UNDRUN		BIT(1)
+#define DCU_INT_MASK_VBLANK		BIT(3)
+
+#define DCU_DIV_RATIO			0x0054
+
+#define DCU_UPDATE_MODE			0x00cc
+#define DCU_UPDATE_MODE_MODE		BIT(31)
+#define DCU_UPDATE_MODE_READREG		BIT(30)
+
+#define DCU_DCFB_MAX			0x300
+
+#define DCU_CTRLDESCLN_1(x)		(0x200 + (x) * 0x40)
+#define DCU_CTRLDESCLN_1_HEIGHT(x)	((x) << 16)
+#define DCU_CTRLDESCLN_1_WIDTH(x)	(x)
+
+#define DCU_CTRLDESCLN_2(x)		(0x204 + (x) * 0x40)
+#define DCU_CTRLDESCLN_2_POSY(x)	((x) << 16)
+#define DCU_CTRLDESCLN_2_POSX(x)	(x)
+
+#define DCU_CTRLDESCLN_3(x)		(0x208 + (x) * 0x40)
+
+#define DCU_CTRLDESCLN_4(x)		(0x20c + (x) * 0x40)
+#define DCU_CTRLDESCLN_4_EN		BIT(31)
+#define DCU_CTRLDESCLN_4_TILE_EN	BIT(30)
+#define DCU_CTRLDESCLN_4_DATA_SEL_CLUT	BIT(29)
+#define DCU_CTRLDESCLN_4_SAFETY_EN	BIT(28)
+#define DCU_CTRLDESCLN_4_TRANS(x)	((x) << 20)
+#define DCU_CTRLDESCLN_4_BPP(x)		((x) << 16)
+#define DCU_CTRLDESCLN_4_RLE_EN		BIT(15)
+#define DCU_CTRLDESCLN_4_LUOFFS(x)	((x) << 4)
+#define DCU_CTRLDESCLN_4_BB_ON		BIT(2)
+#define DCU_CTRLDESCLN_4_AB(x)		(x)
+
+#define DCU_CTRLDESCLN_5(x)		(0x210 + (x) * 0x40)
+#define DCU_CTRLDESCLN_5_CKMAX_R(x)	((x) << 16)
+#define DCU_CTRLDESCLN_5_CKMAX_G(x)	((x) << 8)
+#define DCU_CTRLDESCLN_5_CKMAX_B(x)	(x)
+
+#define DCU_CTRLDESCLN_6(x)		(0x214 + (x) * 0x40)
+#define DCU_CTRLDESCLN_6_CKMIN_R(x)	((x) << 16)
+#define DCU_CTRLDESCLN_6_CKMIN_G(x)	((x) << 8)
+#define DCU_CTRLDESCLN_6_CKMIN_B(x)	(x)
+
+#define DCU_CTRLDESCLN_7(x)		(0x218 + (x) * 0x40)
+#define DCU_CTRLDESCLN_7_TILE_VER(x)	((x) << 16)
+#define DCU_CTRLDESCLN_7_TILE_HOR(x)	(x)
+
+#define DCU_CTRLDESCLN_8(x)		(0x21c + (x) * 0x40)
+#define DCU_CTRLDESCLN_8_FG_FCOLOR(x)	(x)
+
+#define DCU_CTRLDESCLN_9(x)		(0x220 + (x) * 0x40)
+#define DCU_CTRLDESCLN_9_BG_BCOLOR(x)	(x)
+
+#define DCU_CTRLDESCLN_10(x)		(0x224 + (x) * 0x40)
+#define DCU_CTRLDESCLN_10_POST_SKIP(x)	((x) << 16)
+#define DCU_CTRLDESCLN_10_PRE_SKIP(x)	(x)
+
+#define FSL_DCU_RGB565			4
+#define FSL_DCU_RGB888			5
+#define FSL_DCU_ARGB8888		6
+#define FSL_DCU_ARGB1555		11
+#define FSL_DCU_ARGB4444		12
+#define FSL_DCU_YUV422			14
+
+#define TCON_CTRL1			0x0000
+#define TCON_BYPASS_ENABLE		BIT(29)
+
+#define DBG(fmt, ...) DRM_DEBUG(fmt"\n", ##__VA_ARGS__)
+
+struct clk;
+struct device;
+struct drm_device;
+
+struct fsl_dcu_drm_device {
+	struct device *dev;
+	struct regmap *regmap;
+	struct regmap *tcon_regmap;
+	struct regmap *scfg_regmap;
+	unsigned int irq;
+	struct clk *clk;
+	/*protects hardware register*/
+	spinlock_t irq_lock;
+	struct drm_device *ddev;
+	struct drm_fbdev_cma *fbdev;
+	struct fsl_dcu_drm_crtc crtc;
+	struct fsl_dcu_drm_encoder encoder;
+	struct fsl_dcu_drm_connector connector; };
+
+void fsl_dcu_fbdev_init(struct drm_device *dev);
+
+#endif /* __FSL_DCU_DRM_DRV_H__ */
drivers/gpu/drm/fsl/fsl_dcu_drm_fbdev.c new file +46 -0
new file mode 100644
index 0000000..6729f92
@@ -0,0 +1,43 @@
+/*
+ * 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_crtc.h>
+#include <drm/drm_fb_helper.h>
+#include <drm/drm_crtc_helper.h>
+#include <drm/drm_fb_cma_helper.h>
+#include <drm/drm_gem_cma_helper.h>
+#include <linux/clk.h>
+#include <linux/delay.h>
+#include <linux/dma-mapping.h>
+#include <linux/fb.h>
+#include <linux/interrupt.h>
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/of_platform.h>
+#include <linux/regmap.h>
+#include <video/of_display_timing.h>
+#include <video/videomode.h>
+#include <linux/uaccess.h>
+
+#include "fsl_dcu_drm_drv.h"
+#include "fsl_dcu_drm_crtc.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 +14 -0
new file mode 100644
index 0000000..0eb0652
@@ -0,0 +1,45 @@
+/*
+ * 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.
+ */
+
+#include <drm/drmP.h>

drivers/gpu/drm/fsl/fsl_dcu_drm_kms.c line 24

Quoted 10 lines
drivers/gpu/drm/fsl/fsl_dcu_drm_kms.c new file +10 -0
+#include <drm/drm_crtc.h>
+#include <drm/drm_crtc_helper.h>
+#include <drm/drm_fb_cma_helper.h>
+#include <drm/drm_gem_cma_helper.h>
+
+#include "fsl_dcu_drm_crtc.h"
+#include "fsl_dcu_drm_drv.h"
+#include "fsl_dcu_drm_kms.h"
+
+static const struct drm_mode_config_funcs

fsl_dcu_drm_mode_config_funcs = {

Quoted 146 lines
drivers/gpu/drm/fsl/fsl_dcu_drm_kms.c new file +22 -0
+	.fb_create = drm_fb_cma_create,
+};
+
+int fsl_dcu_drm_modeset_init(struct fsl_dcu_drm_device *fsl_dev) {
+	drm_mode_config_init(fsl_dev->ddev);
+
+	fsl_dev->ddev->mode_config.min_width = 0;
+	fsl_dev->ddev->mode_config.min_height = 0;
+	fsl_dev->ddev->mode_config.max_width = 2031;
+	fsl_dev->ddev->mode_config.max_height = 2047;
+	fsl_dev->ddev->mode_config.funcs = &fsl_dcu_drm_mode_config_funcs;
+
+	fsl_dcu_drm_crtc_create(fsl_dev);
+	fsl_dcu_drm_encoder_create(fsl_dev);
+	fsl_dcu_drm_connector_create(fsl_dev, &fsl_dev->encoder.encoder);
+
+	drm_kms_helper_poll_init(fsl_dev->ddev);
+
+	drm_helper_disable_unused_functions(fsl_dev->ddev);
+
+	return 0;
+}
drivers/gpu/drm/fsl/fsl_dcu_drm_kms.h new file +24 -0
new file mode 100644
index 0000000..9d5b798
@@ -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_DRM_KMS_H__
+#define __FSL_DCU_DRM_KMS_H__
+
+#include <linux/types.h>
+
+struct drm_gem_cma_object;
+struct fsl_dcu_drm_device;
+
+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 +65 -0
new file mode 100644
index 0000000..d725594
@@ -0,0 +1,124 @@
+/*
+ * 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.
+ */
+
+#include <drm/drmP.h>
+#include <drm/drm_crtc.h>
+#include <drm/drm_crtc_helper.h>
+#include <drm/drm_fb_cma_helper.h>
+#include <drm/drm_gem_cma_helper.h>
+#include <linux/regmap.h>
+
+#include "fsl_dcu_drm_drv.h"
+#include "fsl_dcu_drm_kms.h"
+#include "fsl_dcu_drm_plane.h"
+
+static void __fsl_dcu_drm_plane_setup(struct drm_plane *plane,
+				      struct drm_framebuffer *fb) {
+	struct fsl_dcu_drm_device *fsl_dev = plane->dev->dev_private;
+	u32 plane_num = 0, alpha, bpp;
+	struct drm_gem_cma_object *gem;
+
+	while (plane->possible_crtcs >> 1)
+		plane_num++;
+
+	gem = drm_fb_cma_get_gem_obj(fb, 0);
+
+	switch (fb->pixel_format) {
+	case DRM_FORMAT_RGB565:
+		bpp = FSL_DCU_RGB565;
+		alpha = 0xff;
+		break;
+	case DRM_FORMAT_RGB888:
+		bpp = FSL_DCU_RGB888;
+		alpha = 0xff;
+		break;
+	case DRM_FORMAT_ARGB8888:
+		bpp = FSL_DCU_ARGB8888;
+		alpha = 0xff;
+		break;
+	case DRM_FORMAT_BGRA4444:
+		bpp = FSL_DCU_ARGB4444;
+		alpha = 0xff;
+		break;
+	case DRM_FORMAT_ARGB1555:
+		bpp = FSL_DCU_ARGB1555;
+		alpha = 0xff;
+		break;
+	case DRM_FORMAT_YUV422:
+		bpp = FSL_DCU_YUV422;
+		alpha = 0xff;
+		break;
+	default:
+		return;
+	}
+
+	regmap_write(fsl_dev->regmap, DCU_CTRLDESCLN_3(plane_num), gem-

paddr);

drivers/gpu/drm/fsl/fsl_dcu_drm_plane.c new file +20 -0
+	regmap_write(fsl_dev->regmap, DCU_CTRLDESCLN_4(plane_num),
+		     DCU_CTRLDESCLN_4_EN |
+		     DCU_CTRLDESCLN_4_TRANS(alpha) |
+		     DCU_CTRLDESCLN_4_BPP(bpp) |
+		     DCU_CTRLDESCLN_4_AB(2));
+	regmap_write(fsl_dev->regmap, DCU_CTRLDESCLN_5(plane_num),
+		     DCU_CTRLDESCLN_5_CKMAX_R(0xFF) |
+		     DCU_CTRLDESCLN_5_CKMAX_G(0xFF) |
+		     DCU_CTRLDESCLN_5_CKMAX_B(0xFF));
+	regmap_write(fsl_dev->regmap, DCU_CTRLDESCLN_6(plane_num),
+		     DCU_CTRLDESCLN_6_CKMIN_R(0) |
+		     DCU_CTRLDESCLN_6_CKMIN_G(0) |
+		     DCU_CTRLDESCLN_6_CKMIN_B(0));
+	regmap_write(fsl_dev->regmap, DCU_CTRLDESCLN_8(plane_num),
+		     DCU_CTRLDESCLN_8_FG_FCOLOR(0));
+	regmap_write(fsl_dev->regmap, DCU_CTRLDESCLN_9(plane_num),
+		     DCU_CTRLDESCLN_9_BG_BCOLOR(0));
+	regmap_write(fsl_dev->regmap, DCU_CTRLDESCLN_10(plane_num),
+		     DCU_CTRLDESCLN_10_POST_SKIP(0) |
+		     DCU_CTRLDESCLN_10_PRE_SKIP(0));

drivers/gpu/drm/fsl/fsl_dcu_drm_plane.c

Quoted 10 lines
drivers/gpu/drm/fsl/fsl_dcu_drm_plane.c new file +10 -0
+	regmap_write(fsl_dev->regmap, DCU_UPDATE_MODE,
+DCU_UPDATE_MODE_READREG); }
+
+void fsl_dcu_drm_plane_setup(struct drm_plane *plane) {
+	if (!plane->fb)
+		return;
+
+	__fsl_dcu_drm_plane_setup(plane, plane->fb); }
+
+int fsl_dcu_drm_plane_update(struct drm_plane *plane, struct drm_crtc

*crtc,

Quoted 65 lines
drivers/gpu/drm/fsl/fsl_dcu_drm_plane.c new file +25 -0
+			     struct drm_framebuffer *fb, int crtc_x, int crtc_y,
+			    unsigned int crtc_w, unsigned int crtc_h,
+			    uint32_t src_x, uint32_t src_y,
+			    uint32_t src_w, uint32_t src_h) {
+	__fsl_dcu_drm_plane_setup(plane, fb);
+	return 0;
+}
+
+int fsl_dcu_drm_plane_disable(struct drm_plane *plane) {
+	return 0;
+}
+
+void fsl_dcu_drm_plane_destroy(struct drm_plane *plane) {
+	fsl_dcu_drm_plane_disable(plane);
+	drm_plane_cleanup(plane);
+}
+
+static const uint32_t formats[] = {
+	DRM_FORMAT_RGB565,
+	DRM_FORMAT_RGB888,
+	DRM_FORMAT_ARGB8888,
+	DRM_FORMAT_ARGB4444,
+	DRM_FORMAT_ARGB1555,
+	DRM_FORMAT_YUV422,
+};
drivers/gpu/drm/fsl/fsl_dcu_drm_plane.h new file +30 -1
new file mode 100644
index 0000000..da88d1c
@@ -0,0 +1,28 @@
+/*
+ * 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;
+
+void fsl_dcu_drm_plane_setup(struct drm_plane *plane); int
+fsl_dcu_drm_plane_update(struct drm_plane *plane,
+			     struct drm_crtc *crtc,
+			     struct drm_framebuffer *fb,
+			     int crtc_x, int crtc_y,
+			     unsigned int crtc_w, unsigned int crtc_h,
+			     uint32_t src_x, uint32_t src_y,
+			     uint32_t src_w, uint32_t src_h); int
+fsl_dcu_drm_plane_disable(struct drm_plane *plane); void
+fsl_dcu_drm_plane_destroy(struct drm_plane *plane);
+
+#endif /* __FSL_DCU_DRM_PLANE_H__ */
--

2.1.0.27.g96db324

Quoted 4 lines

_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel

--
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch

Signature · 7 lines
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch
_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
#8 lore raw
Quoted 59 lines

-----Original Message-----
From: Daniel Vetter [mailto:[email protected]] On Behalf Of Daniel Vetter
Sent: Tuesday, March 03, 2015 6:54 PM
To: Wang Jianwei-B52261
Cc: Daniel Vetter; [email protected]; [email protected]; Wood Scott-B07421; Xiubo Li; Wang Huan-B18965; [email protected]; [email protected]
Subject: Re: [PATCH 1/3] drm/layerscape: Add fsl dcu DRM driver

Quoted 2 lines · On Tue, Mar 03, 2015 at 10:06:57AM +0000, [email protected] wrote:
Quoted 2 lines

-----Original Message-----
From: Daniel Vetter [mailto:[email protected]] On Behalf Of

Daniel

Quoted 5 lines
Quoted 5 lines

Vetter
Sent: Sunday, February 22, 2015 7:35 PM
To: Wang Jianwei-B52261
Cc: [email protected]; [email protected]; Wood Scott-B07421; Xiubo Li; Wang Huan-B18965; linux-

[email protected];

Quoted 5 lines
Quoted 5 lines

[email protected]
Subject: Re: [PATCH 1/3] drm/layerscape: Add fsl dcu DRM driver

Quoted 1 line · Jianwei Wang

This patch add support for Two Dimensional Animation and

Compositing

Quoted 6 lines
Quoted 6 lines
Quoted 6 lines

Engine (2D-ACE) on the Freescale LS102x SoCs.

2D-ACE is a Freescale display controller. It supports at most four plane and provide an hardware cursor.

This is a simplified version, only a primary plane, a fb created

for

Quoted 9 lines
Quoted 9 lines
Quoted 6 lines

fbdev, a crtc, a connector for TFT LCD panel, an encoder, and the encoder is not in use. Now this drver support fbdev only.

Imo adding a new driver without primary plane support (use drm_crtc_init_with_planes) and without atomic support doesn't make

sense

Quoted 6 lines
Quoted 5 lines

any more.

Also, what do you mean with "support fbdev only"?
-Daniel

Quoted 6 lines

Daniel,

This driver has supported primary plane (use drm_crtc_init_with_planes) Already.
If atomic support is a must? 2D-ACE is a simple display Controller and this is a simplified version. If atomic support is not a must, I want

to add

Quoted 1 line

it with patches, is it ok?

Quoted 8 lines

atomic is the new way the drm display subsystem works, not supporting it in new drivers makes this transition even longer. Since I guess if you don't want to do the conversion now no one else will do it anytime later, and then we're stuck with this driver as-is. On top of that atomic should simplify testing for your driver a lot (since a few things are take care of for you in the generic atomic code).
-Daniel

Okey! I'll add atomic support in this driver.

Regards,
Wang Jianwei

Quoted 1,497 lines
Quoted 3 lines

" Now this drver support fbdev only." if this sentence confuses you, I'd like remove it. In fact I mean that this driver only create a

framebuffer

Quoted 38 lines

dev (use drm_fbdev_cma_init).

Thanks
Regards,
Wang Jianwei

Quoted 32 lines
Quoted 7 lines
---
 .../devicetree/bindings/video/fsl,dcfb.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_crtc.c             | 412

+++++++++++++++++++++

Quoted 2 lines
 drivers/gpu/drm/fsl/fsl_dcu_drm_crtc.h             |  40 ++
 drivers/gpu/drm/fsl/fsl_dcu_drm_drv.c              | 323

++++++++++++++++

Quoted 21 lines
 drivers/gpu/drm/fsl/fsl_dcu_drm_drv.h              | 167 +++++++++
 drivers/gpu/drm/fsl/fsl_dcu_drm_fbdev.c            |  43 +++
 drivers/gpu/drm/fsl/fsl_dcu_drm_kms.c              |  45 +++
 drivers/gpu/drm/fsl/fsl_dcu_drm_kms.h              |  22 ++
 drivers/gpu/drm/fsl/fsl_dcu_drm_plane.c            | 124 +++++++
 drivers/gpu/drm/fsl/fsl_dcu_drm_plane.h            |  28 ++
 14 files changed, 1281 insertions(+)
 create mode 100644
Documentation/devicetree/bindings/video/fsl,dcfb.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_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
Quoted 12 lines
Quoted 4 lines
Quoted 4 lines
Documentation/devicetree/bindings/video/fsl,dcfb.txt new file +0 -0
new file mode 100644
index 0000000..de7da97
Quoted 8 lines

Documentation/devicetree/bindings/video/fsl,dcfb.txt line 5

Quoted 8 lines
Documentation/devicetree/bindings/video/fsl,dcfb.txt new file +5 -0
@@ -0,0 +1,50 @@
+* Freescale Simple Display Controller FB Driver
+
+Required properties:
+- compatible:		Should be one of "fsl,ls1021a-dcfb".
+- reg:			Address and length of the register set for

dcfb.

Quoted 39 lines
Quoted 39 lines
Quoted 4 lines
Documentation/devicetree/bindings/video/fsl,dcfb.txt new file +4 -0
+- clocks:		From common clock binding: handle to dcfb clock.
+- clock-names:		From common clock binding: Shall be "dcfb".
+- display:		The phandle to display node.
+

Documentation/devicetree/bindings/video/fsl,dcfb.txt

Quoted 10 lines
Documentation/devicetree/bindings/video/fsl,dcfb.txt new file +10 -0
+Optional properties:
+- scfg-controller:	The phandle of scfg 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.

Quoted 24 lines
Documentation/devicetree/bindings/video/fsl,dcfb.txt new file +24 -0
+
+Examples:
+dcfb: dcfb@2ce0000 {
+	compatible = "fsl,ls1021a-dcfb";
+	reg = <0x0 0x2ce0000 0x0 0x10000>;
+	clocks = <&platform_clk 0>;
+	clock-names = "dcfb";
+	scfg-controller = <&scfg>;
+	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>;
Quoted 8 lines
Quoted 8 lines

drivers/gpu/drm/Kconfig

Quoted 8 lines
Documentation/devicetree/bindings/video/fsl,dcfb.txt new file +7 -0
+				vsync-len = <2>;
+				hsync-active = <1>;
+				vsync-active = <1>;
+			};
+		};
+	};
+};
drivers/gpu/drm/Kconfig +0 -0

index

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines

151a050..a6957aa 100644

drivers/gpu/drm/Kconfig +0 -0
@@ -199,6 +199,8 @@ source "drivers/gpu/drm/bochs/Kconfig"
 
Quoted 8 lines
Quoted 8 lines

drivers/gpu/drm/Makefile

Quoted 8 lines
drivers/gpu/drm/Kconfig +2 -0
 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 +0 -0

index

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

2c239b9..ab5b9ef 100644

drivers/gpu/drm/Makefile +0 -0
@@ -56,6 +56,7 @@ obj-$(CONFIG_DRM_UDL) += udl/
Quoted 8 lines
Quoted 8 lines

Review

Quoted 8 lines
drivers/gpu/drm/Makefile +1 -0
 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/
(quoted diff) +0 -0

b/drivers/gpu/drm/fsl/Kconfig

Quoted 41 lines
Quoted 41 lines
Quoted 41 lines

new file mode 100644 index 0000000..e4f8df0

drivers/gpu/drm/fsl/Kconfig new file +17 -0
@@ -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.
(quoted diff) +0 -0

b/drivers/gpu/drm/fsl/Makefile new file mode 100644 index 0000000..51c3e1f

drivers/gpu/drm/fsl/Makefile new file +7 -0
@@ -0,0 +1,7 @@
+fsl-dcu-drm-y := fsl_dcu_drm_drv.o \
+	       fsl_dcu_drm_kms.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_crtc.c new file +0 -0
new file mode 100644
index 0000000..9f5ba86
@@ -0,0 +1,412 @@
Quoted 8 lines
Quoted 8 lines

drivers/gpu/drm/fsl/fsl_dcu_drm_crtc.c

Quoted 8 lines
drivers/gpu/drm/fsl/fsl_dcu_drm_crtc.c new file +8 -0
+/*
+ * 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

Quoted 2 lines
Quoted 2 lines

drivers/gpu/drm/fsl/fsl_dcu_drm_crtc.c line 10

Quoted 2 lines
drivers/gpu/drm/fsl/fsl_dcu_drm_crtc.c new file +2 -0
+by
+ * the Free Software Foundation; either version 2 of the License,

or

Quoted 14 lines
Quoted 14 lines
Quoted 14 lines
drivers/gpu/drm/fsl/fsl_dcu_drm_crtc.c new file +14 -0
+ * (at your option) any later version.
+ */
+
+#include <linux/backlight.h>
+#include <linux/clk.h>
+#include <linux/regmap.h>
+
+#include <drm/drmP.h>
+#include <drm/drm_atomic_helper.h>
+#include <drm/drm_crtc.h>
+#include <drm/drm_crtc_helper.h>
+#include <drm/drm_fb_cma_helper.h>
+#include <drm/drm_gem_cma_helper.h>
+#include <drm/drm_plane_helper.h>
Quoted 8 lines
Quoted 8 lines

drivers/gpu/drm/fsl/fsl_dcu_drm_crtc.c

Quoted 8 lines
drivers/gpu/drm/fsl/fsl_dcu_drm_crtc.c new file +8 -0
+#include <video/of_display_timing.h>
+
+#include "fsl_dcu_drm_crtc.h"
+#include "fsl_dcu_drm_drv.h"
+#include "fsl_dcu_drm_kms.h"
+#include "fsl_dcu_drm_plane.h"
+
+#define to_fsl_dcu_crtc(c)	container_of(c, struct

fsl_dcu_drm_crtc,

Quoted 16 lines
Quoted 16 lines

crtc)

Quoted 15 lines
drivers/gpu/drm/fsl/fsl_dcu_drm_crtc.c new file +15 -0
+
+static void fsl_dcu_drm_crtc_start(struct drm_crtc *crtc) {
+	fsl_dcu_drm_plane_setup(crtc->primary);
+}
+
+static void fsl_dcu_drm_crtc_stop(struct drm_crtc *crtc) { }
+
+void fsl_dcu_drm_crtc_suspend(struct drm_crtc *crtc) {
+	fsl_dcu_drm_crtc_stop(crtc);
+}
+
+void fsl_dcu_drm_crtc_resume(struct drm_crtc *crtc) {
+	struct fsl_dcu_drm_crtc *fsl_crtc = to_fsl_dcu_crtc(crtc);
+
+	if (fsl_crtc->dpms != DRM_MODE_DPMS_ON)
Quoted 8 lines
Quoted 8 lines

drivers/gpu/drm/fsl/fsl_dcu_drm_crtc.c line 60

Quoted 8 lines
drivers/gpu/drm/fsl/fsl_dcu_drm_crtc.c new file +8 -0
+		return;
+
+	fsl_dcu_drm_crtc_start(crtc);
+}
+
+static void fsl_dcu_drm_crtc_update_base(struct drm_crtc *crtc) { }
+
+static void fsl_dcu_drm_crtc_dpms(struct drm_crtc *crtc, int mode)

{

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
drivers/gpu/drm/fsl/fsl_dcu_drm_crtc.c new file +8 -0
+	struct fsl_dcu_drm_crtc *fsl_crtc = to_fsl_dcu_crtc(crtc);
+
+	if (fsl_crtc->dpms == mode)
+		return;
+
+	if (mode == DRM_MODE_DPMS_ON)
+		fsl_dcu_drm_crtc_start(crtc);
+	else
Quoted 8 lines
Quoted 8 lines

drivers/gpu/drm/fsl/fsl_dcu_drm_crtc.c

Quoted 8 lines
drivers/gpu/drm/fsl/fsl_dcu_drm_crtc.c new file +8 -0
+		fsl_dcu_drm_crtc_stop(crtc);
+
+	fsl_crtc->dpms = mode;
+}
+
+static bool fsl_dcu_drm_crtc_mode_fixup(struct drm_crtc *crtc,
+					const struct drm_display_mode *mode,
+					struct drm_display_mode

*adjusted_mode) {

Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
drivers/gpu/drm/fsl/fsl_dcu_drm_crtc.c new file +9 -0
+	return true;
+}
+
+static void fsl_dcu_drm_crtc_mode_prepare(struct drm_crtc *crtc) {
+		fsl_dcu_drm_crtc_stop(crtc);
+}
+
+static int fsl_dcu_drm_crtc_mode_set(struct drm_crtc *crtc,
+				     struct drm_display_mode *mode,
Quoted 8 lines
Quoted 8 lines

drivers/gpu/drm/fsl/fsl_dcu_drm_crtc.c

Quoted 8 lines
drivers/gpu/drm/fsl/fsl_dcu_drm_crtc.c new file +8 -0
+				     struct drm_display_mode *adjusted_mode,
+				     int x, int y,
+				     struct drm_framebuffer *old_fb) {
+	struct drm_device *dev = crtc->dev;
+	struct fsl_dcu_drm_device *fsl_dev = dev->dev_private;
+	uint32_t hbp, hfp, hsw, vbp, vfp, vsw, div, index;
+
+	DBG(": set mode: %d:\"%s\" %d %d %d %d %d %d %d %d %d %d 0x%x

0x%x",

Quoted 10 lines
Quoted 10 lines

drivers/gpu/drm/fsl/fsl_dcu_drm_crtc.c

Quoted 10 lines
drivers/gpu/drm/fsl/fsl_dcu_drm_crtc.c new file +10 -0
+	    mode->base.id, mode->name,
+	    mode->vrefresh, mode->clock,
+	    mode->hdisplay, mode->hsync_start,
+	    mode->hsync_end, mode->htotal,
+	    mode->vdisplay, mode->vsync_start,
+	    mode->vsync_end, mode->vtotal,
+	    mode->type, mode->flags);
+
+	index = drm_crtc_index(crtc);
+	div = (uint32_t)clk_get_rate(fsl_dev->clk) / crtc->mode.clock

/

Quoted 31 lines
Quoted 31 lines
Quoted 31 lines
drivers/gpu/drm/fsl/fsl_dcu_drm_crtc.c new file +31 -0
+1000;
+
+	/* Configure timings: */
+	hbp = mode->htotal - mode->hsync_end;
+	hfp = mode->hsync_start - mode->hdisplay;
+	hsw = mode->hsync_end - mode->hsync_start;
+	vbp = mode->vtotal - mode->vsync_end;
+	vfp = mode->vsync_start - mode->vdisplay;
+	vsw = mode->vsync_end - mode->vsync_start;
+
+	regmap_write(fsl_dev->regmap, DCU_HSYN_PARA,
+		     DCU_HSYN_PARA_BP(hbp) |
+		     DCU_HSYN_PARA_PW(hsw) |
+		     DCU_HSYN_PARA_FP(hfp));
+	regmap_write(fsl_dev->regmap, DCU_VSYN_PARA,
+		     DCU_VSYN_PARA_BP(vbp) |
+		     DCU_VSYN_PARA_PW(vsw) |
+		     DCU_VSYN_PARA_FP(vfp));
+	regmap_write(fsl_dev->regmap, DCU_DISP_SIZE,
+		     DCU_DISP_SIZE_DELTA_Y(mode->vdisplay) |
+		     DCU_DISP_SIZE_DELTA_X(mode->hdisplay));
+	regmap_write(fsl_dev->regmap, DCU_CTRLDESCLN_1(index),
+		     DCU_CTRLDESCLN_1_HEIGHT(mode->vdisplay) |
+		     DCU_CTRLDESCLN_1_WIDTH(mode->hdisplay));
+	regmap_write(fsl_dev->regmap, DCU_CTRLDESCLN_2(index),
+		     DCU_CTRLDESCLN_2_POSY(y) |
+		     DCU_CTRLDESCLN_2_POSX(x));
+	regmap_write(fsl_dev->regmap, DCU_DIV_RATIO, div);
+	regmap_write(fsl_dev->regmap, DCU_UPDATE_MODE,
+DCU_UPDATE_MODE_READREG);
+
Quoted 8 lines
Quoted 8 lines

drivers/gpu/drm/fsl/fsl_dcu_drm_crtc.c

Quoted 8 lines
drivers/gpu/drm/fsl/fsl_dcu_drm_crtc.c new file +8 -0
+	return 0;
+}
+
+static void fsl_dcu_drm_crtc_mode_commit(struct drm_crtc *crtc) {
+		fsl_dcu_drm_crtc_start(crtc);
+}
+
+static int fsl_dcu_drm_crtc_mode_set_base(struct drm_crtc *crtc,

int x,

Quoted 10 lines
Quoted 10 lines

int y,

Quoted 9 lines
drivers/gpu/drm/fsl/fsl_dcu_drm_crtc.c new file +9 -0
+					  struct drm_framebuffer *old_fb) {
+	fsl_dcu_drm_crtc_update_base(crtc);
+
+	return 0;
+}
+
+static const struct drm_crtc_helper_funcs crtc_helper_funcs = {
+	.dpms = fsl_dcu_drm_crtc_dpms,
+	.mode_fixup = fsl_dcu_drm_crtc_mode_fixup,
Quoted 8 lines
Quoted 8 lines

drivers/gpu/drm/fsl/fsl_dcu_drm_crtc.c

Quoted 8 lines
drivers/gpu/drm/fsl/fsl_dcu_drm_crtc.c new file +8 -0
+	.prepare = fsl_dcu_drm_crtc_mode_prepare,
+	.commit = fsl_dcu_drm_crtc_mode_commit,
+	.mode_set = fsl_dcu_drm_crtc_mode_set,
+	.mode_set_base = fsl_dcu_drm_crtc_mode_set_base, };
+
+static int fsl_dcu_drm_crtc_page_flip(struct drm_crtc *crtc,
+				      struct drm_framebuffer *fb,
+				      struct drm_pending_vblank_event

*event,

Quoted 44 lines
Quoted 44 lines
Quoted 33 lines
drivers/gpu/drm/fsl/fsl_dcu_drm_crtc.c new file +33 -0
+				      uint32_t page_flip_flags)
+{
+	return 0;
+}
+
+static const struct drm_plane_funcs fsl_dcu_drm_plane_funcs = {
+	.update_plane = fsl_dcu_drm_plane_update,
+	.disable_plane = fsl_dcu_drm_plane_disable,
+	.destroy = fsl_dcu_drm_plane_destroy, };
+
+static const struct drm_crtc_funcs crtc_funcs = {
+	.destroy = drm_crtc_cleanup,
+	.set_config = drm_crtc_helper_set_config,
+	.page_flip = fsl_dcu_drm_crtc_page_flip, };
+
+int fsl_dcu_drm_crtc_create(struct fsl_dcu_drm_device *fsl_dev) {
+	struct drm_crtc *crtc = &fsl_dev->crtc.crtc;
+	int ret;
+
+	fsl_dev->crtc.dpms = DRM_MODE_DPMS_OFF;
+
+	ret = drm_crtc_init(fsl_dev->ddev, crtc, &crtc_funcs);
+	if (ret < 0)
+		return ret;
+
+	crtc->primary->funcs = &fsl_dcu_drm_plane_funcs;
+
+	drm_crtc_helper_add(crtc, &crtc_helper_funcs);
+
+	regmap_write(fsl_dev->regmap, DCU_SYN_POL,
+		     DCU_SYN_POL_INV_VS_LOW | DCU_SYN_POL_INV_HS_LOW);
+	regmap_write(fsl_dev->regmap, DCU_BGND, DCU_BGND_R(0) |
+		     DCU_BGND_G(0) | DCU_BGND_B(0));

drivers/gpu/drm/fsl/fsl_dcu_drm_crtc.c

Quoted 10 lines
drivers/gpu/drm/fsl/fsl_dcu_drm_crtc.c new file +10 -0
+	regmap_write(fsl_dev->regmap, DCU_DCU_MODE,
+		     DCU_MODE_BLEND_ITER(1) | DCU_MODE_RASTER_EN);
+	regmap_write(fsl_dev->regmap, DCU_THRESHOLD,
+		     DCU_THRESHOLD_LS_BF_VS(BF_VS_VAL) |
+		     DCU_THRESHOLD_OUT_BUF_HIGH(BUF_MAX_VAL) |
+		     DCU_THRESHOLD_OUT_BUF_LOW(BUF_MIN_VAL));
+	regmap_update_bits(fsl_dev->regmap, DCU_DCU_MODE,
+			   DCU_MODE_DCU_MODE_MASK,
+			   DCU_MODE_DCU_MODE(DCU_MODE_NORMAL));
+	regmap_write(fsl_dev->regmap, DCU_UPDATE_MODE,

DCU_UPDATE_MODE_READREG);

Quoted 11 lines
Quoted 11 lines

drivers/gpu/drm/fsl/fsl_dcu_drm_crtc.c

Quoted 11 lines
drivers/gpu/drm/fsl/fsl_dcu_drm_crtc.c new file +11 -0
+	return 0;
+}
+
+/*
+ * Encoder
+ */
+
+#define to_fsl_dcu_encoder(e) \
+	container_of(e, struct fsl_dcu_drm_encoder, encoder)
+
+static void fsl_dcu_drm_encoder_dpms(struct drm_encoder *encoder,

int

Quoted 2 lines
Quoted 2 lines

drivers/gpu/drm/fsl/fsl_dcu_drm_crtc.c line 210

Quoted 2 lines
drivers/gpu/drm/fsl/fsl_dcu_drm_crtc.c new file +2 -0
+mode) {
+	struct fsl_dcu_drm_encoder *fsl_enc =

to_fsl_dcu_encoder(encoder);

Quoted 15 lines
Quoted 6 lines
Quoted 6 lines
drivers/gpu/drm/fsl/fsl_dcu_drm_crtc.c new file +6 -0
+
+	if (fsl_enc->dpms == mode)
+		return;
+
+	fsl_enc->dpms = mode;
+}
Quoted 8 lines

drivers/gpu/drm/fsl/fsl_dcu_drm_crtc.c

Quoted 8 lines
drivers/gpu/drm/fsl/fsl_dcu_drm_crtc.c new file +8 -0
+
+static bool fsl_dcu_drm_encoder_mode_fixup
+		(struct drm_encoder *encoder,
+		const struct drm_display_mode *mode,
+		struct drm_display_mode *adjusted_mode) {
+	struct drm_device *dev = encoder->dev;
+	struct fsl_dcu_drm_device *fsl_dev = dev->dev_private;
+	struct drm_connector *connector = &fsl_dev-

connector.connector;

Quoted 8 lines
Quoted 8 lines

drivers/gpu/drm/fsl/fsl_dcu_drm_crtc.c

Quoted 8 lines
drivers/gpu/drm/fsl/fsl_dcu_drm_crtc.c new file +8 -0
+	const struct drm_display_mode *panel_mode;
+
+	if (list_empty(&connector->modes)) {
+		dev_dbg(dev->dev, "mode_fixup: empty modes list\n");
+		return false;
+	}
+
+	/* The flat panel mode is fixed, just copy it to the adjusted

mode.

Quoted 12 lines
Quoted 12 lines

*/

drivers/gpu/drm/fsl/fsl_dcu_drm_crtc.c

Quoted 11 lines
drivers/gpu/drm/fsl/fsl_dcu_drm_crtc.c new file +11 -0
+	panel_mode = list_first_entry(&connector->modes,
+				      struct drm_display_mode, head);
+	drm_mode_copy(adjusted_mode, panel_mode);
+
+	return true;
+}
+
+static void fsl_dcu_drm_encoder_mode_prepare(struct drm_encoder
+*encoder) { }
+
+static void fsl_dcu_drm_encoder_mode_set(struct drm_encoder

*encoder,

Quoted 2 lines
Quoted 2 lines

drivers/gpu/drm/fsl/fsl_dcu_drm_crtc.c line 245

Quoted 2 lines
drivers/gpu/drm/fsl/fsl_dcu_drm_crtc.c new file +2 -0
+					 struct drm_display_mode *mode,
+					 struct drm_display_mode

*adjusted_mode) { }

Quoted 7 lines
Quoted 7 lines

drivers/gpu/drm/fsl/fsl_dcu_drm_crtc.c

Quoted 7 lines
drivers/gpu/drm/fsl/fsl_dcu_drm_crtc.c new file +7 -0
+
+static void fsl_dcu_drm_encoder_mode_commit(struct drm_encoder
+*encoder) {
+	;
+}
+
+static const struct drm_encoder_helper_funcs encoder_helper_funcs

= {

Quoted 7 lines
Quoted 7 lines

drivers/gpu/drm/fsl/fsl_dcu_drm_crtc.c

Quoted 7 lines
drivers/gpu/drm/fsl/fsl_dcu_drm_crtc.c new file +7 -0
+	.dpms = fsl_dcu_drm_encoder_dpms,
+	.mode_fixup = fsl_dcu_drm_encoder_mode_fixup,
+	.prepare = fsl_dcu_drm_encoder_mode_prepare,
+	.commit = fsl_dcu_drm_encoder_mode_commit,
+	.mode_set = fsl_dcu_drm_encoder_mode_set, };
+
+static void fsl_dcu_drm_encoder_destroy(struct drm_encoder

*encoder)

Quoted 8 lines
Quoted 8 lines

drivers/gpu/drm/fsl/fsl_dcu_drm_crtc.c line 286

Quoted 8 lines
drivers/gpu/drm/fsl/fsl_dcu_drm_crtc.c new file +8 -0
+{
+	drm_encoder_cleanup(encoder);
+}
+
+static const struct drm_encoder_funcs encoder_funcs = {
+	.destroy = fsl_dcu_drm_encoder_destroy, };
+
+int fsl_dcu_drm_encoder_create(struct fsl_dcu_drm_device *fsl_dev)

{

Quoted 30 lines
Quoted 21 lines
Quoted 21 lines
drivers/gpu/drm/fsl/fsl_dcu_drm_crtc.c new file +21 -0
+	struct drm_encoder *encoder = &fsl_dev->encoder.encoder;
+	int ret;
+
+	fsl_dev->encoder.dpms = DRM_MODE_DPMS_OFF;
+
+	encoder->possible_crtcs = 1;
+
+	ret = drm_encoder_init(fsl_dev->ddev, encoder, &encoder_funcs,
+			       DRM_MODE_ENCODER_LVDS);
+	if (ret < 0)
+		return ret;
+
+	drm_encoder_helper_add(encoder, &encoder_helper_funcs);
+
+	return 0;
+}
+
+/*
+ * Connector
+ */
+
Quoted 8 lines

drivers/gpu/drm/fsl/fsl_dcu_drm_crtc.c

Quoted 8 lines
drivers/gpu/drm/fsl/fsl_dcu_drm_crtc.c new file +8 -0
+#define to_fsl_dcu_connector(c) \
+	container_of(c, struct fsl_dcu_drm_connector, connector)
+
+static int fsl_dcu_drm_connector_get_modes(struct drm_connector
+*connector) {
+	struct drm_device *dev = connector->dev;
+	struct device_node *display_np, *np = dev->dev->of_node;
+	struct drm_display_mode *mode = drm_mode_create(connector-

dev);

Quoted 6 lines
Quoted 6 lines

drivers/gpu/drm/fsl/fsl_dcu_drm_crtc.c

Quoted 6 lines
drivers/gpu/drm/fsl/fsl_dcu_drm_crtc.c new file +6 -0
+	int num_modes = 0;
+
+	if (np) {
+		display_np = of_parse_phandle(np, "display", 0);
+		if (!display_np) {
+			dev_err(dev->dev, "failed to find display

phandle\n");

Quoted 3 lines
Quoted 3 lines

drivers/gpu/drm/fsl/fsl_dcu_drm_crtc.c

Quoted 3 lines
drivers/gpu/drm/fsl/fsl_dcu_drm_crtc.c new file +3 -0
+			return num_modes;
+		}
+		of_get_drm_display_mode(display_np, mode,

OF_USE_NATIVE_MODE);

Quoted 1 line
Quoted 1 line

drivers/gpu/drm/fsl/fsl_dcu_drm_crtc.c line 306

Quoted 1 line
drivers/gpu/drm/fsl/fsl_dcu_drm_crtc.c new file +1 -0
+		mode->type |= DRM_MODE_TYPE_DRIVER |

DRM_MODE_TYPE_PREFERRED,

Quoted 9 lines
Quoted 9 lines

drivers/gpu/drm/fsl/fsl_dcu_drm_crtc.c

Quoted 8 lines
drivers/gpu/drm/fsl/fsl_dcu_drm_crtc.c new file +8 -0
+		drm_mode_probed_add(connector, mode);
+		num_modes++;
+	}
+
+	return num_modes;
+}
+
+static int fsl_dcu_drm_connector_mode_valid(struct drm_connector

*connector,

Quoted 6 lines
Quoted 6 lines

drivers/gpu/drm/fsl/fsl_dcu_drm_crtc.c line 341

Quoted 6 lines
drivers/gpu/drm/fsl/fsl_dcu_drm_crtc.c new file +6 -0
+					    struct drm_display_mode *mode) {
+	return MODE_OK;
+}
+
+static struct drm_encoder *
+fsl_dcu_drm_connector_best_encoder(struct drm_connector *connector)

{

Quoted 7 lines
Quoted 7 lines

drivers/gpu/drm/fsl/fsl_dcu_drm_crtc.c

Quoted 7 lines
drivers/gpu/drm/fsl/fsl_dcu_drm_crtc.c new file +7 -0
+	struct fsl_dcu_drm_connector *fsl_con =
+to_fsl_dcu_connector(connector);
+
+	return fsl_con->encoder;
+}
+
+static const struct drm_connector_helper_funcs

connector_helper_funcs

Quoted 17 lines
Quoted 17 lines

= {

Quoted 16 lines
drivers/gpu/drm/fsl/fsl_dcu_drm_crtc.c new file +16 -0
+	.get_modes = fsl_dcu_drm_connector_get_modes,
+	.mode_valid = fsl_dcu_drm_connector_mode_valid,
+	.best_encoder = fsl_dcu_drm_connector_best_encoder,
+};
+
+static void fsl_dcu_drm_connector_destroy(struct drm_connector
+*connector) {
+	drm_connector_unregister(connector);
+	drm_connector_cleanup(connector);
+}
+
+static enum drm_connector_status
+fsl_dcu_drm_connector_detect(struct drm_connector *connector, bool
+force) {
+	return connector_status_connected;
+}
Quoted 8 lines
Quoted 8 lines

drivers/gpu/drm/fsl/fsl_dcu_drm_crtc.c

Quoted 8 lines
drivers/gpu/drm/fsl/fsl_dcu_drm_crtc.c new file +8 -0
+
+static const struct drm_connector_funcs connector_funcs = {
+	.dpms = drm_helper_connector_dpms,
+	.detect = fsl_dcu_drm_connector_detect,
+	.fill_modes = drm_helper_probe_single_connector_modes,
+	.destroy = fsl_dcu_drm_connector_destroy, };
+
+int fsl_dcu_drm_connector_create(struct fsl_dcu_drm_device

*fsl_dev,

Quoted 4 lines
Quoted 3 lines

drivers/gpu/drm/fsl/fsl_dcu_drm_crtc.c

Quoted 3 lines
drivers/gpu/drm/fsl/fsl_dcu_drm_crtc.c new file +3 -0
+				 struct drm_encoder *encoder)
+{
+	struct drm_connector *connector = &fsl_dev-

connector.connector;

Quoted 8 lines
Quoted 8 lines

drivers/gpu/drm/fsl/fsl_dcu_drm_crtc.c

Quoted 8 lines
drivers/gpu/drm/fsl/fsl_dcu_drm_crtc.c new file +8 -0
+	int ret;
+
+	fsl_dev->connector.encoder = encoder;
+
+	connector->display_info.width_mm = 0;
+	connector->display_info.height_mm = 0;
+
+	ret = drm_connector_init(fsl_dev->ddev, connector,

&connector_funcs,

Quoted 36 lines
Quoted 10 lines
Quoted 10 lines
drivers/gpu/drm/fsl/fsl_dcu_drm_crtc.c new file +10 -0
+				 DRM_MODE_CONNECTOR_LVDS);
+	if (ret < 0)
+		return ret;
+
+	drm_connector_helper_add(connector, &connector_helper_funcs);
+	ret = drm_connector_register(connector);
+	if (ret < 0)
+		goto err_cleanup;
+
+	ret = drm_mode_connector_attach_encoder(connector, encoder);
Quoted 8 lines

drivers/gpu/drm/fsl/fsl_dcu_drm_crtc.c

Quoted 8 lines
drivers/gpu/drm/fsl/fsl_dcu_drm_crtc.c new file +8 -0
+	if (ret < 0)
+		goto err_sysfs;
+
+	connector->encoder = encoder;
+
+	drm_helper_connector_dpms(connector, DRM_MODE_DPMS_OFF);
+	drm_object_property_set_value
+		(&connector->base, fsl_dev->ddev-

mode_config.dpms_property,

Quoted 17 lines
Quoted 17 lines
drivers/gpu/drm/fsl/fsl_dcu_drm_crtc.c new file +10 -0
+		DRM_MODE_DPMS_OFF);
+
+	return 0;
+
+err_sysfs:
+	drm_connector_unregister(connector);
+err_cleanup:
+	drm_connector_cleanup(connector);
+	return ret;
+}
drivers/gpu/drm/fsl/fsl_dcu_drm_crtc.h new file +0 -0
new file mode 100644
index 0000000..ad59992
@@ -0,0 +1,40 @@
Quoted 8 lines
Quoted 8 lines

drivers/gpu/drm/fsl/fsl_dcu_drm_crtc.h line 8

Quoted 8 lines
drivers/gpu/drm/fsl/fsl_dcu_drm_crtc.h new file +8 -0
+/*
+ * 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

Quoted 2 lines
Quoted 2 lines

drivers/gpu/drm/fsl/fsl_dcu_drm_crtc.h line 10

Quoted 2 lines
drivers/gpu/drm/fsl/fsl_dcu_drm_crtc.h new file +2 -0
+by
+ * the Free Software Foundation; either version 2 of the License,

or

Quoted 19 lines
Quoted 19 lines
Quoted 19 lines
drivers/gpu/drm/fsl/fsl_dcu_drm_crtc.h new file +19 -0
+ * (at your option) any later version.
+ */
+
+#ifndef __FSL_DCU_DRM_MODSET_H__
+#define __FSL_DCU_DRM_MODSET_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;
+};
+
+struct fsl_dcu_drm_encoder {
+	struct drm_encoder encoder;
+	int dpms;
Quoted 8 lines
Quoted 8 lines

drivers/gpu/drm/fsl/fsl_dcu_drm_crtc.h line 35

Quoted 8 lines
drivers/gpu/drm/fsl/fsl_dcu_drm_crtc.h new file +8 -0
+};
+
+struct fsl_dcu_drm_connector {
+	struct drm_connector connector;
+	struct drm_encoder *encoder;
+};
+
+int fsl_dcu_drm_crtc_create(struct fsl_dcu_drm_device *fsl_dev);

int

Quoted 1 line
Quoted 1 line

drivers/gpu/drm/fsl/fsl_dcu_drm_crtc.h line 38

Quoted 1 line
drivers/gpu/drm/fsl/fsl_dcu_drm_crtc.h new file +1 -0
+fsl_dcu_drm_encoder_create(struct fsl_dcu_drm_device *fsl_dev);

int

Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
drivers/gpu/drm/fsl/fsl_dcu_drm_crtc.h new file +4 -0
+fsl_dcu_drm_connector_create(struct fsl_dcu_drm_device *fsl_dev,
+				 struct drm_encoder *encoder);
+
+#endif /* __FSL_DCU_DRM_MODSET_H__ */
drivers/gpu/drm/fsl/fsl_dcu_drm_drv.c new file +0 -0
new file mode 100644
index 0000000..1bca45a
@@ -0,0 +1,323 @@
Quoted 8 lines
Quoted 8 lines

drivers/gpu/drm/fsl/fsl_dcu_drm_drv.c line 8

Quoted 8 lines
drivers/gpu/drm/fsl/fsl_dcu_drm_drv.c new file +8 -0
+/*
+ * 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

Quoted 2 lines
Quoted 2 lines

drivers/gpu/drm/fsl/fsl_dcu_drm_drv.c line 10

Quoted 2 lines
drivers/gpu/drm/fsl/fsl_dcu_drm_drv.c new file +2 -0
+by
+ * the Free Software Foundation; either version 2 of the License,

or

Quoted 64 lines
Quoted 64 lines
Quoted 64 lines
drivers/gpu/drm/fsl/fsl_dcu_drm_drv.c new file +64 -0
+ * (at your option) any later version.
+ */
+
+#include <linux/clk.h>
+#include <linux/io.h>
+#include <linux/mm.h>
+#include <linux/module.h>
+#include <linux/of_platform.h>
+#include <linux/platform_device.h>
+#include <linux/pm.h>
+#include <linux/pm_runtime.h>
+#include <linux/regmap.h>
+#include <linux/slab.h>
+
+#include <drm/drmP.h>
+#include "fsl_dcu_drm_drv.h"
+#include "fsl_dcu_drm_kms.h"
+
+static int fsl_dcu_unload(struct drm_device *dev) {
+	drm_mode_config_cleanup(dev);
+	drm_vblank_cleanup(dev);
+	drm_irq_uninstall(dev);
+
+	dev->dev_private = NULL;
+
+	return 0;
+}
+
+static struct regmap_config fsl_dcu_regmap_config = {
+	.reg_bits = 32,
+	.reg_stride = 4,
+	.val_bits = 32,
+};
+
+static int fsl_dcu_bypass_tcon(struct fsl_dcu_drm_device *fsl_dev,
+			       struct device_node *np)
+{
+	struct device_node *tcon_np;
+	struct platform_device *pdev;
+	struct clk *tcon_clk;
+	struct resource *res;
+	void __iomem *base;
+
+	tcon_np = of_parse_phandle(np, "tcon-controller", 0);
+	if (!tcon_np)
+		return -EINVAL;
+
+	pdev = of_find_device_by_node(tcon_np);
+	if (!pdev)
+		return -EINVAL;
+
+	tcon_clk = devm_clk_get(&pdev->dev, "tcon");
+	if (IS_ERR(tcon_clk))
+		return PTR_ERR(tcon_clk);
+	clk_prepare_enable(tcon_clk);
+
+	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+	if (!res)
+		return -ENODEV;
+
+	base = devm_ioremap_resource(&pdev->dev, res);
+	if (IS_ERR(base))
+		return PTR_ERR(base);
+
Quoted 8 lines
Quoted 8 lines

drivers/gpu/drm/fsl/fsl_dcu_drm_drv.c

Quoted 8 lines
drivers/gpu/drm/fsl/fsl_dcu_drm_drv.c new file +8 -0
+	fsl_dev->tcon_regmap = devm_regmap_init_mmio_clk(&pdev->dev,
+			"tcon", base, &fsl_dcu_regmap_config);
+	if (IS_ERR(fsl_dev->tcon_regmap)) {
+		dev_err(&pdev->dev, "regmap init failed\n");
+		return PTR_ERR(fsl_dev->tcon_regmap);
+	}
+
+	regmap_write(fsl_dev->tcon_regmap, TCON_CTRL1,

TCON_BYPASS_ENABLE);

Quoted 32 lines
Quoted 32 lines
Quoted 32 lines
drivers/gpu/drm/fsl/fsl_dcu_drm_drv.c new file +32 -0
+	return 0;
+}
+
+static int fsl_dcu_scfg_config(struct fsl_dcu_drm_device *fsl_dev,
+			       struct device_node *np)
+{
+	struct device_node *scfg_np;
+	struct platform_device *pdev;
+	struct resource *res;
+	void __iomem *base;
+
+	scfg_np = of_parse_phandle(np, "scfg-controller", 0);
+	if (!scfg_np)
+		return 0;
+
+	pdev = of_find_device_by_node(scfg_np);
+	if (!pdev)
+		return -EINVAL;
+
+	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+	if (!res)
+		return -ENODEV;
+
+	base = devm_ioremap_resource(&pdev->dev, res);
+	if (IS_ERR(base))
+		return PTR_ERR(base);
+
+	fsl_dev->scfg_regmap = devm_regmap_init_mmio_clk(&pdev->dev,
+			NULL, base, &fsl_dcu_regmap_config);
+	if (IS_ERR(fsl_dev->scfg_regmap)) {
+		dev_err(&pdev->dev, "regmap init failed\n");
+		return PTR_ERR(fsl_dev->scfg_regmap);
Quoted 8 lines
Quoted 8 lines

drivers/gpu/drm/fsl/fsl_dcu_drm_drv.c

Quoted 8 lines
drivers/gpu/drm/fsl/fsl_dcu_drm_drv.c new file +8 -0
+	}
+
+	regmap_write(fsl_dev->scfg_regmap, 0x28, 0x80000000);
+
+	return 0;
+}
+
+static int fsl_dcu_load(struct drm_device *dev, unsigned long

flags)

Quoted 8 lines
Quoted 8 lines

drivers/gpu/drm/fsl/fsl_dcu_drm_drv.c

Quoted 8 lines
drivers/gpu/drm/fsl/fsl_dcu_drm_drv.c new file +8 -0
+{
+	struct platform_device *pdev = dev->platformdev;
+	struct fsl_dcu_drm_device *fsl_dev;
+	struct resource *res;
+	void __iomem *base;
+	int ret;
+
+	fsl_dev = devm_kzalloc(&pdev->dev, sizeof(*fsl_dev),

GFP_KERNEL);

Quoted 16 lines
Quoted 16 lines
Quoted 16 lines
drivers/gpu/drm/fsl/fsl_dcu_drm_drv.c new file +16 -0
+	if (!fsl_dev)
+		return -ENOMEM;
+
+	fsl_dev->dev = &pdev->dev;
+	fsl_dev->ddev = dev;
+	dev->dev_private = fsl_dev;
+
+	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+	base = devm_ioremap_resource(&pdev->dev, res);
+	if (IS_ERR(base)) {
+		ret = PTR_ERR(base);
+		return ret;
+	}
+
+	fsl_dev->regmap = devm_regmap_init_mmio(&pdev->dev,
+			base, &fsl_dcu_regmap_config);
Quoted 8 lines
Quoted 8 lines

drivers/gpu/drm/fsl/fsl_dcu_drm_drv.c

Quoted 8 lines
drivers/gpu/drm/fsl/fsl_dcu_drm_drv.c new file +8 -0
+	if (IS_ERR(fsl_dev->regmap)) {
+		dev_err(&pdev->dev, "regmap init failed\n");
+		return PTR_ERR(fsl_dev->regmap);
+	}
+
+	ret = fsl_dcu_drm_modeset_init(fsl_dev);
+	if (ret < 0) {
+		dev_err(&pdev->dev, "failed to initialize mode

setting\n");

Quoted 10 lines
Quoted 10 lines

drivers/gpu/drm/fsl/fsl_dcu_drm_drv.c

Quoted 10 lines
drivers/gpu/drm/fsl/fsl_dcu_drm_drv.c new file +10 -0
+		return ret;
+	}
+
+	ret = drm_vblank_init(dev, 1);
+	if (ret < 0) {
+		dev_err(&pdev->dev, "failed to initialize vblank\n");
+		goto done;
+	}
+
+	ret = drm_irq_install(dev, platform_get_irq(dev->platformdev,

0));

Quoted 58 lines
Quoted 58 lines

drivers/gpu/drm/fsl/fsl_dcu_drm_drv.c

Quoted 6 lines
drivers/gpu/drm/fsl/fsl_dcu_drm_drv.c new file +6 -0
+	if (ret < 0) {
+		dev_err(&pdev->dev, "failed to install IRQ handler\n");
+		goto done;
+	}
+
+	/* Put TCON in bypass mode, so the input signals from DCU are

passed

Quoted 51 lines
drivers/gpu/drm/fsl/fsl_dcu_drm_drv.c new file +51 -0
+	 * through TCON unchanged */
+	fsl_dcu_bypass_tcon(fsl_dev, pdev->dev.of_node);
+	fsl_dcu_scfg_config(fsl_dev, pdev->dev.of_node);
+
+	fsl_dev->clk = devm_clk_get(&pdev->dev, "dcfb");
+	if (IS_ERR(fsl_dev->clk)) {
+		ret = PTR_ERR(fsl_dev->clk);
+		dev_err(&pdev->dev, "could not get clock\n");
+		return ret;
+	}
+	clk_prepare_enable(fsl_dev->clk);
+
+	dev_set_drvdata(dev->dev, fsl_dev);
+
+	fsl_dcu_fbdev_init(dev);
+
+	return 0;
+done:
+	if (ret)
+		fsl_dcu_unload(dev);
+
+	return ret;
+}
+
+static void fsl_dcu_drm_preclose(struct drm_device *dev, struct
+drm_file *file) {
+	;
+}
+
+static irqreturn_t fsl_dcu_drm_irq(int irq, void *arg) {
+	return IRQ_HANDLED;
+}
+
+static int fsl_dcu_drm_enable_vblank(struct drm_device *dev, int
+crtc) {
+	return 0;
+}
+
+static void fsl_dcu_drm_disable_vblank(struct drm_device *dev, int
+crtc) {
+	;
+}
+
+static const struct file_operations fsl_dcu_drm_fops = {
+	.owner		= THIS_MODULE,
+	.open		= drm_open,
+	.release	= drm_release,
+	.unlocked_ioctl	= drm_ioctl,
+#ifdef CONFIG_COMPAT
+	.compat_ioctl	= drm_compat_ioctl,
+#endif
Quoted 8 lines
Quoted 8 lines

drivers/gpu/drm/fsl/fsl_dcu_drm_drv.c

Quoted 8 lines
drivers/gpu/drm/fsl/fsl_dcu_drm_drv.c new file +8 -0
+	.poll		= drm_poll,
+	.read		= drm_read,
+	.llseek		= no_llseek,
+	.mmap		= drm_gem_cma_mmap,
+};
+
+static struct drm_driver fsl_dcu_drm_driver = {
+	.driver_features	= DRIVER_HAVE_IRQ | DRIVER_GEM |

DRIVER_MODESET

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
drivers/gpu/drm/fsl/fsl_dcu_drm_drv.c new file +8 -0
+				| DRIVER_PRIME,
+	.load			= fsl_dcu_load,
+	.unload			= fsl_dcu_unload,
+	.preclose		= fsl_dcu_drm_preclose,
+	.irq_handler		= fsl_dcu_drm_irq,
+	.get_vblank_counter	= drm_vblank_count,
+	.enable_vblank		= fsl_dcu_drm_enable_vblank,
+	.disable_vblank		= fsl_dcu_drm_disable_vblank,
Quoted 8 lines
Quoted 8 lines

drivers/gpu/drm/fsl/fsl_dcu_drm_drv.c

Quoted 8 lines
drivers/gpu/drm/fsl/fsl_dcu_drm_drv.c new file +8 -0
+	.gem_free_object	= drm_gem_cma_free_object,
+	.gem_vm_ops		= &drm_gem_cma_vm_ops,
+	.prime_handle_to_fd	= drm_gem_prime_handle_to_fd,
+	.prime_fd_to_handle	= drm_gem_prime_fd_to_handle,
+	.gem_prime_import	= drm_gem_prime_import,
+	.gem_prime_export	= drm_gem_prime_export,
+	.gem_prime_get_sg_table	= drm_gem_cma_prime_get_sg_table,
+	.gem_prime_import_sg_table =

drm_gem_cma_prime_import_sg_table,

Quoted 37 lines
Quoted 37 lines
Quoted 37 lines
drivers/gpu/drm/fsl/fsl_dcu_drm_drv.c new file +37 -0
+	.gem_prime_vmap		= drm_gem_cma_prime_vmap,
+	.gem_prime_vunmap	= drm_gem_cma_prime_vunmap,
+	.gem_prime_mmap		= drm_gem_cma_prime_mmap,
+	.dumb_create		= drm_gem_cma_dumb_create,
+	.dumb_map_offset	= drm_gem_cma_dumb_map_offset,
+	.dumb_destroy		= drm_gem_dumb_destroy,
+	.fops			= &fsl_dcu_drm_fops,
+	.name			= "fsl-dcu-drm",
+	.desc			= "Freescale DCU DRM",
+	.date			= "20150213",
+	.major			= 1,
+	.minor			= 0,
+};
+
+#ifdef CONFIG_PM_SLEEP
+static int fsl_dcu_drm_pm_suspend(struct device *dev) {
+	struct fsl_dcu_drm_device *fsl_dev = dev_get_drvdata(dev);
+
+	drm_kms_helper_poll_disable(fsl_dev->ddev);
+	fsl_dcu_drm_crtc_suspend(&fsl_dev->crtc);
+
+	return 0;
+}
+
+static int fsl_dcu_drm_pm_resume(struct device *dev) {
+	struct fsl_dcu_drm_device *fsl_dev = dev_get_drvdata(dev);
+
+	drm_modeset_lock_all(fsl_dev->ddev);
+	fsl_dcu_drm_crtc_resume(&fsl_dev->crtc);
+	drm_modeset_unlock_all(fsl_dev->ddev);
+
+	drm_kms_helper_poll_enable(fsl_dev->ddev);
+	return 0;
+}
+#endif
+
+static const struct dev_pm_ops fsl_dcu_drm_pm_ops = {
Quoted 8 lines
Quoted 8 lines

drivers/gpu/drm/fsl/fsl_dcu_drm_drv.c line 290

Quoted 8 lines
drivers/gpu/drm/fsl/fsl_dcu_drm_drv.c new file +8 -0
+	SET_SYSTEM_SLEEP_PM_OPS(fsl_dcu_drm_pm_suspend,
+fsl_dcu_drm_pm_resume) };
+
+static int fsl_dcu_drm_probe(struct platform_device *pdev) {
+	return drm_platform_init(&fsl_dcu_drm_driver, pdev); }
+
+static int fsl_dcu_drm_remove(struct platform_device *pdev) {
+	struct fsl_dcu_drm_device *fsl_dev =

platform_get_drvdata(pdev);

Quoted 35 lines
Quoted 35 lines
Quoted 35 lines
drivers/gpu/drm/fsl/fsl_dcu_drm_drv.c new file +28 -0
+
+	drm_put_dev(fsl_dev->ddev);
+
+	return 0;
+}
+
+static struct of_device_id fsl_dcu_of_match[] = {
+		{ .compatible = "fsl,ls1021a-dcfb", },
+		{ },
+};
+MODULE_DEVICE_TABLE(of, fsl_dcu_of_match);
+
+static struct platform_driver fsl_dcu_drm_platform_driver = {
+	.probe		= fsl_dcu_drm_probe,
+	.remove		= fsl_dcu_drm_remove,
+	.driver		= {
+		.owner	= THIS_MODULE,
+		.name	= "fsl,ls1021a-dcfb",
+		.pm	= &fsl_dcu_drm_pm_ops,
+		.of_match_table = fsl_dcu_of_match,
+	},
+};
+
+module_platform_driver(fsl_dcu_drm_platform_driver);
+
+MODULE_ALIAS("platform:fsl-dcu-drm");
+MODULE_DESCRIPTION("Freescale DCU DRM Driver");
+MODULE_LICENSE("GPL");
drivers/gpu/drm/fsl/fsl_dcu_drm_drv.h new file +0 -0
new file mode 100644
index 0000000..8dc7c10
@@ -0,0 +1,167 @@
Quoted 8 lines
Quoted 8 lines

drivers/gpu/drm/fsl/fsl_dcu_drm_drv.h line 8

Quoted 8 lines
drivers/gpu/drm/fsl/fsl_dcu_drm_drv.h new file +8 -0
+/*
+ * 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

Quoted 2 lines
Quoted 2 lines

drivers/gpu/drm/fsl/fsl_dcu_drm_drv.h line 10

Quoted 2 lines
drivers/gpu/drm/fsl/fsl_dcu_drm_drv.h new file +2 -0
+by
+ * the Free Software Foundation; either version 2 of the License,

or

Quoted 169 lines
Quoted 169 lines
Quoted 169 lines
drivers/gpu/drm/fsl/fsl_dcu_drm_drv.h new file +158 -0
+ * (at your option) any later version.
+ */
+
+#ifndef __FSL_DCU_DRM_DRV_H__
+#define __FSL_DCU_DRM_DRV_H__
+
+#include <linux/kernel.h>
+#include <linux/spinlock.h>
+#include <stddef.h>
+#include <drm/drm.h>
+#include <drm/drmP.h>
+#include <drm/drm_fb_helper.h>
+#include <drm/drm_crtc_helper.h>
+#include <drm/drm_gem_cma_helper.h>
+#include <drm/drm_fb_cma_helper.h>
+
+#include "fsl_dcu_drm_crtc.h"
+#define DRIVER_NAME			"fsl-dcu-fb"
+
+#define DCU_DCU_MODE			0x0010
+#define DCU_MODE_BLEND_ITER(x)		((x) << 20)
+#define DCU_MODE_RASTER_EN		BIT(14)
+#define DCU_MODE_DCU_MODE(x)		(x)
+#define DCU_MODE_DCU_MODE_MASK		0x03
+#define DCU_MODE_OFF			0
+#define DCU_MODE_NORMAL			1
+#define DCU_MODE_TEST			2
+#define DCU_MODE_COLORBAR		3
+
+#define DCU_BGND			0x0014
+#define DCU_BGND_R(x)			((x) << 16)
+#define DCU_BGND_G(x)			((x) << 8)
+#define DCU_BGND_B(x)			(x)
+
+#define DCU_DISP_SIZE			0x0018
+#define DCU_DISP_SIZE_DELTA_Y(x)	((x) << 16)
+/*Regisiter value 1/16 of horizontal resolution*/
+#define DCU_DISP_SIZE_DELTA_X(x)	((x) >> 4)
+
+#define DCU_HSYN_PARA			0x001c
+#define DCU_HSYN_PARA_BP(x)		((x) << 22)
+#define DCU_HSYN_PARA_PW(x)		((x) << 11)
+#define DCU_HSYN_PARA_FP(x)		(x)
+
+#define DCU_VSYN_PARA			0x0020
+#define DCU_VSYN_PARA_BP(x)		((x) << 22)
+#define DCU_VSYN_PARA_PW(x)		((x) << 11)
+#define DCU_VSYN_PARA_FP(x)		(x)
+
+#define DCU_SYN_POL			0x0024
+#define DCU_SYN_POL_INV_PXCK_FALL	(0 << 6)
+#define DCU_SYN_POL_NEG_REMAIN		(0 << 5)
+#define DCU_SYN_POL_INV_VS_LOW		BIT(1)
+#define DCU_SYN_POL_INV_HS_LOW		(1)
+
+#define DCU_THRESHOLD			0x0028
+#define DCU_THRESHOLD_LS_BF_VS(x)	((x) << 16)
+#define DCU_THRESHOLD_OUT_BUF_HIGH(x)	((x) << 8)
+#define DCU_THRESHOLD_OUT_BUF_LOW(x)	(x)
+#define BF_VS_VAL			0x03
+#define BUF_MAX_VAL			0x78
+#define BUF_MIN_VAL			0x0a
+
+#define DCU_INT_STATUS			0x002C
+#define DCU_INT_STATUS_UNDRUN		BIT(1)
+
+#define DCU_INT_MASK			0x0030
+#define DCU_INT_MASK_UNDRUN		BIT(1)
+#define DCU_INT_MASK_VBLANK		BIT(3)
+
+#define DCU_DIV_RATIO			0x0054
+
+#define DCU_UPDATE_MODE			0x00cc
+#define DCU_UPDATE_MODE_MODE		BIT(31)
+#define DCU_UPDATE_MODE_READREG		BIT(30)
+
+#define DCU_DCFB_MAX			0x300
+
+#define DCU_CTRLDESCLN_1(x)		(0x200 + (x) * 0x40)
+#define DCU_CTRLDESCLN_1_HEIGHT(x)	((x) << 16)
+#define DCU_CTRLDESCLN_1_WIDTH(x)	(x)
+
+#define DCU_CTRLDESCLN_2(x)		(0x204 + (x) * 0x40)
+#define DCU_CTRLDESCLN_2_POSY(x)	((x) << 16)
+#define DCU_CTRLDESCLN_2_POSX(x)	(x)
+
+#define DCU_CTRLDESCLN_3(x)		(0x208 + (x) * 0x40)
+
+#define DCU_CTRLDESCLN_4(x)		(0x20c + (x) * 0x40)
+#define DCU_CTRLDESCLN_4_EN		BIT(31)
+#define DCU_CTRLDESCLN_4_TILE_EN	BIT(30)
+#define DCU_CTRLDESCLN_4_DATA_SEL_CLUT	BIT(29)
+#define DCU_CTRLDESCLN_4_SAFETY_EN	BIT(28)
+#define DCU_CTRLDESCLN_4_TRANS(x)	((x) << 20)
+#define DCU_CTRLDESCLN_4_BPP(x)		((x) << 16)
+#define DCU_CTRLDESCLN_4_RLE_EN		BIT(15)
+#define DCU_CTRLDESCLN_4_LUOFFS(x)	((x) << 4)
+#define DCU_CTRLDESCLN_4_BB_ON		BIT(2)
+#define DCU_CTRLDESCLN_4_AB(x)		(x)
+
+#define DCU_CTRLDESCLN_5(x)		(0x210 + (x) * 0x40)
+#define DCU_CTRLDESCLN_5_CKMAX_R(x)	((x) << 16)
+#define DCU_CTRLDESCLN_5_CKMAX_G(x)	((x) << 8)
+#define DCU_CTRLDESCLN_5_CKMAX_B(x)	(x)
+
+#define DCU_CTRLDESCLN_6(x)		(0x214 + (x) * 0x40)
+#define DCU_CTRLDESCLN_6_CKMIN_R(x)	((x) << 16)
+#define DCU_CTRLDESCLN_6_CKMIN_G(x)	((x) << 8)
+#define DCU_CTRLDESCLN_6_CKMIN_B(x)	(x)
+
+#define DCU_CTRLDESCLN_7(x)		(0x218 + (x) * 0x40)
+#define DCU_CTRLDESCLN_7_TILE_VER(x)	((x) << 16)
+#define DCU_CTRLDESCLN_7_TILE_HOR(x)	(x)
+
+#define DCU_CTRLDESCLN_8(x)		(0x21c + (x) * 0x40)
+#define DCU_CTRLDESCLN_8_FG_FCOLOR(x)	(x)
+
+#define DCU_CTRLDESCLN_9(x)		(0x220 + (x) * 0x40)
+#define DCU_CTRLDESCLN_9_BG_BCOLOR(x)	(x)
+
+#define DCU_CTRLDESCLN_10(x)		(0x224 + (x) * 0x40)
+#define DCU_CTRLDESCLN_10_POST_SKIP(x)	((x) << 16)
+#define DCU_CTRLDESCLN_10_PRE_SKIP(x)	(x)
+
+#define FSL_DCU_RGB565			4
+#define FSL_DCU_RGB888			5
+#define FSL_DCU_ARGB8888		6
+#define FSL_DCU_ARGB1555		11
+#define FSL_DCU_ARGB4444		12
+#define FSL_DCU_YUV422			14
+
+#define TCON_CTRL1			0x0000
+#define TCON_BYPASS_ENABLE		BIT(29)
+
+#define DBG(fmt, ...) DRM_DEBUG(fmt"\n", ##__VA_ARGS__)
+
+struct clk;
+struct device;
+struct drm_device;
+
+struct fsl_dcu_drm_device {
+	struct device *dev;
+	struct regmap *regmap;
+	struct regmap *tcon_regmap;
+	struct regmap *scfg_regmap;
+	unsigned int irq;
+	struct clk *clk;
+	/*protects hardware register*/
+	spinlock_t irq_lock;
+	struct drm_device *ddev;
+	struct drm_fbdev_cma *fbdev;
+	struct fsl_dcu_drm_crtc crtc;
+	struct fsl_dcu_drm_encoder encoder;
+	struct fsl_dcu_drm_connector connector; };
+
+void fsl_dcu_fbdev_init(struct drm_device *dev);
+
+#endif /* __FSL_DCU_DRM_DRV_H__ */
drivers/gpu/drm/fsl/fsl_dcu_drm_fbdev.c new file +4 -0
new file mode 100644
index 0000000..6729f92
@@ -0,0 +1,43 @@
+/*
+ * Copyright 2015 Freescale Semiconductor, Inc.
+ *
+ * This program is free software; you can redistribute it and/or
Quoted 8 lines
Quoted 8 lines

drivers/gpu/drm/fsl/fsl_dcu_drm_fbdev.c line 12

Quoted 8 lines
drivers/gpu/drm/fsl/fsl_dcu_drm_fbdev.c new file +8 -0
+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

Quoted 42 lines
Quoted 24 lines
Quoted 24 lines
drivers/gpu/drm/fsl/fsl_dcu_drm_fbdev.c new file +24 -0
+or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public
+License for
+ * more details.
+ *
+ */
+
+#include <drm/drmP.h>
+#include <drm/drm_crtc.h>
+#include <drm/drm_fb_helper.h>
+#include <drm/drm_crtc_helper.h>
+#include <drm/drm_fb_cma_helper.h>
+#include <drm/drm_gem_cma_helper.h>
+#include <linux/clk.h>
+#include <linux/delay.h>
+#include <linux/dma-mapping.h>
+#include <linux/fb.h>
+#include <linux/interrupt.h>
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/of_platform.h>
+#include <linux/regmap.h>
+#include <video/of_display_timing.h>
+#include <video/videomode.h>
Quoted 8 lines

drivers/gpu/drm/fsl/fsl_dcu_drm_fbdev.c

Quoted 8 lines
drivers/gpu/drm/fsl/fsl_dcu_drm_fbdev.c new file +8 -0
+#include <linux/uaccess.h>
+
+#include "fsl_dcu_drm_drv.h"
+#include "fsl_dcu_drm_crtc.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);

Quoted 9 lines
Quoted 9 lines
drivers/gpu/drm/fsl/fsl_dcu_drm_fbdev.c new file +2 -0
+
+	fsl_dev->fbdev = drm_fbdev_cma_init(dev, 24, 1, 1); }
drivers/gpu/drm/fsl/fsl_dcu_drm_kms.c new file +0 -0
new file mode 100644
index 0000000..0eb0652
@@ -0,0 +1,45 @@
Quoted 8 lines
Quoted 8 lines

drivers/gpu/drm/fsl/fsl_dcu_drm_kms.c line 8

Quoted 8 lines
drivers/gpu/drm/fsl/fsl_dcu_drm_kms.c new file +8 -0
+/*
+ * 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

Quoted 2 lines
Quoted 2 lines

drivers/gpu/drm/fsl/fsl_dcu_drm_kms.c line 10

Quoted 2 lines
drivers/gpu/drm/fsl/fsl_dcu_drm_kms.c new file +2 -0
+by
+ * the Free Software Foundation; either version 2 of the License,

or

Quoted 15 lines
Quoted 15 lines
Quoted 4 lines
drivers/gpu/drm/fsl/fsl_dcu_drm_kms.c new file +4 -0
+ * (at your option) any later version.
+ */
+
+#include <drm/drmP.h>

drivers/gpu/drm/fsl/fsl_dcu_drm_kms.c line 24

Quoted 10 lines
drivers/gpu/drm/fsl/fsl_dcu_drm_kms.c new file +10 -0
+#include <drm/drm_crtc.h>
+#include <drm/drm_crtc_helper.h>
+#include <drm/drm_fb_cma_helper.h>
+#include <drm/drm_gem_cma_helper.h>
+
+#include "fsl_dcu_drm_crtc.h"
+#include "fsl_dcu_drm_drv.h"
+#include "fsl_dcu_drm_kms.h"
+
+static const struct drm_mode_config_funcs

fsl_dcu_drm_mode_config_funcs = {

Quoted 11 lines
Quoted 11 lines

drivers/gpu/drm/fsl/fsl_dcu_drm_kms.c

Quoted 11 lines
drivers/gpu/drm/fsl/fsl_dcu_drm_kms.c new file +11 -0
+	.fb_create = drm_fb_cma_create,
+};
+
+int fsl_dcu_drm_modeset_init(struct fsl_dcu_drm_device *fsl_dev) {
+	drm_mode_config_init(fsl_dev->ddev);
+
+	fsl_dev->ddev->mode_config.min_width = 0;
+	fsl_dev->ddev->mode_config.min_height = 0;
+	fsl_dev->ddev->mode_config.max_width = 2031;
+	fsl_dev->ddev->mode_config.max_height = 2047;
+	fsl_dev->ddev->mode_config.funcs =

&fsl_dcu_drm_mode_config_funcs;

Quoted 19 lines
Quoted 4 lines

drivers/gpu/drm/fsl/fsl_dcu_drm_kms.c

Quoted 4 lines
drivers/gpu/drm/fsl/fsl_dcu_drm_kms.c new file +4 -0
+
+	fsl_dcu_drm_crtc_create(fsl_dev);
+	fsl_dcu_drm_encoder_create(fsl_dev);
+	fsl_dcu_drm_connector_create(fsl_dev, &fsl_dev-

encoder.encoder);

Quoted 14 lines
Quoted 14 lines
drivers/gpu/drm/fsl/fsl_dcu_drm_kms.c new file +7 -0
+
+	drm_kms_helper_poll_init(fsl_dev->ddev);
+
+	drm_helper_disable_unused_functions(fsl_dev->ddev);
+
+	return 0;
+}
drivers/gpu/drm/fsl/fsl_dcu_drm_kms.h new file +0 -0
new file mode 100644
index 0000000..9d5b798
@@ -0,0 +1,22 @@
Quoted 8 lines
Quoted 8 lines

drivers/gpu/drm/fsl/fsl_dcu_drm_kms.h line 8

Quoted 8 lines
drivers/gpu/drm/fsl/fsl_dcu_drm_kms.h new file +8 -0
+/*
+ * 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

Quoted 2 lines
Quoted 2 lines

drivers/gpu/drm/fsl/fsl_dcu_drm_kms.h line 10

Quoted 2 lines
drivers/gpu/drm/fsl/fsl_dcu_drm_kms.h new file +2 -0
+by
+ * the Free Software Foundation; either version 2 of the License,

or

Quoted 21 lines
Quoted 21 lines
Quoted 21 lines
drivers/gpu/drm/fsl/fsl_dcu_drm_kms.h new file +14 -0
+ * (at your option) any later version.
+ */
+
+#ifndef __FSL_DCU_DRM_KMS_H__
+#define __FSL_DCU_DRM_KMS_H__
+
+#include <linux/types.h>
+
+struct drm_gem_cma_object;
+struct fsl_dcu_drm_device;
+
+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 +0 -0
new file mode 100644
index 0000000..d725594
@@ -0,0 +1,124 @@
Quoted 8 lines
Quoted 8 lines

drivers/gpu/drm/fsl/fsl_dcu_drm_plane.c line 8

Quoted 8 lines
drivers/gpu/drm/fsl/fsl_dcu_drm_plane.c new file +8 -0
+/*
+ * 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

Quoted 2 lines
Quoted 2 lines

drivers/gpu/drm/fsl/fsl_dcu_drm_plane.c line 10

Quoted 2 lines
drivers/gpu/drm/fsl/fsl_dcu_drm_plane.c new file +2 -0
+by
+ * the Free Software Foundation; either version 2 of the License,

or

Quoted 47 lines
Quoted 47 lines
Quoted 47 lines
drivers/gpu/drm/fsl/fsl_dcu_drm_plane.c new file +47 -0
+ * (at your option) any later version.
+ */
+
+#include <drm/drmP.h>
+#include <drm/drm_crtc.h>
+#include <drm/drm_crtc_helper.h>
+#include <drm/drm_fb_cma_helper.h>
+#include <drm/drm_gem_cma_helper.h>
+#include <linux/regmap.h>
+
+#include "fsl_dcu_drm_drv.h"
+#include "fsl_dcu_drm_kms.h"
+#include "fsl_dcu_drm_plane.h"
+
+static void __fsl_dcu_drm_plane_setup(struct drm_plane *plane,
+				      struct drm_framebuffer *fb) {
+	struct fsl_dcu_drm_device *fsl_dev = plane->dev->dev_private;
+	u32 plane_num = 0, alpha, bpp;
+	struct drm_gem_cma_object *gem;
+
+	while (plane->possible_crtcs >> 1)
+		plane_num++;
+
+	gem = drm_fb_cma_get_gem_obj(fb, 0);
+
+	switch (fb->pixel_format) {
+	case DRM_FORMAT_RGB565:
+		bpp = FSL_DCU_RGB565;
+		alpha = 0xff;
+		break;
+	case DRM_FORMAT_RGB888:
+		bpp = FSL_DCU_RGB888;
+		alpha = 0xff;
+		break;
+	case DRM_FORMAT_ARGB8888:
+		bpp = FSL_DCU_ARGB8888;
+		alpha = 0xff;
+		break;
+	case DRM_FORMAT_BGRA4444:
+		bpp = FSL_DCU_ARGB4444;
+		alpha = 0xff;
+		break;
+	case DRM_FORMAT_ARGB1555:
+		bpp = FSL_DCU_ARGB1555;
+		alpha = 0xff;
+		break;
+	case DRM_FORMAT_YUV422:
Quoted 8 lines
Quoted 8 lines

drivers/gpu/drm/fsl/fsl_dcu_drm_plane.c

Quoted 8 lines
drivers/gpu/drm/fsl/fsl_dcu_drm_plane.c new file +8 -0
+		bpp = FSL_DCU_YUV422;
+		alpha = 0xff;
+		break;
+	default:
+		return;
+	}
+
+	regmap_write(fsl_dev->regmap, DCU_CTRLDESCLN_3(plane_num),

gem-

Quoted 23 lines
Quoted 23 lines
Quoted 23 lines

paddr);

drivers/gpu/drm/fsl/fsl_dcu_drm_plane.c new file +22 -0
+	regmap_write(fsl_dev->regmap, DCU_CTRLDESCLN_4(plane_num),
+		     DCU_CTRLDESCLN_4_EN |
+		     DCU_CTRLDESCLN_4_TRANS(alpha) |
+		     DCU_CTRLDESCLN_4_BPP(bpp) |
+		     DCU_CTRLDESCLN_4_AB(2));
+	regmap_write(fsl_dev->regmap, DCU_CTRLDESCLN_5(plane_num),
+		     DCU_CTRLDESCLN_5_CKMAX_R(0xFF) |
+		     DCU_CTRLDESCLN_5_CKMAX_G(0xFF) |
+		     DCU_CTRLDESCLN_5_CKMAX_B(0xFF));
+	regmap_write(fsl_dev->regmap, DCU_CTRLDESCLN_6(plane_num),
+		     DCU_CTRLDESCLN_6_CKMIN_R(0) |
+		     DCU_CTRLDESCLN_6_CKMIN_G(0) |
+		     DCU_CTRLDESCLN_6_CKMIN_B(0));
+	regmap_write(fsl_dev->regmap, DCU_CTRLDESCLN_8(plane_num),
+		     DCU_CTRLDESCLN_8_FG_FCOLOR(0));
+	regmap_write(fsl_dev->regmap, DCU_CTRLDESCLN_9(plane_num),
+		     DCU_CTRLDESCLN_9_BG_BCOLOR(0));
+	regmap_write(fsl_dev->regmap, DCU_CTRLDESCLN_10(plane_num),
+		     DCU_CTRLDESCLN_10_POST_SKIP(0) |
+		     DCU_CTRLDESCLN_10_PRE_SKIP(0));
+	regmap_write(fsl_dev->regmap, DCU_UPDATE_MODE,
+DCU_UPDATE_MODE_READREG); }
Quoted 8 lines
Quoted 8 lines

drivers/gpu/drm/fsl/fsl_dcu_drm_plane.c

Quoted 8 lines
drivers/gpu/drm/fsl/fsl_dcu_drm_plane.c new file +8 -0
+
+void fsl_dcu_drm_plane_setup(struct drm_plane *plane) {
+	if (!plane->fb)
+		return;
+
+	__fsl_dcu_drm_plane_setup(plane, plane->fb); }
+
+int fsl_dcu_drm_plane_update(struct drm_plane *plane, struct

drm_crtc

Quoted 2 lines
Quoted 2 lines

*crtc,

drivers/gpu/drm/fsl/fsl_dcu_drm_plane.c

Quoted 1 line
drivers/gpu/drm/fsl/fsl_dcu_drm_plane.c new file +1 -0
+			     struct drm_framebuffer *fb, int crtc_x, int

crtc_y,

Quoted 31 lines
Quoted 31 lines
Quoted 31 lines
drivers/gpu/drm/fsl/fsl_dcu_drm_plane.c new file +24 -0
+			    unsigned int crtc_w, unsigned int crtc_h,
+			    uint32_t src_x, uint32_t src_y,
+			    uint32_t src_w, uint32_t src_h) {
+	__fsl_dcu_drm_plane_setup(plane, fb);
+	return 0;
+}
+
+int fsl_dcu_drm_plane_disable(struct drm_plane *plane) {
+	return 0;
+}
+
+void fsl_dcu_drm_plane_destroy(struct drm_plane *plane) {
+	fsl_dcu_drm_plane_disable(plane);
+	drm_plane_cleanup(plane);
+}
+
+static const uint32_t formats[] = {
+	DRM_FORMAT_RGB565,
+	DRM_FORMAT_RGB888,
+	DRM_FORMAT_ARGB8888,
+	DRM_FORMAT_ARGB4444,
+	DRM_FORMAT_ARGB1555,
+	DRM_FORMAT_YUV422,
+};
drivers/gpu/drm/fsl/fsl_dcu_drm_plane.h new file +0 -0
new file mode 100644
index 0000000..da88d1c
@@ -0,0 +1,28 @@
Quoted 8 lines
Quoted 8 lines

drivers/gpu/drm/fsl/fsl_dcu_drm_plane.h line 8

Quoted 8 lines
drivers/gpu/drm/fsl/fsl_dcu_drm_plane.h new file +8 -0
+/*
+ * 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

Quoted 2 lines
Quoted 2 lines

drivers/gpu/drm/fsl/fsl_dcu_drm_plane.h line 10

Quoted 2 lines
drivers/gpu/drm/fsl/fsl_dcu_drm_plane.h new file +2 -0
+by
+ * the Free Software Foundation; either version 2 of the License,

or

Quoted 23 lines
Quoted 23 lines
Quoted 23 lines
drivers/gpu/drm/fsl/fsl_dcu_drm_plane.h new file +20 -1
+ * (at your option) any later version.
+ */
+
+#ifndef __FSL_DCU_DRM_PLANE_H__
+#define __FSL_DCU_DRM_PLANE_H__
+
+struct fsl_dcu_drm_device;
+
+void fsl_dcu_drm_plane_setup(struct drm_plane *plane); int
+fsl_dcu_drm_plane_update(struct drm_plane *plane,
+			     struct drm_crtc *crtc,
+			     struct drm_framebuffer *fb,
+			     int crtc_x, int crtc_y,
+			     unsigned int crtc_w, unsigned int crtc_h,
+			     uint32_t src_x, uint32_t src_y,
+			     uint32_t src_w, uint32_t src_h); int
+fsl_dcu_drm_plane_disable(struct drm_plane *plane); void
+fsl_dcu_drm_plane_destroy(struct drm_plane *plane);
+
+#endif /* __FSL_DCU_DRM_PLANE_H__ */
--

2.1.0.27.g96db324

Quoted 9 lines
Quoted 9 lines
Quoted 4 lines

_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel

--
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch

--
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch

#9 lore raw
In reply to Jianwei Wang
Quoted 9 lines · Jianwei Wang

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

2D-ACE is a Freescale display controller. It supports at most four plane and provide an hardware cursor.

This is a simplified version, only a primary plane, a fb created for fbdev, a crtc, a connector for TFT LCD panel, an encoder, and the encoder is not in use. Now this drver support fbdev only.

Hi,

Do you know if that driver also works on Vybrid devices? Vybrid has also DCU4 module with 2D-ACE functionality, also the registers look pretty similar. I was thinking about creating a driver for Vybrid anyway...

Some remarks below...

Quoted 40 lines
---
 .../devicetree/bindings/video/fsl,dcfb.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_crtc.c             | 412 +++++++++++++++++++++
 drivers/gpu/drm/fsl/fsl_dcu_drm_crtc.h             |  40 ++
 drivers/gpu/drm/fsl/fsl_dcu_drm_drv.c              | 323 ++++++++++++++++
 drivers/gpu/drm/fsl/fsl_dcu_drm_drv.h              | 167 +++++++++
 drivers/gpu/drm/fsl/fsl_dcu_drm_fbdev.c            |  43 +++
 drivers/gpu/drm/fsl/fsl_dcu_drm_kms.c              |  45 +++
 drivers/gpu/drm/fsl/fsl_dcu_drm_kms.h              |  22 ++
 drivers/gpu/drm/fsl/fsl_dcu_drm_plane.c            | 124 +++++++
 drivers/gpu/drm/fsl/fsl_dcu_drm_plane.h            |  28 ++
 14 files changed, 1281 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/video/fsl,dcfb.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_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/video/fsl,dcfb.txt new file +0 -0
new file mode 100644
index 0000000..de7da97

Documentation/devicetree/bindings/video/fsl,dcfb.txt line 1

Quoted 1 line
Documentation/devicetree/bindings/video/fsl,dcfb.txt new file +1 -0
@@ -0,0 +1,50 @@
+* Freescale Simple Display Controller FB Driver

"FB Driver" probably refers more to a fbdev driver in the Linux kernel sense, but since this is a DRM driver this is somewhat confusing. The binding should describe the hardware, in the Vybrid RM mentions the IP as "Display Control Unit (DCU4)", so maybe

Freescale Display Controller Unit (DCU4) module

Also, instead of using dcfb, I would use somewhat more hardware describing, e.g. dcu4?

Documentation/devicetree/bindings/video/fsl,dcfb.txt line 4

Quoted 3 lines
Documentation/devicetree/bindings/video/fsl,dcfb.txt new file +3 -0
+
+Required properties:
+- compatible:		Should be one of "fsl,ls1021a-dcfb".

If the driver also works for Vybrid, be favorable to have a generic compatible string, e.g. fsl,dcu4?

Quoted 686 lines
Documentation/devicetree/bindings/video/fsl,dcfb.txt new file +46 -0
+- reg:			Address and length of the register set for dcfb.
+- clocks:		From common clock binding: handle to dcfb clock.
+- clock-names:		From common clock binding: Shall be "dcfb".
+- display:		The phandle to display node.
+
+Optional properties:
+- scfg-controller:	The phandle of scfg 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:
+dcfb: dcfb@2ce0000 {
+	compatible = "fsl,ls1021a-dcfb";
+	reg = <0x0 0x2ce0000 0x0 0x10000>;
+	clocks = <&platform_clk 0>;
+	clock-names = "dcfb";
+	scfg-controller = <&scfg>;
+	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 151a050..a6957aa 100644
@@ -199,6 +199,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 2c239b9..ab5b9ef 100644
@@ -56,6 +56,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..51c3e1f
@@ -0,0 +1,7 @@
+fsl-dcu-drm-y := fsl_dcu_drm_drv.o \
+	       fsl_dcu_drm_kms.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_crtc.c new file +412 -0
new file mode 100644
index 0000000..9f5ba86
@@ -0,0 +1,412 @@
+/*
+ * 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.
+ */
+
+#include <linux/backlight.h>
+#include <linux/clk.h>
+#include <linux/regmap.h>
+
+#include <drm/drmP.h>
+#include <drm/drm_atomic_helper.h>
+#include <drm/drm_crtc.h>
+#include <drm/drm_crtc_helper.h>
+#include <drm/drm_fb_cma_helper.h>
+#include <drm/drm_gem_cma_helper.h>
+#include <drm/drm_plane_helper.h>
+#include <video/of_display_timing.h>
+
+#include "fsl_dcu_drm_crtc.h"
+#include "fsl_dcu_drm_drv.h"
+#include "fsl_dcu_drm_kms.h"
+#include "fsl_dcu_drm_plane.h"
+
+#define to_fsl_dcu_crtc(c)	container_of(c, struct fsl_dcu_drm_crtc, crtc)
+
+static void fsl_dcu_drm_crtc_start(struct drm_crtc *crtc)
+{
+	fsl_dcu_drm_plane_setup(crtc->primary);
+}
+
+static void fsl_dcu_drm_crtc_stop(struct drm_crtc *crtc)
+{
+}
+
+void fsl_dcu_drm_crtc_suspend(struct drm_crtc *crtc)
+{
+	fsl_dcu_drm_crtc_stop(crtc);
+}
+
+void fsl_dcu_drm_crtc_resume(struct drm_crtc *crtc)
+{
+	struct fsl_dcu_drm_crtc *fsl_crtc = to_fsl_dcu_crtc(crtc);
+
+	if (fsl_crtc->dpms != DRM_MODE_DPMS_ON)
+		return;
+
+	fsl_dcu_drm_crtc_start(crtc);
+}
+
+static void fsl_dcu_drm_crtc_update_base(struct drm_crtc *crtc)
+{
+}
+
+static void fsl_dcu_drm_crtc_dpms(struct drm_crtc *crtc, int mode)
+{
+	struct fsl_dcu_drm_crtc *fsl_crtc = to_fsl_dcu_crtc(crtc);
+
+	if (fsl_crtc->dpms == mode)
+		return;
+
+	if (mode == DRM_MODE_DPMS_ON)
+		fsl_dcu_drm_crtc_start(crtc);
+	else
+		fsl_dcu_drm_crtc_stop(crtc);
+
+	fsl_crtc->dpms = mode;
+}
+
+static bool fsl_dcu_drm_crtc_mode_fixup(struct drm_crtc *crtc,
+					const struct drm_display_mode *mode,
+					struct drm_display_mode *adjusted_mode)
+{
+	return true;
+}
+
+static void fsl_dcu_drm_crtc_mode_prepare(struct drm_crtc *crtc)
+{
+		fsl_dcu_drm_crtc_stop(crtc);
+}
+
+static int fsl_dcu_drm_crtc_mode_set(struct drm_crtc *crtc,
+				     struct drm_display_mode *mode,
+				     struct drm_display_mode *adjusted_mode,
+				     int x, int y,
+				     struct drm_framebuffer *old_fb)
+{
+	struct drm_device *dev = crtc->dev;
+	struct fsl_dcu_drm_device *fsl_dev = dev->dev_private;
+	uint32_t hbp, hfp, hsw, vbp, vfp, vsw, div, index;
+
+	DBG(": set mode: %d:\"%s\" %d %d %d %d %d %d %d %d %d %d 0x%x 0x%x",
+	    mode->base.id, mode->name,
+	    mode->vrefresh, mode->clock,
+	    mode->hdisplay, mode->hsync_start,
+	    mode->hsync_end, mode->htotal,
+	    mode->vdisplay, mode->vsync_start,
+	    mode->vsync_end, mode->vtotal,
+	    mode->type, mode->flags);
+
+	index = drm_crtc_index(crtc);
+	div = (uint32_t)clk_get_rate(fsl_dev->clk) / crtc->mode.clock / 1000;
+
+	/* Configure timings: */
+	hbp = mode->htotal - mode->hsync_end;
+	hfp = mode->hsync_start - mode->hdisplay;
+	hsw = mode->hsync_end - mode->hsync_start;
+	vbp = mode->vtotal - mode->vsync_end;
+	vfp = mode->vsync_start - mode->vdisplay;
+	vsw = mode->vsync_end - mode->vsync_start;
+
+	regmap_write(fsl_dev->regmap, DCU_HSYN_PARA,
+		     DCU_HSYN_PARA_BP(hbp) |
+		     DCU_HSYN_PARA_PW(hsw) |
+		     DCU_HSYN_PARA_FP(hfp));
+	regmap_write(fsl_dev->regmap, DCU_VSYN_PARA,
+		     DCU_VSYN_PARA_BP(vbp) |
+		     DCU_VSYN_PARA_PW(vsw) |
+		     DCU_VSYN_PARA_FP(vfp));
+	regmap_write(fsl_dev->regmap, DCU_DISP_SIZE,
+		     DCU_DISP_SIZE_DELTA_Y(mode->vdisplay) |
+		     DCU_DISP_SIZE_DELTA_X(mode->hdisplay));
+	regmap_write(fsl_dev->regmap, DCU_CTRLDESCLN_1(index),
+		     DCU_CTRLDESCLN_1_HEIGHT(mode->vdisplay) |
+		     DCU_CTRLDESCLN_1_WIDTH(mode->hdisplay));
+	regmap_write(fsl_dev->regmap, DCU_CTRLDESCLN_2(index),
+		     DCU_CTRLDESCLN_2_POSY(y) |
+		     DCU_CTRLDESCLN_2_POSX(x));
+	regmap_write(fsl_dev->regmap, DCU_DIV_RATIO, div);
+	regmap_write(fsl_dev->regmap, DCU_UPDATE_MODE, DCU_UPDATE_MODE_READREG);
+
+	return 0;
+}
+
+static void fsl_dcu_drm_crtc_mode_commit(struct drm_crtc *crtc)
+{
+		fsl_dcu_drm_crtc_start(crtc);
+}
+
+static int fsl_dcu_drm_crtc_mode_set_base(struct drm_crtc *crtc, int x, int y,
+					  struct drm_framebuffer *old_fb)
+{
+	fsl_dcu_drm_crtc_update_base(crtc);
+
+	return 0;
+}
+
+static const struct drm_crtc_helper_funcs crtc_helper_funcs = {
+	.dpms = fsl_dcu_drm_crtc_dpms,
+	.mode_fixup = fsl_dcu_drm_crtc_mode_fixup,
+	.prepare = fsl_dcu_drm_crtc_mode_prepare,
+	.commit = fsl_dcu_drm_crtc_mode_commit,
+	.mode_set = fsl_dcu_drm_crtc_mode_set,
+	.mode_set_base = fsl_dcu_drm_crtc_mode_set_base,
+};
+
+static int fsl_dcu_drm_crtc_page_flip(struct drm_crtc *crtc,
+				      struct drm_framebuffer *fb,
+				      struct drm_pending_vblank_event *event,
+				      uint32_t page_flip_flags)
+{
+	return 0;
+}
+
+static const struct drm_plane_funcs fsl_dcu_drm_plane_funcs = {
+	.update_plane = fsl_dcu_drm_plane_update,
+	.disable_plane = fsl_dcu_drm_plane_disable,
+	.destroy = fsl_dcu_drm_plane_destroy,
+};
+
+static const struct drm_crtc_funcs crtc_funcs = {
+	.destroy = drm_crtc_cleanup,
+	.set_config = drm_crtc_helper_set_config,
+	.page_flip = fsl_dcu_drm_crtc_page_flip,
+};
+
+int fsl_dcu_drm_crtc_create(struct fsl_dcu_drm_device *fsl_dev)
+{
+	struct drm_crtc *crtc = &fsl_dev->crtc.crtc;
+	int ret;
+
+	fsl_dev->crtc.dpms = DRM_MODE_DPMS_OFF;
+
+	ret = drm_crtc_init(fsl_dev->ddev, crtc, &crtc_funcs);
+	if (ret < 0)
+		return ret;
+
+	crtc->primary->funcs = &fsl_dcu_drm_plane_funcs;
+
+	drm_crtc_helper_add(crtc, &crtc_helper_funcs);
+
+	regmap_write(fsl_dev->regmap, DCU_SYN_POL,
+		     DCU_SYN_POL_INV_VS_LOW | DCU_SYN_POL_INV_HS_LOW);
+	regmap_write(fsl_dev->regmap, DCU_BGND, DCU_BGND_R(0) |
+		     DCU_BGND_G(0) | DCU_BGND_B(0));
+	regmap_write(fsl_dev->regmap, DCU_DCU_MODE,
+		     DCU_MODE_BLEND_ITER(1) | DCU_MODE_RASTER_EN);
+	regmap_write(fsl_dev->regmap, DCU_THRESHOLD,
+		     DCU_THRESHOLD_LS_BF_VS(BF_VS_VAL) |
+		     DCU_THRESHOLD_OUT_BUF_HIGH(BUF_MAX_VAL) |
+		     DCU_THRESHOLD_OUT_BUF_LOW(BUF_MIN_VAL));
+	regmap_update_bits(fsl_dev->regmap, DCU_DCU_MODE,
+			   DCU_MODE_DCU_MODE_MASK,
+			   DCU_MODE_DCU_MODE(DCU_MODE_NORMAL));
+	regmap_write(fsl_dev->regmap, DCU_UPDATE_MODE, DCU_UPDATE_MODE_READREG);
+	return 0;
+}
+
+/*
+ * Encoder
+ */
+
+#define to_fsl_dcu_encoder(e) \
+	container_of(e, struct fsl_dcu_drm_encoder, encoder)
+
+static void fsl_dcu_drm_encoder_dpms(struct drm_encoder *encoder, int mode)
+{
+	struct fsl_dcu_drm_encoder *fsl_enc = to_fsl_dcu_encoder(encoder);
+
+	if (fsl_enc->dpms == mode)
+		return;
+
+	fsl_enc->dpms = mode;
+}
+
+static bool fsl_dcu_drm_encoder_mode_fixup
+		(struct drm_encoder *encoder,
+		const struct drm_display_mode *mode,
+		struct drm_display_mode *adjusted_mode)
+{
+	struct drm_device *dev = encoder->dev;
+	struct fsl_dcu_drm_device *fsl_dev = dev->dev_private;
+	struct drm_connector *connector = &fsl_dev->connector.connector;
+	const struct drm_display_mode *panel_mode;
+
+	if (list_empty(&connector->modes)) {
+		dev_dbg(dev->dev, "mode_fixup: empty modes list\n");
+		return false;
+	}
+
+	/* The flat panel mode is fixed, just copy it to the adjusted mode. */
+	panel_mode = list_first_entry(&connector->modes,
+				      struct drm_display_mode, head);
+	drm_mode_copy(adjusted_mode, panel_mode);
+
+	return true;
+}
+
+static void fsl_dcu_drm_encoder_mode_prepare(struct drm_encoder *encoder)
+{
+}
+
+static void fsl_dcu_drm_encoder_mode_set(struct drm_encoder *encoder,
+					 struct drm_display_mode *mode,
+					 struct drm_display_mode *adjusted_mode)
+{
+}
+
+static void fsl_dcu_drm_encoder_mode_commit(struct drm_encoder *encoder)
+{
+	;
+}
+
+static const struct drm_encoder_helper_funcs encoder_helper_funcs = {
+	.dpms = fsl_dcu_drm_encoder_dpms,
+	.mode_fixup = fsl_dcu_drm_encoder_mode_fixup,
+	.prepare = fsl_dcu_drm_encoder_mode_prepare,
+	.commit = fsl_dcu_drm_encoder_mode_commit,
+	.mode_set = fsl_dcu_drm_encoder_mode_set,
+};
+
+static void fsl_dcu_drm_encoder_destroy(struct drm_encoder *encoder)
+{
+	drm_encoder_cleanup(encoder);
+}
+
+static const struct drm_encoder_funcs encoder_funcs = {
+	.destroy = fsl_dcu_drm_encoder_destroy,
+};
+
+int fsl_dcu_drm_encoder_create(struct fsl_dcu_drm_device *fsl_dev)
+{
+	struct drm_encoder *encoder = &fsl_dev->encoder.encoder;
+	int ret;
+
+	fsl_dev->encoder.dpms = DRM_MODE_DPMS_OFF;
+
+	encoder->possible_crtcs = 1;
+
+	ret = drm_encoder_init(fsl_dev->ddev, encoder, &encoder_funcs,
+			       DRM_MODE_ENCODER_LVDS);
+	if (ret < 0)
+		return ret;
+
+	drm_encoder_helper_add(encoder, &encoder_helper_funcs);
+
+	return 0;
+}
+
+/*
+ * Connector
+ */
+
+#define to_fsl_dcu_connector(c) \
+	container_of(c, struct fsl_dcu_drm_connector, connector)
+
+static int fsl_dcu_drm_connector_get_modes(struct drm_connector *connector)
+{
+	struct drm_device *dev = connector->dev;
+	struct device_node *display_np, *np = dev->dev->of_node;
+	struct drm_display_mode *mode = drm_mode_create(connector->dev);
+	int num_modes = 0;
+
+	if (np) {
+		display_np = of_parse_phandle(np, "display", 0);
+		if (!display_np) {
+			dev_err(dev->dev, "failed to find display phandle\n");
+			return num_modes;
+		}
+		of_get_drm_display_mode(display_np, mode, OF_USE_NATIVE_MODE);
+		mode->type |= DRM_MODE_TYPE_DRIVER | DRM_MODE_TYPE_PREFERRED,
+		drm_mode_probed_add(connector, mode);
+		num_modes++;
+	}
+
+	return num_modes;
+}
+
+static int fsl_dcu_drm_connector_mode_valid(struct drm_connector *connector,
+					    struct drm_display_mode *mode)
+{
+	return MODE_OK;
+}
+
+static struct drm_encoder *
+fsl_dcu_drm_connector_best_encoder(struct drm_connector *connector)
+{
+	struct fsl_dcu_drm_connector *fsl_con = to_fsl_dcu_connector(connector);
+
+	return fsl_con->encoder;
+}
+
+static const struct drm_connector_helper_funcs connector_helper_funcs = {
+	.get_modes = fsl_dcu_drm_connector_get_modes,
+	.mode_valid = fsl_dcu_drm_connector_mode_valid,
+	.best_encoder = fsl_dcu_drm_connector_best_encoder,
+};
+
+static void fsl_dcu_drm_connector_destroy(struct drm_connector *connector)
+{
+	drm_connector_unregister(connector);
+	drm_connector_cleanup(connector);
+}
+
+static enum drm_connector_status
+fsl_dcu_drm_connector_detect(struct drm_connector *connector, bool force)
+{
+	return connector_status_connected;
+}
+
+static const struct drm_connector_funcs connector_funcs = {
+	.dpms = drm_helper_connector_dpms,
+	.detect = fsl_dcu_drm_connector_detect,
+	.fill_modes = drm_helper_probe_single_connector_modes,
+	.destroy = fsl_dcu_drm_connector_destroy,
+};
+
+int fsl_dcu_drm_connector_create(struct fsl_dcu_drm_device *fsl_dev,
+				 struct drm_encoder *encoder)
+{
+	struct drm_connector *connector = &fsl_dev->connector.connector;
+	int ret;
+
+	fsl_dev->connector.encoder = encoder;
+
+	connector->display_info.width_mm = 0;
+	connector->display_info.height_mm = 0;
+
+	ret = drm_connector_init(fsl_dev->ddev, connector, &connector_funcs,
+				 DRM_MODE_CONNECTOR_LVDS);
+	if (ret < 0)
+		return ret;
+
+	drm_connector_helper_add(connector, &connector_helper_funcs);
+	ret = drm_connector_register(connector);
+	if (ret < 0)
+		goto err_cleanup;
+
+	ret = drm_mode_connector_attach_encoder(connector, encoder);
+	if (ret < 0)
+		goto err_sysfs;
+
+	connector->encoder = encoder;
+
+	drm_helper_connector_dpms(connector, DRM_MODE_DPMS_OFF);
+	drm_object_property_set_value
+		(&connector->base, fsl_dev->ddev->mode_config.dpms_property,
+		DRM_MODE_DPMS_OFF);
+
+	return 0;
+
+err_sysfs:
+	drm_connector_unregister(connector);
+err_cleanup:
+	drm_connector_cleanup(connector);
+	return ret;
+}
drivers/gpu/drm/fsl/fsl_dcu_drm_crtc.h new file +40 -0
new file mode 100644
index 0000000..ad59992
@@ -0,0 +1,40 @@
+/*
+ * 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_MODSET_H__
+#define __FSL_DCU_DRM_MODSET_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;
+};
+
+struct fsl_dcu_drm_encoder {
+	struct drm_encoder encoder;
+	int dpms;
+};
+
+struct fsl_dcu_drm_connector {
+	struct drm_connector connector;
+	struct drm_encoder *encoder;
+};
+
+int fsl_dcu_drm_crtc_create(struct fsl_dcu_drm_device *fsl_dev);
+int fsl_dcu_drm_encoder_create(struct fsl_dcu_drm_device *fsl_dev);
+int fsl_dcu_drm_connector_create(struct fsl_dcu_drm_device *fsl_dev,
+				 struct drm_encoder *encoder);
+
+#endif /* __FSL_DCU_DRM_MODSET_H__ */
drivers/gpu/drm/fsl/fsl_dcu_drm_drv.c new file +106 -0
new file mode 100644
index 0000000..1bca45a
@@ -0,0 +1,323 @@
+/*
+ * 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.
+ */
+
+#include <linux/clk.h>
+#include <linux/io.h>
+#include <linux/mm.h>
+#include <linux/module.h>
+#include <linux/of_platform.h>
+#include <linux/platform_device.h>
+#include <linux/pm.h>
+#include <linux/pm_runtime.h>
+#include <linux/regmap.h>
+#include <linux/slab.h>
+
+#include <drm/drmP.h>
+#include "fsl_dcu_drm_drv.h"
+#include "fsl_dcu_drm_kms.h"
+
+static int fsl_dcu_unload(struct drm_device *dev)
+{
+	drm_mode_config_cleanup(dev);
+	drm_vblank_cleanup(dev);
+	drm_irq_uninstall(dev);
+
+	dev->dev_private = NULL;
+
+	return 0;
+}
+
+static struct regmap_config fsl_dcu_regmap_config = {
+	.reg_bits = 32,
+	.reg_stride = 4,
+	.val_bits = 32,
+};
+
+static int fsl_dcu_bypass_tcon(struct fsl_dcu_drm_device *fsl_dev,
+			       struct device_node *np)
+{
+	struct device_node *tcon_np;
+	struct platform_device *pdev;
+	struct clk *tcon_clk;
+	struct resource *res;
+	void __iomem *base;
+
+	tcon_np = of_parse_phandle(np, "tcon-controller", 0);
+	if (!tcon_np)
+		return -EINVAL;
+
+	pdev = of_find_device_by_node(tcon_np);
+	if (!pdev)
+		return -EINVAL;
+
+	tcon_clk = devm_clk_get(&pdev->dev, "tcon");
+	if (IS_ERR(tcon_clk))
+		return PTR_ERR(tcon_clk);
+	clk_prepare_enable(tcon_clk);
+
+	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+	if (!res)
+		return -ENODEV;
+
+	base = devm_ioremap_resource(&pdev->dev, res);
+	if (IS_ERR(base))
+		return PTR_ERR(base);
+
+	fsl_dev->tcon_regmap = devm_regmap_init_mmio_clk(&pdev->dev,
+			"tcon", base, &fsl_dcu_regmap_config);
+	if (IS_ERR(fsl_dev->tcon_regmap)) {
+		dev_err(&pdev->dev, "regmap init failed\n");
+		return PTR_ERR(fsl_dev->tcon_regmap);
+	}
+
+	regmap_write(fsl_dev->tcon_regmap, TCON_CTRL1, TCON_BYPASS_ENABLE);
+	return 0;
+}
+
+static int fsl_dcu_scfg_config(struct fsl_dcu_drm_device *fsl_dev,
+			       struct device_node *np)
+{
+	struct device_node *scfg_np;
+	struct platform_device *pdev;
+	struct resource *res;
+	void __iomem *base;
+
+	scfg_np = of_parse_phandle(np, "scfg-controller", 0);
+	if (!scfg_np)
+		return 0;
+
+	pdev = of_find_device_by_node(scfg_np);
+	if (!pdev)
+		return -EINVAL;
+
+	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+	if (!res)
+		return -ENODEV;
+
+	base = devm_ioremap_resource(&pdev->dev, res);
+	if (IS_ERR(base))

drivers/gpu/drm/fsl/fsl_dcu_drm_drv.c line 116

Quoted 10 lines
drivers/gpu/drm/fsl/fsl_dcu_drm_drv.c new file +10 -0
+		return PTR_ERR(base);
+
+	fsl_dev->scfg_regmap = devm_regmap_init_mmio_clk(&pdev->dev,
+			NULL, base, &fsl_dcu_regmap_config);
+	if (IS_ERR(fsl_dev->scfg_regmap)) {
+		dev_err(&pdev->dev, "regmap init failed\n");
+		return PTR_ERR(fsl_dev->scfg_regmap);
+	}
+
+	regmap_write(fsl_dev->scfg_regmap, 0x28, 0x80000000);

What does this actually do? I don't think this exists in Vybrid, but I guess we could easily make the property optional which would then not call this function...

--
Stefan

Quoted 678 lines
drivers/gpu/drm/fsl/fsl_dcu_drm_drv.c new file +207 -0
+
+	return 0;
+}
+
+static int fsl_dcu_load(struct drm_device *dev, unsigned long flags)
+{
+	struct platform_device *pdev = dev->platformdev;
+	struct fsl_dcu_drm_device *fsl_dev;
+	struct resource *res;
+	void __iomem *base;
+	int ret;
+
+	fsl_dev = devm_kzalloc(&pdev->dev, sizeof(*fsl_dev), GFP_KERNEL);
+	if (!fsl_dev)
+		return -ENOMEM;
+
+	fsl_dev->dev = &pdev->dev;
+	fsl_dev->ddev = dev;
+	dev->dev_private = fsl_dev;
+
+	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+	base = devm_ioremap_resource(&pdev->dev, res);
+	if (IS_ERR(base)) {
+		ret = PTR_ERR(base);
+		return ret;
+	}
+
+	fsl_dev->regmap = devm_regmap_init_mmio(&pdev->dev,
+			base, &fsl_dcu_regmap_config);
+	if (IS_ERR(fsl_dev->regmap)) {
+		dev_err(&pdev->dev, "regmap init failed\n");
+		return PTR_ERR(fsl_dev->regmap);
+	}
+
+	ret = fsl_dcu_drm_modeset_init(fsl_dev);
+	if (ret < 0) {
+		dev_err(&pdev->dev, "failed to initialize mode setting\n");
+		return ret;
+	}
+
+	ret = drm_vblank_init(dev, 1);
+	if (ret < 0) {
+		dev_err(&pdev->dev, "failed to initialize vblank\n");
+		goto done;
+	}
+
+	ret = drm_irq_install(dev, platform_get_irq(dev->platformdev, 0));
+	if (ret < 0) {
+		dev_err(&pdev->dev, "failed to install IRQ handler\n");
+		goto done;
+	}
+
+	/* Put TCON in bypass mode, so the input signals from DCU are passed
+	 * through TCON unchanged */
+	fsl_dcu_bypass_tcon(fsl_dev, pdev->dev.of_node);
+	fsl_dcu_scfg_config(fsl_dev, pdev->dev.of_node);
+
+	fsl_dev->clk = devm_clk_get(&pdev->dev, "dcfb");
+	if (IS_ERR(fsl_dev->clk)) {
+		ret = PTR_ERR(fsl_dev->clk);
+		dev_err(&pdev->dev, "could not get clock\n");
+		return ret;
+	}
+	clk_prepare_enable(fsl_dev->clk);
+
+	dev_set_drvdata(dev->dev, fsl_dev);
+
+	fsl_dcu_fbdev_init(dev);
+
+	return 0;
+done:
+	if (ret)
+		fsl_dcu_unload(dev);
+
+	return ret;
+}
+
+static void fsl_dcu_drm_preclose(struct drm_device *dev, struct drm_file *file)
+{
+	;
+}
+
+static irqreturn_t fsl_dcu_drm_irq(int irq, void *arg)
+{
+	return IRQ_HANDLED;
+}
+
+static int fsl_dcu_drm_enable_vblank(struct drm_device *dev, int crtc)
+{
+	return 0;
+}
+
+static void fsl_dcu_drm_disable_vblank(struct drm_device *dev, int crtc)
+{
+	;
+}
+
+static const struct file_operations fsl_dcu_drm_fops = {
+	.owner		= THIS_MODULE,
+	.open		= drm_open,
+	.release	= drm_release,
+	.unlocked_ioctl	= drm_ioctl,
+#ifdef CONFIG_COMPAT
+	.compat_ioctl	= drm_compat_ioctl,
+#endif
+	.poll		= drm_poll,
+	.read		= drm_read,
+	.llseek		= no_llseek,
+	.mmap		= drm_gem_cma_mmap,
+};
+
+static struct drm_driver fsl_dcu_drm_driver = {
+	.driver_features	= DRIVER_HAVE_IRQ | DRIVER_GEM | DRIVER_MODESET
+				| DRIVER_PRIME,
+	.load			= fsl_dcu_load,
+	.unload			= fsl_dcu_unload,
+	.preclose		= fsl_dcu_drm_preclose,
+	.irq_handler		= fsl_dcu_drm_irq,
+	.get_vblank_counter	= drm_vblank_count,
+	.enable_vblank		= fsl_dcu_drm_enable_vblank,
+	.disable_vblank		= fsl_dcu_drm_disable_vblank,
+	.gem_free_object	= drm_gem_cma_free_object,
+	.gem_vm_ops		= &drm_gem_cma_vm_ops,
+	.prime_handle_to_fd	= drm_gem_prime_handle_to_fd,
+	.prime_fd_to_handle	= drm_gem_prime_fd_to_handle,
+	.gem_prime_import	= drm_gem_prime_import,
+	.gem_prime_export	= drm_gem_prime_export,
+	.gem_prime_get_sg_table	= drm_gem_cma_prime_get_sg_table,
+	.gem_prime_import_sg_table = drm_gem_cma_prime_import_sg_table,
+	.gem_prime_vmap		= drm_gem_cma_prime_vmap,
+	.gem_prime_vunmap	= drm_gem_cma_prime_vunmap,
+	.gem_prime_mmap		= drm_gem_cma_prime_mmap,
+	.dumb_create		= drm_gem_cma_dumb_create,
+	.dumb_map_offset	= drm_gem_cma_dumb_map_offset,
+	.dumb_destroy		= drm_gem_dumb_destroy,
+	.fops			= &fsl_dcu_drm_fops,
+	.name			= "fsl-dcu-drm",
+	.desc			= "Freescale DCU DRM",
+	.date			= "20150213",
+	.major			= 1,
+	.minor			= 0,
+};
+
+#ifdef CONFIG_PM_SLEEP
+static int fsl_dcu_drm_pm_suspend(struct device *dev)
+{
+	struct fsl_dcu_drm_device *fsl_dev = dev_get_drvdata(dev);
+
+	drm_kms_helper_poll_disable(fsl_dev->ddev);
+	fsl_dcu_drm_crtc_suspend(&fsl_dev->crtc);
+
+	return 0;
+}
+
+static int fsl_dcu_drm_pm_resume(struct device *dev)
+{
+	struct fsl_dcu_drm_device *fsl_dev = dev_get_drvdata(dev);
+
+	drm_modeset_lock_all(fsl_dev->ddev);
+	fsl_dcu_drm_crtc_resume(&fsl_dev->crtc);
+	drm_modeset_unlock_all(fsl_dev->ddev);
+
+	drm_kms_helper_poll_enable(fsl_dev->ddev);
+	return 0;
+}
+#endif
+
+static const struct dev_pm_ops fsl_dcu_drm_pm_ops = {
+	SET_SYSTEM_SLEEP_PM_OPS(fsl_dcu_drm_pm_suspend, fsl_dcu_drm_pm_resume)
+};
+
+static int fsl_dcu_drm_probe(struct platform_device *pdev)
+{
+	return drm_platform_init(&fsl_dcu_drm_driver, pdev);
+}
+
+static int fsl_dcu_drm_remove(struct platform_device *pdev)
+{
+	struct fsl_dcu_drm_device *fsl_dev = platform_get_drvdata(pdev);
+
+	drm_put_dev(fsl_dev->ddev);
+
+	return 0;
+}
+
+static struct of_device_id fsl_dcu_of_match[] = {
+		{ .compatible = "fsl,ls1021a-dcfb", },
+		{ },
+};
+MODULE_DEVICE_TABLE(of, fsl_dcu_of_match);
+
+static struct platform_driver fsl_dcu_drm_platform_driver = {
+	.probe		= fsl_dcu_drm_probe,
+	.remove		= fsl_dcu_drm_remove,
+	.driver		= {
+		.owner	= THIS_MODULE,
+		.name	= "fsl,ls1021a-dcfb",
+		.pm	= &fsl_dcu_drm_pm_ops,
+		.of_match_table = fsl_dcu_of_match,
+	},
+};
+
+module_platform_driver(fsl_dcu_drm_platform_driver);
+
+MODULE_ALIAS("platform:fsl-dcu-drm");
+MODULE_DESCRIPTION("Freescale DCU DRM Driver");
+MODULE_LICENSE("GPL");
drivers/gpu/drm/fsl/fsl_dcu_drm_drv.h new file +167 -0
new file mode 100644
index 0000000..8dc7c10
@@ -0,0 +1,167 @@
+/*
+ * 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_DRV_H__
+#define __FSL_DCU_DRM_DRV_H__
+
+#include <linux/kernel.h>
+#include <linux/spinlock.h>
+#include <stddef.h>
+#include <drm/drm.h>
+#include <drm/drmP.h>
+#include <drm/drm_fb_helper.h>
+#include <drm/drm_crtc_helper.h>
+#include <drm/drm_gem_cma_helper.h>
+#include <drm/drm_fb_cma_helper.h>
+
+#include "fsl_dcu_drm_crtc.h"
+#define DRIVER_NAME			"fsl-dcu-fb"
+
+#define DCU_DCU_MODE			0x0010
+#define DCU_MODE_BLEND_ITER(x)		((x) << 20)
+#define DCU_MODE_RASTER_EN		BIT(14)
+#define DCU_MODE_DCU_MODE(x)		(x)
+#define DCU_MODE_DCU_MODE_MASK		0x03
+#define DCU_MODE_OFF			0
+#define DCU_MODE_NORMAL			1
+#define DCU_MODE_TEST			2
+#define DCU_MODE_COLORBAR		3
+
+#define DCU_BGND			0x0014
+#define DCU_BGND_R(x)			((x) << 16)
+#define DCU_BGND_G(x)			((x) << 8)
+#define DCU_BGND_B(x)			(x)
+
+#define DCU_DISP_SIZE			0x0018
+#define DCU_DISP_SIZE_DELTA_Y(x)	((x) << 16)
+/*Regisiter value 1/16 of horizontal resolution*/
+#define DCU_DISP_SIZE_DELTA_X(x)	((x) >> 4)
+
+#define DCU_HSYN_PARA			0x001c
+#define DCU_HSYN_PARA_BP(x)		((x) << 22)
+#define DCU_HSYN_PARA_PW(x)		((x) << 11)
+#define DCU_HSYN_PARA_FP(x)		(x)
+
+#define DCU_VSYN_PARA			0x0020
+#define DCU_VSYN_PARA_BP(x)		((x) << 22)
+#define DCU_VSYN_PARA_PW(x)		((x) << 11)
+#define DCU_VSYN_PARA_FP(x)		(x)
+
+#define DCU_SYN_POL			0x0024
+#define DCU_SYN_POL_INV_PXCK_FALL	(0 << 6)
+#define DCU_SYN_POL_NEG_REMAIN		(0 << 5)
+#define DCU_SYN_POL_INV_VS_LOW		BIT(1)
+#define DCU_SYN_POL_INV_HS_LOW		(1)
+
+#define DCU_THRESHOLD			0x0028
+#define DCU_THRESHOLD_LS_BF_VS(x)	((x) << 16)
+#define DCU_THRESHOLD_OUT_BUF_HIGH(x)	((x) << 8)
+#define DCU_THRESHOLD_OUT_BUF_LOW(x)	(x)
+#define BF_VS_VAL			0x03
+#define BUF_MAX_VAL			0x78
+#define BUF_MIN_VAL			0x0a
+
+#define DCU_INT_STATUS			0x002C
+#define DCU_INT_STATUS_UNDRUN		BIT(1)
+
+#define DCU_INT_MASK			0x0030
+#define DCU_INT_MASK_UNDRUN		BIT(1)
+#define DCU_INT_MASK_VBLANK		BIT(3)
+
+#define DCU_DIV_RATIO			0x0054
+
+#define DCU_UPDATE_MODE			0x00cc
+#define DCU_UPDATE_MODE_MODE		BIT(31)
+#define DCU_UPDATE_MODE_READREG		BIT(30)
+
+#define DCU_DCFB_MAX			0x300
+
+#define DCU_CTRLDESCLN_1(x)		(0x200 + (x) * 0x40)
+#define DCU_CTRLDESCLN_1_HEIGHT(x)	((x) << 16)
+#define DCU_CTRLDESCLN_1_WIDTH(x)	(x)
+
+#define DCU_CTRLDESCLN_2(x)		(0x204 + (x) * 0x40)
+#define DCU_CTRLDESCLN_2_POSY(x)	((x) << 16)
+#define DCU_CTRLDESCLN_2_POSX(x)	(x)
+
+#define DCU_CTRLDESCLN_3(x)		(0x208 + (x) * 0x40)
+
+#define DCU_CTRLDESCLN_4(x)		(0x20c + (x) * 0x40)
+#define DCU_CTRLDESCLN_4_EN		BIT(31)
+#define DCU_CTRLDESCLN_4_TILE_EN	BIT(30)
+#define DCU_CTRLDESCLN_4_DATA_SEL_CLUT	BIT(29)
+#define DCU_CTRLDESCLN_4_SAFETY_EN	BIT(28)
+#define DCU_CTRLDESCLN_4_TRANS(x)	((x) << 20)
+#define DCU_CTRLDESCLN_4_BPP(x)		((x) << 16)
+#define DCU_CTRLDESCLN_4_RLE_EN		BIT(15)
+#define DCU_CTRLDESCLN_4_LUOFFS(x)	((x) << 4)
+#define DCU_CTRLDESCLN_4_BB_ON		BIT(2)
+#define DCU_CTRLDESCLN_4_AB(x)		(x)
+
+#define DCU_CTRLDESCLN_5(x)		(0x210 + (x) * 0x40)
+#define DCU_CTRLDESCLN_5_CKMAX_R(x)	((x) << 16)
+#define DCU_CTRLDESCLN_5_CKMAX_G(x)	((x) << 8)
+#define DCU_CTRLDESCLN_5_CKMAX_B(x)	(x)
+
+#define DCU_CTRLDESCLN_6(x)		(0x214 + (x) * 0x40)
+#define DCU_CTRLDESCLN_6_CKMIN_R(x)	((x) << 16)
+#define DCU_CTRLDESCLN_6_CKMIN_G(x)	((x) << 8)
+#define DCU_CTRLDESCLN_6_CKMIN_B(x)	(x)
+
+#define DCU_CTRLDESCLN_7(x)		(0x218 + (x) * 0x40)
+#define DCU_CTRLDESCLN_7_TILE_VER(x)	((x) << 16)
+#define DCU_CTRLDESCLN_7_TILE_HOR(x)	(x)
+
+#define DCU_CTRLDESCLN_8(x)		(0x21c + (x) * 0x40)
+#define DCU_CTRLDESCLN_8_FG_FCOLOR(x)	(x)
+
+#define DCU_CTRLDESCLN_9(x)		(0x220 + (x) * 0x40)
+#define DCU_CTRLDESCLN_9_BG_BCOLOR(x)	(x)
+
+#define DCU_CTRLDESCLN_10(x)		(0x224 + (x) * 0x40)
+#define DCU_CTRLDESCLN_10_POST_SKIP(x)	((x) << 16)
+#define DCU_CTRLDESCLN_10_PRE_SKIP(x)	(x)
+
+#define FSL_DCU_RGB565			4
+#define FSL_DCU_RGB888			5
+#define FSL_DCU_ARGB8888		6
+#define FSL_DCU_ARGB1555		11
+#define FSL_DCU_ARGB4444		12
+#define FSL_DCU_YUV422			14
+
+#define TCON_CTRL1			0x0000
+#define TCON_BYPASS_ENABLE		BIT(29)
+
+#define DBG(fmt, ...) DRM_DEBUG(fmt"\n", ##__VA_ARGS__)
+
+struct clk;
+struct device;
+struct drm_device;
+
+struct fsl_dcu_drm_device {
+	struct device *dev;
+	struct regmap *regmap;
+	struct regmap *tcon_regmap;
+	struct regmap *scfg_regmap;
+	unsigned int irq;
+	struct clk *clk;
+	/*protects hardware register*/
+	spinlock_t irq_lock;
+	struct drm_device *ddev;
+	struct drm_fbdev_cma *fbdev;
+	struct fsl_dcu_drm_crtc crtc;
+	struct fsl_dcu_drm_encoder encoder;
+	struct fsl_dcu_drm_connector connector;
+};
+
+void fsl_dcu_fbdev_init(struct drm_device *dev);
+
+#endif /* __FSL_DCU_DRM_DRV_H__ */
drivers/gpu/drm/fsl/fsl_dcu_drm_fbdev.c new file +43 -0
new file mode 100644
index 0000000..6729f92
@@ -0,0 +1,43 @@
+/*
+ * 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_crtc.h>
+#include <drm/drm_fb_helper.h>
+#include <drm/drm_crtc_helper.h>
+#include <drm/drm_fb_cma_helper.h>
+#include <drm/drm_gem_cma_helper.h>
+#include <linux/clk.h>
+#include <linux/delay.h>
+#include <linux/dma-mapping.h>
+#include <linux/fb.h>
+#include <linux/interrupt.h>
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/of_platform.h>
+#include <linux/regmap.h>
+#include <video/of_display_timing.h>
+#include <video/videomode.h>
+#include <linux/uaccess.h>
+
+#include "fsl_dcu_drm_drv.h"
+#include "fsl_dcu_drm_crtc.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 +45 -0
new file mode 100644
index 0000000..0eb0652
@@ -0,0 +1,45 @@
+/*
+ * 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.
+ */
+
+#include <drm/drmP.h>
+#include <drm/drm_crtc.h>
+#include <drm/drm_crtc_helper.h>
+#include <drm/drm_fb_cma_helper.h>
+#include <drm/drm_gem_cma_helper.h>
+
+#include "fsl_dcu_drm_crtc.h"
+#include "fsl_dcu_drm_drv.h"
+#include "fsl_dcu_drm_kms.h"
+
+static const struct drm_mode_config_funcs fsl_dcu_drm_mode_config_funcs = {
+	.fb_create = drm_fb_cma_create,
+};
+
+int fsl_dcu_drm_modeset_init(struct fsl_dcu_drm_device *fsl_dev)
+{
+	drm_mode_config_init(fsl_dev->ddev);
+
+	fsl_dev->ddev->mode_config.min_width = 0;
+	fsl_dev->ddev->mode_config.min_height = 0;
+	fsl_dev->ddev->mode_config.max_width = 2031;
+	fsl_dev->ddev->mode_config.max_height = 2047;
+	fsl_dev->ddev->mode_config.funcs = &fsl_dcu_drm_mode_config_funcs;
+
+	fsl_dcu_drm_crtc_create(fsl_dev);
+	fsl_dcu_drm_encoder_create(fsl_dev);
+	fsl_dcu_drm_connector_create(fsl_dev, &fsl_dev->encoder.encoder);
+
+	drm_kms_helper_poll_init(fsl_dev->ddev);
+
+	drm_helper_disable_unused_functions(fsl_dev->ddev);
+
+	return 0;
+}
drivers/gpu/drm/fsl/fsl_dcu_drm_kms.h new file +22 -0
new file mode 100644
index 0000000..9d5b798
@@ -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_DRM_KMS_H__
+#define __FSL_DCU_DRM_KMS_H__
+
+#include <linux/types.h>
+
+struct drm_gem_cma_object;
+struct fsl_dcu_drm_device;
+
+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 +124 -0
new file mode 100644
index 0000000..d725594
@@ -0,0 +1,124 @@
+/*
+ * 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.
+ */
+
+#include <drm/drmP.h>
+#include <drm/drm_crtc.h>
+#include <drm/drm_crtc_helper.h>
+#include <drm/drm_fb_cma_helper.h>
+#include <drm/drm_gem_cma_helper.h>
+#include <linux/regmap.h>
+
+#include "fsl_dcu_drm_drv.h"
+#include "fsl_dcu_drm_kms.h"
+#include "fsl_dcu_drm_plane.h"
+
+static void __fsl_dcu_drm_plane_setup(struct drm_plane *plane,
+				      struct drm_framebuffer *fb)
+{
+	struct fsl_dcu_drm_device *fsl_dev = plane->dev->dev_private;
+	u32 plane_num = 0, alpha, bpp;
+	struct drm_gem_cma_object *gem;
+
+	while (plane->possible_crtcs >> 1)
+		plane_num++;
+
+	gem = drm_fb_cma_get_gem_obj(fb, 0);
+
+	switch (fb->pixel_format) {
+	case DRM_FORMAT_RGB565:
+		bpp = FSL_DCU_RGB565;
+		alpha = 0xff;
+		break;
+	case DRM_FORMAT_RGB888:
+		bpp = FSL_DCU_RGB888;
+		alpha = 0xff;
+		break;
+	case DRM_FORMAT_ARGB8888:
+		bpp = FSL_DCU_ARGB8888;
+		alpha = 0xff;
+		break;
+	case DRM_FORMAT_BGRA4444:
+		bpp = FSL_DCU_ARGB4444;
+		alpha = 0xff;
+		break;
+	case DRM_FORMAT_ARGB1555:
+		bpp = FSL_DCU_ARGB1555;
+		alpha = 0xff;
+		break;
+	case DRM_FORMAT_YUV422:
+		bpp = FSL_DCU_YUV422;
+		alpha = 0xff;
+		break;
+	default:
+		return;
+	}
+
+	regmap_write(fsl_dev->regmap, DCU_CTRLDESCLN_3(plane_num), gem->paddr);
+	regmap_write(fsl_dev->regmap, DCU_CTRLDESCLN_4(plane_num),
+		     DCU_CTRLDESCLN_4_EN |
+		     DCU_CTRLDESCLN_4_TRANS(alpha) |
+		     DCU_CTRLDESCLN_4_BPP(bpp) |
+		     DCU_CTRLDESCLN_4_AB(2));
+	regmap_write(fsl_dev->regmap, DCU_CTRLDESCLN_5(plane_num),
+		     DCU_CTRLDESCLN_5_CKMAX_R(0xFF) |
+		     DCU_CTRLDESCLN_5_CKMAX_G(0xFF) |
+		     DCU_CTRLDESCLN_5_CKMAX_B(0xFF));
+	regmap_write(fsl_dev->regmap, DCU_CTRLDESCLN_6(plane_num),
+		     DCU_CTRLDESCLN_6_CKMIN_R(0) |
+		     DCU_CTRLDESCLN_6_CKMIN_G(0) |
+		     DCU_CTRLDESCLN_6_CKMIN_B(0));
+	regmap_write(fsl_dev->regmap, DCU_CTRLDESCLN_8(plane_num),
+		     DCU_CTRLDESCLN_8_FG_FCOLOR(0));
+	regmap_write(fsl_dev->regmap, DCU_CTRLDESCLN_9(plane_num),
+		     DCU_CTRLDESCLN_9_BG_BCOLOR(0));
+	regmap_write(fsl_dev->regmap, DCU_CTRLDESCLN_10(plane_num),
+		     DCU_CTRLDESCLN_10_POST_SKIP(0) |
+		     DCU_CTRLDESCLN_10_PRE_SKIP(0));
+	regmap_write(fsl_dev->regmap, DCU_UPDATE_MODE, DCU_UPDATE_MODE_READREG);
+}
+
+void fsl_dcu_drm_plane_setup(struct drm_plane *plane)
+{
+	if (!plane->fb)
+		return;
+
+	__fsl_dcu_drm_plane_setup(plane, plane->fb);
+}
+
+int fsl_dcu_drm_plane_update(struct drm_plane *plane, struct drm_crtc *crtc,
+			     struct drm_framebuffer *fb, int crtc_x, int crtc_y,
+			    unsigned int crtc_w, unsigned int crtc_h,
+			    uint32_t src_x, uint32_t src_y,
+			    uint32_t src_w, uint32_t src_h)
+{
+	__fsl_dcu_drm_plane_setup(plane, fb);
+	return 0;
+}
+
+int fsl_dcu_drm_plane_disable(struct drm_plane *plane)
+{
+	return 0;
+}
+
+void fsl_dcu_drm_plane_destroy(struct drm_plane *plane)
+{
+	fsl_dcu_drm_plane_disable(plane);
+	drm_plane_cleanup(plane);
+}
+
+static const uint32_t formats[] = {
+	DRM_FORMAT_RGB565,
+	DRM_FORMAT_RGB888,
+	DRM_FORMAT_ARGB8888,
+	DRM_FORMAT_ARGB4444,
+	DRM_FORMAT_ARGB1555,
+	DRM_FORMAT_YUV422,
+};
drivers/gpu/drm/fsl/fsl_dcu_drm_plane.h new file +28 -0
new file mode 100644
index 0000000..da88d1c
@@ -0,0 +1,28 @@
+/*
+ * 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;
+
+void fsl_dcu_drm_plane_setup(struct drm_plane *plane);
+int fsl_dcu_drm_plane_update(struct drm_plane *plane,
+			     struct drm_crtc *crtc,
+			     struct drm_framebuffer *fb,
+			     int crtc_x, int crtc_y,
+			     unsigned int crtc_w, unsigned int crtc_h,
+			     uint32_t src_x, uint32_t src_y,
+			     uint32_t src_w, uint32_t src_h);
+int fsl_dcu_drm_plane_disable(struct drm_plane *plane);
+void fsl_dcu_drm_plane_destroy(struct drm_plane *plane);
+
+#endif /* __FSL_DCU_DRM_PLANE_H__ */
#10 lore raw
Quoted 22 lines

-----Original Message-----
From: Stefan Agner [mailto:[email protected]]
Sent: Wednesday, March 04, 2015 11:04 PM
To: Wang Jianwei-B52261
Cc: [email protected]; [email protected]; Wood Scott-B07421; Xiubo Li; Wang Huan-B18965; [email protected]; [email protected]
Subject: Re: [PATCH 1/3] drm/layerscape: Add fsl dcu DRM driver

Quoted 9 lines · Jianwei Wang

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

2D-ACE is a Freescale display controller. It supports at most four plane and provide an hardware cursor.

This is a simplified version, only a primary plane, a fb created for fbdev, a crtc, a connector for TFT LCD panel, an encoder, and the encoder is not in use. Now this drver support fbdev only.

Quoted 8 lines

Hi,

Do you know if that driver also works on Vybrid devices? Vybrid has also DCU4 module with 2D-ACE functionality, also the registers look pretty similar. I was thinking about creating a driver for Vybrid anyway...

Some remarks below...

Hi,

As you say the display IP module on ls1021a and Vybrid device are all 2D-ACE, so I think this driver also works on Vybrid devices. I'd like to do something for the compatibility.

Quoted 10 lines

"FB Driver" probably refers more to a fbdev driver in the Linux kernel sense, but since this is a DRM driver this is somewhat confusing. The binding should describe the hardware, in the Vybrid RM mentions the IP as "Display Control Unit (DCU4)", so maybe

Freescale Display Controller Unit (DCU4) module

Also, instead of using dcfb, I would use somewhat more hardware describing, e.g. dcu4?

Quoted 6 lines

Documentation/devicetree/bindings/video/fsl,dcfb.txt line 4

Quoted 3 lines
Documentation/devicetree/bindings/video/fsl,dcfb.txt new file +3 -0
+
+Required properties:
+- compatible:		Should be one of "fsl,ls1021a-dcfb".

If the driver also works for Vybrid, be favorable to have a generic compatible string, e.g. fsl,dcu4?

Thank you for your comments, I'll modify it.

Quoted 8 lines

drivers/gpu/drm/fsl/fsl_dcu_drm_drv.c line 116

Quoted 1 line
drivers/gpu/drm/fsl/fsl_dcu_drm_drv.c new file +1 -0
+	regmap_write(fsl_dev->scfg_regmap, 0x28, 0x80000000);

What does this actually do? I don't think this exists in Vybrid, but I guess we could easily make the property optional which would then not call this function...

--
Stefan

This is a platform related register. I would move it to platform related file (arch/arm/mach-imx/mach-ls1021a.c).

Regards,
Jianwei

Quoted 1,435 lines
Quoted 5 lines
Quoted 7 lines
---
 .../devicetree/bindings/video/fsl,dcfb.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_crtc.c             | 412

+++++++++++++++++++++

Quoted 2 lines
 drivers/gpu/drm/fsl/fsl_dcu_drm_crtc.h             |  40 ++
 drivers/gpu/drm/fsl/fsl_dcu_drm_drv.c              | 323

++++++++++++++++

Quoted 28 lines
 drivers/gpu/drm/fsl/fsl_dcu_drm_drv.h              | 167 +++++++++
 drivers/gpu/drm/fsl/fsl_dcu_drm_fbdev.c            |  43 +++
 drivers/gpu/drm/fsl/fsl_dcu_drm_kms.c              |  45 +++
 drivers/gpu/drm/fsl/fsl_dcu_drm_kms.h              |  22 ++
 drivers/gpu/drm/fsl/fsl_dcu_drm_plane.c            | 124 +++++++
 drivers/gpu/drm/fsl/fsl_dcu_drm_plane.h            |  28 ++
 14 files changed, 1281 insertions(+)
 create mode 100644
Documentation/devicetree/bindings/video/fsl,dcfb.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_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/video/fsl,dcfb.txt new file +0 -0
new file mode 100644
index 0000000..de7da97

Documentation/devicetree/bindings/video/fsl,dcfb.txt line 1

Quoted 1 line
Documentation/devicetree/bindings/video/fsl,dcfb.txt new file +1 -0
@@ -0,0 +1,50 @@
+* Freescale Simple Display Controller FB Driver

"FB Driver" probably refers more to a fbdev driver in the Linux kernel sense, but since this is a DRM driver this is somewhat confusing. The binding should describe the hardware, in the Vybrid RM mentions the IP as "Display Control Unit (DCU4)", so maybe

Freescale Display Controller Unit (DCU4) module

Also, instead of using dcfb, I would use somewhat more hardware describing, e.g. dcu4?

Documentation/devicetree/bindings/video/fsl,dcfb.txt line 4

Quoted 3 lines
Documentation/devicetree/bindings/video/fsl,dcfb.txt new file +3 -0
+
+Required properties:
+- compatible:		Should be one of "fsl,ls1021a-dcfb".

If the driver also works for Vybrid, be favorable to have a generic compatible string, e.g. fsl,dcu4?

Quoted 5 lines
Documentation/devicetree/bindings/video/fsl,dcfb.txt new file +5 -0
+- reg:			Address and length of the register set for dcfb.
+- clocks:		From common clock binding: handle to dcfb clock.
+- clock-names:		From common clock binding: Shall be "dcfb".
+- display:		The phandle to display node.
+

Documentation/devicetree/bindings/video/fsl,dcfb.txt

Quoted 10 lines
Documentation/devicetree/bindings/video/fsl,dcfb.txt new file +10 -0
+Optional properties:
+- scfg-controller:	The phandle of scfg 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.

Quoted 120 lines
Documentation/devicetree/bindings/video/fsl,dcfb.txt new file +31 -0
+
+Examples:
+dcfb: dcfb@2ce0000 {
+	compatible = "fsl,ls1021a-dcfb";
+	reg = <0x0 0x2ce0000 0x0 0x10000>;
+	clocks = <&platform_clk 0>;
+	clock-names = "dcfb";
+	scfg-controller = <&scfg>;
+	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 index renamed from drivers/gpu/drm/Kconfig +0 -0

151a050..a6957aa 100644

drivers/gpu/drm/Kconfig +2 -0
@@ -199,6 +199,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 index renamed from drivers/gpu/drm/Makefile +0 -0

2c239b9..ab5b9ef 100644

drivers/gpu/drm/Makefile +1 -0
@@ -56,6 +56,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.
(quoted diff) +0 -0

b/drivers/gpu/drm/fsl/Makefile new file mode 100644 index 0000000..51c3e1f

drivers/gpu/drm/fsl/Makefile new file +7 -0
@@ -0,0 +1,7 @@
+fsl-dcu-drm-y := fsl_dcu_drm_drv.o \
+	       fsl_dcu_drm_kms.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_crtc.c new file +22 -0
new file mode 100644
index 0000000..9f5ba86
@@ -0,0 +1,412 @@
+/*
+ * 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.
+ */
+
+#include <linux/backlight.h>
+#include <linux/clk.h>
+#include <linux/regmap.h>
+
+#include <drm/drmP.h>
+#include <drm/drm_atomic_helper.h>
+#include <drm/drm_crtc.h>
+#include <drm/drm_crtc_helper.h>
+#include <drm/drm_fb_cma_helper.h>

drivers/gpu/drm/fsl/fsl_dcu_drm_crtc.c line 32

Quoted 10 lines
drivers/gpu/drm/fsl/fsl_dcu_drm_crtc.c new file +10 -0
+#include <drm/drm_gem_cma_helper.h>
+#include <drm/drm_plane_helper.h>
+#include <video/of_display_timing.h>
+
+#include "fsl_dcu_drm_crtc.h"
+#include "fsl_dcu_drm_drv.h"
+#include "fsl_dcu_drm_kms.h"
+#include "fsl_dcu_drm_plane.h"
+
+#define to_fsl_dcu_crtc(c)	container_of(c, struct fsl_dcu_drm_crtc,

crtc)

Quoted 95 lines
drivers/gpu/drm/fsl/fsl_dcu_drm_crtc.c new file +95 -0
+
+static void fsl_dcu_drm_crtc_start(struct drm_crtc *crtc) {
+	fsl_dcu_drm_plane_setup(crtc->primary);
+}
+
+static void fsl_dcu_drm_crtc_stop(struct drm_crtc *crtc) { }
+
+void fsl_dcu_drm_crtc_suspend(struct drm_crtc *crtc) {
+	fsl_dcu_drm_crtc_stop(crtc);
+}
+
+void fsl_dcu_drm_crtc_resume(struct drm_crtc *crtc) {
+	struct fsl_dcu_drm_crtc *fsl_crtc = to_fsl_dcu_crtc(crtc);
+
+	if (fsl_crtc->dpms != DRM_MODE_DPMS_ON)
+		return;
+
+	fsl_dcu_drm_crtc_start(crtc);
+}
+
+static void fsl_dcu_drm_crtc_update_base(struct drm_crtc *crtc) { }
+
+static void fsl_dcu_drm_crtc_dpms(struct drm_crtc *crtc, int mode) {
+	struct fsl_dcu_drm_crtc *fsl_crtc = to_fsl_dcu_crtc(crtc);
+
+	if (fsl_crtc->dpms == mode)
+		return;
+
+	if (mode == DRM_MODE_DPMS_ON)
+		fsl_dcu_drm_crtc_start(crtc);
+	else
+		fsl_dcu_drm_crtc_stop(crtc);
+
+	fsl_crtc->dpms = mode;
+}
+
+static bool fsl_dcu_drm_crtc_mode_fixup(struct drm_crtc *crtc,
+					const struct drm_display_mode *mode,
+					struct drm_display_mode *adjusted_mode) {
+	return true;
+}
+
+static void fsl_dcu_drm_crtc_mode_prepare(struct drm_crtc *crtc) {
+		fsl_dcu_drm_crtc_stop(crtc);
+}
+
+static int fsl_dcu_drm_crtc_mode_set(struct drm_crtc *crtc,
+				     struct drm_display_mode *mode,
+				     struct drm_display_mode *adjusted_mode,
+				     int x, int y,
+				     struct drm_framebuffer *old_fb) {
+	struct drm_device *dev = crtc->dev;
+	struct fsl_dcu_drm_device *fsl_dev = dev->dev_private;
+	uint32_t hbp, hfp, hsw, vbp, vfp, vsw, div, index;
+
+	DBG(": set mode: %d:\"%s\" %d %d %d %d %d %d %d %d %d %d 0x%x 0x%x",
+	    mode->base.id, mode->name,
+	    mode->vrefresh, mode->clock,
+	    mode->hdisplay, mode->hsync_start,
+	    mode->hsync_end, mode->htotal,
+	    mode->vdisplay, mode->vsync_start,
+	    mode->vsync_end, mode->vtotal,
+	    mode->type, mode->flags);
+
+	index = drm_crtc_index(crtc);
+	div = (uint32_t)clk_get_rate(fsl_dev->clk) / crtc->mode.clock /
+1000;
+
+	/* Configure timings: */
+	hbp = mode->htotal - mode->hsync_end;
+	hfp = mode->hsync_start - mode->hdisplay;
+	hsw = mode->hsync_end - mode->hsync_start;
+	vbp = mode->vtotal - mode->vsync_end;
+	vfp = mode->vsync_start - mode->vdisplay;
+	vsw = mode->vsync_end - mode->vsync_start;
+
+	regmap_write(fsl_dev->regmap, DCU_HSYN_PARA,
+		     DCU_HSYN_PARA_BP(hbp) |
+		     DCU_HSYN_PARA_PW(hsw) |
+		     DCU_HSYN_PARA_FP(hfp));
+	regmap_write(fsl_dev->regmap, DCU_VSYN_PARA,
+		     DCU_VSYN_PARA_BP(vbp) |
+		     DCU_VSYN_PARA_PW(vsw) |
+		     DCU_VSYN_PARA_FP(vfp));
+	regmap_write(fsl_dev->regmap, DCU_DISP_SIZE,
+		     DCU_DISP_SIZE_DELTA_Y(mode->vdisplay) |
+		     DCU_DISP_SIZE_DELTA_X(mode->hdisplay));
+	regmap_write(fsl_dev->regmap, DCU_CTRLDESCLN_1(index),
+		     DCU_CTRLDESCLN_1_HEIGHT(mode->vdisplay) |
+		     DCU_CTRLDESCLN_1_WIDTH(mode->hdisplay));
+	regmap_write(fsl_dev->regmap, DCU_CTRLDESCLN_2(index),
+		     DCU_CTRLDESCLN_2_POSY(y) |
+		     DCU_CTRLDESCLN_2_POSX(x));
+	regmap_write(fsl_dev->regmap, DCU_DIV_RATIO, div);
+	regmap_write(fsl_dev->regmap, DCU_UPDATE_MODE,

drivers/gpu/drm/fsl/fsl_dcu_drm_crtc.c

Quoted 10 lines
drivers/gpu/drm/fsl/fsl_dcu_drm_crtc.c new file +10 -0
+DCU_UPDATE_MODE_READREG);
+
+	return 0;
+}
+
+static void fsl_dcu_drm_crtc_mode_commit(struct drm_crtc *crtc) {
+		fsl_dcu_drm_crtc_start(crtc);
+}
+
+static int fsl_dcu_drm_crtc_mode_set_base(struct drm_crtc *crtc, int x,

int y,

Quoted 50 lines
drivers/gpu/drm/fsl/fsl_dcu_drm_crtc.c new file +50 -0
+					  struct drm_framebuffer *old_fb) {
+	fsl_dcu_drm_crtc_update_base(crtc);
+
+	return 0;
+}
+
+static const struct drm_crtc_helper_funcs crtc_helper_funcs = {
+	.dpms = fsl_dcu_drm_crtc_dpms,
+	.mode_fixup = fsl_dcu_drm_crtc_mode_fixup,
+	.prepare = fsl_dcu_drm_crtc_mode_prepare,
+	.commit = fsl_dcu_drm_crtc_mode_commit,
+	.mode_set = fsl_dcu_drm_crtc_mode_set,
+	.mode_set_base = fsl_dcu_drm_crtc_mode_set_base, };
+
+static int fsl_dcu_drm_crtc_page_flip(struct drm_crtc *crtc,
+				      struct drm_framebuffer *fb,
+				      struct drm_pending_vblank_event *event,
+				      uint32_t page_flip_flags)
+{
+	return 0;
+}
+
+static const struct drm_plane_funcs fsl_dcu_drm_plane_funcs = {
+	.update_plane = fsl_dcu_drm_plane_update,
+	.disable_plane = fsl_dcu_drm_plane_disable,
+	.destroy = fsl_dcu_drm_plane_destroy, };
+
+static const struct drm_crtc_funcs crtc_funcs = {
+	.destroy = drm_crtc_cleanup,
+	.set_config = drm_crtc_helper_set_config,
+	.page_flip = fsl_dcu_drm_crtc_page_flip, };
+
+int fsl_dcu_drm_crtc_create(struct fsl_dcu_drm_device *fsl_dev) {
+	struct drm_crtc *crtc = &fsl_dev->crtc.crtc;
+	int ret;
+
+	fsl_dev->crtc.dpms = DRM_MODE_DPMS_OFF;
+
+	ret = drm_crtc_init(fsl_dev->ddev, crtc, &crtc_funcs);
+	if (ret < 0)
+		return ret;
+
+	crtc->primary->funcs = &fsl_dcu_drm_plane_funcs;
+
+	drm_crtc_helper_add(crtc, &crtc_helper_funcs);
+
+	regmap_write(fsl_dev->regmap, DCU_SYN_POL,
+		     DCU_SYN_POL_INV_VS_LOW | DCU_SYN_POL_INV_HS_LOW);
+	regmap_write(fsl_dev->regmap, DCU_BGND, DCU_BGND_R(0) |
+		     DCU_BGND_G(0) | DCU_BGND_B(0));

drivers/gpu/drm/fsl/fsl_dcu_drm_crtc.c

Quoted 10 lines
drivers/gpu/drm/fsl/fsl_dcu_drm_crtc.c new file +10 -0
+	regmap_write(fsl_dev->regmap, DCU_DCU_MODE,
+		     DCU_MODE_BLEND_ITER(1) | DCU_MODE_RASTER_EN);
+	regmap_write(fsl_dev->regmap, DCU_THRESHOLD,
+		     DCU_THRESHOLD_LS_BF_VS(BF_VS_VAL) |
+		     DCU_THRESHOLD_OUT_BUF_HIGH(BUF_MAX_VAL) |
+		     DCU_THRESHOLD_OUT_BUF_LOW(BUF_MIN_VAL));
+	regmap_update_bits(fsl_dev->regmap, DCU_DCU_MODE,
+			   DCU_MODE_DCU_MODE_MASK,
+			   DCU_MODE_DCU_MODE(DCU_MODE_NORMAL));
+	regmap_write(fsl_dev->regmap, DCU_UPDATE_MODE,

DCU_UPDATE_MODE_READREG);

Quoted 25 lines
drivers/gpu/drm/fsl/fsl_dcu_drm_crtc.c new file +25 -0
+	return 0;
+}
+
+/*
+ * Encoder
+ */
+
+#define to_fsl_dcu_encoder(e) \
+	container_of(e, struct fsl_dcu_drm_encoder, encoder)
+
+static void fsl_dcu_drm_encoder_dpms(struct drm_encoder *encoder, int
+mode) {
+	struct fsl_dcu_drm_encoder *fsl_enc = to_fsl_dcu_encoder(encoder);
+
+	if (fsl_enc->dpms == mode)
+		return;
+
+	fsl_enc->dpms = mode;
+}
+
+static bool fsl_dcu_drm_encoder_mode_fixup
+		(struct drm_encoder *encoder,
+		const struct drm_display_mode *mode,
+		struct drm_display_mode *adjusted_mode) {
+	struct drm_device *dev = encoder->dev;

drivers/gpu/drm/fsl/fsl_dcu_drm_crtc.c

Quoted 10 lines
drivers/gpu/drm/fsl/fsl_dcu_drm_crtc.c new file +10 -0
+	struct fsl_dcu_drm_device *fsl_dev = dev->dev_private;
+	struct drm_connector *connector = &fsl_dev->connector.connector;
+	const struct drm_display_mode *panel_mode;
+
+	if (list_empty(&connector->modes)) {
+		dev_dbg(dev->dev, "mode_fixup: empty modes list\n");
+		return false;
+	}
+
+	/* The flat panel mode is fixed, just copy it to the adjusted mode.

*/

Quoted 72 lines
drivers/gpu/drm/fsl/fsl_dcu_drm_crtc.c new file +72 -0
+	panel_mode = list_first_entry(&connector->modes,
+				      struct drm_display_mode, head);
+	drm_mode_copy(adjusted_mode, panel_mode);
+
+	return true;
+}
+
+static void fsl_dcu_drm_encoder_mode_prepare(struct drm_encoder
+*encoder) { }
+
+static void fsl_dcu_drm_encoder_mode_set(struct drm_encoder *encoder,
+					 struct drm_display_mode *mode,
+					 struct drm_display_mode *adjusted_mode) { }
+
+static void fsl_dcu_drm_encoder_mode_commit(struct drm_encoder
+*encoder) {
+	;
+}
+
+static const struct drm_encoder_helper_funcs encoder_helper_funcs = {
+	.dpms = fsl_dcu_drm_encoder_dpms,
+	.mode_fixup = fsl_dcu_drm_encoder_mode_fixup,
+	.prepare = fsl_dcu_drm_encoder_mode_prepare,
+	.commit = fsl_dcu_drm_encoder_mode_commit,
+	.mode_set = fsl_dcu_drm_encoder_mode_set, };
+
+static void fsl_dcu_drm_encoder_destroy(struct drm_encoder *encoder)
+{
+	drm_encoder_cleanup(encoder);
+}
+
+static const struct drm_encoder_funcs encoder_funcs = {
+	.destroy = fsl_dcu_drm_encoder_destroy, };
+
+int fsl_dcu_drm_encoder_create(struct fsl_dcu_drm_device *fsl_dev) {
+	struct drm_encoder *encoder = &fsl_dev->encoder.encoder;
+	int ret;
+
+	fsl_dev->encoder.dpms = DRM_MODE_DPMS_OFF;
+
+	encoder->possible_crtcs = 1;
+
+	ret = drm_encoder_init(fsl_dev->ddev, encoder, &encoder_funcs,
+			       DRM_MODE_ENCODER_LVDS);
+	if (ret < 0)
+		return ret;
+
+	drm_encoder_helper_add(encoder, &encoder_helper_funcs);
+
+	return 0;
+}
+
+/*
+ * Connector
+ */
+
+#define to_fsl_dcu_connector(c) \
+	container_of(c, struct fsl_dcu_drm_connector, connector)
+
+static int fsl_dcu_drm_connector_get_modes(struct drm_connector
+*connector) {
+	struct drm_device *dev = connector->dev;
+	struct device_node *display_np, *np = dev->dev->of_node;
+	struct drm_display_mode *mode = drm_mode_create(connector->dev);
+	int num_modes = 0;
+
+	if (np) {
+		display_np = of_parse_phandle(np, "display", 0);
+		if (!display_np) {
+			dev_err(dev->dev, "failed to find display phandle\n");
+			return num_modes;
+		}

drivers/gpu/drm/fsl/fsl_dcu_drm_crtc.c

Quoted 10 lines
drivers/gpu/drm/fsl/fsl_dcu_drm_crtc.c new file +10 -0
+		of_get_drm_display_mode(display_np, mode, OF_USE_NATIVE_MODE);
+		mode->type |= DRM_MODE_TYPE_DRIVER | DRM_MODE_TYPE_PREFERRED,
+		drm_mode_probed_add(connector, mode);
+		num_modes++;
+	}
+
+	return num_modes;
+}
+
+static int fsl_dcu_drm_connector_mode_valid(struct drm_connector

*connector,

drivers/gpu/drm/fsl/fsl_dcu_drm_crtc.c

Quoted 13 lines
drivers/gpu/drm/fsl/fsl_dcu_drm_crtc.c new file +13 -0
+					    struct drm_display_mode *mode) {
+	return MODE_OK;
+}
+
+static struct drm_encoder *
+fsl_dcu_drm_connector_best_encoder(struct drm_connector *connector) {
+	struct fsl_dcu_drm_connector *fsl_con =
+to_fsl_dcu_connector(connector);
+
+	return fsl_con->encoder;
+}
+
+static const struct drm_connector_helper_funcs connector_helper_funcs

= {

Quoted 226 lines
drivers/gpu/drm/fsl/fsl_dcu_drm_crtc.c new file +63 -0
+	.get_modes = fsl_dcu_drm_connector_get_modes,
+	.mode_valid = fsl_dcu_drm_connector_mode_valid,
+	.best_encoder = fsl_dcu_drm_connector_best_encoder,
+};
+
+static void fsl_dcu_drm_connector_destroy(struct drm_connector
+*connector) {
+	drm_connector_unregister(connector);
+	drm_connector_cleanup(connector);
+}
+
+static enum drm_connector_status
+fsl_dcu_drm_connector_detect(struct drm_connector *connector, bool
+force) {
+	return connector_status_connected;
+}
+
+static const struct drm_connector_funcs connector_funcs = {
+	.dpms = drm_helper_connector_dpms,
+	.detect = fsl_dcu_drm_connector_detect,
+	.fill_modes = drm_helper_probe_single_connector_modes,
+	.destroy = fsl_dcu_drm_connector_destroy, };
+
+int fsl_dcu_drm_connector_create(struct fsl_dcu_drm_device *fsl_dev,
+				 struct drm_encoder *encoder)
+{
+	struct drm_connector *connector = &fsl_dev->connector.connector;
+	int ret;
+
+	fsl_dev->connector.encoder = encoder;
+
+	connector->display_info.width_mm = 0;
+	connector->display_info.height_mm = 0;
+
+	ret = drm_connector_init(fsl_dev->ddev, connector, &connector_funcs,
+				 DRM_MODE_CONNECTOR_LVDS);
+	if (ret < 0)
+		return ret;
+
+	drm_connector_helper_add(connector, &connector_helper_funcs);
+	ret = drm_connector_register(connector);
+	if (ret < 0)
+		goto err_cleanup;
+
+	ret = drm_mode_connector_attach_encoder(connector, encoder);
+	if (ret < 0)
+		goto err_sysfs;
+
+	connector->encoder = encoder;
+
+	drm_helper_connector_dpms(connector, DRM_MODE_DPMS_OFF);
+	drm_object_property_set_value
+		(&connector->base, fsl_dev->ddev->mode_config.dpms_property,
+		DRM_MODE_DPMS_OFF);
+
+	return 0;
+
+err_sysfs:
+	drm_connector_unregister(connector);
+err_cleanup:
+	drm_connector_cleanup(connector);
+	return ret;
+}
drivers/gpu/drm/fsl/fsl_dcu_drm_crtc.h new file +42 -0
new file mode 100644
index 0000000..ad59992
@@ -0,0 +1,40 @@
+/*
+ * 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_MODSET_H__
+#define __FSL_DCU_DRM_MODSET_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;
+};
+
+struct fsl_dcu_drm_encoder {
+	struct drm_encoder encoder;
+	int dpms;
+};
+
+struct fsl_dcu_drm_connector {
+	struct drm_connector connector;
+	struct drm_encoder *encoder;
+};
+
+int fsl_dcu_drm_crtc_create(struct fsl_dcu_drm_device *fsl_dev); int
+fsl_dcu_drm_encoder_create(struct fsl_dcu_drm_device *fsl_dev); int
+fsl_dcu_drm_connector_create(struct fsl_dcu_drm_device *fsl_dev,
+				 struct drm_encoder *encoder);
+
+#endif /* __FSL_DCU_DRM_MODSET_H__ */
drivers/gpu/drm/fsl/fsl_dcu_drm_drv.c new file +107 -0
new file mode 100644
index 0000000..1bca45a
@@ -0,0 +1,323 @@
+/*
+ * 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.
+ */
+
+#include <linux/clk.h>
+#include <linux/io.h>
+#include <linux/mm.h>
+#include <linux/module.h>
+#include <linux/of_platform.h>
+#include <linux/platform_device.h>
+#include <linux/pm.h>
+#include <linux/pm_runtime.h>
+#include <linux/regmap.h>
+#include <linux/slab.h>
+
+#include <drm/drmP.h>
+#include "fsl_dcu_drm_drv.h"
+#include "fsl_dcu_drm_kms.h"
+
+static int fsl_dcu_unload(struct drm_device *dev) {
+	drm_mode_config_cleanup(dev);
+	drm_vblank_cleanup(dev);
+	drm_irq_uninstall(dev);
+
+	dev->dev_private = NULL;
+
+	return 0;
+}
+
+static struct regmap_config fsl_dcu_regmap_config = {
+	.reg_bits = 32,
+	.reg_stride = 4,
+	.val_bits = 32,
+};
+
+static int fsl_dcu_bypass_tcon(struct fsl_dcu_drm_device *fsl_dev,
+			       struct device_node *np)
+{
+	struct device_node *tcon_np;
+	struct platform_device *pdev;
+	struct clk *tcon_clk;
+	struct resource *res;
+	void __iomem *base;
+
+	tcon_np = of_parse_phandle(np, "tcon-controller", 0);
+	if (!tcon_np)
+		return -EINVAL;
+
+	pdev = of_find_device_by_node(tcon_np);
+	if (!pdev)
+		return -EINVAL;
+
+	tcon_clk = devm_clk_get(&pdev->dev, "tcon");
+	if (IS_ERR(tcon_clk))
+		return PTR_ERR(tcon_clk);
+	clk_prepare_enable(tcon_clk);
+
+	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+	if (!res)
+		return -ENODEV;
+
+	base = devm_ioremap_resource(&pdev->dev, res);
+	if (IS_ERR(base))
+		return PTR_ERR(base);
+
+	fsl_dev->tcon_regmap = devm_regmap_init_mmio_clk(&pdev->dev,
+			"tcon", base, &fsl_dcu_regmap_config);
+	if (IS_ERR(fsl_dev->tcon_regmap)) {
+		dev_err(&pdev->dev, "regmap init failed\n");
+		return PTR_ERR(fsl_dev->tcon_regmap);
+	}
+
+	regmap_write(fsl_dev->tcon_regmap, TCON_CTRL1, TCON_BYPASS_ENABLE);
+	return 0;
+}
+
+static int fsl_dcu_scfg_config(struct fsl_dcu_drm_device *fsl_dev,
+			       struct device_node *np)
+{
+	struct device_node *scfg_np;
+	struct platform_device *pdev;
+	struct resource *res;
+	void __iomem *base;
+
+	scfg_np = of_parse_phandle(np, "scfg-controller", 0);
+	if (!scfg_np)
+		return 0;
+
+	pdev = of_find_device_by_node(scfg_np);
+	if (!pdev)
+		return -EINVAL;
+
+	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+	if (!res)
+		return -ENODEV;
+
+	base = devm_ioremap_resource(&pdev->dev, res);
+	if (IS_ERR(base))

drivers/gpu/drm/fsl/fsl_dcu_drm_drv.c line 117

Quoted 10 lines
drivers/gpu/drm/fsl/fsl_dcu_drm_drv.c new file +10 -0
+		return PTR_ERR(base);
+
+	fsl_dev->scfg_regmap = devm_regmap_init_mmio_clk(&pdev->dev,
+			NULL, base, &fsl_dcu_regmap_config);
+	if (IS_ERR(fsl_dev->scfg_regmap)) {
+		dev_err(&pdev->dev, "regmap init failed\n");
+		return PTR_ERR(fsl_dev->scfg_regmap);
+	}
+
+	regmap_write(fsl_dev->scfg_regmap, 0x28, 0x80000000);

What does this actually do? I don't think this exists in Vybrid, but I guess we could easily make the property optional which would then not call this function...

--
Stefan

Quoted 43 lines
drivers/gpu/drm/fsl/fsl_dcu_drm_drv.c new file +43 -0
+
+	return 0;
+}
+
+static int fsl_dcu_load(struct drm_device *dev, unsigned long flags)
+{
+	struct platform_device *pdev = dev->platformdev;
+	struct fsl_dcu_drm_device *fsl_dev;
+	struct resource *res;
+	void __iomem *base;
+	int ret;
+
+	fsl_dev = devm_kzalloc(&pdev->dev, sizeof(*fsl_dev), GFP_KERNEL);
+	if (!fsl_dev)
+		return -ENOMEM;
+
+	fsl_dev->dev = &pdev->dev;
+	fsl_dev->ddev = dev;
+	dev->dev_private = fsl_dev;
+
+	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+	base = devm_ioremap_resource(&pdev->dev, res);
+	if (IS_ERR(base)) {
+		ret = PTR_ERR(base);
+		return ret;
+	}
+
+	fsl_dev->regmap = devm_regmap_init_mmio(&pdev->dev,
+			base, &fsl_dcu_regmap_config);
+	if (IS_ERR(fsl_dev->regmap)) {
+		dev_err(&pdev->dev, "regmap init failed\n");
+		return PTR_ERR(fsl_dev->regmap);
+	}
+
+	ret = fsl_dcu_drm_modeset_init(fsl_dev);
+	if (ret < 0) {
+		dev_err(&pdev->dev, "failed to initialize mode setting\n");
+		return ret;
+	}
+
+	ret = drm_vblank_init(dev, 1);
+	if (ret < 0) {
+		dev_err(&pdev->dev, "failed to initialize vblank\n");

drivers/gpu/drm/fsl/fsl_dcu_drm_drv.c

Quoted 10 lines
drivers/gpu/drm/fsl/fsl_dcu_drm_drv.c new file +10 -0
+		goto done;
+	}
+
+	ret = drm_irq_install(dev, platform_get_irq(dev->platformdev, 0));
+	if (ret < 0) {
+		dev_err(&pdev->dev, "failed to install IRQ handler\n");
+		goto done;
+	}
+
+	/* Put TCON in bypass mode, so the input signals from DCU are

passed

Quoted 397 lines
drivers/gpu/drm/fsl/fsl_dcu_drm_drv.c new file +148 -0
+	 * through TCON unchanged */
+	fsl_dcu_bypass_tcon(fsl_dev, pdev->dev.of_node);
+	fsl_dcu_scfg_config(fsl_dev, pdev->dev.of_node);
+
+	fsl_dev->clk = devm_clk_get(&pdev->dev, "dcfb");
+	if (IS_ERR(fsl_dev->clk)) {
+		ret = PTR_ERR(fsl_dev->clk);
+		dev_err(&pdev->dev, "could not get clock\n");
+		return ret;
+	}
+	clk_prepare_enable(fsl_dev->clk);
+
+	dev_set_drvdata(dev->dev, fsl_dev);
+
+	fsl_dcu_fbdev_init(dev);
+
+	return 0;
+done:
+	if (ret)
+		fsl_dcu_unload(dev);
+
+	return ret;
+}
+
+static void fsl_dcu_drm_preclose(struct drm_device *dev, struct
+drm_file *file) {
+	;
+}
+
+static irqreturn_t fsl_dcu_drm_irq(int irq, void *arg) {
+	return IRQ_HANDLED;
+}
+
+static int fsl_dcu_drm_enable_vblank(struct drm_device *dev, int
+crtc) {
+	return 0;
+}
+
+static void fsl_dcu_drm_disable_vblank(struct drm_device *dev, int
+crtc) {
+	;
+}
+
+static const struct file_operations fsl_dcu_drm_fops = {
+	.owner		= THIS_MODULE,
+	.open		= drm_open,
+	.release	= drm_release,
+	.unlocked_ioctl	= drm_ioctl,
+#ifdef CONFIG_COMPAT
+	.compat_ioctl	= drm_compat_ioctl,
+#endif
+	.poll		= drm_poll,
+	.read		= drm_read,
+	.llseek		= no_llseek,
+	.mmap		= drm_gem_cma_mmap,
+};
+
+static struct drm_driver fsl_dcu_drm_driver = {
+	.driver_features	= DRIVER_HAVE_IRQ | DRIVER_GEM | DRIVER_MODESET
+				| DRIVER_PRIME,
+	.load			= fsl_dcu_load,
+	.unload			= fsl_dcu_unload,
+	.preclose		= fsl_dcu_drm_preclose,
+	.irq_handler		= fsl_dcu_drm_irq,
+	.get_vblank_counter	= drm_vblank_count,
+	.enable_vblank		= fsl_dcu_drm_enable_vblank,
+	.disable_vblank		= fsl_dcu_drm_disable_vblank,
+	.gem_free_object	= drm_gem_cma_free_object,
+	.gem_vm_ops		= &drm_gem_cma_vm_ops,
+	.prime_handle_to_fd	= drm_gem_prime_handle_to_fd,
+	.prime_fd_to_handle	= drm_gem_prime_fd_to_handle,
+	.gem_prime_import	= drm_gem_prime_import,
+	.gem_prime_export	= drm_gem_prime_export,
+	.gem_prime_get_sg_table	= drm_gem_cma_prime_get_sg_table,
+	.gem_prime_import_sg_table = drm_gem_cma_prime_import_sg_table,
+	.gem_prime_vmap		= drm_gem_cma_prime_vmap,
+	.gem_prime_vunmap	= drm_gem_cma_prime_vunmap,
+	.gem_prime_mmap		= drm_gem_cma_prime_mmap,
+	.dumb_create		= drm_gem_cma_dumb_create,
+	.dumb_map_offset	= drm_gem_cma_dumb_map_offset,
+	.dumb_destroy		= drm_gem_dumb_destroy,
+	.fops			= &fsl_dcu_drm_fops,
+	.name			= "fsl-dcu-drm",
+	.desc			= "Freescale DCU DRM",
+	.date			= "20150213",
+	.major			= 1,
+	.minor			= 0,
+};
+
+#ifdef CONFIG_PM_SLEEP
+static int fsl_dcu_drm_pm_suspend(struct device *dev) {
+	struct fsl_dcu_drm_device *fsl_dev = dev_get_drvdata(dev);
+
+	drm_kms_helper_poll_disable(fsl_dev->ddev);
+	fsl_dcu_drm_crtc_suspend(&fsl_dev->crtc);
+
+	return 0;
+}
+
+static int fsl_dcu_drm_pm_resume(struct device *dev) {
+	struct fsl_dcu_drm_device *fsl_dev = dev_get_drvdata(dev);
+
+	drm_modeset_lock_all(fsl_dev->ddev);
+	fsl_dcu_drm_crtc_resume(&fsl_dev->crtc);
+	drm_modeset_unlock_all(fsl_dev->ddev);
+
+	drm_kms_helper_poll_enable(fsl_dev->ddev);
+	return 0;
+}
+#endif
+
+static const struct dev_pm_ops fsl_dcu_drm_pm_ops = {
+	SET_SYSTEM_SLEEP_PM_OPS(fsl_dcu_drm_pm_suspend,
+fsl_dcu_drm_pm_resume) };
+
+static int fsl_dcu_drm_probe(struct platform_device *pdev) {
+	return drm_platform_init(&fsl_dcu_drm_driver, pdev); }
+
+static int fsl_dcu_drm_remove(struct platform_device *pdev) {
+	struct fsl_dcu_drm_device *fsl_dev = platform_get_drvdata(pdev);
+
+	drm_put_dev(fsl_dev->ddev);
+
+	return 0;
+}
+
+static struct of_device_id fsl_dcu_of_match[] = {
+		{ .compatible = "fsl,ls1021a-dcfb", },
+		{ },
+};
+MODULE_DEVICE_TABLE(of, fsl_dcu_of_match);
+
+static struct platform_driver fsl_dcu_drm_platform_driver = {
+	.probe		= fsl_dcu_drm_probe,
+	.remove		= fsl_dcu_drm_remove,
+	.driver		= {
+		.owner	= THIS_MODULE,
+		.name	= "fsl,ls1021a-dcfb",
+		.pm	= &fsl_dcu_drm_pm_ops,
+		.of_match_table = fsl_dcu_of_match,
+	},
+};
+
+module_platform_driver(fsl_dcu_drm_platform_driver);
+
+MODULE_ALIAS("platform:fsl-dcu-drm");
+MODULE_DESCRIPTION("Freescale DCU DRM Driver");
+MODULE_LICENSE("GPL");
drivers/gpu/drm/fsl/fsl_dcu_drm_drv.h new file +168 -0
new file mode 100644
index 0000000..8dc7c10
@@ -0,0 +1,167 @@
+/*
+ * 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_DRV_H__
+#define __FSL_DCU_DRM_DRV_H__
+
+#include <linux/kernel.h>
+#include <linux/spinlock.h>
+#include <stddef.h>
+#include <drm/drm.h>
+#include <drm/drmP.h>
+#include <drm/drm_fb_helper.h>
+#include <drm/drm_crtc_helper.h>
+#include <drm/drm_gem_cma_helper.h>
+#include <drm/drm_fb_cma_helper.h>
+
+#include "fsl_dcu_drm_crtc.h"
+#define DRIVER_NAME			"fsl-dcu-fb"
+
+#define DCU_DCU_MODE			0x0010
+#define DCU_MODE_BLEND_ITER(x)		((x) << 20)
+#define DCU_MODE_RASTER_EN		BIT(14)
+#define DCU_MODE_DCU_MODE(x)		(x)
+#define DCU_MODE_DCU_MODE_MASK		0x03
+#define DCU_MODE_OFF			0
+#define DCU_MODE_NORMAL			1
+#define DCU_MODE_TEST			2
+#define DCU_MODE_COLORBAR		3
+
+#define DCU_BGND			0x0014
+#define DCU_BGND_R(x)			((x) << 16)
+#define DCU_BGND_G(x)			((x) << 8)
+#define DCU_BGND_B(x)			(x)
+
+#define DCU_DISP_SIZE			0x0018
+#define DCU_DISP_SIZE_DELTA_Y(x)	((x) << 16)
+/*Regisiter value 1/16 of horizontal resolution*/
+#define DCU_DISP_SIZE_DELTA_X(x)	((x) >> 4)
+
+#define DCU_HSYN_PARA			0x001c
+#define DCU_HSYN_PARA_BP(x)		((x) << 22)
+#define DCU_HSYN_PARA_PW(x)		((x) << 11)
+#define DCU_HSYN_PARA_FP(x)		(x)
+
+#define DCU_VSYN_PARA			0x0020
+#define DCU_VSYN_PARA_BP(x)		((x) << 22)
+#define DCU_VSYN_PARA_PW(x)		((x) << 11)
+#define DCU_VSYN_PARA_FP(x)		(x)
+
+#define DCU_SYN_POL			0x0024
+#define DCU_SYN_POL_INV_PXCK_FALL	(0 << 6)
+#define DCU_SYN_POL_NEG_REMAIN		(0 << 5)
+#define DCU_SYN_POL_INV_VS_LOW		BIT(1)
+#define DCU_SYN_POL_INV_HS_LOW		(1)
+
+#define DCU_THRESHOLD			0x0028
+#define DCU_THRESHOLD_LS_BF_VS(x)	((x) << 16)
+#define DCU_THRESHOLD_OUT_BUF_HIGH(x)	((x) << 8)
+#define DCU_THRESHOLD_OUT_BUF_LOW(x)	(x)
+#define BF_VS_VAL			0x03
+#define BUF_MAX_VAL			0x78
+#define BUF_MIN_VAL			0x0a
+
+#define DCU_INT_STATUS			0x002C
+#define DCU_INT_STATUS_UNDRUN		BIT(1)
+
+#define DCU_INT_MASK			0x0030
+#define DCU_INT_MASK_UNDRUN		BIT(1)
+#define DCU_INT_MASK_VBLANK		BIT(3)
+
+#define DCU_DIV_RATIO			0x0054
+
+#define DCU_UPDATE_MODE			0x00cc
+#define DCU_UPDATE_MODE_MODE		BIT(31)
+#define DCU_UPDATE_MODE_READREG		BIT(30)
+
+#define DCU_DCFB_MAX			0x300
+
+#define DCU_CTRLDESCLN_1(x)		(0x200 + (x) * 0x40)
+#define DCU_CTRLDESCLN_1_HEIGHT(x)	((x) << 16)
+#define DCU_CTRLDESCLN_1_WIDTH(x)	(x)
+
+#define DCU_CTRLDESCLN_2(x)		(0x204 + (x) * 0x40)
+#define DCU_CTRLDESCLN_2_POSY(x)	((x) << 16)
+#define DCU_CTRLDESCLN_2_POSX(x)	(x)
+
+#define DCU_CTRLDESCLN_3(x)		(0x208 + (x) * 0x40)
+
+#define DCU_CTRLDESCLN_4(x)		(0x20c + (x) * 0x40)
+#define DCU_CTRLDESCLN_4_EN		BIT(31)
+#define DCU_CTRLDESCLN_4_TILE_EN	BIT(30)
+#define DCU_CTRLDESCLN_4_DATA_SEL_CLUT	BIT(29)
+#define DCU_CTRLDESCLN_4_SAFETY_EN	BIT(28)
+#define DCU_CTRLDESCLN_4_TRANS(x)	((x) << 20)
+#define DCU_CTRLDESCLN_4_BPP(x)		((x) << 16)
+#define DCU_CTRLDESCLN_4_RLE_EN		BIT(15)
+#define DCU_CTRLDESCLN_4_LUOFFS(x)	((x) << 4)
+#define DCU_CTRLDESCLN_4_BB_ON		BIT(2)
+#define DCU_CTRLDESCLN_4_AB(x)		(x)
+
+#define DCU_CTRLDESCLN_5(x)		(0x210 + (x) * 0x40)
+#define DCU_CTRLDESCLN_5_CKMAX_R(x)	((x) << 16)
+#define DCU_CTRLDESCLN_5_CKMAX_G(x)	((x) << 8)
+#define DCU_CTRLDESCLN_5_CKMAX_B(x)	(x)
+
+#define DCU_CTRLDESCLN_6(x)		(0x214 + (x) * 0x40)
+#define DCU_CTRLDESCLN_6_CKMIN_R(x)	((x) << 16)
+#define DCU_CTRLDESCLN_6_CKMIN_G(x)	((x) << 8)
+#define DCU_CTRLDESCLN_6_CKMIN_B(x)	(x)
+
+#define DCU_CTRLDESCLN_7(x)		(0x218 + (x) * 0x40)
+#define DCU_CTRLDESCLN_7_TILE_VER(x)	((x) << 16)
+#define DCU_CTRLDESCLN_7_TILE_HOR(x)	(x)
+
+#define DCU_CTRLDESCLN_8(x)		(0x21c + (x) * 0x40)
+#define DCU_CTRLDESCLN_8_FG_FCOLOR(x)	(x)
+
+#define DCU_CTRLDESCLN_9(x)		(0x220 + (x) * 0x40)
+#define DCU_CTRLDESCLN_9_BG_BCOLOR(x)	(x)
+
+#define DCU_CTRLDESCLN_10(x)		(0x224 + (x) * 0x40)
+#define DCU_CTRLDESCLN_10_POST_SKIP(x)	((x) << 16)
+#define DCU_CTRLDESCLN_10_PRE_SKIP(x)	(x)
+
+#define FSL_DCU_RGB565			4
+#define FSL_DCU_RGB888			5
+#define FSL_DCU_ARGB8888		6
+#define FSL_DCU_ARGB1555		11
+#define FSL_DCU_ARGB4444		12
+#define FSL_DCU_YUV422			14
+
+#define TCON_CTRL1			0x0000
+#define TCON_BYPASS_ENABLE		BIT(29)
+
+#define DBG(fmt, ...) DRM_DEBUG(fmt"\n", ##__VA_ARGS__)
+
+struct clk;
+struct device;
+struct drm_device;
+
+struct fsl_dcu_drm_device {
+	struct device *dev;
+	struct regmap *regmap;
+	struct regmap *tcon_regmap;
+	struct regmap *scfg_regmap;
+	unsigned int irq;
+	struct clk *clk;
+	/*protects hardware register*/
+	spinlock_t irq_lock;
+	struct drm_device *ddev;
+	struct drm_fbdev_cma *fbdev;
+	struct fsl_dcu_drm_crtc crtc;
+	struct fsl_dcu_drm_encoder encoder;
+	struct fsl_dcu_drm_connector connector; };
+
+void fsl_dcu_fbdev_init(struct drm_device *dev);
+
+#endif /* __FSL_DCU_DRM_DRV_H__ */
drivers/gpu/drm/fsl/fsl_dcu_drm_fbdev.c new file +46 -0
new file mode 100644
index 0000000..6729f92
@@ -0,0 +1,43 @@
+/*
+ * 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_crtc.h>
+#include <drm/drm_fb_helper.h>
+#include <drm/drm_crtc_helper.h>
+#include <drm/drm_fb_cma_helper.h>
+#include <drm/drm_gem_cma_helper.h>
+#include <linux/clk.h>
+#include <linux/delay.h>
+#include <linux/dma-mapping.h>
+#include <linux/fb.h>
+#include <linux/interrupt.h>
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/of_platform.h>
+#include <linux/regmap.h>
+#include <video/of_display_timing.h>
+#include <video/videomode.h>
+#include <linux/uaccess.h>
+
+#include "fsl_dcu_drm_drv.h"
+#include "fsl_dcu_drm_crtc.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 +14 -0
new file mode 100644
index 0000000..0eb0652
@@ -0,0 +1,45 @@
+/*
+ * 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.
+ */
+
+#include <drm/drmP.h>

drivers/gpu/drm/fsl/fsl_dcu_drm_kms.c line 24

Quoted 10 lines
drivers/gpu/drm/fsl/fsl_dcu_drm_kms.c new file +10 -0
+#include <drm/drm_crtc.h>
+#include <drm/drm_crtc_helper.h>
+#include <drm/drm_fb_cma_helper.h>
+#include <drm/drm_gem_cma_helper.h>
+
+#include "fsl_dcu_drm_crtc.h"
+#include "fsl_dcu_drm_drv.h"
+#include "fsl_dcu_drm_kms.h"
+
+static const struct drm_mode_config_funcs

fsl_dcu_drm_mode_config_funcs = {

Quoted 146 lines
drivers/gpu/drm/fsl/fsl_dcu_drm_kms.c new file +22 -0
+	.fb_create = drm_fb_cma_create,
+};
+
+int fsl_dcu_drm_modeset_init(struct fsl_dcu_drm_device *fsl_dev) {
+	drm_mode_config_init(fsl_dev->ddev);
+
+	fsl_dev->ddev->mode_config.min_width = 0;
+	fsl_dev->ddev->mode_config.min_height = 0;
+	fsl_dev->ddev->mode_config.max_width = 2031;
+	fsl_dev->ddev->mode_config.max_height = 2047;
+	fsl_dev->ddev->mode_config.funcs = &fsl_dcu_drm_mode_config_funcs;
+
+	fsl_dcu_drm_crtc_create(fsl_dev);
+	fsl_dcu_drm_encoder_create(fsl_dev);
+	fsl_dcu_drm_connector_create(fsl_dev, &fsl_dev->encoder.encoder);
+
+	drm_kms_helper_poll_init(fsl_dev->ddev);
+
+	drm_helper_disable_unused_functions(fsl_dev->ddev);
+
+	return 0;
+}
drivers/gpu/drm/fsl/fsl_dcu_drm_kms.h new file +24 -0
new file mode 100644
index 0000000..9d5b798
@@ -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_DRM_KMS_H__
+#define __FSL_DCU_DRM_KMS_H__
+
+#include <linux/types.h>
+
+struct drm_gem_cma_object;
+struct fsl_dcu_drm_device;
+
+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 +65 -0
new file mode 100644
index 0000000..d725594
@@ -0,0 +1,124 @@
+/*
+ * 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.
+ */
+
+#include <drm/drmP.h>
+#include <drm/drm_crtc.h>
+#include <drm/drm_crtc_helper.h>
+#include <drm/drm_fb_cma_helper.h>
+#include <drm/drm_gem_cma_helper.h>
+#include <linux/regmap.h>
+
+#include "fsl_dcu_drm_drv.h"
+#include "fsl_dcu_drm_kms.h"
+#include "fsl_dcu_drm_plane.h"
+
+static void __fsl_dcu_drm_plane_setup(struct drm_plane *plane,
+				      struct drm_framebuffer *fb) {
+	struct fsl_dcu_drm_device *fsl_dev = plane->dev->dev_private;
+	u32 plane_num = 0, alpha, bpp;
+	struct drm_gem_cma_object *gem;
+
+	while (plane->possible_crtcs >> 1)
+		plane_num++;
+
+	gem = drm_fb_cma_get_gem_obj(fb, 0);
+
+	switch (fb->pixel_format) {
+	case DRM_FORMAT_RGB565:
+		bpp = FSL_DCU_RGB565;
+		alpha = 0xff;
+		break;
+	case DRM_FORMAT_RGB888:
+		bpp = FSL_DCU_RGB888;
+		alpha = 0xff;
+		break;
+	case DRM_FORMAT_ARGB8888:
+		bpp = FSL_DCU_ARGB8888;
+		alpha = 0xff;
+		break;
+	case DRM_FORMAT_BGRA4444:
+		bpp = FSL_DCU_ARGB4444;
+		alpha = 0xff;
+		break;
+	case DRM_FORMAT_ARGB1555:
+		bpp = FSL_DCU_ARGB1555;
+		alpha = 0xff;
+		break;
+	case DRM_FORMAT_YUV422:
+		bpp = FSL_DCU_YUV422;
+		alpha = 0xff;
+		break;
+	default:
+		return;
+	}
+
+	regmap_write(fsl_dev->regmap, DCU_CTRLDESCLN_3(plane_num), gem-

paddr);

drivers/gpu/drm/fsl/fsl_dcu_drm_plane.c new file +20 -0
+	regmap_write(fsl_dev->regmap, DCU_CTRLDESCLN_4(plane_num),
+		     DCU_CTRLDESCLN_4_EN |
+		     DCU_CTRLDESCLN_4_TRANS(alpha) |
+		     DCU_CTRLDESCLN_4_BPP(bpp) |
+		     DCU_CTRLDESCLN_4_AB(2));
+	regmap_write(fsl_dev->regmap, DCU_CTRLDESCLN_5(plane_num),
+		     DCU_CTRLDESCLN_5_CKMAX_R(0xFF) |
+		     DCU_CTRLDESCLN_5_CKMAX_G(0xFF) |
+		     DCU_CTRLDESCLN_5_CKMAX_B(0xFF));
+	regmap_write(fsl_dev->regmap, DCU_CTRLDESCLN_6(plane_num),
+		     DCU_CTRLDESCLN_6_CKMIN_R(0) |
+		     DCU_CTRLDESCLN_6_CKMIN_G(0) |
+		     DCU_CTRLDESCLN_6_CKMIN_B(0));
+	regmap_write(fsl_dev->regmap, DCU_CTRLDESCLN_8(plane_num),
+		     DCU_CTRLDESCLN_8_FG_FCOLOR(0));
+	regmap_write(fsl_dev->regmap, DCU_CTRLDESCLN_9(plane_num),
+		     DCU_CTRLDESCLN_9_BG_BCOLOR(0));
+	regmap_write(fsl_dev->regmap, DCU_CTRLDESCLN_10(plane_num),
+		     DCU_CTRLDESCLN_10_POST_SKIP(0) |
+		     DCU_CTRLDESCLN_10_PRE_SKIP(0));

drivers/gpu/drm/fsl/fsl_dcu_drm_plane.c

Quoted 10 lines
drivers/gpu/drm/fsl/fsl_dcu_drm_plane.c new file +10 -0
+	regmap_write(fsl_dev->regmap, DCU_UPDATE_MODE,
+DCU_UPDATE_MODE_READREG); }
+
+void fsl_dcu_drm_plane_setup(struct drm_plane *plane) {
+	if (!plane->fb)
+		return;
+
+	__fsl_dcu_drm_plane_setup(plane, plane->fb); }
+
+int fsl_dcu_drm_plane_update(struct drm_plane *plane, struct drm_crtc

*crtc,

Quoted 62 lines
drivers/gpu/drm/fsl/fsl_dcu_drm_plane.c new file +25 -0
+			     struct drm_framebuffer *fb, int crtc_x, int crtc_y,
+			    unsigned int crtc_w, unsigned int crtc_h,
+			    uint32_t src_x, uint32_t src_y,
+			    uint32_t src_w, uint32_t src_h) {
+	__fsl_dcu_drm_plane_setup(plane, fb);
+	return 0;
+}
+
+int fsl_dcu_drm_plane_disable(struct drm_plane *plane) {
+	return 0;
+}
+
+void fsl_dcu_drm_plane_destroy(struct drm_plane *plane) {
+	fsl_dcu_drm_plane_disable(plane);
+	drm_plane_cleanup(plane);
+}
+
+static const uint32_t formats[] = {
+	DRM_FORMAT_RGB565,
+	DRM_FORMAT_RGB888,
+	DRM_FORMAT_ARGB8888,
+	DRM_FORMAT_ARGB4444,
+	DRM_FORMAT_ARGB1555,
+	DRM_FORMAT_YUV422,
+};
drivers/gpu/drm/fsl/fsl_dcu_drm_plane.h new file +30 -0
new file mode 100644
index 0000000..da88d1c
@@ -0,0 +1,28 @@
+/*
+ * 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;
+
+void fsl_dcu_drm_plane_setup(struct drm_plane *plane); int
+fsl_dcu_drm_plane_update(struct drm_plane *plane,
+			     struct drm_crtc *crtc,
+			     struct drm_framebuffer *fb,
+			     int crtc_x, int crtc_y,
+			     unsigned int crtc_w, unsigned int crtc_h,
+			     uint32_t src_x, uint32_t src_y,
+			     uint32_t src_w, uint32_t src_h); int
+fsl_dcu_drm_plane_disable(struct drm_plane *plane); void
+fsl_dcu_drm_plane_destroy(struct drm_plane *plane);
+
+#endif /* __FSL_DCU_DRM_PLANE_H__ */
#11 lore raw
In reply to Stefan Agner

Hi Stefan,

I have tested recently, this driver also works on Vybrid twr board. I send V3 patches just now, Please help test it on Vybrid board if necessary.

Regards,

Jianwei

Quoted 1,462 lines

-----Original Message-----
From: Stefan Agner [mailto:[email protected]]
Sent: Wednesday, March 04, 2015 11:04 PM
To: Wang Jianwei-B52261
Cc: [email protected]; [email protected]; Wood Scott- B07421; Xiubo Li; Wang Huan-B18965; [email protected]; linux- [email protected]
Subject: Re: [PATCH 1/3] drm/layerscape: Add fsl dcu DRM driver

Quoted 9 lines · Jianwei Wang

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

2D-ACE is a Freescale display controller. It supports at most four plane and provide an hardware cursor.

This is a simplified version, only a primary plane, a fb created for fbdev, a crtc, a connector for TFT LCD panel, an encoder, and the encoder is not in use. Now this drver support fbdev only.

Hi,

Do you know if that driver also works on Vybrid devices? Vybrid has also DCU4 module with 2D-ACE functionality, also the registers look pretty similar. I was thinking about creating a driver for Vybrid anyway...

Some remarks below...

Quoted 11 lines
---
 .../devicetree/bindings/video/fsl,dcfb.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_crtc.c             | 412

+++++++++++++++++++++

Quoted 2 lines
 drivers/gpu/drm/fsl/fsl_dcu_drm_crtc.h             |  40 ++
 drivers/gpu/drm/fsl/fsl_dcu_drm_drv.c              | 323

++++++++++++++++

Quoted 28 lines
 drivers/gpu/drm/fsl/fsl_dcu_drm_drv.h              | 167 +++++++++
 drivers/gpu/drm/fsl/fsl_dcu_drm_fbdev.c            |  43 +++
 drivers/gpu/drm/fsl/fsl_dcu_drm_kms.c              |  45 +++
 drivers/gpu/drm/fsl/fsl_dcu_drm_kms.h              |  22 ++
 drivers/gpu/drm/fsl/fsl_dcu_drm_plane.c            | 124 +++++++
 drivers/gpu/drm/fsl/fsl_dcu_drm_plane.h            |  28 ++
 14 files changed, 1281 insertions(+)
 create mode 100644
Documentation/devicetree/bindings/video/fsl,dcfb.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_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/video/fsl,dcfb.txt new file +0 -0
new file mode 100644
index 0000000..de7da97

Documentation/devicetree/bindings/video/fsl,dcfb.txt line 1

Quoted 1 line
Documentation/devicetree/bindings/video/fsl,dcfb.txt new file +1 -0
@@ -0,0 +1,50 @@
+* Freescale Simple Display Controller FB Driver

"FB Driver" probably refers more to a fbdev driver in the Linux kernel sense, but since this is a DRM driver this is somewhat confusing. The binding should describe the hardware, in the Vybrid RM mentions the IP as "Display Control Unit (DCU4)", so maybe

Freescale Display Controller Unit (DCU4) module

Also, instead of using dcfb, I would use somewhat more hardware describing, e.g. dcu4?

Documentation/devicetree/bindings/video/fsl,dcfb.txt line 4

Quoted 3 lines
Documentation/devicetree/bindings/video/fsl,dcfb.txt new file +3 -0
+
+Required properties:
+- compatible:		Should be one of "fsl,ls1021a-dcfb".

If the driver also works for Vybrid, be favorable to have a generic compatible string, e.g. fsl,dcu4?

Quoted 5 lines
Documentation/devicetree/bindings/video/fsl,dcfb.txt new file +5 -0
+- reg:			Address and length of the register set for dcfb.
+- clocks:		From common clock binding: handle to dcfb clock.
+- clock-names:		From common clock binding: Shall be "dcfb".
+- display:		The phandle to display node.
+

Documentation/devicetree/bindings/video/fsl,dcfb.txt

Quoted 10 lines
Documentation/devicetree/bindings/video/fsl,dcfb.txt new file +10 -0
+Optional properties:
+- scfg-controller:	The phandle of scfg 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.

Quoted 120 lines
Documentation/devicetree/bindings/video/fsl,dcfb.txt new file +31 -0
+
+Examples:
+dcfb: dcfb@2ce0000 {
+	compatible = "fsl,ls1021a-dcfb";
+	reg = <0x0 0x2ce0000 0x0 0x10000>;
+	clocks = <&platform_clk 0>;
+	clock-names = "dcfb";
+	scfg-controller = <&scfg>;
+	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 index renamed from drivers/gpu/drm/Kconfig +0 -0

151a050..a6957aa 100644

drivers/gpu/drm/Kconfig +2 -0
@@ -199,6 +199,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 index renamed from drivers/gpu/drm/Makefile +0 -0

2c239b9..ab5b9ef 100644

drivers/gpu/drm/Makefile +1 -0
@@ -56,6 +56,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.
(quoted diff) +0 -0

b/drivers/gpu/drm/fsl/Makefile new file mode 100644 index 0000000..51c3e1f

drivers/gpu/drm/fsl/Makefile new file +7 -0
@@ -0,0 +1,7 @@
+fsl-dcu-drm-y := fsl_dcu_drm_drv.o \
+	       fsl_dcu_drm_kms.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_crtc.c new file +22 -0
new file mode 100644
index 0000000..9f5ba86
@@ -0,0 +1,412 @@
+/*
+ * 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.
+ */
+
+#include <linux/backlight.h>
+#include <linux/clk.h>
+#include <linux/regmap.h>
+
+#include <drm/drmP.h>
+#include <drm/drm_atomic_helper.h>
+#include <drm/drm_crtc.h>
+#include <drm/drm_crtc_helper.h>
+#include <drm/drm_fb_cma_helper.h>

drivers/gpu/drm/fsl/fsl_dcu_drm_crtc.c line 32

Quoted 10 lines
drivers/gpu/drm/fsl/fsl_dcu_drm_crtc.c new file +10 -0
+#include <drm/drm_gem_cma_helper.h>
+#include <drm/drm_plane_helper.h>
+#include <video/of_display_timing.h>
+
+#include "fsl_dcu_drm_crtc.h"
+#include "fsl_dcu_drm_drv.h"
+#include "fsl_dcu_drm_kms.h"
+#include "fsl_dcu_drm_plane.h"
+
+#define to_fsl_dcu_crtc(c)	container_of(c, struct fsl_dcu_drm_crtc,

crtc)

Quoted 95 lines
drivers/gpu/drm/fsl/fsl_dcu_drm_crtc.c new file +95 -0
+
+static void fsl_dcu_drm_crtc_start(struct drm_crtc *crtc) {
+	fsl_dcu_drm_plane_setup(crtc->primary);
+}
+
+static void fsl_dcu_drm_crtc_stop(struct drm_crtc *crtc) { }
+
+void fsl_dcu_drm_crtc_suspend(struct drm_crtc *crtc) {
+	fsl_dcu_drm_crtc_stop(crtc);
+}
+
+void fsl_dcu_drm_crtc_resume(struct drm_crtc *crtc) {
+	struct fsl_dcu_drm_crtc *fsl_crtc = to_fsl_dcu_crtc(crtc);
+
+	if (fsl_crtc->dpms != DRM_MODE_DPMS_ON)
+		return;
+
+	fsl_dcu_drm_crtc_start(crtc);
+}
+
+static void fsl_dcu_drm_crtc_update_base(struct drm_crtc *crtc) { }
+
+static void fsl_dcu_drm_crtc_dpms(struct drm_crtc *crtc, int mode) {
+	struct fsl_dcu_drm_crtc *fsl_crtc = to_fsl_dcu_crtc(crtc);
+
+	if (fsl_crtc->dpms == mode)
+		return;
+
+	if (mode == DRM_MODE_DPMS_ON)
+		fsl_dcu_drm_crtc_start(crtc);
+	else
+		fsl_dcu_drm_crtc_stop(crtc);
+
+	fsl_crtc->dpms = mode;
+}
+
+static bool fsl_dcu_drm_crtc_mode_fixup(struct drm_crtc *crtc,
+					const struct drm_display_mode *mode,
+					struct drm_display_mode *adjusted_mode) {
+	return true;
+}
+
+static void fsl_dcu_drm_crtc_mode_prepare(struct drm_crtc *crtc) {
+		fsl_dcu_drm_crtc_stop(crtc);
+}
+
+static int fsl_dcu_drm_crtc_mode_set(struct drm_crtc *crtc,
+				     struct drm_display_mode *mode,
+				     struct drm_display_mode *adjusted_mode,
+				     int x, int y,
+				     struct drm_framebuffer *old_fb) {
+	struct drm_device *dev = crtc->dev;
+	struct fsl_dcu_drm_device *fsl_dev = dev->dev_private;
+	uint32_t hbp, hfp, hsw, vbp, vfp, vsw, div, index;
+
+	DBG(": set mode: %d:\"%s\" %d %d %d %d %d %d %d %d %d %d 0x%x 0x%x",
+	    mode->base.id, mode->name,
+	    mode->vrefresh, mode->clock,
+	    mode->hdisplay, mode->hsync_start,
+	    mode->hsync_end, mode->htotal,
+	    mode->vdisplay, mode->vsync_start,
+	    mode->vsync_end, mode->vtotal,
+	    mode->type, mode->flags);
+
+	index = drm_crtc_index(crtc);
+	div = (uint32_t)clk_get_rate(fsl_dev->clk) / crtc->mode.clock /
+1000;
+
+	/* Configure timings: */
+	hbp = mode->htotal - mode->hsync_end;
+	hfp = mode->hsync_start - mode->hdisplay;
+	hsw = mode->hsync_end - mode->hsync_start;
+	vbp = mode->vtotal - mode->vsync_end;
+	vfp = mode->vsync_start - mode->vdisplay;
+	vsw = mode->vsync_end - mode->vsync_start;
+
+	regmap_write(fsl_dev->regmap, DCU_HSYN_PARA,
+		     DCU_HSYN_PARA_BP(hbp) |
+		     DCU_HSYN_PARA_PW(hsw) |
+		     DCU_HSYN_PARA_FP(hfp));
+	regmap_write(fsl_dev->regmap, DCU_VSYN_PARA,
+		     DCU_VSYN_PARA_BP(vbp) |
+		     DCU_VSYN_PARA_PW(vsw) |
+		     DCU_VSYN_PARA_FP(vfp));
+	regmap_write(fsl_dev->regmap, DCU_DISP_SIZE,
+		     DCU_DISP_SIZE_DELTA_Y(mode->vdisplay) |
+		     DCU_DISP_SIZE_DELTA_X(mode->hdisplay));
+	regmap_write(fsl_dev->regmap, DCU_CTRLDESCLN_1(index),
+		     DCU_CTRLDESCLN_1_HEIGHT(mode->vdisplay) |
+		     DCU_CTRLDESCLN_1_WIDTH(mode->hdisplay));
+	regmap_write(fsl_dev->regmap, DCU_CTRLDESCLN_2(index),
+		     DCU_CTRLDESCLN_2_POSY(y) |
+		     DCU_CTRLDESCLN_2_POSX(x));
+	regmap_write(fsl_dev->regmap, DCU_DIV_RATIO, div);
+	regmap_write(fsl_dev->regmap, DCU_UPDATE_MODE,

drivers/gpu/drm/fsl/fsl_dcu_drm_crtc.c

Quoted 10 lines
drivers/gpu/drm/fsl/fsl_dcu_drm_crtc.c new file +10 -0
+DCU_UPDATE_MODE_READREG);
+
+	return 0;
+}
+
+static void fsl_dcu_drm_crtc_mode_commit(struct drm_crtc *crtc) {
+		fsl_dcu_drm_crtc_start(crtc);
+}
+
+static int fsl_dcu_drm_crtc_mode_set_base(struct drm_crtc *crtc, int x,

int y,

Quoted 50 lines
drivers/gpu/drm/fsl/fsl_dcu_drm_crtc.c new file +50 -0
+					  struct drm_framebuffer *old_fb) {
+	fsl_dcu_drm_crtc_update_base(crtc);
+
+	return 0;
+}
+
+static const struct drm_crtc_helper_funcs crtc_helper_funcs = {
+	.dpms = fsl_dcu_drm_crtc_dpms,
+	.mode_fixup = fsl_dcu_drm_crtc_mode_fixup,
+	.prepare = fsl_dcu_drm_crtc_mode_prepare,
+	.commit = fsl_dcu_drm_crtc_mode_commit,
+	.mode_set = fsl_dcu_drm_crtc_mode_set,
+	.mode_set_base = fsl_dcu_drm_crtc_mode_set_base, };
+
+static int fsl_dcu_drm_crtc_page_flip(struct drm_crtc *crtc,
+				      struct drm_framebuffer *fb,
+				      struct drm_pending_vblank_event *event,
+				      uint32_t page_flip_flags)
+{
+	return 0;
+}
+
+static const struct drm_plane_funcs fsl_dcu_drm_plane_funcs = {
+	.update_plane = fsl_dcu_drm_plane_update,
+	.disable_plane = fsl_dcu_drm_plane_disable,
+	.destroy = fsl_dcu_drm_plane_destroy, };
+
+static const struct drm_crtc_funcs crtc_funcs = {
+	.destroy = drm_crtc_cleanup,
+	.set_config = drm_crtc_helper_set_config,
+	.page_flip = fsl_dcu_drm_crtc_page_flip, };
+
+int fsl_dcu_drm_crtc_create(struct fsl_dcu_drm_device *fsl_dev) {
+	struct drm_crtc *crtc = &fsl_dev->crtc.crtc;
+	int ret;
+
+	fsl_dev->crtc.dpms = DRM_MODE_DPMS_OFF;
+
+	ret = drm_crtc_init(fsl_dev->ddev, crtc, &crtc_funcs);
+	if (ret < 0)
+		return ret;
+
+	crtc->primary->funcs = &fsl_dcu_drm_plane_funcs;
+
+	drm_crtc_helper_add(crtc, &crtc_helper_funcs);
+
+	regmap_write(fsl_dev->regmap, DCU_SYN_POL,
+		     DCU_SYN_POL_INV_VS_LOW | DCU_SYN_POL_INV_HS_LOW);
+	regmap_write(fsl_dev->regmap, DCU_BGND, DCU_BGND_R(0) |
+		     DCU_BGND_G(0) | DCU_BGND_B(0));

drivers/gpu/drm/fsl/fsl_dcu_drm_crtc.c

Quoted 10 lines
drivers/gpu/drm/fsl/fsl_dcu_drm_crtc.c new file +10 -0
+	regmap_write(fsl_dev->regmap, DCU_DCU_MODE,
+		     DCU_MODE_BLEND_ITER(1) | DCU_MODE_RASTER_EN);
+	regmap_write(fsl_dev->regmap, DCU_THRESHOLD,
+		     DCU_THRESHOLD_LS_BF_VS(BF_VS_VAL) |
+		     DCU_THRESHOLD_OUT_BUF_HIGH(BUF_MAX_VAL) |
+		     DCU_THRESHOLD_OUT_BUF_LOW(BUF_MIN_VAL));
+	regmap_update_bits(fsl_dev->regmap, DCU_DCU_MODE,
+			   DCU_MODE_DCU_MODE_MASK,
+			   DCU_MODE_DCU_MODE(DCU_MODE_NORMAL));
+	regmap_write(fsl_dev->regmap, DCU_UPDATE_MODE,

DCU_UPDATE_MODE_READREG);

Quoted 25 lines
drivers/gpu/drm/fsl/fsl_dcu_drm_crtc.c new file +25 -0
+	return 0;
+}
+
+/*
+ * Encoder
+ */
+
+#define to_fsl_dcu_encoder(e) \
+	container_of(e, struct fsl_dcu_drm_encoder, encoder)
+
+static void fsl_dcu_drm_encoder_dpms(struct drm_encoder *encoder, int
+mode) {
+	struct fsl_dcu_drm_encoder *fsl_enc = to_fsl_dcu_encoder(encoder);
+
+	if (fsl_enc->dpms == mode)
+		return;
+
+	fsl_enc->dpms = mode;
+}
+
+static bool fsl_dcu_drm_encoder_mode_fixup
+		(struct drm_encoder *encoder,
+		const struct drm_display_mode *mode,
+		struct drm_display_mode *adjusted_mode) {
+	struct drm_device *dev = encoder->dev;

drivers/gpu/drm/fsl/fsl_dcu_drm_crtc.c

Quoted 10 lines
drivers/gpu/drm/fsl/fsl_dcu_drm_crtc.c new file +10 -0
+	struct fsl_dcu_drm_device *fsl_dev = dev->dev_private;
+	struct drm_connector *connector = &fsl_dev->connector.connector;
+	const struct drm_display_mode *panel_mode;
+
+	if (list_empty(&connector->modes)) {
+		dev_dbg(dev->dev, "mode_fixup: empty modes list\n");
+		return false;
+	}
+
+	/* The flat panel mode is fixed, just copy it to the adjusted mode.

*/

Quoted 72 lines
drivers/gpu/drm/fsl/fsl_dcu_drm_crtc.c new file +72 -0
+	panel_mode = list_first_entry(&connector->modes,
+				      struct drm_display_mode, head);
+	drm_mode_copy(adjusted_mode, panel_mode);
+
+	return true;
+}
+
+static void fsl_dcu_drm_encoder_mode_prepare(struct drm_encoder
+*encoder) { }
+
+static void fsl_dcu_drm_encoder_mode_set(struct drm_encoder *encoder,
+					 struct drm_display_mode *mode,
+					 struct drm_display_mode *adjusted_mode) { }
+
+static void fsl_dcu_drm_encoder_mode_commit(struct drm_encoder
+*encoder) {
+	;
+}
+
+static const struct drm_encoder_helper_funcs encoder_helper_funcs = {
+	.dpms = fsl_dcu_drm_encoder_dpms,
+	.mode_fixup = fsl_dcu_drm_encoder_mode_fixup,
+	.prepare = fsl_dcu_drm_encoder_mode_prepare,
+	.commit = fsl_dcu_drm_encoder_mode_commit,
+	.mode_set = fsl_dcu_drm_encoder_mode_set, };
+
+static void fsl_dcu_drm_encoder_destroy(struct drm_encoder *encoder)
+{
+	drm_encoder_cleanup(encoder);
+}
+
+static const struct drm_encoder_funcs encoder_funcs = {
+	.destroy = fsl_dcu_drm_encoder_destroy, };
+
+int fsl_dcu_drm_encoder_create(struct fsl_dcu_drm_device *fsl_dev) {
+	struct drm_encoder *encoder = &fsl_dev->encoder.encoder;
+	int ret;
+
+	fsl_dev->encoder.dpms = DRM_MODE_DPMS_OFF;
+
+	encoder->possible_crtcs = 1;
+
+	ret = drm_encoder_init(fsl_dev->ddev, encoder, &encoder_funcs,
+			       DRM_MODE_ENCODER_LVDS);
+	if (ret < 0)
+		return ret;
+
+	drm_encoder_helper_add(encoder, &encoder_helper_funcs);
+
+	return 0;
+}
+
+/*
+ * Connector
+ */
+
+#define to_fsl_dcu_connector(c) \
+	container_of(c, struct fsl_dcu_drm_connector, connector)
+
+static int fsl_dcu_drm_connector_get_modes(struct drm_connector
+*connector) {
+	struct drm_device *dev = connector->dev;
+	struct device_node *display_np, *np = dev->dev->of_node;
+	struct drm_display_mode *mode = drm_mode_create(connector->dev);
+	int num_modes = 0;
+
+	if (np) {
+		display_np = of_parse_phandle(np, "display", 0);
+		if (!display_np) {
+			dev_err(dev->dev, "failed to find display phandle\n");
+			return num_modes;
+		}

drivers/gpu/drm/fsl/fsl_dcu_drm_crtc.c

Quoted 10 lines
drivers/gpu/drm/fsl/fsl_dcu_drm_crtc.c new file +10 -0
+		of_get_drm_display_mode(display_np, mode, OF_USE_NATIVE_MODE);
+		mode->type |= DRM_MODE_TYPE_DRIVER | DRM_MODE_TYPE_PREFERRED,
+		drm_mode_probed_add(connector, mode);
+		num_modes++;
+	}
+
+	return num_modes;
+}
+
+static int fsl_dcu_drm_connector_mode_valid(struct drm_connector

*connector,

drivers/gpu/drm/fsl/fsl_dcu_drm_crtc.c

Quoted 13 lines
drivers/gpu/drm/fsl/fsl_dcu_drm_crtc.c new file +13 -0
+					    struct drm_display_mode *mode) {
+	return MODE_OK;
+}
+
+static struct drm_encoder *
+fsl_dcu_drm_connector_best_encoder(struct drm_connector *connector) {
+	struct fsl_dcu_drm_connector *fsl_con =
+to_fsl_dcu_connector(connector);
+
+	return fsl_con->encoder;
+}
+
+static const struct drm_connector_helper_funcs connector_helper_funcs =

{

Quoted 226 lines
drivers/gpu/drm/fsl/fsl_dcu_drm_crtc.c new file +63 -0
+	.get_modes = fsl_dcu_drm_connector_get_modes,
+	.mode_valid = fsl_dcu_drm_connector_mode_valid,
+	.best_encoder = fsl_dcu_drm_connector_best_encoder,
+};
+
+static void fsl_dcu_drm_connector_destroy(struct drm_connector
+*connector) {
+	drm_connector_unregister(connector);
+	drm_connector_cleanup(connector);
+}
+
+static enum drm_connector_status
+fsl_dcu_drm_connector_detect(struct drm_connector *connector, bool
+force) {
+	return connector_status_connected;
+}
+
+static const struct drm_connector_funcs connector_funcs = {
+	.dpms = drm_helper_connector_dpms,
+	.detect = fsl_dcu_drm_connector_detect,
+	.fill_modes = drm_helper_probe_single_connector_modes,
+	.destroy = fsl_dcu_drm_connector_destroy, };
+
+int fsl_dcu_drm_connector_create(struct fsl_dcu_drm_device *fsl_dev,
+				 struct drm_encoder *encoder)
+{
+	struct drm_connector *connector = &fsl_dev->connector.connector;
+	int ret;
+
+	fsl_dev->connector.encoder = encoder;
+
+	connector->display_info.width_mm = 0;
+	connector->display_info.height_mm = 0;
+
+	ret = drm_connector_init(fsl_dev->ddev, connector, &connector_funcs,
+				 DRM_MODE_CONNECTOR_LVDS);
+	if (ret < 0)
+		return ret;
+
+	drm_connector_helper_add(connector, &connector_helper_funcs);
+	ret = drm_connector_register(connector);
+	if (ret < 0)
+		goto err_cleanup;
+
+	ret = drm_mode_connector_attach_encoder(connector, encoder);
+	if (ret < 0)
+		goto err_sysfs;
+
+	connector->encoder = encoder;
+
+	drm_helper_connector_dpms(connector, DRM_MODE_DPMS_OFF);
+	drm_object_property_set_value
+		(&connector->base, fsl_dev->ddev->mode_config.dpms_property,
+		DRM_MODE_DPMS_OFF);
+
+	return 0;
+
+err_sysfs:
+	drm_connector_unregister(connector);
+err_cleanup:
+	drm_connector_cleanup(connector);
+	return ret;
+}
drivers/gpu/drm/fsl/fsl_dcu_drm_crtc.h new file +42 -0
new file mode 100644
index 0000000..ad59992
@@ -0,0 +1,40 @@
+/*
+ * 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_MODSET_H__
+#define __FSL_DCU_DRM_MODSET_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;
+};
+
+struct fsl_dcu_drm_encoder {
+	struct drm_encoder encoder;
+	int dpms;
+};
+
+struct fsl_dcu_drm_connector {
+	struct drm_connector connector;
+	struct drm_encoder *encoder;
+};
+
+int fsl_dcu_drm_crtc_create(struct fsl_dcu_drm_device *fsl_dev); int
+fsl_dcu_drm_encoder_create(struct fsl_dcu_drm_device *fsl_dev); int
+fsl_dcu_drm_connector_create(struct fsl_dcu_drm_device *fsl_dev,
+				 struct drm_encoder *encoder);
+
+#endif /* __FSL_DCU_DRM_MODSET_H__ */
drivers/gpu/drm/fsl/fsl_dcu_drm_drv.c new file +107 -0
new file mode 100644
index 0000000..1bca45a
@@ -0,0 +1,323 @@
+/*
+ * 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.
+ */
+
+#include <linux/clk.h>
+#include <linux/io.h>
+#include <linux/mm.h>
+#include <linux/module.h>
+#include <linux/of_platform.h>
+#include <linux/platform_device.h>
+#include <linux/pm.h>
+#include <linux/pm_runtime.h>
+#include <linux/regmap.h>
+#include <linux/slab.h>
+
+#include <drm/drmP.h>
+#include "fsl_dcu_drm_drv.h"
+#include "fsl_dcu_drm_kms.h"
+
+static int fsl_dcu_unload(struct drm_device *dev) {
+	drm_mode_config_cleanup(dev);
+	drm_vblank_cleanup(dev);
+	drm_irq_uninstall(dev);
+
+	dev->dev_private = NULL;
+
+	return 0;
+}
+
+static struct regmap_config fsl_dcu_regmap_config = {
+	.reg_bits = 32,
+	.reg_stride = 4,
+	.val_bits = 32,
+};
+
+static int fsl_dcu_bypass_tcon(struct fsl_dcu_drm_device *fsl_dev,
+			       struct device_node *np)
+{
+	struct device_node *tcon_np;
+	struct platform_device *pdev;
+	struct clk *tcon_clk;
+	struct resource *res;
+	void __iomem *base;
+
+	tcon_np = of_parse_phandle(np, "tcon-controller", 0);
+	if (!tcon_np)
+		return -EINVAL;
+
+	pdev = of_find_device_by_node(tcon_np);
+	if (!pdev)
+		return -EINVAL;
+
+	tcon_clk = devm_clk_get(&pdev->dev, "tcon");
+	if (IS_ERR(tcon_clk))
+		return PTR_ERR(tcon_clk);
+	clk_prepare_enable(tcon_clk);
+
+	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+	if (!res)
+		return -ENODEV;
+
+	base = devm_ioremap_resource(&pdev->dev, res);
+	if (IS_ERR(base))
+		return PTR_ERR(base);
+
+	fsl_dev->tcon_regmap = devm_regmap_init_mmio_clk(&pdev->dev,
+			"tcon", base, &fsl_dcu_regmap_config);
+	if (IS_ERR(fsl_dev->tcon_regmap)) {
+		dev_err(&pdev->dev, "regmap init failed\n");
+		return PTR_ERR(fsl_dev->tcon_regmap);
+	}
+
+	regmap_write(fsl_dev->tcon_regmap, TCON_CTRL1, TCON_BYPASS_ENABLE);
+	return 0;
+}
+
+static int fsl_dcu_scfg_config(struct fsl_dcu_drm_device *fsl_dev,
+			       struct device_node *np)
+{
+	struct device_node *scfg_np;
+	struct platform_device *pdev;
+	struct resource *res;
+	void __iomem *base;
+
+	scfg_np = of_parse_phandle(np, "scfg-controller", 0);
+	if (!scfg_np)
+		return 0;
+
+	pdev = of_find_device_by_node(scfg_np);
+	if (!pdev)
+		return -EINVAL;
+
+	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+	if (!res)
+		return -ENODEV;
+
+	base = devm_ioremap_resource(&pdev->dev, res);
+	if (IS_ERR(base))

drivers/gpu/drm/fsl/fsl_dcu_drm_drv.c line 117

Quoted 10 lines
drivers/gpu/drm/fsl/fsl_dcu_drm_drv.c new file +10 -0
+		return PTR_ERR(base);
+
+	fsl_dev->scfg_regmap = devm_regmap_init_mmio_clk(&pdev->dev,
+			NULL, base, &fsl_dcu_regmap_config);
+	if (IS_ERR(fsl_dev->scfg_regmap)) {
+		dev_err(&pdev->dev, "regmap init failed\n");
+		return PTR_ERR(fsl_dev->scfg_regmap);
+	}
+
+	regmap_write(fsl_dev->scfg_regmap, 0x28, 0x80000000);

What does this actually do? I don't think this exists in Vybrid, but I guess we could easily make the property optional which would then not call this function...

--
Stefan

Quoted 450 lines
drivers/gpu/drm/fsl/fsl_dcu_drm_drv.c new file +201 -0
+
+	return 0;
+}
+
+static int fsl_dcu_load(struct drm_device *dev, unsigned long flags)
+{
+	struct platform_device *pdev = dev->platformdev;
+	struct fsl_dcu_drm_device *fsl_dev;
+	struct resource *res;
+	void __iomem *base;
+	int ret;
+
+	fsl_dev = devm_kzalloc(&pdev->dev, sizeof(*fsl_dev), GFP_KERNEL);
+	if (!fsl_dev)
+		return -ENOMEM;
+
+	fsl_dev->dev = &pdev->dev;
+	fsl_dev->ddev = dev;
+	dev->dev_private = fsl_dev;
+
+	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+	base = devm_ioremap_resource(&pdev->dev, res);
+	if (IS_ERR(base)) {
+		ret = PTR_ERR(base);
+		return ret;
+	}
+
+	fsl_dev->regmap = devm_regmap_init_mmio(&pdev->dev,
+			base, &fsl_dcu_regmap_config);
+	if (IS_ERR(fsl_dev->regmap)) {
+		dev_err(&pdev->dev, "regmap init failed\n");
+		return PTR_ERR(fsl_dev->regmap);
+	}
+
+	ret = fsl_dcu_drm_modeset_init(fsl_dev);
+	if (ret < 0) {
+		dev_err(&pdev->dev, "failed to initialize mode setting\n");
+		return ret;
+	}
+
+	ret = drm_vblank_init(dev, 1);
+	if (ret < 0) {
+		dev_err(&pdev->dev, "failed to initialize vblank\n");
+		goto done;
+	}
+
+	ret = drm_irq_install(dev, platform_get_irq(dev->platformdev, 0));
+	if (ret < 0) {
+		dev_err(&pdev->dev, "failed to install IRQ handler\n");
+		goto done;
+	}
+
+	/* Put TCON in bypass mode, so the input signals from DCU are passed
+	 * through TCON unchanged */
+	fsl_dcu_bypass_tcon(fsl_dev, pdev->dev.of_node);
+	fsl_dcu_scfg_config(fsl_dev, pdev->dev.of_node);
+
+	fsl_dev->clk = devm_clk_get(&pdev->dev, "dcfb");
+	if (IS_ERR(fsl_dev->clk)) {
+		ret = PTR_ERR(fsl_dev->clk);
+		dev_err(&pdev->dev, "could not get clock\n");
+		return ret;
+	}
+	clk_prepare_enable(fsl_dev->clk);
+
+	dev_set_drvdata(dev->dev, fsl_dev);
+
+	fsl_dcu_fbdev_init(dev);
+
+	return 0;
+done:
+	if (ret)
+		fsl_dcu_unload(dev);
+
+	return ret;
+}
+
+static void fsl_dcu_drm_preclose(struct drm_device *dev, struct
+drm_file *file) {
+	;
+}
+
+static irqreturn_t fsl_dcu_drm_irq(int irq, void *arg) {
+	return IRQ_HANDLED;
+}
+
+static int fsl_dcu_drm_enable_vblank(struct drm_device *dev, int
+crtc) {
+	return 0;
+}
+
+static void fsl_dcu_drm_disable_vblank(struct drm_device *dev, int
+crtc) {
+	;
+}
+
+static const struct file_operations fsl_dcu_drm_fops = {
+	.owner		= THIS_MODULE,
+	.open		= drm_open,
+	.release	= drm_release,
+	.unlocked_ioctl	= drm_ioctl,
+#ifdef CONFIG_COMPAT
+	.compat_ioctl	= drm_compat_ioctl,
+#endif
+	.poll		= drm_poll,
+	.read		= drm_read,
+	.llseek		= no_llseek,
+	.mmap		= drm_gem_cma_mmap,
+};
+
+static struct drm_driver fsl_dcu_drm_driver = {
+	.driver_features	= DRIVER_HAVE_IRQ | DRIVER_GEM | DRIVER_MODESET
+				| DRIVER_PRIME,
+	.load			= fsl_dcu_load,
+	.unload			= fsl_dcu_unload,
+	.preclose		= fsl_dcu_drm_preclose,
+	.irq_handler		= fsl_dcu_drm_irq,
+	.get_vblank_counter	= drm_vblank_count,
+	.enable_vblank		= fsl_dcu_drm_enable_vblank,
+	.disable_vblank		= fsl_dcu_drm_disable_vblank,
+	.gem_free_object	= drm_gem_cma_free_object,
+	.gem_vm_ops		= &drm_gem_cma_vm_ops,
+	.prime_handle_to_fd	= drm_gem_prime_handle_to_fd,
+	.prime_fd_to_handle	= drm_gem_prime_fd_to_handle,
+	.gem_prime_import	= drm_gem_prime_import,
+	.gem_prime_export	= drm_gem_prime_export,
+	.gem_prime_get_sg_table	= drm_gem_cma_prime_get_sg_table,
+	.gem_prime_import_sg_table = drm_gem_cma_prime_import_sg_table,
+	.gem_prime_vmap		= drm_gem_cma_prime_vmap,
+	.gem_prime_vunmap	= drm_gem_cma_prime_vunmap,
+	.gem_prime_mmap		= drm_gem_cma_prime_mmap,
+	.dumb_create		= drm_gem_cma_dumb_create,
+	.dumb_map_offset	= drm_gem_cma_dumb_map_offset,
+	.dumb_destroy		= drm_gem_dumb_destroy,
+	.fops			= &fsl_dcu_drm_fops,
+	.name			= "fsl-dcu-drm",
+	.desc			= "Freescale DCU DRM",
+	.date			= "20150213",
+	.major			= 1,
+	.minor			= 0,
+};
+
+#ifdef CONFIG_PM_SLEEP
+static int fsl_dcu_drm_pm_suspend(struct device *dev) {
+	struct fsl_dcu_drm_device *fsl_dev = dev_get_drvdata(dev);
+
+	drm_kms_helper_poll_disable(fsl_dev->ddev);
+	fsl_dcu_drm_crtc_suspend(&fsl_dev->crtc);
+
+	return 0;
+}
+
+static int fsl_dcu_drm_pm_resume(struct device *dev) {
+	struct fsl_dcu_drm_device *fsl_dev = dev_get_drvdata(dev);
+
+	drm_modeset_lock_all(fsl_dev->ddev);
+	fsl_dcu_drm_crtc_resume(&fsl_dev->crtc);
+	drm_modeset_unlock_all(fsl_dev->ddev);
+
+	drm_kms_helper_poll_enable(fsl_dev->ddev);
+	return 0;
+}
+#endif
+
+static const struct dev_pm_ops fsl_dcu_drm_pm_ops = {
+	SET_SYSTEM_SLEEP_PM_OPS(fsl_dcu_drm_pm_suspend,
+fsl_dcu_drm_pm_resume) };
+
+static int fsl_dcu_drm_probe(struct platform_device *pdev) {
+	return drm_platform_init(&fsl_dcu_drm_driver, pdev); }
+
+static int fsl_dcu_drm_remove(struct platform_device *pdev) {
+	struct fsl_dcu_drm_device *fsl_dev = platform_get_drvdata(pdev);
+
+	drm_put_dev(fsl_dev->ddev);
+
+	return 0;
+}
+
+static struct of_device_id fsl_dcu_of_match[] = {
+		{ .compatible = "fsl,ls1021a-dcfb", },
+		{ },
+};
+MODULE_DEVICE_TABLE(of, fsl_dcu_of_match);
+
+static struct platform_driver fsl_dcu_drm_platform_driver = {
+	.probe		= fsl_dcu_drm_probe,
+	.remove		= fsl_dcu_drm_remove,
+	.driver		= {
+		.owner	= THIS_MODULE,
+		.name	= "fsl,ls1021a-dcfb",
+		.pm	= &fsl_dcu_drm_pm_ops,
+		.of_match_table = fsl_dcu_of_match,
+	},
+};
+
+module_platform_driver(fsl_dcu_drm_platform_driver);
+
+MODULE_ALIAS("platform:fsl-dcu-drm");
+MODULE_DESCRIPTION("Freescale DCU DRM Driver");
+MODULE_LICENSE("GPL");
drivers/gpu/drm/fsl/fsl_dcu_drm_drv.h new file +168 -0
new file mode 100644
index 0000000..8dc7c10
@@ -0,0 +1,167 @@
+/*
+ * 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_DRV_H__
+#define __FSL_DCU_DRM_DRV_H__
+
+#include <linux/kernel.h>
+#include <linux/spinlock.h>
+#include <stddef.h>
+#include <drm/drm.h>
+#include <drm/drmP.h>
+#include <drm/drm_fb_helper.h>
+#include <drm/drm_crtc_helper.h>
+#include <drm/drm_gem_cma_helper.h>
+#include <drm/drm_fb_cma_helper.h>
+
+#include "fsl_dcu_drm_crtc.h"
+#define DRIVER_NAME			"fsl-dcu-fb"
+
+#define DCU_DCU_MODE			0x0010
+#define DCU_MODE_BLEND_ITER(x)		((x) << 20)
+#define DCU_MODE_RASTER_EN		BIT(14)
+#define DCU_MODE_DCU_MODE(x)		(x)
+#define DCU_MODE_DCU_MODE_MASK		0x03
+#define DCU_MODE_OFF			0
+#define DCU_MODE_NORMAL			1
+#define DCU_MODE_TEST			2
+#define DCU_MODE_COLORBAR		3
+
+#define DCU_BGND			0x0014
+#define DCU_BGND_R(x)			((x) << 16)
+#define DCU_BGND_G(x)			((x) << 8)
+#define DCU_BGND_B(x)			(x)
+
+#define DCU_DISP_SIZE			0x0018
+#define DCU_DISP_SIZE_DELTA_Y(x)	((x) << 16)
+/*Regisiter value 1/16 of horizontal resolution*/
+#define DCU_DISP_SIZE_DELTA_X(x)	((x) >> 4)
+
+#define DCU_HSYN_PARA			0x001c
+#define DCU_HSYN_PARA_BP(x)		((x) << 22)
+#define DCU_HSYN_PARA_PW(x)		((x) << 11)
+#define DCU_HSYN_PARA_FP(x)		(x)
+
+#define DCU_VSYN_PARA			0x0020
+#define DCU_VSYN_PARA_BP(x)		((x) << 22)
+#define DCU_VSYN_PARA_PW(x)		((x) << 11)
+#define DCU_VSYN_PARA_FP(x)		(x)
+
+#define DCU_SYN_POL			0x0024
+#define DCU_SYN_POL_INV_PXCK_FALL	(0 << 6)
+#define DCU_SYN_POL_NEG_REMAIN		(0 << 5)
+#define DCU_SYN_POL_INV_VS_LOW		BIT(1)
+#define DCU_SYN_POL_INV_HS_LOW		(1)
+
+#define DCU_THRESHOLD			0x0028
+#define DCU_THRESHOLD_LS_BF_VS(x)	((x) << 16)
+#define DCU_THRESHOLD_OUT_BUF_HIGH(x)	((x) << 8)
+#define DCU_THRESHOLD_OUT_BUF_LOW(x)	(x)
+#define BF_VS_VAL			0x03
+#define BUF_MAX_VAL			0x78
+#define BUF_MIN_VAL			0x0a
+
+#define DCU_INT_STATUS			0x002C
+#define DCU_INT_STATUS_UNDRUN		BIT(1)
+
+#define DCU_INT_MASK			0x0030
+#define DCU_INT_MASK_UNDRUN		BIT(1)
+#define DCU_INT_MASK_VBLANK		BIT(3)
+
+#define DCU_DIV_RATIO			0x0054
+
+#define DCU_UPDATE_MODE			0x00cc
+#define DCU_UPDATE_MODE_MODE		BIT(31)
+#define DCU_UPDATE_MODE_READREG		BIT(30)
+
+#define DCU_DCFB_MAX			0x300
+
+#define DCU_CTRLDESCLN_1(x)		(0x200 + (x) * 0x40)
+#define DCU_CTRLDESCLN_1_HEIGHT(x)	((x) << 16)
+#define DCU_CTRLDESCLN_1_WIDTH(x)	(x)
+
+#define DCU_CTRLDESCLN_2(x)		(0x204 + (x) * 0x40)
+#define DCU_CTRLDESCLN_2_POSY(x)	((x) << 16)
+#define DCU_CTRLDESCLN_2_POSX(x)	(x)
+
+#define DCU_CTRLDESCLN_3(x)		(0x208 + (x) * 0x40)
+
+#define DCU_CTRLDESCLN_4(x)		(0x20c + (x) * 0x40)
+#define DCU_CTRLDESCLN_4_EN		BIT(31)
+#define DCU_CTRLDESCLN_4_TILE_EN	BIT(30)
+#define DCU_CTRLDESCLN_4_DATA_SEL_CLUT	BIT(29)
+#define DCU_CTRLDESCLN_4_SAFETY_EN	BIT(28)
+#define DCU_CTRLDESCLN_4_TRANS(x)	((x) << 20)
+#define DCU_CTRLDESCLN_4_BPP(x)		((x) << 16)
+#define DCU_CTRLDESCLN_4_RLE_EN		BIT(15)
+#define DCU_CTRLDESCLN_4_LUOFFS(x)	((x) << 4)
+#define DCU_CTRLDESCLN_4_BB_ON		BIT(2)
+#define DCU_CTRLDESCLN_4_AB(x)		(x)
+
+#define DCU_CTRLDESCLN_5(x)		(0x210 + (x) * 0x40)
+#define DCU_CTRLDESCLN_5_CKMAX_R(x)	((x) << 16)
+#define DCU_CTRLDESCLN_5_CKMAX_G(x)	((x) << 8)
+#define DCU_CTRLDESCLN_5_CKMAX_B(x)	(x)
+
+#define DCU_CTRLDESCLN_6(x)		(0x214 + (x) * 0x40)
+#define DCU_CTRLDESCLN_6_CKMIN_R(x)	((x) << 16)
+#define DCU_CTRLDESCLN_6_CKMIN_G(x)	((x) << 8)
+#define DCU_CTRLDESCLN_6_CKMIN_B(x)	(x)
+
+#define DCU_CTRLDESCLN_7(x)		(0x218 + (x) * 0x40)
+#define DCU_CTRLDESCLN_7_TILE_VER(x)	((x) << 16)
+#define DCU_CTRLDESCLN_7_TILE_HOR(x)	(x)
+
+#define DCU_CTRLDESCLN_8(x)		(0x21c + (x) * 0x40)
+#define DCU_CTRLDESCLN_8_FG_FCOLOR(x)	(x)
+
+#define DCU_CTRLDESCLN_9(x)		(0x220 + (x) * 0x40)
+#define DCU_CTRLDESCLN_9_BG_BCOLOR(x)	(x)
+
+#define DCU_CTRLDESCLN_10(x)		(0x224 + (x) * 0x40)
+#define DCU_CTRLDESCLN_10_POST_SKIP(x)	((x) << 16)
+#define DCU_CTRLDESCLN_10_PRE_SKIP(x)	(x)
+
+#define FSL_DCU_RGB565			4
+#define FSL_DCU_RGB888			5
+#define FSL_DCU_ARGB8888		6
+#define FSL_DCU_ARGB1555		11
+#define FSL_DCU_ARGB4444		12
+#define FSL_DCU_YUV422			14
+
+#define TCON_CTRL1			0x0000
+#define TCON_BYPASS_ENABLE		BIT(29)
+
+#define DBG(fmt, ...) DRM_DEBUG(fmt"\n", ##__VA_ARGS__)
+
+struct clk;
+struct device;
+struct drm_device;
+
+struct fsl_dcu_drm_device {
+	struct device *dev;
+	struct regmap *regmap;
+	struct regmap *tcon_regmap;
+	struct regmap *scfg_regmap;
+	unsigned int irq;
+	struct clk *clk;
+	/*protects hardware register*/
+	spinlock_t irq_lock;
+	struct drm_device *ddev;
+	struct drm_fbdev_cma *fbdev;
+	struct fsl_dcu_drm_crtc crtc;
+	struct fsl_dcu_drm_encoder encoder;
+	struct fsl_dcu_drm_connector connector; };
+
+void fsl_dcu_fbdev_init(struct drm_device *dev);
+
+#endif /* __FSL_DCU_DRM_DRV_H__ */
drivers/gpu/drm/fsl/fsl_dcu_drm_fbdev.c new file +46 -0
new file mode 100644
index 0000000..6729f92
@@ -0,0 +1,43 @@
+/*
+ * 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_crtc.h>
+#include <drm/drm_fb_helper.h>
+#include <drm/drm_crtc_helper.h>
+#include <drm/drm_fb_cma_helper.h>
+#include <drm/drm_gem_cma_helper.h>
+#include <linux/clk.h>
+#include <linux/delay.h>
+#include <linux/dma-mapping.h>
+#include <linux/fb.h>
+#include <linux/interrupt.h>
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/of_platform.h>
+#include <linux/regmap.h>
+#include <video/of_display_timing.h>
+#include <video/videomode.h>
+#include <linux/uaccess.h>
+
+#include "fsl_dcu_drm_drv.h"
+#include "fsl_dcu_drm_crtc.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 +14 -0
new file mode 100644
index 0000000..0eb0652
@@ -0,0 +1,45 @@
+/*
+ * 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.
+ */
+
+#include <drm/drmP.h>

drivers/gpu/drm/fsl/fsl_dcu_drm_kms.c line 24

Quoted 10 lines
drivers/gpu/drm/fsl/fsl_dcu_drm_kms.c new file +10 -0
+#include <drm/drm_crtc.h>
+#include <drm/drm_crtc_helper.h>
+#include <drm/drm_fb_cma_helper.h>
+#include <drm/drm_gem_cma_helper.h>
+
+#include "fsl_dcu_drm_crtc.h"
+#include "fsl_dcu_drm_drv.h"
+#include "fsl_dcu_drm_kms.h"
+
+static const struct drm_mode_config_funcs fsl_dcu_drm_mode_config_funcs

= {

Quoted 146 lines
drivers/gpu/drm/fsl/fsl_dcu_drm_kms.c new file +22 -0
+	.fb_create = drm_fb_cma_create,
+};
+
+int fsl_dcu_drm_modeset_init(struct fsl_dcu_drm_device *fsl_dev) {
+	drm_mode_config_init(fsl_dev->ddev);
+
+	fsl_dev->ddev->mode_config.min_width = 0;
+	fsl_dev->ddev->mode_config.min_height = 0;
+	fsl_dev->ddev->mode_config.max_width = 2031;
+	fsl_dev->ddev->mode_config.max_height = 2047;
+	fsl_dev->ddev->mode_config.funcs = &fsl_dcu_drm_mode_config_funcs;
+
+	fsl_dcu_drm_crtc_create(fsl_dev);
+	fsl_dcu_drm_encoder_create(fsl_dev);
+	fsl_dcu_drm_connector_create(fsl_dev, &fsl_dev->encoder.encoder);
+
+	drm_kms_helper_poll_init(fsl_dev->ddev);
+
+	drm_helper_disable_unused_functions(fsl_dev->ddev);
+
+	return 0;
+}
drivers/gpu/drm/fsl/fsl_dcu_drm_kms.h new file +24 -0
new file mode 100644
index 0000000..9d5b798
@@ -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_DRM_KMS_H__
+#define __FSL_DCU_DRM_KMS_H__
+
+#include <linux/types.h>
+
+struct drm_gem_cma_object;
+struct fsl_dcu_drm_device;
+
+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 +65 -0
new file mode 100644
index 0000000..d725594
@@ -0,0 +1,124 @@
+/*
+ * 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.
+ */
+
+#include <drm/drmP.h>
+#include <drm/drm_crtc.h>
+#include <drm/drm_crtc_helper.h>
+#include <drm/drm_fb_cma_helper.h>
+#include <drm/drm_gem_cma_helper.h>
+#include <linux/regmap.h>
+
+#include "fsl_dcu_drm_drv.h"
+#include "fsl_dcu_drm_kms.h"
+#include "fsl_dcu_drm_plane.h"
+
+static void __fsl_dcu_drm_plane_setup(struct drm_plane *plane,
+				      struct drm_framebuffer *fb) {
+	struct fsl_dcu_drm_device *fsl_dev = plane->dev->dev_private;
+	u32 plane_num = 0, alpha, bpp;
+	struct drm_gem_cma_object *gem;
+
+	while (plane->possible_crtcs >> 1)
+		plane_num++;
+
+	gem = drm_fb_cma_get_gem_obj(fb, 0);
+
+	switch (fb->pixel_format) {
+	case DRM_FORMAT_RGB565:
+		bpp = FSL_DCU_RGB565;
+		alpha = 0xff;
+		break;
+	case DRM_FORMAT_RGB888:
+		bpp = FSL_DCU_RGB888;
+		alpha = 0xff;
+		break;
+	case DRM_FORMAT_ARGB8888:
+		bpp = FSL_DCU_ARGB8888;
+		alpha = 0xff;
+		break;
+	case DRM_FORMAT_BGRA4444:
+		bpp = FSL_DCU_ARGB4444;
+		alpha = 0xff;
+		break;
+	case DRM_FORMAT_ARGB1555:
+		bpp = FSL_DCU_ARGB1555;
+		alpha = 0xff;
+		break;
+	case DRM_FORMAT_YUV422:
+		bpp = FSL_DCU_YUV422;
+		alpha = 0xff;
+		break;
+	default:
+		return;
+	}
+
+	regmap_write(fsl_dev->regmap, DCU_CTRLDESCLN_3(plane_num), gem-

paddr);

drivers/gpu/drm/fsl/fsl_dcu_drm_plane.c new file +20 -0
+	regmap_write(fsl_dev->regmap, DCU_CTRLDESCLN_4(plane_num),
+		     DCU_CTRLDESCLN_4_EN |
+		     DCU_CTRLDESCLN_4_TRANS(alpha) |
+		     DCU_CTRLDESCLN_4_BPP(bpp) |
+		     DCU_CTRLDESCLN_4_AB(2));
+	regmap_write(fsl_dev->regmap, DCU_CTRLDESCLN_5(plane_num),
+		     DCU_CTRLDESCLN_5_CKMAX_R(0xFF) |
+		     DCU_CTRLDESCLN_5_CKMAX_G(0xFF) |
+		     DCU_CTRLDESCLN_5_CKMAX_B(0xFF));
+	regmap_write(fsl_dev->regmap, DCU_CTRLDESCLN_6(plane_num),
+		     DCU_CTRLDESCLN_6_CKMIN_R(0) |
+		     DCU_CTRLDESCLN_6_CKMIN_G(0) |
+		     DCU_CTRLDESCLN_6_CKMIN_B(0));
+	regmap_write(fsl_dev->regmap, DCU_CTRLDESCLN_8(plane_num),
+		     DCU_CTRLDESCLN_8_FG_FCOLOR(0));
+	regmap_write(fsl_dev->regmap, DCU_CTRLDESCLN_9(plane_num),
+		     DCU_CTRLDESCLN_9_BG_BCOLOR(0));
+	regmap_write(fsl_dev->regmap, DCU_CTRLDESCLN_10(plane_num),
+		     DCU_CTRLDESCLN_10_POST_SKIP(0) |
+		     DCU_CTRLDESCLN_10_PRE_SKIP(0));

drivers/gpu/drm/fsl/fsl_dcu_drm_plane.c

Quoted 10 lines
drivers/gpu/drm/fsl/fsl_dcu_drm_plane.c new file +10 -0
+	regmap_write(fsl_dev->regmap, DCU_UPDATE_MODE,
+DCU_UPDATE_MODE_READREG); }
+
+void fsl_dcu_drm_plane_setup(struct drm_plane *plane) {
+	if (!plane->fb)
+		return;
+
+	__fsl_dcu_drm_plane_setup(plane, plane->fb); }
+
+int fsl_dcu_drm_plane_update(struct drm_plane *plane, struct drm_crtc

*crtc,

Quoted 62 lines
drivers/gpu/drm/fsl/fsl_dcu_drm_plane.c new file +25 -0
+			     struct drm_framebuffer *fb, int crtc_x, int crtc_y,
+			    unsigned int crtc_w, unsigned int crtc_h,
+			    uint32_t src_x, uint32_t src_y,
+			    uint32_t src_w, uint32_t src_h) {
+	__fsl_dcu_drm_plane_setup(plane, fb);
+	return 0;
+}
+
+int fsl_dcu_drm_plane_disable(struct drm_plane *plane) {
+	return 0;
+}
+
+void fsl_dcu_drm_plane_destroy(struct drm_plane *plane) {
+	fsl_dcu_drm_plane_disable(plane);
+	drm_plane_cleanup(plane);
+}
+
+static const uint32_t formats[] = {
+	DRM_FORMAT_RGB565,
+	DRM_FORMAT_RGB888,
+	DRM_FORMAT_ARGB8888,
+	DRM_FORMAT_ARGB4444,
+	DRM_FORMAT_ARGB1555,
+	DRM_FORMAT_YUV422,
+};
drivers/gpu/drm/fsl/fsl_dcu_drm_plane.h new file +30 -0
new file mode 100644
index 0000000..da88d1c
@@ -0,0 +1,28 @@
+/*
+ * 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;
+
+void fsl_dcu_drm_plane_setup(struct drm_plane *plane); int
+fsl_dcu_drm_plane_update(struct drm_plane *plane,
+			     struct drm_crtc *crtc,
+			     struct drm_framebuffer *fb,
+			     int crtc_x, int crtc_y,
+			     unsigned int crtc_w, unsigned int crtc_h,
+			     uint32_t src_x, uint32_t src_y,
+			     uint32_t src_w, uint32_t src_h); int
+fsl_dcu_drm_plane_disable(struct drm_plane *plane); void
+fsl_dcu_drm_plane_destroy(struct drm_plane *plane);
+
+#endif /* __FSL_DCU_DRM_PLANE_H__ */