Skip to contentSkip to conversation

drm/sun4i: Add basic LVDS support for A10

PATCH In review Priit Laes 4 participants 19 messages Feb 11, 2017 – Apr 20, 2017 2 messages not in the archive

Subsystems (7)
lore
Share & tools
lore

Priit Laes

author
#0 lore raw

cover drm/sun4i: Add basic LVDS support for A10

This series adds initial LVDS functionality for A10 SoC and includes display blocks (TCON, backend and frontend) for A10 dtsi and implements of mode property for TCON to allow switching between rgb/lvds output.

This series has been tested on Gemei G9 A10 tablet, but still relies on u-boot to properly set up LVDS reset controller.

---

Jonathan Liu (1):
ARM: sunxi_defconfig: Enable simple panel

Priit Laes (7):
ARM: sun4i: Add display blocks for the sun4i dtsi. drm/panel: simple: Add support for LG LP097x02-slq2 panel drm/sun4i: Add optional 'mode' property to TCON
drm/sun4i: Add encoder type argument to sun4i_tcon0_mode_set drm/sun4i: Add initial LVDS stub
drm/sun4i: Add various bits and pieces to enable LVDS support on sun4i
ARM: dts: sun4i: gemei-g9: Add LVDS display support

 .../bindings/display/sunxi/sun4i-drm.txt           |   3 +
 arch/arm/boot/dts/sun4i-a10-gemei-g9.dts           |  95 ++++++-
 arch/arm/boot/dts/sun4i-a10.dtsi                   | 104 ++++++++
 arch/arm/configs/sunxi_defconfig                   |   4 +
 drivers/gpu/drm/panel/panel-simple.c               |  25 ++
 drivers/gpu/drm/sun4i/Makefile                     |   1 +
 drivers/gpu/drm/sun4i/sun4i_lvds.c                 | 276 +++++++++++++++++++++
 drivers/gpu/drm/sun4i/sun4i_lvds.h                 |  15 ++
 drivers/gpu/drm/sun4i/sun4i_rgb.c                  |   2 +-
 drivers/gpu/drm/sun4i/sun4i_tcon.c                 |  57 ++++-
 drivers/gpu/drm/sun4i/sun4i_tcon.h                 |  18 +-
 11 files changed, 580 insertions(+), 20 deletions(-)
 create mode 100644 drivers/gpu/drm/sun4i/sun4i_lvds.c
 create mode 100644 drivers/gpu/drm/sun4i/sun4i_lvds.h
Signature · 6 lines
2.9.3

--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
author
#1 lore raw

PATCH 1/8 ARM: sunxi_defconfig: Enable simple panel

From: Jonathan Liu <[email protected]>

---
 arch/arm/configs/sunxi_defconfig | 4 ++++
 1 file changed, 4 insertions(+)
arch/arm/configs/sunxi_defconfig +4 -0
index da92c25..7abe6a4 100644
@@ -153,3 +153,7 @@ CONFIG_NLS_ISO8859_1=y
 CONFIG_PRINTK_TIME=y
 CONFIG_DEBUG_FS=y
 CONFIG_CRYPTO_DEV_SUN4I_SS=y
+CONFIG_BACKLIGHT_CLASS_DEVICE=y
+CONFIG_BACKLIGHT_LCD_SUPPORT=y
+CONFIG_BACKLIGHT_PWM=y
+CONFIG_DRM_PANEL_SIMPLE=y
Signature · 1 line
2.9.3
#2 lore raw

Re: [linux-sunxi] [PATCH 1/8] ARM: sunxi_defconfig: Enable simple panel

Quoted 2 lines · Priit Laes

From: Jonathan Liu <[email protected]>

This needs a commit message about why these need to be enabled, like

"Most Allwinner tablets use the same design of a dumb LCD panel coupled
with a PWM controlled backlight."

Also the subject does not mention CONFIG_BACKLIGHT_PWM being enabled.

Quoted 1 line

Since you are resending the patch, you must also add your SoB.

ChenYu

Quoted 19 lines
---
 arch/arm/configs/sunxi_defconfig | 4 ++++
 1 file changed, 4 insertions(+)
arch/arm/configs/sunxi_defconfig +4 -1
index da92c25..7abe6a4 100644
@@ -153,3 +153,7 @@ CONFIG_NLS_ISO8859_1=y
 CONFIG_PRINTK_TIME=y
 CONFIG_DEBUG_FS=y
 CONFIG_CRYPTO_DEV_SUN4I_SS=y
+CONFIG_BACKLIGHT_CLASS_DEVICE=y
+CONFIG_BACKLIGHT_LCD_SUPPORT=y
+CONFIG_BACKLIGHT_PWM=y
+CONFIG_DRM_PANEL_SIMPLE=y
--

2.9.3

Quoted 4 lines

--
You received this message because you are subscribed to the Google Groups "linux-sunxi" group.
To unsubscribe from this group and stop receiving emails from it, send an email to linux-sunxi+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/[email protected] For more options, visit https://groups.google.com/d/optout.

--
To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

author
#3 lore raw

PATCH 2/8 ARM: sun4i: Add display blocks for the sun4i dtsi.

In reply to Priit Laes

Added basic display pipeline consisting of tcon, display backend and frontend blocks.

---
 arch/arm/boot/dts/sun4i-a10.dtsi | 104 +++++++++++++++++++++++++++++++++++++++
 1 file changed, 104 insertions(+)
arch/arm/boot/dts/sun4i-a10.dtsi +104 -0
index ba20b48..70991c9 100644
@@ -779,6 +779,45 @@
 			#size-cells = <0>;
 		};
 
+		tcon0: lcd-controller@1c0c000 {
+			compatible = "allwinner,sun5i-a13-tcon";
+			reg = <0x01c0c000 0x1000>;
+			interrupts = <44>;
+			resets = <&tcon0_ch0_clk 1>;
+			reset-names = "lcd";
+			clocks = <&ahb_gates 36>,
+				 <&tcon0_ch0_clk>,
+				 <&tcon0_ch1_clk>;
+			clock-names = "ahb",
+				      "tcon-ch0",
+				      "tcon-ch1";
+			clock-output-names = "tcon-pixel-clock";
+			status = "disabled";
+
+			ports {
+				#address-cells = <1>;
+				#size-cells = <0>;
+
+				tcon0_in: port@0 {
+					#address-cells = <1>;
+					#size-cells = <0>;
+					reg = <0>;
+
+					tcon0_in_be0: endpoint@0 {
+						reg = <0>;
+						remote-endpoint = <&be0_out_tcon0>;
+					};
+				};
+
+				tcon0_out: port@1 {
+					#address-cells = <1>;
+					#size-cells = <0>;
+					reg = <1>;
+				};
+			};
+		};
+
+
 		mmc0: mmc@01c0f000 {
 			compatible = "allwinner,sun4i-a10-mmc";
 			reg = <0x01c0f000 0x1000>;
@@ -1328,5 +1367,70 @@
 			clocks = <&apb1_gates 7>;
 			status = "disabled";
 		};
+
+		fe0: display-frontend@1e00000 {
+			compatible = "allwinner,sun5i-a13-display-frontend";
+			reg = <0x01e00000 0x20000>;
+			interrupts = <47>;
+			clocks = <&ahb_gates 46>, <&de_fe0_clk>,
+				 <&dram_gates 25>;
+			clock-names = "ahb", "mod",
+				      "ram";
+			resets = <&de_fe0_clk>;
+			status = "disabled";
+
+			ports {
+				#address-cells = <1>;
+				#size-cells = <0>;
+
+				fe0_out: port@1 {
+					#address-cells = <1>;
+					#size-cells = <0>;
+					reg = <1>;
+
+					fe0_out_be0: endpoint {
+						remote-endpoint = <&be0_in_fe0>;
+					};
+				};
+			};
+		};
+
+		be0: display-backend@1e60000 {
+			compatible = "allwinner,sun5i-a13-display-backend";
+			reg = <0x01e60000 0x10000>;
+			clocks = <&ahb_gates 44>, <&de_be0_clk>,
+				 <&dram_gates 26>;
+			clock-names = "ahb", "mod",
+				      "ram";
+			resets = <&de_be0_clk>;
+			status = "disabled";
+
+			ports {
+				#address-cells = <1>;
+				#size-cells = <0>;
+
+				be0_in: port@0 {
+					#address-cells = <1>;
+					#size-cells = <0>;
+					reg = <0>;
+
+					be0_in_fe0: endpoint@0 {
+						reg = <0>;
+						remote-endpoint = <&fe0_out_be0>;
+					};
+				};
+
+				be0_out: port@1 {
+					#address-cells = <1>;
+					#size-cells = <0>;
+					reg = <1>;
+
+					be0_out_tcon0: endpoint@0 {
+						reg = <0>;
+						remote-endpoint = <&tcon0_in_be0>;
+					};
+				};
+			};
+		};
 	};
 };
Signature · 1 line
2.9.3
#4 lore raw

Re: [PATCH 2/8] ARM: sun4i: Add display blocks for the sun4i dtsi.

Hi,

Quoted 13 lines · Priit Laes

Added basic display pipeline consisting of tcon, display backend and frontend blocks.

---
 arch/arm/boot/dts/sun4i-a10.dtsi | 104 +++++++++++++++++++++++++++++++++++++++
 1 file changed, 104 insertions(+)
arch/arm/boot/dts/sun4i-a10.dtsi +0 -0
index ba20b48..70991c9 100644

arch/arm/boot/dts/sun4i-a10.dtsi line 783

Quoted 5 lines
arch/arm/boot/dts/sun4i-a10.dtsi +2 -0
@@ -779,6 +779,45 @@
 			#size-cells = <0>;
 		};
 
+		tcon0: lcd-controller at 1c0c000 {
+			compatible = "allwinner,sun5i-a13-tcon";

There's a few bits here and there that need to be setup differently in A10, so you cannot reuse that compatible (same thing for the other).

Also, I'd really like to have all the blocks listed here, and not only the first pipeline. Ideally, on the A10, the two pipelines should be enabled too.

Maxime

Signature · 10 lines
Maxime Ripard, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 801 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20170213/f23f38dd/attachment.sig>
#5 lore raw

Re: [PATCH 2/8] ARM: sun4i: Add display blocks for the sun4i dtsi.

Quoted 25 lines · Maxime Ripard

Hi,

Quoted 13 lines · Priit Laes

Added basic display pipeline consisting of tcon, display backend and frontend blocks.

---
 arch/arm/boot/dts/sun4i-a10.dtsi | 104 +++++++++++++++++++++++++++++++++++++++
 1 file changed, 104 insertions(+)
arch/arm/boot/dts/sun4i-a10.dtsi +0 -0
index ba20b48..70991c9 100644

arch/arm/boot/dts/sun4i-a10.dtsi line 783

Quoted 5 lines
arch/arm/boot/dts/sun4i-a10.dtsi +2 -0
@@ -779,6 +779,45 @@
                      #size-cells = <0>;
              };
 
+             tcon0: lcd-controller@1c0c000 {
+                     compatible = "allwinner,sun5i-a13-tcon";

There's a few bits here and there that need to be setup differently in A10, so you cannot reuse that compatible (same thing for the other).

Quoted 3 lines

Also, I'd really like to have all the blocks listed here, and not only the first pipeline. Ideally, on the A10, the two pipelines should be enabled too.

The display pipeline driver has to be fixed before that can happen though. And I haven't started to work on what I proposed yet. Though if someone wants to take over I can forward any design plans I have.

ChenYu

Quoted 7 lines

Maxime

--
Maxime Ripard, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com

author
#6 lore raw

Re: [linux-sunxi] Re: [PATCH 2/8] ARM: sun4i: Add display blocks for the sun4i dtsi.

Quoted 38 lines · Chen-Yu Tsai
Quoted 30 lines · Maxime Ripard

Hi,

Quoted 16 lines · Priit Laes

Added basic display pipeline consisting of tcon, display backend and
frontend blocks.

---
 arch/arm/boot/dts/sun4i-a10.dtsi | 104
+++++++++++++++++++++++++++++++++++++++

 1 file changed, 104 insertions(+)
arch/arm/boot/dts/sun4i-a10.dtsi +0 -0
index ba20b48..70991c9 100644

arch/arm/boot/dts/sun4i-a10.dtsi line 783

Quoted 5 lines
arch/arm/boot/dts/sun4i-a10.dtsi +2 -0
@@ -779,6 +779,45 @@
                       #size-cells = <0>;
               };
 
+             tcon0: lcd-controller@1c0c000 {
+                     compatible = "allwinner,sun5i-a13-tcon";

There's a few bits here and there that need to be setup differently in
A10, so you cannot reuse that compatible (same thing for the other).

Quoted 5 lines

Also, I'd really like to have all the blocks listed here, and not only
the first pipeline. Ideally, on the A10, the two pipelines should be
enabled too.

Quoted 3 lines

The display pipeline driver has to be fixed before that can happen though. And I haven't started to work on what I proposed yet. Though if someone wants to take over I can forward any design plans I have.

Well, my plan was to get at least minimum bits mainlined and then build additional features on top.

Wens, it would be cool though, if you could share your plans.

Unfortunately I have only single A10 device (with LVDS and mini-HDMI) but I don't actually have other LVDS-displays I could easily use with A20 devices (I have CubieTruck and A20-Olinuxino Micro).

Päikest,
Priit :)
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

#7 lore raw

Re: [linux-sunxi] Re: [PATCH 2/8] ARM: sun4i: Add display blocks for the sun4i dtsi.

Hi,

Quoted 39 lines · Priit Laes
Quoted 38 lines · Chen-Yu Tsai
Quoted 35 lines · Maxime Ripard

Hi,

Quoted 16 lines · Priit Laes

Added basic display pipeline consisting of tcon, display backend and
frontend blocks.

---
 arch/arm/boot/dts/sun4i-a10.dtsi | 104
+++++++++++++++++++++++++++++++++++++++

 1 file changed, 104 insertions(+)
arch/arm/boot/dts/sun4i-a10.dtsi +0 -0
index ba20b48..70991c9 100644

arch/arm/boot/dts/sun4i-a10.dtsi line 783

Quoted 5 lines
arch/arm/boot/dts/sun4i-a10.dtsi +2 -0
@@ -779,6 +779,45 @@
                       #size-cells = <0>;
               };
 
+             tcon0: lcd-controller@1c0c000 {
+                     compatible = "allwinner,sun5i-a13-tcon";

There's a few bits here and there that need to be setup differently in
A10, so you cannot reuse that compatible (same thing for the other).

Also, I'd really like to have all the blocks listed here, and not only
the first pipeline. Ideally, on the A10, the two pipelines should be
enabled too.

Quoted 6 lines
Quoted 3 lines

The display pipeline driver has to be fixed before that can happen though. And I haven't started to work on what I proposed yet. Though if someone wants to take over I can forward any design plans I have.

Well, my plan was to get at least minimum bits mainlined and then build additional features on top.

I understand that, but now that we have the DT stability to maintain, I want to make sure that everything is correctly represented from day one, with code that works.

Otherwise, we might or might not be able to fix things properly later down the road (or at the expense of ugly hacks).

Maxime

Signature · 8 lines
Maxime Ripard, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com

-- 
You received this message because you are subscribed to the Google Groups "linux-sunxi" group.
To unsubscribe from this group and stop receiving emails from it, send an email to linux-sunxi+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/[email protected]
For more options, visit https://groups.google.com/d/optout.

A message that is not in the archive (sent off-list or not yet received): 1487004405.20308.3.camel-q/[email protected]

#9 lore raw

Re: Re: [PATCH 2/8] ARM: sun4i: Add display blocks for the sun4i dtsi.

Hi

If you want I work with a Allwinner A20 (my board are derived from OlinuXino-Micro-A20), and I will interest with LVDS function.

I use your patch but I have nothing to display on my screen. You can see my work on
https://github.com/Philippe12/linux-sunxi/tree/sun7i-A20-lvds
My hardware is good, it word with u-boot and a older kernel 3.4.104

I use a dlc screen (dlc0700DDG-T-11) my fault is probably on simple-panel information but I didn't seen were

If you can tell me some things to check.

Thank for your help
Best regards
Philippe FOUQUET

Quoted 56 lines · Priit Laes
Quoted 38 lines · Chen-Yu Tsai
Quoted 30 lines · On Mon, Feb 13, 2017 at 5:16 PM, Maxime Ripard…

Hi,

Quoted 16 lines · Priit Laes

Added basic display pipeline consisting of tcon, display backend and
frontend blocks.

Signed-off-by Priit Laes <pl...-q/[email protected] <javascript:>>

---

 arch/arm/boot/dts/sun4i-a10.dtsi | 104 
+++++++++++++++++++++++++++++++++++++++ 
 1 file changed, 104 insertions(+) 
arch/arm/boot/dts/sun4i-a10.dtsi +0 -0
index ba20b48..70991c9 100644 

arch/arm/boot/dts/sun4i-a10.dtsi line 783

Quoted 5 lines
arch/arm/boot/dts/sun4i-a10.dtsi +2 -0
@@ -779,6 +779,45 @@ 
                      #size-cells = <0>; 
              }; 
 
+             tcon0: lcd-controller@1c0c000 { 
+                     compatible = "allwinner,sun5i-a13-tcon"; 

There's a few bits here and there that need to be setup differently in
A10, so you cannot reuse that compatible (same thing for the other).

Quoted 5 lines

Also, I'd really like to have all the blocks listed here, and not only
the first pipeline. Ideally, on the A10, the two pipelines should be
enabled too.

Quoted 3 lines

The display pipeline driver has to be fixed before that can happen though. And I haven't started to work on what I proposed yet. Though if someone wants to take over I can forward any design plans I have.

Well, my plan was to get at least minimum bits mainlined and then build additional features on top.

Wens, it would be cool though, if you could share your plans.

Unfortunately I have only single A10 device (with LVDS and mini-HDMI) but I don't actually have other LVDS-displays I could easily use with A20 devices (I have CubieTruck and A20-Olinuxino Micro).

Päikest,
Priit :)

Signature · 3 lines
You received this message because you are subscribed to the Google Groups "linux-sunxi" group.
To unsubscribe from this group and stop receiving emails from it, send an email to linux-sunxi+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/[email protected]
For more options, visit https://groups.google.com/d/optout.
author
#10 lore raw

PATCH 3/8 drm/panel: simple: Add support for LG LP097x02-slq2 panel

In reply to Priit Laes

Add simple-panel support for the LG LP097x02-slq2, which is 10" 1024x768 LVDS panel.

---
 drivers/gpu/drm/panel/panel-simple.c | 25 +++++++++++++++++++++++++
 1 file changed, 25 insertions(+)
drivers/gpu/drm/panel/panel-simple.c +25 -0
index 06aaf79..2948fed 100644
@@ -1205,6 +1205,28 @@ static const struct panel_desc lg_lp097qx1_spa1 = {
 	},
 };
 
+static const struct drm_display_mode lg_lp097x02_slq2_mode = {
+    .clock = 100000,
+    .hdisplay = 1024,
+    .hsync_start = 1024 + 260,
+    .hsync_end = 1024 + 260 + 1,
+    .htotal = 1024 + 260 + 1 + 799,
+    .vdisplay = 768,
+    .vsync_start = 768 + 16,
+    .vsync_end = 768 + 16 + 1,
+    .vtotal = 768 + 16 + 1 + 15,
+    .vrefresh = 60,
+};
+
+static const struct panel_desc lg_lp097x02_slq2 = {
+    .modes = &lg_lp097x02_slq2_mode,
+    .num_modes = 1,
+    .size = {
+        .width = 197,
+        .height = 147,
+    },
+};
+
 static const struct drm_display_mode lg_lp120up1_mode = {
 	.clock = 162300,
 	.hdisplay = 1920,
@@ -1817,6 +1839,9 @@ static const struct of_device_id platform_of_match[] = {
 		.compatible = "lg,lp097qx1-spa1",
 		.data = &lg_lp097qx1_spa1,
 	}, {
+		.compatible = "lg,lp097x02-slq2",
+		.data = &lg_lp097x02_slq2,
+	}, {
 		.compatible = "lg,lp120up1",
 		.data = &lg_lp120up1,
 	}, {
Signature · 1 line
2.9.3
author
#11 lore raw

PATCH 4/8 drm/sun4i: Add optional 'mode' property to TCON

In reply to Priit Laes

Add variable to enable either 'rgb' or 'lvds' output.

---
 Documentation/devicetree/bindings/display/sunxi/sun4i-drm.txt | 3 +++
 1 file changed, 3 insertions(+)
Documentation/devicetree/bindings/display/sunxi/sun4i-drm.txt +3 -0
index b82c004..c367ede 100644
@@ -43,6 +43,9 @@ Required properties:
  - reset-names: the reset names mentioned above
  - clock-output-names: Name of the pixel clock created
 
+- mode: Defines which encoder will be enabled. Values are 'rgb', 'lvds'.
+  Defaults to 'rgb' if not set.
+
 - ports: A ports node with endpoint definitions as defined in
   Documentation/devicetree/bindings/media/video-interfaces.txt. The
   first port should be the input endpoint, the second one the output
Signature · 1 line
2.9.3

A message that is not in the archive (sent off-list or not yet received): 20170211174405.28395-5-plaes-q/[email protected]

#13 lore raw

Re: [PATCH 4/8] drm/sun4i: Add optional 'mode' property to TCON

First way thank for this work
But I can't use it, I'm explain myself.

My LVDS connexion works fine because I display correctly the console under uboot (I work with CONFIG_VIDEO_LCD_MODE)

I use the wiki : http://linux-sunxi.org/LCD to convert my fex config to CONFIG_VIDEO_LCD_MODE for the uboot all work fine

But for the kernel nothing, I have some crazy line or black screen.

- I add my lcd configuration into simple_panel.c (
http://linux-sunxi.org/LCD)
- I can seen the debug ligne came from LVDS driver.
- My LCD screen is a dlc070ddg 7' 800x480 LVDS 18bits.
- I work with a Olimex_A20-OLinuXino-Micro
<http://linux-sunxi.org/Olimex_A20-OLinuXino-Micro>.

I don't know where I can search If some body have a idea?

Thanks

Quoted 27 lines · Priit Laes

Add variable to enable either 'rgb' or 'lvds' output.

Signed-off-by Priit Laes <pl...-q/[email protected] <javascript:>>

---

 Documentation/devicetree/bindings/display/sunxi/sun4i-drm.txt | 3 +++ 
 1 file changed, 3 insertions(+) 
Documentation/devicetree/bindings/display/sunxi/sun4i-drm.txt +3 -0
index b82c004..c367ede 100644 
@@ -43,6 +43,9 @@ Required properties: 
  - reset-names: the reset names mentioned above 
  - clock-output-names: Name of the pixel clock created 
 
+- mode: Defines which encoder will be enabled. Values are 'rgb', 'lvds'. 
+  Defaults to 'rgb' if not set. 
+ 
 - ports: A ports node with endpoint definitions as defined in 
   Documentation/devicetree/bindings/media/video-interfaces.txt. The 
   first port should be the input endpoint, the second one the output 
Signature · 1 line
2.9.3 
Signature · 3 lines
You received this message because you are subscribed to the Google Groups "linux-sunxi" group.
To unsubscribe from this group and stop receiving emails from it, send an email to linux-sunxi+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/[email protected]
For more options, visit https://groups.google.com/d/optout.
#14 lore raw

Re: [PATCH 4/8] drm/sun4i: Add optional 'mode' property to TCON

In reply to Priit Laes

Hi,

Quoted 12 lines · Priit Laes

Add variable to enable either 'rgb' or 'lvds' output.

---
 Documentation/devicetree/bindings/display/sunxi/sun4i-drm.txt | 3 +++
 1 file changed, 3 insertions(+)
Documentation/devicetree/bindings/display/sunxi/sun4i-drm.txt +0 -0
index b82c004..c367ede 100644

Documentation/devicetree/bindings/display/sunxi/sun4i-drm.txt Required properties: · line 48

Quoted 6 lines
Documentation/devicetree/bindings/display/sunxi/sun4i-drm.txt +3 -0
@@ -43,6 +43,9 @@ Required properties:
  - reset-names: the reset names mentioned above
  - clock-output-names: Name of the pixel clock created
 
+- mode: Defines which encoder will be enabled. Values are 'rgb', 'lvds'.
+  Defaults to 'rgb' if not set.
+

Unfortunately, this won't really work. You could very well have two panels and switch from one to another by changing the pin muxing, so we have to use an enpoint for that.

This is pretty much the same case that we have with the A10s where we need to have two output endpoints for the TV Encoder and HDMI, something we cannot support right now in our binding, since we assume that we have the two channels that only have one user, which turned out to be wrong.

I guess an easy way would be to have an extra property defining which channel the endpoint is attached to.

Thanks,
Maxime

Signature · 3 lines
Maxime Ripard, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com
author
#15 lore raw

PATCH 5/8 drm/sun4i: Add encoder type argument to sun4i_tcon0_mode_set

In reply to Priit Laes

Depending on the output type, we have to enable/disable some bits conditionally.

---
 drivers/gpu/drm/sun4i/sun4i_rgb.c  | 2 +-
 drivers/gpu/drm/sun4i/sun4i_tcon.c | 3 ++-
 drivers/gpu/drm/sun4i/sun4i_tcon.h | 3 ++-
 3 files changed, 5 insertions(+), 3 deletions(-)
drivers/gpu/drm/sun4i/sun4i_rgb.c +1 -1
index f5e86fe..3d4eb05 100644
@@ -179,7 +179,7 @@ static void sun4i_rgb_encoder_mode_set(struct drm_encoder *encoder,
 	struct sun4i_drv *drv = rgb->drv;
 	struct sun4i_tcon *tcon = drv->tcon;
 
-	sun4i_tcon0_mode_set(tcon, mode);
+	sun4i_tcon0_mode_set(tcon, mode, DRM_MODE_ENCODER_DAC);
 
 	clk_set_rate(tcon->dclk, mode->crtc_clock * 1000);
 
drivers/gpu/drm/sun4i/sun4i_tcon.c +2 -1
index ea2906f..71d0087 100644
@@ -124,7 +124,8 @@ static int sun4i_tcon_get_clk_delay(struct drm_display_mode *mode,
 }
 
 void sun4i_tcon0_mode_set(struct sun4i_tcon *tcon,
-			  struct drm_display_mode *mode)
+			  struct drm_display_mode *mode,
+			  int type)
 {
 	unsigned int bp, hsync, vsync;
 	u8 clk_delay;
drivers/gpu/drm/sun4i/sun4i_tcon.h +2 -1
index 166064b..b040e10 100644
@@ -188,7 +188,8 @@ void sun4i_tcon_enable_vblank(struct sun4i_tcon *tcon, bool enable);
 void sun4i_tcon_switch_interlace(struct sun4i_tcon *tcon,
 				 bool enable);
 void sun4i_tcon0_mode_set(struct sun4i_tcon *tcon,
-			  struct drm_display_mode *mode);
+			  struct drm_display_mode *mode,
+			  int type);
 void sun4i_tcon1_mode_set(struct sun4i_tcon *tcon,
 			  struct drm_display_mode *mode);
 
Signature · 1 line
2.9.3
#16 lore raw

Re: [PATCH 5/8] drm/sun4i: Add encoder type argument to sun4i_tcon0_mode_set

Quoted 15 lines · Priit Laes

Depending on the output type, we have to enable/disable some bits conditionally.

---
 drivers/gpu/drm/sun4i/sun4i_rgb.c  | 2 +-
 drivers/gpu/drm/sun4i/sun4i_tcon.c | 3 ++-
 drivers/gpu/drm/sun4i/sun4i_tcon.h | 3 ++-
 3 files changed, 5 insertions(+), 3 deletions(-)
drivers/gpu/drm/sun4i/sun4i_rgb.c +0 -0
index f5e86fe..3d4eb05 100644

drivers/gpu/drm/sun4i/sun4i_rgb.c static void sun4i_rgb_encoder_mode_set(struct drm_encoder *encoder, · line 182

Quoted 5 lines
drivers/gpu/drm/sun4i/sun4i_rgb.c +1 -1
@@ -179,7 +179,7 @@ static void sun4i_rgb_encoder_mode_set(struct drm_encoder *encoder,
 	struct sun4i_drv *drv = rgb->drv;
 	struct sun4i_tcon *tcon = drv->tcon;
 
-	sun4i_tcon0_mode_set(tcon, mode);
+	sun4i_tcon0_mode_set(tcon, mode, DRM_MODE_ENCODER_DAC);

This is not the proper encoder type. You can just use encoder_type in drm_encoder.

Maxime

Signature · 10 lines
Maxime Ripard, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 801 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20170213/102fab86/attachment.sig>
author
#17 lore raw

PATCH 6/8 drm/sun4i: Add initial LVDS stub

In reply to Priit Laes
---
 drivers/gpu/drm/sun4i/Makefile     |   1 +
 drivers/gpu/drm/sun4i/sun4i_lvds.c | 247 +++++++++++++++++++++++++++++++++++++
 drivers/gpu/drm/sun4i/sun4i_lvds.h |  15 +++
 3 files changed, 263 insertions(+)
 create mode 100644 drivers/gpu/drm/sun4i/sun4i_lvds.c
 create mode 100644 drivers/gpu/drm/sun4i/sun4i_lvds.h
drivers/gpu/drm/sun4i/Makefile +1 -0
index d625a82..5dfbe16 100644
@@ -11,3 +11,4 @@ obj-$(CONFIG_DRM_SUN4I)		+= sun4i-drm.o sun4i-tcon.o
 obj-$(CONFIG_DRM_SUN4I)		+= sun4i_backend.o
 obj-$(CONFIG_DRM_SUN4I)		+= sun6i_drc.o
 obj-$(CONFIG_DRM_SUN4I)		+= sun4i_tv.o
+obj-$(CONFIG_DRM_SUN4I)		+= sun4i_lvds.o
drivers/gpu/drm/sun4i/sun4i_lvds.c new file +247 -0

247 lines not on this page · raw message

drivers/gpu/drm/sun4i/sun4i_lvds.h new file +15 -0
new file mode 100644
index 0000000..1fc9646
@@ -0,0 +1,15 @@
+/*
+ * Copyright (C) 2016 Priit Laes <plaes-q/[email protected]>
+ *
+ * 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 _SUN4I_LVDS_H_
+#define _SUN4I_LVDS_H_
+
+int sun4i_lvds_init(struct drm_device *drm);
+
+#endif /* _SUN4I_LVDS_H_ */
Signature · 1 line
2.9.3
author
#18 lore raw

PATCH 7/8 drm/sun4i: Add various bits and pieces to enable LVDS support on sun4i

In reply to Priit Laes

TODO: We still rely on u-boot for lvds reset bit setup :(

---
 drivers/gpu/drm/sun4i/sun4i_lvds.c | 29 ++++++++++++++++++++
 drivers/gpu/drm/sun4i/sun4i_tcon.c | 54 ++++++++++++++++++++++++++++++++------
 drivers/gpu/drm/sun4i/sun4i_tcon.h | 15 +++++++++++
 3 files changed, 90 insertions(+), 8 deletions(-)
drivers/gpu/drm/sun4i/sun4i_lvds.c +29 -0
index 2ba4705..de738e5 100644
@@ -114,6 +114,35 @@ static void sun4i_lvds_encoder_enable(struct drm_encoder *encoder)
 	/* encoder->bridge can be NULL; drm_bridge_enable checks for it */
 	drm_bridge_enable(encoder->bridge);
 
+	/* Enable the LVDS */
+	regmap_update_bits(tcon->regs, SUN4I_TCON0_LVDS_IF_REG,
+			   SUN4I_TCON0_LVDS_IF_ENABLE,
+			   SUN4I_TCON0_LVDS_IF_ENABLE);
+
+	/*
+	 * TODO: SUN4I_TCON0_LVDS_ANA0_REG_C and SUN4I_TCON0_LVDS_ANA0_PD
+	 * registers span 3 bits, but we only set upper 2 for both
+	 * of them based on values taken from Allwinner driver.
+	 */
+	regmap_write(tcon->regs, SUN4I_TCON0_LVDS_ANA0_REG,
+		     SUN4I_TCON0_LVDS_ANA0_CK_EN |
+		     SUN4I_TCON0_LVDS_ANA0_REG_V |
+		     SUN4I_TCON0_LVDS_ANA0_REG_C |
+		     SUN4I_TCON0_LVDS_ANA0_EN_MB |
+		     SUN4I_TCON0_LVDS_ANA0_PD |
+		     SUN4I_TCON0_LVDS_ANA0_DCHS);
+
+	udelay(2000);
+
+	regmap_write(tcon->regs, SUN4I_TCON0_LVDS_ANA1_REG,
+		     SUN4I_TCON0_LVDS_ANA1_INIT);
+
+	udelay(1000);
+
+	regmap_update_bits(tcon->regs, SUN4I_TCON0_LVDS_ANA1_REG,
+			   SUN4I_TCON0_LVDS_ANA1_UPDATE,
+		           SUN4I_TCON0_LVDS_ANA1_UPDATE);
+
 	sun4i_tcon_channel_enable(tcon, 0);
 }
 
drivers/gpu/drm/sun4i/sun4i_tcon.c +46 -8

91 lines not on this page · raw message

drivers/gpu/drm/sun4i/sun4i_tcon.h +15 -0
index b040e10..dc4e350 100644
@@ -69,8 +69,11 @@
 #define SUN4I_TCON0_TTL3_REG			0x7c
 #define SUN4I_TCON0_TTL4_REG			0x80
 #define SUN4I_TCON0_LVDS_IF_REG			0x84
+#define SUN4I_TCON0_LVDS_IF_ENABLE			BIT(31)
+#define SUN4I_TCON0_LVDS_IF_BITWIDTH			BIT(26)
 #define SUN4I_TCON0_IO_POL_REG			0x88
 #define SUN4I_TCON0_IO_POL_DCLK_PHASE(phase)		((phase & 3) << 28)
+#define SUN4I_TCON0_IO_POL_DCLK_PHASE_MASK		(3 << 28)
 #define SUN4I_TCON0_IO_POL_HSYNC_POSITIVE		BIT(25)
 #define SUN4I_TCON0_IO_POL_VSYNC_POSITIVE		BIT(24)
 
@@ -128,6 +131,18 @@
 #define SUN4I_TCON_CEU_RANGE_G_REG		0x144
 #define SUN4I_TCON_CEU_RANGE_B_REG		0x148
 #define SUN4I_TCON_MUX_CTRL_REG			0x200
+#define SUN4I_TCON0_LVDS_ANA0_REG		0x220
+#define SUN4I_TCON0_LVDS_ANA0_CK_EN			BIT(29) | BIT(28)
+#define SUN4I_TCON0_LVDS_ANA0_REG_V			BIT(27) | BIT(26)
+/* TODO: BIT(23) also belongs to ANA0_REG_C register set */
+#define SUN4I_TCON0_LVDS_ANA0_REG_C			BIT(25) | BIT(24)
+#define SUN4I_TCON0_LVDS_ANA0_EN_MB			BIT(22)
+/* TODO: BIT(19) also belongs to ANA0_PD register set */
+#define SUN4I_TCON0_LVDS_ANA0_PD			BIT(21) | BIT(20)
+#define SUN4I_TCON0_LVDS_ANA0_DCHS			BIT(16)
+#define SUN4I_TCON0_LVDS_ANA1_REG		0x224
+#define SUN4I_TCON0_LVDS_ANA1_INIT			(0x1f << 26 | 0x1f << 10)
+#define SUN4I_TCON0_LVDS_ANA1_UPDATE			(0x1f << 16 | 0x1f << 00)
 #define SUN4I_TCON1_FILL_CTL_REG		0x300
 #define SUN4I_TCON1_FILL_BEG0_REG		0x304
 #define SUN4I_TCON1_FILL_END0_REG		0x308
Signature · 1 line
2.9.3
#19 lore raw

Re: [PATCH 7/8] drm/sun4i: Add various bits and pieces to enable LVDS support on sun4i

Quoted 1 line · Priit Laes

TODO: We still rely on u-boot for lvds reset bit setup :(

That needs to be figured out before merging :/

You also have a number of checkpatch warnings / errors that needs to be fixed.

Quoted 36 lines
---
 drivers/gpu/drm/sun4i/sun4i_lvds.c | 29 ++++++++++++++++++++
 drivers/gpu/drm/sun4i/sun4i_tcon.c | 54 ++++++++++++++++++++++++++++++++------
 drivers/gpu/drm/sun4i/sun4i_tcon.h | 15 +++++++++++
 3 files changed, 90 insertions(+), 8 deletions(-)
drivers/gpu/drm/sun4i/sun4i_lvds.c +20 -0
index 2ba4705..de738e5 100644
@@ -114,6 +114,35 @@ static void sun4i_lvds_encoder_enable(struct drm_encoder *encoder)
 	/* encoder->bridge can be NULL; drm_bridge_enable checks for it */
 	drm_bridge_enable(encoder->bridge);
 
+	/* Enable the LVDS */
+	regmap_update_bits(tcon->regs, SUN4I_TCON0_LVDS_IF_REG,
+			   SUN4I_TCON0_LVDS_IF_ENABLE,
+			   SUN4I_TCON0_LVDS_IF_ENABLE);
+
+	/*
+	 * TODO: SUN4I_TCON0_LVDS_ANA0_REG_C and SUN4I_TCON0_LVDS_ANA0_PD
+	 * registers span 3 bits, but we only set upper 2 for both
+	 * of them based on values taken from Allwinner driver.
+	 */
+	regmap_write(tcon->regs, SUN4I_TCON0_LVDS_ANA0_REG,
+		     SUN4I_TCON0_LVDS_ANA0_CK_EN |
+		     SUN4I_TCON0_LVDS_ANA0_REG_V |
+		     SUN4I_TCON0_LVDS_ANA0_REG_C |
+		     SUN4I_TCON0_LVDS_ANA0_EN_MB |
+		     SUN4I_TCON0_LVDS_ANA0_PD |
+		     SUN4I_TCON0_LVDS_ANA0_DCHS);
+
+	udelay(2000);
+

drivers/gpu/drm/sun4i/sun4i_lvds.c static void sun4i_lvds_encoder_enable(struct drm_encoder *encoder) · line 146

Quoted 10 lines
drivers/gpu/drm/sun4i/sun4i_lvds.c +9 -0
+	regmap_write(tcon->regs, SUN4I_TCON0_LVDS_ANA1_REG,
+		     SUN4I_TCON0_LVDS_ANA1_INIT);
+
+	udelay(1000);
+
+	regmap_update_bits(tcon->regs, SUN4I_TCON0_LVDS_ANA1_REG,
+			   SUN4I_TCON0_LVDS_ANA1_UPDATE,
+		           SUN4I_TCON0_LVDS_ANA1_UPDATE);
+
 	sun4i_tcon_channel_enable(tcon, 0);

This should be merged in your patch 6.

Quoted 31 lines
drivers/gpu/drm/sun4i/sun4i_lvds.c +0 -0
 }
 
drivers/gpu/drm/sun4i/sun4i_tcon.c +2 -5
index 71d0087..468a3ce 100644
@@ -18,6 +18,7 @@
 #include <drm/drm_panel.h>
 
 #include <linux/component.h>
+#include <linux/delay.h>
 #include <linux/ioport.h>
 #include <linux/of_address.h>
 #include <linux/of_device.h>
@@ -29,6 +30,7 @@
 #include "sun4i_crtc.h"
 #include "sun4i_dotclock.h"
 #include "sun4i_drv.h"
+#include "sun4i_lvds.h"
 #include "sun4i_rgb.h"
 #include "sun4i_tcon.h"
 
@@ -169,12 +171,29 @@ void sun4i_tcon0_mode_set(struct sun4i_tcon *tcon,
 		     SUN4I_TCON0_BASIC2_V_BACKPORCH(bp));
 
 	/* Set Hsync and Vsync length */
-	hsync = mode->crtc_hsync_end - mode->crtc_hsync_start;
-	vsync = mode->crtc_vsync_end - mode->crtc_vsync_start;
-	DRM_DEBUG_DRIVER("Setting HSYNC %d, VSYNC %d\n", hsync, vsync);
-	regmap_write(tcon->regs, SUN4I_TCON0_BASIC3_REG,
-		     SUN4I_TCON0_BASIC3_V_SYNC(vsync) |

drivers/gpu/drm/sun4i/sun4i_tcon.c void sun4i_tcon0_mode_set(struct sun4i_tcon *tcon, · line 182

Quoted 10 lines
drivers/gpu/drm/sun4i/sun4i_tcon.c +9 -1
-		     SUN4I_TCON0_BASIC3_H_SYNC(hsync));
+	if (type != DRM_MODE_ENCODER_LVDS) {
+		// Not needed for LVDS?
+		hsync = mode->crtc_hsync_end - mode->crtc_hsync_start;
+		vsync = mode->crtc_vsync_end - mode->crtc_vsync_start;
+		DRM_DEBUG_DRIVER("Setting HSYNC %d, VSYNC %d\n", hsync, vsync);
+		regmap_write(tcon->regs, SUN4I_TCON0_BASIC3_REG,
+			     SUN4I_TCON0_BASIC3_V_SYNC(vsync) |
+			     SUN4I_TCON0_BASIC3_H_SYNC(hsync));
+	}

This is your patch 5 (and it would be better to put the condition on what we know rather than what we assume, we know that it's working for RGB, but not for anything else).

Quoted 4 lines
drivers/gpu/drm/sun4i/sun4i_tcon.c +4 -0
+
+	if (type == DRM_MODE_ENCODER_LVDS) {
+		/* Setup bit depth */
+		/* TODO: Figure out where to get display bit depth

drivers/gpu/drm/sun4i/sun4i_tcon.c void sun4i_tcon0_mode_set(struct sun4i_tcon *tcon, · line 196

Quoted 10 lines
drivers/gpu/drm/sun4i/sun4i_tcon.c +10 -0
+		 * val = (1: 18-bit, 0: 24-bit)
+		 * TODO: Should we set more registers:
+		 * BIT(28) - LVDS_DIRECTION
+		 * BIT(27) - LVDS_MODE
+		 * BIT(23) - LVDS_CORRECT_MODE
+		 */
+		regmap_update_bits(tcon->regs, SUN4I_TCON0_LVDS_IF_REG,
+				   SUN4I_TCON0_LVDS_IF_BITWIDTH,
+				   SUN4I_TCON0_LVDS_IF_BITWIDTH);
+	}

And this in your patch 6

Quoted 8 lines
drivers/gpu/drm/sun4i/sun4i_tcon.c +1 -0
 	/* Setup the polarity of the various signals */
 	if (!(mode->flags & DRM_MODE_FLAG_PHSYNC))
@@ -183,8 +202,15 @@ void sun4i_tcon0_mode_set(struct sun4i_tcon *tcon,
 	if (!(mode->flags & DRM_MODE_FLAG_PVSYNC))
 		val |= SUN4I_TCON0_IO_POL_VSYNC_POSITIVE;
 
+

drivers/gpu/drm/sun4i/sun4i_tcon.c void sun4i_tcon0_mode_set(struct sun4i_tcon *tcon, · line 214

Quoted 10 lines
drivers/gpu/drm/sun4i/sun4i_tcon.c +7 -1
+	/* Set proper DCLK phase value */
+	if (type == DRM_MODE_ENCODER_LVDS)
+		val |= SUN4I_TCON0_IO_POL_DCLK_PHASE(1);
+
 	regmap_update_bits(tcon->regs, SUN4I_TCON0_IO_POL_REG,
-			   SUN4I_TCON0_IO_POL_HSYNC_POSITIVE | SUN4I_TCON0_IO_POL_VSYNC_POSITIVE,
+			   SUN4I_TCON0_IO_POL_HSYNC_POSITIVE |
+			   SUN4I_TCON0_IO_POL_VSYNC_POSITIVE |
+			   SUN4I_TCON0_IO_POL_DCLK_PHASE_MASK,
 			   val);

This is covered by your clk_set_phase already.

Quoted 47 lines
drivers/gpu/drm/sun4i/sun4i_tcon.c +13 -1
 	/* Map output pins to channel 0 */
@@ -480,6 +506,7 @@ static int sun4i_tcon_bind(struct device *dev, struct device *master,
 	struct drm_device *drm = data;
 	struct sun4i_drv *drv = drm->dev_private;
 	struct sun4i_tcon *tcon;
+	const char *mode;
 	int ret;
 
 	tcon = devm_kzalloc(dev, sizeof(*tcon), GFP_KERNEL);
@@ -525,7 +552,18 @@ static int sun4i_tcon_bind(struct device *dev, struct device *master,
 		goto err_free_clocks;
 	}
 
-	ret = sun4i_rgb_init(drm);
+	/* Check which output mode is set, defaulting to RGB */
+	ret = of_property_read_string(dev->of_node, "mode", &mode);
+
+	if (ret || !strcmp(mode, "rgb"))
+		ret = sun4i_rgb_init(drm);
+	else if (!strcmp(mode, "lvds"))
+		ret = sun4i_lvds_init(drm);
+	else {
+		dev_err(dev, "Unknown TCON mode: %s\n", mode);
+		ret = -1;
+	}
+
 	if (ret < 0)
 		goto err_free_clocks;
 
drivers/gpu/drm/sun4i/sun4i_tcon.h +3 -0
index b040e10..dc4e350 100644
@@ -69,8 +69,11 @@
 #define SUN4I_TCON0_TTL3_REG			0x7c
 #define SUN4I_TCON0_TTL4_REG			0x80
 #define SUN4I_TCON0_LVDS_IF_REG			0x84
+#define SUN4I_TCON0_LVDS_IF_ENABLE			BIT(31)
+#define SUN4I_TCON0_LVDS_IF_BITWIDTH			BIT(26)
 #define SUN4I_TCON0_IO_POL_REG			0x88
 #define SUN4I_TCON0_IO_POL_DCLK_PHASE(phase)		((phase & 3) << 28)
+#define SUN4I_TCON0_IO_POL_DCLK_PHASE_MASK		(3 << 28)
 #define SUN4I_TCON0_IO_POL_HSYNC_POSITIVE		BIT(25)
 #define SUN4I_TCON0_IO_POL_VSYNC_POSITIVE		BIT(24)
 

drivers/gpu/drm/sun4i/sun4i_tcon.h line 140

Quoted 10 lines
drivers/gpu/drm/sun4i/sun4i_tcon.h +7 -0
@@ -128,6 +131,18 @@
 #define SUN4I_TCON_CEU_RANGE_G_REG		0x144
 #define SUN4I_TCON_CEU_RANGE_B_REG		0x148
 #define SUN4I_TCON_MUX_CTRL_REG			0x200
+#define SUN4I_TCON0_LVDS_ANA0_REG		0x220
+#define SUN4I_TCON0_LVDS_ANA0_CK_EN			BIT(29) | BIT(28)
+#define SUN4I_TCON0_LVDS_ANA0_REG_V			BIT(27) | BIT(26)
+/* TODO: BIT(23) also belongs to ANA0_REG_C register set */
+#define SUN4I_TCON0_LVDS_ANA0_REG_C			BIT(25) | BIT(24)
+#define SUN4I_TCON0_LVDS_ANA0_EN_MB			BIT(22)
+/* TODO: BIT(19) also belongs to ANA0_PD register set */

Why don't you set them then?

Maxime

Signature · 3 lines
Maxime Ripard, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com
author
#20 lore raw

PATCH 8/8 ARM: dts: sun4i: gemei-g9: Add LVDS display support

In reply to Priit Laes
---
 arch/arm/boot/dts/sun4i-a10-gemei-g9.dts | 95 +++++++++++++++++++++++++++++---
 1 file changed, 86 insertions(+), 9 deletions(-)
arch/arm/boot/dts/sun4i-a10-gemei-g9.dts +86 -9
index 9616cde..c19f906 100644
@@ -1,5 +1,5 @@
 /*
- * Copyright 2015 Priit Laes
+ * Copyright 2015-2017 Priit Laes
  *
  * Priit Laes <plaes-q/[email protected]>
  *
@@ -48,28 +48,69 @@
 #include <dt-bindings/gpio/gpio.h>
 #include <dt-bindings/input/input.h>
 #include <dt-bindings/interrupt-controller/irq.h>
+#include <dt-bindings/pwm/pwm.h>
 
 / {
 	model = "Gemei G9 Tablet";
 	compatible = "gemei,g9", "allwinner,sun4i-a10";
 
+	/*
+	 * TODO:
+	 *   2x cameras via CSI
+	 *   AXP battery management
+	 *   NAND
+	 *   OTG
+	 *   Touchscreen - gt801_2plus1 @ i2c adapter 2 @ 0x48
+	 *   HDMI output
+	 */
+
 	aliases {
 		serial0 = &uart0;
 	};
 
+	backlight: backlight {
+		compatible = "pwm-backlight";
+		pinctrl-names = "default";
+		pinctrl-0 = <&lcd_backlight_pin>;
+		/* TODO: Figure out proper parameters */
+		pwms = <&pwm 0 50000 PWM_POLARITY_INVERTED>;
+		brightness-levels = <0 10 20 30 40 50 60 70 80 90 100>;
+		enable-gpios = <&pio 7 7 GPIO_ACTIVE_HIGH>; /* PH7 */
+		default-brightness-level = <8>;
+	};
+
 	chosen {
 		stdout-path = "serial0:115200n8";
 	};
+
+	panel: panel {
+		compatible = "lg,lp097x02-slq2";
+		pinctrl-names = "default";
+		pinctrl-0 = <&lcd_enable_pin &lcd_lvds0_pins>;
+		enable-gpios = <&pio 7 8 GPIO_ACTIVE_HIGH>; /* PH8 */
+		#address-cells = <1>;
+		#size-cells = <0>;
+
+		port {
+			#address-cells = <1>;
+			#size-cells = <0>;
+
+			panel_input: endpoint {
+				remote-endpoint = <&tcon0_out_panel>;
+			};
+		};
+	};
+
+	display-engine {
+		compatible = "allwinner,sun5i-a13-display-engine";
+		allwinner,pipelines = <&fe0>;
+	};
+};
+
+&be0 {
+	status = "okay";
 };
 
-/*
- * TODO:
- *   2x cameras via CSI
- *   AXP battery management
- *   NAND
- *   OTG
- *   Touchscreen - gt801_2plus1 @ i2c adapter 2 @ 0x48
- */
 &codec {
 	/* PH15 controls power to external amplifier (ft2012q) */
 	pinctrl-names = "default";
@@ -90,6 +131,10 @@
 	status = "okay";
 };
 
+&fe0 {
+	status = "okay";
+};
+
 &i2c0 {
 	pinctrl-names = "default";
 	pinctrl-0 = <&i2c0_pins_a>;
@@ -159,6 +204,27 @@
 		pins = "PH15";
 		function = "gpio_out";
 	};
+
+	lcd_backlight_pin: lcd_backlight_pin@0 {
+		pins = "PH7";
+		function = "gpio_out";
+	};
+
+	lcd_enable_pin: lcd_enable_pin@0 {
+		pins = "PH8";
+		function = "gpio_out";
+	};
+
+	lcd_lvds0_pins: lcd_lvds0_pins@0 {
+		pins =  "PD0", "PD1", "PD2", "PD3", "PD4", "PD5", "PD6", "PD7", "PD8", "PD9";
+		function = "lvds0";
+	};
+};
+
+&pwm {
+        pinctrl-names = "default";
+        pinctrl-0 = <&pwm0_pins_a>;
+        status = "okay";
 };
 
 &reg_dcdc2 {
@@ -194,6 +260,17 @@
 	status = "okay";
 };
 
+&tcon0 {
+	mode = "lvds";
+	status = "okay";
+};
+
+&tcon0_out {
+	tcon0_out_panel: endpoint@1 {
+		reg = <0>;
+		remote-endpoint = <&panel_input>;
+	};
+};
 
 &uart0  {
 	pinctrl-names = "default";
Signature · 1 line
2.9.3