From patchwork Fri Mar 5 14:18:52 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Vasut X-Patchwork-Id: 1447848 X-Patchwork-Delegate: patrice.chotard@st.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=denx.de header.i=@denx.de header.a=rsa-sha256 header.s=phobos-20191101 header.b=XOHS6Esl; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4DsVGx74dxz9sVt for ; Sat, 6 Mar 2021 01:19:13 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 51EB68204B; Fri, 5 Mar 2021 15:19:02 +0100 (CET) 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=1614953942; bh=uPEgQl6RKNyytg++V6PmxVac8TngRgW+qQ0KNuCgXnA=; h=From:To:Cc:Subject:Date:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From; b=XOHS6EslqEeBAOLVnZmpAJDVME8wyZZgYkMskReUkrcDgN7316fydF35B++n9J7A2 fYpYSSxx7ZBvFHWG+ZQptjjaS3tVspOJikeAOppibr6NY0nGoyWbsWIIanDUK1gyda A5TGlegpc4V8cPnpPAFZDIVu6dweS9cYPycoTHyu19fQN88S3aYh2LaBU6BAs2NOn1 IRiSKhafBwvsFtYRuZPXzNTX0bADYIXja8AZTuZQj+Dz+jjtnE3KHVQYQjpoBMxR6I pyRQWo5D9fa9js9gO2YdCAHiNw/mf75E8YYpMw91sB0h8lnxVGKwFbF5NJYmChREvP yAoCRNqFOua+A== Received: by phobos.denx.de (Postfix, from userid 109) id 7D2E88204A; Fri, 5 Mar 2021 15:19:00 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL,SPF_HELO_NONE autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-out.m-online.net (mail-out.m-online.net [212.18.0.9]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id BF70A8204A for ; Fri, 5 Mar 2021 15:18:57 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=denx.de Authentication-Results: phobos.denx.de; spf=none smtp.mailfrom=marex@denx.de Received: from frontend01.mail.m-online.net (unknown [192.168.8.182]) by mail-out.m-online.net (Postfix) with ESMTP id 4DsVGT3wPdz1qsZn; Fri, 5 Mar 2021 15:18:57 +0100 (CET) Received: from localhost (dynscan1.mnet-online.de [192.168.6.70]) by mail.m-online.net (Postfix) with ESMTP id 4DsVGT3YN6z1t6p6; Fri, 5 Mar 2021 15:18:57 +0100 (CET) Received: from mail.mnet-online.de ([192.168.8.182]) by localhost (dynscan1.mail.m-online.net [192.168.6.70]) (amavisd-new, port 10024) with ESMTP id Judurs_2C0Wb; Fri, 5 Mar 2021 15:18:56 +0100 (CET) X-Auth-Info: pRvGhLINJIDUIDKC6BOqDQw1W6Du5em1FRwnJZOwxos= Received: from tr.lan (ip-89-176-112-137.net.upcbroadband.cz [89.176.112.137]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.mnet-online.de (Postfix) with ESMTPSA; Fri, 5 Mar 2021 15:18:56 +0100 (CET) From: Marek Vasut To: u-boot@lists.denx.de Cc: Marek Vasut , Patrick Delaunay , Patrice Chotard Subject: [PATCH] arm: stm32mp1: Set soc_type, soc_pkg, soc_rev env variables Date: Fri, 5 Mar 2021 15:18:52 +0100 Message-Id: <20210305141852.97101-1-marex@denx.de> X-Mailer: git-send-email 2.30.1 MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 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.102.4 at phobos.denx.de X-Virus-Status: Clean Split up get_soc_name(), clean the decoding up a bit, and set up environment variables which contain the SoC type, package, revision. This is useful on SoMs, where multiple SoC options are populated. Signed-off-by: Marek Vasut Cc: Patrick Delaunay Cc: Patrice Chotard Reviewed-by: Patrice Chotard --- arch/arm/mach-stm32mp/cpu.c | 105 ++++++++++++++++++------------------ 1 file changed, 53 insertions(+), 52 deletions(-) diff --git a/arch/arm/mach-stm32mp/cpu.c b/arch/arm/mach-stm32mp/cpu.c index 3faa4ec18a4..887db9b5b0c 100644 --- a/arch/arm/mach-stm32mp/cpu.c +++ b/arch/arm/mach-stm32mp/cpu.c @@ -349,89 +349,78 @@ u32 get_cpu_package(void) return get_otp(BSEC_OTP_PKG, PKG_SHIFT, PKG_MASK); } -void get_soc_name(char name[SOC_NAME_SIZE]) +static const char * const soc_type[] = { + "????", + "151C", "151A", "151F", "151D", + "153C", "153A", "153F", "153D", + "157C", "157A", "157F", "157D" +}; + +static const char * const soc_pkg[] = { "??", "AD", "AC", "AB", "AA" }; +static const char * const soc_rev[] = { "?", "A", "B", "Z" }; + +static void get_cpu_string_offsets(unsigned int *type, unsigned int *pkg, + unsigned int *rev) { - char *cpu_s, *cpu_r, *pkg; + u32 cpu_type = get_cpu_type(); + u32 ct = cpu_type & ~(BIT(7) | BIT(0)); + u32 cm = ((cpu_type & BIT(7)) >> 6) | (cpu_type & BIT(0)); + u32 cp = get_cpu_package(); - /* MPUs Part Numbers */ - switch (get_cpu_type()) { - case CPU_STM32MP157Fxx: - cpu_s = "157F"; - break; - case CPU_STM32MP157Dxx: - cpu_s = "157D"; - break; - case CPU_STM32MP157Cxx: - cpu_s = "157C"; - break; - case CPU_STM32MP157Axx: - cpu_s = "157A"; - break; - case CPU_STM32MP153Fxx: - cpu_s = "153F"; - break; - case CPU_STM32MP153Dxx: - cpu_s = "153D"; + /* Bits 0 and 7 are the ACDF, 00:C 01:A 10:F 11:D */ + switch (ct) { + case CPU_STM32MP151Cxx: + *type = cm + 1; break; case CPU_STM32MP153Cxx: - cpu_s = "153C"; - break; - case CPU_STM32MP153Axx: - cpu_s = "153A"; - break; - case CPU_STM32MP151Fxx: - cpu_s = "151F"; - break; - case CPU_STM32MP151Dxx: - cpu_s = "151D"; + *type = cm + 5; break; - case CPU_STM32MP151Cxx: - cpu_s = "151C"; - break; - case CPU_STM32MP151Axx: - cpu_s = "151A"; + case CPU_STM32MP157Cxx: + *type = cm + 9; break; default: - cpu_s = "????"; + *type = 0; break; } /* Package */ - switch (get_cpu_package()) { + switch (cp) { case PKG_AA_LBGA448: - pkg = "AA"; - break; case PKG_AB_LBGA354: - pkg = "AB"; - break; case PKG_AC_TFBGA361: - pkg = "AC"; - break; case PKG_AD_TFBGA257: - pkg = "AD"; + *pkg = cp; break; default: - pkg = "??"; + pkg = 0; break; } - /* REVISION */ + /* Revision */ switch (get_cpu_rev()) { case CPU_REVA: - cpu_r = "A"; + *rev = 1; break; case CPU_REVB: - cpu_r = "B"; + *rev = 2; break; case CPU_REVZ: - cpu_r = "Z"; + *rev = 3; break; default: - cpu_r = "?"; + *rev = 0; break; } +} + +void get_soc_name(char name[SOC_NAME_SIZE]) +{ + unsigned int type, pkg, rev; - snprintf(name, SOC_NAME_SIZE, "STM32MP%s%s Rev.%s", cpu_s, pkg, cpu_r); + get_cpu_string_offsets(&type, &pkg, &rev); + + snprintf(name, SOC_NAME_SIZE, "STM32MP%s%s Rev.%s", + soc_type[type], soc_pkg[pkg], soc_rev[rev]); } #if defined(CONFIG_DISPLAY_CPUINFO) @@ -620,11 +609,23 @@ static int setup_serial_number(void) return 0; } +static void setup_soc_type_pkg_rev(void) +{ + unsigned int type, pkg, rev; + + get_cpu_string_offsets(&type, &pkg, &rev); + + env_set("soc_type", soc_type[type]); + env_set("soc_pkg", soc_pkg[pkg]); + env_set("soc_rev", soc_rev[rev]); +} + int arch_misc_init(void) { setup_boot_mode(); setup_mac_address(); setup_serial_number(); + setup_soc_type_pkg_rev(); return 0; }