From e2c8ffc1c3519e1fadfcc152fd5562607735553e Mon Sep 17 00:00:00 2001
From: Yuri Mazzuoli <yuri.mazzuoli@seco.com>
Date: Fri, 16 Feb 2024 16:26:49 +0100
Subject: [PATCH] [C72][DTS][OVERLAY] add LVDS overlays

seco-imx8mn-c72-lvds-dual-156-overlay.dts for Innolux G156HCE-L01 15.6-inch
seco-imx8mn-c72-lvds-dual-215-overlay.dts for AUO P215HCN 21.5-inch
---
 arch/arm64/boot/dts/seco/overlays/Makefile    |   4 +-
 .../seco-imx8mn-c72-lvds-dual-156-overlay.dts | 197 ++++++++++++++++++
 .../seco-imx8mn-c72-lvds-dual-215-overlay.dts | 192 +++++++++++++++++
 3 files changed, 392 insertions(+), 1 deletion(-)
 create mode 100644 arch/arm64/boot/dts/seco/overlays/seco-imx8mn-c72-lvds-dual-156-overlay.dts
 create mode 100644 arch/arm64/boot/dts/seco/overlays/seco-imx8mn-c72-lvds-dual-215-overlay.dts

diff --git a/arch/arm64/boot/dts/seco/overlays/Makefile b/arch/arm64/boot/dts/seco/overlays/Makefile
index c7384b20d07b8e..c2d4539af2d5fb 100644
--- a/arch/arm64/boot/dts/seco/overlays/Makefile
+++ b/arch/arm64/boot/dts/seco/overlays/Makefile
@@ -48,7 +48,9 @@ dtbo-$(CONFIG_ARCH_MXC) += \
 	seco-imx8mp-d18-ov5640-csi0.dtbo\
 	seco-imx8mp-d18-ov5640-csi1.dtbo\
 	seco-imx8mp-d18-audio-btsco.dtbo\
-	seco-imx8mn-c72-edp.dtbo
+	seco-imx8mn-c72-edp.dtbo\
+	seco-imx8mn-c72-lvds-dual-215.dtbo\
+	seco-imx8mn-c72-lvds-dual-156.dtbo
 
 	# seco-imx8qm-c26-dp.dtbo\
 	# seco-imx8qm-c26-lvds-single.dtbo\
diff --git a/arch/arm64/boot/dts/seco/overlays/seco-imx8mn-c72-lvds-dual-156-overlay.dts b/arch/arm64/boot/dts/seco/overlays/seco-imx8mn-c72-lvds-dual-156-overlay.dts
new file mode 100644
index 00000000000000..d5a5c16e1a1389
--- /dev/null
+++ b/arch/arm64/boot/dts/seco/overlays/seco-imx8mn-c72-lvds-dual-156-overlay.dts
@@ -0,0 +1,197 @@
+/*
+ * Copyright 2017 NXP
+ *
+ * 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.
+ *
+ * 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 <dt-bindings/drm_mipi_dsi.h>
+#include <dt-bindings/gpio/gpio.h>
+#include <dt-bindings/interrupt-controller/irq.h>
+#include <dt-bindings/display/media-bus-format.h>
+
+
+/dts-v1/;
+/plugin/;
+
+/ {
+        compatible = "fsl,imx8mn-evk","seco,seco-imx8mn-c72", "fsl,imx8mn";
+
+/*  __________________________________________________________________________
+ * |                                                                          |
+ * |                               DSI-to-LVDS                                |
+ * |__________________________________________________________________________|
+ */
+
+
+	fragment@panel {
+		target-path = "/";
+		__overlay__ {
+			panel_lvds: lvds_panel {
+				compatible = "seco-innolux,G156HCE-L01", "panel-dpi";
+				#address-cells = <1>;
+				#size-cells = <0>;
+				no-hpd;
+
+				width-mm = <344>;
+				height-mm = <194>;
+				
+				prepare-ms = <1>;
+				enable-ms = <450>;
+				disable-ms = <200>;
+				unprepare-ms = <10>;
+
+				bpc = <8>;
+				bus-format = <DT_MEDIA_BUS_FMT_RGB888_1X24>;
+
+				status = "okay";
+
+				panel-timing {
+					clock-frequency = <120000000>;
+					hactive = <0x780>;
+					vactive = <0x438>;
+
+					hfront-porch = <80>;
+					hsync-len = <20>;
+					hback-porch = <80>;
+
+					vfront-porch = <3>;
+					vsync-len = <4>;
+					vback-porch = <3>;
+					
+					de-active = <1>;
+				};
+
+				port@0 {
+					reg = <0>;
+					panel_in: endpoint {
+						remote-endpoint = <&bridge_to_panel>;
+					};
+				};
+			};
+		};
+	};
+
+    fragment@lcdif {
+        target = <&lcdif>;
+        __overlay__ {
+            status = "okay";
+            max-res = <1920>,<1080>;
+        };
+    };
+
+
+    fragment@dsi {
+        target = <&mipi_dsi>;
+        __overlay__ {
+            status = "okay";
+        
+            port@1 {
+                mipi_to_bridge: endpoint {
+                    remote-endpoint = <&bridge_to_mipi>;
+                    attach-bridge;
+                };
+            };
+        };
+    };
+
+
+    fragment@bridge {
+        target = <&adv_bridge>;
+        __overlay__ {
+
+            #address-cells = <1>;
+            #size-cells = <0>;
+            lvds,datamap = "jeida";
+            lvds,dual-channel;
+            lvds,channel-swap;
+            lvds,preserve-dsi-timings;
+            //lvds,test-mode;
+                /*include/drm/drm_mipi_dsi.h*/
+			dsi,mode-flags = <(MIPI_DSI_MODE_VIDEO | MIPI_DSI_MODE_VIDEO_SYNC_PULSE | MIPI_DSI_MODE_LPM)>;
+            
+            clocks = <&si5351a 0>;
+            status = "okay";
+            
+            port@0 {
+                reg = <0>;
+                bridge_to_mipi: endpoint {
+                    remote-endpoint = <&mipi_to_bridge>;
+                };
+            };
+            
+            port@1 {
+                reg = <1>;
+                bridge_to_panel: endpoint {
+                    remote-endpoint = <&panel_in>;
+                };
+            };
+        };
+    };
+
+
+    fragment@backlighrt {
+        target-path = "/";
+        __overlay__ {
+            lcd0_backlight {
+                compatible = "pwm-backlight";
+                pwms = <&pwm1 0 100000>;
+                status = "okay";
+
+                brightness-levels = <0 100>;
+                num-interpolated-steps = <100>;
+                default-brightness-level = <100>;
+            };
+        };
+    };	
+
+
+    fragment@clock {
+        target = <&si5351a>;
+        __overlay__ {
+            status = "okay";
+            /* connect xtal input to 27MHz reference */
+		    clocks = <&osc_27m>;
+            clkout0 {
+                    silabs,pll-spread_spectrum-1_5;
+            };
+        };
+    };
+
+
+    fragment@regs {
+        target = <&regfixed>;
+        __overlay__ {
+            reg_panel_en: reg_panelen {
+                compatible = "regulator-fixed";
+                regulator-name = "PANL_EN";
+                regulator-min-microvolt = <3300000>;
+                regulator-max-microvolt = <3300000>;
+                gpio = <&gpio1 2 GPIO_ACTIVE_HIGH>;
+                enable-active-high;
+                regulator-always-on;
+                status = "okay";
+            };
+
+            reg_lcd0_bkl_en: regulator-lcd0-bkl-en {
+                compatible = "regulator-fixed";
+                regulator-name = "lcd0_bkl_en";
+                regulator-min-microvolt = <3300000>;
+                regulator-max-microvolt = <3300000>;
+                gpio = <&gpio1 0 0>;
+                enable-active-high;
+                regulator-always-on;
+                status = "okay";
+            };
+        };
+    };
+
+};
diff --git a/arch/arm64/boot/dts/seco/overlays/seco-imx8mn-c72-lvds-dual-215-overlay.dts b/arch/arm64/boot/dts/seco/overlays/seco-imx8mn-c72-lvds-dual-215-overlay.dts
new file mode 100644
index 00000000000000..d0ebef2ba00203
--- /dev/null
+++ b/arch/arm64/boot/dts/seco/overlays/seco-imx8mn-c72-lvds-dual-215-overlay.dts
@@ -0,0 +1,192 @@
+/*
+ * Copyright 2017 NXP
+ *
+ * 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.
+ *
+ * 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 <dt-bindings/drm_mipi_dsi.h>
+#include <dt-bindings/gpio/gpio.h>
+#include <dt-bindings/interrupt-controller/irq.h>
+#include <dt-bindings/display/media-bus-format.h>
+
+
+/dts-v1/;
+/plugin/;
+
+/ {
+        compatible = "fsl,imx8mn-evk","seco,seco-imx8mn-c72", "fsl,imx8mn";
+
+/*  __________________________________________________________________________
+ * |                                                                          |
+ * |                               DSI-to-LVDS                                |
+ * |__________________________________________________________________________|
+ */
+
+
+	fragment@panel {
+		target-path = "/";
+		__overlay__ {
+			panel_lvds: lvds_panel {
+				compatible = "seco-auo,p215hcn", "panel-dpi";
+				#address-cells = <1>;
+				#size-cells = <0>;
+				no-hpd;
+
+				width-mm  = <68>;
+				height-mm = <121>;
+
+				prepare-ms   = <100>;
+				enable-ms    = <100>;
+				disable-ms   = <100>;
+				unprepare-ms = <100>;
+
+				bpc = <8>;
+				bus-format = <DT_MEDIA_BUS_FMT_RGB888_1X24>;
+
+				status = "okay";
+
+				panel-timing {
+					clock-frequency = <160000000>;
+					hactive = <1920>;
+					vactive = <1080>;
+					hfront-porch = <85>;
+					hsync-len = <10>;
+					hback-porch = <85>;
+					vfront-porch = <20>;
+					vsync-len = <10>;
+					vback-porch = <20>;
+				};
+
+				port@0 {
+					reg = <0>;
+					panel_in: endpoint {
+						remote-endpoint = <&bridge_to_panel>;
+					};
+				};
+			};
+		};
+	};
+
+    fragment@1 {
+        target = <&lcdif>;
+        __overlay__ {
+            status = "okay";
+            max-res = <1920>,<1080>;
+        };
+    };
+
+
+    fragment@2 {
+        target = <&mipi_dsi>;
+        __overlay__ {
+            status = "okay";
+        
+            port@1 {
+                mipi_to_bridge: endpoint {
+                    remote-endpoint = <&bridge_to_mipi>;
+                    attach-bridge;
+                };
+            };
+        };
+    };
+
+
+    fragment@3 {
+        target = <&adv_bridge>;
+        __overlay__ {
+            #address-cells = <1>;
+            #size-cells = <0>;
+            lvds,datamap = "jeida";
+            lvds,dual-channel;
+            lvds,channel-swap;
+            lvds,preserve-dsi-timings;
+            //lvds,test-mode;
+                /*include/drm/drm_mipi_dsi.h*/
+			dsi,mode-flags = <(MIPI_DSI_MODE_VIDEO | MIPI_DSI_MODE_VIDEO_SYNC_PULSE | MIPI_DSI_MODE_LPM)>;
+            
+            clocks = <&si5351a 0>;
+            status = "okay";
+            
+            port@0 {
+                reg = <0>;
+                bridge_to_mipi: endpoint {
+                    remote-endpoint = <&mipi_to_bridge>;
+                };
+            };
+            
+            port@1 {
+                reg = <1>;
+                bridge_to_panel: endpoint {
+                    remote-endpoint = <&panel_in>;
+                };
+            };
+        };
+    };
+
+
+    fragment@4 {
+        target-path = "/";
+        __overlay__ {
+            lcd0_backlight {
+                compatible = "pwm-backlight";
+                pwms = <&pwm1 0 100000>;
+                status = "okay";
+
+                brightness-levels = <0 100>;
+                num-interpolated-steps = <100>;
+                default-brightness-level = <100>;
+            };
+        };
+    };	
+
+
+    fragment@5 {
+        target = <&si5351a>;
+        __overlay__ {
+            status = "okay";
+            /* connect xtal input to 27MHz reference */
+		    clocks = <&osc_27m>;
+            clkout0 {
+                    silabs,pll-spread_spectrum-1_5;
+            };
+        };
+    };
+
+
+    fragment@6 {
+        target = <&regfixed>;
+        __overlay__ {
+            reg_panel_en: reg_panelen {
+                compatible = "regulator-fixed";
+                regulator-name = "PANL_EN";
+                regulator-min-microvolt = <3300000>;
+                regulator-max-microvolt = <3300000>;
+                gpio = <&gpio1 2 GPIO_ACTIVE_HIGH>;
+                enable-active-high;
+                regulator-always-on;
+                status = "okay";
+            };
+
+            reg_lcd0_bkl_en: regulator-lcd0-bkl-en {
+                compatible = "regulator-fixed";
+                regulator-name = "lcd0_bkl_en";
+                regulator-min-microvolt = <3300000>;
+                regulator-max-microvolt = <3300000>;
+                gpio = <&gpio1 0 0>;
+                enable-active-high;
+                regulator-always-on;
+                status = "okay";
+            };
+        };
+    };
+
+};
-- 
GitLab