]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
rtc: rx8025: revise single register write to use offset
authorMathew McBride <matt@traverse.com.au>
Fri, 17 Sep 2021 06:46:04 +0000 (06:46 +0000)
committerTom Rini <trini@konsulko.com>
Sun, 3 Oct 2021 18:40:56 +0000 (14:40 -0400)
Writing of individual registers was not functioning
correctly as a 0 'offset' byte under DM-managed
I2C was being appended in front of register we
wanted to access.

Signed-off-by: Mathew McBride <matt@traverse.com.au>
drivers/rtc/rx8025.c

index 9423a1bb8224bd6b8b2db5a82999ab7e9513cfad..1394c2306a445f5326ba29446fe0589340f24859 100644 (file)
@@ -214,11 +214,14 @@ static int rx8025_rtc_reset(struct udevice *dev)
  */
 static int rtc_write(struct udevice *dev, uchar reg, uchar val)
 {
-       uchar buf[2];
-       buf[0] = reg << 4;
-       buf[1] = val;
+       /* The RX8025/RX8035 uses the top 4 bits of the
+        * 'offset' byte as the start register address,
+        * and the bottom 4 bits as a 'transfer' mode setting
+        * (only applicable for reads)
+        */
+       u8 offset = (reg << 4);
 
-       if (dm_i2c_write(dev, 0, buf, 2)) {
+       if (dm_i2c_reg_write(dev, offset, val)) {
                printf("Error writing to RTC\n");
                return -EIO;
        }