aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMartin Braun <martin.braun@ettus.com>2017-05-23 16:23:42 -0700
committerMartin Braun <martin.braun@ettus.com>2017-12-22 15:03:53 -0800
commit7c9b8019063eee06d090bc0e3c26d340c3f1d9a8 (patch)
tree5db665348ef415f9601d2487d485bd0d6628dc0c
parent5926f1b9d9f67856dac2849e9ce9961220e4e0c1 (diff)
downloaduhd-7c9b8019063eee06d090bc0e3c26d340c3f1d9a8.tar.gz
uhd-7c9b8019063eee06d090bc0e3c26d340c3f1d9a8.tar.bz2
uhd-7c9b8019063eee06d090bc0e3c26d340c3f1d9a8.zip
mpm: Made overlay selection a static method for more flexibility
-rw-r--r--mpm/python/usrp_mpm/dboard_manager/base.py19
-rw-r--r--mpm/python/usrp_mpm/dboard_manager/eiscat.py15
-rw-r--r--mpm/python/usrp_mpm/periph_manager/base.py12
3 files changed, 35 insertions, 11 deletions
diff --git a/mpm/python/usrp_mpm/dboard_manager/base.py b/mpm/python/usrp_mpm/dboard_manager/base.py
index e16906cb4..cc18292c1 100644
--- a/mpm/python/usrp_mpm/dboard_manager/base.py
+++ b/mpm/python/usrp_mpm/dboard_manager/base.py
@@ -38,12 +38,19 @@ class DboardManagerBase(object):
# maps these keys to actual spidev paths. Also throws a warning/error if
# the SPI configuration is invalid.
spi_chipselect = {}
- # Lists device tree overlays that need to be applied before this class can
- # be used. List of strings. If strings contain the token {sfp}, it will be
- # expanded to the flavour of SFP configuration is (XG, 1G, ...).
- # Example: 'magnesium-{sfp}' could get expanded to 'eiscat-XG'.
- # Are applied in order.
- dt_overlays = []
+ @staticmethod
+ def list_required_dt_overlays(eeprom_md, sfp_config, device_args):
+ """
+ Lists device tree overlays that need to be applied before this class can
+ be used. List of strings.
+ Are applied in order.
+
+ eeprom_md -- Dictionary of info read out from the dboard EEPROM
+ sfp_config -- A string identifying the configuration of the SFP ports.
+ Example: "XG", "HG", "XA", ...
+ device_args -- Arbitrary dictionary of info, typically user-defined
+ """
+ return []
def __init__(self, slot_idx, **kwargs):
self.log = get_logger('dboardManager')
diff --git a/mpm/python/usrp_mpm/dboard_manager/eiscat.py b/mpm/python/usrp_mpm/dboard_manager/eiscat.py
index c0a5e2fb1..78dae0c1f 100644
--- a/mpm/python/usrp_mpm/dboard_manager/eiscat.py
+++ b/mpm/python/usrp_mpm/dboard_manager/eiscat.py
@@ -366,7 +366,20 @@ class EISCAT(DboardManagerBase):
"adc1": create_spidev_iface_sane,
"phase_dac": create_spidev_iface_phasedac,
}
- dt_overlays = ['eiscat-{sfp}']
+
+ @staticmethod
+ def list_required_dt_overlays(eeprom_md, sfp_config, device_args):
+ """
+ Lists device tree overlays that need to be applied before this class can
+ be used. List of strings.
+ Are applied in order.
+
+ eeprom_md -- Dictionary of info read out from the dboard EEPROM
+ sfp_config -- A string identifying the configuration of the SFP ports.
+ Example: "XG", "HG", "XA", ...
+ device_args -- Arbitrary dictionary of info, typically user-defined
+ """
+ return ['eiscat-{sfp}'.format(sfp=sfp_config)]
def __init__(self, slot_idx, **kwargs):
super(EISCAT, self).__init__(slot_idx, **kwargs)
diff --git a/mpm/python/usrp_mpm/periph_manager/base.py b/mpm/python/usrp_mpm/periph_manager/base.py
index 143243f7a..12c4f4e58 100644
--- a/mpm/python/usrp_mpm/periph_manager/base.py
+++ b/mpm/python/usrp_mpm/periph_manager/base.py
@@ -328,12 +328,16 @@ class PeriphManagerBase(object):
if db_class is None:
self.log.warning("Could not identify daughterboard class for PID {:04X}!".format(db_pid))
continue
+ requested_overlays = db_class.list_required_dt_overlays(
+ dboard_eeprom_md,
+ 'XG', # FIXME don't hardcode
+ {}, # FIXME don't hardcode
+ )
self.log.trace("Dboard requires device tree overlays: {}".format(
- db_class.dt_overlays
+ requested_overlays
))
- for overlay in db_class.dt_overlays:
- # FIXME don't hardcode XG
- dtoverlay.apply_overlay_safe(overlay.format(sfp="XG"))
+ for overlay in requested_overlays:
+ dtoverlay.apply_overlay_safe(overlay)
if len(self.dboard_spimaster_addrs) > dboard_idx:
spi_nodes = sorted(get_spidev_nodes(self.dboard_spimaster_addrs[dboard_idx]))
self.log.debug("Found spidev nodes: {0}".format(spi_nodes))