From 557c24d082b6ecb9bfe5407b77ae43fa7650a5dc Mon Sep 17 00:00:00 2001
From: hc <hc@nodka.com>
Date: Fri, 17 Feb 2023 11:02:20 +0000
Subject: [PATCH] add eDP LVDS PCIE WIFI6

---
 u-boot/drivers/video/drm/rockchip_panel.c |   99 ++++++++++++++++++++++++++++++++++++++++++++++---
 1 files changed, 92 insertions(+), 7 deletions(-)

diff --git a/u-boot/drivers/video/drm/rockchip_panel.c b/u-boot/drivers/video/drm/rockchip_panel.c
old mode 100644
new mode 100755
index de7e5e2..652e748
--- a/u-boot/drivers/video/drm/rockchip_panel.c
+++ b/u-boot/drivers/video/drm/rockchip_panel.c
@@ -45,6 +45,7 @@
 	bool power_invert;
 	u32 bus_format;
 	unsigned int bpc;
+	unsigned int lvds_index;
 
 	struct {
 		unsigned int prepare;
@@ -66,6 +67,13 @@
 	struct udevice *backlight;
 	struct gpio_desc enable_gpio;
 	struct gpio_desc reset_gpio;
+	struct gpio_desc edp_bl_on;
+	struct gpio_desc edp_bl_en;
+
+	struct gpio_desc lvds_gpio0;
+	struct gpio_desc lvds_gpio1;
+	struct gpio_desc lvds_gpio2;
+	struct gpio_desc lvds_gpio3;
 
 	int cmd_type;
 	struct gpio_desc spi_sdi_gpio;
@@ -275,24 +283,58 @@
 
 	if (priv->prepared)
 		return;
+	
+	/*7511 LVDS IO Control start*/
+	printk("nodka_lvds_index = %d\n",plat->lvds_index);
+	
+	ret = plat->lvds_index  & 1;
+	if (dm_gpio_is_valid(&priv->lvds_gpio0))
+	dm_gpio_set_value(&priv->lvds_gpio0, ret);
+	ret = dm_gpio_get_value(&priv->lvds_gpio0);
+	printf("lvds_gpio0 : %d\n",ret);
+
+	ret = plat->lvds_index >> 1 & 1;
+	if (dm_gpio_is_valid(&priv->lvds_gpio1))
+	dm_gpio_set_value(&priv->lvds_gpio1, ret);
+	ret = dm_gpio_get_value(&priv->lvds_gpio1);
+	printf("lvds_gpio1 : %d\n",ret);
+	
+	ret = plat->lvds_index >> 2 & 1;
+	if (dm_gpio_is_valid(&priv->lvds_gpio2))
+	dm_gpio_set_value(&priv->lvds_gpio2, ret);
+	ret = dm_gpio_get_value(&priv->lvds_gpio2);
+	printf("lvds_gpio2 : %d\n",ret);
+	
+	ret = plat->lvds_index >> 3 & 1;
+	if (dm_gpio_is_valid(&priv->lvds_gpio3))
+	dm_gpio_set_value(&priv->lvds_gpio3, ret);
+	ret = dm_gpio_get_value(&priv->lvds_gpio3);
+	printf("lvds_gpio3 : %d\n",ret);
+	mdelay(100);
+/*7511 LVDS IO Control end*/
 
 	if (priv->power_supply)
 		regulator_set_enable(priv->power_supply, !plat->power_invert);
-
+	
+	if (dm_gpio_is_valid(&priv->edp_bl_on))
+		dm_gpio_set_value(&priv->edp_bl_on, 1);
+		
+	if (dm_gpio_is_valid(&priv->edp_bl_en))
+		dm_gpio_set_value(&priv->edp_bl_en, 1);
+	
 	if (dm_gpio_is_valid(&priv->enable_gpio))
 		dm_gpio_set_value(&priv->enable_gpio, 1);
-
+	
 	if (plat->delay.prepare)
 		mdelay(plat->delay.prepare);
-
+	
 	if (dm_gpio_is_valid(&priv->reset_gpio))
 		dm_gpio_set_value(&priv->reset_gpio, 1);
-
-	if (plat->delay.reset)
-		mdelay(plat->delay.reset);
-
+	mdelay(50);
 	if (dm_gpio_is_valid(&priv->reset_gpio))
 		dm_gpio_set_value(&priv->reset_gpio, 0);
+			
+	mdelay(200);
 
 	if (plat->delay.init)
 		mdelay(plat->delay.init);
@@ -407,6 +449,7 @@
 	plat->delay.disable = dev_read_u32_default(dev, "disable-delay-ms", 0);
 	plat->delay.init = dev_read_u32_default(dev, "init-delay-ms", 0);
 	plat->delay.reset = dev_read_u32_default(dev, "reset-delay-ms", 0);
+	plat->lvds_index = dev_read_u32_default(dev, "nodka-lvds", 0);
 
 	plat->bus_format = dev_read_u32_default(dev, "bus-format",
 						MEDIA_BUS_FMT_RBG888_1X24);
@@ -457,6 +500,20 @@
 	int ret;
 	const char *cmd_type;
 
+	ret = gpio_request_by_name(dev, "edp-bl-gpios", 0,
+				   &priv->edp_bl_on, GPIOD_IS_OUT);
+	if (ret && ret != -ENOENT) {
+		printf("%s: Cannot get enable GPIO: %d\n", __func__, ret);
+		return ret;
+	}
+
+	ret = gpio_request_by_name(dev, "edp-bl-en", 0,
+				   &priv->edp_bl_en, GPIOD_IS_OUT);
+	if (ret && ret != -ENOENT) {
+		printf("%s: Cannot get enable GPIO: %d\n", __func__, ret);
+		return ret;
+	}
+	
 	ret = gpio_request_by_name(dev, "enable-gpios", 0,
 				   &priv->enable_gpio, GPIOD_IS_OUT);
 	if (ret && ret != -ENOENT) {
@@ -471,6 +528,34 @@
 		return ret;
 	}
 
+	ret = gpio_request_by_name(dev, "lvds-gpio0", 0,
+				   &priv->lvds_gpio0, GPIOD_IS_OUT);
+	if (ret && ret != -ENOENT) {
+		printf("%s: Cannot get lvds-gpio0: %d\n", __func__, ret);
+		return ret;
+	}
+
+	ret = gpio_request_by_name(dev, "lvds-gpio1", 0,
+				   &priv->lvds_gpio1, GPIOD_IS_OUT);
+	if (ret && ret != -ENOENT) {
+		printf("%s: Cannot get lvds-gpio1: %d\n", __func__, ret);
+		return ret;
+	}
+	
+	ret = gpio_request_by_name(dev, "lvds-gpio2", 0,
+				   &priv->lvds_gpio2, GPIOD_IS_OUT);
+	if (ret && ret != -ENOENT) {
+		printf("%s: Cannot get lvds-gpio2: %d\n", __func__, ret);
+		return ret;
+	}
+	
+	ret = gpio_request_by_name(dev, "lvds-gpio3", 0,
+				   &priv->lvds_gpio3, GPIOD_IS_OUT);
+	if (ret && ret != -ENOENT) {
+		printf("%s: Cannot get lvds-gpio3: %d\n", __func__, ret);
+		return ret;
+	}
+	
 	ret = uclass_get_device_by_phandle(UCLASS_PANEL_BACKLIGHT, dev,
 					   "backlight", &priv->backlight);
 	if (ret && ret != -ENOENT) {

--
Gitblit v1.6.2