diff options
author | Martin Braun <martin.braun@ettus.com> | 2017-12-12 10:40:46 -0800 |
---|---|---|
committer | Martin Braun <martin.braun@ettus.com> | 2017-12-22 15:05:58 -0800 |
commit | fadf6e2ebaa12cfd89942a57efbe60e8e56bff77 (patch) | |
tree | 5fa469ce04b4ef39635bf00fb5e961846acf45e0 /mpm/python/usrp_mpm | |
parent | 881509874737cabc0097d51566fc72a6ea1d521c (diff) | |
download | uhd-fadf6e2ebaa12cfd89942a57efbe60e8e56bff77.tar.gz uhd-fadf6e2ebaa12cfd89942a57efbe60e8e56bff77.tar.bz2 uhd-fadf6e2ebaa12cfd89942a57efbe60e8e56bff77.zip |
mpm: mg: Fix lookup of user EEPROM map
For unknown revs, this now scales back to the last known rev.
Reviewed-By: Trung Tran <trung.tran@ettus.com>
Diffstat (limited to 'mpm/python/usrp_mpm')
-rw-r--r-- | mpm/python/usrp_mpm/dboard_manager/magnesium.py | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/mpm/python/usrp_mpm/dboard_manager/magnesium.py b/mpm/python/usrp_mpm/dboard_manager/magnesium.py index c17e5db27..8645ec9f6 100644 --- a/mpm/python/usrp_mpm/dboard_manager/magnesium.py +++ b/mpm/python/usrp_mpm/dboard_manager/magnesium.py @@ -285,6 +285,9 @@ class Magnesium(DboardManagerBase): base_i2c_adapter = '/sys/class/i2c-adapter' # Map I2C channel to slot index i2c_chan_map = {0: 'i2c-9', 1: 'i2c-10'} + # This map describes how the user data is stored in EEPROM. If a dboard rev + # changes the way the EEPROM is used, we add a new entry. If a dboard rev + # is not found in the map, then we go backward until we find a suitable rev user_eeprom = { 2: { # RevC 'label': "e0004000.i2c", @@ -349,7 +352,7 @@ class Magnesium(DboardManagerBase): self.log.trace("Loaded C++ drivers.") self._init_myk_api(self.mykonos) self.eeprom_fs, self.eeprom_path = self._init_user_eeprom( - self.user_eeprom[self.rev] + self._get_user_eeprom_info(self.rev) ) self.log.trace("Loading SPI devices...") self._spi_ifaces = { @@ -404,6 +407,20 @@ class Magnesium(DboardManagerBase): self.log.trace("adding {}".format(method)) setattr(self, method, export_method(myk, method)) + def _get_user_eeprom_info(self, rev): + """ + Return an EEPROM access map (from self.user_eeprom) based on the rev. + """ + rev_for_lookup = rev + while rev_for_lookup not in self.user_eeprom: + if rev_for_lookup < 0: + raise RuntimeError("Could not find a user EEPROM map for " + "revision %d!", rev) + rev_for_lookup -= 1 + assert rev_for_lookup in self.user_eeprom, \ + "Invalid EEPROM lookup rev!" + return self.user_eeprom[rev_for_lookup] + def _init_user_eeprom(self, eeprom_info): """ Reads out user-data EEPROM, and intializes a BufferFS object from that. |