aboutsummaryrefslogtreecommitdiffstats
path: root/host/lib/usrp/x300/x300_mb_controller.hpp
blob: 9a220ab006f52e9b9a62d6ca83b4f07263a9d6f1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
//
// Copyright 2019 Ettus Research, a National Instruments Brand
//
// SPDX-License-Identifier: GPL-3.0-or-later
//

#ifndef INCLUDED_LIBUHD_X300_MB_CONTROLLER_HPP
#define INCLUDED_LIBUHD_X300_MB_CONTROLLER_HPP

#include "x300_clock_ctrl.hpp"
#include <uhd/rfnoc/mb_controller.hpp>
#include <uhd/types/wb_iface.hpp>

namespace uhd { namespace rfnoc {

/*! X300-Specific version of the mb_controller
 *
 * Reminder: There is one of these per motherboard.
 */
class x300_mb_controller : public mb_controller
{
public:
    x300_mb_controller(uhd::i2c_iface::sptr zpu_i2c,
        uhd::wb_iface::sptr zpu_ctrl,
        x300_clock_ctrl::sptr clock_ctrl)
        : _zpu_i2c(zpu_i2c), _zpu_ctrl(zpu_ctrl), _clock_ctrl(clock_ctrl)
    {
        // nop
    }

    //! Return reference to the ZPU-owned I2C controller
    uhd::i2c_iface::sptr get_zpu_i2c()
    {
        return _zpu_i2c;
    }

    //! Reference to the ZPU peek/poke interface
    uhd::wb_iface::sptr get_zpu_ctrl() { return _zpu_ctrl; }

    //! Return reference to LMK clock controller
    x300_clock_ctrl::sptr get_clock_ctrl() { return _clock_ctrl; }

    //! X300-specific version of the timekeeper controls
    class x300_timekeeper : public mb_controller::timekeeper
    {
    public:
        x300_timekeeper(uhd::wb_iface::sptr zpu_ctrl) : _zpu_ctrl(zpu_ctrl) {}

        uint64_t get_ticks_now();

        uint64_t get_ticks_last_pps();

        void set_ticks_now(const uint64_t ticks);

        void set_ticks_next_pps(const uint64_t ticks);

        void set_period(const uint64_t period_ns);

    private:
        uhd::wb_iface::sptr _zpu_ctrl;
    };

private:
    /**************************************************************************
     * Attributes
     *************************************************************************/
    //! Reference to the ZPU-owned I2C controller
    uhd::i2c_iface::sptr _zpu_i2c;

    //! Reference to the ZPU peek/poke interface
    uhd::wb_iface::sptr _zpu_ctrl;

    //! Reference to LMK clock controller
    x300_clock_ctrl::sptr _clock_ctrl;
};

}} // namespace uhd::rfnoc

#endif /* INCLUDED_LIBUHD_X300_MB_CONTROLLER_HPP */