18UHAL_REGISTER_DERIVED_NODE(PC059IONode)
22 :
SFPMuxIONode(node, "i2c", "i2c", "SI5345", {
"PLL",
"CDR" }, {
"usfp_i2c",
"i2c" })
34 return "FMC_UID_PROM";
42 std::stringstream status;
47 TLOG() << std::endl << status.str();
62 getNode(
"csr.ctrl.pll_rst").write(0x1);
63 getNode(
"csr.ctrl.pll_rst").write(0x0);
65 getNode(
"csr.ctrl.rst_i2c").write(0x1);
66 getNode(
"csr.ctrl.rst_i2c").write(0x0);
68 getNode(
"csr.ctrl.rst_i2cmux").write(0x1);
69 getNode(
"csr.ctrl.rst_i2cmux").write(0x0);
71 getClient().dispatch();
75 getNode<I2CMasterNode>(
m_uid_i2c_bus).get_slave(
"AX3_Switch").write_i2c(0x01, 0x7f);
76 }
catch (
const std::exception& e) {
84 getNode(
"csr.ctrl.rst").write(0x1);
85 getNode(
"csr.ctrl.rst").write(0x0);
86 getClient().dispatch();
88 getNode(
"csr.ctrl.mux").write(0);
89 getClient().dispatch();
94 sfp_expander->set_inversion(0, 0x00);
95 sfp_expander->set_inversion(1, 0x00);
98 sfp_expander->set_io(0, 0x00);
99 sfp_expander->set_io(1, 0xff);
102 sfp_expander->set_outputs(0, 0x00);
110 TLOG() <<
"Reset done";
118 getNode(
"csr.ctrl.mux").write(mux_channel);
119 getClient().dispatch();
129 auto active_sfp_mux_channel = getNode(
"csr.ctrl.mux").read();
130 getClient().dispatch();
131 return active_sfp_mux_channel.value();
140 getNode(
"csr.ctrl.rst_i2cmux").write(0x1);
141 getClient().dispatch();
142 getNode(
"csr.ctrl.rst_i2cmux").write(0x0);
143 getClient().dispatch();
146 uint8_t channel_select_byte = 1UL << sfp_id;
147 getNode<I2CMasterNode>(m_pll_i2c_bus).get_slave(
"SFP_Switch").write_i2cPrimitive({ channel_select_byte });
157 std::stringstream status;
158 uint32_t sfp_bus_index;
161 status <<
"Upstream SFP:" << std::endl;
162 }
else if (sfp_id > 0 && sfp_id < 9) {
163 switch_sfp_i2c_mux_channel(sfp_id - 1);
164 status <<
"Fanout SFP " << sfp_id - 1 <<
":" << std::endl;
169 auto sfp = get_i2c_device<I2CSFPSlave>(m_sfp_i2c_buses.at(sfp_bus_index),
"SFP_EEProm");
171 status << sfp->get_status();
174 TLOG() << status.str();
183 std::stringstream status;
186 bool pll_ok = states.find(
"pll_ok")->second.value();
187 bool mmcm_ok = states.find(
"mmcm_ok")->second.value();
189 TLOG_DEBUG(5) <<
"pll ok: " << pll_ok <<
", mmcm ok: " << mmcm_ok;
191 return pll_ok && mmcm_ok;
200 uint32_t sfp_bus_index;
203 }
else if (sfp_id > 0 && sfp_id < 9) {
204 switch_sfp_i2c_mux_channel(sfp_id - 1);
209 auto sfp = get_i2c_device<I2CSFPSlave>(m_sfp_i2c_buses.at(sfp_bus_index),
"SFP_EEProm");
210 sfp->switch_soft_tx_control_bit(turn_on);
221 uint8_t current_sfp_tx_control_flags = sfp_expander->read_outputs_config(0);
223 uint8_t new_sfp_tx_control_flags;
226 new_sfp_tx_control_flags = current_sfp_tx_control_flags & ~(1UL << sfp_id);
230 new_sfp_tx_control_flags = current_sfp_tx_control_flags | (1UL << sfp_id);
233 sfp_expander->set_outputs(0, new_sfp_tx_control_flags);
virtual void write_soft_reset_register() const
Write soft reset register.
const std::string m_uid_i2c_bus
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.
Class for the PC059 board.
uint32_t read_active_sfp_mux_channel() const override
Read the active SFP mux channel.
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)
bool clocks_ok() const override
Clocks ready?
void switch_sfp_mux_channel(uint32_t mux_channel) const override
Switch the SFP mux channel.
void validate_sfp_id(uint32_t sfp_id) const
Fill hardware monitoring structure.
std::string get_uid_address_parameter_name() const override
Get the UID address parameter name.
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.
void switch_sfp_i2c_mux_channel(uint32_t sfp_id) const
Switch the SFP I2C mux channel.
void switch_sfp_tx(uint32_t sfp_id, bool turn_on) const override
control tx laser of on-board SFP softly (I2C command)
void reset(const std::string &clock_config_file) const override
Reset pc059 node.
Base class for boards which have a physical SFP mux.
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,...)
std::string format_reg_table(T data, std::string title, std::vector< std::string > headers)
Format reg-value table.
std::string format_reg_value(T reg_value, uint32_t base)
void millisleep(const double &time_in_milliseconds)
void warning(const Issue &issue)