public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
* [U-Boot-Users] [patch] add support for "eeprom info"
@ 2008-01-23 16:13 Mike Frysinger
  2008-01-23 21:06 ` Wolfgang Denk
  0 siblings, 1 reply; 18+ messages in thread
From: Mike Frysinger @ 2008-01-23 16:13 UTC (permalink / raw)
  To: u-boot

This patch adds a new sub command to eeprom called "info".  This allows eeprom
driver writers to implement a way of querying the device.  For example, SPI
flashes have status commands, jedec ids, part ids, and other fun stuff.  It's
useful to be able to quickly probe this data (so you know things are detected
properly and all that jazz).

For example, on Blackfin boards, you can do:
bfin> eeprom info
SPI Device: m25p128 0x20 (ST) 0x20 0x18
Parameters: num sectors = 64, sector size = 262144, write size = 256
Flash Size: 128 mbit (16 mbyte)
Status: 0x00

I made the function weak so that people aren't required to implement this
function (mostly so that it does not break all the SPI drivers out there right
now).

Signed-off-by: Mike Frysinger <vapier@gentoo.org>
---
diff --git a/common/cmd_eeprom.c b/common/cmd_eeprom.c
index e5000e9..cc8c277 100644
--- a/common/cmd_eeprom.c
+++ b/common/cmd_eeprom.c
@@ -49,6 +49,7 @@ extern int  eeprom_read  (unsigned dev_addr, unsigned offset,
 			  uchar *buffer, unsigned cnt);
 extern int  eeprom_write (unsigned dev_addr, unsigned offset,
 			  uchar *buffer, unsigned cnt);
+extern int  eeprom_info (void) __attribute__((weak));
 #if defined(CFG_EEPROM_WREN)
 extern int eeprom_write_enable (unsigned dev_addr, int state);
 #endif
@@ -104,7 +105,8 @@ int do_eeprom ( cmd_tbl_t * cmdtp, int flag, int argc, char *argv[])
 
 			puts ("done\n");
 			return rcode;
-		}
+		} else if (argc == 2 && eeprom_info && strcmp (argv[1], "info") == 0)
+			return eeprom_info ();
 	}
 
 	printf ("Usage:\n%s\n", cmdtp->usage);
@@ -435,6 +437,7 @@ U_BOOT_CMD(
 	"read  devaddr addr off cnt\n"
 	"eeprom write devaddr addr off cnt\n"
 	"       - read/write `cnt' bytes from `devaddr` EEPROM at offset `off'\n"
+	"eeprom info\n"
 );
 #else /* One EEPROM */
 U_BOOT_CMD(
@@ -443,6 +446,7 @@ U_BOOT_CMD(
 	"read  addr off cnt\n"
 	"eeprom write addr off cnt\n"
 	"       - read/write `cnt' bytes at EEPROM offset `off'\n"
+	"eeprom info\n"
 );
 #endif /* CFG_I2C_MULTI_EEPROMS */
 
diff --git a/include/common.h b/include/common.h
index 54083f1..511e2f6 100644
--- a/include/common.h
+++ b/include/common.h
@@ -298,6 +298,7 @@ int  eeprom_probe (unsigned dev_addr, unsigned offset);
 #endif
 int  eeprom_read  (unsigned dev_addr, unsigned offset, uchar *buffer, unsigned cnt);
 int  eeprom_write (unsigned dev_addr, unsigned offset, uchar *buffer, unsigned cnt);
+int  eeprom_info  (void) __attribute__((weak)); /* optional interface */
 #ifdef CONFIG_LWMON
 extern uchar pic_read  (uchar reg);
 extern void  pic_write (uchar reg, uchar val);

^ permalink raw reply related	[flat|nested] 18+ messages in thread

end of thread, other threads:[~2008-01-25 17:21 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-01-23 16:13 [U-Boot-Users] [patch] add support for "eeprom info" Mike Frysinger
2008-01-23 21:06 ` Wolfgang Denk
2008-01-23 21:15   ` Mike Frysinger
2008-01-23 21:23     ` Wolfgang Denk
2008-01-23 22:29       ` Mike Frysinger
2008-01-24  0:44         ` Wolfgang Denk
2008-01-24  3:39           ` Mike Frysinger
2008-01-24  4:24             ` Ben Warren
2008-01-24  5:17               ` Mike Frysinger
2008-01-24 11:13                 ` Wolfgang Denk
2008-01-25 13:31                   ` Mike Frysinger
2008-01-24  9:13           ` Mike Frysinger
2008-01-24 11:31             ` Wolfgang Denk
2008-01-25 13:33               ` Mike Frysinger
2008-01-25 15:09                 ` Wolfgang Denk
2008-01-25 16:02                   ` Mike Frysinger
2008-01-25 16:54                     ` J. William Campbell
2008-01-25 17:21                       ` Mike Frysinger

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox