[PATCH u-boot v2019.04-aspeed-openbmc 3/4] ftgmac100: Simplify NCSI detection

Joel Stanley joel at jms.id.au
Fri Jun 10 18:00:58 AEST 2022


We don't need priv->ncsi_mode as we already have priv->phy_mode.

Signed-off-by: Joel Stanley <joel at jms.id.au>
---
 drivers/net/ftgmac100.c | 17 +++++------------
 1 file changed, 5 insertions(+), 12 deletions(-)

diff --git a/drivers/net/ftgmac100.c b/drivers/net/ftgmac100.c
index aa1d63880c8c..92170f52434e 100644
--- a/drivers/net/ftgmac100.c
+++ b/drivers/net/ftgmac100.c
@@ -18,7 +18,6 @@
 #include <wait_bit.h>
 #include <linux/io.h>
 #include <linux/iopoll.h>
-#include <net/ncsi.h>
 
 #include "ftgmac100.h"
 #include "aspeed_mdio.h"
@@ -85,7 +84,6 @@ struct ftgmac100_data {
 	struct mii_dev *bus;
 	u32 phy_mode;
 	u32 max_speed;
-	bool ncsi_mode;
 
 	struct clk_bulk clks;
 
@@ -192,7 +190,7 @@ static int ftgmac100_phy_adjust_link(struct ftgmac100_data *priv)
 	struct phy_device *phydev = priv->phydev;
 	u32 maccr;
 
-	if (!phydev->link && !priv->ncsi_mode) {
+	if (!phydev->link && priv->phy_mode != PHY_INTERFACE_MODE_NCSI) {
 		dev_err(phydev->dev, "No link\n");
 		return -EREMOTEIO;
 	}
@@ -228,7 +226,7 @@ static int ftgmac100_phy_init(struct udevice *dev)
 	if (!phydev)
 		return -ENODEV;
 
-	if (!priv->ncsi_mode)
+	if (priv->phy_mode != PHY_INTERFACE_MODE_NCSI)
 		phydev->supported &= PHY_GBIT_FEATURES;
 	if (priv->max_speed) {
 		ret = phy_set_supported(phydev, priv->max_speed);
@@ -287,7 +285,7 @@ static void ftgmac100_stop(struct udevice *dev)
 
 	writel(0, &ftgmac100->maccr);
 
-	if (!priv->ncsi_mode)
+	if (priv->phy_mode != PHY_INTERFACE_MODE_NCSI)
 		phy_shutdown(priv->phydev);
 }
 
@@ -581,13 +579,8 @@ static int ftgmac100_probe(struct udevice *dev)
 {
 	struct eth_pdata *pdata = dev_get_platdata(dev);
 	struct ftgmac100_data *priv = dev_get_priv(dev);
-	const char *phy_mode;
 	int ret;
 
-	phy_mode = dev_read_string(dev, "phy-mode");
-	priv->ncsi_mode = dev_read_bool(dev, "use-ncsi") ||
-		(phy_mode && strcmp(phy_mode, "NC-SI") == 0);
-
 	priv->iobase = (struct ftgmac100 *)pdata->iobase;
 	priv->phy_mode = pdata->phy_interface;
 	priv->max_speed = pdata->max_speed;
@@ -596,7 +589,7 @@ static int ftgmac100_probe(struct udevice *dev)
 	if (ret)
 		goto out;
 
-	if (priv->ncsi_mode) {
+	if (priv->phy_mode == PHY_INTERFACE_MODE_NCSI) {
 		printf("%s - NCSI detected\n", __func__);
 	} else {
 		ret = ftgmac100_mdio_init(dev);
@@ -624,7 +617,7 @@ static int ftgmac100_remove(struct udevice *dev)
 {
 	struct ftgmac100_data *priv = dev_get_priv(dev);
 
-	if (!priv->ncsi_mode) {
+	if (priv->phy_mode != PHY_INTERFACE_MODE_NCSI) {
 		free(priv->phydev);
 		mdio_unregister(priv->bus);
 		mdio_free(priv->bus);
-- 
2.35.1



More information about the openbmc mailing list