Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 24 Feb 2020 10:40:36 +0000 (UTC)
From:      Emmanuel Vadot <manu@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r358279 - head/sys/arm64/rockchip
Message-ID:  <202002241040.01OAeaYr010509@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: manu
Date: Mon Feb 24 10:40:35 2020
New Revision: 358279
URL: https://svnweb.freebsd.org/changeset/base/358279

Log:
  arm64: rockchip: rk808: Only init regulator not enabled
  
  If a regulator is already enabled, do not set its value to the minimum
  supported on the board.
  This fixes booting on rock64 where we set some regulator to the minimal value
  while the IPs needs more based on what the bootloader configured.
  
  MFC after:	1 week

Modified:
  head/sys/arm64/rockchip/rk805.c

Modified: head/sys/arm64/rockchip/rk805.c
==============================================================================
--- head/sys/arm64/rockchip/rk805.c	Mon Feb 24 10:38:38 2020	(r358278)
+++ head/sys/arm64/rockchip/rk805.c	Mon Feb 24 10:40:35 2020	(r358279)
@@ -97,6 +97,7 @@ struct rk805_softc {
 	int			nregs;
 };
 
+static int rk805_regnode_status(struct regnode *regnode, int *status);
 static int rk805_regnode_set_voltage(struct regnode *regnode, int min_uvolt,
     int max_uvolt, int *udelay);
 
@@ -351,6 +352,7 @@ rk805_read(device_t dev, uint8_t reg, uint8_t *data, u
 static int
 rk805_write(device_t dev, uint8_t reg, uint8_t data)
 {
+
 	return (iicdev_writeto(dev, reg, &data, 1, IIC_INTRWAIT));
 }
 
@@ -359,7 +361,7 @@ rk805_regnode_init(struct regnode *regnode)
 {
 	struct rk805_reg_sc *sc;
 	struct regnode_std_param *param;
-	int rv, udelay;
+	int rv, udelay, status;
 
 	sc = regnode_get_softc(regnode);
 	param = regnode_get_stdparam(regnode);
@@ -367,13 +369,17 @@ rk805_regnode_init(struct regnode *regnode)
 		return (0);
 
 	/* 
-	 * Set the regulator at the correct voltage
+	 * Set the regulator at the correct voltage if it is not enabled.
 	 * Do not enable it, this is will be done either by a
 	 * consumer or by regnode_set_constraint if boot_on is true
 	 */
+	rv = rk805_regnode_status(regnode, &status);
+	if (rv != 0 || status == REGULATOR_STATUS_ENABLED)
+		return (rv);
+
 	rv = rk805_regnode_set_voltage(regnode, param->min_uvolt,
 	    param->max_uvolt, &udelay);
-	if (rv != 0)
+	if (udelay != 0)
 		DELAY(udelay);
 
 	return (rv);



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202002241040.01OAeaYr010509>