Skip to contentSkip to conversation

misc: atsha204a: bug fixes

PATCH In review Adrian Fiergolski 2 participants 7 messages Jan 11, 2022 Char and misc drivers

lore
Share & tools
lore
#0 lore raw

v2 cover misc: atsha204a: bug fixes

Series of patches fixing atsha204a driver. Partially inspired by Enclustra's repo [1].

[1] https://github.com/enclustra-bsp/xilinx-uboot

Adrian Fiergolski (3):
misc: atsha204a: return timeout from wakeup function
misc: atsha204a: add delay after sending the message
misc: atsha204a: fix i2c address readout from DTS

 drivers/misc/atsha204a-i2c.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
Signature · 1 line
2.34.1
#1 lore raw

PATCH v2 1/3 misc: atsha204a: return timeout from wakeup function

If the maximum number of wake-up attempts is exceeded, return -ETIMEDOUT.

---
 drivers/misc/atsha204a-i2c.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/misc/atsha204a-i2c.c +2 -2
index 715dabb279..9d069fb33c 100644
@@ -240,10 +240,10 @@ int atsha204a_wakeup(struct udevice *dev)
 		}
 
 		debug("success\n");
-		break;
+		return 0;
 	}
 
-	return 0;
+	return -ETIMEDOUT;
 }
 
 int atsha204a_idle(struct udevice *dev)
Signature · 1 line
2.34.1
#3 lore raw

PATCH v2 2/3 misc: atsha204a: add delay after sending the message

In reply to Adrian Fiergolski

Once request is sent, and before receiving a response, the delay is required. This patch fixes missing delay for before first response try.

---
 drivers/misc/atsha204a-i2c.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/misc/atsha204a-i2c.c +1 -1
index 9d069fb33c..d264477927 100644
@@ -280,6 +280,7 @@ static int atsha204a_transaction(struct udevice *dev, struct atsha204a_req *req,
 	}
 
 	do {
+		udelay(ATSHA204A_EXECTIME);
 		res = atsha204a_recv_resp(dev, resp);
 		if (!res || res == -EMSGSIZE || res == -EBADMSG)
 			break;
@@ -287,7 +288,6 @@ static int atsha204a_transaction(struct udevice *dev, struct atsha204a_req *req,
 		debug("ATSHA204A transaction polling for response "
 		      "(timeout = %d)\n", timeout);
 
-		udelay(ATSHA204A_EXECTIME);
 		timeout -= ATSHA204A_EXECTIME;
 	} while (timeout > 0);
 
Signature · 1 line
2.34.1
#5 lore raw

PATCH v2 3/3 misc: atsha204a: fix i2c address readout from DTS

In reply to Adrian Fiergolski

This patch replaces use fdtdec_get_addr with simpler dev_read_addr(). fdtdec_get_addr doesn't work properly on ZynqMP-based (64bit) system. Although not confirmed, it could be related to the fact, that quoting the documentation, "This variant hard-codes the number of cells used to represent the address and size based on sizeof(fdt_addr_t) and sizeof(fdt_size_t)".

---
 drivers/misc/atsha204a-i2c.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/misc/atsha204a-i2c.c +1 -1
index d264477927..b89463babb 100644
@@ -388,7 +388,7 @@ static int atsha204a_of_to_plat(struct udevice *dev)
 	fdt_addr_t *priv = dev_get_priv(dev);
 	fdt_addr_t addr;
 
-	addr = fdtdec_get_addr(gd->fdt_blob, dev_of_offset(dev), "reg");
+	addr = dev_read_addr(dev);
 	if (addr == FDT_ADDR_T_NONE) {
 		debug("Can't get ATSHA204A I2C base address\n");
 		return -ENXIO;
Signature · 1 line
2.34.1
Reviewed-by on v2 3/3
#6 lore raw

Re: [PATCH v2 3/3] misc: atsha204a: fix i2c address readout from DTS

Quoted 7 lines · On Tue, 11 Jan 2022 19:05:31 +0100 Adrian Fiergolski…

This patch replaces use fdtdec_get_addr with simpler dev_read_addr(). fdtdec_get_addr doesn't work properly on ZynqMP-based (64bit) system. Although not confirmed, it could be related to the fact, that quoting the documentation, "This variant hard-codes the number of cells used to represent the address and size based on sizeof(fdt_addr_t) and sizeof(fdt_size_t)".