From 75967a24f9a3d86e0c2e9c937400498d47ccc3ef Mon Sep 17 00:00:00 2001 From: Adrian Fiergolski Date: Tue, 11 Jan 2022 19:05:29 +0100 Subject: [PATCH 1/6] misc: atsha204a: return timeout from wakeup function MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit If the maximum number of wake-up attempts is exceeded, return -ETIMEDOUT. Signed-off-by: Adrian Fiergolski Reviewed-by: Marek Behún --- 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 715dabb2799..9d069fb33c9 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) From e4662716fbbe4ce717cbf9f193564943ffe355f8 Mon Sep 17 00:00:00 2001 From: Adrian Fiergolski Date: Tue, 11 Jan 2022 19:05:30 +0100 Subject: [PATCH 2/6] misc: atsha204a: add delay after sending the message MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 Reviewed-by: Marek Behún --- 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 9d069fb33c9..d264477927d 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); From 532a5b297cb27a23979cf2ea2dd2a00bb2e8cf58 Mon Sep 17 00:00:00 2001 From: Adrian Fiergolski Date: Tue, 11 Jan 2022 19:05:31 +0100 Subject: [PATCH 3/6] misc: atsha204a: fix i2c address readout from DTS MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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)". Signed-off-by: Adrian Fiergolski Reviewed-by: Marek Behún --- 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 d264477927d..b89463babb5 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 = dev_read_addr(dev); if (addr == FDT_ADDR_T_NONE) { debug("Can't get ATSHA204A I2C base address\n"); return -ENXIO; From 6db539f983400279cd682fecbbd1fdd4c96d9034 Mon Sep 17 00:00:00 2001 From: Nikita Yushchenko Date: Tue, 15 Feb 2022 20:58:52 +0300 Subject: [PATCH 4/6] i2c: fix always-true condition in i2c_probe_chip() Per dm_i2c_ops.probe_chip documentation, i2c_probe_chip() shall fallback to default probe method when .probe_chip() returns -ENOSYS. Signed-off-by: Nikita Yushchenko Reviewed-by: Heiko Schocher --- drivers/i2c/i2c-uclass.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/i2c/i2c-uclass.c b/drivers/i2c/i2c-uclass.c index 5539becc197..335911c46bb 100644 --- a/drivers/i2c/i2c-uclass.c +++ b/drivers/i2c/i2c-uclass.c @@ -280,7 +280,7 @@ static int i2c_probe_chip(struct udevice *bus, uint chip_addr, if (ops->probe_chip) { ret = ops->probe_chip(bus, chip_addr, chip_flags); - if (!ret || ret != -ENOSYS) + if (ret != -ENOSYS) return ret; } From e3c2042ae7d188e00e48d984e373a2de505d8b77 Mon Sep 17 00:00:00 2001 From: Marek Vasut Date: Wed, 16 Feb 2022 15:27:59 +0100 Subject: [PATCH 5/6] cmd: eeprom: Do not rewrite EEPROM I2C bus with DM I2C enabled With DM I2C, the EEPROM bus has been correctly configured in eeprom_execute_command() already. Do not reconfigure it here with hard-coded bus number again. Signed-off-by: Marek Vasut Cc: Heiko Schocher Cc: Tom Rini Reviewed-by: Heiko Schocher --- cmd/eeprom.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmd/eeprom.c b/cmd/eeprom.c index cdd65af763b..fc0d4440694 100644 --- a/cmd/eeprom.c +++ b/cmd/eeprom.c @@ -149,7 +149,7 @@ static int eeprom_rw(unsigned dev_addr, unsigned offset, uchar *buffer, int rcode = 0; uchar addr[3]; -#if defined(CONFIG_SYS_I2C_EEPROM_BUS) +#if !CONFIG_IS_ENABLED(DM_I2C) && defined(CONFIG_SYS_I2C_EEPROM_BUS) eeprom_init(CONFIG_SYS_I2C_EEPROM_BUS); #endif From fc1383ae2b5ca69e51bee68e4047589a5ee7b386 Mon Sep 17 00:00:00 2001 From: Michael Opdenacker Date: Wed, 2 Mar 2022 16:56:02 +0100 Subject: [PATCH 6/6] bootcount: clarify documentation - Grammar fixes - Clarify explanations Signed-off-by: Michael Opdenacker Reviewed-by: Heiko Schocher --- doc/README.bootcount | 34 ++++++++++++++++++---------------- drivers/bootcount/Kconfig | 10 +++++----- 2 files changed, 23 insertions(+), 21 deletions(-) diff --git a/doc/README.bootcount b/doc/README.bootcount index b1c22905c66..f6c5f82f985 100644 --- a/doc/README.bootcount +++ b/doc/README.bootcount @@ -3,14 +3,16 @@ Boot Count Limit ================ +This is enabled by CONFIG_BOOTCOUNT_LIMIT. + This allows to detect multiple failed attempts to boot Linux. -After a power-on reset, "bootcount" variable will be initialized with 1, and +After a power-on reset, the "bootcount" variable will be initialized to 1, and each reboot will increment the value by 1. If, after a reboot, the new value of "bootcount" exceeds the value of "bootlimit", then instead of the standard boot action (executing the contents of -"bootcmd") an alternate boot action will be performed, and the contents of +"bootcmd"), an alternate boot action will be performed, and the contents of "altbootcmd" will be executed. If the variable "bootlimit" is not defined in the environment, the Boot Count @@ -18,18 +20,18 @@ Limit feature is disabled. If it is enabled, but "altbootcmd" is not defined, then U-Boot will drop into interactive mode and remain there. It is the responsibility of some application code (typically a Linux -application) to reset the variable "bootcount", thus allowing for more boot -cycles. +application) to reset the variable "bootcount" to 0 when the system booted +successfully, thus allowing for more boot cycles. -BOOTCOUNT_EXT -------------- +CONFIG_BOOTCOUNT_EXT +-------------------- This adds support for maintaining boot count in a file on an EXT filesystem. -The file to use is define by: +The file to use is defined by: -SYS_BOOTCOUNT_EXT_INTERFACE -SYS_BOOTCOUNT_EXT_DEVPART -SYS_BOOTCOUNT_EXT_NAME +CONFIG_SYS_BOOTCOUNT_EXT_INTERFACE +CONFIG_SYS_BOOTCOUNT_EXT_DEVPART +CONFIG_SYS_BOOTCOUNT_EXT_NAME The format of the file is: @@ -42,10 +44,10 @@ u8 bootcount u8 upgrade_available ==== ================= -To prevent unattended usage of "altbootcmd" the "upgrade_available" variable is +To prevent unattended usage of "altbootcmd", the "upgrade_available" variable is used. -If "upgrade_available" is 0, "bootcount" is not saved, if "upgrade_available" is -1 "bootcount" is save. -So the Userspace Application must set the "upgrade_available" and "bootcount" -variables to 0, if a boot was successfully. -This also prevents writes on all reboots. +If "upgrade_available" is 0, "bootcount" is not saved. +If "upgrade_available" is 1, "bootcount" is saved. +So a userspace application should take care of setting the "upgrade_available" +and "bootcount" variables to 0, if the system boots successfully. +This also avoids writing the "bootcount" information on all reboots. diff --git a/drivers/bootcount/Kconfig b/drivers/bootcount/Kconfig index 607027c968d..65c052fc2e7 100644 --- a/drivers/bootcount/Kconfig +++ b/drivers/bootcount/Kconfig @@ -68,15 +68,15 @@ config BOOTCOUNT_ENV "bootcount" is stored in the environment. To prevent a saveenv on all reboots, the environment variable "upgrade_available" is used. If "upgrade_available" is - 0, "bootcount" is always 0, if "upgrade_available" is - 1 "bootcount" is incremented in the environment. + 0, "bootcount" is always 0. If "upgrade_available" is 1, + "bootcount" is incremented in the environment. So the Userspace Application must set the "upgrade_available" - and "bootcount" variable to 0, if a boot was successfully. + and "bootcount" variables to 0, if the system booted successfully. config BOOTCOUNT_RAM bool "Boot counter in RAM" help - Store the bootcount in DRAM protected against against bit errors + Store the bootcount in DRAM protected against bit errors due to short power loss or holding a system in RESET. config BOOTCOUNT_I2C @@ -166,7 +166,7 @@ config BOOTCOUNT_BOOTLIMIT help Set the Maximum number of reboot cycles allowed without the boot counter being cleared. - If set to 0 do not set a boot limit in the environment. + If set to 0, do not set a boot limit in the environment. config BOOTCOUNT_ALEN int "I2C address length"