[RFC PATCH 2/2] tcan4x5x: set nwkrq voltage

Sean Nyekjaer <[email protected]>
Newsgroups org.u-boot-project.lists.u-boot
Message-ID <[email protected]>
nwkrq can be driven from vio or vsup voltage, read from devicetree to
determine which rail should drive nwkrq.

Signed-off-by: Sean Nyekjaer <[email protected]>
---
 drivers/misc/tcan4x5x.c | 30 ++++++++++++++++++++++++++++++
 1 file changed, 30 insertions(+)

diff --git a/drivers/misc/tcan4x5x.c b/drivers/misc/tcan4x5x.c
index a304f3db9df..e9e63f06e13 100644
--- a/drivers/misc/tcan4x5x.c
+++ b/drivers/misc/tcan4x5x.c
@@ -10,6 +10,7 @@
 
 #define TCAN4X5X_CONFIG 0x800
 #define TCAN4X5X_MODE_BITS (BIT(7) | BIT(6))
+#define TCAN4X5X_NWKRQ_VOLTAGE_VIO BIT(19)
 
 struct tcan4x5x_transfer {
 	u8 cmd;
@@ -87,6 +88,28 @@ static int tcan4x5x_enable_sleep(struct udevice *dev)
 	return ret;
 }
 
+static int tcan4x5x_nwkrq_vio(struct udevice *dev)
+{
+	u32 val;
+	int ret;
+
+	ret = tcan4x5x_read_reg(dev, TCAN4X5X_CONFIG, &val);
+	if (ret) {
+		log_err("failed to read from tcan4x5x\n");
+		return ret;
+	}
+
+	log_debug("read %x\n", val);
+	val |= TCAN4X5X_NWKRQ_VOLTAGE_VIO;
+	log_debug("write %x\n", val);
+
+	ret = tcan4x5x_write_reg(dev, TCAN4X5X_CONFIG, val);
+	if (ret)
+		log_err("reg write failed (%d)\n", ret);
+
+	return ret;
+}
+
 static int tcan4x5x_probe(struct udevice *dev)
 {
 	struct gpio_desc rst;
@@ -119,6 +142,13 @@ static int tcan4x5x_probe(struct udevice *dev)
 	 */
 	udelay(1000);
 
+	if (dev_read_bool(dev, "ti,nwkrq-voltage-vio")) {
+		log_debug("set nwkrq voltage to vio\n");
+		ret = tcan4x5x_nwkrq_vio(dev);
+		if (ret)
+			return ret;
+	}
+
 	return tcan4x5x_enable_sleep(dev);
 }
 
-- 
2.55.0
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.