diff options
author | Martin Braun <martin.braun@ettus.com> | 2014-10-07 11:32:14 +0200 |
---|---|---|
committer | Martin Braun <martin.braun@ettus.com> | 2014-10-07 12:09:33 +0200 |
commit | 1b149f561370687ad65e3aa644a402f00dbd16ea (patch) | |
tree | ab86042840fa1369d64bca56c5f3a64d1a4f1f72 /host/lib/usrp/e300/e300_eeprom_manager.hpp | |
parent | fd3e84941de463fa1a7ebab0a69515b4bf2614cd (diff) | |
download | uhd-1b149f561370687ad65e3aa644a402f00dbd16ea.tar.gz uhd-1b149f561370687ad65e3aa644a402f00dbd16ea.tar.bz2 uhd-1b149f561370687ad65e3aa644a402f00dbd16ea.zip |
Initial commit E300 support.
Diffstat (limited to 'host/lib/usrp/e300/e300_eeprom_manager.hpp')
-rw-r--r-- | host/lib/usrp/e300/e300_eeprom_manager.hpp | 125 |
1 files changed, 125 insertions, 0 deletions
diff --git a/host/lib/usrp/e300/e300_eeprom_manager.hpp b/host/lib/usrp/e300/e300_eeprom_manager.hpp new file mode 100644 index 000000000..e77f25ed5 --- /dev/null +++ b/host/lib/usrp/e300/e300_eeprom_manager.hpp @@ -0,0 +1,125 @@ +// +// Copyright 2014 Ettus Research LLC +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see <http://www.gnu.org/licenses/>. +// + +#ifndef INCLUDED_E300_EEPROM_MANAGER_HPP +#define INCLUDED_E300_EEPROM_MANAGER_HPP + +#include <boost/thread/mutex.hpp> +#include <boost/shared_ptr.hpp> +#include <uhd/types/dict.hpp> +#include <uhd/usrp/mboard_eeprom.hpp> +#include <uhd/usrp/dboard_eeprom.hpp> + +#include "e300_i2c.hpp" + +namespace uhd { namespace usrp { namespace e300 { + +static const boost::uint16_t E300_MB_PID = 0x77d1; +static const boost::uint16_t E310_MB_PID = 0x77d2; + +static const boost::uint16_t E300_DB_PID = 0x0100; +static const boost::uint16_t E310_DB_PID = 0x0110; + +class e300_eeprom_manager : boost::noncopyable +{ +public: + typedef boost::shared_ptr<e300_eeprom_manager> sptr; + e300_eeprom_manager(i2c::sptr i2c); + ~e300_eeprom_manager(); + + // mboard + const mboard_eeprom_t& read_mb_eeprom(); + void write_mb_eeprom(const mboard_eeprom_t& eeprom); + + UHD_INLINE const mboard_eeprom_t& get_mb_eeprom() + { + return _mb_eeprom; + } + + // dboard + const dboard_eeprom_t& read_db_eeprom(); + void write_db_eeprom(const dboard_eeprom_t& eeprom); + + UHD_INLINE const dboard_eeprom_t& get_db_eeprom() + { + return _db_eeprom; + } + + + i2c::sptr get_i2c_sptr(void); + + enum mboard_t {USRP_E300_MB, USRP_E310_MB, UNKNOWN}; + + mboard_t get_mb_type(void) const; + static mboard_t get_mb_type(boost::uint16_t pid); + std::string get_mb_type_string(void) const; + +private: // types + const static size_t MB_SERIAL_LEN = 6; + const static size_t MB_NAME_LEN = 32; + const static size_t MB_ADDR = 0x51; + + const static size_t DB_SERIAL_LEN = 6; + const static size_t DB_ADDR = 0x50; + + struct mb_eeprom_map_t + { + // Data format version + boost::uint16_t data_version_major; + boost::uint16_t data_version_minor; + + // NIC mac address + boost::uint8_t mac_addr[6]; + + // HW identification info + boost::uint16_t hw_product; + boost::uint16_t hw_revision; + + // serial + boost::uint8_t serial[MB_SERIAL_LEN]; + boost::uint8_t pad[20 - MB_SERIAL_LEN]; + + //User specific + boost::uint8_t user_name[MB_NAME_LEN]; + }; + + struct db_eeprom_map_t + { + // Data format version + boost::uint16_t data_version_major; + boost::uint16_t data_version_minor; + + // HW identification info + boost::uint16_t hw_product; + boost::uint16_t hw_revision; + + // serial + boost::uint8_t serial[MB_SERIAL_LEN]; + boost::uint8_t pad[20 - MB_SERIAL_LEN]; + }; + +private: // members + mboard_eeprom_t _mb_eeprom; + dboard_eeprom_t _db_eeprom; + i2c::sptr _i2c; + + boost::mutex _mutex; +}; + +}}} //namespace + +#endif // INCLUDED_E300_EEPROM_MANAGER_HPP |