Lines Matching refs:efx
73 static int qt2025c_wait_heartbeat(struct ef4_nic *efx) in qt2025c_wait_heartbeat() argument
81 reg = ef4_mdio_read(efx, MDIO_MMD_PCS, PCS_FW_HEARTBEAT_REG); in qt2025c_wait_heartbeat()
93 netif_err(efx, hw, efx->net_dev, in qt2025c_wait_heartbeat()
105 static int qt2025c_wait_fw_status_good(struct ef4_nic *efx) in qt2025c_wait_fw_status_good() argument
112 reg = ef4_mdio_read(efx, MDIO_MMD_PCS, PCS_UC8051_STATUS_REG); in qt2025c_wait_fw_status_good()
127 static void qt2025c_restart_firmware(struct ef4_nic *efx) in qt2025c_restart_firmware() argument
130 ef4_mdio_write(efx, 3, 0xe854, 0x00c0); in qt2025c_restart_firmware()
131 ef4_mdio_write(efx, 3, 0xe854, 0x0040); in qt2025c_restart_firmware()
135 static int qt2025c_wait_reset(struct ef4_nic *efx) in qt2025c_wait_reset() argument
139 rc = qt2025c_wait_heartbeat(efx); in qt2025c_wait_reset()
143 rc = qt2025c_wait_fw_status_good(efx); in qt2025c_wait_reset()
148 netif_dbg(efx, hw, efx->net_dev, in qt2025c_wait_reset()
150 qt2025c_restart_firmware(efx); in qt2025c_wait_reset()
151 rc = qt2025c_wait_heartbeat(efx); in qt2025c_wait_reset()
154 rc = qt2025c_wait_fw_status_good(efx); in qt2025c_wait_reset()
160 static void qt2025c_firmware_id(struct ef4_nic *efx) in qt2025c_firmware_id() argument
162 struct qt202x_phy_data *phy_data = efx->phy_data; in qt2025c_firmware_id()
167 firmware_id[i] = ef4_mdio_read(efx, MDIO_MMD_PCS, in qt2025c_firmware_id()
169 netif_info(efx, probe, efx->net_dev, in qt2025c_firmware_id()
180 static void qt2025c_bug17190_workaround(struct ef4_nic *efx) in qt2025c_bug17190_workaround() argument
182 struct qt202x_phy_data *phy_data = efx->phy_data; in qt2025c_bug17190_workaround()
190 if (efx->link_state.up || in qt2025c_bug17190_workaround()
191 !ef4_mdio_links_ok(efx, MDIO_DEVS_PMAPMD | MDIO_DEVS_PHYXS)) { in qt2025c_bug17190_workaround()
203 netif_dbg(efx, hw, efx->net_dev, "bashing QT2025C PMA/PMD\n"); in qt2025c_bug17190_workaround()
204 ef4_mdio_set_flag(efx, MDIO_MMD_PMAPMD, MDIO_CTRL1, in qt2025c_bug17190_workaround()
207 ef4_mdio_set_flag(efx, MDIO_MMD_PMAPMD, MDIO_CTRL1, in qt2025c_bug17190_workaround()
213 static int qt2025c_select_phy_mode(struct ef4_nic *efx) in qt2025c_select_phy_mode() argument
215 struct qt202x_phy_data *phy_data = efx->phy_data; in qt2025c_select_phy_mode()
216 struct falcon_board *board = falcon_board(efx); in qt2025c_select_phy_mode()
230 phy_op_mode = (efx->loopback_mode == LOOPBACK_NONE) ? 0x0038 : 0x0020; in qt2025c_select_phy_mode()
233 reg = ef4_mdio_read(efx, 1, 0xc319); in qt2025c_select_phy_mode()
236 netif_dbg(efx, hw, efx->net_dev, "Switching PHY to mode 0x%04x\n", in qt2025c_select_phy_mode()
243 ef4_mdio_write(efx, 1, 0xc300, 0x0000); in qt2025c_select_phy_mode()
249 ef4_mdio_write(efx, 1, 0xc303, 0x4498); in qt2025c_select_phy_mode()
251 ef4_mdio_write(efx, 1, 0xc303, 0x4488); in qt2025c_select_phy_mode()
252 ef4_mdio_write(efx, 1, 0xc303, 0x4480); in qt2025c_select_phy_mode()
253 ef4_mdio_write(efx, 1, 0xc303, 0x4490); in qt2025c_select_phy_mode()
254 ef4_mdio_write(efx, 1, 0xc303, 0x4498); in qt2025c_select_phy_mode()
257 ef4_mdio_write(efx, 1, 0xc303, 0x0920); in qt2025c_select_phy_mode()
258 ef4_mdio_write(efx, 1, 0xd008, 0x0004); in qt2025c_select_phy_mode()
260 ef4_mdio_write(efx, 1, 0xc303, 0x0900); in qt2025c_select_phy_mode()
261 ef4_mdio_write(efx, 1, 0xd008, 0x0005); in qt2025c_select_phy_mode()
262 ef4_mdio_write(efx, 1, 0xc303, 0x0920); in qt2025c_select_phy_mode()
263 ef4_mdio_write(efx, 1, 0xd008, 0x0004); in qt2025c_select_phy_mode()
265 ef4_mdio_write(efx, 1, 0xc303, 0x4900); in qt2025c_select_phy_mode()
267 ef4_mdio_write(efx, 1, 0xc303, 0x4900); in qt2025c_select_phy_mode()
268 ef4_mdio_write(efx, 1, 0xc302, 0x0004); in qt2025c_select_phy_mode()
269 ef4_mdio_write(efx, 1, 0xc316, 0x0013); in qt2025c_select_phy_mode()
270 ef4_mdio_write(efx, 1, 0xc318, 0x0054); in qt2025c_select_phy_mode()
271 ef4_mdio_write(efx, 1, 0xc319, phy_op_mode); in qt2025c_select_phy_mode()
272 ef4_mdio_write(efx, 1, 0xc31a, 0x0098); in qt2025c_select_phy_mode()
273 ef4_mdio_write(efx, 3, 0x0026, 0x0e00); in qt2025c_select_phy_mode()
274 ef4_mdio_write(efx, 3, 0x0027, 0x0013); in qt2025c_select_phy_mode()
275 ef4_mdio_write(efx, 3, 0x0028, 0xa528); in qt2025c_select_phy_mode()
276 ef4_mdio_write(efx, 1, 0xd006, 0x000a); in qt2025c_select_phy_mode()
277 ef4_mdio_write(efx, 1, 0xd007, 0x0009); in qt2025c_select_phy_mode()
278 ef4_mdio_write(efx, 1, 0xd008, 0x0004); in qt2025c_select_phy_mode()
283 ef4_mdio_write(efx, 1, 0xc317, 0x00ff); in qt2025c_select_phy_mode()
286 ef4_mdio_set_flag(efx, 1, PMA_PMD_MODE_REG, in qt2025c_select_phy_mode()
288 ef4_mdio_write(efx, 1, 0xc300, 0x0002); in qt2025c_select_phy_mode()
292 qt2025c_restart_firmware(efx); in qt2025c_select_phy_mode()
295 rc = qt2025c_wait_reset(efx); in qt2025c_select_phy_mode()
297 netif_err(efx, hw, efx->net_dev, in qt2025c_select_phy_mode()
306 static int qt202x_reset_phy(struct ef4_nic *efx) in qt202x_reset_phy() argument
310 if (efx->phy_type == PHY_TYPE_QT2025C) { in qt202x_reset_phy()
313 rc = qt2025c_wait_reset(efx); in qt202x_reset_phy()
319 rc = ef4_mdio_reset_mmd(efx, MDIO_MMD_PHYXS, in qt202x_reset_phy()
330 falcon_board(efx)->type->init_phy(efx); in qt202x_reset_phy()
335 netif_err(efx, hw, efx->net_dev, "PHY reset timed out\n"); in qt202x_reset_phy()
339 static int qt202x_phy_probe(struct ef4_nic *efx) in qt202x_phy_probe() argument
346 efx->phy_data = phy_data; in qt202x_phy_probe()
347 phy_data->phy_mode = efx->phy_mode; in qt202x_phy_probe()
351 efx->mdio.mmds = QT202X_REQUIRED_DEVS; in qt202x_phy_probe()
352 efx->mdio.mode_support = MDIO_SUPPORTS_C45 | MDIO_EMULATE_C22; in qt202x_phy_probe()
353 efx->loopback_modes = QT202X_LOOPBACKS | FALCON_XMAC_LOOPBACKS; in qt202x_phy_probe()
357 static int qt202x_phy_init(struct ef4_nic *efx) in qt202x_phy_init() argument
362 rc = qt202x_reset_phy(efx); in qt202x_phy_init()
364 netif_err(efx, probe, efx->net_dev, "PHY init failed\n"); in qt202x_phy_init()
368 devid = ef4_mdio_read_id(efx, MDIO_MMD_PHYXS); in qt202x_phy_init()
369 netif_info(efx, probe, efx->net_dev, in qt202x_phy_init()
374 if (efx->phy_type == PHY_TYPE_QT2025C) in qt202x_phy_init()
375 qt2025c_firmware_id(efx); in qt202x_phy_init()
380 static int qt202x_link_ok(struct ef4_nic *efx) in qt202x_link_ok() argument
382 return ef4_mdio_links_ok(efx, QT202X_REQUIRED_DEVS); in qt202x_link_ok()
385 static bool qt202x_phy_poll(struct ef4_nic *efx) in qt202x_phy_poll() argument
387 bool was_up = efx->link_state.up; in qt202x_phy_poll()
389 efx->link_state.up = qt202x_link_ok(efx); in qt202x_phy_poll()
390 efx->link_state.speed = 10000; in qt202x_phy_poll()
391 efx->link_state.fd = true; in qt202x_phy_poll()
392 efx->link_state.fc = efx->wanted_fc; in qt202x_phy_poll()
394 if (efx->phy_type == PHY_TYPE_QT2025C) in qt202x_phy_poll()
395 qt2025c_bug17190_workaround(efx); in qt202x_phy_poll()
397 return efx->link_state.up != was_up; in qt202x_phy_poll()
400 static int qt202x_phy_reconfigure(struct ef4_nic *efx) in qt202x_phy_reconfigure() argument
402 struct qt202x_phy_data *phy_data = efx->phy_data; in qt202x_phy_reconfigure()
404 if (efx->phy_type == PHY_TYPE_QT2025C) { in qt202x_phy_reconfigure()
405 int rc = qt2025c_select_phy_mode(efx); in qt202x_phy_reconfigure()
415 &efx->mdio, efx->mdio.prtad, MDIO_MMD_PMAPMD, in qt202x_phy_reconfigure()
417 efx->phy_mode & PHY_MODE_TX_DISABLED || in qt202x_phy_reconfigure()
418 efx->phy_mode & PHY_MODE_LOW_POWER || in qt202x_phy_reconfigure()
419 efx->loopback_mode == LOOPBACK_PCS || in qt202x_phy_reconfigure()
420 efx->loopback_mode == LOOPBACK_PMAPMD); in qt202x_phy_reconfigure()
423 if (!(efx->phy_mode & PHY_MODE_TX_DISABLED) && in qt202x_phy_reconfigure()
425 qt202x_reset_phy(efx); in qt202x_phy_reconfigure()
427 ef4_mdio_transmit_disable(efx); in qt202x_phy_reconfigure()
430 ef4_mdio_phy_reconfigure(efx); in qt202x_phy_reconfigure()
432 phy_data->phy_mode = efx->phy_mode; in qt202x_phy_reconfigure()
437 static void qt202x_phy_get_link_ksettings(struct ef4_nic *efx, in qt202x_phy_get_link_ksettings() argument
440 mdio45_ethtool_ksettings_get(&efx->mdio, cmd); in qt202x_phy_get_link_ksettings()
443 static void qt202x_phy_remove(struct ef4_nic *efx) in qt202x_phy_remove() argument
446 kfree(efx->phy_data); in qt202x_phy_remove()
447 efx->phy_data = NULL; in qt202x_phy_remove()
450 static int qt202x_phy_get_module_info(struct ef4_nic *efx, in qt202x_phy_get_module_info() argument
458 static int qt202x_phy_get_module_eeprom(struct ef4_nic *efx, in qt202x_phy_get_module_eeprom() argument
463 if (efx->phy_type == PHY_TYPE_QT2025C) { in qt202x_phy_get_module_eeprom()
472 rc = ef4_mdio_read(efx, mmd, reg_base + ee->offset + i); in qt202x_phy_get_module_eeprom()