Lines Matching refs:efx
168 static void txc_reset_logic(struct ef4_nic *efx);
171 void falcon_txc_set_gpio_val(struct ef4_nic *efx, int pin, int on) in falcon_txc_set_gpio_val() argument
173 ef4_mdio_set_flag(efx, MDIO_MMD_PHYXS, TXC_GPIO_OUTPUT, 1 << pin, on); in falcon_txc_set_gpio_val()
177 void falcon_txc_set_gpio_dir(struct ef4_nic *efx, int pin, int dir) in falcon_txc_set_gpio_dir() argument
179 ef4_mdio_set_flag(efx, MDIO_MMD_PHYXS, TXC_GPIO_DIR, 1 << pin, dir); in falcon_txc_set_gpio_dir()
184 static int txc_reset_phy(struct ef4_nic *efx) in txc_reset_phy() argument
186 int rc = ef4_mdio_reset_mmd(efx, MDIO_MMD_PMAPMD, in txc_reset_phy()
193 rc = ef4_mdio_check_mmds(efx, TXC_REQUIRED_DEVS); in txc_reset_phy()
200 netif_err(efx, hw, efx->net_dev, TXCNAME ": reset timed out!\n"); in txc_reset_phy()
205 static int txc_bist_one(struct ef4_nic *efx, int mmd, int test) in txc_bist_one() argument
212 ctrl = ef4_mdio_read(efx, MDIO_MMD_PCS, TXC_MTDIABLO_CTRL); in txc_bist_one()
214 ef4_mdio_write(efx, MDIO_MMD_PCS, TXC_MTDIABLO_CTRL, ctrl); in txc_bist_one()
219 ef4_mdio_write(efx, mmd, TXC_BIST_CTL, bctl); in txc_bist_one()
223 ef4_mdio_write(efx, mmd, TXC_BIST_CTL, bctl); in txc_bist_one()
226 ef4_mdio_write(efx, mmd, TXC_BIST_CTL, in txc_bist_one()
234 ef4_mdio_write(efx, mmd, TXC_BIST_CTL, bctl); in txc_bist_one()
238 bctl = ef4_mdio_read(efx, mmd, TXC_BIST_CTL); in txc_bist_one()
243 int count = ef4_mdio_read(efx, mmd, TXC_BIST_RX0ERRCNT + lane); in txc_bist_one()
245 netif_err(efx, hw, efx->net_dev, TXCNAME": BIST error. " in txc_bist_one()
249 count = ef4_mdio_read(efx, mmd, TXC_BIST_RX0FRMCNT + lane); in txc_bist_one()
251 netif_err(efx, hw, efx->net_dev, TXCNAME": BIST error. " in txc_bist_one()
258 netif_info(efx, hw, efx->net_dev, TXCNAME": BIST pass\n"); in txc_bist_one()
261 ef4_mdio_write(efx, mmd, TXC_BIST_CTL, 0); in txc_bist_one()
265 ef4_mdio_write(efx, MDIO_MMD_PCS, TXC_MTDIABLO_CTRL, ctrl); in txc_bist_one()
270 static int txc_bist(struct ef4_nic *efx) in txc_bist() argument
272 return txc_bist_one(efx, MDIO_MMD_PCS, TXC_BIST_CTRL_TYPE_TSD); in txc_bist()
277 static void txc_apply_defaults(struct ef4_nic *efx) in txc_apply_defaults() argument
287 ef4_mdio_write(efx, MDIO_MMD_PHYXS, TXC_ALRGS_ATXPRE0, TXC_ATXPRE_NONE); in txc_apply_defaults()
288 ef4_mdio_write(efx, MDIO_MMD_PHYXS, TXC_ALRGS_ATXPRE1, TXC_ATXPRE_NONE); in txc_apply_defaults()
291 ef4_mdio_write(efx, MDIO_MMD_PHYXS, in txc_apply_defaults()
293 ef4_mdio_write(efx, MDIO_MMD_PHYXS, in txc_apply_defaults()
299 ef4_mdio_write(efx, MDIO_MMD_PMAPMD, in txc_apply_defaults()
301 ef4_mdio_write(efx, MDIO_MMD_PMAPMD, in txc_apply_defaults()
303 ef4_mdio_write(efx, MDIO_MMD_PMAPMD, in txc_apply_defaults()
305 ef4_mdio_write(efx, MDIO_MMD_PMAPMD, in txc_apply_defaults()
309 mctrl = ef4_mdio_read(efx, MDIO_MMD_PHYXS, TXC_MRGS_CTL); in txc_apply_defaults()
313 ef4_mdio_write(efx, MDIO_MMD_PHYXS, TXC_MRGS_CTL, mctrl); in txc_apply_defaults()
316 txc_reset_logic(efx); in txc_apply_defaults()
318 falcon_board(efx)->type->init_phy(efx); in txc_apply_defaults()
321 static int txc43128_phy_probe(struct ef4_nic *efx) in txc43128_phy_probe() argument
329 efx->phy_data = phy_data; in txc43128_phy_probe()
330 phy_data->phy_mode = efx->phy_mode; in txc43128_phy_probe()
332 efx->mdio.mmds = TXC_REQUIRED_DEVS; in txc43128_phy_probe()
333 efx->mdio.mode_support = MDIO_SUPPORTS_C45 | MDIO_EMULATE_C22; in txc43128_phy_probe()
335 efx->loopback_modes = TXC_LOOPBACKS | FALCON_XMAC_LOOPBACKS; in txc43128_phy_probe()
341 static int txc43128_phy_init(struct ef4_nic *efx) in txc43128_phy_init() argument
345 rc = txc_reset_phy(efx); in txc43128_phy_init()
349 rc = txc_bist(efx); in txc43128_phy_init()
353 txc_apply_defaults(efx); in txc43128_phy_init()
359 static void txc_glrgs_lane_power(struct ef4_nic *efx, int mmd) in txc_glrgs_lane_power() argument
362 int ctl = ef4_mdio_read(efx, mmd, TXC_GLRGS_GLCMD); in txc_glrgs_lane_power()
364 if (!(efx->phy_mode & PHY_MODE_LOW_POWER)) in txc_glrgs_lane_power()
369 ef4_mdio_write(efx, mmd, TXC_GLRGS_GLCMD, ctl); in txc_glrgs_lane_power()
373 static void txc_analog_lane_power(struct ef4_nic *efx, int mmd) in txc_analog_lane_power() argument
379 int txctl = ef4_mdio_read(efx, mmd, TXC_ALRGS_ATXCTL); in txc_analog_lane_power()
380 int rxctl = ef4_mdio_read(efx, mmd, TXC_ALRGS_ARXCTL); in txc_analog_lane_power()
382 if (!(efx->phy_mode & PHY_MODE_LOW_POWER)) { in txc_analog_lane_power()
390 ef4_mdio_write(efx, mmd, TXC_ALRGS_ATXCTL, txctl); in txc_analog_lane_power()
391 ef4_mdio_write(efx, mmd, TXC_ALRGS_ARXCTL, rxctl); in txc_analog_lane_power()
394 static void txc_set_power(struct ef4_nic *efx) in txc_set_power() argument
397 ef4_mdio_set_mmds_lpower(efx, in txc_set_power()
398 !!(efx->phy_mode & PHY_MODE_LOW_POWER), in txc_set_power()
403 txc_glrgs_lane_power(efx, MDIO_MMD_PCS); in txc_set_power()
404 txc_glrgs_lane_power(efx, MDIO_MMD_PHYXS); in txc_set_power()
407 txc_analog_lane_power(efx, MDIO_MMD_PMAPMD); in txc_set_power()
408 txc_analog_lane_power(efx, MDIO_MMD_PHYXS); in txc_set_power()
411 static void txc_reset_logic_mmd(struct ef4_nic *efx, int mmd) in txc_reset_logic_mmd() argument
413 int val = ef4_mdio_read(efx, mmd, TXC_GLRGS_GLCMD); in txc_reset_logic_mmd()
417 ef4_mdio_write(efx, mmd, TXC_GLRGS_GLCMD, val); in txc_reset_logic_mmd()
419 val = ef4_mdio_read(efx, mmd, TXC_GLRGS_GLCMD); in txc_reset_logic_mmd()
425 netif_info(efx, hw, efx->net_dev, in txc_reset_logic_mmd()
431 static void txc_reset_logic(struct ef4_nic *efx) in txc_reset_logic() argument
436 txc_reset_logic_mmd(efx, MDIO_MMD_PCS); in txc_reset_logic()
439 static bool txc43128_phy_read_link(struct ef4_nic *efx) in txc43128_phy_read_link() argument
441 return ef4_mdio_links_ok(efx, TXC_REQUIRED_DEVS); in txc43128_phy_read_link()
444 static int txc43128_phy_reconfigure(struct ef4_nic *efx) in txc43128_phy_reconfigure() argument
446 struct txc43128_data *phy_data = efx->phy_data; in txc43128_phy_reconfigure()
447 enum ef4_phy_mode mode_change = efx->phy_mode ^ phy_data->phy_mode; in txc43128_phy_reconfigure()
448 bool loop_change = LOOPBACK_CHANGED(phy_data, efx, TXC_LOOPBACKS); in txc43128_phy_reconfigure()
450 if (efx->phy_mode & mode_change & PHY_MODE_TX_DISABLED) { in txc43128_phy_reconfigure()
451 txc_reset_phy(efx); in txc43128_phy_reconfigure()
452 txc_apply_defaults(efx); in txc43128_phy_reconfigure()
453 falcon_reset_xaui(efx); in txc43128_phy_reconfigure()
457 ef4_mdio_transmit_disable(efx); in txc43128_phy_reconfigure()
458 ef4_mdio_phy_reconfigure(efx); in txc43128_phy_reconfigure()
460 txc_set_power(efx); in txc43128_phy_reconfigure()
467 txc_reset_logic(efx); in txc43128_phy_reconfigure()
469 phy_data->phy_mode = efx->phy_mode; in txc43128_phy_reconfigure()
470 phy_data->loopback_mode = efx->loopback_mode; in txc43128_phy_reconfigure()
475 static void txc43128_phy_fini(struct ef4_nic *efx) in txc43128_phy_fini() argument
478 ef4_mdio_write(efx, MDIO_MMD_PMAPMD, MDIO_PMA_LASI_CTRL, 0); in txc43128_phy_fini()
481 static void txc43128_phy_remove(struct ef4_nic *efx) in txc43128_phy_remove() argument
483 kfree(efx->phy_data); in txc43128_phy_remove()
484 efx->phy_data = NULL; in txc43128_phy_remove()
489 static bool txc43128_phy_poll(struct ef4_nic *efx) in txc43128_phy_poll() argument
491 struct txc43128_data *data = efx->phy_data; in txc43128_phy_poll()
492 bool was_up = efx->link_state.up; in txc43128_phy_poll()
494 efx->link_state.up = txc43128_phy_read_link(efx); in txc43128_phy_poll()
495 efx->link_state.speed = 10000; in txc43128_phy_poll()
496 efx->link_state.fd = true; in txc43128_phy_poll()
497 efx->link_state.fc = efx->wanted_fc; in txc43128_phy_poll()
499 if (efx->link_state.up || (efx->loopback_mode != LOOPBACK_NONE)) { in txc43128_phy_poll()
505 txc_reset_logic(efx); in txc43128_phy_poll()
509 return efx->link_state.up != was_up; in txc43128_phy_poll()
516 static const char *txc43128_test_name(struct ef4_nic *efx, unsigned int index) in txc43128_test_name() argument
523 static int txc43128_run_tests(struct ef4_nic *efx, int *results, unsigned flags) in txc43128_run_tests() argument
530 rc = txc_reset_phy(efx); in txc43128_run_tests()
534 rc = txc_bist(efx); in txc43128_run_tests()
535 txc_apply_defaults(efx); in txc43128_run_tests()
540 static void txc43128_get_link_ksettings(struct ef4_nic *efx, in txc43128_get_link_ksettings() argument
543 mdio45_ethtool_ksettings_get(&efx->mdio, cmd); in txc43128_get_link_ksettings()