Skip to content

Commit e24a6c8

Browse files
aspeedJackykuba-moo
authored andcommitted
net: ftgmac100: Get link speed and duplex for NC-SI
The ethtool of this driver uses the phy API of ethtool to get the link information from PHY driver. Because the NC-SI is forced on 100Mbps and full duplex, the driver connect a fixed-link phy driver for NC-SI. The ethtool will get the link information from the fixed-link phy driver. Signed-off-by: Jacky Chou <[email protected]> Reviewed-by: Jacob Keller <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent 59a0ad4 commit e24a6c8

File tree

1 file changed

+26
-2
lines changed

1 file changed

+26
-2
lines changed

drivers/net/ethernet/faraday/ftgmac100.c

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
#include <linux/crc32.h>
2525
#include <linux/if_vlan.h>
2626
#include <linux/of_net.h>
27+
#include <linux/phy_fixed.h>
2728
#include <net/ip.h>
2829
#include <net/ncsi.h>
2930

@@ -50,6 +51,15 @@
5051
#define FTGMAC_100MHZ 100000000
5152
#define FTGMAC_25MHZ 25000000
5253

54+
/* For NC-SI to register a fixed-link phy device */
55+
static struct fixed_phy_status ncsi_phy_status = {
56+
.link = 1,
57+
.speed = SPEED_100,
58+
.duplex = DUPLEX_FULL,
59+
.pause = 0,
60+
.asym_pause = 0
61+
};
62+
5363
struct ftgmac100 {
5464
/* Registers */
5565
struct resource *res;
@@ -1531,7 +1541,8 @@ static int ftgmac100_open(struct net_device *netdev)
15311541
if (netdev->phydev) {
15321542
/* If we have a PHY, start polling */
15331543
phy_start(netdev->phydev);
1534-
} else if (priv->use_ncsi) {
1544+
}
1545+
if (priv->use_ncsi) {
15351546
/* If using NC-SI, set our carrier on and start the stack */
15361547
netif_carrier_on(netdev);
15371548

@@ -1544,6 +1555,7 @@ static int ftgmac100_open(struct net_device *netdev)
15441555
return 0;
15451556

15461557
err_ncsi:
1558+
phy_stop(netdev->phydev);
15471559
napi_disable(&priv->napi);
15481560
netif_stop_queue(netdev);
15491561
err_alloc:
@@ -1577,7 +1589,7 @@ static int ftgmac100_stop(struct net_device *netdev)
15771589
netif_napi_del(&priv->napi);
15781590
if (netdev->phydev)
15791591
phy_stop(netdev->phydev);
1580-
else if (priv->use_ncsi)
1592+
if (priv->use_ncsi)
15811593
ncsi_stop_dev(priv->ndev);
15821594

15831595
ftgmac100_stop_hw(priv);
@@ -1715,6 +1727,9 @@ static void ftgmac100_phy_disconnect(struct net_device *netdev)
17151727
phy_disconnect(netdev->phydev);
17161728
if (of_phy_is_fixed_link(priv->dev->of_node))
17171729
of_phy_deregister_fixed_link(priv->dev->of_node);
1730+
1731+
if (priv->use_ncsi)
1732+
fixed_phy_unregister(netdev->phydev);
17181733
}
17191734

17201735
static void ftgmac100_destroy_mdio(struct net_device *netdev)
@@ -1792,6 +1807,7 @@ static int ftgmac100_probe(struct platform_device *pdev)
17921807
struct resource *res;
17931808
int irq;
17941809
struct net_device *netdev;
1810+
struct phy_device *phydev;
17951811
struct ftgmac100 *priv;
17961812
struct device_node *np;
17971813
int err = 0;
@@ -1879,6 +1895,14 @@ static int ftgmac100_probe(struct platform_device *pdev)
18791895
err = -EINVAL;
18801896
goto err_phy_connect;
18811897
}
1898+
1899+
phydev = fixed_phy_register(PHY_POLL, &ncsi_phy_status, NULL);
1900+
err = phy_connect_direct(netdev, phydev, ftgmac100_adjust_link,
1901+
PHY_INTERFACE_MODE_MII);
1902+
if (err) {
1903+
dev_err(&pdev->dev, "Connecting PHY failed\n");
1904+
goto err_phy_connect;
1905+
}
18821906
} else if (np && of_phy_is_fixed_link(np)) {
18831907
struct phy_device *phy;
18841908

0 commit comments

Comments
 (0)