From patchwork Mon Aug 12 06:41:27 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sagar Shrikant Kadam X-Patchwork-Id: 1145516 X-Patchwork-Delegate: uboot@andestech.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=sifive.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=sifive.com header.i=@sifive.com header.b="HS8MnkTs"; dkim-atps=neutral Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 466R9R2rJvz9sN6 for ; Mon, 12 Aug 2019 16:42:35 +1000 (AEST) Received: by lists.denx.de (Postfix, from userid 105) id D6AA8C21CB1; Mon, 12 Aug 2019 06:42:25 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=-0.0 required=5.0 tests=RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, T_DKIM_INVALID autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id 39CF4C21EA8; Mon, 12 Aug 2019 06:42:24 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 2D11CC21E7E; Mon, 12 Aug 2019 06:42:09 +0000 (UTC) Received: from mail-pg1-f193.google.com (mail-pg1-f193.google.com [209.85.215.193]) by lists.denx.de (Postfix) with ESMTPS id 76CDBC21E31 for ; Mon, 12 Aug 2019 06:42:07 +0000 (UTC) Received: by mail-pg1-f193.google.com with SMTP id x15so38638766pgg.8 for ; Sun, 11 Aug 2019 23:42:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sifive.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=Gge9+HdMBzlymVvEgBW1F7p947sJn7pwFXqPbAaK+Os=; b=HS8MnkTsgMNLihp274O6KUvpBoUk29f4p2wFXTADfOMDgwIevox/XupI7LP8hk8NDZ l4XJTwmQ2omzdmUVIvQIOI72Wp/vbBj2DDJ+n3lugbg1ynWjmGkCgxp8T/NevremVQ+f hmAsPSTY72x/XtUTEQU+PXKiiAWmY8bQzV9CrUh0lnHfwBL0AMtXe2S4AnpwN+AKr+X6 yBagkULRnm/fy7jL0PyUuZ7PsHbWeVw/ZTIDGwah34Dy7iB3JxfpNa6oS2bsGlKKBRYp qN97cMMTcnaljhh5hdg8U/X+u8fB0jThkdDtFOfvhH2cB7PgkcPfqrTViRA5sC18A4eR Lb6Q== 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:in-reply-to :references; bh=Gge9+HdMBzlymVvEgBW1F7p947sJn7pwFXqPbAaK+Os=; b=CQiX1X2WlEnVlxtaBY1vRAP6WGWPCJGwSKMRSjPBddgPziRugN/559rcy0ntHgjqYo KVq23+UIDybH0LzK1MJUGi7e7SckZtK3SbiLNhpl5miW8MvIbiJlgEnSxB+UmEW+riEO Eyyn1ZPOYnpg4qySEphswlspZ0c9Q+1bCuTxUCFdarOQ2rZ3iYM5trMzZUSQ1Vh8ZUQG SgV9UT4ZtIszgXpriqudJWIqFUK/FVb8LCH0KQ/QK8NWpTpaEVo88zR9/ZHddkHFzbCi TgwlsPR2Zex8TZgkmbsUuvhy/f2/qB4LAS2JIGHP+6SNcbyUnVB3qmNIS6tqnOUmJnit WuAg== X-Gm-Message-State: APjAAAWueJfMLgBp4fvI+F/OLwkVfiwyZekQysxSsD2TZKtMZaKjSL8K FQHEzcdWowTifP+i94MNSIMzUCY2ayKxmw== X-Google-Smtp-Source: APXvYqytflLqRR2STs2hkHbsO0Um60epLvcaFC+y6Ghv7d7wcKx1iPwkS/vroxhATCiixM2dmIguzg== X-Received: by 2002:a63:6fc9:: with SMTP id k192mr28576564pgc.20.1565592125765; Sun, 11 Aug 2019 23:42:05 -0700 (PDT) Received: from gamma07.internal.sifive.com ([64.62.193.194]) by smtp.googlemail.com with ESMTPSA id v8sm89475577pgs.82.2019.08.11.23.42.05 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 11 Aug 2019 23:42:05 -0700 (PDT) From: Sagar Shrikant Kadam To: u-boot@lists.denx.de Date: Sun, 11 Aug 2019 23:41:27 -0700 Message-Id: <1565592087-1290-2-git-send-email-sagar.kadam@sifive.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1565592087-1290-1-git-send-email-sagar.kadam@sifive.com> References: <1565592087-1290-1-git-send-email-sagar.kadam@sifive.com> Cc: palmer@sifive.com Subject: [U-Boot] [U-BOOT PATCH] riscv: sifive: fu540: set serial environment variable from otp X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" This patch sets the serial# environment variable by reading the board serial number from the OTP memory region. Signed-off-by: Sagar Shrikant Kadam Reviewed-by: Anup Patel --- board/sifive/fu540/fu540.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/board/sifive/fu540/fu540.c b/board/sifive/fu540/fu540.c index 11daf1a..06bf442 100644 --- a/board/sifive/fu540/fu540.c +++ b/board/sifive/fu540/fu540.c @@ -122,10 +122,20 @@ static void fu540_setup_macaddr(u32 serialnum) int misc_init_r(void) { - /* Set ethaddr environment variable if not set */ - if (!env_get("ethaddr")) - fu540_setup_macaddr(fu540_read_serialnum()); - + u32 serial_num; + char buf[11] = {0}; + + /* Set ethaddr environment variable from board serial number */ + if (!env_get("serial#")) { + serial_num = fu540_read_serialnum(); + if (!serial_num) { + WARN(1, "Board serial number should not be 0 !!"); + return 0; + } + snprintf(buf, sizeof(buf), "%08x", serial_num); + env_set("serial#", buf); + fu540_setup_macaddr(serial_num); + } return 0; }