Skip to contentSkip to conversation

drm: Add ASPEED GFX driver

PATCH In review Joel Stanley 2 participants 10 messages Apr 19, 2018

Subsystems (5)
lore
Share & tools
lore

Joel Stanley

author maintainer
#0 lore raw

cover drm: Add ASPEED GFX driver

This series adds a DRM driver for the ASPEED AST2500 GFX ("Display Controller") hardware present inside the BMC. This is distinct from the PCIe VGA device that is exposed to the host. It uses it's own hardware, and has it's own framebuffer in system RAM.

Joel Stanley (5):
drm: Add ASPEED GFX driver
drm: aspeed: Debugfs interface for GFX registers
ARM: dts: aspeed-g5: Add resets and clocks to GFX node
ARM: dts: ast2500-evb: Enable the GFX IP
ARM: dts: witherspoon: Enable the GFX IP

 arch/arm/boot/dts/aspeed-ast2500-evb.dts      |  21 +-
 .../boot/dts/aspeed-bmc-opp-witherspoon.dts   |   8 +
 arch/arm/boot/dts/aspeed-g5.dtsi              |   4 +
 drivers/gpu/drm/Kconfig                       |   2 +
 drivers/gpu/drm/Makefile                      |   1 +
 drivers/gpu/drm/aspeed/Kconfig                |  15 +
 drivers/gpu/drm/aspeed/Makefile               |   4 +
 drivers/gpu/drm/aspeed/aspeed_gfx.h           | 105 +++++++
 drivers/gpu/drm/aspeed/aspeed_gfx_crtc.c      | 247 ++++++++++++++++
 drivers/gpu/drm/aspeed/aspeed_gfx_debugfs.c   |  77 +++++
 drivers/gpu/drm/aspeed/aspeed_gfx_drv.c       | 266 ++++++++++++++++++
 drivers/gpu/drm/aspeed/aspeed_gfx_out.c       |  48 ++++
 12 files changed, 797 insertions(+), 1 deletion(-)
 create mode 100644 drivers/gpu/drm/aspeed/Kconfig
 create mode 100644 drivers/gpu/drm/aspeed/Makefile
 create mode 100644 drivers/gpu/drm/aspeed/aspeed_gfx.h
 create mode 100644 drivers/gpu/drm/aspeed/aspeed_gfx_crtc.c
 create mode 100644 drivers/gpu/drm/aspeed/aspeed_gfx_debugfs.c
 create mode 100644 drivers/gpu/drm/aspeed/aspeed_gfx_drv.c
 create mode 100644 drivers/gpu/drm/aspeed/aspeed_gfx_out.c
Signature · 1 line
2.17.0
author maintainer
#1 lore raw

PATCH 1/5 drm: Add ASPEED GFX driver

This driver is for the ASPEED BMC SoC's GFX display hardware. This driver runs on the ARM based BMC systems, unlike the ast driver which runs on a host CPU and is is for a PCI graphics device.

The AST2500 supports a total of 3 output paths:

1. VGA output, the output target can choose either or both to the DAC or DVO interface.

2. Graphics CRT output, the output target can choose either or both to the DAC or DVO interface.

3. Video input from DVO, the video input can be used for video engine capture or DAC display output.

Output options are selected in SCU2C.

The "VGA mode" device is the PCI attached controller. The "Graphics CRT" is the ARM's internal display controller.

The driver only supports a simple configuration consisting of a 40MHz pixel clock, fixed by hardware limitations, and the VGA output path.

---
 drivers/gpu/drm/Kconfig                  |   2 +
 drivers/gpu/drm/Makefile                 |   1 +
 drivers/gpu/drm/aspeed/Kconfig           |  15 ++
 drivers/gpu/drm/aspeed/Makefile          |   3 +
 drivers/gpu/drm/aspeed/aspeed_gfx.h      | 104 +++++++++
 drivers/gpu/drm/aspeed/aspeed_gfx_crtc.c | 247 +++++++++++++++++++++
 drivers/gpu/drm/aspeed/aspeed_gfx_drv.c  | 262 +++++++++++++++++++++++
 drivers/gpu/drm/aspeed/aspeed_gfx_out.c  |  48 +++++
 8 files changed, 682 insertions(+)
 create mode 100644 drivers/gpu/drm/aspeed/Kconfig
 create mode 100644 drivers/gpu/drm/aspeed/Makefile
 create mode 100644 drivers/gpu/drm/aspeed/aspeed_gfx.h
 create mode 100644 drivers/gpu/drm/aspeed/aspeed_gfx_crtc.c
 create mode 100644 drivers/gpu/drm/aspeed/aspeed_gfx_drv.c
 create mode 100644 drivers/gpu/drm/aspeed/aspeed_gfx_out.c
drivers/gpu/drm/Kconfig +2 -0
index 83cb2a88c204..0a7032fac731 100644
@@ -278,6 +278,8 @@ source "drivers/gpu/drm/tinydrm/Kconfig"
 
 source "drivers/gpu/drm/pl111/Kconfig"
 
+source "drivers/gpu/drm/aspeed/Kconfig"
+
 # Keep legacy drivers last
 
 menuconfig DRM_LEGACY
drivers/gpu/drm/Makefile +1 -0
index a8acc197dec3..d192c000888d 100644
@@ -100,3 +100,4 @@ obj-$(CONFIG_DRM_ZTE)	+= zte/
 obj-$(CONFIG_DRM_MXSFB)	+= mxsfb/
 obj-$(CONFIG_DRM_TINYDRM) += tinydrm/
 obj-$(CONFIG_DRM_PL111) += pl111/
+obj-$(CONFIG_DRM_ASPEED_GFX) += aspeed/
drivers/gpu/drm/aspeed/Kconfig new file +15 -0
new file mode 100644
index 000000000000..6f1e64c0a6ce
@@ -0,0 +1,15 @@
+config DRM_ASPEED_GFX
+	tristate "ASPEED BMC Display Controller"
+	depends on DRM && OF
+	select DRM_KMS_HELPER
+	select DRM_KMS_FB_HELPER
+	select DRM_KMS_CMA_HELPER
+	select DRM_PANEL
+	select DMA_CMA
+	select CMA
+	select MFD_SYSCON
+	help
+	  Chose this option if you have an ASPEED AST2400/AST2500
+	  SOC Display Controller (aka GFX).
+
+	  If M is selected this module will be called aspeed_gfx.
drivers/gpu/drm/aspeed/Makefile new file +3 -0
new file mode 100644
index 000000000000..6e194cd790d8
@@ -0,0 +1,3 @@
+aspeed_gfx-y := aspeed_gfx_drv.o aspeed_gfx_crtc.o aspeed_gfx_out.o
+
+obj-$(CONFIG_DRM_ASPEED_GFX) += aspeed_gfx.o
drivers/gpu/drm/aspeed/aspeed_gfx.h new file +104 -0

104 lines not on this page · raw message

drivers/gpu/drm/aspeed/aspeed_gfx_crtc.c new file +247 -0

247 lines not on this page · raw message

drivers/gpu/drm/aspeed/aspeed_gfx_drv.c new file +262 -0

262 lines not on this page · raw message

drivers/gpu/drm/aspeed/aspeed_gfx_out.c new file +48 -0

48 lines not on this page · raw message

Signature · 1 line
2.17.0
author maintainer
#2 lore raw

PATCH 2/5 drm: aspeed: Debugfs interface for GFX registers

In reply to Joel Stanley

This exposes the GFX registers in debugfs for debugging. The idea is borrowed from the Broadcom driver.

---
 drivers/gpu/drm/aspeed/Makefile             |  1 +
 drivers/gpu/drm/aspeed/aspeed_gfx.h         |  1 +
 drivers/gpu/drm/aspeed/aspeed_gfx_debugfs.c | 77 +++++++++++++++++++++
 drivers/gpu/drm/aspeed/aspeed_gfx_drv.c     |  4 ++
 4 files changed, 83 insertions(+)
 create mode 100644 drivers/gpu/drm/aspeed/aspeed_gfx_debugfs.c
drivers/gpu/drm/aspeed/Makefile +1 -0
index 6e194cd790d8..b01dd5800672 100644
@@ -1,3 +1,4 @@
 aspeed_gfx-y := aspeed_gfx_drv.o aspeed_gfx_crtc.o aspeed_gfx_out.o
+aspeed_gfx-$(CONFIG_DEBUG_FS) += aspeed_gfx_debugfs.o
 
 obj-$(CONFIG_DRM_ASPEED_GFX) += aspeed_gfx.o
drivers/gpu/drm/aspeed/aspeed_gfx.h +1 -0
index fb56e425bd48..c46afb3398cb 100644
@@ -17,6 +17,7 @@ struct aspeed_gfx {
 
 int aspeed_gfx_create_pipe(struct drm_device *drm);
 int aspeed_gfx_create_output(struct drm_device *drm);
+int aspeed_gfx_debugfs_init(struct drm_minor *minor);
 
 #define CRT_CTRL1		0x60 /* CRT Control I */
 #define CRT_CTRL2		0x64 /* CRT Control II */
drivers/gpu/drm/aspeed/aspeed_gfx_debugfs.c new file +77 -0

77 lines not on this page · raw message

drivers/gpu/drm/aspeed/aspeed_gfx_drv.c +4 -0
index fa76ff313a73..e9377d43459d 100644
@@ -200,6 +200,10 @@ static struct drm_driver aspeed_gfx_driver = {
 	.date = "20180319",
 	.major = 1,
 	.minor = 0,
+
+#if defined(CONFIG_DEBUG_FS)
+	.debugfs_init = aspeed_gfx_debugfs_init,
+#endif
 };
 
 static const struct of_device_id aspeed_gfx_match[] = {
Signature · 1 line
2.17.0
author maintainer
#3 lore raw

PATCH 3/5 ARM: dts: aspeed-g5: Add resets and clocks to GFX node

In reply to Joel Stanley

The ast2500 has a reset for the CRT device that must be deasserted before it can be used. Similarly it has a clock gate for a clock called D1CLK that must be set to running.

---
 arch/arm/boot/dts/aspeed-g5.dtsi | 4 ++++
 1 file changed, 4 insertions(+)
arch/arm/boot/dts/aspeed-g5.dtsi +4 -0
index 25a88dd44d91..4ca4bc463347 100644
@@ -175,6 +175,10 @@
 				compatible = "aspeed,ast2500-gfx", "syscon";
 				reg = <0x1e6e6000 0x1000>;
 				reg-io-width = <4>;
+				clocks = <&syscon ASPEED_CLK_GATE_D1CLK>;
+				resets = <&syscon ASPEED_RESET_CRT1>;
+				status = "disabled";
+				interrupts = <0x19>;
 			};
 
 			adc: adc@1e6e9000 {
Signature · 1 line
2.17.0
Reviewed-by on v1 3/5
#4 lore raw

Re: [PATCH linux dev-4.13 3/5] ARM: dts: aspeed-g5: Add resets and clocks to GFX node

Quoted 14 lines · Joel Stanley

The ast2500 has a reset for the CRT device that must be deasserted before it can be used. Similarly it has a clock gate for a clock called D1CLK that must be set to running.

---
 arch/arm/boot/dts/aspeed-g5.dtsi | 4 ++++
 1 file changed, 4 insertions(+)
arch/arm/boot/dts/aspeed-g5.dtsi +0 -0
index 25a88dd44d91..4ca4bc463347 100644

arch/arm/boot/dts/aspeed-g5.dtsi line 181

Quoted 7 lines
arch/arm/boot/dts/aspeed-g5.dtsi +4 -0
@@ -175,6 +175,10 @@
 				compatible = "aspeed,ast2500-gfx", "syscon";
 				reg = <0x1e6e6000 0x1000>;
 				reg-io-width = <4>;
+				clocks = <&syscon ASPEED_CLK_GATE_D1CLK>;
+				resets = <&syscon ASPEED_RESET_CRT1>;
+				status = "disabled";
+				interrupts = <0x19>;

Bit of a nit, but it would be easier to reference the documentation if the interrupt was base 10...

Quoted 6 lines
arch/arm/boot/dts/aspeed-g5.dtsi +0 -0
 			};
 
 			adc: adc@1e6e9000 {
Signature · 1 line
2.17.0
author maintainer
#5 lore raw

Re: [PATCH linux dev-4.13 3/5] ARM: dts: aspeed-g5: Add resets and clocks to GFX node

Quoted 10 lines · Andrew Jeffery
Quoted 9 lines · Joel Stanley

The ast2500 has a reset for the CRT device that must be deasserted before it can be used. Similarly it has a clock gate for a clock called D1CLK that must be set to running.

---
 arch/arm/boot/dts/aspeed-g5.dtsi | 4 ++++
 1 file changed, 4 insertions(+)
Quoted 14 lines

arch/arm/boot/dts/aspeed-g5.dtsi line 181

Quoted 12 lines
arch/arm/boot/dts/aspeed-g5.dtsi +4 -0
index 25a88dd44d91..4ca4bc463347 100644
@@ -175,6 +175,10 @@
                              compatible = "aspeed,ast2500-gfx", "syscon";
                              reg = <0x1e6e6000 0x1000>;
                              reg-io-width = <4>;
+                             clocks = <&syscon ASPEED_CLK_GATE_D1CLK>;
+                             resets = <&syscon ASPEED_RESET_CRT1>;
+                             status = "disabled";
+                             interrupts = <0x19>;

Bit of a nit, but it would be easier to reference the documentation if the interrupt was base 10...

I'm not sure why they are hex. I'd take an upstream patch to change them all over to base 10.

Quoted 2 lines

Thanks for reviewing.

Cheers,

Joel

author maintainer
#6 lore raw

PATCH 4/5 ARM: dts: ast2500-evb: Enable the GFX IP

In reply to Joel Stanley

The GFX controller is the internal graphics device used by the SoC (opposed to the one connected via the PCIe device and used by the host).

This configures it with a framebuffer region and adds it to the command line so kernel boot messages appear on the display.

---
 arch/arm/boot/dts/aspeed-ast2500-evb.dts | 21 ++++++++++++++++++++-
 1 file changed, 20 insertions(+), 1 deletion(-)
arch/arm/boot/dts/aspeed-ast2500-evb.dts +20 -1
index 45efac8f8806..c0a7f51e7eb6 100644
@@ -13,12 +13,26 @@
 
 	chosen {
 		stdout-path = &uart5;
-		bootargs = "console=ttyS4,115200 earlyprintk";
+		bootargs = "console=tty0 console=ttyS4,115200 earlyprintk";
 	};
 
 	memory@80000000 {
+		device_type = "memory";
 		reg = <0x80000000 0x20000000>;
 	};
+
+	reserved-memory {
+		#address-cells = <1>;
+		#size-cells = <1>;
+		ranges;
+
+		gfx_memory: framebuffer {
+			size = <0x01000000>;
+			alignment = <0x01000000>;
+			compatible = "shared-dma-pool";
+			reusable;
+		};
+	};
 };
 
 &fmc {
@@ -80,3 +94,8 @@
 		reg = <0x4d>;
 	};
 };
+
+&gfx {
+     status = "okay";
+     memory-region = <&gfx_memory>;
+};
Signature · 1 line
2.17.0
Reviewed-by on v1 4/5
#7 lore raw

Re: [PATCH linux dev-4.13 4/5] ARM: dts: ast2500-evb: Enable the GFX IP

Quoted 7 lines · Joel Stanley

The GFX controller is the internal graphics device used by the SoC (opposed to the one connected via the PCIe device and used by the host).

This configures it with a framebuffer region and adds it to the command line so kernel boot messages appear on the display.

Quoted 49 lines
---
 arch/arm/boot/dts/aspeed-ast2500-evb.dts | 21 ++++++++++++++++++++-
 1 file changed, 20 insertions(+), 1 deletion(-)
arch/arm/boot/ renamed from arch/arm/boot/dts/aspeed-ast2500-evb.dts +0 -0

dts/aspeed-ast2500-evb.dts
index 45efac8f8806..c0a7f51e7eb6 100644

arch/arm/boot/dts/aspeed-ast2500-evb.dts +20 -1
@@ -13,12 +13,26 @@
 
 	chosen {
 		stdout-path = &uart5;
-		bootargs = "console=ttyS4,115200 earlyprintk";
+		bootargs = "console=tty0 console=ttyS4,115200 earlyprintk";
 	};
 
 	memory@80000000 {
+		device_type = "memory";
 		reg = <0x80000000 0x20000000>;
 	};
+
+	reserved-memory {
+		#address-cells = <1>;
+		#size-cells = <1>;
+		ranges;
+
+		gfx_memory: framebuffer {
+			size = <0x01000000>;
+			alignment = <0x01000000>;
+			compatible = "shared-dma-pool";
+			reusable;
+		};
+	};
 };
 
 &fmc {
@@ -80,3 +94,8 @@
 		reg = <0x4d>;
 	};
 };
+
+&gfx {
+     status = "okay";
+     memory-region = <&gfx_memory>;
+};
Signature · 1 line
2.17.0
author maintainer
#8 lore raw

PATCH 5/5 ARM: dts: witherspoon: Enable the GFX IP

In reply to Joel Stanley

The GFX controller is the internal graphics device used by the SoC (opposed to the one connected via the PCIe device and used by the host).

This configures it with a framebuffer region and adds it to the command line so kernel boot messages appear on the display.

---
 arch/arm/boot/dts/aspeed-bmc-opp-witherspoon.dts | 8 ++++++++
 1 file changed, 8 insertions(+)
arch/arm/boot/dts/aspeed-bmc-opp-witherspoon.dts +8 -0
index e8e4d305a9cf..596608f4b936 100644
@@ -26,6 +26,13 @@
 			no-map;
 			reg = <0x98000000 0x04000000>; /* 64M */
 		};
+
+		gfx_memory: framebuffer {
+			size = <0x01000000>;
+			alignment = <0x01000000>;
+			compatible = "shared-dma-pool";
+			reusable;
+		};
 	};
 
 	gpio-keys {
@@ -617,6 +624,7 @@
 
 &gfx {
 	status = "okay";
+	memory-region = <&gfx_memory>;
 };
 
 &pinctrl {
Signature · 1 line
2.17.0
Reviewed-by on v1 5/5
#9 lore raw

Re: [PATCH linux dev-4.13 5/5] ARM: dts: witherspoon: Enable the GFX IP

Quoted 7 lines · Joel Stanley

The GFX controller is the internal graphics device used by the SoC (opposed to the one connected via the PCIe device and used by the host).

This configures it with a framebuffer region and adds it to the command line so kernel boot messages appear on the display.

Quoted 34 lines
---
 arch/arm/boot/dts/aspeed-bmc-opp-witherspoon.dts | 8 ++++++++
 1 file changed, 8 insertions(+)
arch/ renamed from arch/arm/boot/dts/aspeed-bmc-opp-witherspoon.dts +0 -0

arm/boot/dts/aspeed-bmc-opp-witherspoon.dts
index e8e4d305a9cf..596608f4b936 100644

arch/arm/boot/dts/aspeed-bmc-opp-witherspoon.dts +8 -0
@@ -26,6 +26,13 @@
 			no-map;
 			reg = <0x98000000 0x04000000>; /* 64M */
 		};
+
+		gfx_memory: framebuffer {
+			size = <0x01000000>;
+			alignment = <0x01000000>;
+			compatible = "shared-dma-pool";
+			reusable;
+		};
 	};
 
 	gpio-keys {
@@ -617,6 +624,7 @@
 
 &gfx {
 	status = "okay";
+	memory-region = <&gfx_memory>;
 };
 
 &pinctrl {
Signature · 1 line
2.17.0