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";
125 getNode(
"csr.ctrl.mux").write(mux_channel);
126 getClient().dispatch();
136 auto active_sfp_mux_channel = getNode(
"csr.ctrl.mux").read();
137 getClient().dispatch();
138 return active_sfp_mux_channel.value();
147 getNode(
"csr.ctrl.rst_i2cmux").write(0x1);
148 getClient().dispatch();
149 getNode(
"csr.ctrl.rst_i2cmux").write(0x0);
150 getClient().dispatch();
153 uint8_t channel_select_byte = 1UL << sfp_id;
154 getNode<I2CMasterNode>(m_pll_i2c_bus).get_slave(
"SFP_Switch").write_i2cPrimitive({ channel_select_byte });
164 std::stringstream status;
165 uint32_t sfp_bus_index;
168 status <<
"Upstream SFP:" << std::endl;
169 }
else if (sfp_id > 0 && sfp_id < 9) {
170 switch_sfp_i2c_mux_channel(sfp_id - 1);
171 status <<
"Fanout SFP " << sfp_id - 1 <<
":" << std::endl;
176 auto sfp = get_i2c_device<I2CSFPSlave>(m_sfp_i2c_buses.at(sfp_bus_index),
"SFP_EEProm");
178 status << sfp->get_status();
181 TLOG() << status.str();
190 std::stringstream status;
193 bool pll_ok = states.find(
"pll_ok")->second.value();
194 bool mmcm_ok = states.find(
"mmcm_ok")->second.value();
196 TLOG_DEBUG(5) <<
"pll ok: " << pll_ok <<
", mmcm ok: " << mmcm_ok;
198 return pll_ok && mmcm_ok;
207 uint32_t sfp_bus_index;
210 }
else if (sfp_id > 0 && sfp_id < 9) {
211 switch_sfp_i2c_mux_channel(sfp_id - 1);
216 auto sfp = get_i2c_device<I2CSFPSlave>(m_sfp_i2c_buses.at(sfp_bus_index),
"SFP_EEProm");
217 sfp->switch_soft_tx_control_bit(turn_on);
228 uint8_t current_sfp_tx_control_flags = sfp_expander->read_outputs_config(0);
230 uint8_t new_sfp_tx_control_flags;
233 new_sfp_tx_control_flags = current_sfp_tx_control_flags & ~(1UL << sfp_id);
237 new_sfp_tx_control_flags = current_sfp_tx_control_flags | (1UL << sfp_id);
240 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.
void reset_pll() const override
Reset PLL.
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)