diff mbox series

[4/4] rtc: rx8025: revise single register write to use offset

Message ID 20210917064604.3912-5-matt@traverse.com.au
State Accepted
Commit 701c04f331f8389c9def2f61ef2a5d7d3e3e5bfd
Delegated to: Tom Rini
Headers show
Series Add EPSON RX8035 RTC support | expand

Commit Message

Mathew McBride Sept. 17, 2021, 6:46 a.m. UTC
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 | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

Comments

Tom Rini Oct. 3, 2021, 11:33 p.m. UTC | #1
On Fri, Sep 17, 2021 at 06:46:04AM +0000, Mathew McBride wrote:

> 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>

Applied to u-boot/next, thanks!
diff mbox series

Patch

diff --git a/drivers/rtc/rx8025.c b/drivers/rtc/rx8025.c
index 9423a1bb82..1394c2306a 100644
--- a/drivers/rtc/rx8025.c
+++ b/drivers/rtc/rx8025.c
@@ -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;
 	}