aboutsummaryrefslogtreecommitdiffstats
path: root/host/lib/usrp
diff options
context:
space:
mode:
Diffstat (limited to 'host/lib/usrp')
-rw-r--r--host/lib/usrp/cores/spi_core_4000.cpp18
-rw-r--r--host/lib/usrp/x400/x400_radio_control.cpp41
-rw-r--r--host/lib/usrp/x400/x400_radio_control.hpp3
3 files changed, 43 insertions, 19 deletions
diff --git a/host/lib/usrp/cores/spi_core_4000.cpp b/host/lib/usrp/cores/spi_core_4000.cpp
index 1d72dd88d..55486d6c8 100644
--- a/host/lib/usrp/cores/spi_core_4000.cpp
+++ b/host/lib/usrp/cores/spi_core_4000.cpp
@@ -25,6 +25,7 @@ public:
const size_t spi_transaction_cfg,
const size_t spi_transaction_go,
const size_t spi_status,
+ const size_t spi_controller_info,
const mapper_sptr port_mapper)
: _poke32(std::move(poke32_fn))
, _peek32(std::move(peek32_fn))
@@ -32,6 +33,7 @@ public:
, _spi_transaction_cfg(spi_transaction_cfg)
, _spi_transaction_go(spi_transaction_go)
, _spi_status(spi_status)
+ , _spi_ctrl_info(spi_controller_info)
, _port_mapper(port_mapper)
{
}
@@ -39,12 +41,17 @@ public:
void set_spi_slave_config(
const std::vector<uhd::features::spi_slave_config_t>& ssc) override
{
- if (ssc.size() > 4) {
- throw uhd::value_error(
- "Passed more than 4 SPI slaves. Maximum number of SPI slaves is 4.");
+ const size_t num_slaves_allowed = _peek32(_spi_ctrl_info) & 0xF;
+ if (ssc.size() > num_slaves_allowed) {
+ throw uhd::value_error("Number of configurations passed ("
+ + std::to_string(ssc.size())
+ + ") exceeds the maximum number allowed by "
+ "the bitfile per radio block. Maximum number: "
+ + std::to_string(num_slaves_allowed));
}
_spi_slave_config = ssc;
+ _slave_ctrl_cache.assign(_spi_slave_config.size(), 0);
}
uint32_t transact_spi(const int which_slave,
@@ -135,8 +142,9 @@ private:
const size_t _spi_transaction_cfg;
const size_t _spi_transaction_go;
const size_t _spi_status;
+ const size_t _spi_ctrl_info;
const mapper_sptr _port_mapper;
- std::vector<uint32_t> _slave_ctrl_cache{0, 0, 0, 0};
+ std::vector<uint32_t> _slave_ctrl_cache;
uint32_t _transaction_cfg_cache = 0;
std::mutex _mutex;
std::vector<uhd::features::spi_slave_config_t> _spi_slave_config;
@@ -161,6 +169,7 @@ spi_core_4000::sptr spi_core_4000::make(spi_core_4000::poke32_fn_t&& poke32_fn,
const size_t spi_transaction_cfg,
const size_t spi_transaction_go,
const size_t spi_status,
+ const size_t spi_controller_info,
const mapper_sptr port_mapper)
{
return std::make_shared<spi_core_4000_impl>(std::move(poke32_fn),
@@ -169,6 +178,7 @@ spi_core_4000::sptr spi_core_4000::make(spi_core_4000::poke32_fn_t&& poke32_fn,
spi_transaction_cfg,
spi_transaction_go,
spi_status,
+ spi_controller_info,
port_mapper);
}
diff --git a/host/lib/usrp/x400/x400_radio_control.cpp b/host/lib/usrp/x400/x400_radio_control.cpp
index ef2d6bd21..59207d486 100644
--- a/host/lib/usrp/x400/x400_radio_control.cpp
+++ b/host/lib/usrp/x400/x400_radio_control.cpp
@@ -191,20 +191,32 @@ x400_radio_control_impl::x400_radio_control_impl(make_args_ptr make_args)
auto gpio_port_mapper = std::shared_ptr<uhd::mapper::gpio_port_mapper>(
new uhd::rfnoc::x400::x400_gpio_port_mapping);
- auto spicore = uhd::cores::spi_core_4000::make(
- [this](const uint32_t addr, const uint32_t data) {
- regs().poke32(addr, data, get_command_time(0));
- },
- [this](
- const uint32_t addr) { return regs().peek32(addr, get_command_time(0)); },
- x400_regs::SPI_SLAVE_CFG,
- x400_regs::SPI_TRANSACTION_CFG_REG,
- x400_regs::SPI_TRANSACTION_GO_REG,
- x400_regs::SPI_STATUS_REG,
- gpio_port_mapper);
-
- _spi_getter_iface = std::make_shared<x400_spi_getter>(spicore);
- register_feature(_spi_getter_iface);
+
+ // Check if SPI is available as GPIO source, otherwise don't register
+ // SPI_GETTER_IFace
+ auto gpio_srcs = _mb_control->get_gpio_srcs("GPIO0");
+ if (std::count(gpio_srcs.begin(), gpio_srcs.end(), "DB0_SPI") > 0) {
+ auto spicore = uhd::cores::spi_core_4000::make(
+ [this](const uint32_t addr, const uint32_t data) {
+ regs().poke32(addr, data, get_command_time(0));
+ },
+ [this](const uint32_t addr) {
+ return regs().peek32(addr, get_command_time(0));
+ },
+ x400_regs::SPI_SLAVE_CFG,
+ x400_regs::SPI_TRANSACTION_CFG_REG,
+ x400_regs::SPI_TRANSACTION_GO_REG,
+ x400_regs::SPI_STATUS_REG,
+ x400_regs::SPI_CONTROLLER_INFO_REG,
+ gpio_port_mapper);
+
+ _spi_getter_iface = std::make_shared<x400_spi_getter>(spicore);
+ register_feature(_spi_getter_iface);
+ } else {
+ UHD_LOG_INFO("x400_radio_control",
+ "SPI functionality not available in this FPGA image. Please update to at "
+ "least version 7.7 to use SPI.");
+ }
}
}
@@ -816,5 +828,4 @@ std::string x400_radio_control_impl::get_dboard_fe_from_chan(
UHD_RFNOC_BLOCK_REGISTER_FOR_DEVICE_DIRECT(
x400_radio_control, RADIO_BLOCK, X400, "Radio", true, "radio_clk", "ctrl_clk")
-
}} // namespace uhd::rfnoc
diff --git a/host/lib/usrp/x400/x400_radio_control.hpp b/host/lib/usrp/x400/x400_radio_control.hpp
index cd45291bc..7fcf9a12a 100644
--- a/host/lib/usrp/x400/x400_radio_control.hpp
+++ b/host/lib/usrp/x400/x400_radio_control.hpp
@@ -54,6 +54,9 @@ constexpr uint32_t SPI_TRANSACTION_GO_REG = SPI_SLAVE_CFG + 0x0014;
//! Base address for SPI_STATUS Register
constexpr uint32_t SPI_STATUS_REG = SPI_SLAVE_CFG + 0x0018;
+//! Base address for SPI_CONTROLLER_INFO Register
+constexpr uint32_t SPI_CONTROLLER_INFO_REG = SPI_SLAVE_CFG + 0x001C;
+
} // namespace x400_regs
class x400_radio_control_impl : public radio_control_impl