git: 07448cd0c634 - main - axp81x: Fix the register accesses

From: Emmanuel Vadot <manu_at_FreeBSD.org>
Date: Tue, 10 Nov 2026 13:42:54 UTC
The branch main has been updated by manu:

URL: https://cgit.FreeBSD.org/src/commit/?id=07448cd0c6341793406fa0d7a2f33401be01c7a3

commit 07448cd0c6341793406fa0d7a2f33401be01c7a3
Author:     Emmanuel Vadot <manu@FreeBSD.org>
AuthorDate: 2026-11-10 07:54:22 +0000
Commit:     Emmanuel Vadot <manu@FreeBSD.org>
CommitDate: 2026-11-10 13:42:45 +0000

    axp81x: Fix the register accesses
    
    The register pointer was written without IIC_M_NOSTOP, so the controller
    sends a STOP before the read message. On the Allwinner H6 (twsi) this
    makes the reads return garbage without any error.
    
    Set IIC_M_NOSTOP on it, and send the register and its value in a single
    write message, like the other PMIC drivers do.
    
    Tested on: A64, H6
---
 sys/arm/allwinner/axp81x.c | 21 ++++++++++-----------
 1 file changed, 10 insertions(+), 11 deletions(-)

diff --git a/sys/arm/allwinner/axp81x.c b/sys/arm/allwinner/axp81x.c
index 2983ff09e296..b7d286276294 100644
--- a/sys/arm/allwinner/axp81x.c
+++ b/sys/arm/allwinner/axp81x.c
@@ -717,7 +717,7 @@ axp8xx_read(device_t dev, uint8_t reg, uint8_t *data, uint8_t size)
 	sc = device_get_softc(dev);
 
 	msg[0].slave = sc->addr;
-	msg[0].flags = IIC_M_WR;
+	msg[0].flags = IIC_M_WR | IIC_M_NOSTOP;
 	msg[0].len = 1;
 	msg[0].buf = &reg;
 
@@ -733,21 +733,20 @@ static int
 axp8xx_write(device_t dev, uint8_t reg, uint8_t val)
 {
 	struct axp8xx_softc *sc;
-	struct iic_msg msg[2];
+	struct iic_msg msg;
+	uint8_t buf[2];
 
 	sc = device_get_softc(dev);
 
-	msg[0].slave = sc->addr;
-	msg[0].flags = IIC_M_WR;
-	msg[0].len = 1;
-	msg[0].buf = &reg;
+	buf[0] = reg;
+	buf[1] = val;
 
-	msg[1].slave = sc->addr;
-	msg[1].flags = IIC_M_WR;
-	msg[1].len = 1;
-	msg[1].buf = &val;
+	msg.slave = sc->addr;
+	msg.flags = IIC_M_WR;
+	msg.len = sizeof(buf);
+	msg.buf = buf;
 
-	return (iicbus_transfer(dev, msg, 2));
+	return (iicbus_transfer(dev, &msg, 1));
 }
 
 static int