aboutsummaryrefslogtreecommitdiffstats
path: root/mpm/tools/eeprom.h
diff options
context:
space:
mode:
authorMartin Braun <martin.braun@ettus.com>2018-01-12 17:11:05 -0800
committerMartin Braun <martin.braun@ettus.com>2018-01-12 17:30:53 -0800
commitdeccab5a1b90df299b7b194bfef9da046f8f319b (patch)
treedac633f8e1fdabc370ff6bbacbf53d22332f260c /mpm/tools/eeprom.h
parentefc0b22f7ea9b808512cb59a5a52202adf84b6e1 (diff)
downloaduhd-deccab5a1b90df299b7b194bfef9da046f8f319b.tar.gz
uhd-deccab5a1b90df299b7b194bfef9da046f8f319b.tar.bz2
uhd-deccab5a1b90df299b7b194bfef9da046f8f319b.zip
mpm: Add EEPROM utilities for N310
Actually-written-by: Moritz Fischer <moritz.fischer@ettus.com>
Diffstat (limited to 'mpm/tools/eeprom.h')
-rw-r--r--mpm/tools/eeprom.h82
1 files changed, 82 insertions, 0 deletions
diff --git a/mpm/tools/eeprom.h b/mpm/tools/eeprom.h
new file mode 100644
index 000000000..9b8ef15fb
--- /dev/null
+++ b/mpm/tools/eeprom.h
@@ -0,0 +1,82 @@
+//
+// Copyright 2017 Ettus Research, a National Instruments Company
+//
+// SPDX-License-Identifier: GPL-3.0
+//
+
+#ifndef EEPROM_H
+#define EEPROM_H
+
+#include <arpa/inet.h>
+
+typedef uint32_t u32;
+typedef uint16_t u16;
+typedef uint8_t u8;
+
+#define ETH_ALEN 6
+
+/* TODO: Come up with a smarter way to do this when we start using this on
+ * another device */
+#define NVMEM_PATH_SLOT_A "/sys/bus/nvmem/devices/9-00500/nvmem"
+#define NVMEM_PATH_SLOT_B "/sys/bus/nvmem/devices/10-00500/nvmem"
+#define NVMEM_PATH_MB "/sys/bus/nvmem/devices/2-00500/nvmem"
+
+struct usrp_sulfur_eeprom {
+ u32 magic;
+ u32 version;
+ u32 mcu_flags[4];
+ u16 pid;
+ u16 rev;
+ u8 serial[8];
+ u8 eth_addr0[ETH_ALEN];
+ u8 __pad_0[2];
+ u8 eth_addr1[ETH_ALEN];
+ u8 __pad_1[2];
+ u8 eth_addr2[ETH_ALEN];
+ u8 __pad_2[2];
+ u32 crc;
+} __attribute__((packed));
+
+struct usrp_sulfur_db_eeprom {
+ u32 magic;
+ u32 version;
+ u16 pid;
+ u16 rev;
+ u8 serial[8];
+ u32 crc;
+
+} __attribute__((packed));
+
+/* Motherboard EEPROM stuff */
+struct usrp_sulfur_eeprom *usrp_sulfur_eeprom_new(const u32 *mcu_flags,
+ const u16 pid,
+ const u16 rev,
+ const u8 *serial,
+ const char *eth_addr0,
+ const char *eth_addr1,
+ const char *eth_addr2);
+
+void usrp_sulfur_eeprom_to_i2c(struct usrp_sulfur_eeprom *ep, const char *path);
+
+void usrp_sulfur_eeprom_to_file(struct usrp_sulfur_eeprom *ep,
+ const char *path);
+
+void usrp_sulfur_eeprom_recrc(struct usrp_sulfur_eeprom *ep);
+
+struct usrp_sulfur_eeprom *usrp_sulfur_eeprom_from_file(const char *path);
+
+void usrp_sulfur_eeprom_print(const struct usrp_sulfur_eeprom *ep);
+
+/* Daughterboard EEPROM stuff */
+struct usrp_sulfur_db_eeprom *usrp_sulfur_db_eeprom_new(const u16 pid,
+ const u16 rev,
+ const u8 *serial);
+
+void usrp_sulfur_db_eeprom_to_file(struct usrp_sulfur_db_eeprom *ep,
+ const char *path);
+
+struct usrp_sulfur_db_eeprom *usrp_sulfur_db_eeprom_from_file(const char *path);
+
+void usrp_sulfur_db_eeprom_print(const struct usrp_sulfur_db_eeprom *ep);
+
+#endif /* EEPROM_H */