18UHAL_REGISTER_DERIVED_NODE(GIBIONode)
22 :
IONode(node, "i2c", "i2c", {
"PLL" }, {
"PLL",
"SFP CDR 0",
"SFP CDR 1",
"SFP CDR 2",
"SFP CDR 3",
"SFP CDR 4",
"SFP CDR 5",
"10 MHz" }, {
"i2c",
"i2c",
"i2c",
"i2c",
"i2c",
"i2c" })
29 std::string uid_i2c_bus,
30 std::string pll_i2c_bus,
31 std::string pll_i2c_device,
32 std::vector<std::string> clock_names,
33 std::vector<std::string> sfp_i2c_buses)
34 :
IONode(node, uid_i2c_bus, pll_i2c_bus, pll_i2c_device, clock_names, sfp_i2c_buses)
55 std::stringstream status;
66 std::vector<std::string> sfp_vec;
67 std::vector<uint8_t> los_vec;
68 std::vector<uint8_t> fault_vec;
73 los_vec.push_back(0x4C - 4*((sfp_los >> i) & 1));
74 fault_vec.push_back(0x4C - 4*((sfp_fault >> i) & 1));
77 status <<
"------IO expander----" << std::endl;
78 status <<
"SFP: " <<
vec_fmt(sfp_vec) << std::endl;
79 status <<
"LOS: " <<
vec_fmt(los_vec) << std::endl;
80 status <<
"Fault: " <<
vec_fmt(fault_vec) << std::endl;
85 TLOG() << std::endl << status.str();
91std::unique_ptr<const SI534xSlave>
116 if (carrier_type == kCarrierEnclustraA35) {
118 getNode<I2CMasterNode>(
m_uid_i2c_bus).get_slave(
"AX3_Switch").write_i2c(0x01, 0x7f);
119 }
catch (
const std::exception& e) {
125 getNode(
"csr.ctrl.i2c_sw_rst").write(0x0);
126 getNode(
"csr.ctrl.i2c_exten_rst").write(0x0);
127 getNode(
"csr.ctrl.clk_gen_rst").write(0x0);
128 getClient().dispatch();
133 getNode(
"csr.ctrl.i2c_sw_rst").write(0x1);
134 getNode(
"csr.ctrl.i2c_exten_rst").write(0x1);
135 getNode(
"csr.ctrl.clk_gen_rst").write(0x1);
136 getClient().dispatch();
146 getNode(
"csr.ctrl.rst").write(0x1);
147 getNode(
"csr.ctrl.rst").write(0x0);
148 getClient().dispatch();
152 getNode(
"csr.ctrl.gps_clk_en").write(0x0);
155 getNode(
"csr.ctrl.gps_clk_fltr_a").write(0x0);
156 getNode(
"csr.ctrl.gps_clk_fltr_b").write(0x0);
157 getClient().dispatch();
164 TLOG() <<
"Reset done";
176 sfp_expander_0->set_inversion(0, 0x00);
177 sfp_expander_0->set_inversion(1, 0x00);
178 sfp_expander_1->set_inversion(0, 0x00);
179 sfp_expander_1->set_inversion(1, 0x00);
182 sfp_expander_0->set_io(0, 0xff);
183 sfp_expander_0->set_io(1, 0xff);
185 sfp_expander_1->set_io(0, 0xff);
186 sfp_expander_1->set_io(1, 0x00);
199 getNode(
"csr.ctrl.clk_gen_rst").write(0x0);
200 getNode(
"csr.ctrl.clk_gen_rst").write(0x1);
207 std::stringstream status;
211 uint8_t i2c_mux_bitmask = 1UL << (sfp_id+1);
217 status <<
"SFP " << sfp_id <<
":" << std::endl;
218 status << sfp->get_status();
221 TLOG() << status.str();
233 uint32_t expander_bits = sfp_expander_1->read_inputs(0);
234 expander_bits = (expander_bits << 8) + sfp_expander_0->read_inputs(1);
235 expander_bits = (expander_bits << 8) + sfp_expander_0->read_inputs(0);
237 return expander_bits;
246 uint8_t los_bits = 0x00;
248 for (uint8_t sfp = 0; sfp<6; sfp++) {
251 los_bits = (los_bits << 1) + ((expander_bits >> (2 + 20 - 4*sfp)) & 1);
263 uint8_t fault_bits = 0x00;
265 for (uint8_t sfp = 0; sfp<6; sfp++) {
268 fault_bits = (fault_bits << 1) + ((expander_bits >> (3 + 20 - 4*sfp)) & 1);
279 std::stringstream status;
282 bool pll_lol = states.find(
"clk_gen_lol")->second.value();
283 bool pll_interrupt = states.find(
"clk_gen_intr")->second.value();
284 bool mmcm_ok = states.find(
"mmcm_ok")->second.value();
285 bool mmcm_10_ok = states.find(
"mmcm_ok")->second.value();
287 TLOG_DEBUG(5) <<
"pll lol: " << pll_lol <<
", pll intr: " << pll_interrupt
288 <<
", mmcm ok: " << mmcm_ok <<
", mmcm 10MHz ok: " << mmcm_10_ok;
290 return !pll_lol && mmcm_ok && mmcm_10_ok;
300 sfp->switch_soft_tx_control_bit(turn_on);
310 uint8_t current_sfp_tx_control_flags = sfp_expander_1->read_outputs_config(1);
312 uint8_t new_sfp_tx_control_flags;
315 new_sfp_tx_control_flags = current_sfp_tx_control_flags & ~(1UL << sfp_id);
319 new_sfp_tx_control_flags = current_sfp_tx_control_flags | (1UL << sfp_id);
322 sfp_expander_1->set_outputs(1, new_sfp_tx_control_flags);
372 uint8_t mux_channel_config = mux_channel_bitmask & 0x7f;
374 auto i2c_bus = getNode<I2CMasterNode>(
"i2c");
375 i2c_bus.write_i2cPrimitive(0x70, {mux_channel_config});
384 return temp_mon->read_temperature();
Class for the timing FMC board.
void switch_sfp_tx(uint32_t sfp_id, bool turn_on) const override
control tx laser of on-board SFP softly (I2C command)
virtual uint8_t read_sfps_fault() const
Retrive SFP fault status for all SFPs.
void set_i2c_mux_channels(uint8_t mux_channel_bitmask) const
Fill hardware monitoring structure.
void reset(const std::string &clock_config_file) const override
Reset GIB IO.
void set_up_io_infrastructure() const override
Set up i2c buses, enable ICs.
std::unique_ptr< const SI534xSlave > get_pll() const override
GET PLL I2C interface.
void switch_sfp_soft_tx_control_bit(uint32_t sfp_id, bool turn_on) const override
control tx laser of on-board SFP softly (I2C command)
virtual uint8_t get_num_sfps() const
virtual uint32_t read_io_expanders() const
Read the contents of the IO expanders.
void validate_sfp_id(uint32_t sfp_id) const
std::string get_hardware_info(bool print_out) const override
Print hardware information.
void reset_pll() const override
Reset PLL.
std::string get_uid_address_parameter_name() const override
Get the UID address parameter name.
GIBIONode(const uhal::Node &node)
void configure_expander() const
Configure the GIB expander.
std::string get_sfp_status(uint32_t sfp_id, bool print_out=false) const override
Print status of on-board SFP.
std::string get_status(bool print_out=false) const override
Get status string, optionally print.
virtual uint8_t read_sfps_los() const
Retrive SFP LOS status for all SFPs.
bool clocks_ok() const override
Clocks ready?
virtual uint8_t get_sfp_tx_disable_bitmap() const
float read_board_temperature() const
Read board temp.
Base class for timing IO nodes.
const std::string m_pll_i2c_bus
const std::string m_pll_i2c_device
virtual uint32_t read_carrier_type() const
Read the word identifying the FPFA carrier board.
virtual std::string get_hardware_info(bool print_out=false) const
Print hardware information.
const std::string m_uid_i2c_bus
const std::vector< std::string > m_sfp_i2c_buses
virtual void configure_pll(const std::string &clock_config_file="") const
Configure clock chip.
std::unique_ptr< const T > get_i2c_device(const std::string &i2c_bus_name, const std::string &i2c_device_name) const
Get the an I2C chip.
std::map< std::string, uhal::ValWord< uint32_t > > read_sub_nodes(const uhal::Node &node, bool dispatch=true) const
Read subnodes.
#define TLOG_DEBUG(lvl,...)
CarrierType convert_value_to_carrier_type(uint32_t darrier_type)
std::string format_reg_table(T data, std::string title, std::vector< std::string > headers)
Format reg-value table.
std::string vec_fmt(const std::vector< T > &vec)
std::string to_string(const T &v)
std::string format_reg_value(T reg_value, uint32_t base)
void millisleep(const double &time_in_milliseconds)
void warning(const Issue &issue)