def init(self): """ initialize (mount) the daughterboard flash """ ret = False self.log.trace("Initializing daughterboard flash") dtoverlay.apply_overlay_safe(self.overlay) time.sleep(0.2) try: self.mtd_devpath = get_device_from_symbol(self.dt_symbol, ['*', 'mtd']) self.mtdblock_devpath = get_device_from_symbol( self.dt_symbol, ['*', 'block']) except FileNotFoundError: raise ValueError( "could not find MTD/-block device for device tree symbol {}".format( self.dt_symbol)) try: self.mount = Mount(self.mtdblock_devpath, '/mnt/' + self.dt_symbol, ['-t', 'jffs2'], log=self.log) if not self.mount.ismounted(): ret = self.mount.mount() if not ret: raise RuntimeError() self.initialized = True except: self.log.warning("Failed to initialize daughterboard flash") return ret
def apply_idle_overlay(self): """ Load all overlays required to go into idle power savings mode. """ idle_overlay = self.get_idle_dt_overlay(self.device_info) self.log.debug( "Motherboard requests device tree overlay for Idle power savings mode: {}" .format(idle_overlay)) dtoverlay.apply_overlay_safe(idle_overlay)
def apply_idle_overlay(self): """ Load all overlays required to go into idle power savings mode. """ idle_overlay = self.get_idle_dt_overlay(self.device_info) self.log.debug("Motherboard requests device tree overlay for Idle power savings mode: {}".format( idle_overlay )) dtoverlay.apply_overlay_safe(idle_overlay)
def _init_mboard_overlays(self): """ Load all required overlays for this motherboard """ requested_overlays = self.list_required_dt_overlays(self.device_info, ) self.log.debug("Motherboard requests device tree overlays: {}".format( requested_overlays)) for overlay in requested_overlays: dtoverlay.apply_overlay_safe(overlay) # Need to wait here a second to make sure the ethernet interfaces are up # TODO: Fine-tune this number, or wait for some smarter signal. sleep(1)
def main(): """ Main function """ db_id = get_dboard_id_from_eeprom(['rhodium']) if 'rhodium' not in db_id: exit() logger = get_main_logger() dtoverlay.apply_overlay_safe('n320') context = pyudev.Context() adapter = pyudev.Devices.from_sys_path(context, '/sys/class/i2c-adapter/i2c-9') lodist = FPGAtoLoDist(adapter) lodist.reset('P3_3V_RF_EN') lodist.reset('P6_5V_LDO_EN') lodist.reset('P6_8V_EN')
def _init_mboard_overlays(self): """ Load all required overlays for this motherboard """ requested_overlays = self.list_required_dt_overlays( self.device_info, ) self.log.debug("Motherboard requests device tree overlays: {}".format( requested_overlays )) for overlay in requested_overlays: dtoverlay.apply_overlay_safe(overlay) # Need to wait here a second to make sure the ethernet interfaces are up # TODO: Fine-tune this number, or wait for some smarter signal. sleep(1)
def main(): """ Main function """ db_id = get_dboard_id_from_eeprom(['rhodium']) if 'rhodium' not in db_id: exit() logger = get_main_logger() dtoverlay.apply_overlay_safe('n320') context = pyudev.Context() adapter = pyudev.Devices.from_sys_path(context, '/sys/class/i2c-adapter/i2c-9') lodist = FPGAtoLoDist(adapter) lodist.reset('P3_3V_RF_EN') lodist.reset('P6_5V_LDO_EN') lodist.reset('P6_8V_EN')
def _init_periphs(self): """ Initialize power and peripherals that don't need user-settings """ def _get_i2c_dev(): " Return the I2C path for this daughterboard " import pyudev context = pyudev.Context() i2c_dev_path = os.path.join(self.base_i2c_adapter, self.i2c_chan_map[self.slot_idx]) return pyudev.Devices.from_sys_path(context, i2c_dev_path) def _init_spi_devices(): " Returns abstraction layers to all the SPI devices " self.log.trace("Loading SPI interfaces...") return { key: self.spi_factories[key](self._spi_nodes[key]) for key in self._spi_nodes } self._port_expander = TCA6408(_get_i2c_dev()) self._daughterboard_gpio = FPGAtoDbGPIO(self.slot_idx) # TODO: applying the overlay without checking for the presence of the # LO dist board will create a kernel error. Fix this when the I2C API # is implemented by checking if the board is present before applying. try: apply_overlay_safe('n321') self._lo_dist = FPGAtoLoDist(_get_i2c_dev()) except RuntimeError: self._lo_dist = None self.log.debug("Turning on Module and RF power supplies") self._power_on() self._spi_ifaces = _init_spi_devices() self.log.debug("Loaded SPI interfaces!") self.cpld = RhCPLD(self._spi_ifaces['cpld'], self.log) self.log.debug("Loaded CPLD interfaces!") # Create DAC interface (analog output is disabled). self.log.trace("Creating DAC control object...") self.dac = DAC37J82Rh(self.slot_idx, self._spi_ifaces['dac'], self.log) # Create ADC interface (JESD204B link is powered down). self.log.trace("Creating ADC control object...") self.adc = AD9695Rh(self.slot_idx, self._spi_ifaces['adc'], self.log) self.log.info("Succesfully loaded all peripherals!")
def _init_periphs(self): """ Initialize power and peripherals that don't need user-settings """ def _get_i2c_dev(): " Return the I2C path for this daughterboard " import pyudev context = pyudev.Context() i2c_dev_path = os.path.join( self.base_i2c_adapter, self.i2c_chan_map[self.slot_idx] ) return pyudev.Devices.from_sys_path(context, i2c_dev_path) def _init_spi_devices(): " Returns abstraction layers to all the SPI devices " self.log.trace("Loading SPI interfaces...") return { key: self.spi_factories[key](self._spi_nodes[key]) for key in self._spi_nodes } self._port_expander = TCA6408(_get_i2c_dev()) self._daughterboard_gpio = FPGAtoDbGPIO(self.slot_idx) # TODO: applying the overlay without checking for the presence of the # LO dist board will create a kernel error. Fix this when the I2C API # is implemented by checking if the board is present before applying. try: apply_overlay_safe('n321') self._lo_dist = FPGAtoLoDist(_get_i2c_dev()) except RuntimeError: self._lo_dist = None self.log.debug("Turning on Module and RF power supplies") self._power_on() self._spi_ifaces = _init_spi_devices() self.log.debug("Loaded SPI interfaces!") self.cpld = RhCPLD(self._spi_ifaces['cpld'], self.log) self.log.debug("Loaded CPLD interfaces!") # Create DAC interface (analog output is disabled). self.log.trace("Creating DAC control object...") self.dac = DAC37J82Rh(self.slot_idx, self._spi_ifaces['dac'], self.log) # Create ADC interface (JESD204B link is powered down). self.log.trace("Creating ADC control object...") self.adc = AD9695Rh(self.slot_idx, self._spi_ifaces['adc'], self.log) self.log.info("Succesfully loaded all peripherals!")