All of lore.kernel.org
 help / color / mirror / Atom feed
From: Stefan Roese <sr@denx.de>
To: "Pali Rohár" <pali@kernel.org>, "Marek Behún" <kabel@kernel.org>
Cc: u-boot@lists.denx.de
Subject: Re: [PATCH 1/2] arm: mvebu: turris_omnia: Show MCU type in show_board_info()
Date: Mon, 1 Aug 2022 13:56:41 +0200	[thread overview]
Message-ID: <a0c33545-774a-6d77-03a1-c834d49297bf@denx.de> (raw)
In-Reply-To: <20220729112907.8207-1-pali@kernel.org>

On 29.07.22 13:29, Pali Rohár wrote:
> Different Turris Omnia HW board revisions contains different MCU.
> Show type in show_board_info() to easily identify which MCU is populated.
> 
> Signed-off-by: Pali Rohár <pali@kernel.org>

Reviewed-by: Stefan Roese <sr@denx.de>

Thanks,
Stefan

> ---
>   board/CZ.NIC/turris_omnia/turris_omnia.c | 45 ++++++++++++++++++++++++
>   1 file changed, 45 insertions(+)
> 
> diff --git a/board/CZ.NIC/turris_omnia/turris_omnia.c b/board/CZ.NIC/turris_omnia/turris_omnia.c
> index b169abca0956..6fc2018c1cfb 100644
> --- a/board/CZ.NIC/turris_omnia/turris_omnia.c
> +++ b/board/CZ.NIC/turris_omnia/turris_omnia.c
> @@ -62,13 +62,27 @@ enum mcu_commands {
>   	CMD_GET_STATUS_WORD	= 0x01,
>   	CMD_GET_RESET		= 0x09,
>   	CMD_WATCHDOG_STATE	= 0x0b,
> +
> +	/* available if STS_FEATURES_SUPPORTED bit set in status word */
> +	CMD_GET_FEATURES	= 0x10,
>   };
>   
>   enum status_word_bits {
> +	STS_MCU_TYPE_MASK	= GENMASK(1, 0),
> +	STS_MCU_TYPE_STM32	= 0,
> +	STS_MCU_TYPE_GD32	= 1,
> +	STS_MCU_TYPE_MKL	= 2,
> +	STS_MCU_TYPE_UNKN	= 3,
> +	STS_FEATURES_SUPPORTED	= BIT(2),
>   	CARD_DET_STSBIT		= 0x0010,
>   	MSATA_IND_STSBIT	= 0x0020,
>   };
>   
> +/* CMD_GET_FEATURES */
> +enum features_e {
> +	FEAT_PERIPH_MCU		= BIT(0),
> +};
> +
>   /*
>    * Those values and defines are taken from the Marvell U-Boot version
>    * "u-boot-2013.01-2014_T3.0"
> @@ -371,6 +385,36 @@ static int omnia_get_ram_size_gb(void)
>   	return ram_size;
>   }
>   
> +static const char * const omnia_get_mcu_type(void)
> +{
> +	static const char * const mcu_types[] = {
> +		[STS_MCU_TYPE_STM32] = "STM32",
> +		[STS_MCU_TYPE_GD32]  = "GD32",
> +		[STS_MCU_TYPE_MKL]   = "MKL",
> +		[STS_MCU_TYPE_UNKN]  = "unknown",
> +	};
> +	static const char * const mcu_types_with_perip_resets[] = {
> +		[STS_MCU_TYPE_STM32] = "STM32 (with peripheral resets)",
> +		[STS_MCU_TYPE_GD32]  = "GD32 (with peripheral resets)",
> +		[STS_MCU_TYPE_MKL]   = "MKL (with peripheral resets)",
> +		[STS_MCU_TYPE_UNKN]  = "unknown (with peripheral resets)",
> +	};
> +	u16 stsword, features;
> +	int ret;
> +
> +	ret = omnia_mcu_read(CMD_GET_STATUS_WORD, &stsword, sizeof(stsword));
> +	if (ret)
> +		return "unknown";
> +
> +	if (stsword & STS_FEATURES_SUPPORTED) {
> +		ret = omnia_mcu_read(CMD_GET_FEATURES, &features, sizeof(features));
> +		if (ret == 0 && (features & FEAT_PERIPH_MCU))
> +			return mcu_types_with_perip_resets[stsword & STS_MCU_TYPE_MASK];
> +	}
> +
> +	return mcu_types[stsword & STS_MCU_TYPE_MASK];
> +}
> +
>   /*
>    * Define the DDR layout / topology here in the board file. This will
>    * be used by the DDR3 init code in the SPL U-Boot version to configure
> @@ -688,6 +732,7 @@ int show_board_info(void)
>   
>   	err = turris_atsha_otp_get_serial_number(&version_num, &serial_num);
>   	printf("Model: Turris Omnia\n");
> +	printf("  MCU type: %s\n", omnia_get_mcu_type());
>   	printf("  RAM size: %i MiB\n", omnia_get_ram_size_gb() * 1024);
>   	if (err)
>   		printf("  Serial Number: unknown\n");

Viele Grüße,
Stefan Roese

-- 
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: sr@denx.de

  parent reply	other threads:[~2022-08-01 11:56 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-07-29 11:29 [PATCH 1/2] arm: mvebu: turris_omnia: Show MCU type in show_board_info() Pali Rohár
2022-07-29 11:29 ` [PATCH 2/2] arm: mvebu: turris_omnia: Add support for design with SW reset signals Pali Rohár
2022-08-01 11:58   ` Stefan Roese
2022-08-01 12:19     ` Pali Rohár
2022-08-01 15:49   ` Marek Behún
2022-08-09 11:32   ` Stefan Roese
2022-08-01 11:56 ` Stefan Roese [this message]
2022-08-01 15:49 ` [PATCH 1/2] arm: mvebu: turris_omnia: Show MCU type in show_board_info() Marek Behún
2022-08-09 11:32 ` Stefan Roese

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=a0c33545-774a-6d77-03a1-c834d49297bf@denx.de \
    --to=sr@denx.de \
    --cc=kabel@kernel.org \
    --cc=pali@kernel.org \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.