diff options
Diffstat (limited to 'mpm')
-rw-r--r-- | mpm/python/usrp_mpm/periph_manager/base.py | 52 | ||||
-rw-r--r-- | mpm/python/usrp_mpm/periph_manager/e320.py | 4 | ||||
-rw-r--r-- | mpm/python/usrp_mpm/periph_manager/n3xx.py | 53 |
3 files changed, 64 insertions, 45 deletions
diff --git a/mpm/python/usrp_mpm/periph_manager/base.py b/mpm/python/usrp_mpm/periph_manager/base.py index 1206289b9..2dc69e908 100644 --- a/mpm/python/usrp_mpm/periph_manager/base.py +++ b/mpm/python/usrp_mpm/periph_manager/base.py @@ -169,11 +169,12 @@ class PeriphManagerBase(object): ########################################################################### # Device initialization (at MPM startup) ########################################################################### - def __init__(self, args): + def __init__(self): # Note: args is a dictionary. assert len(self.pids) > 0 assert self.mboard_eeprom_magic is not None self.dboards = [] + self._default_args = "" # Set up logging self.log = get_logger('PeriphManager') self.claimed = False @@ -183,36 +184,47 @@ class PeriphManagerBase(object): self.mboard_info = self._get_mboard_info(self._eeprom_head) self.log.info("Device serial number: {}" .format(self.mboard_info.get('serial', 'n/a'))) - dboard_infos = self._get_dboard_eeprom_info() + self.dboard_infos = self._get_dboard_eeprom_info() self.device_info = \ self.generate_device_info( self._eeprom_head, self.mboard_info, - dboard_infos + self.dboard_infos ) - self._default_args = self._update_default_args(args) - self.log.debug("Using default args: {}".format(self._default_args)) - self._init_mboard_overlays() - override_db_pids_str = self._default_args.get('override_db_pids') - if override_db_pids_str: - override_db_pids = [ - int(x, 0) for x in override_db_pids_str.split(",") - ] - else: - override_db_pids = [] - self._init_dboards( - dboard_infos, - override_db_pids, - self._default_args - ) - self._device_initialized = True - self._initialization_status = "No errors." except Exception as ex: self.log.error("Failed to initialize device: %s", str(ex)) self._device_initialized = False self._initialization_status = str(ex) super(PeriphManagerBase, self).__init__() + def overlay_apply(self): + """ + Apply FPGA overlay + """ + self._init_mboard_overlays() + + def init_dboards(self, args): + """ + Run full initialization of daugther boards if they're exist + Using 'override_db_pids' args to overwrite number of dboards that need to be init. + """ + self._default_args = self._update_default_args(args) + self.log.debug("Using default args: {}".format(self._default_args)) + override_db_pids_str = self._default_args.get('override_db_pids') + if override_db_pids_str: + override_db_pids = [ + int(x, 0) for x in override_db_pids_str.split(",") + ] + else: + override_db_pids = [] + self._init_dboards( + self.dboard_infos, + override_db_pids, + self._default_args + ) + self._device_initialized = True + self._initialization_status = "No errors." + def _read_mboard_eeprom(self): """ Read out mboard EEPROM. diff --git a/mpm/python/usrp_mpm/periph_manager/e320.py b/mpm/python/usrp_mpm/periph_manager/e320.py index d60b7c110..dbcaead2a 100644 --- a/mpm/python/usrp_mpm/periph_manager/e320.py +++ b/mpm/python/usrp_mpm/periph_manager/e320.py @@ -128,7 +128,9 @@ class e320(ZynqComponents, PeriphManagerBase): # Ctor and device initialization tasks ########################################################################### def __init__(self, args): - super(e320, self).__init__(args) + super(e320, self).__init__() + self.overlay_apply() + self.init_dboards(args) if not self._device_initialized: # Don't try and figure out what's going on. Just give up. return diff --git a/mpm/python/usrp_mpm/periph_manager/n3xx.py b/mpm/python/usrp_mpm/periph_manager/n3xx.py index b018d055e..cd80d0d33 100644 --- a/mpm/python/usrp_mpm/periph_manager/n3xx.py +++ b/mpm/python/usrp_mpm/periph_manager/n3xx.py @@ -219,11 +219,36 @@ class n3xx(ZynqComponents, PeriphManagerBase): self._available_endpoints = list(range(256)) self._bp_leds = None self._gpsd = None - super(n3xx, self).__init__(args) - if not self._device_initialized: - # Don't try and figure out what's going on. Just give up. - return + super(n3xx, self).__init__() try: + # Init peripherals + # these peripherals are specific to mboard and + # need to configured before applying fpga overlay + self._gpios = TCA6424(int(self.mboard_info['rev'])) + self.log.trace("Enabling power of MGT156MHZ clk") + self._gpios.set("PWREN-CLK-MGT156MHz") + self.enable_1g_ref_clock() + self.enable_wr_ref_clock() + self.enable_gps( + enable=str2bool( + args.get('enable_gps', N3XX_DEFAULT_ENABLE_GPS) + ) + ) + self.enable_fp_gpio( + enable=str2bool( + args.get( + 'enable_fp_gpio', + N3XX_DEFAULT_ENABLE_FPGPIO + ) + ) + ) + # Apply overlay + self.overlay_apply() + # Run dboards init + self.init_dboards(args) + if not self._device_initialized: + # Don't try and figure out what's going on. Just give up. + return self._init_peripherals(args) except Exception as ex: self.log.error("Failed to initialize motherboard: %s", str(ex)) @@ -317,28 +342,8 @@ class n3xx(ZynqComponents, PeriphManagerBase): # Sanity checks assert self.device_info.get('product') in self.product_map.values(), \ "Device product could not be determined!" - # Init peripherals - self.log.trace("Initializing TCA6424 port expander controls...") - self._gpios = TCA6424(int(self.mboard_info['rev'])) self.log.trace("Initializing back panel LED controls...") self._bp_leds = BackpanelGPIO() - self.log.trace("Enabling power of MGT156MHZ clk") - self._gpios.set("PWREN-CLK-MGT156MHz") - self.enable_1g_ref_clock() - self.enable_wr_ref_clock() - self.enable_gps( - enable=str2bool( - args.get('enable_gps', N3XX_DEFAULT_ENABLE_GPS) - ) - ) - self.enable_fp_gpio( - enable=str2bool( - args.get( - 'enable_fp_gpio', - N3XX_DEFAULT_ENABLE_FPGPIO - ) - ) - ) # Init Mboard Regs self.mboard_regs_control = MboardRegsControl( self.mboard_regs_label, self.log) |