[PATCH u-boot-mvebu 4/5] arm: mvebu: a37xx: Extend mbox_do_cmd() code

Marek Behún marek.behun at nic.cz
Thu Feb 17 15:16:33 CET 2022


On Thu, 17 Feb 2022 10:26:18 +0100
Pali Rohár <pali at kernel.org> 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
> parsing response from Marvell OTP commands.
> 
> Signed-off-by: Pali Rohár <pali at kernel.org>

...

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

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)
{
	...
}

>  
>  #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 */
                                          Marvell's
> +	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


More information about the U-Boot mailing list