From 83dde40090e0bbd91c304602cc0e3c365f7878bb Mon Sep 17 00:00:00 2001 From: Martin Braun Date: Tue, 26 Sep 2017 18:22:25 -0700 Subject: uhd: Changed mboard_eeprom_t interface, refactored MB EEPROM code - uhd::usrp::mboard_eeprom_t is now simply a map. Its commit() method has no utility being a public API call, because the user never gets access to the appropriate I2C object (Minor API breakage) - The central mboard_eeprom.cpp file was broken up and put into many smaller compilation units in every device's implementation folder. - Renamed some of the constants (e.g. B000_* -> USRP1_*, N100_* -> N200_*) - Removed the N000_* EEPROM code, because, well, you know, there's no such device --- host/lib/usrp/x300/x300_impl.cpp | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) (limited to 'host/lib/usrp/x300/x300_impl.cpp') diff --git a/host/lib/usrp/x300/x300_impl.cpp b/host/lib/usrp/x300/x300_impl.cpp index 1e22f7fb7..f98bdb5b1 100644 --- a/host/lib/usrp/x300/x300_impl.cpp +++ b/host/lib/usrp/x300/x300_impl.cpp @@ -18,7 +18,7 @@ #include "x300_impl.hpp" #include "x300_lvbitx.hpp" #include "x310_lvbitx.hpp" -#include "x300_mb_eeprom.hpp" +#include "x300_mb_eeprom_iface.hpp" #include "apply_corrections.hpp" #include #include @@ -125,7 +125,8 @@ static device_addrs_t x300_find_with_addr(const device_addr_t &hint) i2c_core_100_wb32::sptr zpu_i2c = i2c_core_100_wb32::make(zpu_ctrl, I2C1_BASE); x300_mb_eeprom_iface::sptr eeprom_iface = x300_mb_eeprom_iface::make(zpu_ctrl, zpu_i2c); - const mboard_eeprom_t mb_eeprom(*eeprom_iface, "X300"); + const mboard_eeprom_t mb_eeprom = + x300_impl::get_mb_eeprom(eeprom_iface); if (mb_eeprom.size() == 0 or x300_impl::claim_status(zpu_ctrl) == x300_impl::CLAIMED_BY_OTHER) { // Skip device claimed by another process @@ -233,7 +234,8 @@ static device_addrs_t x300_find_pcie(const device_addr_t &hint, bool explicit_qu i2c_core_100_wb32::sptr zpu_i2c = i2c_core_100_wb32::make(zpu_ctrl, I2C1_BASE); x300_mb_eeprom_iface::sptr eeprom_iface = x300_mb_eeprom_iface::make(zpu_ctrl, zpu_i2c); - const mboard_eeprom_t mb_eeprom(*eeprom_iface, "X300"); + const mboard_eeprom_t mb_eeprom = + x300_impl::get_mb_eeprom(eeprom_iface); if (mb_eeprom.size() == 0 or x300_impl::claim_status(zpu_ctrl) == x300_impl::CLAIMED_BY_OTHER) { // Skip device claimed by another process @@ -783,13 +785,21 @@ void x300_impl::setup_mb(const size_t mb_i, const uhd::device_addr_t &dev_addr) x300_mb_eeprom_iface::sptr eeprom16 = x300_mb_eeprom_iface::make(mb.zpu_ctrl, mb.zpu_i2c); if (dev_addr.has_key("blank_eeprom")) { - UHD_LOGGER_WARNING("X300") << "Obliterating the motherboard EEPROM..." ; + UHD_LOGGER_WARNING("X300") << "Obliterating the motherboard EEPROM..."; eeprom16->write_eeprom(0x50, 0, byte_vector_t(256, 0xff)); } - const mboard_eeprom_t mb_eeprom(*eeprom16, "X300"); + + const mboard_eeprom_t mb_eeprom = get_mb_eeprom(eeprom16); _tree->create(mb_path / "eeprom") + // Initialize the property with a current copy of the EEPROM contents .set(mb_eeprom) - .add_coerced_subscriber(boost::bind(&x300_impl::set_mb_eeprom, this, mb.zpu_i2c, _1)); + // Whenever this property is written, update the chip + .add_coerced_subscriber( + [this, eeprom16](const mboard_eeprom_t &mb_eeprom){ + this->set_mb_eeprom(eeprom16, mb_eeprom); + } + ) + ; bool recover_mb_eeprom = dev_addr.has_key("recover_mb_eeprom"); if (recover_mb_eeprom) { @@ -1523,16 +1533,6 @@ bool x300_impl::is_pps_present(mboard_members_t& mb) return false; } -/*********************************************************************** - * eeprom - **********************************************************************/ - -void x300_impl::set_mb_eeprom(i2c_iface::sptr i2c, const mboard_eeprom_t &mb_eeprom) -{ - i2c_iface::sptr eeprom16 = i2c->eeprom16(); - mb_eeprom.commit(*eeprom16, "X300"); -} - /*********************************************************************** * claimer logic **********************************************************************/ -- cgit v1.2.3