From: Stefano Babic <sbabic@denx.de>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH 3/5] Add fuse API and commands
Date: Tue, 21 Aug 2012 10:11:13 +0200 [thread overview]
Message-ID: <503342A1.1040904@denx.de> (raw)
In-Reply-To: <1038235395.2398352.1344948755663.JavaMail.root@advansee.com>
On 14/08/2012 14:52, Beno?t Th?baudeau wrote:
> This can be useful for fuse-like hardware, OTP SoC options, etc.
>
> Signed-off-by: Beno?t Th?baudeau <benoit.thebaudeau@advansee.com>
> Cc: Wolfgang Denk <wd@denx.de>
> Cc: Stefano Babic <sbabic@denx.de>
> ---
CC to Anatolji, he knows very well the MPC5121 that has currently
support of fuses.
> {u-boot-4d3c95f.orig => u-boot-4d3c95f}/README | 1 +
> .../common/Makefile | 1 +
> /dev/null => u-boot-4d3c95f/common/cmd_fuse.c | 182 ++++++++++++++++++++
> .../include/config_cmd_all.h | 1 +
> /dev/null => u-boot-4d3c95f/include/fuse.h | 49 ++++++
> 5 files changed, 234 insertions(+)
> create mode 100644 u-boot-4d3c95f/common/cmd_fuse.c
> create mode 100644 u-boot-4d3c95f/include/fuse.h
>
> diff --git u-boot-4d3c95f.orig/README u-boot-4d3c95f/README
> index fb9d904..c40fd34 100644
> --- u-boot-4d3c95f.orig/README
> +++ u-boot-4d3c95f/README
> @@ -780,6 +780,7 @@ The following options need to be configured:
> CONFIG_CMD_FDOS * Dos diskette Support
> CONFIG_CMD_FLASH flinfo, erase, protect
> CONFIG_CMD_FPGA FPGA device initialization support
> + CONFIG_CMD_FUSE Device fuse support
> CONFIG_CMD_GO * the 'go' command (exec code)
> CONFIG_CMD_GREPENV * search environment
> CONFIG_CMD_HWFLOW * RTS/CTS hw flow control
Agree in this split: we have a general fuse command and each SOC / SOC
family can add its own implementation.
> +static int do_fuse(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[])
> +{
> + u32 bank, row, bit, cnt, val;
> + int ret, i;
> +
> + if (argc < 4 || strtou32(argv[2], 0, &bank) ||
> + strtou32(argv[3], 0, &row))
> + return CMD_RET_USAGE;
> +
> + if (!strcmp(argv[1], "read.bit")) {
> + if (argc != 5 || strtou32(argv[4], 0, &bit))
> + return CMD_RET_USAGE;
> +
> + printf("Reading bank %u row 0x%.8x bit %u: ", bank, row, bit);
> + ret = fuse_read_bit(bank, row, bit, &val);
> + if (ret)
> + goto err;
> +
> + printf("%u\n", val);
> + } else if (!strcmp(argv[1], "read.row")) {
> + if (argc == 4)
> + cnt = 1;
> + else if (argc != 5 || strtou32(argv[4], 0, &cnt))
> + return CMD_RET_USAGE;
> +
> + printf("Reading bank %u:\n", bank);
> + for (i = 0; i < cnt; i++, row++) {
> + if (!(i % 4))
> + printf("\nRow 0x%.8x:", row);
> +
> + ret = fuse_read_row(bank, row, &val);
> + if (ret)
> + goto err;
> +
> + printf(" %.8x", val);
> + }
> + putc('\n');
> + } else if (!strcmp(argv[1], "sense.bit")) {
> + if (argc != 5 || strtou32(argv[4], 0, &bit))
> + return CMD_RET_USAGE;
> +
> + printf("Sensing bank %u row 0x%.8x bit %u: ", bank, row, bit);
Each command sends this output to the console. I am thinking about if
instead of printf() we shoud use debug()
> +U_BOOT_CMD(
> + fuse, CONFIG_SYS_MAXARGS, 0, do_fuse,
> + "Fuse sub-system",
> + "read.bit <bank> <row> <bit> - read a fuse bit\n"
> + "fuse read.row <bank> <row> [<cnt>] - read 1 or 'cnt' fuse rows,\n"
> + " starting at 'row'\n"
> + "fuse sense.bit <bank> <row> <bit> - sense a fuse bit\n"
> + "fuse sense.row <bank> <row> [<cnt>] - sense 1 or 'cnt' fuse rows,\n"
> + " starting at 'row'\n"
> + "fuse prog.bit <bank> <row> <bit> - program a fuse bit (PERMANENT)\n"
> + "fuse prog.row <bank> <row> <hexval> [<hexval>...] - program 1 or\n"
> + " several fuse rows, starting at 'row' (PERMANENT)\n"
> + "fuse ovride.bit <bank> <row> <bit> <val> - override a fuse bit\n"
> + "fuse ovride.row <bank> <row> <hexval> [<hexval>...] - override 1 or\n"
> + " several fuse rows, starting at 'row'"
> +);
General question: why do we need the "bit" interface ? I have thought it
is enough the read row / prog row interface (even if there is a bit
programming).
Best regards,
Stefano Babic
--
=====================================================================
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-53 Fax: +49-8142-66989-80 Email: sbabic at denx.de
=====================================================================
next prev parent reply other threads:[~2012-08-21 8:11 UTC|newest]
Thread overview: 38+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-08-14 12:51 [U-Boot] [PATCH 0/5] Make iim support common to mpc and imx Benoît Thébaudeau
2012-08-14 12:52 ` [U-Boot] [PATCH 1/5] imx iim: Homogenize and fix register definitions Benoît Thébaudeau
2012-11-27 13:30 ` [U-Boot] [PATCH v2 " Benoît Thébaudeau
2012-11-27 13:30 ` [U-Boot] [PATCH v2 2/5] imx iim: Add useful fuse definitions Benoît Thébaudeau
2012-11-27 13:31 ` [U-Boot] [PATCH v2 3/5] Add fuse API and commands Benoît Thébaudeau
2012-11-27 13:31 ` [U-Boot] [PATCH v2 4/5] Add fsl_iim driver Benoît Thébaudeau
2012-11-27 13:32 ` [U-Boot] [PATCH v2 5/5] mpc iim: Switch to common fsl_iim Benoît Thébaudeau
2013-03-18 12:07 ` [U-Boot] [PATCH v2 1/5] imx iim: Homogenize and fix register definitions Stefano Babic
2013-03-18 12:08 ` Benoît Thébaudeau
2013-03-18 12:13 ` Benoît Thébaudeau
2012-08-14 12:52 ` [U-Boot] [PATCH 2/5] imx iim: Add useful fuse definitions Benoît Thébaudeau
2012-08-14 12:52 ` [U-Boot] [PATCH 3/5] Add fuse API and commands Benoît Thébaudeau
2012-08-21 8:11 ` Stefano Babic [this message]
2012-08-21 10:14 ` Benoît Thébaudeau
2012-08-22 10:43 ` Dirk Behme
2012-08-22 11:11 ` Benoît Thébaudeau
2012-08-22 16:25 ` Dirk Behme
2012-08-22 16:53 ` Benoît Thébaudeau
2012-08-23 10:31 ` Stefano Babic
2012-08-23 13:23 ` Eric Nelson
2012-11-26 16:03 ` Benoît Thébaudeau
2012-11-27 7:19 ` Dirk Behme
2012-11-27 16:58 ` Eric Nelson
2012-11-27 18:27 ` Benoît Thébaudeau
2012-11-27 18:36 ` Eric Nelson
2012-11-27 19:23 ` Benoît Thébaudeau
2012-11-27 19:54 ` Eric Nelson
2012-12-03 9:03 ` Stefano Babic
2012-12-03 11:25 ` Benoît Thébaudeau
2012-12-03 11:41 ` Stefano Babic
2012-08-14 12:52 ` [U-Boot] [PATCH 4/5] Add fsl_iim driver Benoît Thébaudeau
2012-08-21 8:13 ` Stefano Babic
2012-08-21 12:56 ` Benoît Thébaudeau
2012-08-21 13:41 ` Stefano Babic
2012-08-14 12:53 ` [U-Boot] [PATCH 5/5] mpc iim: Switch to common fsl_iim Benoît Thébaudeau
2012-08-15 14:30 ` Benoît Thébaudeau
2012-08-21 8:15 ` Stefano Babic
2012-11-05 20:05 ` Benoît Thébaudeau
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=503342A1.1040904@denx.de \
--to=sbabic@denx.de \
--cc=u-boot@lists.denx.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox