WIP FPC-III support
[linux/fpc-iii.git] / drivers / net / ethernet / sfc / falcon / mdio_10g.h
blobde676bfa064da31c451eb5a5e05961b7b5838840
1 /* SPDX-License-Identifier: GPL-2.0-only */
2 /****************************************************************************
3 * Driver for Solarflare network controllers and boards
4 * Copyright 2006-2011 Solarflare Communications Inc.
5 */
7 #ifndef EF4_MDIO_10G_H
8 #define EF4_MDIO_10G_H
10 #include <linux/mdio.h>
13 * Helper functions for doing 10G MDIO as specified in IEEE 802.3 clause 45.
16 #include "efx.h"
18 static inline unsigned ef4_mdio_id_rev(u32 id) { return id & 0xf; }
19 static inline unsigned ef4_mdio_id_model(u32 id) { return (id >> 4) & 0x3f; }
20 unsigned ef4_mdio_id_oui(u32 id);
22 static inline int ef4_mdio_read(struct ef4_nic *efx, int devad, int addr)
24 return efx->mdio.mdio_read(efx->net_dev, efx->mdio.prtad, devad, addr);
27 static inline void
28 ef4_mdio_write(struct ef4_nic *efx, int devad, int addr, int value)
30 efx->mdio.mdio_write(efx->net_dev, efx->mdio.prtad, devad, addr, value);
33 static inline u32 ef4_mdio_read_id(struct ef4_nic *efx, int mmd)
35 u16 id_low = ef4_mdio_read(efx, mmd, MDIO_DEVID2);
36 u16 id_hi = ef4_mdio_read(efx, mmd, MDIO_DEVID1);
37 return (id_hi << 16) | (id_low);
40 static inline bool ef4_mdio_phyxgxs_lane_sync(struct ef4_nic *efx)
42 int i, lane_status;
43 bool sync;
45 for (i = 0; i < 2; ++i)
46 lane_status = ef4_mdio_read(efx, MDIO_MMD_PHYXS,
47 MDIO_PHYXS_LNSTAT);
49 sync = !!(lane_status & MDIO_PHYXS_LNSTAT_ALIGN);
50 if (!sync)
51 netif_dbg(efx, hw, efx->net_dev, "XGXS lane status: %x\n",
52 lane_status);
53 return sync;
56 const char *ef4_mdio_mmd_name(int mmd);
59 * Reset a specific MMD and wait for reset to clear.
60 * Return number of spins left (>0) on success, -%ETIMEDOUT on failure.
62 * This function will sleep
64 int ef4_mdio_reset_mmd(struct ef4_nic *efx, int mmd, int spins, int spintime);
66 /* As ef4_mdio_check_mmd but for multiple MMDs */
67 int ef4_mdio_check_mmds(struct ef4_nic *efx, unsigned int mmd_mask);
69 /* Check the link status of specified mmds in bit mask */
70 bool ef4_mdio_links_ok(struct ef4_nic *efx, unsigned int mmd_mask);
72 /* Generic transmit disable support though PMAPMD */
73 void ef4_mdio_transmit_disable(struct ef4_nic *efx);
75 /* Generic part of reconfigure: set/clear loopback bits */
76 void ef4_mdio_phy_reconfigure(struct ef4_nic *efx);
78 /* Set the power state of the specified MMDs */
79 void ef4_mdio_set_mmds_lpower(struct ef4_nic *efx, int low_power,
80 unsigned int mmd_mask);
82 /* Set (some of) the PHY settings over MDIO */
83 int ef4_mdio_set_link_ksettings(struct ef4_nic *efx,
84 const struct ethtool_link_ksettings *cmd);
86 /* Push advertising flags and restart autonegotiation */
87 void ef4_mdio_an_reconfigure(struct ef4_nic *efx);
89 /* Get pause parameters from AN if available (otherwise return
90 * requested pause parameters)
92 u8 ef4_mdio_get_pause(struct ef4_nic *efx);
94 /* Wait for specified MMDs to exit reset within a timeout */
95 int ef4_mdio_wait_reset_mmds(struct ef4_nic *efx, unsigned int mmd_mask);
97 /* Set or clear flag, debouncing */
98 static inline void
99 ef4_mdio_set_flag(struct ef4_nic *efx, int devad, int addr,
100 int mask, bool state)
102 mdio_set_flag(&efx->mdio, efx->mdio.prtad, devad, addr, mask, state);
105 /* Liveness self-test for MDIO PHYs */
106 int ef4_mdio_test_alive(struct ef4_nic *efx);
108 #endif /* EF4_MDIO_10G_H */