From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id B3CD6C19F2D for ; Tue, 9 Aug 2022 11:32:24 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 15DF082A4B; Tue, 9 Aug 2022 13:32:22 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=denx.de Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=denx.de; s=phobos-20191101; t=1660044742; bh=uxJNMpje6DbyZosFgaYhkcH1Ux7kxdzVu/f+KysShLs=; h=Date:Subject:To:Cc:References:From:In-Reply-To:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=DGkIiJpfEjKfuQpWkJ0Pmk7tKrw/oZScW+//e7Z+xS1MWrtS5n6CdgmIp+kESWHYj nt87CIauRwlis9l5tqiZsgwCGOvgK3/ji6gu1U/aCKNHN9JXMaWkTvW9DSaJNNSxTI BVTKADbONeqlD00Uc6cv0uP/M0e4xF17GYVzGyyM3sPTBuNZqjSZfkeyRag8Av9hIi doPSoLgTaFm6ooBhDiSKN+j9q8iMK/5NLNydqUP885WD+H2EnDkoxpS3belk44mxEj wC5+40qmWdwawU4XQ61hOcWa5dOj6l2eOMZLoJ+vkkTIGnIAAjj3z2EHmCJZjCFC1t sw0CusIIzyVlg== Received: by phobos.denx.de (Postfix, from userid 109) id C624C849CC; Tue, 9 Aug 2022 13:32:19 +0200 (CEST) Received: from mout-u-204.mailbox.org (mout-u-204.mailbox.org [80.241.59.204]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id E24668210C for ; Tue, 9 Aug 2022 13:32:16 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=denx.de Authentication-Results: phobos.denx.de; spf=fail smtp.mailfrom=sr@denx.de Received: from smtp102.mailbox.org (smtp102.mailbox.org [10.196.197.102]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-384) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mout-u-204.mailbox.org (Postfix) with ESMTPS id 4M29rx5hVfz9sQM; Tue, 9 Aug 2022 13:32:01 +0200 (CEST) Message-ID: <2a2fc464-f1f9-cae4-adce-8537f060ee1b@denx.de> Date: Tue, 9 Aug 2022 13:32:00 +0200 MIME-Version: 1.0 Subject: Re: [PATCH 1/2] arm: mvebu: turris_omnia: Show MCU type in show_board_info() Content-Language: en-US To: =?UTF-8?Q?Pali_Roh=c3=a1r?= , =?UTF-8?Q?Marek_Beh=c3=ban?= Cc: u-boot@lists.denx.de References: <20220729112907.8207-1-pali@kernel.org> From: Stefan Roese In-Reply-To: <20220729112907.8207-1-pali@kernel.org> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.6 at phobos.denx.de X-Virus-Status: Clean 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 Applied to u-boot-marvell/master 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