diff options
author | Sugandha Gupta <sugandha.gupta@ettus.com> | 2019-01-25 11:34:47 -0800 |
---|---|---|
committer | Brent Stapleton <brent.stapleton@ettus.com> | 2019-05-01 15:17:23 -0700 |
commit | 178b35569b1a25180a80a23b945b10b04c9f10f5 (patch) | |
tree | 3adb6f78ebd148867a50526c60fe7bf9694a4a72 /mpm/lib | |
parent | 8a400f6a30942c9d6d3596f6989720eb4cff058b (diff) | |
download | uhd-178b35569b1a25180a80a23b945b10b04c9f10f5.tar.gz uhd-178b35569b1a25180a80a23b945b10b04c9f10f5.tar.bz2 uhd-178b35569b1a25180a80a23b945b10b04c9f10f5.zip |
e310/e320: Move E310 to MPM architecture and refactor
- Turns the E310 into an MPM device (like N3xx, E320)
- Factor out common code between E320 and E310, maximize sharing between
the two devices
- Remove all pre-MPM E310 code that is no longer needed
- Modify MPM to remove all existing overlays before applying new ones
(this is necessary to enable idle image mode for E310)
Co-authored-by: Virendra Kakade <virendra.kakade@ni.com>
Signed-off-by: Virendra Kakade <virendra.kakade@ni.com>
Diffstat (limited to 'mpm/lib')
-rw-r--r-- | mpm/lib/CMakeLists.txt | 2 | ||||
-rw-r--r-- | mpm/lib/dboards/CMakeLists.txt | 4 | ||||
-rw-r--r-- | mpm/lib/dboards/e31x_db_manager.cpp | 79 |
3 files changed, 84 insertions, 1 deletions
diff --git a/mpm/lib/CMakeLists.txt b/mpm/lib/CMakeLists.txt index 10f8f0d9d..82a5d8e16 100644 --- a/mpm/lib/CMakeLists.txt +++ b/mpm/lib/CMakeLists.txt @@ -14,7 +14,7 @@ add_subdirectory(types) if(ENABLE_MYKONOS) add_subdirectory(mykonos) -elseif(ENABLE_E320) +elseif(ENABLE_E320 OR ENABLE_E300) add_subdirectory(catalina) endif(ENABLE_MYKONOS) diff --git a/mpm/lib/dboards/CMakeLists.txt b/mpm/lib/dboards/CMakeLists.txt index 0760d9fd1..4a13528eb 100644 --- a/mpm/lib/dboards/CMakeLists.txt +++ b/mpm/lib/dboards/CMakeLists.txt @@ -16,4 +16,8 @@ elseif(ENABLE_E320) USRP_PERIPHS_ADD_OBJECT(dboards neon_manager.cpp ) +elseif(ENABLE_E300) + USRP_PERIPHS_ADD_OBJECT(dboards + e31x_db_manager.cpp + ) endif(ENABLE_MAGNESIUM) diff --git a/mpm/lib/dboards/e31x_db_manager.cpp b/mpm/lib/dboards/e31x_db_manager.cpp new file mode 100644 index 000000000..b433dde30 --- /dev/null +++ b/mpm/lib/dboards/e31x_db_manager.cpp @@ -0,0 +1,79 @@ +// +// Copyright 2018 Ettus Research, a National Instruments Company +// +// SPDX-License-Identifier: GPL-3.0-or-later +// + +#include <mpm/ad9361/e31x_defaults.hpp> +#include <mpm/dboards/e31x_db_manager.hpp> +#include <mpm/spi/spi_iface.hpp> +#include <mpm/spi/spi_regs_iface.hpp> +#include <mpm/types/regs_iface.hpp> +#include <boost/make_shared.hpp> +#include <memory> + +using namespace mpm::dboards; +using namespace mpm::chips; +using namespace mpm::types; +using namespace mpm::types::e31x; + +namespace { /*anon*/ + +constexpr uint32_t AD9361_SPI_WRITE_CMD = 0x00800000; +constexpr uint32_t AD9361_SPI_READ_CMD = 0x00000000; +constexpr uint32_t AD9361_SPI_ADDR_MASK = 0x003FFF00; +constexpr uint32_t AD9361_SPI_ADDR_SHIFT = 8; +constexpr uint32_t AD9361_SPI_DATA_MASK = 0x000000FF; +constexpr uint32_t AD9361_SPI_DATA_SHIFT = 0; +constexpr uint32_t AD9361_SPI_NUM_BITS = 24; +constexpr uint32_t AD9361_SPI_SPEED_HZ = 2000000; +constexpr int AD9361_SPI_MODE = 1; + +} // namespace /*anon*/ + +/*! MPM-style E310 SPI Iface for AD9361 CTRL + * + */ +class e310_ad9361_io_spi : public ad9361_io +{ +public: + e310_ad9361_io_spi(regs_iface::sptr regs_iface, uint32_t slave_num) : + _regs_iface(regs_iface), _slave_num(slave_num) { } + + ~e310_ad9361_io_spi() {/*nop*/} + + uint8_t peek8(uint32_t reg) + { + return _regs_iface->peek8(reg); + } + + void poke8(uint32_t reg, uint8_t val) + { + _regs_iface->poke8(reg, val); + } + +private: + regs_iface::sptr _regs_iface; + uint32_t _slave_num; +}; + +e31x_db_manager::e31x_db_manager(const std::string &catalina_spidev) +{ + // Make the MPM-style low level SPI Regs iface + auto spi_iface = mpm::spi::make_spi_regs_iface( + mpm::spi::spi_iface::make_spidev(catalina_spidev, AD9361_SPI_SPEED_HZ, AD9361_SPI_MODE), + AD9361_SPI_ADDR_SHIFT, + AD9361_SPI_DATA_SHIFT, + AD9361_SPI_READ_CMD, + AD9361_SPI_WRITE_CMD); + // Make the SPI interface + auto spi_io_iface = std::make_shared<e310_ad9361_io_spi>(spi_iface, 0); + // Translate from a std shared_ptr to Boost (for legacy compatability) + auto spi_io_iface_boost = boost::shared_ptr<e310_ad9361_io_spi>( + spi_io_iface.get(), + [spi_io_iface](...) mutable { spi_io_iface.reset(); }); + // Make the actual Catalina Ctrl object + _catalina_ctrl = ad9361_ctrl::make_spi( + boost::make_shared<e31x_ad9361_client_t>(), + spi_io_iface_boost); +} |