blob: 667149e2d45b2490dc670bc263626f757bccc088 [file] [log] [blame]
Tom Rini83d290c2018-05-06 17:58:06 -04001// SPDX-License-Identifier: GPL-2.0+
wdenk38635852002-08-27 05:55:31 +00002/*
3 * (C) Copyright 2000, 2001
4 * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
wdenk38635852002-08-27 05:55:31 +00005 */
6
d4f5c722005-08-12 21:16:13 +02007/*
8 * Support for read and write access to EEPROM like memory devices. This
9 * includes regular EEPROM as well as FRAM (ferroelectic nonvolaile RAM).
10 * FRAM devices read and write data at bus speed. In particular, there is no
Peter Meerwalde506a002012-02-08 05:31:53 +000011 * write delay. Also, there is no limit imposed on the number of bytes that can
d4f5c722005-08-12 21:16:13 +020012 * be transferred with a single read or write.
Wolfgang Denk6617aae2005-08-19 00:46:54 +020013 *
d4f5c722005-08-12 21:16:13 +020014 * Use the following configuration options to ensure no unneeded performance
15 * degradation (typical for EEPROM) is incured for FRAM memory:
Wolfgang Denk6617aae2005-08-19 00:46:54 +020016 *
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +020017 * #define CONFIG_SYS_I2C_FRAM
18 * #undef CONFIG_SYS_EEPROM_PAGE_WRITE_DELAY_MS
d4f5c722005-08-12 21:16:13 +020019 *
20 */
21
wdenk38635852002-08-27 05:55:31 +000022#include <common.h>
23#include <config.h>
24#include <command.h>
Simon Glasscb3ef682019-11-14 12:57:50 -070025#include <eeprom.h>
wdenk38635852002-08-27 05:55:31 +000026#include <i2c.h>
Nikita Kiryanove7c27292016-04-16 17:55:12 +030027#include <eeprom_layout.h>
wdenk38635852002-08-27 05:55:31 +000028
Marek Vasut4f296d02015-11-10 20:53:18 +010029#ifndef CONFIG_SYS_I2C_SPEED
30#define CONFIG_SYS_I2C_SPEED 50000
Stefan Roese98f4a3d2005-09-22 09:04:17 +020031#endif
wdenk38635852002-08-27 05:55:31 +000032
Marek Vasutd7387462015-11-10 20:53:26 +010033#ifndef CONFIG_SYS_EEPROM_PAGE_WRITE_DELAY_MS
34#define CONFIG_SYS_EEPROM_PAGE_WRITE_DELAY_MS 0
35#endif
36
Marek Vasut6717e3c2015-11-10 20:53:28 +010037#ifndef CONFIG_SYS_EEPROM_PAGE_WRITE_BITS
38#define CONFIG_SYS_EEPROM_PAGE_WRITE_BITS 8
39#endif
40
Mario Sixa6e7b772016-04-20 10:44:52 +020041#ifndef I2C_RXTX_LEN
42#define I2C_RXTX_LEN 128
43#endif
44
Marek Vasut6717e3c2015-11-10 20:53:28 +010045#define EEPROM_PAGE_SIZE (1 << CONFIG_SYS_EEPROM_PAGE_WRITE_BITS)
46#define EEPROM_PAGE_OFFSET(x) ((x) & (EEPROM_PAGE_SIZE - 1))
47
Marek Vasut4f296d02015-11-10 20:53:18 +010048/*
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +020049 * for CONFIG_SYS_I2C_EEPROM_ADDR_LEN == 2 (16-bit EEPROM address) offset is
wdenk38635852002-08-27 05:55:31 +000050 * 0x000nxxxx for EEPROM address selectors at n, offset xxxx in EEPROM.
51 *
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +020052 * for CONFIG_SYS_I2C_EEPROM_ADDR_LEN == 1 (8-bit EEPROM page address) offset is
wdenk38635852002-08-27 05:55:31 +000053 * 0x00000nxx for EEPROM address selectors and page number at n.
54 */
Heiko Schocher548738b2010-01-07 08:55:40 +010055#if !defined(CONFIG_SPI) || defined(CONFIG_ENV_EEPROM_IS_ON_I2C)
Marek Vasut4f296d02015-11-10 20:53:18 +010056#if !defined(CONFIG_SYS_I2C_EEPROM_ADDR_LEN) || \
Marek Vasutd4e69e62015-11-10 20:53:33 +010057 (CONFIG_SYS_I2C_EEPROM_ADDR_LEN < 1) || \
58 (CONFIG_SYS_I2C_EEPROM_ADDR_LEN > 2)
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +020059#error CONFIG_SYS_I2C_EEPROM_ADDR_LEN must be 1 or 2
wdenk38635852002-08-27 05:55:31 +000060#endif
61#endif
62
Simon Goldschmidt4f256172019-03-26 13:38:52 +010063#if defined(CONFIG_DM_I2C)
64int eeprom_i2c_bus;
65#endif
66
Marek Vasut52cd47c2015-11-10 20:53:25 +010067__weak int eeprom_write_enable(unsigned dev_addr, int state)
68{
69 return 0;
70}
Marek Vasut4f296d02015-11-10 20:53:18 +010071
Marek Vasut354e3ed2015-11-10 20:53:31 +010072void eeprom_init(int bus)
Marek Vasut4f296d02015-11-10 20:53:18 +010073{
Marek Vasut4f296d02015-11-10 20:53:18 +010074 /* I2C EEPROM */
Simon Goldschmidt4f256172019-03-26 13:38:52 +010075#if defined(CONFIG_DM_I2C)
76 eeprom_i2c_bus = bus;
77#elif defined(CONFIG_SYS_I2C)
Marek Vasut354e3ed2015-11-10 20:53:31 +010078 if (bus >= 0)
79 i2c_set_bus_num(bus);
Marek Vasut4f296d02015-11-10 20:53:18 +010080 i2c_init(CONFIG_SYS_I2C_SPEED, CONFIG_SYS_I2C_SLAVE);
81#endif
82}
83
Marek Vasut02c321c2015-11-10 20:53:24 +010084static int eeprom_addr(unsigned dev_addr, unsigned offset, uchar *addr)
85{
86 unsigned blk_off;
87 int alen;
88
89 blk_off = offset & 0xff; /* block offset */
90#if CONFIG_SYS_I2C_EEPROM_ADDR_LEN == 1
91 addr[0] = offset >> 8; /* block number */
92 addr[1] = blk_off; /* block offset */
93 alen = 2;
94#else
95 addr[0] = offset >> 16; /* block number */
96 addr[1] = offset >> 8; /* upper address octet */
97 addr[2] = blk_off; /* lower address octet */
98 alen = 3;
99#endif /* CONFIG_SYS_I2C_EEPROM_ADDR_LEN */
100
101 addr[0] |= dev_addr; /* insert device address */
102
103 return alen;
104}
105
Marek Vasut39b6f982015-11-10 20:53:29 +0100106static int eeprom_len(unsigned offset, unsigned end)
107{
108 unsigned len = end - offset;
109
110 /*
111 * For a FRAM device there is no limit on the number of the
Lukasz Majewski35087fb2019-06-09 22:54:38 +0200112 * bytes that can be accessed with the single read or write
Marek Vasut39b6f982015-11-10 20:53:29 +0100113 * operation.
114 */
115#if !defined(CONFIG_SYS_I2C_FRAM)
116 unsigned blk_off = offset & 0xff;
117 unsigned maxlen = EEPROM_PAGE_SIZE - EEPROM_PAGE_OFFSET(blk_off);
118
119 if (maxlen > I2C_RXTX_LEN)
120 maxlen = I2C_RXTX_LEN;
121
122 if (len > maxlen)
123 len = maxlen;
124#endif
125
126 return len;
127}
128
Marek Vasut91320882015-11-10 20:53:23 +0100129static int eeprom_rw_block(unsigned offset, uchar *addr, unsigned alen,
130 uchar *buffer, unsigned len, bool read)
131{
132 int ret = 0;
133
Simon Goldschmidt4f256172019-03-26 13:38:52 +0100134#if defined(CONFIG_DM_I2C)
Lukasz Majewski0c07a9b2018-11-21 23:40:43 +0100135 struct udevice *dev;
136
Simon Goldschmidt4f256172019-03-26 13:38:52 +0100137 ret = i2c_get_chip_for_busnum(eeprom_i2c_bus, addr[0],
Lukasz Majewski0c07a9b2018-11-21 23:40:43 +0100138 alen - 1, &dev);
139 if (ret) {
140 printf("%s: Cannot find udev for a bus %d\n", __func__,
Simon Goldschmidt4f256172019-03-26 13:38:52 +0100141 eeprom_i2c_bus);
Lukasz Majewski0c07a9b2018-11-21 23:40:43 +0100142 return CMD_RET_FAILURE;
143 }
144
145 if (read)
146 ret = dm_i2c_read(dev, offset, buffer, len);
147 else
148 ret = dm_i2c_write(dev, offset, buffer, len);
149
150#else /* Non DM I2C support - will be removed */
Marek Vasut91320882015-11-10 20:53:23 +0100151
152 if (read)
153 ret = i2c_read(addr[0], offset, alen - 1, buffer, len);
154 else
155 ret = i2c_write(addr[0], offset, alen - 1, buffer, len);
Simon Goldschmidt4f256172019-03-26 13:38:52 +0100156#endif /* CONFIG_DM_I2C */
Lukasz Majewski0c07a9b2018-11-21 23:40:43 +0100157 if (ret)
158 ret = CMD_RET_FAILURE;
159
Marek Vasut91320882015-11-10 20:53:23 +0100160 return ret;
161}
162
Marek Vasut1a378892015-11-10 20:53:30 +0100163static int eeprom_rw(unsigned dev_addr, unsigned offset, uchar *buffer,
164 unsigned cnt, bool read)
wdenk38635852002-08-27 05:55:31 +0000165{
166 unsigned end = offset + cnt;
Marek Vasut1a378892015-11-10 20:53:30 +0100167 unsigned alen, len;
wdenk38635852002-08-27 05:55:31 +0000168 int rcode = 0;
Marek Vasut02c321c2015-11-10 20:53:24 +0100169 uchar addr[3];
wdenk38635852002-08-27 05:55:31 +0000170
Simon Goldschmidt4f256172019-03-26 13:38:52 +0100171#if defined(CONFIG_SYS_I2C_EEPROM_BUS)
172 eeprom_init(CONFIG_SYS_I2C_EEPROM_BUS);
173#endif
174
wdenk38635852002-08-27 05:55:31 +0000175 while (offset < end) {
Marek Vasut02c321c2015-11-10 20:53:24 +0100176 alen = eeprom_addr(dev_addr, offset, addr);
wdenk38635852002-08-27 05:55:31 +0000177
Marek Vasut39b6f982015-11-10 20:53:29 +0100178 len = eeprom_len(offset, end);
d4f5c722005-08-12 21:16:13 +0200179
Marek Vasut1a378892015-11-10 20:53:30 +0100180 rcode = eeprom_rw_block(offset, addr, alen, buffer, len, read);
Marek Vasut91320882015-11-10 20:53:23 +0100181
wdenk38635852002-08-27 05:55:31 +0000182 buffer += len;
183 offset += len;
Marek Vasut1a378892015-11-10 20:53:30 +0100184
185 if (!read)
186 udelay(CONFIG_SYS_EEPROM_PAGE_WRITE_DELAY_MS * 1000);
wdenk38635852002-08-27 05:55:31 +0000187 }
d4f5c722005-08-12 21:16:13 +0200188
wdenk38635852002-08-27 05:55:31 +0000189 return rcode;
190}
191
Marek Vasut1a378892015-11-10 20:53:30 +0100192int eeprom_read(unsigned dev_addr, unsigned offset, uchar *buffer, unsigned cnt)
wdenk38635852002-08-27 05:55:31 +0000193{
Marek Vasut1a378892015-11-10 20:53:30 +0100194 /*
195 * Read data until done or would cross a page boundary.
196 * We must write the address again when changing pages
197 * because the next page may be in a different device.
198 */
199 return eeprom_rw(dev_addr, offset, buffer, cnt, 1);
200}
201
Marek Vasutd4e69e62015-11-10 20:53:33 +0100202int eeprom_write(unsigned dev_addr, unsigned offset,
203 uchar *buffer, unsigned cnt)
Marek Vasut1a378892015-11-10 20:53:30 +0100204{
205 int ret;
wdenk38635852002-08-27 05:55:31 +0000206
Marek Vasut52cd47c2015-11-10 20:53:25 +0100207 eeprom_write_enable(dev_addr, 1);
208
Marek Vasut4f296d02015-11-10 20:53:18 +0100209 /*
210 * Write data until done or would cross a write page boundary.
wdenk38635852002-08-27 05:55:31 +0000211 * We must write the address again when changing pages
212 * because the address counter only increments within a page.
213 */
Alexey Brodkin52bc7c72015-12-14 18:45:34 +0300214 ret = eeprom_rw(dev_addr, offset, buffer, cnt, 0);
Marek Vasut52cd47c2015-11-10 20:53:25 +0100215
216 eeprom_write_enable(dev_addr, 0);
Marek Vasut1a378892015-11-10 20:53:30 +0100217 return ret;
wdenk38635852002-08-27 05:55:31 +0000218}
219
Nikita Kiryanovc40f0372016-04-16 17:55:11 +0300220static int parse_numeric_param(char *str)
221{
222 char *endptr;
223 int value = simple_strtol(str, &endptr, 16);
224
225 return (*endptr != '\0') ? -1 : value;
226}
227
228/**
229 * parse_i2c_bus_addr - parse the i2c bus and i2c devaddr parameters
230 *
231 * @i2c_bus: address to store the i2c bus
232 * @i2c_addr: address to store the device i2c address
233 * @argc: count of command line arguments left to parse
234 * @argv: command line arguments left to parse
235 * @argc_no_bus_addr: argc value we expect to see when bus & addr aren't given
236 *
237 * @returns: number of arguments parsed or CMD_RET_USAGE if error
238 */
239static int parse_i2c_bus_addr(int *i2c_bus, ulong *i2c_addr, int argc,
240 char * const argv[], int argc_no_bus_addr)
241{
242 int argc_no_bus = argc_no_bus_addr + 1;
243 int argc_bus_addr = argc_no_bus_addr + 2;
244
245#ifdef CONFIG_SYS_DEF_EEPROM_ADDR
246 if (argc == argc_no_bus_addr) {
247 *i2c_bus = -1;
248 *i2c_addr = CONFIG_SYS_DEF_EEPROM_ADDR;
249
250 return 0;
251 }
252#endif
253 if (argc == argc_no_bus) {
254 *i2c_bus = -1;
255 *i2c_addr = parse_numeric_param(argv[0]);
256
257 return 1;
258 }
259
260 if (argc == argc_bus_addr) {
261 *i2c_bus = parse_numeric_param(argv[0]);
262 *i2c_addr = parse_numeric_param(argv[1]);
263
264 return 2;
265 }
266
267 return CMD_RET_USAGE;
268}
269
Nikita Kiryanovaa9e6042016-04-16 17:55:03 +0300270#ifdef CONFIG_CMD_EEPROM_LAYOUT
Nikita Kiryanovaa9e6042016-04-16 17:55:03 +0300271
272__weak int eeprom_parse_layout_version(char *str)
273{
274 return LAYOUT_VERSION_UNRECOGNIZED;
275}
276
277static unsigned char eeprom_buf[CONFIG_SYS_EEPROM_SIZE];
278
Nikita Kiryanove7c27292016-04-16 17:55:12 +0300279#endif
280
Nikita Kiryanovaa9e6042016-04-16 17:55:03 +0300281enum eeprom_action {
Nikita Kiryanove7c27292016-04-16 17:55:12 +0300282 EEPROM_READ,
283 EEPROM_WRITE,
Nikita Kiryanovaa9e6042016-04-16 17:55:03 +0300284 EEPROM_PRINT,
285 EEPROM_UPDATE,
286 EEPROM_ACTION_INVALID,
287};
288
289static enum eeprom_action parse_action(char *cmd)
290{
Nikita Kiryanov3dc9be82016-04-16 17:55:13 +0300291 if (!strncmp(cmd, "read", 4))
292 return EEPROM_READ;
293 if (!strncmp(cmd, "write", 5))
294 return EEPROM_WRITE;
295#ifdef CONFIG_CMD_EEPROM_LAYOUT
Nikita Kiryanovaa9e6042016-04-16 17:55:03 +0300296 if (!strncmp(cmd, "print", 5))
297 return EEPROM_PRINT;
298 if (!strncmp(cmd, "update", 6))
299 return EEPROM_UPDATE;
Nikita Kiryanov3dc9be82016-04-16 17:55:13 +0300300#endif
Nikita Kiryanovaa9e6042016-04-16 17:55:03 +0300301
302 return EEPROM_ACTION_INVALID;
303}
304
Nikita Kiryanovaa9e6042016-04-16 17:55:03 +0300305static int eeprom_execute_command(enum eeprom_action action, int i2c_bus,
Nikita Kiryanove7c27292016-04-16 17:55:12 +0300306 ulong i2c_addr, int layout_ver, char *key,
307 char *value, ulong addr, ulong off, ulong cnt)
Nikita Kiryanovaa9e6042016-04-16 17:55:03 +0300308{
Nikita Kiryanove7c27292016-04-16 17:55:12 +0300309 int rcode = 0;
310 const char *const fmt =
Klaus H. Sorensen6478a7e2019-12-11 11:18:29 +0000311 "\nEEPROM @0x%lX %s: addr 0x%08lx off 0x%04lx count %ld ... ";
Nikita Kiryanove7c27292016-04-16 17:55:12 +0300312#ifdef CONFIG_CMD_EEPROM_LAYOUT
Nikita Kiryanovaa9e6042016-04-16 17:55:03 +0300313 struct eeprom_layout layout;
Nikita Kiryanove7c27292016-04-16 17:55:12 +0300314#endif
Nikita Kiryanovaa9e6042016-04-16 17:55:03 +0300315
316 if (action == EEPROM_ACTION_INVALID)
317 return CMD_RET_USAGE;
318
319 eeprom_init(i2c_bus);
Nikita Kiryanove7c27292016-04-16 17:55:12 +0300320 if (action == EEPROM_READ) {
321 printf(fmt, i2c_addr, "read", addr, off, cnt);
322
323 rcode = eeprom_read(i2c_addr, off, (uchar *)addr, cnt);
324
325 puts("done\n");
326 return rcode;
327 } else if (action == EEPROM_WRITE) {
328 printf(fmt, i2c_addr, "write", addr, off, cnt);
329
330 rcode = eeprom_write(i2c_addr, off, (uchar *)addr, cnt);
331
332 puts("done\n");
333 return rcode;
334 }
335
336#ifdef CONFIG_CMD_EEPROM_LAYOUT
Nikita Kiryanovaa9e6042016-04-16 17:55:03 +0300337 rcode = eeprom_read(i2c_addr, 0, eeprom_buf, CONFIG_SYS_EEPROM_SIZE);
338 if (rcode < 0)
339 return rcode;
340
341 eeprom_layout_setup(&layout, eeprom_buf, CONFIG_SYS_EEPROM_SIZE,
342 layout_ver);
343
344 if (action == EEPROM_PRINT) {
345 layout.print(&layout);
346 return 0;
347 }
348
349 layout.update(&layout, key, value);
350
351 rcode = eeprom_write(i2c_addr, 0, layout.data, CONFIG_SYS_EEPROM_SIZE);
Nikita Kiryanove7c27292016-04-16 17:55:12 +0300352#endif
Nikita Kiryanovaa9e6042016-04-16 17:55:03 +0300353
354 return rcode;
355}
356
357#define NEXT_PARAM(argc, index) { (argc)--; (index)++; }
Nikita Kiryanov3dc9be82016-04-16 17:55:13 +0300358int do_eeprom(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
Nikita Kiryanovaa9e6042016-04-16 17:55:03 +0300359{
360 int layout_ver = LAYOUT_VERSION_AUTODETECT;
361 enum eeprom_action action = EEPROM_ACTION_INVALID;
Nikita Kiryanov3dc9be82016-04-16 17:55:13 +0300362 int i2c_bus = -1, index = 0;
363 ulong i2c_addr = -1, addr = 0, cnt = 0, off = 0;
364 int ret;
Nikita Kiryanovaa9e6042016-04-16 17:55:03 +0300365 char *field_name = "";
366 char *field_value = "";
367
368 if (argc <= 1)
369 return CMD_RET_USAGE;
370
371 NEXT_PARAM(argc, index); /* Skip program name */
372
373 action = parse_action(argv[index]);
374 NEXT_PARAM(argc, index);
375
Nikita Kiryanov3dc9be82016-04-16 17:55:13 +0300376 if (action == EEPROM_ACTION_INVALID)
Nikita Kiryanovaa9e6042016-04-16 17:55:03 +0300377 return CMD_RET_USAGE;
378
Nikita Kiryanov3dc9be82016-04-16 17:55:13 +0300379#ifdef CONFIG_CMD_EEPROM_LAYOUT
380 if (action == EEPROM_PRINT || action == EEPROM_UPDATE) {
381 if (!strcmp(argv[index], "-l")) {
382 NEXT_PARAM(argc, index);
383 layout_ver = eeprom_parse_layout_version(argv[index]);
384 NEXT_PARAM(argc, index);
385 }
386 }
387#endif
Nikita Kiryanovaa9e6042016-04-16 17:55:03 +0300388
Nikita Kiryanov3dc9be82016-04-16 17:55:13 +0300389 switch (action) {
390 case EEPROM_READ:
391 case EEPROM_WRITE:
392 ret = parse_i2c_bus_addr(&i2c_bus, &i2c_addr, argc,
393 argv + index, 3);
394 break;
395 case EEPROM_PRINT:
396 ret = parse_i2c_bus_addr(&i2c_bus, &i2c_addr, argc,
397 argv + index, 0);
398 break;
399 case EEPROM_UPDATE:
400 ret = parse_i2c_bus_addr(&i2c_bus, &i2c_addr, argc,
401 argv + index, 2);
402 break;
403 default:
404 /* Get compiler to stop whining */
405 return CMD_RET_USAGE;
Nikita Kiryanovaa9e6042016-04-16 17:55:03 +0300406 }
407
Nikita Kiryanov3dc9be82016-04-16 17:55:13 +0300408 if (ret == CMD_RET_USAGE)
409 return ret;
Nikita Kiryanovaa9e6042016-04-16 17:55:03 +0300410
Nikita Kiryanov3dc9be82016-04-16 17:55:13 +0300411 while (ret--)
412 NEXT_PARAM(argc, index);
Nikita Kiryanovaa9e6042016-04-16 17:55:03 +0300413
Nikita Kiryanov3dc9be82016-04-16 17:55:13 +0300414 if (action == EEPROM_READ || action == EEPROM_WRITE) {
415 addr = parse_numeric_param(argv[index]);
416 NEXT_PARAM(argc, index);
417 off = parse_numeric_param(argv[index]);
418 NEXT_PARAM(argc, index);
419 cnt = parse_numeric_param(argv[index]);
420 }
Nikita Kiryanovaa9e6042016-04-16 17:55:03 +0300421
Nikita Kiryanov3dc9be82016-04-16 17:55:13 +0300422#ifdef CONFIG_CMD_EEPROM_LAYOUT
423 if (action == EEPROM_UPDATE) {
Nikita Kiryanovaa9e6042016-04-16 17:55:03 +0300424 field_name = argv[index];
425 NEXT_PARAM(argc, index);
Nikita Kiryanovaa9e6042016-04-16 17:55:03 +0300426 field_value = argv[index];
427 NEXT_PARAM(argc, index);
428 }
Nikita Kiryanov3dc9be82016-04-16 17:55:13 +0300429#endif
Nikita Kiryanovaa9e6042016-04-16 17:55:03 +0300430
Nikita Kiryanovaa9e6042016-04-16 17:55:03 +0300431 return eeprom_execute_command(action, i2c_bus, i2c_addr, layout_ver,
Nikita Kiryanov3dc9be82016-04-16 17:55:13 +0300432 field_name, field_value, addr, off, cnt);
wdenk38635852002-08-27 05:55:31 +0000433}
Heiko Schocher548738b2010-01-07 08:55:40 +0100434
wdenk0d498392003-07-01 21:06:45 +0000435U_BOOT_CMD(
Nikita Kiryanovaa9e6042016-04-16 17:55:03 +0300436 eeprom, 8, 1, do_eeprom,
Peter Tyser2fb26042009-01-27 18:03:12 -0600437 "EEPROM sub-system",
Marek Vasutd4fec4e2015-11-10 20:53:32 +0100438 "read <bus> <devaddr> addr off cnt\n"
439 "eeprom write <bus> <devaddr> addr off cnt\n"
Wolfgang Denka89c33d2009-05-24 17:06:54 +0200440 " - read/write `cnt' bytes from `devaddr` EEPROM at offset `off'"
Nikita Kiryanovaa9e6042016-04-16 17:55:03 +0300441#ifdef CONFIG_CMD_EEPROM_LAYOUT
442 "\n"
Nikita Kiryanov3dc9be82016-04-16 17:55:13 +0300443 "eeprom print [-l <layout_version>] <bus> <devaddr>\n"
Nikita Kiryanovaa9e6042016-04-16 17:55:03 +0300444 " - Print layout fields and their data in human readable format\n"
Nikita Kiryanov3dc9be82016-04-16 17:55:13 +0300445 "eeprom update [-l <layout_version>] <bus> <devaddr> field_name field_value\n"
Nikita Kiryanovaa9e6042016-04-16 17:55:03 +0300446 " - Update a specific eeprom field with new data.\n"
447 " The new data must be written in the same human readable format as shown by the print command.\n"
448 "\n"
449 "LAYOUT VERSIONS\n"
450 "The -l option can be used to force the command to interpret the EEPROM data using the chosen layout.\n"
451 "If the -l option is omitted, the command will auto detect the layout based on the data in the EEPROM.\n"
452 "The values which can be provided with the -l option are:\n"
453 CONFIG_EEPROM_LAYOUT_HELP_STRING"\n"
454#endif
Jeroen Hofstee0e350f82014-06-23 00:22:08 +0200455)