File 0102-Power-up-the-anx6345-properly-from-the-driver.patch of Package u-boot

From 234aae053d75143b63fe4dfb25340a438bccb912 Mon Sep 17 00:00:00 2001
From: Torsten Duwe <duwe@lst.de>
Date: Wed, 6 May 2020 17:57:37 +0200
Subject: [PATCH 102/102] Power up the anx6345 properly: from the driver

---
 drivers/video/bridge/anx6345.c | 53 ++++++++++++++++++++++++++++++++++
 1 file changed, 53 insertions(+)

diff --git a/drivers/video/bridge/anx6345.c b/drivers/video/bridge/anx6345.c
index 93fa25f16e3..49476a00b54 100644
--- a/drivers/video/bridge/anx6345.c
+++ b/drivers/video/bridge/anx6345.c
@@ -11,6 +11,7 @@
 #include <log.h>
 #include <video_bridge.h>
 #include <linux/delay.h>
+#include <power/regulator.h>
 #include "../anx98xx-edp.h"
 
 #define DP_MAX_LINK_RATE		0x001
@@ -267,6 +268,56 @@ static int anx6345_attach(struct udevice *dev)
 	return 0;
 }
 
+/*
+ * Olimex' Teres-I Schematics carry a note:
+ * Power UP sequency:
+ * Set edp_RESET to LOW
+ * Set DLDO3 to 1.2V
+ * Set DLDO2 to 2.5V
+ * up DLDO2
+ * 2 ms delay
+ * up DLDO3
+ * 10ms delay
+ * eDP_RESET to HIGH
+ */
+static void anx6345_powercycle(struct udevice *dev)
+{
+	struct video_bridge_priv *uc_priv = dev_get_uclass_priv(dev);
+	struct udevice *regul_12;
+	struct udevice *regul_25;
+	int ret;
+
+	if ((ret = device_get_supply_regulator(dev, "dvdd12-supply", &regul_12)) != 0 )
+	{
+	  debug("No 1.2V regulator for anx6345 (%d)- skipping power cycle\n", ret);
+		return;
+	}
+
+	if (device_get_supply_regulator(dev, "dvdd25-supply", &regul_25))
+		regul_25 = 0;	/* Give it a try anyway. */
+
+	regulator_set_enable(regul_12, false);
+	if (regul_25) regulator_set_enable(regul_25, false);
+
+	dm_gpio_set_value(&uc_priv->reset, true);
+
+	/* Hope this is long enough for all caps to discharge again */
+	mdelay(100);
+
+	regulator_set_value(regul_12, 1200000);
+	/* power up as specified */
+	if (regul_25)
+	{
+		regulator_set_value(regul_25, 2500000);
+		regulator_set_enable(regul_25, true);
+		mdelay(2);
+	}
+	regulator_set_enable(regul_12, true);
+	mdelay(10);
+
+	/* reset and sleep will be deasserted by video_bridge_set_active() */
+}
+
 static int anx6345_enable(struct udevice *dev)
 {
 	u8 chipid, colordepth, lanes, data_rate, c;
@@ -274,6 +325,8 @@ static int anx6345_enable(struct udevice *dev)
 	struct display_timing timing;
 	struct anx6345_priv *priv = dev_get_priv(dev);
 
+	anx6345_powercycle(dev);
+
 	/* Deassert reset and enable power */
 	ret = video_bridge_set_active(dev, true);
 	if (ret)
-- 
2.35.3

openSUSE Build Service is sponsored by