diff options
author | Martin Braun <martin.braun@ettus.com> | 2017-05-12 14:27:59 -0700 |
---|---|---|
committer | Martin Braun <martin.braun@ettus.com> | 2017-12-22 15:03:53 -0800 |
commit | 9dee6175da45440997c8ed82fbf40f8f380dc4a7 (patch) | |
tree | ad791488d217c76f9187b318f026872f419939d5 /mpm/python/usrp_mpm/periph_manager | |
parent | ca1723c02ea3d30f1003840f6fc1350e39c97485 (diff) | |
download | uhd-9dee6175da45440997c8ed82fbf40f8f380dc4a7.tar.gz uhd-9dee6175da45440997c8ed82fbf40f8f380dc4a7.tar.bz2 uhd-9dee6175da45440997c8ed82fbf40f8f380dc4a7.zip |
mpm: Moved device and dboard init/deinit to their own methods
Also cleaned up some cruft.
Diffstat (limited to 'mpm/python/usrp_mpm/periph_manager')
-rw-r--r-- | mpm/python/usrp_mpm/periph_manager/base.py | 41 | ||||
-rw-r--r-- | mpm/python/usrp_mpm/periph_manager/n310.py | 35 |
2 files changed, 28 insertions, 48 deletions
diff --git a/mpm/python/usrp_mpm/periph_manager/base.py b/mpm/python/usrp_mpm/periph_manager/base.py index a6f69fd6d..ec0e4ed79 100644 --- a/mpm/python/usrp_mpm/periph_manager/base.py +++ b/mpm/python/usrp_mpm/periph_manager/base.py @@ -336,19 +336,34 @@ class PeriphManagerBase(object): self.log.info("Found {} daughterboard(s).".format(len(self.dboards))) # self.overlays = "" - # self._dboard_eeproms = {} - # self.log.debug("Initializing dboards") - # # for dboard_slot, eeprom_addr in self.dboard_eeprom_addrs.iteritems(): - # # self.log.debug("Adding dboard for slot {0}".format(dboard_slot)) - # # spi_devices = [] - # # # I know EEPROM adresses for my dboard slots - # # eeprom_data = EEPROM().read_eeprom(get_eeprom_paths(eeprom_addr)) - # # # I know spidev masters on the dboard slots - # # hw_pid = eeprom_data[0].get("hw_pid", 0) - # # if hw_pid in dboard_manager.HW_PIDS: - # # spi_devices = get_spidev_nodes(self.dboard_spimaster_addrs.get(dboard_slot)) - # # dboard = dboard_manager.HW_PIDS.get(hw_pid, dboard_manager.unknown) - # # self.dboards.update({dboard_slot: dboard(spi_devices, eeprom_data)}) + + def init(self, args): + """ + Run the mboard initialization. This is typically done at the beginning + of a UHD session. + Default behaviour is to call init() on all the daughterboards.`args' is + passed to the daughterboard's init calls. For additional features, + this needs to be overridden. + + args -- A dictionary of args for initialization. Similar to device args + in UHD. + """ + self.log.info("Mboard init() called with device args `{}'.".format( + ",".join(['{}={}'.format(x, args[x]) for x in args]) + )) + self.log.debug("Initializing dboards...") + for dboard in self.dboards: + dboard.init(args) + + def deinit(self): + """ + Power down a device after a UHD session. + This must be safe to call multiple times. The default behaviour is to + call deinit() on all the daughterboards. + """ + self.log.info("Mboard deinit() called.") + for dboard in self.dboards: + dboard.deinit() def safe_list_updateable_components(self): """ diff --git a/mpm/python/usrp_mpm/periph_manager/n310.py b/mpm/python/usrp_mpm/periph_manager/n310.py index 59eb7da94..1d2e23b91 100644 --- a/mpm/python/usrp_mpm/periph_manager/n310.py +++ b/mpm/python/usrp_mpm/periph_manager/n310.py @@ -126,46 +126,11 @@ class n310(PeriphManagerBase): self.set_clock_source(N3XX_DEFAULT_CLOCK_SOURCE) - # data = self._read_eeprom_v1(self._eeprom_rawdata) - # mac 0: mgmt port, mac1: sfp0, mac2: sfp1 - # self.interfaces["mgmt"] = { - # "mac_addr": byte_to_mac(data[0]), - # "addrs": get_iface_addrs(byte_to_mac(data[0])) - # } - # self.interfaces["sfp0"] = { - # "mac_addr": byte_to_mac(data[1]), - # "addrs": get_iface_addrs(byte_to_mac(data[1])) - # } - # self.interfaces["sfp1"] = { - # "mac_addr": byte_to_mac(data[2]), - # "addrs": get_iface_addrs(byte_to_mac(data[2])) - # } - # self.mboard_info["serial"] = data[0] # some format self.mboard_info["serial"] = '123' # some format with open("/sys/class/rfnoc_crossbar/crossbar0/local_addr", "w") as xbar: xbar.write("0x2") # if header.get("dataversion", 0) == 1: - # Initialize our daughterboards: - self.log.debug("Initializing dboards...") - for dboard in self.dboards: - dboard.init_device() - - def _read_eeprom_v1(self, data): - """ - read eeprom with data version 1 - """ - # data contains - # 24 bytes header -> ignore them here - # 8 bytes serial - # 6 bytes mac_addr0 - # 2 bytes pad - # 6 bytes mac_addr1 - # 2 bytes pad - # 6 bytes mac_addr2 - # 2 bytes pad - # 4 bytes CRC - return struct.unpack_from("!28x 8s 6s 2x 6s 2x 6s 2x I", data) def get_interfaces(self): """ |