diff options
author | Mark Meserve <mark.meserve@ni.com> | 2017-05-02 17:09:03 -0500 |
---|---|---|
committer | Martin Braun <martin.braun@ettus.com> | 2017-12-22 15:03:52 -0800 |
commit | 24d3011233ba1cd0b8788eccfacd0b67cb776600 (patch) | |
tree | cfd2af3212182e76a84b1fcb325b26ebd266bdb6 /mpm/python/usrp_mpm/dboard_manager/magnesium.py | |
parent | 8f9f29dabc1a0f9db1101f658d9bcbac526eca39 (diff) | |
download | uhd-24d3011233ba1cd0b8788eccfacd0b67cb776600.tar.gz uhd-24d3011233ba1cd0b8788eccfacd0b67cb776600.tar.bz2 uhd-24d3011233ba1cd0b8788eccfacd0b67cb776600.zip |
mg: bring up links
Diffstat (limited to 'mpm/python/usrp_mpm/dboard_manager/magnesium.py')
-rw-r--r-- | mpm/python/usrp_mpm/dboard_manager/magnesium.py | 66 |
1 files changed, 45 insertions, 21 deletions
diff --git a/mpm/python/usrp_mpm/dboard_manager/magnesium.py b/mpm/python/usrp_mpm/dboard_manager/magnesium.py index fa2dbe9c3..de871abf8 100644 --- a/mpm/python/usrp_mpm/dboard_manager/magnesium.py +++ b/mpm/python/usrp_mpm/dboard_manager/magnesium.py @@ -26,6 +26,25 @@ from .base import DboardManagerBase from .. import nijesdcore from ..uio import UIO from ..mpmlog import get_logger +from .lmk_mg import LMK04828Mg + +def create_spidev_iface(dev_node): + """ + Create a regs iface from a spidev node + """ + SPI_SPEED_HZ = 1000000 + SPI_ADDR_SHIFT = 8 + SPI_DATA_SHIFT = 0 + SPI_READ_FLAG = 1<<23 + SPI_WRIT_FLAG = 0 + return lib.spi.make_spidev_regs_iface( + dev_node, + SPI_SPEED_HZ, + SPI_ADDR_SHIFT, + SPI_DATA_SHIFT, + SPI_READ_FLAG, + SPI_WRIT_FLAG + ) class Magnesium(DboardManagerBase): """ @@ -54,25 +73,16 @@ class Magnesium(DboardManagerBase): """ Execute necessary init dance to bring up dboard """ + self.clock_regs = create_spidev_iface(self._spi_nodes['lmk']) self.log.debug("Loading C++ drivers...") self._device = lib.dboards.magnesium_manager( self._spi_nodes['mykonos'], ) - SPI_SPEED_HZ = 1000000 - SPI_ADDR_SHIFT = 8 - SPI_DATA_SHIFT = 0 - SPI_READ_FLAG = 1<<23 - SPI_WRIT_FLAG = 0 - self.lmk = lib.spi.make_spidev_regs_iface( - dev_node, - SPI_SPEED_HZ, - SPI_ADDR_SHIFT, - SPI_DATA_SHIFT, - SPI_READ_FLAG, - SPI_WRIT_FLAG - ) + self.spi_lock = self._device.get_spi_lock() self.mykonos = self._device.get_radio_ctrl() self.log.debug("Loaded C++ drivers.") + self.lmk = LMK04828Mg(self.clock_regs, self.spi_lock) + self.log.debug("Getting Mg A uio...") self.radio_regs = UIO(label="jesd204b-regs", read_only=False) self.log.info("Radio-register UIO object successfully generated!") @@ -89,9 +99,9 @@ class Magnesium(DboardManagerBase): self.jesdcore.check_core() self.log.trace("Initializing LMK...") self.lmk.init() + self.radio_regs.poke32(0x2078, 0xA000040) + self.log.trace("Verify LMK Chip ID...") self.lmk.verify_chip_id() - self.log.trace("Enabling SYSREF pulses...") - self.lmk.enable_sysref_pulse() self.jesdcore.unreset_mmcm() @@ -105,23 +115,36 @@ class Magnesium(DboardManagerBase): self.jesdcore.send_sysref_pulse() self.mykonos.finish_initialization() - self.log.trace("Stargin Mykonos JESD framing...") + self.log.trace("Starting Mykonos framer...") self.mykonos.start_jesd_rx() + self.jesdcore.send_sysref_pulse() + self.log.trace("Resetting FPGA deframer...") self.jesdcore.init_deframer() + self.log.trace("Resetting FPGA framer...") self.jesdcore.init_framer() + self.log.trace("Starting Mykonos deframer...") self.mykonos.start_jesd_tx() - #TODO add function for Enable FPGA LMFC Generator + self.log.trace("Enable LMFC and send") + self.jesdcore.enable_lmfc() self.jesdcore.send_sysref_pulse() time.sleep(0.2) if not self.jesdcore.get_framer_status(): raise Exception('JESD Core Framer is not synced!') if not self.jesdcore.get_deframer_status(): raise Exception('JESD Core Deframer is not synced!') - #if (!self.mykonos.get_framer_status()) - # raise Exception('Mykonos Framer is not synced!') - #if (!self.mykonos.get_deframer_status()) - # raise Exception('Mykonos Deframer is not synced!') + if (self.mykonos.get_framer_status() & 0xFF != 0x3E): + raise Exception('Mykonos Framer is not synced!') + if (self.mykonos.get_deframer_status() & 0x7F != 0x28): + raise Exception('Mykonos Deframer is not synced!') + self.log.trace("JESD fully synced and ready") + + def dump_jesd_core(self): + for i in range(0x2000, 0x2110, 0x10): + print("0x%04X " % i), + for j in range(0, 0x10, 0x4): + print("%08X" % self.radio_regs.peek32(i + j)), + print("") def read_eeprom_v1(self, data): """ @@ -130,3 +153,4 @@ class Magnesium(DboardManagerBase): # magnesium eeprom contains # nothing return struct.unpack_from("x", data) + |