[PATCH 0/3] 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(-)

If the maximum number of wake-up attempts is exceeded, return -ETIMEDOUT.
Signed-off-by: Adrian Fiergolski adrian.fiergolski@fastree3d.com --- drivers/misc/atsha204a-i2c.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/misc/atsha204a-i2c.c b/drivers/misc/atsha204a-i2c.c index 715dabb279..9d069fb33c 100644 --- a/drivers/misc/atsha204a-i2c.c +++ b/drivers/misc/atsha204a-i2c.c @@ -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)

On Tue, 21 Dec 2021 17:17:20 +0100 Adrian Fiergolski adrian.fiergolski@fastree3d.com wrote:
If the maximum number of wake-up attempts is exceeded, return -ETIMEDOUT.
Signed-off-by: Adrian Fiergolski adrian.fiergolski@fastree3d.com
Reviewed-by: Marek Behún marek.behun@nic.cz

Once request is sent, and before receiving a response, the delay is required. This patch fixes missing delay for before first response try.
Signed-off-by: Adrian Fiergolski adrian.fiergolski@fastree3d.com --- drivers/misc/atsha204a-i2c.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/misc/atsha204a-i2c.c b/drivers/misc/atsha204a-i2c.c index 9d069fb33c..d264477927 100644 --- a/drivers/misc/atsha204a-i2c.c +++ b/drivers/misc/atsha204a-i2c.c @@ -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);

On Tue, 21 Dec 2021 17:17:21 +0100 Adrian Fiergolski adrian.fiergolski@fastree3d.com wrote:
Once request is sent, and before receiving a response, the delay is required. This patch fixes missing delay for before first response try.
Signed-off-by: Adrian Fiergolski adrian.fiergolski@fastree3d.com
Reviewed-by: Marek Behún marek.behun@nic.cz

This patch replaces use fdtdec_get_addr with recommended fdtdec_get_addr_size_auto_parent.
Signed-off-by: Adrian Fiergolski adrian.fiergolski@fastree3d.com --- drivers/misc/atsha204a-i2c.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/misc/atsha204a-i2c.c b/drivers/misc/atsha204a-i2c.c index d264477927..1008b914c2 100644 --- a/drivers/misc/atsha204a-i2c.c +++ b/drivers/misc/atsha204a-i2c.c @@ -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 = fdtdec_get_addr_size_auto_noparent(gd->fdt_blob, dev_of_offset(dev), "reg", 0, NULL, false); if (addr == FDT_ADDR_T_NONE) { debug("Can't get ATSHA204A I2C base address\n"); return -ENXIO;

On Tue, 21 Dec 2021 17:17:22 +0100 Adrian Fiergolski adrian.fiergolski@fastree3d.com wrote:
This patch replaces use fdtdec_get_addr with recommended fdtdec_get_addr_size_auto_parent.
And why is that required?
If at all, I would rather change it to simple dev_read_addr().
Marek

Hi Marek,
Thank you for your review.
On 21.12.2021 18:52, Marek Behún wrote:
On Tue, 21 Dec 2021 17:17:22 +0100 Adrian Fiergolski adrian.fiergolski@fastree3d.com wrote:
This patch replaces use fdtdec_get_addr with recommended fdtdec_get_addr_size_auto_parent.
And why is that required?
I didn't debug why exactly, but it didn't work with my embedded system based on ZynqMP (64bit). I might guess it's related to the fact that, quoting 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)".
If at all, I would rather change it to simple dev_read_addr().
Good idea, it's much cleaner. I have just confirmed it works as well. I will share the new version of the patches.
Adrian

Thanks everyone for including me — I don’t have any code comments but I will say that this i2c driver, with the exception of the i2c default address (which looks like is being set via the device tree anyway), should also work with the ATECC508, ATECC608A, ATECC608B (which is the one of those three recommended for new designs) as I believe the interface at this level was not changed.
So that might be a nice comment or add to documentation. Otherwise, I’m glad to see y’all supporting this.
Also, it’s been a while since I’ve been active on such mailing lists, so I can’t remember the reply etiquette exactly. Apologizes in advance for the naive top-post :)
Josh
On Dec 21, 2021, at 9:17 AM, Adrian Fiergolski adrian.fiergolski@fastree3d.com wrote:
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(-)
-- 2.34.1

On Tue, 21 Dec 2021 10:00:14 -0700 Josh Datko jbd@cryptotronix.com wrote:
Thanks everyone for including me — I don’t have any code comments but I will say that this i2c driver, with the exception of the i2c default address (which looks like is being set via the device tree anyway), should also work with the ATECC508, ATECC608A, ATECC608B (which is the one of those three recommended for new designs) as I believe the interface at this level was not changed.
We have been unable to get those, wich current chip crisis, and so we couldn't test.
Marek
participants (3)
-
Adrian Fiergolski
-
Josh Datko
-
Marek Behún