aboutsummaryrefslogtreecommitdiffstats
path: root/mpm/tools/eeprom.c
diff options
context:
space:
mode:
authorMoritz Fischer <moritz.fischer@ettus.com>2018-04-25 18:01:09 -0700
committerMartin Braun <martin.braun@ettus.com>2018-06-20 17:10:05 -0500
commit91a5518443f4ff938f67a2f1bd1b09b24bceecd5 (patch)
treeeb4adccd6d3c687d157d4a4073e76970a5ed0a69 /mpm/tools/eeprom.c
parent0935bf5c2a6952fd07bc4b6c618d12b0bd79ca78 (diff)
downloaduhd-91a5518443f4ff938f67a2f1bd1b09b24bceecd5.tar.gz
uhd-91a5518443f4ff938f67a2f1bd1b09b24bceecd5.tar.bz2
uhd-91a5518443f4ff938f67a2f1bd1b09b24bceecd5.zip
mpm: tools: Introduce dt-compat and mcu-compat fields
Introduce dt-compat and mcu-compat fields into the eeprom structure. For the motherboard eeprom this is straightforward, since there's still padding bytes that could be (ab)used for this. On the dboard side more creativity is required and the original revision field of 2 bytes is reduced to only one byte revision and one byte dt-compat. Since this will only affect new units being backwards compatible with older versions of the bootloader is not an issue. Reviewed-by: Brent Stapleton <brent.stapleton@ettus.com> Signed-off-by: Moritz Fischer <moritz.fischer@ettus.com>
Diffstat (limited to 'mpm/tools/eeprom.c')
-rw-r--r--mpm/tools/eeprom.c30
1 files changed, 23 insertions, 7 deletions
diff --git a/mpm/tools/eeprom.c b/mpm/tools/eeprom.c
index ce4c76277..c2bf3705e 100644
--- a/mpm/tools/eeprom.c
+++ b/mpm/tools/eeprom.c
@@ -31,8 +31,8 @@
static const u32 USRP_EEPROM_MAGIC = 0xF008AD10;
static const u32 USRP_EEPROM_DB_MAGIC = 0xF008AD11;
-static const u32 USRP_EEPROM_VERSION = 1;
-static const u32 USRP_EEPROM_DB_VERSION = 1;
+static const u32 USRP_EEPROM_VERSION = 2;
+static const u32 USRP_EEPROM_DB_VERSION = 2;
static const u32 USRP_EEPROM_DEFAULT_MCU_FLAGS[4] = {0x0, 0x0, 0x0, 0x0};
@@ -122,10 +122,12 @@ static int __eth_addr_parse(uint8_t *out, const char *in)
struct usrp_sulfur_eeprom *usrp_sulfur_eeprom_new(const u32 *mcu_flags,
const u16 pid,
const u16 rev,
- const u8 *serial,
+ const char *serial,
const char *eth_addr0,
const char *eth_addr1,
- const char *eth_addr2)
+ const char *eth_addr2,
+ const u16 dt_compat,
+ const u16 mcu_compat)
{
struct usrp_sulfur_eeprom *ep;
int i;
@@ -169,6 +171,9 @@ struct usrp_sulfur_eeprom *usrp_sulfur_eeprom_new(const u32 *mcu_flags,
if (eth_addr2)
__eth_addr_parse(ep->eth_addr2, eth_addr2);
+ ep->dt_compat = htons(dt_compat);
+ ep->mcu_compat = htons(mcu_compat);
+
ep->crc = htonl(crc32(0, &ep->magic, sizeof(*ep)-4));
return ep;
@@ -217,6 +222,10 @@ void usrp_sulfur_eeprom_print(const struct usrp_sulfur_eeprom *ep)
ep->eth_addr2[0], ep->eth_addr2[1], ep->eth_addr2[2],
ep->eth_addr2[3], ep->eth_addr2[4], ep->eth_addr2[5]);
+ if (ntohl(ep->version) == 2)
+ printf("-- DT-Compat/MCU-Compat: %04x %04x\n",
+ ntohs(ep->dt_compat), ntohs(ep->mcu_compat));
+
printf("-- CRC: %08x (%s)\n", ntohl(ep->crc),
__usrp_sulfur_eeprom_check_crc(ep) ? "matches": "doesn't match!");
}
@@ -400,7 +409,8 @@ void usrp_sulfur_eeprom_to_i2c(struct usrp_sulfur_eeprom *ep, const char *path)
struct usrp_sulfur_db_eeprom *usrp_sulfur_db_eeprom_new(const u16 pid,
const u16 rev,
- const u8 *serial)
+ const char *serial,
+ const u16 dt_compat)
{
struct usrp_sulfur_db_eeprom *ep;
int i;
@@ -418,7 +428,8 @@ struct usrp_sulfur_db_eeprom *usrp_sulfur_db_eeprom_new(const u16 pid,
ep->version = htonl(USRP_EEPROM_DB_VERSION);
ep->pid = htons(pid);
- ep->rev = htons(rev);
+ ep->rev.v2_rev.rev = rev;
+ ep->rev.v2_rev.dt_compat = dt_compat;
if (strlen(serial) > 8) {
fprintf(stderr, "Serial# too long\n");
@@ -476,8 +487,13 @@ void usrp_sulfur_db_eeprom_print(const struct usrp_sulfur_db_eeprom *ep)
return;
}
- printf("-- PID/REV: %04x %04x\n", ntohs(ep->pid), ntohs(ep->rev));
+ if (ntohl(ep->version) == 1)
+ printf("-- PID/REV: %04x %04x\n", ntohs(ep->pid), ntohs(ep->rev.v1_rev));
+ else
+ printf("-- PID/REV: %04x %02x\n", ntohs(ep->pid), ep->rev.v2_rev.rev);
printf("-- Serial: %s\n", ep->serial);
+ if (ntohl(ep->version) == 2)
+ printf("-- DT-Compat: %02x\n", ep->rev.v2_rev.dt_compat);
printf("-- CRC: %08x (%s)\n", ntohl(ep->crc),
__usrp_sulfur_db_eeprom_check_crc(ep) ? "matches": "doesn't match!");
}