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 E1C88C433F5 for ; Sun, 28 Nov 2021 16:03:12 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 06C9A80F9D; Sun, 28 Nov 2021 17:03:10 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=akkea.ca Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=akkea.ca header.i=@akkea.ca header.b="n134vs5E"; dkim=pass (1024-bit key) header.d=akkea.ca header.i=@akkea.ca header.b="YpLZqcbx"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id E02498083E; Sun, 28 Nov 2021 17:03:07 +0100 (CET) Received: from node.akkea.ca (li1434-30.members.linode.com [45.33.107.30]) (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 17D1D8083E for ; Sun, 28 Nov 2021 17:03:04 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=akkea.ca Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=angus@akkea.ca Received: from localhost (localhost [127.0.0.1]) by node.akkea.ca (Postfix) with ESMTP id F41044E200C; Sun, 28 Nov 2021 16:03:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=akkea.ca; s=mail; t=1638115382; bh=SEqF0e4LFbbD3QCXjUNlq8cYpR5RtIkkt0pkZHFbWac=; h=From:To:Cc:Subject:Date; b=n134vs5E0iOR4yt7/Ua3Wh5MOesrOsHIN9L6YUEE3S5ZckwKwqNAOVE87C0+hepA6 d9JZsNWrexaVZS3yHgnpig6t1r2iHA2licwPaRMWemqvL0E/1xnowqdG8AlyhkgQBd iTCl3MDXGhbzjQf4+FVIvfcHZXZiP66a/HW9w3n0= Received: from node.akkea.ca ([127.0.0.1]) by localhost (mail.akkea.ca [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id KTaZ9S7bMYkT; Sun, 28 Nov 2021 16:03:01 +0000 (UTC) Received: from midas.localdomain (S0106788a2041785e.gv.shawcable.net [24.108.106.191]) by node.akkea.ca (Postfix) with ESMTPSA id 621024E2003; Sun, 28 Nov 2021 16:03:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=akkea.ca; s=mail; t=1638115381; bh=SEqF0e4LFbbD3QCXjUNlq8cYpR5RtIkkt0pkZHFbWac=; h=From:To:Cc:Subject:Date; b=YpLZqcbx7ihRJY4auf4TlL9czdXnPfPz7EpIKgqWlMAGhBCCD/boRfQdDsKur5EW0 3Oe4MiR2bC8RA906FAgRMwpQMY69EjitHJr5ArbAqbu7j54teURS7IfVmt1RxBJyx8 kPgkxbXUELIZNGcLZfd0172YWZENUcEPbE4NAaPw= From: Angus Ainslie To: u-boot@lists.denx.de Cc: kernel@puri.sm, Angus Ainslie Subject: [PATCH 1/2] cmd: fuse: add a fuse comparison function Date: Sun, 28 Nov 2021 08:02:52 -0800 Message-Id: <20211128160253.1468839-1-angus@akkea.ca> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.37 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 Compare a hexval to the fuse value and return pass or fail. Signed-off-by: Angus Ainslie --- cmd/fuse.c | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/cmd/fuse.c b/cmd/fuse.c index e001619d172..78b1065d99e 100644 --- a/cmd/fuse.c +++ b/cmd/fuse.c @@ -45,7 +45,7 @@ static int do_fuse(struct cmd_tbl *cmdtp, int flag, int argc, { const char *op = argc >= 2 ? argv[1] : NULL; int confirmed = argc >= 3 && !strcmp(argv[2], "-y"); - u32 bank, word, cnt, val; + u32 bank, word, cnt, val, cmp; int ret, i; argc -= 2 + confirmed; @@ -73,6 +73,24 @@ static int do_fuse(struct cmd_tbl *cmdtp, int flag, int argc, printf(" %.8x", val); } putc('\n'); + } else if (!strcmp(op, "cmp")) { + if (argc != 3 || strtou32(argv[2], 0, &cmp)) + return CMD_RET_USAGE; + + printf("Comparing bank %u:\n", bank); + printf("\nWord 0x%.8x:", word); + printf("\nValue 0x%.8x:", cmp); + + ret = fuse_read(bank, word, &val); + if (ret) + goto err; + + printf("0x%.8x\n", val); + if (val != cmp) { + printf("failed\n"); + return CMD_RET_FAILURE; + } + printf("passed\n"); } else if (!strcmp(op, "sense")) { if (argc == 2) cnt = 1; @@ -137,6 +155,8 @@ U_BOOT_CMD( "Fuse sub-system", "read [] - read 1 or 'cnt' fuse words,\n" " starting at 'word'\n" + "fuse cmp - compare 'hexval' to fuse\n" + " at 'word'\n" "fuse sense [] - sense 1 or 'cnt' fuse words,\n" " starting at 'word'\n" "fuse prog [-y] [...] - program 1 or\n" -- 2.25.1