forked from acooks/tn40xx-driver
-
Notifications
You must be signed in to change notification settings - Fork 0
/
TLK10232_phy_Linux.c
88 lines (64 loc) · 2.13 KB
/
TLK10232_phy_Linux.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
#include "tn40.h"
int TLK10232_get_settings(struct net_device *netdev, struct ethtool_cmd *ecmd)
{
struct bdx_priv *priv = netdev_priv(netdev);
ecmd->supported =
(SUPPORTED_10000baseT_Full | SUPPORTED_FIBRE | SUPPORTED_Pause);
ecmd->advertising = (ADVERTISED_10000baseT_Full | ADVERTISED_Pause);
if (READ_REG(priv, regMAC_LNK_STAT) & MAC_LINK_STAT) {
ecmd->speed = priv->link_speed;
} else {
ecmd->speed = 0;
}
ecmd->duplex = DUPLEX_FULL;
ecmd->port = PORT_FIBRE;
ecmd->transceiver = XCVR_EXTERNAL;
ecmd->autoneg = AUTONEG_DISABLE;
return 0;
}
int TLK10232_set_settings(struct net_device *netdev, struct ethtool_cmd *ecmd)
{
struct bdx_priv *priv = netdev_priv(netdev);
pr_err("%s Does not support ethtool -s option\n", priv->ndev->name);
return -EPERM;
}
#ifdef ETHTOOL_GLINKSETTINGS
int TLK10232_get_link_ksettings(struct net_device *netdev,
struct ethtool_link_ksettings *cmd)
{
struct bdx_priv *priv = netdev_priv(netdev);
cmd->base.speed =
(READ_REG(priv, regMAC_LNK_STAT) & MAC_LINK_STAT) ? priv->link_speed
: 0;
cmd->base.port = PORT_FIBRE;
cmd->base.autoneg = AUTONEG_DISABLE;
cmd->base.duplex = DUPLEX_FULL;
__set_bit(ETHTOOL_LINK_MODE_10000baseT_Full_BIT,
cmd->link_modes.supported);
__set_bit(ETHTOOL_LINK_MODE_Pause_BIT, cmd->link_modes.supported);
__set_bit(ETHTOOL_LINK_MODE_FIBRE_BIT, cmd->link_modes.supported);;
memcpy(cmd->link_modes.advertising, cmd->link_modes.supported,
sizeof(cmd->link_modes.advertising));
return 0;
}
#endif
#ifdef ETHTOOL_SLINKSETTINGS
int TLK10232_set_link_ksettings(struct net_device *netdev,
const struct ethtool_link_ksettings *cmd)
{
struct bdx_priv *priv = netdev_priv(netdev);
pr_err("%s Does not support ethtool -s option\n", priv->ndev->name);
return -EPERM;
}
#endif
__init void TLK10232_register_settings(struct bdx_priv *priv)
{
priv->phy_ops.get_settings = TLK10232_get_settings;
priv->phy_ops.set_settings = TLK10232_set_settings;
#ifdef ETHTOOL_GLINKSETTINGS
priv->phy_ops.get_link_ksettings = TLK10232_get_link_ksettings;
#endif
#ifdef ETHTOOL_SLINKSETTINGS
priv->phy_ops.set_link_ksettings = TLK10232_set_link_ksettings;
#endif
}