Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 56480C432BE for ; Tue, 31 Aug 2021 11:54:02 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id BD216606A5 for ; Tue, 31 Aug 2021 11:54:01 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org BD216606A5 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=foundries.io Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=lists.denx.de Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 1D5F282E3F; Tue, 31 Aug 2021 13:53:59 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=foundries.io Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=foundries.io header.i=@foundries.io header.b="MHKgWKOt"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 9C10F82DB4; Tue, 31 Aug 2021 13:53:56 +0200 (CEST) Received: from mail-lf1-x136.google.com (mail-lf1-x136.google.com [IPv6:2a00:1450:4864:20::136]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 5396D83205 for ; Tue, 31 Aug 2021 13:53:47 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=foundries.io Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=oleksandr.suvorov@foundries.io Received: by mail-lf1-x136.google.com with SMTP id c8so25330660lfi.3 for ; Tue, 31 Aug 2021 04:53:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=foundries.io; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=5SyONSrJT81pJ18PFQF6ra5FuuyaxiTBt0ckovdXv9I=; b=MHKgWKOt5hvM0CR1xctUFE7wmu1YqLlo650+I2OE/Il102jcs/93zHhMPfLicSE1k1 Ey+QBzcoC1sWUnOQqv6W7KKsnX18adbR+eykagCWNslLxe7L7fA/gCQ2POWYuaAdBR2b 2q355hoASGpllvViFWsmvS5hObCl++5DOkuPbIodfle9FMVT1GS+hJVHUjzqH5lR4pOK XRa8+Es3M90kkkLxv7+dO6VznBsNl+qUbZpaSJ6jTxQf5AVVrIOCOM+D+0INLm80f/J+ oIa41IL/NUFID7w6LypOV0iHi097ERO9G9wHqw5Nrx4pmkokDbUxIe+lbayLBRiAFq7w 1h8w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=5SyONSrJT81pJ18PFQF6ra5FuuyaxiTBt0ckovdXv9I=; b=G6Gh8XsXxqTM7QMVVpOkePHzx3QvAIQ5W0g7DZfJjO7+q1q5Ck4Gg0YqrGJtRUsS39 8kDEOcdJppaEdG+uHgjKE/K/6fhBJOQDuKXaqmeY1vf+kK3+8CSrlZKoeV+NX8W/cMnZ 7W/h+8d4p7kVwYI1i2wxKKy1NOwHSfgjCg5SotV2LT464Qte1paiGXEisr5Oscp4IaDX xTpm1GZYX/SuPzHt3GG3Ld+nrRXehunoZFaCdsoT+0p8x6dJGMeecfs8YyYD6pbaOP+e v5Of31v4dlhDuzyaL69VA02YnME/8fxgd38tMfHYq7Gxl4nkahv4FkFTdxXGEIlmDCWl QZqA== X-Gm-Message-State: AOAM532ormLpZ/QH9jyNjlJmFcBM2Oa4wRxGneYwwtFVjucE/V4k5oTn fVaZgwZ7fqO+NaVZOdbo2pnRuygYjm8+8g== X-Google-Smtp-Source: ABdhPJwYRd/8XME7CN656Kth7q9aTUm0uTfoOzrfnWXcdn/wDAAK7YtB9KqOQj0hJj+81EtDhDNFog== X-Received: by 2002:ac2:4c39:: with SMTP id u25mr2737530lfq.428.1630410826258; Tue, 31 Aug 2021 04:53:46 -0700 (PDT) Received: from cryobook.bearlog ([82.193.109.226]) by smtp.gmail.com with ESMTPSA id d12sm1634011lfj.78.2021.08.31.04.53.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 31 Aug 2021 04:53:45 -0700 (PDT) From: Oleksandr Suvorov To: u-boot@lists.denx.de Cc: Tom Rini , Ricardo Salveti , Oleksandr Suvorov , Fabio Estevam , Harald Seiler , "NXP i.MX U-Boot Team" , Simon Glass , Stefano Babic Subject: [PATCH v2] mx7ulp: add getting a board serial number Date: Tue, 31 Aug 2021 14:53:42 +0300 Message-Id: <20210831145323.v2.1.6cf5f3f9aa@changeid> X-Mailer: git-send-email 2.31.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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.103.2 at phobos.denx.de X-Virus-Status: Clean From: Ricardo Salveti Get Unique ID of SoC iMX7ULP, using the logic described in Fusemap (IMX7ULPRMB2_Rev0_Fusemap) attached in the i.MX 7ULP APRM [1]. [1] https://www.nxp.com/docs/en/reference-manual/IMX7ULPRMB2.pdf Signed-off-by: Ricardo Salveti Co-developed-by: Oleksandr Suvorov Signed-off-by: Oleksandr Suvorov --- Changes in v2: - rebase the commit on top of the following series: https://patchwork.ozlabs.org/project/uboot/list/?series=260161 arch/arm/mach-imx/mx7ulp/soc.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/arch/arm/mach-imx/mx7ulp/soc.c b/arch/arm/mach-imx/mx7ulp/soc.c index 320f24dd29..baf18cf8b7 100644 --- a/arch/arm/mach-imx/mx7ulp/soc.c +++ b/arch/arm/mach-imx/mx7ulp/soc.c @@ -13,6 +13,7 @@ #include #include #include +#include #include #define PMC0_BASE_ADDR 0x410a1000 @@ -363,3 +364,25 @@ enum boot_device get_boot_device(void) return boot_dev; } + +#ifdef CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG +/* + * OCOTP_CFG (SJC CHALLENGE, Unique ID) + * i.MX 7ULP Applications Processor Reference Manual, Rev. 0, 09/2020 + * + * OCOTP_CFG0 offset 0x4B0: 15:0 -> 15:0 bits of Unique ID + * OCOTP_CFG1 offset 0x4C0: 15:0 -> 31:16 bits of Unique ID + * OCOTP_CFG2 offset 0x4D0: 15:0 -> 47:32 bits of Unique ID + * OCOTP_CFG3 offset 0x4E0: 15:0 -> 63:48 bits of Unique ID + */ +void get_board_serial(struct tag_serialnr *serialnr) +{ + struct ocotp_regs *ocotp = (struct ocotp_regs *)OCOTP_BASE_ADDR; + struct fuse_bank *bank = &ocotp->bank[1]; + struct fuse_bank1_regs *fuse = + (struct fuse_bank1_regs *)bank->fuse_regs; + + serialnr->low = (fuse->cfg0 & 0xFFFF) + ((fuse->cfg1 & 0xFFFF) << 16); + serialnr->high = (fuse->cfg2 & 0xFFFF) + ((fuse->cfg3 & 0xFFFF) << 16); +} +#endif /* CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG */ -- 2.31.1