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 EBF8AC433EF for ; Sun, 28 Nov 2021 16:03:24 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 3629381244; Sun, 28 Nov 2021 17:03:16 +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="Ie0t3jtC"; dkim=pass (1024-bit key) header.d=akkea.ca header.i=@akkea.ca header.b="Ie0t3jtC"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 3C0A880FE7; Sun, 28 Nov 2021 17:03:12 +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 B7C1580FE7 for ; Sun, 28 Nov 2021 17:03:07 +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 4AAAF4E200C; Sun, 28 Nov 2021 16:03:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=akkea.ca; s=mail; t=1638115386; bh=k/NDu97epWrJaN+OS6cVJVf/aNJCWs8WrPy1g1j9928=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=Ie0t3jtCsHulyXiinjiCV6gGi2eOn/tkhEWTcit9Xu3XtGtORaBSac0G4B+WnPRyG kBM8AIULl/LM/pAcn2SHpMrHF9jbixH168O9Law8qmyHyNnKd2shcT3uLtQa/697Ru 2CdKtKCEQ3zFWJpxHSRbBIYL1vH7HYxqeOmFH8xo= 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 l3F25VeRZPDx; Sun, 28 Nov 2021 16:03:06 +0000 (UTC) Received: from midas.localdomain (S0106788a2041785e.gv.shawcable.net [24.108.106.191]) by node.akkea.ca (Postfix) with ESMTPSA id DC96B4E2003; Sun, 28 Nov 2021 16:03:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=akkea.ca; s=mail; t=1638115386; bh=k/NDu97epWrJaN+OS6cVJVf/aNJCWs8WrPy1g1j9928=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=Ie0t3jtCsHulyXiinjiCV6gGi2eOn/tkhEWTcit9Xu3XtGtORaBSac0G4B+WnPRyG kBM8AIULl/LM/pAcn2SHpMrHF9jbixH168O9Law8qmyHyNnKd2shcT3uLtQa/697Ru 2CdKtKCEQ3zFWJpxHSRbBIYL1vH7HYxqeOmFH8xo= From: Angus Ainslie To: u-boot@lists.denx.de Cc: kernel@puri.sm, Angus Ainslie Subject: [PATCH 2/2] cmd: fuse: Add a command to read fuses to memory Date: Sun, 28 Nov 2021 08:02:53 -0800 Message-Id: <20211128160253.1468839-2-angus@akkea.ca> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211128160253.1468839-1-angus@akkea.ca> References: <20211128160253.1468839-1-angus@akkea.ca> 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 With the fuse values in memory we can use some of the other u-boot shell conditonal operators to do tests. Signed-off-by: Angus Ainslie --- cmd/fuse.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/cmd/fuse.c b/cmd/fuse.c index 78b1065d99e..0676bb7a812 100644 --- a/cmd/fuse.c +++ b/cmd/fuse.c @@ -12,6 +12,7 @@ #include #include #include +#include #include static int strtou32(const char *str, unsigned int base, u32 *result) @@ -46,6 +47,8 @@ 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, cmp; + ulong addr; + void *buf, *start; int ret, i; argc -= 2 + confirmed; @@ -73,6 +76,28 @@ static int do_fuse(struct cmd_tbl *cmdtp, int flag, int argc, printf(" %.8x", val); } putc('\n'); + } else if (!strcmp(op, "readm")) { + if (argc == 3) + cnt = 1; + else if (argc != 4 || strtou32(argv[3], 0, &cnt)) + return CMD_RET_USAGE; + + addr = simple_strtoul(argv[2], NULL, 16); + + start = map_sysmem(addr, 4); + buf = start; + + printf("Reading bank %u len %u to 0x%lx\n", bank, cnt, addr); + for (i = 0; i < cnt; i++, word++) { + ret = fuse_read(bank, word, &val); + if (ret) + goto err; + + *((u32 *)buf) = val; + buf += 4; + } + + unmap_sysmem(start); } else if (!strcmp(op, "cmp")) { if (argc != 3 || strtou32(argv[2], 0, &cmp)) return CMD_RET_USAGE; @@ -157,6 +182,8 @@ U_BOOT_CMD( " starting at 'word'\n" "fuse cmp - compare 'hexval' to fuse\n" " at 'word'\n" + "fuse readm [] - read 1 or 'cnt' fuse words,\n" + " starting at 'word' into memory at 'addr'\n" "fuse sense [] - sense 1 or 'cnt' fuse words,\n" " starting at 'word'\n" "fuse prog [-y] [...] - program 1 or\n" -- 2.25.1