From 93617aa25cc0ec62cbdbf9cdb41ec11fcc29f2b3 Mon Sep 17 00:00:00 2001 From: Brent Stapleton Date: Tue, 20 Mar 2018 15:13:14 -0700 Subject: mpm: Adding offset to EEPROM reads Adding address offset to all MBoard and DBoard EEPROM reads. This matches what we're doing for the user portion of the EEPROM, and allows us to share access to an EEPROM. --- mpm/python/usrp_mpm/eeprom.py | 3 ++- mpm/python/usrp_mpm/periph_manager/base.py | 14 ++++++++++++++ mpm/python/usrp_mpm/periph_manager/n3xx.py | 2 ++ 3 files changed, 18 insertions(+), 1 deletion(-) (limited to 'mpm') diff --git a/mpm/python/usrp_mpm/eeprom.py b/mpm/python/usrp_mpm/eeprom.py index 543823cbb..79532f9f8 100644 --- a/mpm/python/usrp_mpm/eeprom.py +++ b/mpm/python/usrp_mpm/eeprom.py @@ -88,6 +88,7 @@ class DboardEEPROM(object): def read_eeprom( nvmem_path, + offset, eeprom_header_format, eeprom_header_keys, expected_magic, @@ -130,7 +131,7 @@ def read_eeprom( # Dawaj, dawaj max_size = max_size or -1 with open(nvmem_path, "rb") as nvmem_file: - data = nvmem_file.read(max_size) + data = nvmem_file.read(max_size)[offset:] eeprom_magic, eeprom_version = EEPROM_DEFAULT_HEADER.unpack_from(data) if eeprom_magic != expected_magic: raise RuntimeError( diff --git a/mpm/python/usrp_mpm/periph_manager/base.py b/mpm/python/usrp_mpm/periph_manager/base.py index f2b2aeb37..3ded0d3c2 100644 --- a/mpm/python/usrp_mpm/periph_manager/base.py +++ b/mpm/python/usrp_mpm/periph_manager/base.py @@ -62,6 +62,11 @@ class PeriphManagerBase(object): # If empty, this will be ignored and no EEPROM info for the device is read # out. mboard_eeprom_addr = "" + # Offset of the motherboard EEPROM. All accesses to this EEPROM will be + # offset by this amount. In many cases, this value will be 0. But in some + # situations, we may want to use the offset as a way of partitioning + # access to an EEPROM. + mboard_eeprom_offset = 0 # The EEPROM code checks for this word to see if the readout was valid. # Typically, devices should not override this unless their EEPROM follows a # different standard. @@ -96,6 +101,13 @@ class PeriphManagerBase(object): # out. # If this is a list of EEPROMs, paths will be concatenated. dboard_eeprom_addr = None + # Offset of the daughterboard EEPROM. All accesses to this EEPROM will be + # offset by this amount. In many cases, this value will be 0. But in some + # situations, we may want to use the offset as a way of partitioning + # access to an EEPROM. + # Assume that all dboard offsets are the same for a given device. That is, + # the offset of DBoard 0 == offset of DBoard 1 + dboard_eeprom_offset = 0 # The EEPROM code checks for this word to see if the readout was valid. # Typically, devices should not override this unless their EEPROM follows a # different standard. @@ -175,6 +187,7 @@ class PeriphManagerBase(object): .format(self.mboard_eeprom_addr)) (self._eeprom_head, self._eeprom_rawdata) = eeprom.read_eeprom( get_eeprom_paths(self.mboard_eeprom_addr)[0], + self.mboard_eeprom_offset, eeprom.MboardEEPROM.eeprom_header_format, eeprom.MboardEEPROM.eeprom_header_keys, self.mboard_eeprom_magic, @@ -298,6 +311,7 @@ class PeriphManagerBase(object): self.log.debug("Initializing dboard %d...", dboard_idx) dboard_eeprom_md, dboard_eeprom_rawdata = eeprom.read_eeprom( dboard_eeprom_path, + self.dboard_eeprom_offset, eeprom.DboardEEPROM.eeprom_header_format, eeprom.DboardEEPROM.eeprom_header_keys, self.dboard_eeprom_magic, diff --git a/mpm/python/usrp_mpm/periph_manager/n3xx.py b/mpm/python/usrp_mpm/periph_manager/n3xx.py index 6926ee1d7..373689521 100644 --- a/mpm/python/usrp_mpm/periph_manager/n3xx.py +++ b/mpm/python/usrp_mpm/periph_manager/n3xx.py @@ -458,6 +458,7 @@ class n3xx(PeriphManagerBase): description = "N300-Series Device" pids = {0x4242: 'n310', 0x4240: 'n300'} mboard_eeprom_addr = "e0005000.i2c" + mboard_eeprom_offset = 0 mboard_eeprom_max_len = 256 mboard_info = {"type": "n3xx", "product": "unknown", @@ -473,6 +474,7 @@ class n3xx(PeriphManagerBase): 'fan': 'get_fan_sensor', } dboard_eeprom_addr = "e0004000.i2c" + dboard_eeprom_offset = 0 dboard_eeprom_max_len = 64 # We're on a Zynq target, so the following two come from the Zynq standard -- cgit v1.2.3