0001
0002
0003
0004
0005
0006
0007 #ifndef EF4_MDIO_10G_H
0008 #define EF4_MDIO_10G_H
0009
0010 #include <linux/mdio.h>
0011
0012
0013
0014
0015
0016 #include "efx.h"
0017
0018 static inline unsigned ef4_mdio_id_rev(u32 id) { return id & 0xf; }
0019 static inline unsigned ef4_mdio_id_model(u32 id) { return (id >> 4) & 0x3f; }
0020 unsigned ef4_mdio_id_oui(u32 id);
0021
0022 static inline int ef4_mdio_read(struct ef4_nic *efx, int devad, int addr)
0023 {
0024 return efx->mdio.mdio_read(efx->net_dev, efx->mdio.prtad, devad, addr);
0025 }
0026
0027 static inline void
0028 ef4_mdio_write(struct ef4_nic *efx, int devad, int addr, int value)
0029 {
0030 efx->mdio.mdio_write(efx->net_dev, efx->mdio.prtad, devad, addr, value);
0031 }
0032
0033 static inline u32 ef4_mdio_read_id(struct ef4_nic *efx, int mmd)
0034 {
0035 u16 id_low = ef4_mdio_read(efx, mmd, MDIO_DEVID2);
0036 u16 id_hi = ef4_mdio_read(efx, mmd, MDIO_DEVID1);
0037 return (id_hi << 16) | (id_low);
0038 }
0039
0040 static inline bool ef4_mdio_phyxgxs_lane_sync(struct ef4_nic *efx)
0041 {
0042 int i, lane_status;
0043 bool sync;
0044
0045 for (i = 0; i < 2; ++i)
0046 lane_status = ef4_mdio_read(efx, MDIO_MMD_PHYXS,
0047 MDIO_PHYXS_LNSTAT);
0048
0049 sync = !!(lane_status & MDIO_PHYXS_LNSTAT_ALIGN);
0050 if (!sync)
0051 netif_dbg(efx, hw, efx->net_dev, "XGXS lane status: %x\n",
0052 lane_status);
0053 return sync;
0054 }
0055
0056 const char *ef4_mdio_mmd_name(int mmd);
0057
0058
0059
0060
0061
0062
0063
0064 int ef4_mdio_reset_mmd(struct ef4_nic *efx, int mmd, int spins, int spintime);
0065
0066
0067 int ef4_mdio_check_mmds(struct ef4_nic *efx, unsigned int mmd_mask);
0068
0069
0070 bool ef4_mdio_links_ok(struct ef4_nic *efx, unsigned int mmd_mask);
0071
0072
0073 void ef4_mdio_transmit_disable(struct ef4_nic *efx);
0074
0075
0076 void ef4_mdio_phy_reconfigure(struct ef4_nic *efx);
0077
0078
0079 void ef4_mdio_set_mmds_lpower(struct ef4_nic *efx, int low_power,
0080 unsigned int mmd_mask);
0081
0082
0083 int ef4_mdio_set_link_ksettings(struct ef4_nic *efx,
0084 const struct ethtool_link_ksettings *cmd);
0085
0086
0087 void ef4_mdio_an_reconfigure(struct ef4_nic *efx);
0088
0089
0090
0091
0092 u8 ef4_mdio_get_pause(struct ef4_nic *efx);
0093
0094
0095 int ef4_mdio_wait_reset_mmds(struct ef4_nic *efx, unsigned int mmd_mask);
0096
0097
0098 static inline void
0099 ef4_mdio_set_flag(struct ef4_nic *efx, int devad, int addr,
0100 int mask, bool state)
0101 {
0102 mdio_set_flag(&efx->mdio, efx->mdio.prtad, devad, addr, mask, state);
0103 }
0104
0105
0106 int ef4_mdio_test_alive(struct ef4_nic *efx);
0107
0108 #endif