diff options
| -rw-r--r-- | host/lib/usrp/dboard/magnesium/magnesium_radio_ctrl_impl.cpp | 32 | ||||
| -rw-r--r-- | host/lib/usrp/dboard/magnesium/magnesium_radio_ctrl_impl.hpp | 15 | 
2 files changed, 46 insertions, 1 deletions
diff --git a/host/lib/usrp/dboard/magnesium/magnesium_radio_ctrl_impl.cpp b/host/lib/usrp/dboard/magnesium/magnesium_radio_ctrl_impl.cpp index 54f2f64cc..2c0f82aa8 100644 --- a/host/lib/usrp/dboard/magnesium/magnesium_radio_ctrl_impl.cpp +++ b/host/lib/usrp/dboard/magnesium/magnesium_radio_ctrl_impl.cpp @@ -48,6 +48,8 @@ namespace {      const size_t MAGNESIUM_NUM_TX_CHANS = 1;      const size_t MAGNESIUM_NUM_RX_CHANS = 1; +    const size_t FPGPIO_MASTER_RADIO = 0; +      /*! Return a valid 'which' string for use with AD9371 API calls       *       * These strings take the form of "RX1", "TX2", ... @@ -299,6 +301,36 @@ void magnesium_radio_ctrl_impl::_init_peripherals()      } else {          UHD_LOG_TRACE("MAGNESIUM", "Not a master radio, no LOs.");      } + +    _gpio.clear(); // Following the as-if rule, this can get optimized out +    for (size_t radio_idx = 0; radio_idx < _get_num_radios(); radio_idx++) { +        UHD_LOG_TRACE("MAGNESIUM", +            "Initializing GPIOs for channel " << radio_idx); +        _gpio.emplace_back( +            gpio_atr::gpio_atr_3000::make( +                _get_ctrl(radio_idx), +                regs::sr_addr(regs::ATR) +            ) +        ); +        // DSA and AD9371 gain bits do *not* toggle on ATR modes. If we ever +        // connect anything else to this core, we might need to set_atr_mode() +        // to MODE_ATR on those bits. For now, all bits simply do what they're +        // told, and don't toggle on RX/TX state changes. +         _gpio.back()->set_atr_mode( +             usrp::gpio_atr::MODE_GPIO, // Disable ATR mode +             usrp::gpio_atr::gpio_atr_3000::MASK_SET_ALL +         ); +         _gpio.back()->set_gpio_ddr( +            usrp::gpio_atr::DDR_OUTPUT, // Make all GPIOs outputs +            usrp::gpio_atr::gpio_atr_3000::MASK_SET_ALL +        ); +    } + +    if (get_block_id().get_block_count() == FPGPIO_MASTER_RADIO) { +        UHD_LOG_TRACE(unique_id(), "Initializing front-panel GPIO control...") +        _fp_gpio = gpio_atr::gpio_atr_3000::make( +                _get_ctrl(0), regs::sr_addr(regs::FP_GPIO), regs::RB_FP_GPIO); +    }  }  void magnesium_radio_ctrl_impl::_init_defaults() diff --git a/host/lib/usrp/dboard/magnesium/magnesium_radio_ctrl_impl.hpp b/host/lib/usrp/dboard/magnesium/magnesium_radio_ctrl_impl.hpp index 7c96e47d0..4e31886f7 100644 --- a/host/lib/usrp/dboard/magnesium/magnesium_radio_ctrl_impl.hpp +++ b/host/lib/usrp/dboard/magnesium/magnesium_radio_ctrl_impl.hpp @@ -23,6 +23,7 @@  #include "magnesium_cpld_ctrl.hpp"  #include "magnesium_cpld_regs.hpp"  #include "adf435x.hpp" +#include "gpio_atr_3000.hpp"  #include <uhd/types/serial.hpp>  #include <uhd/usrp/dboard_manager.hpp>  #include <uhd/usrp/gpio_defs.hpp> @@ -158,9 +159,21 @@ private:      //! Reference to the RX LO      adf435x_iface::sptr _rx_lo; -    //! Reference to the CPLD controls +    //! Reference to the CPLD controls. Even if there's multiple radios, +    //  there's only one CPLD control.      std::shared_ptr<magnesium_cpld_ctrl> _cpld; +    //! ATR controls. These control the external DSA and the AD9371 gain +    //  up/down bits. They do *not* control the ATR state of the CPLD, the +    //  tx/rx run states are hooked up directly to the CPLD. +    // +    //  Every radio channel gets its own ATR state register. +    std::vector<usrp::gpio_atr::gpio_atr_3000::sptr> _gpio; + +    //! Front panel GPIO controller. Note that only one radio block per +    //  module can be the FP-GPIO master. +    usrp::gpio_atr::gpio_atr_3000::sptr _fp_gpio; +  }; /* class radio_ctrl_impl */  | 
