arm: mvebu: a37xx: Add support for reading OTP
Subsystems (3)
cover arm: mvebu: a37xx: Add support for reading OTP
Add support for reading NB fuse OTP, SB fuse OTP and Security OTP values via U-Boot fuse API on Armada 37xx boards.
Pali Rohár (5):
arm: mvebu: a37xx: Add support for reading NB and SB fuse OTP value
arm: mvebu: a37xx: Enable fuse command on all Armada 3720 boards
arm: mvebu: a37xx: Move generic mbox code to arch/arm/mach-mvebu
arm: mvebu: a37xx: Extend mbox_do_cmd() code
arm: mvebu: a37xx: Add support for reading Security OTP values
arch/arm/mach-mvebu/Kconfig | 1 + arch/arm/mach-mvebu/Makefile | 3 + arch/arm/mach-mvebu/armada3700/Makefile | 3 +- arch/arm/mach-mvebu/armada3700/efuse.c | 172 ++++++++++++++++++++ arch/arm/mach-mvebu/armada3700/mbox.c | 79 +++++++++ arch/arm/mach-mvebu/include/mach/mbox.h | 40 +++++ board/CZ.NIC/turris_mox/mox_sp.c | 73 +-------- configs/mvebu_db-88f3720_defconfig | 2 + configs/mvebu_espressobin-88f3720_defconfig | 2 + configs/turris_mox_defconfig | 2 + configs/uDPU_defconfig | 2 + 11 files changed, 308 insertions(+), 71 deletions(-) create mode 100644 arch/arm/mach-mvebu/armada3700/efuse.c create mode 100644 arch/arm/mach-mvebu/armada3700/mbox.c create mode 100644 arch/arm/mach-mvebu/include/mach/mbox.h
Signature · 1 line
2.20.1
PATCH 1/5 arm: mvebu: a37xx: Add support for reading NB and SB fuse OTP value
Implement it via U-Boot fuse API.
Banks 0-43 are reserved for accessing Security OTP (not implemented yet). Bank 44 is used for accessing North Bridge OTP (69 bits via words 0-2). Bank 45 is used for accessing South Bridge OTP (97 bits via words 0-3).
Write support is not implemented yet as it looks like that both North and South Bridge OTPs are already burned in factory with some data. Meaning of some bits of North Bridge are documented in WTMI source code. Meaning of bits in South Bridge is unknown.
--- arch/arm/mach-mvebu/Kconfig | 1 + arch/arm/mach-mvebu/Makefile | 3 + arch/arm/mach-mvebu/armada3700/Makefile | 1 + arch/arm/mach-mvebu/armada3700/efuse.c | 136 ++++++++++++++++++++++++ 4 files changed, 141 insertions(+) create mode 100644 arch/arm/mach-mvebu/armada3700/efuse.c
arch/arm/mach-mvebu/Kconfig +1 -0
@@ -44,6 +44,7 @@ config ARMADA_XP config ARMADA_3700 bool select ARM64 + select HAVE_MVEBU_EFUSE # Armada 7K and 8K are very similar - use only one Kconfig symbol for both config ARMADA_8K
arch/arm/mach-mvebu/Makefile +3 -0
@@ -27,7 +27,10 @@ obj-$(CONFIG_ARMADA_375) += ../../../drivers/ddr/marvell/axp/xor.o obj-$(CONFIG_ARMADA_38X) += ../../../drivers/ddr/marvell/a38x/xor.o obj-$(CONFIG_ARMADA_XP) += ../../../drivers/ddr/marvell/axp/xor.o obj-$(CONFIG_ARMADA_MSYS) += ../../../drivers/ddr/marvell/axp/xor.o + +ifdef CONFIG_ARMADA_38X obj-$(CONFIG_MVEBU_EFUSE) += efuse.o +endif extra-y += kwbimage.cfg
arch/arm/mach-mvebu/armada3700/Makefile +1 -0
@@ -3,3 +3,4 @@ # Copyright (C) 2016 Stefan Roese <[email protected]> obj-y = cpu.o +obj-$(CONFIG_MVEBU_EFUSE) += efuse.o
arch/arm/mach-mvebu/armada3700/efuse.c new file +136 -0
136 lines not on this page · raw message
Signature · 1 line
2.20.1
Re: [PATCH u-boot-mvebu 1/5] arm: mvebu: a37xx: Add support for reading NB and SB fuse OTP value
Quoted 1 line · On Thu, 17 Feb 2022 10:26:15 +0100 Pali Rohár <[email protected]> wrote:
Implement it via U-Boot fuse API.
nitpick: In commit messages I prefer not to refer to commit title, i.e. instead of
Implement it via U-Boot fuse API.
I would write
Implement reading NB and SB fuses of Armada 37xx SOC via U-Boot fuse API.
as the first sentence.
Quoted 6 lines
Banks 0-43 are reserved for accessing Security OTP (not implemented yet). Bank 44 is used for accessing North Bridge OTP (69 bits via words 0-2). Bank 45 is used for accessing South Bridge OTP (97 bits via words 0-3).
Write support is not implemented yet as it looks like that both North
^because/since
Quoted 1 line
and South Bridge OTPs are already burned in factory with some data. Meaning
^The
meaning
Quoted 1 line
of some bits of North Bridge are documented in WTMI source code. Meaning of
^is (or meaningS are) ^The
meaning of
Quoted 1 line
bits in South Bridge is unknown.
Otherwise
PATCH 2/5 arm: mvebu: a37xx: Enable fuse command on all Armada 3720 boards
In reply to Pali RohárAllows to read OTP bits via U-Boot fuse command on all Armada 3720 boards.
--- configs/mvebu_db-88f3720_defconfig | 2 ++ configs/mvebu_espressobin-88f3720_defconfig | 2 ++ configs/turris_mox_defconfig | 2 ++ configs/uDPU_defconfig | 2 ++ 4 files changed, 8 insertions(+)
configs/mvebu_db-88f3720_defconfig +2 -0
@@ -5,6 +5,7 @@ CONFIG_SYS_TEXT_BASE=0x00000000 CONFIG_SYS_MALLOC_F_LEN=0x2000 CONFIG_NR_DRAM_BANKS=1 CONFIG_TARGET_MVEBU_ARMADA_37XX=y +CONFIG_MVEBU_EFUSE=y CONFIG_ENV_SIZE=0x10000 CONFIG_ENV_OFFSET=0x3f0000 CONFIG_ENV_SECT_SIZE=0x10000
@@ -24,6 +25,7 @@ CONFIG_DISPLAY_BOARDINFO_LATE=y CONFIG_ARCH_EARLY_INIT_R=y CONFIG_BOARD_EARLY_INIT_F=y # CONFIG_CMD_FLASH is not set +CONFIG_CMD_FUSE=y CONFIG_CMD_GPIO=y CONFIG_CMD_I2C=y CONFIG_CMD_MMC=y
configs/mvebu_espressobin-88f3720_defconfig +2 -0
@@ -5,6 +5,7 @@ CONFIG_SYS_TEXT_BASE=0x00000000 CONFIG_SYS_MALLOC_F_LEN=0x2000 CONFIG_NR_DRAM_BANKS=1 CONFIG_TARGET_MVEBU_ARMADA_37XX=y +CONFIG_MVEBU_EFUSE=y CONFIG_ENV_SIZE=0x10000 CONFIG_ENV_OFFSET=0x3F0000 CONFIG_ENV_SECT_SIZE=0x10000
@@ -26,6 +27,7 @@ CONFIG_ARCH_EARLY_INIT_R=y CONFIG_BOARD_EARLY_INIT_F=y CONFIG_BOARD_LATE_INIT=y # CONFIG_CMD_FLASH is not set +CONFIG_CMD_FUSE=y CONFIG_CMD_GPIO=y CONFIG_CMD_GPT=y CONFIG_CMD_I2C=y
configs/turris_mox_defconfig +2 -0
@@ -5,6 +5,7 @@ CONFIG_SYS_TEXT_BASE=0x00000000 CONFIG_SYS_MALLOC_F_LEN=0x2000 CONFIG_NR_DRAM_BANKS=2 CONFIG_TARGET_TURRIS_MOX=y +CONFIG_MVEBU_EFUSE=y CONFIG_ENV_SIZE=0x10000 CONFIG_ENV_OFFSET=0x180000 CONFIG_ENV_SECT_SIZE=0x10000
@@ -31,6 +32,7 @@ CONFIG_MISC_INIT_R=y CONFIG_CMD_SHA1SUM=y CONFIG_CMD_CLK=y # CONFIG_CMD_FLASH is not set +CONFIG_CMD_FUSE=y CONFIG_CMD_GPIO=y CONFIG_CMD_GPT=y CONFIG_CMD_I2C=y
configs/uDPU_defconfig +2 -0
@@ -4,6 +4,7 @@ CONFIG_ARCH_MVEBU=y CONFIG_SYS_TEXT_BASE=0x00000000 CONFIG_SYS_MALLOC_F_LEN=0x2000 CONFIG_TARGET_MVEBU_ARMADA_37XX=y +CONFIG_MVEBU_EFUSE=y CONFIG_ENV_SIZE=0x10000 CONFIG_ENV_OFFSET=0x180000 CONFIG_ENV_SECT_SIZE=0x10000
@@ -29,6 +30,7 @@ CONFIG_SYS_PROMPT="uDPU>> " # CONFIG_CMD_IMI is not set # CONFIG_CMD_XIMG is not set # CONFIG_CMD_FLASH is not set +CONFIG_CMD_FUSE=y CONFIG_CMD_GPIO=y CONFIG_CMD_I2C=y CONFIG_CMD_MMC=y
Signature · 1 line
2.20.1
Re: [PATCH u-boot-mvebu 2/5] arm: mvebu: a37xx: Enable fuse command on all Armada 3720 boards
Quoted 1 line · On Thu, 17 Feb 2022 10:26:16 +0100 Pali Rohár <[email protected]> wrote:
Allows to read OTP bits via U-Boot fuse command on all Armada 3720 boards.
^Allow (we use present simple in commit messages)
otherwise
PATCH 3/5 arm: mvebu: a37xx: Move generic mbox code to arch/arm/mach-mvebu
In reply to Pali RohárGeneric A3720 mbox code is currently in Turris Mox specific board file board/CZ.NIC/turris_mox/mox_sp.c. Move it to board independent arch file arch/arm/mach-mvebu/armada3700/mbox.c.
--- arch/arm/mach-mvebu/armada3700/Makefile | 2 +- arch/arm/mach-mvebu/armada3700/mbox.c | 67 ++++++++++++++++++++++++ arch/arm/mach-mvebu/include/mach/mbox.h | 23 +++++++++ board/CZ.NIC/turris_mox/mox_sp.c | 69 +------------------------ 4 files changed, 92 insertions(+), 69 deletions(-) create mode 100644 arch/arm/mach-mvebu/armada3700/mbox.c create mode 100644 arch/arm/mach-mvebu/include/mach/mbox.h
arch/arm/mach-mvebu/armada3700/Makefile +1 -1
@@ -2,5 +2,5 @@ # # Copyright (C) 2016 Stefan Roese <[email protected]> -obj-y = cpu.o +obj-y = cpu.o mbox.o obj-$(CONFIG_MVEBU_EFUSE) += efuse.o
arch/arm/mach-mvebu/armada3700/mbox.c new file +67 -0
67 lines not on this page · raw message
arch/arm/mach-mvebu/include/mach/mbox.h new file +23 -0
@@ -0,0 +1,23 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ +/* +* Copyright (C) 2018 Marek Behun <[email protected]> +*/ + +#ifndef _MVEBU_MBOX_H +#define _MVEBU_MBOX_H + +enum mbox_cmd { +MBOX_CMD_GET_RANDOM =1 , +MBOX_CMD_BOARD_INFO , +MBOX_CMD_ECDSA_PUB_KEY , +MBOX_CMD_HASH , +MBOX_CMD_SIGN , +MBOX_CMD_VERIFY , + +MBOX_CMD_OTP_READ , +MBOX_CMD_OTP_WRITE , +}; + +int mbox_do_cmd (enum mbox_cmd cmd,u32 *in,int nout); + +#endif
board/CZ.NIC/turris_mox/mox_sp.c +1 -68
75 lines not on this page · raw message
Signature · 1 line
2.20.1
Re: [PATCH u-boot-mvebu 3/5] arm: mvebu: a37xx: Move generic mbox code to arch/arm/mach-mvebu
Quoted 3 lines · On Thu, 17 Feb 2022 10:26:17 +0100 Pali Rohár <[email protected]> wrote:
Generic A3720 mbox code is currently in Turris Mox specific board file
board/CZ.NIC/turris_mox/mox_sp.c. Move it to board independent arch filearch/arm/mach-mvebu/armada3700/mbox.c.
PATCH 4/5 arm: mvebu: a37xx: Extend mbox_do_cmd() code
In reply to Pali RohárAllow to specify input parameters, define all available mbox commands supported by CZ.NIC secure firmware + Marvell fuse.bin firmware and fix parsing response from Marvell OTP commands.
--- arch/arm/mach-mvebu/armada3700/mbox.c | 16 ++++++++++++++-- arch/arm/mach-mvebu/include/mach/mbox.h | 19 ++++++++++++++++++- board/CZ.NIC/turris_mox/mox_sp.c | 4 ++-- 3 files changed, 34 insertions(+), 5 deletions(-)
arch/arm/mach-mvebu/armada3700/mbox.c +14 -2
@@ -1,6 +1,7 @@// SPDX-License-Identifier: GPL-2.0+ /* * Copyright (C) 2018 Marek Behun <[email protected]> +* Copyright (C) 2021 Pali Rohár <[email protected]> */ #include <common.h>
@@ -15,6 +16,7 @@#define RWTM_CMD (RWTM_BASE + 0x40)#define RWTM_CMD_RETSTATUS (RWTM_BASE + 0x80)#define RWTM_CMD_STATUS (i) (size_t)(RWTM_BASE + 0x84 + (i) * 4) +#define MAX_ARGS 16#define RWTM_HOST_INT_RESET (RWTM_BASE + 0xc8)#define RWTM_HOST_INT_MASK (RWTM_BASE + 0xcc)
@@ -27,15 +29,23 @@#define MBOX_STS_ERROR (s) ((s) & (3 << 30))#define MBOX_STS_VALUE (s) (((s) >> 10) & 0xfffff)#define MBOX_STS_CMD (s) ((s) & 0x3ff) +#define MBOX_STS_MARVELL_ERROR (s) ((s) == 0 ? 0 : (s) == 2 ? ETIMEDOUT : (s) == 3 ? EINVAL : (s) == 4 ? ENOSYS : EIO) -int mbox_do_cmd (enum mbox_cmd cmd,u32 *out,int nout) +int mbox_do_cmd (enum mbox_cmd cmd,u32 *in,int nin,u32 *out,int nout) {const int tries =50 ;int i;u32 status; +if (nin >MAX_ARGS || nout >MAX_ARGS ) +return -EINVAL ; +clrbits_le32 (RWTM_HOST_INT_MASK ,SP_CMD_COMPLETE ); +for (i =0 ; i < nin; i++) +writel (in[i],RWTM_CMD_PARAM (i)); +for (; i <MAX_ARGS ; i++) +writel (0x0 ,RWTM_CMD_PARAM (i));writel (cmd,RWTM_CMD );for (i =0 ; i < tries; ++i) {
@@ -57,9 +67,11 @@ int mbox_do_cmd(enum mbox_cmd cmd, u32 *out, int nout)setbits_le32 (RWTM_HOST_INT_RESET ,SP_CMD_COMPLETE );if (MBOX_STS_CMD (status) != cmd) -return -EIO ; +return -MBOX_STS_MARVELL_ERROR (status);else if (MBOX_STS_ERROR (status) ==MBOX_STS_FAIL )return -(int )MBOX_STS_VALUE (status); +else if (MBOX_STS_ERROR (status) ==MBOX_STS_BADCMD ) +return -ENOSYS ;else if (MBOX_STS_ERROR (status) !=MBOX_STS_SUCCESS )return -EIO ;else
arch/arm/mach-mvebu/include/mach/mbox.h +18 -1
@@ -1,6 +1,7 @@/* SPDX-License-Identifier: GPL-2.0+ */ /* * Copyright (C) 2018 Marek Behun <[email protected]> +* Copyright (C) 2021 Pali Rohár <[email protected]> */ #ifndef _MVEBU_MBOX_H
@@ -16,8 +17,24 @@ enum mbox_cmd {MBOX_CMD_OTP_READ ,MBOX_CMD_OTP_WRITE , + +MBOX_CMD_REBOOT , + +/* OTP read commands supported by Marvell fuse.bin firmware */ +MBOX_CMD_OTP_READ_1B =257 , +MBOX_CMD_OTP_READ_8B , +MBOX_CMD_OTP_READ_32B , +MBOX_CMD_OTP_READ_64B , +MBOX_CMD_OTP_READ_256B , + +/* OTP write commands supported by Marvell fuse.bin firmware */ +MBOX_CMD_OTP_WRITE_1B =513 , +MBOX_CMD_OTP_WRITE_8B , +MBOX_CMD_OTP_WRITE_32B , +MBOX_CMD_OTP_WRITE_64B , + MBOX_CMD_OTP_WRITE_256B, }; -int mbox_do_cmd (enum mbox_cmd cmd,u32 *in,int nout); +int mbox_do_cmd (enum mbox_cmd cmd,u32 *in,int nin,u32 *out,int nout);#endif
board/CZ.NIC/turris_mox/mox_sp.c +2 -2
@@ -19,7 +19,7 @@ const char *mox_sp_get_ecdsa_public_key(void)if (public_key[0 ])return public_key; - res =mbox_do_cmd (MBOX_CMD_ECDSA_PUB_KEY , out,16 ); + res =mbox_do_cmd (MBOX_CMD_ECDSA_PUB_KEY ,NULL ,0 , out,16 );if (res <0 )return NULL ;
@@ -47,7 +47,7 @@ int mbox_sp_get_board_info(u64 *sn, u8 *mac1, u8 *mac2, int *bv, int *ram)u32 out[8 ];int res; - res =mbox_do_cmd (MBOX_CMD_BOARD_INFO , out,8 ); + res =mbox_do_cmd (MBOX_CMD_BOARD_INFO ,NULL ,0 , out,8 );if (res <0 )return res;
Signature · 1 line
2.20.1
Re: [PATCH u-boot-mvebu 4/5] arm: mvebu: a37xx: Extend mbox_do_cmd() code
Quoted 2 lines · On Thu, 17 Feb 2022 10:26:18 +0100 Pali Rohár <[email protected]> wrote:
Allow to specify input parameters, define all available mbox commands supported by CZ.NIC secure firmware + Marvell fuse.bin firmware and fix
CZ.NIC's and also Marvell's
Quoted 3 lines
parsing response from Marvell OTP commands.
Signed-off-by Pali Rohár <[email protected]>
...
Quoted 4 lines
#define
MBOX_STS_ERROR(s)((s) & (3 << 30))
#defineMBOX_STS_VALUE(s)(((s) >> 10) &0xfffff)
#defineMBOX_STS_CMD(s)((s) &0x3ff)
+#defineMBOX_STS_MARVELL_ERROR(s)((s) == 0 ? 0 : (s) == 2 ? ETIMEDOUT : (s) == 3 ? EINVAL : (s) == 4 ? ENOSYS : EIO)
This is starting to become too complicated for a macro :-( What do you think about converting all these to a static function? Something like
static int mbox_parse_status(u32 status, u16 *cmd, u32 *value,
bool marvell)
{
...
}arch/arm/mach-mvebu/include/mach/mbox.h enum mbox_cmd { · line 23
Quoted 10 lines
#ifndef
_MVEBU_MBOX_Harch/arm/mach-mvebu/include/mach/mbox.h +4
-0@@ -16,8 +17,24 @@ enum mbox_cmd {MBOX_CMD_OTP_READ ,MBOX_CMD_OTP_WRITE , + + MBOX_CMD_REBOOT, + +/* OTP read commands supported by Marvell fuse.bin firmware */
Marvell's
arch/arm/mach-mvebu/include/mach/mbox.h enum mbox_cmd { · line 30
Quoted 7 lines
arch/arm/mach-mvebu/include/mach/mbox.h +7
-0+MBOX_CMD_OTP_READ_1B =257 , +MBOX_CMD_OTP_READ_8B , +MBOX_CMD_OTP_READ_32B , +MBOX_CMD_OTP_READ_64B , + MBOX_CMD_OTP_READ_256B, + +/* OTP write commands supported by Marvell fuse.bin firmware */
Marvell's
Re: [PATCH u-boot-mvebu 4/5] arm: mvebu: a37xx: Extend mbox_do_cmd() code
Quoted 10 lines · On Thursday 17 February 2022 15:16:33 Marek Behún wrote:
Quoted 2 lines · On Thu, 17 Feb 2022 10:26:18 +0100 Pali Rohár <[email protected]> wrote:
Allow to specify input parameters, define all available mbox commands supported by CZ.NIC secure firmware + Marvell fuse.bin firmware and fix
CZ.NIC's and also Marvell's
Quoted 3 lines
parsing response from Marvell OTP commands.
Signed-off-by Pali Rohár <[email protected]>
Quoted 8 lines
...
Quoted 4 lines
#define
MBOX_STS_ERROR(s)((s) & (3 << 30))
#defineMBOX_STS_VALUE(s)(((s) >> 10) &0xfffff)
#defineMBOX_STS_CMD(s)((s) &0x3ff)
+#defineMBOX_STS_MARVELL_ERROR(s)((s) == 0 ? 0 : (s) == 2 ? ETIMEDOUT : (s) == 3 ? EINVAL : (s) == 4 ? ENOSYS : EIO)This is starting to become too complicated for a macro :-(
It is straightforward switch macro. I can reformat it to be more readable, e.g.:
#define MBOX_STS_MARVELL_ERROR(s) ((s) == 0 ? 0 : \ (s) == 2 ? ETIMEDOUT : \ (s) == 3 ? EINVAL : \ (s) == 4 ? ENOSYS : \ EIO)
Quoted 28 lines
What do you think about converting all these to a static function? Something like
static int mbox_parse_status(u32 status, u16 *cmd, u32 *value,
bool marvell){ ... }arch/arm/mach-mvebu/include/mach/mbox.h enum mbox_cmd { · line 23
Quoted 10 lines
#ifndef
_MVEBU_MBOX_Harch/arm/mach-mvebu/include/mach/mbox.h +4
-0@@ -16,8 +17,24 @@ enum mbox_cmd {MBOX_CMD_OTP_READ ,MBOX_CMD_OTP_WRITE , + + MBOX_CMD_REBOOT, + +/* OTP read commands supported by Marvell fuse.bin firmware */ Marvell's
arch/arm/mach-mvebu/include/mach/mbox.h enum mbox_cmd { · line 30
Quoted 7 lines
arch/arm/mach-mvebu/include/mach/mbox.h +7
-0+MBOX_CMD_OTP_READ_1B =257 , +MBOX_CMD_OTP_READ_8B , +MBOX_CMD_OTP_READ_32B , +MBOX_CMD_OTP_READ_64B , + MBOX_CMD_OTP_READ_256B, + +/* OTP write commands supported by Marvell fuse.bin firmware */ Marvell's
Re: [PATCH u-boot-mvebu 4/5] arm: mvebu: a37xx: Extend mbox_do_cmd() code
Quoted 20 lines · On Thu, 17 Feb 2022 18:13:17 +0100 Pali Rohár <[email protected]> wrote:
Quoted 10 lines · On Thursday 17 February 2022 15:16:33 Marek Behún wrote:
Quoted 2 lines · On Thu, 17 Feb 2022 10:26:18 +0100 Pali Rohár <[email protected]> wrote:
Allow to specify input parameters, define all available mbox commands supported by CZ.NIC secure firmware + Marvell fuse.bin firmware and fix
CZ.NIC's and also Marvell's
Quoted 3 lines
parsing response from Marvell OTP commands.
Signed-off-by Pali Rohár <[email protected]>Quoted 8 lines
...
Quoted 4 lines
#define
MBOX_STS_ERROR(s)((s) & (3 << 30))
#defineMBOX_STS_VALUE(s)(((s) >> 10) &0xfffff)
#defineMBOX_STS_CMD(s)((s) &0x3ff)
+#defineMBOX_STS_MARVELL_ERROR(s)((s) == 0 ? 0 : (s) == 2 ? ETIMEDOUT : (s) == 3 ? EINVAL : (s) == 4 ? ENOSYS : EIO)This is starting to become too complicated for a macro :-(
Quoted 8 lines
It is straightforward switch macro. I can reformat it to be more readable, e.g.:
#define MBOX_STS_MARVELL_ERROR(s) ((s) == 0 ? 0 : \ (s) == 2 ? ETIMEDOUT : \ (s) == 3 ? EINVAL : \ (s) == 4 ? ENOSYS : \ EIO)
I would still prefer static functions for such expressions, but this formatting is better then nothing.
If you resend with this formatting, you can add my Reviewed-by.
Marek
PATCH 5/5 arm: mvebu: a37xx: Add support for reading Security OTP values
In reply to Pali RohárOnly secure CM3 core can access Security OTP. It is not possible via A53 core on which is running U-Boot. Marvell for this purpose defined mbox API for sending OTP commands between CM and A53 cores.
Implement this Marvell mbox API via U-Boot fuse API.
Banks 0-43 are used for accessing Security OTP (44 rows with 67 bits via 44 banks and words 0-2).
Write support is not implemented yet.
--- arch/arm/mach-mvebu/armada3700/efuse.c | 40 ++++++++++++++++++++++++-- 1 file changed, 38 insertions(+), 2 deletions(-)
arch/arm/mach-mvebu/armada3700/efuse.c +38 -2
@@ -8,6 +8,7 @@#include <common.h> #include <asm/io.h> #include <linux/delay.h> +#include <mach/mbox.h> #include <mach/soc.h> #define OTP_NB_REG_BASE ((void __iomem *)MVEBU_REGISTER(0x12600))
@@ -77,6 +78,42 @@ static void otp_read_parallel(void __iomem *base, u32 *data, u32 count) } } +static int rwtm_otp_read (u8 row,u32 word,u32 *data) +{ +u32 out[3 ]; +u32 in[2 ]; +int res; + +/* +* MBOX_CMD_OTP_READ_32B command is supported by Marvell fuse.bin +* firmware and also by new (yet unreleased) CZ.NIC wtmi firmware. +* But this command does not provide access to lock bit. +*/ +if (word <2 ) { + in[0 ] = row; + in[1 ] = word *32 ; + res =mbox_do_cmd (MBOX_CMD_OTP_READ_32B , in,2 , out,2 ); +if (res != -ENOSYS ) { +if (!res) + *data = out[0 ]; +return res; + } +/* Fallback for old version of CZ.NIC wtmi firmware. */ + } + +/* +* MBOX_CMD_OTP_READ command is supported only by CZ.NIC wtmi firmware +* (in all versions) and provide access to all bits, including lock bit. +* Note that CZ.NIC wtmi firmware may be compiled to disallow access to +* OTP (for security reasons), so this command may fail too. +*/ + in[0 ] = row; + res =mbox_do_cmd (MBOX_CMD_OTP_READ , in,1 , out,3 ); +if (!res) + *data = out[word]; +return res; +} +/* * Banks 0-43 are used for accessing Security OTP (44 rows with 67 bits via 44 banks and words 0-2) * Bank 44 is used for accessing North Bridge OTP (69 bits via words 0-2)
@@ -96,8 +133,7 @@ int fuse_read(u32 bank, u32 word, u32 *val)if (bank <=RWTM_MAX_BANK ) {if (word >=RWTM_ROW_WORDS )return -EINVAL ; -/* TODO: not implemented yet */ -return -ENOSYS ; +return rwtm_otp_read (bank, word, val); }else if (bank ==OTP_NB_BANK ) {u32 data[OTP_NB_WORDS ];if (word >=OTP_NB_WORDS )
Signature · 1 line
2.20.1
Re: [PATCH u-boot-mvebu 5/5] arm: mvebu: a37xx: Add support for reading Security OTP values
Quoted 1 line · On Thu, 17 Feb 2022 10:26:19 +0100 Pali Rohár <[email protected]> wrote:
Only secure CM3 core can access Security OTP. It is not possible via A53
It is not possible for the A53 core (on which U-Boot is running) to read it directly.
Quoted 1 line
core on which is running U-Boot. Marvell for this purpose defined mbox API
For this purpose Marvell defined...
Quoted 1 line
for sending OTP commands between CM and A53 cores.
^CM3
Quoted 1 line
Implement this Marvell mbox API via U-Boot fuse API.
Implement these Marvell fuse reading mbox commands via ....
Quoted 2 lines
Banks 0-43 are used for accessing Security OTP (44 rows with 67 bits via 44 banks and words 0-2).
Note that of the 67 bits, the 3 upper bits are: 1 lock bit and 2 auxiliary bits (meant for testing during the manufacture of the SOC, as I understand it).
Also note that the lock bit and the auxiliary bits are not readable via Marvell commands.
With CZ.NIC's commands the lock bit is readable.
Quoted 22 lines
Write support is not implemented yet.
Signed-off-by Pali Rohár <[email protected]>--- arch/arm/mach-mvebu/armada3700/efuse.c | 40 ++++++++++++++++++++++++-- 1 file changed, 38 insertions(+), 2 deletions(-)arch/arm/mach-mvebu/armada3700/efuse.c +1
-0@@ -8,6 +8,7 @@#include <common.h> #include <asm/io.h> #include <linux/delay.h> +#include <mach/mbox.h> #include <mach/soc.h> #define OTP_NB_REG_BASE ((void __iomem *)MVEBU_REGISTER(0x12600))@@ -77,6 +78,42 @@ static void otp_read_parallel(void __iomem *base, u32 *data, u32 count) } }
arch/arm/mach-mvebu/armada3700/efuse.c static void otp_read_parallel(void __iomem *base, u32 *data, u32 count) · line 89
Quoted 10 lines
arch/arm/mach-mvebu/armada3700/efuse.c +9
-0+static int rwtm_otp_read (u8 row,u32 word,u32 *data) +{ +u32 out[3 ]; +u32 in[2 ]; +int res; + +/* +* MBOX_CMD_OTP_READ_32B command is supported by Marvell fuse.bin +* firmware and also by new (yet unreleased) CZ.NIC wtmi firmware.
Marvell's, CZ.NIC's, and drop the "(yet unreleased)", because you'll need to send another patch that drops it afterwards.
arch/arm/mach-mvebu/armada3700/efuse.c static void otp_read_parallel(void __iomem *base, u32 *data, u32 count) · line 102
Quoted 13 lines
arch/arm/mach-mvebu/armada3700/efuse.c +13
-0+* But this command does not provide access to lock bit. +*/ +if (word <2 ) { + in[0 ] = row; + in[1 ] = word *32 ; + res =mbox_do_cmd (MBOX_CMD_OTP_READ_32B , in,2 , out,2 ); +if (res != -ENOSYS ) { +if (!res) + *data = out[0 ]; +return res; + } +/* Fallback for old version of CZ.NIC wtmi firmware. */ + }
I am afraid this is not correct, because Marvell's firmware reads the efuse without Error Correction. So it is possible for Marvell's command to return different value than CZ.NIC's command.
You need to determine whether CZ.NIC's command is supported, and use it if it is, otherwise use Marvell's command. Or you need to define whether and when the Error Correction is supposed to be used, or something.
But doing what you are doing here can make Turris MOX boards read different values. I know of at least one board where serial number or MAC address needs Error Correction.
Marek
Re: [PATCH u-boot-mvebu 5/5] arm: mvebu: a37xx: Add support for reading Security OTP values
Quoted 85 lines · On Thursday 17 February 2022 15:31:10 Marek Behún wrote:
Quoted 1 line · On Thu, 17 Feb 2022 10:26:19 +0100 Pali Rohár <[email protected]> wrote:
Only secure CM3 core can access Security OTP. It is not possible via A53
It is not possible for the A53 core (on which U-Boot is running) to read it directly.
Quoted 1 line
core on which is running U-Boot. Marvell for this purpose defined mbox API
For this purpose Marvell defined...
Quoted 1 line
for sending OTP commands between CM and A53 cores.
^CM3Quoted 1 line
Implement this Marvell mbox API via U-Boot fuse API.
Implement these Marvell fuse reading mbox commands via ....
Quoted 2 lines
Banks 0-43 are used for accessing Security OTP (44 rows with 67 bits via 44 banks and words 0-2).
Note that of the 67 bits, the 3 upper bits are: 1 lock bit and 2 auxiliary bits (meant for testing during the manufacture of the SOC, as I understand it).
Also note that the lock bit and the auxiliary bits are not readable via Marvell commands.
With CZ.NIC's commands the lock bit is readable.
Quoted 22 lines
Write support is not implemented yet.
Signed-off-by Pali Rohár <[email protected]>--- arch/arm/mach-mvebu/armada3700/efuse.c | 40 ++++++++++++++++++++++++-- 1 file changed, 38 insertions(+), 2 deletions(-)arch/arm/mach-mvebu/armada3700/efuse.c +1
-0@@ -8,6 +8,7 @@#include <common.h> #include <asm/io.h> #include <linux/delay.h> +#include <mach/mbox.h> #include <mach/soc.h> #define OTP_NB_REG_BASE ((void __iomem *)MVEBU_REGISTER(0x12600))@@ -77,6 +78,42 @@ static void otp_read_parallel(void __iomem *base, u32 *data, u32 count) } }arch/arm/mach-mvebu/armada3700/efuse.c static void otp_read_parallel(void __iomem *base, u32 *data, u32 count) · line 89
Quoted 10 lines
arch/arm/mach-mvebu/armada3700/efuse.c +9
-0+static int rwtm_otp_read (u8 row,u32 word,u32 *data) +{ +u32 out[3 ]; +u32 in[2 ]; +int res; + +/* +* MBOX_CMD_OTP_READ_32B command is supported by Marvell fuse.bin +* firmware and also by new (yet unreleased) CZ.NIC wtmi firmware. Marvell's, CZ.NIC's, and drop the "(yet unreleased)", because you'll need to send another patch that drops it afterwards.
arch/arm/mach-mvebu/armada3700/efuse.c static void otp_read_parallel(void __iomem *base, u32 *data, u32 count) · line 102
Quoted 13 lines
arch/arm/mach-mvebu/armada3700/efuse.c +13
-0+* But this command does not provide access to lock bit. +*/ +if (word <2 ) { + in[0 ] = row; + in[1 ] = word *32 ; + res =mbox_do_cmd (MBOX_CMD_OTP_READ_32B , in,2 , out,2 ); +if (res != -ENOSYS ) { +if (!res) + *data = out[0 ]; +return res; + } +/* Fallback for old version of CZ.NIC wtmi firmware. */ + }I am afraid this is not correct, because Marvell's firmware reads the efuse without Error Correction. So it is possible for Marvell's command to return different value than CZ.NIC's command.
Quoted 4 lines
You need to determine whether CZ.NIC's command is supported, and use it if it is, otherwise use Marvell's command. Or you need to define whether and when the Error Correction is supposed to be used, or something.
Seems that this U-Boot fuse API is low level API, so it probably would be better to always read without ECC correction (which is provided by Marvell OTP API). As ECC is stored in other bits, it is possible to read everything needed for ECC correction via this API.
This could simplify patch: Lock bit read via CZ.NIC API (as there is no other API) and other bits read via Marvell API (which is going to be supported also by CZ.NIC firmware).
Quoted 5 lines
But doing what you are doing here can make Turris MOX boards read different values. I know of at least one board where serial number or MAC address needs Error Correction.
Marek
Re: [PATCH u-boot-mvebu 5/5] arm: mvebu: a37xx: Add support for reading Security OTP values
Quoted 91 lines · On Thu, 17 Feb 2022 17:50:31 +0100 Pali Rohár <[email protected]> wrote:
Quoted 85 lines · On Thursday 17 February 2022 15:31:10 Marek Behún wrote:
Quoted 1 line · On Thu, 17 Feb 2022 10:26:19 +0100 Pali Rohár <[email protected]> wrote:
Only secure CM3 core can access Security OTP. It is not possible via A53
It is not possible for the A53 core (on which U-Boot is running) to read it directly.
Quoted 1 line
core on which is running U-Boot. Marvell for this purpose defined mbox API
For this purpose Marvell defined...
Quoted 1 line
for sending OTP commands between CM and A53 cores.
^CM3Quoted 1 line
Implement this Marvell mbox API via U-Boot fuse API.
Implement these Marvell fuse reading mbox commands via ....
Quoted 2 lines
Banks 0-43 are used for accessing Security OTP (44 rows with 67 bits via 44 banks and words 0-2).
Note that of the 67 bits, the 3 upper bits are: 1 lock bit and 2 auxiliary bits (meant for testing during the manufacture of the SOC, as I understand it).
Also note that the lock bit and the auxiliary bits are not readable via Marvell commands.
With CZ.NIC's commands the lock bit is readable.
Quoted 22 lines
Write support is not implemented yet.
Signed-off-by Pali Rohár <[email protected]>--- arch/arm/mach-mvebu/armada3700/efuse.c | 40 ++++++++++++++++++++++++-- 1 file changed, 38 insertions(+), 2 deletions(-)arch/arm/mach-mvebu/armada3700/efuse.c +1
-0@@ -8,6 +8,7 @@#include <common.h> #include <asm/io.h> #include <linux/delay.h> +#include <mach/mbox.h> #include <mach/soc.h> #define OTP_NB_REG_BASE ((void __iomem *)MVEBU_REGISTER(0x12600))@@ -77,6 +78,42 @@ static void otp_read_parallel(void __iomem *base, u32 *data, u32 count) } }arch/arm/mach-mvebu/armada3700/efuse.c static void otp_read_parallel(void __iomem *base, u32 *data, u32 count) · line 89
Quoted 10 lines
arch/arm/mach-mvebu/armada3700/efuse.c +9
-0+static int rwtm_otp_read (u8 row,u32 word,u32 *data) +{ +u32 out[3 ]; +u32 in[2 ]; +int res; + +/* +* MBOX_CMD_OTP_READ_32B command is supported by Marvell fuse.bin +* firmware and also by new (yet unreleased) CZ.NIC wtmi firmware. Marvell's, CZ.NIC's, and drop the "(yet unreleased)", because you'll need to send another patch that drops it afterwards.
arch/arm/mach-mvebu/armada3700/efuse.c static void otp_read_parallel(void __iomem *base, u32 *data, u32 count) · line 102
Quoted 13 lines
arch/arm/mach-mvebu/armada3700/efuse.c +13
-0+* But this command does not provide access to lock bit. +*/ +if (word <2 ) { + in[0 ] = row; + in[1 ] = word *32 ; + res =mbox_do_cmd (MBOX_CMD_OTP_READ_32B , in,2 , out,2 ); +if (res != -ENOSYS ) { +if (!res) + *data = out[0 ]; +return res; + } +/* Fallback for old version of CZ.NIC wtmi firmware. */ + }I am afraid this is not correct, because Marvell's firmware reads the efuse without Error Correction. So it is possible for Marvell's command to return different value than CZ.NIC's command.
Quoted 4 lines
You need to determine whether CZ.NIC's command is supported, and use it if it is, otherwise use Marvell's command. Or you need to define whether and when the Error Correction is supposed to be used, or something.
Quoted 8 lines
Seems that this U-Boot fuse API is low level API, so it probably would be better to always read without ECC correction (which is provided by Marvell OTP API). As ECC is stored in other bits, it is possible to read everything needed for ECC correction via this API.
This could simplify patch: Lock bit read via CZ.NIC API (as there is no other API) and other bits read via Marvell API (which is going to be supported also by CZ.NIC firmware).
Ok, as long as turris_mox.c reads OTP with Error Correction, fuse can be kept low level.
Marek
Quoted 5 lines
Quoted 5 lines
But doing what you are doing here can make Turris MOX boards read different values. I know of at least one board where serial number or MAC address needs Error Correction.
Marek
Re: [PATCH u-boot-mvebu 5/5] arm: mvebu: a37xx: Add support for reading Security OTP values
In reply to Marek BehúnQuoted 9 lines · On Thursday 17 February 2022 15:31:10 Marek Behún wrote:
Quoted 9 lines
arch/arm/mach-mvebu/armada3700/efuse.c +9
-0+* But this command does not provide access to lock bit. +*/ +if (word <2 ) { + in[0 ] = row; + in[1 ] = word *32 ; + res =mbox_do_cmd (MBOX_CMD_OTP_READ_32B , in,2 , out,2 ); +if (res != -ENOSYS ) { +if (!res) + *data = out[0 ];
Quoted 8 lines
arch/arm/mach-mvebu/armada3700/efuse.c static void otp_read_parallel(void __iomem *base, u32 *data, u32 count) · line 102
Quoted 4 lines
arch/arm/mach-mvebu/armada3700/efuse.c +4
-0+return res; + } +/* Fallback for old version of CZ.NIC wtmi firmware. */ + }I am afraid this is not correct, because Marvell's firmware reads the efuse without Error Correction. So it is possible for Marvell's command to return different value than CZ.NIC's command.
This is not truth. CZ.NIC firmware for MBOX_CMD_OTP_READ command calls efuse_read_row_no_ecc which is not doing error correction too.
So both commands return same value, without error correction.
Re: [PATCH u-boot-mvebu 5/5] arm: mvebu: a37xx: Add support for reading Security OTP values
Quoted 19 lines · On Tue, 22 Feb 2022 21:47:57 +0100 Pali Rohár <[email protected]> wrote:
Quoted 9 lines · On Thursday 17 February 2022 15:31:10 Marek Behún wrote:
Quoted 9 lines
arch/arm/mach-mvebu/armada3700/efuse.c +9
-0+* But this command does not provide access to lock bit. +*/ +if (word <2 ) { + in[0 ] = row; + in[1 ] = word *32 ; + res =mbox_do_cmd (MBOX_CMD_OTP_READ_32B , in,2 , out,2 ); +if (res != -ENOSYS ) { +if (!res) + *data = out[0 ];Quoted 8 lines
arch/arm/mach-mvebu/armada3700/efuse.c static void otp_read_parallel(void __iomem *base, u32 *data, u32 count) · line 102
Quoted 4 lines
arch/arm/mach-mvebu/armada3700/efuse.c +4
-0+return res; + } +/* Fallback for old version of CZ.NIC wtmi firmware. */ + }I am afraid this is not correct, because Marvell's firmware reads the efuse without Error Correction. So it is possible for Marvell's command to return different value than CZ.NIC's command.
Quoted 4 lines
This is not truth. CZ.NIC firmware for
MBOX_CMD_OTP_READcommand callsefuse_read_row_no_eccwhich is not doing error correction too.So both commands return same value, without error correction.
Seems that I have trouble remembering what how I have actually implemented it :) Oh well. Sorry about this.
v2 cover arm: mvebu: a37xx: Add support for reading OTP
In reply to Pali RohárAdd support for reading NB fuse OTP, SB fuse OTP and Security OTP values via U-Boot fuse API on Armada 37xx boards.
Pali Rohár (5):
arm: mvebu: a37xx: Add support for reading NB and SB fuse OTP value
arm: mvebu: a37xx: Enable fuse command on all Armada 3720 boards
arm: mvebu: a37xx: Move generic mbox code to arch/arm/mach-mvebu
arm: mvebu: a37xx: Extend mbox_do_cmd() code
arm: mvebu: a37xx: Add support for reading Security OTP values
arch/arm/mach-mvebu/Kconfig | 1 + arch/arm/mach-mvebu/Makefile | 3 + arch/arm/mach-mvebu/armada3700/Makefile | 3 +- arch/arm/mach-mvebu/armada3700/efuse.c | 170 ++++++++++++++++++++ arch/arm/mach-mvebu/armada3700/mbox.c | 83 ++++++++++ arch/arm/mach-mvebu/include/mach/mbox.h | 40 +++++ board/CZ.NIC/turris_mox/mox_sp.c | 73 +-------- configs/mvebu_db-88f3720_defconfig | 2 + configs/mvebu_espressobin-88f3720_defconfig | 2 + configs/turris_mox_defconfig | 2 + configs/uDPU_defconfig | 2 + 11 files changed, 310 insertions(+), 71 deletions(-) create mode 100644 arch/arm/mach-mvebu/armada3700/efuse.c create mode 100644 arch/arm/mach-mvebu/armada3700/mbox.c create mode 100644 arch/arm/mach-mvebu/include/mach/mbox.h
Signature · 1 line
2.20.1
PATCH v2 1/5 arm: mvebu: a37xx: Add support for reading NB and SB fuse OTP value
Implement reading NB and SB fuses of Armada 37xx SOC via U-Boot fuse API.
Banks 0-43 are reserved for accessing Security OTP (not implemented yet). Bank 44 is used for accessing North Bridge OTP (69 bits via words 0-2). Bank 45 is used for accessing South Bridge OTP (97 bits via words 0-3).
Write support is not implemented yet because it looks like that both North and South Bridge OTPs are already burned in factory with some data. The meaning of some bits of North Bridge is documented in WTMI source code. The meaning of bits in South Bridge is unknown.
--- arch/arm/mach-mvebu/Kconfig | 1 + arch/arm/mach-mvebu/Makefile | 3 + arch/arm/mach-mvebu/armada3700/Makefile | 1 + arch/arm/mach-mvebu/armada3700/efuse.c | 136 ++++++++++++++++++++++++ 4 files changed, 141 insertions(+) create mode 100644 arch/arm/mach-mvebu/armada3700/efuse.c
arch/arm/mach-mvebu/Kconfig +1 -0
@@ -44,6 +44,7 @@ config ARMADA_XP config ARMADA_3700 bool select ARM64 + select HAVE_MVEBU_EFUSE # Armada 7K and 8K are very similar - use only one Kconfig symbol for both config ARMADA_8K
arch/arm/mach-mvebu/Makefile +3 -0
@@ -27,7 +27,10 @@ obj-$(CONFIG_ARMADA_375) += ../../../drivers/ddr/marvell/axp/xor.o obj-$(CONFIG_ARMADA_38X) += ../../../drivers/ddr/marvell/a38x/xor.o obj-$(CONFIG_ARMADA_XP) += ../../../drivers/ddr/marvell/axp/xor.o obj-$(CONFIG_ARMADA_MSYS) += ../../../drivers/ddr/marvell/axp/xor.o + +ifdef CONFIG_ARMADA_38X obj-$(CONFIG_MVEBU_EFUSE) += efuse.o +endif extra-y += kwbimage.cfg
arch/arm/mach-mvebu/armada3700/Makefile +1 -0
@@ -3,3 +3,4 @@ # Copyright (C) 2016 Stefan Roese <[email protected]> obj-y = cpu.o +obj-$(CONFIG_MVEBU_EFUSE) += efuse.o
arch/arm/mach-mvebu/armada3700/efuse.c new file +136 -0
136 lines not on this page · raw message
Signature · 1 line
2.20.1
Re: [PATCH u-boot-mvebu v2 1/5] arm: mvebu: a37xx: Add support for reading NB and SB fuse OTP value
Quoted 6 lines · Pali Rohár
Implement reading NB and SB fuses of Armada 37xx SOC via U-Boot fuse API.
Banks 0-43 are reserved for accessing Security OTP (not implemented yet). Bank 44 is used for accessing North Bridge OTP (69 bits via words 0-2). Bank 45 is used for accessing South Bridge OTP (97 bits via words 0-3).
Quoted 7 lines
Write support is not implemented yet because it looks like that both North and South Bridge OTPs are already burned in factory with some data. The meaning of some bits of North Bridge is documented in WTMI source code. The meaning of bits in South Bridge is unknown.
Signed-off-by Pali Rohár <[email protected]>Reviewed-by Marek Behún <[email protected]>
Thanks,
Stefan
Quoted 176 lines
--- arch/arm/mach-mvebu/Kconfig | 1 + arch/arm/mach-mvebu/Makefile | 3 + arch/arm/mach-mvebu/armada3700/Makefile | 1 + arch/arm/mach-mvebu/armada3700/efuse.c | 136 ++++++++++++++++++++++++ 4 files changed, 141 insertions(+)create mode 100644
arch/arm/mach-mvebu/armada3700/efuse.carch/arm/mach-mvebu/Kconfig +1
-0@@ -44,6 +44,7 @@ config ARMADA_XP config ARMADA_3700 bool select ARM64 + select HAVE_MVEBU_EFUSE # Armada 7K and 8K are very similar - use only one Kconfig symbol for both config ARMADA_8Karch/arm/mach-mvebu/Makefile +3
-0@@ -27,7 +27,10 @@ obj-$(CONFIG_ARMADA_375) += ../../../drivers/ddr/marvell/axp/xor.o obj-$(CONFIG_ARMADA_38X) += ../../../drivers/ddr/marvell/a38x/xor.o obj-$(CONFIG_ARMADA_XP) += ../../../drivers/ddr/marvell/axp/xor.o obj-$(CONFIG_ARMADA_MSYS) += ../../../drivers/ddr/marvell/axp/xor.o + +ifdef CONFIG_ARMADA_38X obj-$(CONFIG_MVEBU_EFUSE) += efuse.o +endif extra-y += kwbimage.cfgarch/arm/mach-mvebu/armada3700/Makefile +1
-0@@ -3,3 +3,4 @@ # Copyright (C) 2016 Stefan Roese <[email protected]> obj-y = cpu.o +obj-$(CONFIG_MVEBU_EFUSE) += efuse.oarch/arm/mach-mvebu/armada3700/efuse.c new file +126
-0@@ -0,0 +1,136 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* +* (C) 2017 Marvell International Ltd. +* (C) 2021 Pali Rohár <[email protected]> +*/ + +#include <config.h> +#include <common.h> +#include <asm/io.h> +#include <linux/delay.h> +#include <mach/soc.h> + +#define OTP_NB_REG_BASE ((void __iomem *)MVEBU_REGISTER(0x12600)) +#define OTP_SB_REG_BASE ((void __iomem *)MVEBU_REGISTER(0x1A200)) + +#define OTP_CONTROL_OFF 0x00 +#define OTP_MODE_BIT BIT(15) +#define OTP_RPTR_RST_BIT BIT(14) +#define OTP_POR_B_BIT BIT(13) +#define OTP_PRDT_BIT BIT(3) +#define OTP_READ_PORT_OFF 0x04 +#define OTP_READ_POINTER_OFF 0x08 +#define OTP_PTR_INC_BIT BIT(8) + +static void otp_read_parallel (void __iomem *base,u32 *data,u32 count) +{ +u32 regval; + +/* 1. Clear OTP_MODE_NB to parallel mode */ + regval =readl (base +OTP_CONTROL_OFF ); + regval &= ~OTP_MODE_BIT ; +writel (regval, base +OTP_CONTROL_OFF ); + +/* 2. Set OTP_POR_B_NB enter normal operation */ + regval =readl (base +OTP_CONTROL_OFF ); + regval |=OTP_POR_B_BIT ; +writel (regval, base +OTP_CONTROL_OFF ); + +/* 3. Set OTP_PTR_INC_NB to auto-increment pointer after each read */ + regval =readl (base +OTP_READ_POINTER_OFF ); + regval |=OTP_PTR_INC_BIT ; +writel (regval, base +OTP_READ_POINTER_OFF ); + +/* 4. Set OTP_RPTR_RST_NB, then clear the same field */ + regval =readl (base +OTP_CONTROL_OFF ); + regval |=OTP_RPTR_RST_BIT ; +writel (regval, base +OTP_CONTROL_OFF ); + + regval =readl (base +OTP_CONTROL_OFF ); + regval &= ~OTP_RPTR_RST_BIT ; +writel (regval, base +OTP_CONTROL_OFF ); + +/* 5. Toggle OTP_PRDT_NB +* a. Set OTP_PRDT_NB to 1. +* b. Clear OTP_PRDT_NB to 0. +* c. Wait for a minimum of 100 ns. +* d. Set OTP_PRDT_NB to 1 +*/ + regval =readl (base +OTP_CONTROL_OFF ); + regval |=OTP_PRDT_BIT ; +writel (regval, base +OTP_CONTROL_OFF ); + + regval =readl (base +OTP_CONTROL_OFF ); + regval &= ~OTP_PRDT_BIT ; +writel (regval, base +OTP_CONTROL_OFF ); + +ndelay (100 ); + + regval =readl (base +OTP_CONTROL_OFF ); + regval |=OTP_PRDT_BIT ; +writel (regval, base +OTP_CONTROL_OFF ); + +while (count-- >0 ) { +/* 6. Read the content of OTP 32-bits at a time */ +ndelay (100000 ); + *(data++) =readl (base +OTP_READ_PORT_OFF ); + } +} + +/* +* Banks 0-43 are used for accessing Security OTP (44 rows with 67 bits via 44 banks and words 0-2) +* Bank 44 is used for accessing North Bridge OTP (69 bits via words 0-2) +* Bank 45 is used for accessing South Bridge OTP (97 bits via words 0-3) +*/ + +#define RWTM_ROWS 44 +#define RWTM_MAX_BANK (RWTM_ROWS - 1) +#define RWTM_ROW_WORDS 3 +#define OTP_NB_BANK RWTM_ROWS +#define OTP_NB_WORDS 3 +#define OTP_SB_BANK (RWTM_ROWS + 1) +#define OTP_SB_WORDS 4 + +int fuse_read (u32 bank,u32 word,u32 *val) +{ +if (bank <=RWTM_MAX_BANK ) { +if (word >=RWTM_ROW_WORDS ) +return -EINVAL ; +/* TODO: not implemented yet */ +return -ENOSYS ; + }else if (bank ==OTP_NB_BANK ) { +u32 data[OTP_NB_WORDS ]; +if (word >=OTP_NB_WORDS ) +return -EINVAL ; +otp_read_parallel (OTP_NB_REG_BASE , data,OTP_NB_WORDS ); + *val = data[word]; +return 0 ; + }else if (bank ==OTP_SB_BANK ) { +u32 data[OTP_SB_WORDS ]; +if (word >=OTP_SB_WORDS ) +return -EINVAL ; +otp_read_parallel (OTP_SB_REG_BASE , data,OTP_SB_WORDS ); + *val = data[word]; +return 0 ; + }else { +return -EINVAL ; + } +} + +int fuse_prog (u32 bank,u32 word,u32 val) +{ +/* TODO: not implemented yet */ +return -ENOSYS ; +} + +int fuse_sense (u32 bank,u32 word,u32 *val)
arch/arm/mach-mvebu/armada3700/efuse.c line 136
Quoted 10 lines
arch/arm/mach-mvebu/armada3700/efuse.c new file +10
-0+{ +/* not supported */ +return -ENOSYS ; +} + +int fuse_override (u32 bank,u32 word,u32 val) +{ +/* not supported */ +return -ENOSYS ; +}
Viele Grüße,
Stefan Roese
Signature · 3 lines
DENX Software Engineering GmbH, Managing Director: Wolfgang Denk HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-51 Fax: (+49)-8142-66989-80 Email: [email protected]
PATCH v2 2/5 arm: mvebu: a37xx: Enable fuse command on all Armada 3720 boards
In reply to Pali RohárAllow to read OTP bits via U-Boot fuse command on all Armada 3720 boards.
--- configs/mvebu_db-88f3720_defconfig | 2 ++ configs/mvebu_espressobin-88f3720_defconfig | 2 ++ configs/turris_mox_defconfig | 2 ++ configs/uDPU_defconfig | 2 ++ 4 files changed, 8 insertions(+)
configs/mvebu_db-88f3720_defconfig +2 -0
@@ -5,6 +5,7 @@ CONFIG_SYS_TEXT_BASE=0x00000000 CONFIG_SYS_MALLOC_F_LEN=0x2000 CONFIG_NR_DRAM_BANKS=1 CONFIG_TARGET_MVEBU_ARMADA_37XX=y +CONFIG_MVEBU_EFUSE=y CONFIG_ENV_SIZE=0x10000 CONFIG_ENV_OFFSET=0x3f0000 CONFIG_ENV_SECT_SIZE=0x10000
@@ -24,6 +25,7 @@ CONFIG_DISPLAY_BOARDINFO_LATE=y CONFIG_ARCH_EARLY_INIT_R=y CONFIG_BOARD_EARLY_INIT_F=y # CONFIG_CMD_FLASH is not set +CONFIG_CMD_FUSE=y CONFIG_CMD_GPIO=y CONFIG_CMD_I2C=y CONFIG_CMD_MMC=y
configs/mvebu_espressobin-88f3720_defconfig +2 -0
@@ -5,6 +5,7 @@ CONFIG_SYS_TEXT_BASE=0x00000000 CONFIG_SYS_MALLOC_F_LEN=0x2000 CONFIG_NR_DRAM_BANKS=1 CONFIG_TARGET_MVEBU_ARMADA_37XX=y +CONFIG_MVEBU_EFUSE=y CONFIG_ENV_SIZE=0x10000 CONFIG_ENV_OFFSET=0x3F0000 CONFIG_ENV_SECT_SIZE=0x10000
@@ -26,6 +27,7 @@ CONFIG_ARCH_EARLY_INIT_R=y CONFIG_BOARD_EARLY_INIT_F=y CONFIG_BOARD_LATE_INIT=y # CONFIG_CMD_FLASH is not set +CONFIG_CMD_FUSE=y CONFIG_CMD_GPIO=y CONFIG_CMD_GPT=y CONFIG_CMD_I2C=y
configs/turris_mox_defconfig +2 -0
@@ -5,6 +5,7 @@ CONFIG_SYS_TEXT_BASE=0x00000000 CONFIG_SYS_MALLOC_F_LEN=0x2000 CONFIG_NR_DRAM_BANKS=2 CONFIG_TARGET_TURRIS_MOX=y +CONFIG_MVEBU_EFUSE=y CONFIG_ENV_SIZE=0x10000 CONFIG_ENV_OFFSET=0x180000 CONFIG_ENV_SECT_SIZE=0x10000
@@ -31,6 +32,7 @@ CONFIG_MISC_INIT_R=y CONFIG_CMD_SHA1SUM=y CONFIG_CMD_CLK=y # CONFIG_CMD_FLASH is not set +CONFIG_CMD_FUSE=y CONFIG_CMD_GPIO=y CONFIG_CMD_GPT=y CONFIG_CMD_I2C=y
configs/uDPU_defconfig +2 -0
@@ -4,6 +4,7 @@ CONFIG_ARCH_MVEBU=y CONFIG_SYS_TEXT_BASE=0x00000000 CONFIG_SYS_MALLOC_F_LEN=0x2000 CONFIG_TARGET_MVEBU_ARMADA_37XX=y +CONFIG_MVEBU_EFUSE=y CONFIG_ENV_SIZE=0x10000 CONFIG_ENV_OFFSET=0x180000 CONFIG_ENV_SECT_SIZE=0x10000
@@ -29,6 +30,7 @@ CONFIG_SYS_PROMPT="uDPU>> " # CONFIG_CMD_IMI is not set # CONFIG_CMD_XIMG is not set # CONFIG_CMD_FLASH is not set +CONFIG_CMD_FUSE=y CONFIG_CMD_GPIO=y CONFIG_CMD_I2C=y CONFIG_CMD_MMC=y
Signature · 1 line
2.20.1
Re: [PATCH u-boot-mvebu v2 2/5] arm: mvebu: a37xx: Enable fuse command on all Armada 3720 boards
Quoted 4 lines · Pali Rohár
Allow to read OTP bits via U-Boot fuse command on all Armada 3720 boards.
Signed-off-by Pali Rohár <[email protected]>Reviewed-by Marek Behún <[email protected]>
Thanks,
Stefan
Quoted 80 lines
--- configs/mvebu_db-88f3720_defconfig | 2 ++ configs/mvebu_espressobin-88f3720_defconfig | 2 ++ configs/turris_mox_defconfig | 2 ++ configs/uDPU_defconfig | 2 ++ 4 files changed, 8 insertions(+)configs/mvebu_db-88f3720_defconfig +2
-0@@ -5,6 +5,7 @@ CONFIG_SYS_TEXT_BASE=0x00000000 CONFIG_SYS_MALLOC_F_LEN=0x2000 CONFIG_NR_DRAM_BANKS=1 CONFIG_TARGET_MVEBU_ARMADA_37XX=y +CONFIG_MVEBU_EFUSE=y CONFIG_ENV_SIZE=0x10000 CONFIG_ENV_OFFSET=0x3f0000 CONFIG_ENV_SECT_SIZE=0x10000@@ -24,6 +25,7 @@ CONFIG_DISPLAY_BOARDINFO_LATE=y CONFIG_ARCH_EARLY_INIT_R=y CONFIG_BOARD_EARLY_INIT_F=y # CONFIG_CMD_FLASH is not set +CONFIG_CMD_FUSE=y CONFIG_CMD_GPIO=y CONFIG_CMD_I2C=y CONFIG_CMD_MMC=yconfigs/mvebu_espressobin-88f3720_defconfig +2
-0@@ -5,6 +5,7 @@ CONFIG_SYS_TEXT_BASE=0x00000000 CONFIG_SYS_MALLOC_F_LEN=0x2000 CONFIG_NR_DRAM_BANKS=1 CONFIG_TARGET_MVEBU_ARMADA_37XX=y +CONFIG_MVEBU_EFUSE=y CONFIG_ENV_SIZE=0x10000 CONFIG_ENV_OFFSET=0x3F0000 CONFIG_ENV_SECT_SIZE=0x10000@@ -26,6 +27,7 @@ CONFIG_ARCH_EARLY_INIT_R=y CONFIG_BOARD_EARLY_INIT_F=y CONFIG_BOARD_LATE_INIT=y # CONFIG_CMD_FLASH is not set +CONFIG_CMD_FUSE=y CONFIG_CMD_GPIO=y CONFIG_CMD_GPT=y CONFIG_CMD_I2C=yconfigs/turris_mox_defconfig +2
-0@@ -5,6 +5,7 @@ CONFIG_SYS_TEXT_BASE=0x00000000 CONFIG_SYS_MALLOC_F_LEN=0x2000 CONFIG_NR_DRAM_BANKS=2 CONFIG_TARGET_TURRIS_MOX=y +CONFIG_MVEBU_EFUSE=y CONFIG_ENV_SIZE=0x10000 CONFIG_ENV_OFFSET=0x180000 CONFIG_ENV_SECT_SIZE=0x10000@@ -31,6 +32,7 @@ CONFIG_MISC_INIT_R=y CONFIG_CMD_SHA1SUM=y CONFIG_CMD_CLK=y # CONFIG_CMD_FLASH is not set +CONFIG_CMD_FUSE=y CONFIG_CMD_GPIO=y CONFIG_CMD_GPT=y CONFIG_CMD_I2C=yconfigs/uDPU_defconfig +1
-0@@ -4,6 +4,7 @@ CONFIG_ARCH_MVEBU=y CONFIG_SYS_TEXT_BASE=0x00000000 CONFIG_SYS_MALLOC_F_LEN=0x2000 CONFIG_TARGET_MVEBU_ARMADA_37XX=y +CONFIG_MVEBU_EFUSE=y CONFIG_ENV_SIZE=0x10000 CONFIG_ENV_OFFSET=0x180000 CONFIG_ENV_SECT_SIZE=0x10000
configs/uDPU_defconfig CONFIG_SYS_PROMPT="uDPU>> " · line 36
Quoted 7 lines
configs/uDPU_defconfig +1
-0@@ -29,6 +30,7 @@ CONFIG_SYS_PROMPT="uDPU>> " # CONFIG_CMD_IMI is not set # CONFIG_CMD_XIMG is not set # CONFIG_CMD_FLASH is not set +CONFIG_CMD_FUSE=y CONFIG_CMD_GPIO=y CONFIG_CMD_I2C=y CONFIG_CMD_MMC=y
Viele Grüße,
Stefan Roese
Signature · 3 lines
DENX Software Engineering GmbH, Managing Director: Wolfgang Denk HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-51 Fax: (+49)-8142-66989-80 Email: [email protected]
PATCH v2 3/5 arm: mvebu: a37xx: Move generic mbox code to arch/arm/mach-mvebu
In reply to Pali RohárGeneric A3720 mbox code is currently in Turris Mox specific board file board/CZ.NIC/turris_mox/mox_sp.c. Move it to board independent arch file arch/arm/mach-mvebu/armada3700/mbox.c.
--- arch/arm/mach-mvebu/armada3700/Makefile | 2 +- arch/arm/mach-mvebu/armada3700/mbox.c | 67 ++++++++++++++++++++++++ arch/arm/mach-mvebu/include/mach/mbox.h | 23 +++++++++ board/CZ.NIC/turris_mox/mox_sp.c | 69 +------------------------ 4 files changed, 92 insertions(+), 69 deletions(-) create mode 100644 arch/arm/mach-mvebu/armada3700/mbox.c create mode 100644 arch/arm/mach-mvebu/include/mach/mbox.h
arch/arm/mach-mvebu/armada3700/Makefile +1 -1
@@ -2,5 +2,5 @@ # # Copyright (C) 2016 Stefan Roese <[email protected]> -obj-y = cpu.o +obj-y = cpu.o mbox.o obj-$(CONFIG_MVEBU_EFUSE) += efuse.o
arch/arm/mach-mvebu/armada3700/mbox.c new file +67 -0
67 lines not on this page · raw message
arch/arm/mach-mvebu/include/mach/mbox.h new file +23 -0
@@ -0,0 +1,23 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ +/* +* Copyright (C) 2018 Marek Behun <[email protected]> +*/ + +#ifndef _MVEBU_MBOX_H +#define _MVEBU_MBOX_H + +enum mbox_cmd { +MBOX_CMD_GET_RANDOM =1 , +MBOX_CMD_BOARD_INFO , +MBOX_CMD_ECDSA_PUB_KEY , +MBOX_CMD_HASH , +MBOX_CMD_SIGN , +MBOX_CMD_VERIFY , + +MBOX_CMD_OTP_READ , +MBOX_CMD_OTP_WRITE , +}; + +int mbox_do_cmd (enum mbox_cmd cmd,u32 *in,int nout); + +#endif
board/CZ.NIC/turris_mox/mox_sp.c +1 -68
75 lines not on this page · raw message
Signature · 1 line
2.20.1
Re: [PATCH u-boot-mvebu v2 3/5] arm: mvebu: a37xx: Move generic mbox code to arch/arm/mach-mvebu
Quoted 6 lines · Pali Rohár
Generic A3720 mbox code is currently in Turris Mox specific board file
board/CZ.NIC/turris_mox/mox_sp.c. Move it to board independent arch filearch/arm/mach-mvebu/armada3700/mbox.c.Signed-off-by Pali Rohár <[email protected]>Reviewed-by Marek Behún <[email protected]>
Thanks,
Stefan
Quoted 192 lines
--- arch/arm/mach-mvebu/armada3700/Makefile | 2 +- arch/arm/mach-mvebu/armada3700/mbox.c | 67 ++++++++++++++++++++++++ arch/arm/mach-mvebu/include/mach/mbox.h | 23 +++++++++ board/CZ.NIC/turris_mox/mox_sp.c | 69 +------------------------ 4 files changed, 92 insertions(+), 69 deletions(-)create mode 100644
arch/arm/mach-mvebu/armada3700/mbox.ccreate mode 100644arch/arm/mach-mvebu/include/mach/mbox.harch/arm/mach-mvebu/armada3700/Makefile +1
-1@@ -2,5 +2,5 @@ # # Copyright (C) 2016 Stefan Roese <[email protected]> -obj-y = cpu.o +obj-y = cpu.o mbox.o obj-$(CONFIG_MVEBU_EFUSE) += efuse.oarch/arm/mach-mvebu/armada3700/mbox.c new file +67
-0@@ -0,0 +1,67 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* +* Copyright (C) 2018 Marek Behun <[email protected]> +*/ + +#include <common.h> +#include <asm/arch/soc.h> +#include <asm/io.h> +#include <linux/bitops.h> +#include <linux/delay.h> +#include <mach/mbox.h> + +#define RWTM_BASE (MVEBU_REGISTER(0xb0000)) +#define RWTM_CMD_PARAM (i) (size_t)(RWTM_BASE + (i) * 4) +#define RWTM_CMD (RWTM_BASE + 0x40) +#define RWTM_CMD_RETSTATUS (RWTM_BASE + 0x80) +#define RWTM_CMD_STATUS (i) (size_t)(RWTM_BASE + 0x84 + (i) * 4) + +#define RWTM_HOST_INT_RESET (RWTM_BASE + 0xc8) +#define RWTM_HOST_INT_MASK (RWTM_BASE + 0xcc) +#define SP_CMD_COMPLETE BIT(0) + +#define MBOX_STS_SUCCESS (0x0 << 30) +#define MBOX_STS_FAIL (0x1 << 30) +#define MBOX_STS_BADCMD (0x2 << 30) +#define MBOX_STS_LATER (0x3 << 30) +#define MBOX_STS_ERROR (s) ((s) & (3 << 30)) +#define MBOX_STS_VALUE (s) (((s) >> 10) & 0xfffff) +#define MBOX_STS_CMD (s) ((s) & 0x3ff) + +int mbox_do_cmd (enum mbox_cmd cmd,u32 *out,int nout) +{ +const int tries =50 ; +int i; +u32 status; + +clrbits_le32 (RWTM_HOST_INT_MASK ,SP_CMD_COMPLETE ); + +writel (cmd,RWTM_CMD ); + +for (i =0 ; i < tries; ++i) { +mdelay (10 ); +if (readl (RWTM_HOST_INT_RESET ) &SP_CMD_COMPLETE ) +break ; + } + +if (i == tries) { +/* if timed out, don't read status */ +setbits_le32 (RWTM_HOST_INT_RESET ,SP_CMD_COMPLETE ); +return -ETIMEDOUT ; + } + +for (i =0 ; i < nout; ++i) + out[i] =readl (RWTM_CMD_STATUS (i)); + status =readl (RWTM_CMD_RETSTATUS ); + +setbits_le32 (RWTM_HOST_INT_RESET ,SP_CMD_COMPLETE ); + +if (MBOX_STS_CMD (status) != cmd) +return -EIO ; +else if (MBOX_STS_ERROR (status) ==MBOX_STS_FAIL ) +return -(int )MBOX_STS_VALUE (status); +else if (MBOX_STS_ERROR (status) !=MBOX_STS_SUCCESS ) +return -EIO ; +else +return MBOX_STS_VALUE (status); +}arch/arm/mach-mvebu/include/mach/mbox.h new file +23
-0@@ -0,0 +1,23 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ +/* +* Copyright (C) 2018 Marek Behun <[email protected]> +*/ + +#ifndef _MVEBU_MBOX_H +#define _MVEBU_MBOX_H + +enum mbox_cmd { +MBOX_CMD_GET_RANDOM =1 , +MBOX_CMD_BOARD_INFO , +MBOX_CMD_ECDSA_PUB_KEY , +MBOX_CMD_HASH , +MBOX_CMD_SIGN , +MBOX_CMD_VERIFY , + +MBOX_CMD_OTP_READ , +MBOX_CMD_OTP_WRITE , +}; + +int mbox_do_cmd (enum mbox_cmd cmd,u32 *in,int nout); + +#endif board/CZ.NIC/turris_mox/mox_sp.c +0
-62@@ -8,74 +8,7 @@#include <asm/io.h> #include <linux/bitops.h> #include <linux/delay.h> - -#define RWTM_BASE (MVEBU_REGISTER(0xb0000)) -#define RWTM_CMD_PARAM (i) (size_t)(RWTM_BASE + (i) * 4) -#define RWTM_CMD (RWTM_BASE + 0x40) -#define RWTM_CMD_RETSTATUS (RWTM_BASE + 0x80) -#define RWTM_CMD_STATUS (i) (size_t)(RWTM_BASE + 0x84 + (i) * 4) - -#define RWTM_HOST_INT_RESET (RWTM_BASE + 0xc8) -#define RWTM_HOST_INT_MASK (RWTM_BASE + 0xcc) -#define SP_CMD_COMPLETE BIT(0) - -#define MBOX_STS_SUCCESS (0x0 << 30) -#define MBOX_STS_FAIL (0x1 << 30) -#define MBOX_STS_BADCMD (0x2 << 30) -#define MBOX_STS_LATER (0x3 << 30) -#define MBOX_STS_ERROR (s) ((s) & (3 << 30)) -#define MBOX_STS_VALUE (s) (((s) >> 10) & 0xfffff) -#define MBOX_STS_CMD (s) ((s) & 0x3ff) - -enum mbox_cmd { -MBOX_CMD_GET_RANDOM =1 , -MBOX_CMD_BOARD_INFO , -MBOX_CMD_ECDSA_PUB_KEY , -MBOX_CMD_HASH , -MBOX_CMD_SIGN , -MBOX_CMD_VERIFY , - -MBOX_CMD_OTP_READ , -MBOX_CMD_OTP_WRITE -}; - -static int mbox_do_cmd (enum mbox_cmd cmd,u32 *out,int nout) -{ -const int tries =50 ; -int i; -u32 status; - -clrbits_le32 (RWTM_HOST_INT_MASK ,SP_CMD_COMPLETE ); - -writel (cmd,RWTM_CMD ); - -for (i =0 ; i < tries; ++i) { -mdelay (10 ); -if (readl (RWTM_HOST_INT_RESET ) &SP_CMD_COMPLETE ) -break ; - } - -if (i == tries) { -/* if timed out, don't read status */ -setbits_le32 (RWTM_HOST_INT_RESET ,SP_CMD_COMPLETE ); -return -ETIMEDOUT ; - } - -for (i =0 ; i < nout; ++i) - out[i] =readl (RWTM_CMD_STATUS (i)); - status =readl (RWTM_CMD_RETSTATUS ); - -setbits_le32 (RWTM_HOST_INT_RESET ,SP_CMD_COMPLETE ); - -if (MBOX_STS_CMD (status) != cmd) -return -EIO ; -else if (MBOX_STS_ERROR (status) ==MBOX_STS_FAIL )
board/CZ.NIC/turris_mox/mox_sp.c line 14
Quoted 10 lines
board/CZ.NIC/turris_mox/mox_sp.c +1
-6-return -(int )MBOX_STS_VALUE (status); - else if (MBOX_STS_ERROR(status) != MBOX_STS_SUCCESS) - return -EIO; - else - return MBOX_STS_VALUE(status); -} +#include <mach/mbox.h> const char *mox_sp_get_ecdsa_public_key (void ) {
Viele Grüße,
Stefan Roese
Signature · 3 lines
DENX Software Engineering GmbH, Managing Director: Wolfgang Denk HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-51 Fax: (+49)-8142-66989-80 Email: [email protected]
PATCH v2 4/5 arm: mvebu: a37xx: Extend mbox_do_cmd() code
In reply to Pali RohárAllow to specify input parameters, define all available mbox commands supported by CZ.NIC's secure firmware and also Marvell's fuse.bin firmware and fix parsing response from Marvell OTP commands.
--- arch/arm/mach-mvebu/armada3700/mbox.c | 20 ++++++++++++++++++-- arch/arm/mach-mvebu/include/mach/mbox.h | 19 ++++++++++++++++++- board/CZ.NIC/turris_mox/mox_sp.c | 4 ++-- 3 files changed, 38 insertions(+), 5 deletions(-)
arch/arm/mach-mvebu/armada3700/mbox.c +18 -2
@@ -1,6 +1,7 @@// SPDX-License-Identifier: GPL-2.0+ /* * Copyright (C) 2018 Marek Behun <[email protected]> +* Copyright (C) 2021 Pali Rohár <[email protected]> */ #include <common.h>
@@ -15,6 +16,7 @@#define RWTM_CMD (RWTM_BASE + 0x40)#define RWTM_CMD_RETSTATUS (RWTM_BASE + 0x80)#define RWTM_CMD_STATUS (i) (size_t)(RWTM_BASE + 0x84 + (i) * 4) +#define MAX_ARGS 16#define RWTM_HOST_INT_RESET (RWTM_BASE + 0xc8)#define RWTM_HOST_INT_MASK (RWTM_BASE + 0xcc)
@@ -27,15 +29,27 @@#define MBOX_STS_ERROR (s) ((s) & (3 << 30))#define MBOX_STS_VALUE (s) (((s) >> 10) & 0xfffff)#define MBOX_STS_CMD (s) ((s) & 0x3ff) +#define MBOX_STS_MARVELL_ERROR (s) ((s) == 0 ? 0 : \ + (s) == 2 ? ETIMEDOUT : \ + (s) == 3 ? EINVAL : \ + (s) == 4 ? ENOSYS : \ + EIO) -int mbox_do_cmd (enum mbox_cmd cmd,u32 *out,int nout) +int mbox_do_cmd (enum mbox_cmd cmd,u32 *in,int nin,u32 *out,int nout) {const int tries =50 ;int i;u32 status; +if (nin >MAX_ARGS || nout >MAX_ARGS ) +return -EINVAL ; +clrbits_le32 (RWTM_HOST_INT_MASK ,SP_CMD_COMPLETE ); +for (i =0 ; i < nin; i++) +writel (in[i],RWTM_CMD_PARAM (i)); +for (; i <MAX_ARGS ; i++) +writel (0x0 ,RWTM_CMD_PARAM (i));writel (cmd,RWTM_CMD );for (i =0 ; i < tries; ++i) {
@@ -57,9 +71,11 @@ int mbox_do_cmd(enum mbox_cmd cmd, u32 *out, int nout)setbits_le32 (RWTM_HOST_INT_RESET ,SP_CMD_COMPLETE );if (MBOX_STS_CMD (status) != cmd) -return -EIO ; +return -MBOX_STS_MARVELL_ERROR (status);else if (MBOX_STS_ERROR (status) ==MBOX_STS_FAIL )return -(int )MBOX_STS_VALUE (status); +else if (MBOX_STS_ERROR (status) ==MBOX_STS_BADCMD ) +return -ENOSYS ;else if (MBOX_STS_ERROR (status) !=MBOX_STS_SUCCESS )return -EIO ;else
arch/arm/mach-mvebu/include/mach/mbox.h +18 -1
@@ -1,6 +1,7 @@/* SPDX-License-Identifier: GPL-2.0+ */ /* * Copyright (C) 2018 Marek Behun <[email protected]> +* Copyright (C) 2021 Pali Rohár <[email protected]> */ #ifndef _MVEBU_MBOX_H
@@ -16,8 +17,24 @@ enum mbox_cmd {MBOX_CMD_OTP_READ ,MBOX_CMD_OTP_WRITE , + +MBOX_CMD_REBOOT , + +/* OTP read commands supported by Marvell fuse.bin firmware */ +MBOX_CMD_OTP_READ_1B =257 , +MBOX_CMD_OTP_READ_8B , +MBOX_CMD_OTP_READ_32B , +MBOX_CMD_OTP_READ_64B , +MBOX_CMD_OTP_READ_256B , + +/* OTP write commands supported by Marvell fuse.bin firmware */ +MBOX_CMD_OTP_WRITE_1B =513 , +MBOX_CMD_OTP_WRITE_8B , +MBOX_CMD_OTP_WRITE_32B , +MBOX_CMD_OTP_WRITE_64B , + MBOX_CMD_OTP_WRITE_256B, }; -int mbox_do_cmd (enum mbox_cmd cmd,u32 *in,int nout); +int mbox_do_cmd (enum mbox_cmd cmd,u32 *in,int nin,u32 *out,int nout);#endif
board/CZ.NIC/turris_mox/mox_sp.c +2 -2
@@ -19,7 +19,7 @@ const char *mox_sp_get_ecdsa_public_key(void)if (public_key[0 ])return public_key; - res =mbox_do_cmd (MBOX_CMD_ECDSA_PUB_KEY , out,16 ); + res =mbox_do_cmd (MBOX_CMD_ECDSA_PUB_KEY ,NULL ,0 , out,16 );if (res <0 )return NULL ;
@@ -47,7 +47,7 @@ int mbox_sp_get_board_info(u64 *sn, u8 *mac1, u8 *mac2, int *bv, int *ram)u32 out[8 ];int res; - res =mbox_do_cmd (MBOX_CMD_BOARD_INFO , out,8 ); + res =mbox_do_cmd (MBOX_CMD_BOARD_INFO ,NULL ,0 , out,8 );if (res <0 )return res;
Signature · 1 line
2.20.1
Re: [PATCH u-boot-mvebu v2 4/5] arm: mvebu: a37xx: Extend mbox_do_cmd() code
Quoted 6 lines · Pali Rohár
Allow to specify input parameters, define all available mbox commands supported by CZ.NIC's secure firmware and also Marvell's fuse.bin firmware and fix parsing response from Marvell OTP commands.
Signed-off-by Pali Rohár <[email protected]>Reviewed-by Marek Behún <[email protected]>
Thanks,
Stefan
Quoted 120 lines
--- arch/arm/mach-mvebu/armada3700/mbox.c | 20 ++++++++++++++++++-- arch/arm/mach-mvebu/include/mach/mbox.h | 19 ++++++++++++++++++- board/CZ.NIC/turris_mox/mox_sp.c | 4 ++-- 3 files changed, 38 insertions(+), 5 deletions(-)arch/arm/mach-mvebu/armada3700/mbox.c +18
-2@@ -1,6 +1,7 @@// SPDX-License-Identifier: GPL-2.0+ /* * Copyright (C) 2018 Marek Behun <[email protected]> +* Copyright (C) 2021 Pali Rohár <[email protected]> */ #include <common.h> @@ -15,6 +16,7 @@#define RWTM_CMD (RWTM_BASE + 0x40)#define RWTM_CMD_RETSTATUS (RWTM_BASE + 0x80)#define RWTM_CMD_STATUS (i) (size_t)(RWTM_BASE + 0x84 + (i) * 4) +#define MAX_ARGS 16#define RWTM_HOST_INT_RESET (RWTM_BASE + 0xc8)#define RWTM_HOST_INT_MASK (RWTM_BASE + 0xcc)@@ -27,15 +29,27 @@#define MBOX_STS_ERROR (s) ((s) & (3 << 30))#define MBOX_STS_VALUE (s) (((s) >> 10) & 0xfffff)#define MBOX_STS_CMD (s) ((s) & 0x3ff) +#define MBOX_STS_MARVELL_ERROR (s) ((s) == 0 ? 0 : \ + (s) == 2 ? ETIMEDOUT : \ + (s) == 3 ? EINVAL : \ + (s) == 4 ? ENOSYS : \ + EIO) -int mbox_do_cmd (enum mbox_cmd cmd,u32 *out,int nout) +int mbox_do_cmd (enum mbox_cmd cmd,u32 *in,int nin,u32 *out,int nout) {const int tries =50 ;int i;u32 status; +if (nin >MAX_ARGS || nout >MAX_ARGS ) +return -EINVAL ; +clrbits_le32 (RWTM_HOST_INT_MASK ,SP_CMD_COMPLETE ); +for (i =0 ; i < nin; i++) +writel (in[i],RWTM_CMD_PARAM (i)); +for (; i <MAX_ARGS ; i++) +writel (0x0 ,RWTM_CMD_PARAM (i));writel (cmd,RWTM_CMD );for (i =0 ; i < tries; ++i) {@@ -57,9 +71,11 @@ int mbox_do_cmd(enum mbox_cmd cmd, u32 *out, int nout)setbits_le32 (RWTM_HOST_INT_RESET ,SP_CMD_COMPLETE );if (MBOX_STS_CMD (status) != cmd) -return -EIO ; +return -MBOX_STS_MARVELL_ERROR (status);else if (MBOX_STS_ERROR (status) ==MBOX_STS_FAIL )return -(int )MBOX_STS_VALUE (status); +else if (MBOX_STS_ERROR (status) ==MBOX_STS_BADCMD ) +return -ENOSYS ;else if (MBOX_STS_ERROR (status) !=MBOX_STS_SUCCESS )return -EIO ;else arch/arm/mach-mvebu/include/mach/mbox.h +18
-1@@ -1,6 +1,7 @@/* SPDX-License-Identifier: GPL-2.0+ */ /* * Copyright (C) 2018 Marek Behun <[email protected]> +* Copyright (C) 2021 Pali Rohár <[email protected]> */ #ifndef _MVEBU_MBOX_H@@ -16,8 +17,24 @@ enum mbox_cmd {MBOX_CMD_OTP_READ ,MBOX_CMD_OTP_WRITE , + +MBOX_CMD_REBOOT , + +/* OTP read commands supported by Marvell fuse.bin firmware */ +MBOX_CMD_OTP_READ_1B =257 , +MBOX_CMD_OTP_READ_8B , +MBOX_CMD_OTP_READ_32B , +MBOX_CMD_OTP_READ_64B , +MBOX_CMD_OTP_READ_256B , + +/* OTP write commands supported by Marvell fuse.bin firmware */ +MBOX_CMD_OTP_WRITE_1B =513 , +MBOX_CMD_OTP_WRITE_8B , +MBOX_CMD_OTP_WRITE_32B , +MBOX_CMD_OTP_WRITE_64B , + MBOX_CMD_OTP_WRITE_256B, }; -int mbox_do_cmd (enum mbox_cmd cmd,u32 *in,int nout); +int mbox_do_cmd (enum mbox_cmd cmd,u32 *in,int nin,u32 *out,int nout);#endif board/CZ.NIC/turris_mox/mox_sp.c +1
-1@@ -19,7 +19,7 @@ const char *mox_sp_get_ecdsa_public_key(void)if (public_key[0 ])return public_key; - res =mbox_do_cmd (MBOX_CMD_ECDSA_PUB_KEY , out,16 ); + res =mbox_do_cmd (MBOX_CMD_ECDSA_PUB_KEY ,NULL ,0 , out,16 );if (res <0 )return NULL ;
board/CZ.NIC/turris_mox/mox_sp.c int mbox_sp_get_board_info(u64 *sn, u8 *mac1, u8 *mac2, int *bv, int *ram) · line 53
Quoted 8 lines
board/CZ.NIC/turris_mox/mox_sp.c +1
-1@@ -47,7 +47,7 @@ int mbox_sp_get_board_info(u64 *sn, u8 *mac1, u8 *mac2, int *bv, int *ram)u32 out[8 ];int res; - res =mbox_do_cmd (MBOX_CMD_BOARD_INFO , out,8 ); + res =mbox_do_cmd (MBOX_CMD_BOARD_INFO ,NULL ,0 , out,8 );if (res <0 )return res;
Viele Grüße,
Stefan Roese
Signature · 3 lines
DENX Software Engineering GmbH, Managing Director: Wolfgang Denk HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-51 Fax: (+49)-8142-66989-80 Email: [email protected]
PATCH v2 5/5 arm: mvebu: a37xx: Add support for reading Security OTP values
In reply to Pali RohárIt is not possible for the A53 core (on which U-Boot is running) to read it directly. For this purpose Marvell defined mbox API for sending OTP commands between CM3 and A53 cores.
Implement these Marvell fuse reading mbox commands via U-Boot fuse API.
Banks 0-43 are used for accessing Security OTP (44 rows with 67 bits via 44 banks and words 0-2).
Note that of the 67 bits, the 3 upper bits are: 1 lock bit and 2 auxiliary bits (meant for testing during the manufacture of the SOC, as I understand it).
Also note that the lock bit and the auxiliary bits are not readable via Marvell commands.
With CZ.NIC's commands the lock bit is readable.
Write support is not implemented yet.
--- arch/arm/mach-mvebu/armada3700/efuse.c | 38 ++++++++++++++++++++++++-- 1 file changed, 36 insertions(+), 2 deletions(-)
arch/arm/mach-mvebu/armada3700/efuse.c +36 -2
@@ -8,6 +8,7 @@#include <common.h> #include <asm/io.h> #include <linux/delay.h> +#include <mach/mbox.h> #include <mach/soc.h> #define OTP_NB_REG_BASE ((void __iomem *)MVEBU_REGISTER(0x12600))
@@ -77,6 +78,40 @@ static void otp_read_parallel(void __iomem *base, u32 *data, u32 count) } } +static int rwtm_otp_read (u8 row,u32 word,u32 *data) +{ +u32 out[3 ]; +u32 in[2 ]; +int res = -EINVAL ; + +if (word <2 ) { +/* +* MBOX_CMD_OTP_READ_32B command is supported by Marvell +* fuse.bin firmware and also by new CZ.NIC wtmi firmware. +* This command returns raw bits without ECC corrections. +* It does not provide access to the lock bit. +*/ + in[0 ] = row; + in[1 ] = word *32 ; + res =mbox_do_cmd (MBOX_CMD_OTP_READ_32B , in,2 , out,2 ); +if (!res) + *data = out[0 ]; + }else if (word ==2 ) { +/* +* MBOX_CMD_OTP_READ command is supported only by CZ.NIC wtmi +* firmware and provide access to all bits, including lock bit. +* But this command does ECC correction of returned bits. So +* use it only for accessing lock bit. +*/ + in[0 ] = row; + res =mbox_do_cmd (MBOX_CMD_OTP_READ , in,1 , out,3 ); +if (!res) + *data = out[2 ]; + } + +return res; +} +/* * Banks 0-43 are used for accessing Security OTP (44 rows with 67 bits via 44 banks and words 0-2) * Bank 44 is used for accessing North Bridge OTP (69 bits via words 0-2)
@@ -96,8 +131,7 @@ int fuse_read(u32 bank, u32 word, u32 *val)if (bank <=RWTM_MAX_BANK ) {if (word >=RWTM_ROW_WORDS )return -EINVAL ; -/* TODO: not implemented yet */ -return -ENOSYS ; +return rwtm_otp_read (bank, word, val); }else if (bank ==OTP_NB_BANK ) {u32 data[OTP_NB_WORDS ];if (word >=OTP_NB_WORDS )
Signature · 1 line
2.20.1
Re: [PATCH u-boot-mvebu v2 5/5] arm: mvebu: a37xx: Add support for reading Security OTP values
Quoted 53 lines · On Thu, 17 Feb 2022 19:50:46 +0100 Pali Rohár <[email protected]> wrote:
It is not possible for the A53 core (on which U-Boot is running) to read it directly. For this purpose Marvell defined mbox API for sending OTP commands between CM3 and A53 cores.
Implement these Marvell fuse reading mbox commands via U-Boot fuse API.
Banks 0-43 are used for accessing Security OTP (44 rows with 67 bits via 44 banks and words 0-2).
Note that of the 67 bits, the 3 upper bits are: 1 lock bit and 2 auxiliary bits (meant for testing during the manufacture of the SOC, as I understand it).
Also note that the lock bit and the auxiliary bits are not readable via Marvell commands.
With CZ.NIC's commands the lock bit is readable.
Write support is not implemented yet.
Signed-off-by Pali Rohár <[email protected]>--- arch/arm/mach-mvebu/armada3700/efuse.c | 38 ++++++++++++++++++++++++-- 1 file changed, 36 insertions(+), 2 deletions(-)arch/arm/mach-mvebu/armada3700/efuse.c +13
-0@@ -8,6 +8,7 @@#include <common.h> #include <asm/io.h> #include <linux/delay.h> +#include <mach/mbox.h> #include <mach/soc.h> #define OTP_NB_REG_BASE ((void __iomem *)MVEBU_REGISTER(0x12600))@@ -77,6 +78,40 @@ static void otp_read_parallel(void __iomem *base, u32 *data, u32 count) } } +static int rwtm_otp_read (u8 row,u32 word,u32 *data) +{ +u32 out[3 ]; +u32 in[2 ]; +int res = -EINVAL ; + +if (word <2 ) { +/* +* MBOX_CMD_OTP_READ_32B command is supported by Marvell +* fuse.bin firmware and also by new CZ.NIC wtmi firmware. +* This command returns raw bits without ECC corrections. +* It does not provide access to the lock bit.
arch/arm/mach-mvebu/armada3700/efuse.c static void otp_read_parallel(void __iomem *base, u32 *data, u32 count) · line 102
Quoted 10 lines
arch/arm/mach-mvebu/armada3700/efuse.c +10
-0+*/ + in[0 ] = row; + in[1 ] = word *32 ; + res =mbox_do_cmd (MBOX_CMD_OTP_READ_32B , in,2 , out,2 ); +if (!res) + *data = out[0 ]; + }else if (word ==2 ) { +/* +* MBOX_CMD_OTP_READ command is supported only by CZ.NIC wtmi +* firmware and provide
nitpick: *provides
Re: [PATCH u-boot-mvebu v2 5/5] arm: mvebu: a37xx: Add support for reading Security OTP values
In reply to Pali RohárQuoted 13 lines · Pali Rohár
It is not possible for the A53 core (on which U-Boot is running) to read it directly. For this purpose Marvell defined mbox API for sending OTP commands between CM3 and A53 cores.
Implement these Marvell fuse reading mbox commands via U-Boot fuse API.
Banks 0-43 are used for accessing Security OTP (44 rows with 67 bits via 44 banks and words 0-2).
Note that of the 67 bits, the 3 upper bits are: 1 lock bit and 2 auxiliary bits (meant for testing during the manufacture of the SOC, as I understand it).
Quoted 8 lines
Also note that the lock bit and the auxiliary bits are not readable via Marvell commands.
With CZ.NIC's commands the lock bit is readable.
Write support is not implemented yet.
Signed-off-by Pali Rohár <[email protected]>
Thanks,
Stefan
Quoted 58 lines
--- arch/arm/mach-mvebu/armada3700/efuse.c | 38 ++++++++++++++++++++++++-- 1 file changed, 36 insertions(+), 2 deletions(-)arch/arm/mach-mvebu/armada3700/efuse.c +35
-0@@ -8,6 +8,7 @@#include <common.h> #include <asm/io.h> #include <linux/delay.h> +#include <mach/mbox.h> #include <mach/soc.h> #define OTP_NB_REG_BASE ((void __iomem *)MVEBU_REGISTER(0x12600))@@ -77,6 +78,40 @@ static void otp_read_parallel(void __iomem *base, u32 *data, u32 count) } } +static int rwtm_otp_read (u8 row,u32 word,u32 *data) +{ +u32 out[3 ]; +u32 in[2 ]; +int res = -EINVAL ; + +if (word <2 ) { +/* +* MBOX_CMD_OTP_READ_32B command is supported by Marvell +* fuse.bin firmware and also by new CZ.NIC wtmi firmware. +* This command returns raw bits without ECC corrections. +* It does not provide access to the lock bit. +*/ + in[0 ] = row; + in[1 ] = word *32 ; + res =mbox_do_cmd (MBOX_CMD_OTP_READ_32B , in,2 , out,2 ); +if (!res) + *data = out[0 ]; + }else if (word ==2 ) { +/* +* MBOX_CMD_OTP_READ command is supported only by CZ.NIC wtmi +* firmware and provide access to all bits, including lock bit. +* But this command does ECC correction of returned bits. So +* use it only for accessing lock bit. +*/ + in[0 ] = row; + res =mbox_do_cmd (MBOX_CMD_OTP_READ , in,1 , out,3 ); +if (!res) + *data = out[2 ]; + } + +return res; +} +/* * Banks 0-43 are used for accessing Security OTP (44 rows with 67 bits via 44 banks and words 0-2) * Bank 44 is used for accessing North Bridge OTP (69 bits via words 0-2)
arch/arm/mach-mvebu/armada3700/efuse.c int fuse_read(u32 bank, u32 word, u32 *val) · line 137
Quoted 9 lines
arch/arm/mach-mvebu/armada3700/efuse.c +1
-2@@ -96,8 +131,7 @@ int fuse_read(u32 bank, u32 word, u32 *val)if (bank <=RWTM_MAX_BANK ) {if (word >=RWTM_ROW_WORDS )return -EINVAL ; -/* TODO: not implemented yet */ -return -ENOSYS ; +return rwtm_otp_read (bank, word, val); }else if (bank ==OTP_NB_BANK ) {u32 data[OTP_NB_WORDS ];if (word >=OTP_NB_WORDS )
Viele Grüße,
Stefan Roese
Signature · 3 lines
DENX Software Engineering GmbH, Managing Director: Wolfgang Denk HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-51 Fax: (+49)-8142-66989-80 Email: [email protected]
Re: [PATCH u-boot-mvebu v2 5/5] arm: mvebu: a37xx: Add support for reading Security OTP values
In reply to Pali RohárQuoted 55 lines · On Thursday 17 February 2022 19:50:46 Pali Rohár wrote:
It is not possible for the A53 core (on which U-Boot is running) to read it directly. For this purpose Marvell defined mbox API for sending OTP commands between CM3 and A53 cores.
Implement these Marvell fuse reading mbox commands via U-Boot fuse API.
Banks 0-43 are used for accessing Security OTP (44 rows with 67 bits via 44 banks and words 0-2).
Note that of the 67 bits, the 3 upper bits are: 1 lock bit and 2 auxiliary bits (meant for testing during the manufacture of the SOC, as I understand it).
Also note that the lock bit and the auxiliary bits are not readable via Marvell commands.
With CZ.NIC's commands the lock bit is readable.
Write support is not implemented yet.
Signed-off-by Pali Rohár <[email protected]>--- arch/arm/mach-mvebu/armada3700/efuse.c | 38 ++++++++++++++++++++++++-- 1 file changed, 36 insertions(+), 2 deletions(-)arch/arm/mach-mvebu/armada3700/efuse.c +15
-0@@ -8,6 +8,7 @@#include <common.h> #include <asm/io.h> #include <linux/delay.h> +#include <mach/mbox.h> #include <mach/soc.h> #define OTP_NB_REG_BASE ((void __iomem *)MVEBU_REGISTER(0x12600))@@ -77,6 +78,40 @@ static void otp_read_parallel(void __iomem *base, u32 *data, u32 count) } } +static int rwtm_otp_read (u8 row,u32 word,u32 *data) +{ +u32 out[3 ]; +u32 in[2 ]; +int res = -EINVAL ; + +if (word <2 ) { +/* +* MBOX_CMD_OTP_READ_32B command is supported by Marvell +* fuse.bin firmware and also by new CZ.NIC wtmi firmware. +* This command returns raw bits without ECC corrections. +* It does not provide access to the lock bit. +*/ + in[0 ] = row;
arch/arm/mach-mvebu/armada3700/efuse.c static void otp_read_parallel(void __iomem *base, u32 *data, u32 count) · line 104
Quoted 10 lines
arch/arm/mach-mvebu/armada3700/efuse.c +10
-0+ in[1 ] = word *32 ; + res =mbox_do_cmd (MBOX_CMD_OTP_READ_32B , in,2 , out,2 ); +if (!res) + *data = out[0 ]; + }else if (word ==2 ) { +/* +* MBOX_CMD_OTP_READ command is supported only by CZ.NIC wtmi +* firmware and provide access to all bits, including lock bit. +* But this command does ECC correction of returned bits. So +* use it only for accessing lock bit.
MBOX_CMD_OTP_READ (like MBOX_CMD_OTP_READ_32B) does not do ECC correction, I have verified it. So above comment is not correct.
Quoted 26 lines
arch/arm/mach-mvebu/armada3700/efuse.c +11
-2+*/ + in[0 ] = row; + res =mbox_do_cmd (MBOX_CMD_OTP_READ , in,1 , out,3 ); +if (!res) + *data = out[2 ]; + } + +return res; +} +/* * Banks 0-43 are used for accessing Security OTP (44 rows with 67 bits via 44 banks and words 0-2) * Bank 44 is used for accessing North Bridge OTP (69 bits via words 0-2) @@ -96,8 +131,7 @@ int fuse_read(u32 bank, u32 word, u32 *val)if (bank <=RWTM_MAX_BANK ) {if (word >=RWTM_ROW_WORDS )return -EINVAL ; -/* TODO: not implemented yet */ -return -ENOSYS ; +return rwtm_otp_read (bank, word, val); }else if (bank ==OTP_NB_BANK ) {u32 data[OTP_NB_WORDS ];if (word >=OTP_NB_WORDS )Signature · 1 line
2.20.1
v3 cover arm: mvebu: a37xx: Add support for reading OTP
In reply to Pali RohárAdd support for reading NB fuse OTP, SB fuse OTP and Security OTP values via U-Boot fuse API on Armada 37xx boards.
Changes in v3:
* Updated comment in patch 5/5 about MBOX_CMD_OTP_READ command
* In patch 5/5 fixed number of output arguments for MBOX_CMD_OTP_READ_32B command
Pali Rohár (5):
arm: mvebu: a37xx: Add support for reading NB and SB fuse OTP value
arm: mvebu: a37xx: Enable fuse command on all Armada 3720 boards
arm: mvebu: a37xx: Move generic mbox code to arch/arm/mach-mvebu
arm: mvebu: a37xx: Extend mbox_do_cmd() code
arm: mvebu: a37xx: Add support for reading Security OTP values
arch/arm/mach-mvebu/Kconfig | 1 + arch/arm/mach-mvebu/Makefile | 3 + arch/arm/mach-mvebu/armada3700/Makefile | 3 +- arch/arm/mach-mvebu/armada3700/efuse.c | 171 ++++++++++++++++++++ arch/arm/mach-mvebu/armada3700/mbox.c | 83 ++++++++++ arch/arm/mach-mvebu/include/mach/mbox.h | 40 +++++ board/CZ.NIC/turris_mox/mox_sp.c | 73 +-------- configs/mvebu_db-88f3720_defconfig | 2 + configs/mvebu_espressobin-88f3720_defconfig | 2 + configs/turris_mox_defconfig | 2 + configs/uDPU_defconfig | 2 + 11 files changed, 311 insertions(+), 71 deletions(-) create mode 100644 arch/arm/mach-mvebu/armada3700/efuse.c create mode 100644 arch/arm/mach-mvebu/armada3700/mbox.c create mode 100644 arch/arm/mach-mvebu/include/mach/mbox.h
Signature · 1 line
2.20.1
PATCH v3 1/5 arm: mvebu: a37xx: Add support for reading NB and SB fuse OTP value
Implement reading NB and SB fuses of Armada 37xx SOC via U-Boot fuse API.
Banks 0-43 are reserved for accessing Security OTP (not implemented yet). Bank 44 is used for accessing North Bridge OTP (69 bits via words 0-2). Bank 45 is used for accessing South Bridge OTP (97 bits via words 0-3).
Write support is not implemented yet because it looks like that both North and South Bridge OTPs are already burned in factory with some data. The meaning of some bits of North Bridge is documented in WTMI source code. The meaning of bits in South Bridge is unknown.
--- arch/arm/mach-mvebu/Kconfig | 1 + arch/arm/mach-mvebu/Makefile | 3 + arch/arm/mach-mvebu/armada3700/Makefile | 1 + arch/arm/mach-mvebu/armada3700/efuse.c | 136 ++++++++++++++++++++++++ 4 files changed, 141 insertions(+) create mode 100644 arch/arm/mach-mvebu/armada3700/efuse.c
arch/arm/mach-mvebu/Kconfig +1 -0
@@ -44,6 +44,7 @@ config ARMADA_XP config ARMADA_3700 bool select ARM64 + select HAVE_MVEBU_EFUSE # Armada 7K and 8K are very similar - use only one Kconfig symbol for both config ARMADA_8K
arch/arm/mach-mvebu/Makefile +3 -0
@@ -27,7 +27,10 @@ obj-$(CONFIG_ARMADA_375) += ../../../drivers/ddr/marvell/axp/xor.o obj-$(CONFIG_ARMADA_38X) += ../../../drivers/ddr/marvell/a38x/xor.o obj-$(CONFIG_ARMADA_XP) += ../../../drivers/ddr/marvell/axp/xor.o obj-$(CONFIG_ARMADA_MSYS) += ../../../drivers/ddr/marvell/axp/xor.o + +ifdef CONFIG_ARMADA_38X obj-$(CONFIG_MVEBU_EFUSE) += efuse.o +endif extra-y += kwbimage.cfg
arch/arm/mach-mvebu/armada3700/Makefile +1 -0
@@ -3,3 +3,4 @@ # Copyright (C) 2016 Stefan Roese <[email protected]> obj-y = cpu.o +obj-$(CONFIG_MVEBU_EFUSE) += efuse.o
arch/arm/mach-mvebu/armada3700/efuse.c new file +136 -0
136 lines not on this page · raw message
Signature · 1 line
2.20.1
PATCH v3 2/5 arm: mvebu: a37xx: Enable fuse command on all Armada 3720 boards
In reply to Pali RohárAllow to read OTP bits via U-Boot fuse command on all Armada 3720 boards.
--- configs/mvebu_db-88f3720_defconfig | 2 ++ configs/mvebu_espressobin-88f3720_defconfig | 2 ++ configs/turris_mox_defconfig | 2 ++ configs/uDPU_defconfig | 2 ++ 4 files changed, 8 insertions(+)
configs/mvebu_db-88f3720_defconfig +2 -0
@@ -5,6 +5,7 @@ CONFIG_SYS_TEXT_BASE=0x00000000 CONFIG_SYS_MALLOC_F_LEN=0x2000 CONFIG_NR_DRAM_BANKS=1 CONFIG_TARGET_MVEBU_ARMADA_37XX=y +CONFIG_MVEBU_EFUSE=y CONFIG_ENV_SIZE=0x10000 CONFIG_ENV_OFFSET=0x3f0000 CONFIG_ENV_SECT_SIZE=0x10000
@@ -24,6 +25,7 @@ CONFIG_DISPLAY_BOARDINFO_LATE=y CONFIG_ARCH_EARLY_INIT_R=y CONFIG_BOARD_EARLY_INIT_F=y # CONFIG_CMD_FLASH is not set +CONFIG_CMD_FUSE=y CONFIG_CMD_GPIO=y CONFIG_CMD_I2C=y CONFIG_CMD_MMC=y
configs/mvebu_espressobin-88f3720_defconfig +2 -0
@@ -5,6 +5,7 @@ CONFIG_SYS_TEXT_BASE=0x00000000 CONFIG_SYS_MALLOC_F_LEN=0x2000 CONFIG_NR_DRAM_BANKS=1 CONFIG_TARGET_MVEBU_ARMADA_37XX=y +CONFIG_MVEBU_EFUSE=y CONFIG_ENV_SIZE=0x10000 CONFIG_ENV_OFFSET=0x3F0000 CONFIG_ENV_SECT_SIZE=0x10000
@@ -26,6 +27,7 @@ CONFIG_ARCH_EARLY_INIT_R=y CONFIG_BOARD_EARLY_INIT_F=y CONFIG_BOARD_LATE_INIT=y # CONFIG_CMD_FLASH is not set +CONFIG_CMD_FUSE=y CONFIG_CMD_GPIO=y CONFIG_CMD_GPT=y CONFIG_CMD_I2C=y
configs/turris_mox_defconfig +2 -0
@@ -5,6 +5,7 @@ CONFIG_SYS_TEXT_BASE=0x00000000 CONFIG_SYS_MALLOC_F_LEN=0x2000 CONFIG_NR_DRAM_BANKS=2 CONFIG_TARGET_TURRIS_MOX=y +CONFIG_MVEBU_EFUSE=y CONFIG_ENV_SIZE=0x10000 CONFIG_ENV_OFFSET=0x180000 CONFIG_ENV_SECT_SIZE=0x10000
@@ -31,6 +32,7 @@ CONFIG_MISC_INIT_R=y CONFIG_CMD_SHA1SUM=y CONFIG_CMD_CLK=y # CONFIG_CMD_FLASH is not set +CONFIG_CMD_FUSE=y CONFIG_CMD_GPIO=y CONFIG_CMD_GPT=y CONFIG_CMD_I2C=y
configs/uDPU_defconfig +2 -0
@@ -4,6 +4,7 @@ CONFIG_ARCH_MVEBU=y CONFIG_SYS_TEXT_BASE=0x00000000 CONFIG_SYS_MALLOC_F_LEN=0x2000 CONFIG_TARGET_MVEBU_ARMADA_37XX=y +CONFIG_MVEBU_EFUSE=y CONFIG_ENV_SIZE=0x10000 CONFIG_ENV_OFFSET=0x180000 CONFIG_ENV_SECT_SIZE=0x10000
@@ -29,6 +30,7 @@ CONFIG_SYS_PROMPT="uDPU>> " # CONFIG_CMD_IMI is not set # CONFIG_CMD_XIMG is not set # CONFIG_CMD_FLASH is not set +CONFIG_CMD_FUSE=y CONFIG_CMD_GPIO=y CONFIG_CMD_I2C=y CONFIG_CMD_MMC=y
Signature · 1 line
2.20.1
PATCH v3 3/5 arm: mvebu: a37xx: Move generic mbox code to arch/arm/mach-mvebu
In reply to Pali RohárGeneric A3720 mbox code is currently in Turris Mox specific board file board/CZ.NIC/turris_mox/mox_sp.c. Move it to board independent arch file arch/arm/mach-mvebu/armada3700/mbox.c.
--- arch/arm/mach-mvebu/armada3700/Makefile | 2 +- arch/arm/mach-mvebu/armada3700/mbox.c | 67 ++++++++++++++++++++++++ arch/arm/mach-mvebu/include/mach/mbox.h | 23 +++++++++ board/CZ.NIC/turris_mox/mox_sp.c | 69 +------------------------ 4 files changed, 92 insertions(+), 69 deletions(-) create mode 100644 arch/arm/mach-mvebu/armada3700/mbox.c create mode 100644 arch/arm/mach-mvebu/include/mach/mbox.h
arch/arm/mach-mvebu/armada3700/Makefile +1 -1
@@ -2,5 +2,5 @@ # # Copyright (C) 2016 Stefan Roese <[email protected]> -obj-y = cpu.o +obj-y = cpu.o mbox.o obj-$(CONFIG_MVEBU_EFUSE) += efuse.o
arch/arm/mach-mvebu/armada3700/mbox.c new file +67 -0
67 lines not on this page · raw message
arch/arm/mach-mvebu/include/mach/mbox.h new file +23 -0
@@ -0,0 +1,23 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ +/* +* Copyright (C) 2018 Marek Behun <[email protected]> +*/ + +#ifndef _MVEBU_MBOX_H +#define _MVEBU_MBOX_H + +enum mbox_cmd { +MBOX_CMD_GET_RANDOM =1 , +MBOX_CMD_BOARD_INFO , +MBOX_CMD_ECDSA_PUB_KEY , +MBOX_CMD_HASH , +MBOX_CMD_SIGN , +MBOX_CMD_VERIFY , + +MBOX_CMD_OTP_READ , +MBOX_CMD_OTP_WRITE , +}; + +int mbox_do_cmd (enum mbox_cmd cmd,u32 *in,int nout); + +#endif
board/CZ.NIC/turris_mox/mox_sp.c +1 -68
75 lines not on this page · raw message
Signature · 1 line
2.20.1
PATCH v3 4/5 arm: mvebu: a37xx: Extend mbox_do_cmd() code
In reply to Pali RohárAllow to specify input parameters, define all available mbox commands supported by CZ.NIC's secure firmware and also Marvell's fuse.bin firmware and fix parsing response from Marvell OTP commands.
--- arch/arm/mach-mvebu/armada3700/mbox.c | 20 ++++++++++++++++++-- arch/arm/mach-mvebu/include/mach/mbox.h | 19 ++++++++++++++++++- board/CZ.NIC/turris_mox/mox_sp.c | 4 ++-- 3 files changed, 38 insertions(+), 5 deletions(-)
arch/arm/mach-mvebu/armada3700/mbox.c +18 -2
@@ -1,6 +1,7 @@// SPDX-License-Identifier: GPL-2.0+ /* * Copyright (C) 2018 Marek Behun <[email protected]> +* Copyright (C) 2021 Pali Rohár <[email protected]> */ #include <common.h>
@@ -15,6 +16,7 @@#define RWTM_CMD (RWTM_BASE + 0x40)#define RWTM_CMD_RETSTATUS (RWTM_BASE + 0x80)#define RWTM_CMD_STATUS (i) (size_t)(RWTM_BASE + 0x84 + (i) * 4) +#define MAX_ARGS 16#define RWTM_HOST_INT_RESET (RWTM_BASE + 0xc8)#define RWTM_HOST_INT_MASK (RWTM_BASE + 0xcc)
@@ -27,15 +29,27 @@#define MBOX_STS_ERROR (s) ((s) & (3 << 30))#define MBOX_STS_VALUE (s) (((s) >> 10) & 0xfffff)#define MBOX_STS_CMD (s) ((s) & 0x3ff) +#define MBOX_STS_MARVELL_ERROR (s) ((s) == 0 ? 0 : \ + (s) == 2 ? ETIMEDOUT : \ + (s) == 3 ? EINVAL : \ + (s) == 4 ? ENOSYS : \ + EIO) -int mbox_do_cmd (enum mbox_cmd cmd,u32 *out,int nout) +int mbox_do_cmd (enum mbox_cmd cmd,u32 *in,int nin,u32 *out,int nout) {const int tries =50 ;int i;u32 status; +if (nin >MAX_ARGS || nout >MAX_ARGS ) +return -EINVAL ; +clrbits_le32 (RWTM_HOST_INT_MASK ,SP_CMD_COMPLETE ); +for (i =0 ; i < nin; i++) +writel (in[i],RWTM_CMD_PARAM (i)); +for (; i <MAX_ARGS ; i++) +writel (0x0 ,RWTM_CMD_PARAM (i));writel (cmd,RWTM_CMD );for (i =0 ; i < tries; ++i) {
@@ -57,9 +71,11 @@ int mbox_do_cmd(enum mbox_cmd cmd, u32 *out, int nout)setbits_le32 (RWTM_HOST_INT_RESET ,SP_CMD_COMPLETE );if (MBOX_STS_CMD (status) != cmd) -return -EIO ; +return -MBOX_STS_MARVELL_ERROR (status);else if (MBOX_STS_ERROR (status) ==MBOX_STS_FAIL )return -(int )MBOX_STS_VALUE (status); +else if (MBOX_STS_ERROR (status) ==MBOX_STS_BADCMD ) +return -ENOSYS ;else if (MBOX_STS_ERROR (status) !=MBOX_STS_SUCCESS )return -EIO ;else
arch/arm/mach-mvebu/include/mach/mbox.h +18 -1
@@ -1,6 +1,7 @@/* SPDX-License-Identifier: GPL-2.0+ */ /* * Copyright (C) 2018 Marek Behun <[email protected]> +* Copyright (C) 2021 Pali Rohár <[email protected]> */ #ifndef _MVEBU_MBOX_H
@@ -16,8 +17,24 @@ enum mbox_cmd {MBOX_CMD_OTP_READ ,MBOX_CMD_OTP_WRITE , + +MBOX_CMD_REBOOT , + +/* OTP read commands supported by Marvell fuse.bin firmware */ +MBOX_CMD_OTP_READ_1B =257 , +MBOX_CMD_OTP_READ_8B , +MBOX_CMD_OTP_READ_32B , +MBOX_CMD_OTP_READ_64B , +MBOX_CMD_OTP_READ_256B , + +/* OTP write commands supported by Marvell fuse.bin firmware */ +MBOX_CMD_OTP_WRITE_1B =513 , +MBOX_CMD_OTP_WRITE_8B , +MBOX_CMD_OTP_WRITE_32B , +MBOX_CMD_OTP_WRITE_64B , + MBOX_CMD_OTP_WRITE_256B, }; -int mbox_do_cmd (enum mbox_cmd cmd,u32 *in,int nout); +int mbox_do_cmd (enum mbox_cmd cmd,u32 *in,int nin,u32 *out,int nout);#endif
board/CZ.NIC/turris_mox/mox_sp.c +2 -2
@@ -19,7 +19,7 @@ const char *mox_sp_get_ecdsa_public_key(void)if (public_key[0 ])return public_key; - res =mbox_do_cmd (MBOX_CMD_ECDSA_PUB_KEY , out,16 ); + res =mbox_do_cmd (MBOX_CMD_ECDSA_PUB_KEY ,NULL ,0 , out,16 );if (res <0 )return NULL ;
@@ -47,7 +47,7 @@ int mbox_sp_get_board_info(u64 *sn, u8 *mac1, u8 *mac2, int *bv, int *ram)u32 out[8 ];int res; - res =mbox_do_cmd (MBOX_CMD_BOARD_INFO , out,8 ); + res =mbox_do_cmd (MBOX_CMD_BOARD_INFO ,NULL ,0 , out,8 );if (res <0 )return res;
Signature · 1 line
2.20.1
PATCH v3 5/5 arm: mvebu: a37xx: Add support for reading Security OTP values
In reply to Pali RohárIt is not possible for the A53 core (on which U-Boot is running) to read it directly. For this purpose Marvell defined mbox API for sending OTP commands between CM3 and A53 cores.
Implement these Marvell fuse reading mbox commands via U-Boot fuse API.
Banks 0-43 are used for accessing Security OTP (44 rows with 67 bits via 44 banks and words 0-2).
Note that of the 67 bits, the 3 upper bits are: 1 lock bit and 2 auxiliary bits (meant for testing during the manufacture of the SOC, as I understand it).
Also note that the lock bit and the auxiliary bits are not readable via Marvell commands.
With CZ.NIC's commands the lock bit is readable.
Write support is not implemented yet.
--- arch/arm/mach-mvebu/armada3700/efuse.c | 39 ++++++++++++++++++++++++-- 1 file changed, 37 insertions(+), 2 deletions(-)
arch/arm/mach-mvebu/armada3700/efuse.c +37 -2
@@ -8,6 +8,7 @@#include <common.h> #include <asm/io.h> #include <linux/delay.h> +#include <mach/mbox.h> #include <mach/soc.h> #define OTP_NB_REG_BASE ((void __iomem *)MVEBU_REGISTER(0x12600))
@@ -77,6 +78,41 @@ static void otp_read_parallel(void __iomem *base, u32 *data, u32 count) } } +static int rwtm_otp_read (u8 row,u32 word,u32 *data) +{ +u32 out[3 ]; +u32 in[2 ]; +int res = -EINVAL ; + +if (word <2 ) { +/* +* MBOX_CMD_OTP_READ_32B command is supported by Marvell +* fuse.bin firmware and also by new CZ.NIC wtmi firmware. +* This command returns raw bits without ECC corrections. +* It does not provide access to the lock bit. +*/ + in[0 ] = row; + in[1 ] = word *32 ; + res =mbox_do_cmd (MBOX_CMD_OTP_READ_32B , in,2 , out,1 ); +if (!res) + *data = out[0 ]; + }else if (word ==2 ) { +/* +* MBOX_CMD_OTP_READ command is supported only by new CZ.NIC +* wtmi firmware and provides access to all bits, including +* lock bit without doing ECC corrections. For compatibility +* with Marvell fuse.bin firmware, use this command only for +* accessing lock bit. +*/ + in[0 ] = row; + res =mbox_do_cmd (MBOX_CMD_OTP_READ , in,1 , out,3 ); +if (!res) + *data = out[2 ]; + } + +return res; +} +/* * Banks 0-43 are used for accessing Security OTP (44 rows with 67 bits via 44 banks and words 0-2) * Bank 44 is used for accessing North Bridge OTP (69 bits via words 0-2)
@@ -96,8 +132,7 @@ int fuse_read(u32 bank, u32 word, u32 *val)if (bank <=RWTM_MAX_BANK ) {if (word >=RWTM_ROW_WORDS )return -EINVAL ; -/* TODO: not implemented yet */ -return -ENOSYS ; +return rwtm_otp_read (bank, word, val); }else if (bank ==OTP_NB_BANK ) {u32 data[OTP_NB_WORDS ];if (word >=OTP_NB_WORDS )
Signature · 1 line
2.20.1
Hello! Is v3 series Ok now?
Quoted 33 lines · On Wednesday 23 February 2022 14:15:44 Pali Rohár wrote:
Add support for reading NB fuse OTP, SB fuse OTP and Security OTP values via U-Boot fuse API on Armada 37xx boards.
Changes in v3:
* Updated comment in patch 5/5 aboutMBOX_CMD_OTP_READcommand
* In patch 5/5 fixed number of output arguments forMBOX_CMD_OTP_READ_32BcommandPali Rohár (5):
arm: mvebu: a37xx: Add support for reading NB and SB fuse OTP value
arm: mvebu: a37xx: Enable fuse command on all Armada 3720 boards
arm: mvebu: a37xx: Move generic mbox code toarch/arm/mach-mvebu
arm: mvebu: a37xx: Extendmbox_do_cmd()code
arm: mvebu: a37xx: Add support for reading Security OTP valuesarch/arm/mach-mvebu/Kconfig | 1 + arch/arm/mach-mvebu/Makefile | 3 + arch/arm/mach-mvebu/armada3700/Makefile | 3 +- arch/arm/mach-mvebu/armada3700/efuse.c | 171 ++++++++++++++++++++ arch/arm/mach-mvebu/armada3700/mbox.c | 83 ++++++++++ arch/arm/mach-mvebu/include/mach/mbox.h | 40 +++++ board/CZ.NIC/turris_mox/mox_sp.c | 73 +-------- configs/mvebu_db-88f3720_defconfig | 2 + configs/mvebu_espressobin-88f3720_defconfig | 2 + configs/turris_mox_defconfig | 2 + configs/uDPU_defconfig | 2 + 11 files changed, 311 insertions(+), 71 deletions(-) create mode 100644 arch/arm/mach-mvebu/armada3700/efuse.c create mode 100644 arch/arm/mach-mvebu/armada3700/mbox.c create mode 100644 arch/arm/mach-mvebu/include/mach/mbox.hSignature · 1 line
2.20.1
Quoted 1 line · Pali Rohár
Hello! Is v3 series Ok now?
I don't have any objections. I plan to pull this patch series in the next merge window, as we are at rc3 now already.
Thanks,
Stefan
Quoted 31 lines · On Wednesday 23 February 2022 14:15:44 Pali Rohár wrote:
Quoted 30 lines
Add support for reading NB fuse OTP, SB fuse OTP and Security OTP values via U-Boot fuse API on Armada 37xx boards.
Changes in v3:
* Updated comment in patch 5/5 aboutMBOX_CMD_OTP_READcommand
* In patch 5/5 fixed number of output arguments forMBOX_CMD_OTP_READ_32BcommandPali Rohár (5):
arm: mvebu: a37xx: Add support for reading NB and SB fuse OTP value
arm: mvebu: a37xx: Enable fuse command on all Armada 3720 boards
arm: mvebu: a37xx: Move generic mbox code toarch/arm/mach-mvebu
arm: mvebu: a37xx: Extendmbox_do_cmd()code
arm: mvebu: a37xx: Add support for reading Security OTP valuesarch/arm/mach-mvebu/Kconfig | 1 + arch/arm/mach-mvebu/Makefile | 3 + arch/arm/mach-mvebu/armada3700/Makefile | 3 +- arch/arm/mach-mvebu/armada3700/efuse.c | 171 ++++++++++++++++++++ arch/arm/mach-mvebu/armada3700/mbox.c | 83 ++++++++++ arch/arm/mach-mvebu/include/mach/mbox.h | 40 +++++ board/CZ.NIC/turris_mox/mox_sp.c | 73 +-------- configs/mvebu_db-88f3720_defconfig | 2 + configs/mvebu_espressobin-88f3720_defconfig | 2 + configs/turris_mox_defconfig | 2 + configs/uDPU_defconfig | 2 + 11 files changed, 311 insertions(+), 71 deletions(-)create mode 100644
arch/arm/mach-mvebu/armada3700/efuse.ccreate mode 100644arch/arm/mach-mvebu/armada3700/mbox.ccreate mode 100644arch/arm/mach-mvebu/include/mach/mbox.h
Quoted 3 lines
Quoted 3 lines
Signature · 1 line
2.20.1
Viele Grüße,
Stefan Roese
Signature · 3 lines
DENX Software Engineering GmbH, Managing Director: Wolfgang Denk HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-51 Fax: (+49)-8142-66989-80 Email: [email protected]
Quoted 5 lines · On Tuesday 08 March 2022 12:57:37 Stefan Roese wrote:
Quoted 1 line · Pali Rohár
Hello! Is v3 series Ok now?
I don't have any objections. I plan to pull this patch series in the next merge window, as we are at rc3 now already.
PING?
Quoted 45 lines
Thanks,
StefanQuoted 31 lines · On Wednesday 23 February 2022 14:15:44 Pali Rohár wrote:
Quoted 30 lines
Add support for reading NB fuse OTP, SB fuse OTP and Security OTP values via U-Boot fuse API on Armada 37xx boards.
Changes in v3:
* Updated comment in patch 5/5 aboutMBOX_CMD_OTP_READcommand
* In patch 5/5 fixed number of output arguments forMBOX_CMD_OTP_READ_32BcommandPali Rohár (5):
arm: mvebu: a37xx: Add support for reading NB and SB fuse OTP value
arm: mvebu: a37xx: Enable fuse command on all Armada 3720 boards
arm: mvebu: a37xx: Move generic mbox code toarch/arm/mach-mvebu
arm: mvebu: a37xx: Extendmbox_do_cmd()code
arm: mvebu: a37xx: Add support for reading Security OTP valuesarch/arm/mach-mvebu/Kconfig | 1 + arch/arm/mach-mvebu/Makefile | 3 + arch/arm/mach-mvebu/armada3700/Makefile | 3 +- arch/arm/mach-mvebu/armada3700/efuse.c | 171 ++++++++++++++++++++ arch/arm/mach-mvebu/armada3700/mbox.c | 83 ++++++++++ arch/arm/mach-mvebu/include/mach/mbox.h | 40 +++++ board/CZ.NIC/turris_mox/mox_sp.c | 73 +-------- configs/mvebu_db-88f3720_defconfig | 2 + configs/mvebu_espressobin-88f3720_defconfig | 2 + configs/turris_mox_defconfig | 2 + configs/uDPU_defconfig | 2 + 11 files changed, 311 insertions(+), 71 deletions(-)create mode 100644
arch/arm/mach-mvebu/armada3700/efuse.ccreate mode 100644arch/arm/mach-mvebu/armada3700/mbox.ccreate mode 100644arch/arm/mach-mvebu/include/mach/mbox.hQuoted 3 lines
Quoted 3 lines
Signature · 1 line
2.20.1Viele Grüße,
Stefan RoeseSignature · 3 lines
DENX Software Engineering GmbH, Managing Director: Wolfgang Denk HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-51 Fax: (+49)-8142-66989-80 Email: [email protected]
Quoted 8 lines · Pali Rohár
Quoted 5 lines · On Tuesday 08 March 2022 12:57:37 Stefan Roese wrote:
Quoted 1 line · Pali Rohár
Hello! Is v3 series Ok now?
I don't have any objections. I plan to pull this patch series in the next merge window, as we are at rc3 now already.
PING?
Yes, I know. Sorry, just back from vacation and business trip. I'll try to handle the patch backlog today and/or tomorrow. ;)
Thanks,
Stefan
Quoted 38 lines
Quoted 38 lines
Thanks,
StefanQuoted 34 lines · On Wednesday 23 February 2022 14:15:44 Pali Rohár wrote:
Quoted 33 lines
Add support for reading NB fuse OTP, SB fuse OTP and Security OTP values via U-Boot fuse API on Armada 37xx boards.
Changes in v3:
* Updated comment in patch 5/5 aboutMBOX_CMD_OTP_READcommand
* In patch 5/5 fixed number of output arguments forMBOX_CMD_OTP_READ_32BcommandPali Rohár (5):
arm: mvebu: a37xx: Add support for reading NB and SB fuse OTP value
arm: mvebu: a37xx: Enable fuse command on all Armada 3720 boards
arm: mvebu: a37xx: Move generic mbox code toarch/arm/mach-mvebu
arm: mvebu: a37xx: Extendmbox_do_cmd()code
arm: mvebu: a37xx: Add support for reading Security OTP valuesarch/arm/mach-mvebu/Kconfig | 1 + arch/arm/mach-mvebu/Makefile | 3 + arch/arm/mach-mvebu/armada3700/Makefile | 3 +- arch/arm/mach-mvebu/armada3700/efuse.c | 171 ++++++++++++++++++++ arch/arm/mach-mvebu/armada3700/mbox.c | 83 ++++++++++ arch/arm/mach-mvebu/include/mach/mbox.h | 40 +++++ board/CZ.NIC/turris_mox/mox_sp.c | 73 +-------- configs/mvebu_db-88f3720_defconfig | 2 + configs/mvebu_espressobin-88f3720_defconfig | 2 + configs/turris_mox_defconfig | 2 + configs/uDPU_defconfig | 2 + 11 files changed, 311 insertions(+), 71 deletions(-)create mode 100644
arch/arm/mach-mvebu/armada3700/efuse.ccreate mode 100644arch/arm/mach-mvebu/armada3700/mbox.ccreate mode 100644arch/arm/mach-mvebu/include/mach/mbox.hSignature · 1 line
2.20.1
Quoted 7 lines
Quoted 7 lines
Viele Grüße,
Stefan RoeseSignature · 3 lines
DENX Software Engineering GmbH, Managing Director: Wolfgang Denk HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-51 Fax: (+49)-8142-66989-80 Email: [email protected]
Viele Grüße,
Stefan Roese
Signature · 3 lines
DENX Software Engineering GmbH, Managing Director: Wolfgang Denk HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-51 Fax: (+49)-8142-66989-80 Email: [email protected]
Quoted 26 lines · Pali Rohár
Add support for reading NB fuse OTP, SB fuse OTP and Security OTP values via U-Boot fuse API on Armada 37xx boards.
Changes in v3:
* Updated comment in patch 5/5 aboutMBOX_CMD_OTP_READcommand
* In patch 5/5 fixed number of output arguments forMBOX_CMD_OTP_READ_32BcommandPali Rohár (5):
arm: mvebu: a37xx: Add support for reading NB and SB fuse OTP value
arm: mvebu: a37xx: Enable fuse command on all Armada 3720 boards
arm: mvebu: a37xx: Move generic mbox code toarch/arm/mach-mvebu
arm: mvebu: a37xx: Extendmbox_do_cmd()code
arm: mvebu: a37xx: Add support for reading Security OTP valuesarch/arm/mach-mvebu/Kconfig | 1 + arch/arm/mach-mvebu/Makefile | 3 + arch/arm/mach-mvebu/armada3700/Makefile | 3 +- arch/arm/mach-mvebu/armada3700/efuse.c | 171 ++++++++++++++++++++ arch/arm/mach-mvebu/armada3700/mbox.c | 83 ++++++++++ arch/arm/mach-mvebu/include/mach/mbox.h | 40 +++++ board/CZ.NIC/turris_mox/mox_sp.c | 73 +-------- configs/mvebu_db-88f3720_defconfig | 2 + configs/mvebu_espressobin-88f3720_defconfig | 2 + configs/turris_mox_defconfig | 2 + configs/uDPU_defconfig | 2 + 11 files changed, 311 insertions(+), 71 deletions(-)
Quoted 4 lines
create mode 100644
arch/arm/mach-mvebu/armada3700/efuse.ccreate mode 100644arch/arm/mach-mvebu/armada3700/mbox.ccreate mode 100644arch/arm/mach-mvebu/include/mach/mbox.h
Applied to u-boot-marvell/master
Thanks,
Stefan