Exemple #1
0
    def _init_peripherals(self, args):
        """
        Turn on all peripherals. This may throw an error on failure, so make
        sure to catch it.

        Periphals are initialized in the order of least likely to fail, to most
        likely.
        """
        # 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)
        self.mboard_regs_control.get_git_hash()
        self.mboard_regs_control.get_build_timestamp()
        self._check_fpga_compat()
        self._update_fpga_type()
        # Init clocking
        self.enable_ref_clock(enable=True)
        self._ext_clock_freq = None
        self._init_ref_clock_and_time(args)
        self._init_meas_clock()
        # Init CHDR transports
        self._xport_mgrs = {
            'udp': N3xxXportMgrUDP(self.log.getChild('UDP')),
            'liberio': N3xxXportMgrLiberio(self.log.getChild('liberio')),
        }
        # Spawn status monitoring thread
        self.log.trace("Spawning status monitor thread...")
        self._status_monitor_thread = threading.Thread(
            target=self._monitor_status,
            name="N3xxStatusMonitorThread",
            daemon=True,
        )
        self._status_monitor_thread.start()
        # Init complete.
        self.log.debug("Device info: {}".format(self.device_info))
Exemple #2
0
 def __init__(self, args):
     self._tear_down = False
     self._status_monitor_thread = None
     self._ext_clock_freq = None
     self._clock_source = None
     self._time_source = None
     self._bp_leds = None
     self._gpsd = None
     self._qsfp_retimer = None
     super(n3xx, self).__init__()
     try:
         # Init peripherals
         # these peripherals are specific to mboard and
         # need to configured before applying fpga overlay
         args = self._update_default_args(args)
         self._gpios = TCA6424(int(self.mboard_info['rev']))
         self.log.trace("Enabling power of MGT156MHZ clk")
         self._gpios.set("PWREN-CLK-MGT156MHz")
         self._gps_enabled = str2bool(
             args.get('enable_gps', N3XX_DEFAULT_ENABLE_GPS))
         if not self._gps_enabled:
             self.log.info("Disabling GPS (gpsdo reference and time/location data).")
         self.enable_1g_ref_clock()
         self.enable_wr_ref_clock()
         self.enable_gps(enable=self._gps_enabled)
         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 BaseException as ex:
         self.log.error("Failed to initialize motherboard: %s", str(ex))
         self._initialization_status = str(ex)
         self._device_initialized = False
     try:
         if not args.get('skip_boot_init', False):
             self.init(args)
     except BaseException as ex:
         self.log.warning("Failed to initialize device on boot: %s", str(ex))
Exemple #3
0
    def _init_peripherals(self, args):
        """
        Turn on all peripherals. This may throw an error on failure, so make
        sure to catch it.

        Periphals are initialized in the order of least likely to fail, to most
        likely.
        """
        # 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)
        self.mboard_regs_control.get_git_hash()
        self.mboard_regs_control.get_build_timestamp()
        self._check_fpga_compat()
        self._update_fpga_type()
        self.crossbar_base_port = self.mboard_regs_control.get_xbar_baseport()
        # Init clocking
        self.enable_ref_clock(enable=True)
        self._ext_clock_freq = None
        self._init_ref_clock_and_time(args)
        self._init_meas_clock()
        # Init GPSd iface and GPS sensors
        self._init_gps_sensors()
        # Init QSFP board (if available)
        qsfp_i2c = i2c_dev.of_get_i2c_adapter(N32X_QSFP_I2C_LABEL)
        if qsfp_i2c:
            self.log.debug("Creating QSFP Retimer control object...")
            self._qsfp_retimer = RetimerQSFP(qsfp_i2c)
            self._qsfp_retimer.set_rate_preset(N32X_DEFAULT_QSFP_RATE_PRESET)
            self._qsfp_retimer.set_driver_preset(N32X_DEFAULT_QSFP_DRIVER_PRESET)
        elif self.device_info['product'] == 'n320':
            # If we have an N320, we should also have the QSFP board, but we
            # won't freak out if we can't find it. Maybe someone removed or
            # disabled it.
            self.log.warning("No QSFP board detected!")
        # Init CHDR transports
        self._xport_mgrs = {
            'udp': N3xxXportMgrUDP(self.log.getChild('UDP'), args),
            'liberio': N3xxXportMgrLiberio(self.log.getChild('liberio')),
        }
        # Spawn status monitoring thread
        self.log.trace("Spawning status monitor thread...")
        self._status_monitor_thread = threading.Thread(
            target=self._monitor_status,
            name="N3xxStatusMonitorThread",
            daemon=True,
        )
        self._status_monitor_thread.start()
        # Init complete.
        self.log.debug("Device info: {}".format(self.device_info))