Skip to contentSkip to conversation

Aquantia PHY driver updates to reduce FW dependency

PATCH Superseded Alex Marginean 2 participants 15 messages Aug 8, 2019 – Aug 12, 2019

Subsystems (2)

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

cover Aquantia PHY driver updates to reduce FW dependency

The main purpose of this patch series is to allow the AQR driver to run on a larger number of boards without having to use a custom aquantia FW on each of them. Configuration points that are exclusively controlled by PHY firmware are not configured based on phydev->interface as well as new DT node properties.

The patch set introduces a couple of new interface types (XFI and USXGMII), introduces a couple of binding documents and updates the ENETC eth driver to use the new interface types.

Alex Marginean (11):
include: phy: define XFI and USXGMII interface types
include: phy: add data field for private driver data
drivers: net: aquantia: use XFI, USXGMII interface types
drivers: net: aquantia: add PHY generation information
drivers: net: aquantia: set up SI protocol based on interface type
drivers: net: aquantia: set MDI reversal based on DT property
drivers: net: aquantia: set SMBus addr based on DT property
drivers: net: aquantia: use SI and LI status in loop waiting for link
up
doc: bindings: add bindings document for PHY nodes
doc: bindings: Aquantia PHY node binding
drivers: net: fsl_enetc: use XFI, USXGMII interface type macros

 doc/device-tree-bindings/net/aquantia-phy.txt |  25 ++
 doc/device-tree-bindings/net/phy.txt          |  24 ++
 drivers/net/fsl_enetc.c                       |   2 +
 drivers/net/phy/aquantia.c                    | 219 ++++++++++++++++--
 include/phy.h                                 |   3 +
 include/phy_interface.h                       |   4 +
 6 files changed, 263 insertions(+), 14 deletions(-)
 create mode 100644 doc/device-tree-bindings/net/aquantia-phy.txt
 create mode 100644 doc/device-tree-bindings/net/phy.txt
Signature · 1 line
2.17.1
#1 lore raw

PATCH 1/11 include: phy: define XFI and USXGMII interface types

Drivers currently use XGMII for XFI and USXGMII and, where needed, use other information to identify the actual protocol on the board. With these two defined drivers can now rely on DT phy-mode property.

---
 include/phy_interface.h | 4 ++++
 1 file changed, 4 insertions(+)
include/phy_interface.h +4 -0
index c6823189f8..73f3a3679c 100644
@@ -31,6 +31,8 @@ typedef enum {
 	PHY_INTERFACE_MODE_XLAUI,
 	PHY_INTERFACE_MODE_CAUI2,
 	PHY_INTERFACE_MODE_CAUI4,
+	PHY_INTERFACE_MODE_XFI,
+	PHY_INTERFACE_MODE_USXGMII,
 	PHY_INTERFACE_MODE_NONE,	/* Must be last */
 
 	PHY_INTERFACE_MODE_COUNT,
@@ -58,6 +60,8 @@ static const char * const phy_interface_strings[] = {
 	[PHY_INTERFACE_MODE_XLAUI]		= "xlaui4",
 	[PHY_INTERFACE_MODE_CAUI2]		= "caui2",
 	[PHY_INTERFACE_MODE_CAUI4]		= "caui4",
+	[PHY_INTERFACE_MODE_XFI]		= "xfi",
+	[PHY_INTERFACE_MODE_USXGMII]		= "usxgmii",
 	[PHY_INTERFACE_MODE_NONE]		= "",
 };
 
Signature · 1 line
2.17.1
#2 lore raw

PATCH 2/11 include: phy: add data field for private driver data

In reply to Alex Marginean

This is useful to carry custom information between the driver structure associated with a specific HW and the driver code.

---
 include/phy.h | 3 +++
 1 file changed, 3 insertions(+)
include/phy.h +3 -0
index f4530faeb9..58455d6493 100644
@@ -110,6 +110,9 @@ struct phy_driver {
 			 u16 val);
 
 	struct list_head list;
+
+	/* driver private data */
+	ulong data;
 };
 
 struct phy_device {
Signature · 1 line
2.17.1
#3 lore raw

PATCH 3/11 drivers: net: aquantia: use XFI, USXGMII interface types

In reply to Alex Marginean

The PHY supports XFI and USXGMII, the notable difference being that USX AN is enabled for USXGMII. Legacy code uses XGMII for any 10G proto and detects whether USX AN should be enabled or not using a PHY status register. Keep that functionality too, so we don't break existing drivers.

---
 drivers/net/phy/aquantia.c | 38 +++++++++++++++++++++++++++++---------
 1 file changed, 29 insertions(+), 9 deletions(-)
drivers/net/phy/aquantia.c +29 -9
index 465ec2d342..9dda87c4c9 100644
@@ -256,8 +256,10 @@ static int aquantia_upload_firmware(struct phy_device *phydev)
 
 int aquantia_config(struct phy_device *phydev)
 {
+	int if_type = phydev->interface;
 	u32 val, id, rstatus, fault;
 	u32 reg_val1 = 0;
+	int usx_an = 0;
 
 	id = phy_read(phydev, MDIO_MMD_VEND1, GLOBAL_FIRMWARE_ID);
 	rstatus = phy_read(phydev, MDIO_MMD_VEND1, GLOBAL_RSTATUS_1);
@@ -278,17 +280,35 @@ int aquantia_config(struct phy_device *phydev)
 		if (ret != 0)
 			return ret;
 	}
+	/*
+	 * for backward compatibility convert XGMII into either XFI or USX based
+	 * on FW config
+	 */
+	if (if_type == PHY_INTERFACE_MODE_XGMII) {
+		reg_val1 = phy_read(phydev, MDIO_MMD_PHYXS,
+				    AQUANTIA_SYSTEM_INTERFACE_SR);
+		if ((reg_val1 & AQUANTIA_SI_IN_USE_MASK) == AQUANTIA_SI_USXGMII)
+			if_type = PHY_INTERFACE_MODE_USXGMII;
+		else
+			if_type = PHY_INTERFACE_MODE_XFI;
+	}
+
 
 	val = phy_read(phydev, MDIO_MMD_PMAPMD, MII_BMCR);
 
-	if (phydev->interface == PHY_INTERFACE_MODE_SGMII) {
+	switch (if_type) {
+	case PHY_INTERFACE_MODE_SGMII:
 		/* 1000BASE-T mode */
 		phydev->advertising = SUPPORTED_1000baseT_Full;
 		phydev->supported = phydev->advertising;
 
 		val = (val & ~AQUNTIA_SPEED_LSB_MASK) | AQUNTIA_SPEED_MSB_MASK;
 		phy_write(phydev, MDIO_MMD_PMAPMD, MII_BMCR, val);
-	} else if (phydev->interface == PHY_INTERFACE_MODE_XGMII) {
+		break;
+	case PHY_INTERFACE_MODE_USXGMII:
+		usx_an = 1;
+		/* FALLTHROUGH */
+	case PHY_INTERFACE_MODE_XFI:
 		/* 10GBASE-T mode */
 		phydev->advertising = SUPPORTED_10000baseT_Full;
 		phydev->supported = phydev->advertising;
@@ -299,10 +319,8 @@ int aquantia_config(struct phy_device *phydev)
 				  AQUNTIA_SPEED_LSB_MASK |
 				  AQUNTIA_SPEED_MSB_MASK);
 
-		val = phy_read(phydev, MDIO_MMD_PHYXS,
-			       AQUANTIA_SYSTEM_INTERFACE_SR);
 		/* If SI is USXGMII then start USXGMII autoneg */
-		if ((val & AQUANTIA_SI_IN_USE_MASK) == AQUANTIA_SI_USXGMII) {
+		if (usx_an) {
 			reg_val1 =  phy_read(phydev, MDIO_MMD_PHYXS,
 					     AQUANTIA_VENDOR_PROVISIONING_REG);
 
@@ -317,22 +335,24 @@ int aquantia_config(struct phy_device *phydev)
 			printf("%s: system interface XFI\n",
 			       phydev->dev->name);
 		}
-
-	} else if (phydev->interface == PHY_INTERFACE_MODE_SGMII_2500) {
+		break;
+	case PHY_INTERFACE_MODE_SGMII_2500:
 		/* 2.5GBASE-T mode */
 		phydev->advertising = SUPPORTED_1000baseT_Full;
 		phydev->supported = phydev->advertising;
 
 		phy_write(phydev, MDIO_MMD_AN, AQUNTIA_10G_CTL, 1);
 		phy_write(phydev, MDIO_MMD_AN, AQUNTIA_VENDOR_P1, 0x9440);
-	} else if (phydev->interface == PHY_INTERFACE_MODE_MII) {
+		break;
+	case PHY_INTERFACE_MODE_MII:
 		/* 100BASE-TX mode */
 		phydev->advertising = SUPPORTED_100baseT_Full;
 		phydev->supported = phydev->advertising;
 
 		val = (val & ~AQUNTIA_SPEED_MSB_MASK) | AQUNTIA_SPEED_LSB_MASK;
 		phy_write(phydev, MDIO_MMD_PMAPMD, MII_BMCR, val);
-	}
+		break;
+	};
 
 	val = phy_read(phydev, MDIO_MMD_VEND1, AQUANTIA_RESERVED_STATUS);
 	reg_val1 = phy_read(phydev, MDIO_MMD_VEND1, AQUANTIA_FIRMWARE_ID);
Signature · 1 line
2.17.1
#4 lore raw

PATCH 4/11 drivers: net: aquantia: add PHY generation information

In reply to Alex Marginean

Uses the data field in phy_driver structure to identify the PHY generation. This is useful for custom configuration as non-generic PHY registers are not 100% compatible between generations.

---
 drivers/net/phy/aquantia.c | 11 +++++++++++
 1 file changed, 11 insertions(+)
drivers/net/phy/aquantia.c +11 -0
index 9dda87c4c9..6425ba2021 100644
@@ -69,6 +69,12 @@
 #define VERSION_STRING_OFFSET 0x0200
 #define HEADER_OFFSET 0x300
 
+/* driver private data */
+#define AQUANTIA_NA		0
+#define AQUANTIA_GEN1		1
+#define AQUANTIA_GEN2		2
+#define AQUANTIA_GEN3		3
+
 #pragma pack(1)
 struct fw_header {
 	u8 padding[4];
@@ -453,6 +459,7 @@ struct phy_driver aqr105_driver = {
 	.config = &aquantia_config,
 	.startup = &aquantia_startup,
 	.shutdown = &gen10g_shutdown,
+	.data = AQUANTIA_GEN1,
 };
 
 struct phy_driver aqr106_driver = {
@@ -479,6 +486,7 @@ struct phy_driver aqr107_driver = {
 	.config = &aquantia_config,
 	.startup = &aquantia_startup,
 	.shutdown = &gen10g_shutdown,
+	.data = AQUANTIA_GEN2,
 };
 
 struct phy_driver aqr112_driver = {
@@ -492,6 +500,7 @@ struct phy_driver aqr112_driver = {
 	.config = &aquantia_config,
 	.startup = &aquantia_startup,
 	.shutdown = &gen10g_shutdown,
+	.data = AQUANTIA_GEN3,
 };
 
 struct phy_driver aqr405_driver = {
@@ -505,6 +514,7 @@ struct phy_driver aqr405_driver = {
 	.config = &aquantia_config,
 	.startup = &aquantia_startup,
 	.shutdown = &gen10g_shutdown,
+	.data = AQUANTIA_GEN1,
 };
 
 struct phy_driver aqr412_driver = {
@@ -518,6 +528,7 @@ struct phy_driver aqr412_driver = {
 	.config = &aquantia_config,
 	.startup = &aquantia_startup,
 	.shutdown = &gen10g_shutdown,
+	.data = AQUANTIA_GEN3,
 };
 
 int phy_aquantia_init(void)
Signature · 1 line
2.17.1
#5 lore raw

PATCH 5/11 drivers: net: aquantia: set up SI protocol based on interface type

In reply to Alex Marginean

If PHY is not ready for data by the time _config is called, reconfigure the PHY system interface to use the proper protocol based on phydev->interface, just in case the defaults set by PHY firmware don't match current configuration.

---
 drivers/net/phy/aquantia.c | 109 +++++++++++++++++++++++++++++++++++++
 1 file changed, 109 insertions(+)
drivers/net/phy/aquantia.c +109 -0
index 6425ba2021..ab165e76f5 100644
@@ -21,6 +21,7 @@
 #define AQUNTIA_SPEED_MSB_MASK	0x40
 
 #define AQUANTIA_SYSTEM_INTERFACE_SR     0xe812
+#define  AQUANTIA_SYSTEM_INTERFACE_SR_READY	BIT(0)
 #define AQUANTIA_VENDOR_PROVISIONING_REG 0xC441
 #define AQUANTIA_FIRMWARE_ID		 0x20
 #define AQUANTIA_RESERVED_STATUS	 0xc885
@@ -33,6 +34,9 @@
 #define AQUANTIA_SI_USXGMII              0x0018
 
 /* registers in MDIO_MMD_VEND1 region */
+#define AQUANTIA_VND1_GLOBAL_SC			0x000
+#define  AQUANTIA_VND1_GLOBAL_SC_LP		BIT(0xb)
+
 #define GLOBAL_FIRMWARE_ID 0x20
 #define GLOBAL_FAULT 0xc850
 #define GLOBAL_RSTATUS_1 0xc885
@@ -60,6 +64,26 @@
 #define UP_RUN_STALL_OVERRIDE BIT(6)
 #define UP_RUN_STALL BIT(0)
 
+/*
+ * global start rate, the protocol associated with this speed is used by default
+ * on SI.
+ */
+#define AQUANTIA_VND1_GSTART_RATE		0x31a
+#define  AQUANTIA_VND1_GSTART_RATE_OFF		0
+#define  AQUANTIA_VND1_GSTART_RATE_100M		1
+#define  AQUANTIA_VND1_GSTART_RATE_1G		2
+#define  AQUANTIA_VND1_GSTART_RATE_10G		3
+#define  AQUANTIA_VND1_GSTART_RATE_2_5G		4
+#define  AQUANTIA_VND1_GSTART_RATE_5G		5
+
+/* SYSCFG registers for 100M, 1G, 2.5G, 5G, 10G */
+#define AQUANTIA_VND1_GSYSCFG_BASE		0x31b
+#define AQUANTIA_VND1_GSYSCFG_100M		0
+#define AQUANTIA_VND1_GSYSCFG_1G		1
+#define AQUANTIA_VND1_GSYSCFG_2_5G		2
+#define AQUANTIA_VND1_GSYSCFG_5G		3
+#define AQUANTIA_VND1_GSYSCFG_10G		4
+
 /* addresses of memory segments in the phy */
 #define DRAM_BASE_ADDR 0x3FFE0000
 #define IRAM_BASE_ADDR 0x40000000
@@ -260,6 +284,72 @@ static int aquantia_upload_firmware(struct phy_device *phydev)
 }
 #endif
 
+struct {
+	u16 syscfg;
+	int cnt;
+	u16 start_rate;
+} aquantia_syscfg[PHY_INTERFACE_MODE_COUNT] = {
+	[PHY_INTERFACE_MODE_SGMII] =      {0x04b, AQUANTIA_VND1_GSYSCFG_1G,
+					   AQUANTIA_VND1_GSTART_RATE_1G},
+	[PHY_INTERFACE_MODE_SGMII_2500] = {0x144, AQUANTIA_VND1_GSYSCFG_2_5G,
+					   AQUANTIA_VND1_GSTART_RATE_2_5G},
+	[PHY_INTERFACE_MODE_XGMII] =      {0x100, AQUANTIA_VND1_GSYSCFG_10G,
+					   AQUANTIA_VND1_GSTART_RATE_10G},
+	[PHY_INTERFACE_MODE_XFI] =        {0x100, AQUANTIA_VND1_GSYSCFG_10G,
+					   AQUANTIA_VND1_GSTART_RATE_10G},
+	[PHY_INTERFACE_MODE_USXGMII] =    {0x080, AQUANTIA_VND1_GSYSCFG_10G,
+					   AQUANTIA_VND1_GSTART_RATE_10G},
+};
+
+static int aquantia_set_proto(struct phy_device *phydev, int if_type)
+{
+	int i;
+
+	/* this code only works on gen2 and gen3 PHYs */
+	if (phydev->drv->data != AQUANTIA_GEN2 &&
+	    phydev->drv->data != AQUANTIA_GEN3)
+		return -ENOTSUPP;
+
+	if (!aquantia_syscfg[if_type].cnt)
+		return 0;
+
+	/* set the default rate to enable the SI link */
+	phy_write(phydev, MDIO_MMD_VEND1, AQUANTIA_VND1_GSTART_RATE,
+		  aquantia_syscfg[if_type].start_rate);
+
+	for (i = 0; i <= aquantia_syscfg[if_type].cnt; i++)
+		phy_write(phydev, MDIO_MMD_VEND1,
+			  AQUANTIA_VND1_GSYSCFG_BASE + i,
+			  aquantia_syscfg[if_type].syscfg);
+	return 0;
+}
+
+static bool aquantia_link_is_up(struct phy_device *phydev)
+{
+	u16 reg, regmask;
+	int devad, regnum;
+
+	/*
+	 * On Gen 2 and 3 we have a bit that indicates that both system and
+	 * line side are ready for data, use that if possible.
+	 */
+	if (phydev->drv->data == AQUANTIA_GEN2 ||
+	    phydev->drv->data == AQUANTIA_GEN3) {
+		devad = MDIO_MMD_PHYXS;
+		regnum = AQUANTIA_SYSTEM_INTERFACE_SR;
+		regmask = AQUANTIA_SYSTEM_INTERFACE_SR_READY;
+	} else {
+		devad = MDIO_MMD_AN;
+		regnum = MDIO_STAT1;
+		regmask = MDIO_AN_STAT1_COMPLETE;
+	}
+	/* the register should be latched, do a double read */
+	phy_read(phydev, devad, regnum);
+	reg = phy_read(phydev, devad, regnum);
+
+	return !!(reg & regmask);
+}
+
 int aquantia_config(struct phy_device *phydev)
 {
 	int if_type = phydev->interface;
@@ -299,6 +389,25 @@ int aquantia_config(struct phy_device *phydev)
 			if_type = PHY_INTERFACE_MODE_XFI;
 	}
 
+	if (!aquantia_link_is_up(phydev)) {
+		/*
+		 * if link is up already we can just use it, otherwise configure
+		 * the protocols in the PHY.  If link is down set the system
+		 * interface protocol to use based on phydev->interface
+		 */
+
+		/* set PHY in low power mode so we can configure protocols */
+		phy_write(phydev, MDIO_MMD_VEND1, AQUANTIA_VND1_GLOBAL_SC,
+			  AQUANTIA_VND1_GLOBAL_SC_LP);
+		mdelay(10);
+
+		/* configure protocol based on phydev->interface */
+		aquantia_set_proto(phydev, if_type);
+
+		/* wake PHY back up */
+		phy_write(phydev, MDIO_MMD_VEND1, AQUANTIA_VND1_GLOBAL_SC, 0);
+		mdelay(10);
+	}
 
 	val = phy_read(phydev, MDIO_MMD_PMAPMD, MII_BMCR);
 
Signature · 1 line
2.17.1
#6 lore raw

PATCH 6/11 drivers: net: aquantia: set MDI reversal based on DT property

In reply to Alex Marginean

MDI pins up to the RJ45 connector may be reversed on the board and the default PHY configuration applied by firmware may or may not match that. Add an optional DT property to configure MDI reversal for this case.

---
 drivers/net/phy/aquantia.c | 39 ++++++++++++++++++++++++++++++++++++++
 1 file changed, 39 insertions(+)
drivers/net/phy/aquantia.c +39 -0
index ab165e76f5..62a4d1ea6e 100644
@@ -64,6 +64,13 @@
 #define UP_RUN_STALL_OVERRIDE BIT(6)
 #define UP_RUN_STALL BIT(0)
 
+#define AQUANTIA_PMA_RX_VENDOR_P1		0xe400
+#define  AQUANTIA_PMA_RX_VENDOR_P1_MDI_MSK	GENMASK(1, 0)
+/* MDI reversal configured through registers */
+#define  AQUANTIA_PMA_RX_VENDOR_P1_MDI_CFG	BIT(1)
+/* MDI reversal enabled */
+#define  AQUANTIA_PMA_RX_VENDOR_P1_MDI_REV	BIT(0)
+
 /*
  * global start rate, the protocol associated with this speed is used by default
  * on SI.
@@ -324,6 +331,36 @@ static int aquantia_set_proto(struct phy_device *phydev, int if_type)
 	return 0;
 }
 
+static int aquantia_dts_config(struct phy_device *phydev)
+{
+#ifdef CONFIG_OF_CONTROL
+	ofnode node = phydev->node;
+	u32 prop;
+	u16 reg;
+
+	/* this code only works on gen2 and gen3 PHYs */
+	if (phydev->drv->data != AQUANTIA_GEN2 &&
+	    phydev->drv->data != AQUANTIA_GEN3)
+		return -ENOTSUPP;
+
+	if (!ofnode_valid(node))
+		return 0;
+
+	if (!ofnode_read_u32(node, "mdi-reversal", &prop)) {
+		debug("mdi-reversal = %d\n", (int)prop);
+		reg =  phy_read(phydev, MDIO_MMD_PMAPMD,
+				AQUANTIA_PMA_RX_VENDOR_P1);
+		reg &= ~AQUANTIA_PMA_RX_VENDOR_P1_MDI_MSK;
+		reg |= AQUANTIA_PMA_RX_VENDOR_P1_MDI_CFG;
+		reg |= prop ? AQUANTIA_PMA_RX_VENDOR_P1_MDI_REV : 0;
+		phy_write(phydev, MDIO_MMD_PMAPMD, AQUANTIA_PMA_RX_VENDOR_P1,
+			  reg);
+	}
+
+#endif
+	return 0;
+}
+
 static bool aquantia_link_is_up(struct phy_device *phydev)
 {
 	u16 reg, regmask;
@@ -403,6 +440,8 @@ int aquantia_config(struct phy_device *phydev)
 
 		/* configure protocol based on phydev->interface */
 		aquantia_set_proto(phydev, if_type);
+		/* apply custom configuration based on DT */
+		aquantia_dts_config(phydev);
 
 		/* wake PHY back up */
 		phy_write(phydev, MDIO_MMD_VEND1, AQUANTIA_VND1_GLOBAL_SC, 0);
Signature · 1 line
2.17.1
#7 lore raw

PATCH 6/11 drivers: net: aquantia: set MDI reversal based on DT property

Quoted 28 lines · Alex Marginean

MDI pins up to the RJ45 connector may be reversed on the board and the default PHY configuration applied by firmware may or may not match that. Add an optional DT property to configure MDI reversal for this case.

---
  drivers/net/phy/aquantia.c | 39 ++++++++++++++++++++++++++++++++++++++
  1 file changed, 39 insertions(+)
drivers/net/phy/aquantia.c +7 -0
index ab165e76f5..62a4d1ea6e 100644
@@ -64,6 +64,13 @@
  #define UP_RUN_STALL_OVERRIDE BIT(6)
  #define UP_RUN_STALL BIT(0)
 
+#define AQUANTIA_PMA_RX_VENDOR_P1		0xe400
+#define  AQUANTIA_PMA_RX_VENDOR_P1_MDI_MSK	GENMASK(1, 0)
+/* MDI reversal configured through registers */
+#define  AQUANTIA_PMA_RX_VENDOR_P1_MDI_CFG	BIT(1)
+/* MDI reversal enabled */
+#define  AQUANTIA_PMA_RX_VENDOR_P1_MDI_REV	BIT(0)
+
  /*
   * global start rate, the protocol associated with this speed is used by default
   * on SI.

drivers/net/phy/aquantia.c static int aquantia_set_proto(struct phy_device *phydev, int if_type) · line 336

Quoted 6 lines
drivers/net/phy/aquantia.c +3 -0
@@ -324,6 +331,36 @@ static int aquantia_set_proto(struct phy_device *phydev, int if_type)
  	return 0;
  }
 
+static int aquantia_dts_config(struct phy_device *phydev)
+{
+#ifdef CONFIG_OF_CONTROL

^ This should be CONFIG_DM_ETH

Quoted 40 lines
drivers/net/phy/aquantia.c +29 -0
+	ofnode node = phydev->node;
+	u32 prop;
+	u16 reg;
+
+	/* this code only works on gen2 and gen3 PHYs */
+	if (phydev->drv->data != AQUANTIA_GEN2 &&
+	    phydev->drv->data != AQUANTIA_GEN3)
+		return -ENOTSUPP;
+
+	if (!ofnode_valid(node))
+		return 0;
+
+	if (!ofnode_read_u32(node, "mdi-reversal", &prop)) {
+		debug("mdi-reversal = %d\n", (int)prop);
+		reg =  phy_read(phydev, MDIO_MMD_PMAPMD,
+				AQUANTIA_PMA_RX_VENDOR_P1);
+		reg &= ~AQUANTIA_PMA_RX_VENDOR_P1_MDI_MSK;
+		reg |= AQUANTIA_PMA_RX_VENDOR_P1_MDI_CFG;
+		reg |= prop ? AQUANTIA_PMA_RX_VENDOR_P1_MDI_REV : 0;
+		phy_write(phydev, MDIO_MMD_PMAPMD, AQUANTIA_PMA_RX_VENDOR_P1,
+			  reg);
+	}
+
+#endif
+	return 0;
+}
+
  static bool aquantia_link_is_up(struct phy_device *phydev)
  {
  	u16 reg, regmask;
@@ -403,6 +440,8 @@ int aquantia_config(struct phy_device *phydev)
 
  		/* configure protocol based on phydev->interface */
  		aquantia_set_proto(phydev, if_type);
+		/* apply custom configuration based on DT */
+		aquantia_dts_config(phydev);
 
  		/* wake PHY back up */
  		phy_write(phydev, MDIO_MMD_VEND1, AQUANTIA_VND1_GLOBAL_SC, 0);
#8 lore raw

PATCH 7/11 drivers: net: aquantia: set SMBus addr based on DT property

In reply to Alex Marginean

Aquantia PHYs have a SMBus interface mostly used for debug. The addresses on this interface are normally set up by PHY firmware, but depending on the board they may end up not being unique. Add an optional DT property used to change SMBus address if needed.

---
 drivers/net/phy/aquantia.c | 15 +++++++++++++++
 1 file changed, 15 insertions(+)
drivers/net/phy/aquantia.c +15 -0
index 62a4d1ea6e..34df069f97 100644
@@ -91,6 +91,9 @@
 #define AQUANTIA_VND1_GSYSCFG_5G		3
 #define AQUANTIA_VND1_GSYSCFG_10G		4
 
+#define AQUANTIA_VND1_SMBUS0			0xc485
+#define AQUANTIA_VND1_SMBUS1			0xc495
+
 /* addresses of memory segments in the phy */
 #define DRAM_BASE_ADDR 0x3FFE0000
 #define IRAM_BASE_ADDR 0x40000000
@@ -356,6 +359,18 @@ static int aquantia_dts_config(struct phy_device *phydev)
 		phy_write(phydev, MDIO_MMD_PMAPMD, AQUANTIA_PMA_RX_VENDOR_P1,
 			  reg);
 	}
+	if (!ofnode_read_u32(node, "smb-addr", &prop)) {
+		debug("smb-addr = %x\n", (int)prop);
+		/*
+		 * there are two addresses here, normally just one bus would
+		 * be in use so we're setting both regs using the same DT
+		 * property.
+		 */
+		phy_write(phydev, MDIO_MMD_VEND1, AQUANTIA_VND1_SMBUS0,
+			  (u16)(prop << 1));
+		phy_write(phydev, MDIO_MMD_VEND1, AQUANTIA_VND1_SMBUS1,
+			  (u16)(prop << 1));
+	}
 
 #endif
 	return 0;
Signature · 1 line
2.17.1
#9 lore raw

PATCH 8/11 drivers: net: aquantia: use SI and LI status in loop waiting for link up

In reply to Alex Marginean

In some cases the link on the system interface of the aquantia PHY comes up after the link on line interface. The link state loop only checks the line side, which may result in first packet sent being lost.
Use aquantia_link_is_up instead, which checks both system and line side on gen 2/3 PHYs to avoid losing the 1st packet.

---
 drivers/net/phy/aquantia.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)
drivers/net/phy/aquantia.c +2 -5
index 34df069f97..70180e3e4e 100644
@@ -543,17 +543,14 @@ int aquantia_startup(struct phy_device *phydev)
 	phydev->duplex = DUPLEX_FULL;
 
 	/* if the AN is still in progress, wait till timeout. */
-	phy_read(phydev, MDIO_MMD_AN, MDIO_STAT1);
-	reg = phy_read(phydev, MDIO_MMD_AN, MDIO_STAT1);
-	if (!(reg & MDIO_AN_STAT1_COMPLETE)) {
+	if (!aquantia_link_is_up(phydev)) {
 		printf("%s Waiting for PHY auto negotiation to complete",
 		       phydev->dev->name);
 		do {
 			udelay(1000);
-			reg = phy_read(phydev, MDIO_MMD_AN, MDIO_STAT1);
 			if ((i++ % 500) == 0)
 				printf(".");
-		} while (!(reg & MDIO_AN_STAT1_COMPLETE) &&
+		} while (!aquantia_link_is_up(phydev) &&
 			 i < (4 * PHY_ANEG_TIMEOUT));
 
 		if (i > PHY_ANEG_TIMEOUT)
Signature · 1 line
2.17.1
#10 lore raw

PATCH 9/11 doc: bindings: add bindings document for PHY nodes

In reply to Alex Marginean

It defines that PHY nodes must be children on MDIO bus nodes and defines the only required property in U-Boot, reg. This property along with the example provided are copied over from Linux.

---
 doc/device-tree-bindings/net/phy.txt | 24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)
 create mode 100644 doc/device-tree-bindings/net/phy.txt
doc/device-tree-bindings/net/phy.txt new file +24 -0
new file mode 100644
index 0000000000..6599c667b5
@@ -0,0 +1,24 @@
+PHY nodes
+
+If the device tree is used to describe networking interfaces, U-Boot expects a
+node for each PHY.  Parent node for such a PHY node is expected to correspond to
+a MDIO bus and the bus is used to access the PHY.
+
+Required properties:
+
+ - reg : The ID number for the phy, usually a small integer
+
+Example:
+
+ethernet-phy at 0 {
+	compatible = "ethernet-phy-id0141.0e90", "ethernet-phy-ieee802.3-c22";
+	interrupt-parent = <&PIC>;
+	interrupts = <35 IRQ_TYPE_EDGE_RISING>;
+	reg = <0>;
+
+	resets = <&rst 8>;
+	reset-names = "phy";
+	reset-gpios = <&gpio1 4 GPIO_ACTIVE_LOW>;
+	reset-assert-us = <1000>;
+	reset-deassert-us = <2000>;
+};
Signature · 1 line
2.17.1
#11 lore raw

PATCH 10/11 doc: bindings: Aquantia PHY node binding

In reply to Alex Marginean

A couple of optional properties have been introduced for Aquantia PHY allowing the driver to set up wiring related configuration points that are otherwise driven by firmware.

---
 doc/device-tree-bindings/net/aquantia-phy.txt | 25 +++++++++++++++++++
 1 file changed, 25 insertions(+)
 create mode 100644 doc/device-tree-bindings/net/aquantia-phy.txt
doc/device-tree-bindings/net/aquantia-phy.txt new file +25 -0
new file mode 100644
index 0000000000..89ce61e05b
@@ -0,0 +1,25 @@
+PHY nodes for Aquantia devices.
+
+This text describes properties that are applicable to Aquantia PHY nodes in
+addition to the bindings in phy.txt.
+
+Aquantia PHYs allow some flexibility in the way they are wired in a system,
+they allow MDI pins to be reversed, LEDs linked up in different weays, have an
+I2C slave interface that can be used for debug.  Normally the configuration
+corresponding to these is driven by the PHY firmware with the downside that
+a custom firmware is needed for each integration of a PHY.
+Several optional bindings are defined that allow these configuration points to
+be driven by the PHY driver and reduce dependency on specific FW versions.
+
+Optional properties:
+mdi-reversal: 0 or 1 indicating that reversal must be disabled/enabled.
+              Firmware default is used if the property is missing.
+smb-addr:     I2C/SMBus address to use, firmware default is used if the property
+              is missing.
+
+Example node:
+phy at 00 {
+	reg = <0x00>;
+	mdi-reversal = <1>;
+	smb-addr = <0x25>;
+};
Signature · 1 line
2.17.1
#12 lore raw

PATCH 11/11 drivers: net: fsl_enetc: use XFI, USXGMII interface type macros

In reply to Alex Marginean

Apply 10G PCS init for USXGMII, XFI interface types.

---
 drivers/net/fsl_enetc.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/net/fsl_enetc.c +2 -0
index 145d66bb16..a4472c7c50 100644
@@ -194,6 +194,8 @@ static void enetc_start_pcs(struct udevice *dev)
 		enetc_init_rgmii(dev);
 		break;
 	case PHY_INTERFACE_MODE_XGMII:
+	case PHY_INTERFACE_MODE_USXGMII:
+	case PHY_INTERFACE_MODE_XFI:
 		enetc_init_sxgmii(dev);
 		break;
 	};
Signature · 1 line
2.17.1
#13 lore raw

cover Aquantia PHY driver updates to reduce FW dependency

In reply to Alex Marginean
Quoted 4 lines · Alex Marginean

The main purpose of this patch series is to allow the AQR driver to run on a larger number of boards without having to use a custom aquantia FW on each of them. Configuration points that are exclusively controlled by PHY firmware are not configured based on phydev->interface as well as new DT node properties.

^ s/not/now/

Quoted 29 lines

The patch set introduces a couple of new interface types (XFI and USXGMII), introduces a couple of binding documents and updates the ENETC eth driver to use the new interface types.

Alex Marginean (11):
include: phy: define XFI and USXGMII interface types
include: phy: add data field for private driver data
drivers: net: aquantia: use XFI, USXGMII interface types
drivers: net: aquantia: add PHY generation information
drivers: net: aquantia: set up SI protocol based on interface type
drivers: net: aquantia: set MDI reversal based on DT property
drivers: net: aquantia: set SMBus addr based on DT property
drivers: net: aquantia: use SI and LI status in loop waiting for link
up
doc: bindings: add bindings document for PHY nodes
doc: bindings: Aquantia PHY node binding
drivers: net: fsl_enetc: use XFI, USXGMII interface type macros

  doc/device-tree-bindings/net/aquantia-phy.txt |  25 ++
  doc/device-tree-bindings/net/phy.txt          |  24 ++
  drivers/net/fsl_enetc.c                       |   2 +
  drivers/net/phy/aquantia.c                    | 219 ++++++++++++++++--
  include/phy.h                                 |   3 +
  include/phy_interface.h                       |   4 +
  6 files changed, 263 insertions(+), 14 deletions(-)

create mode 100644 doc/device-tree-bindings/net/aquantia-phy.txt create mode 100644 doc/device-tree-bindings/net/phy.txt

#14 lore raw

cover Aquantia PHY driver updates to reduce FW dependency

In reply to Alex Marginean
Quoted 30 lines · Alex Marginean

The main purpose of this patch series is to allow the AQR driver to run on a larger number of boards without having to use a custom aquantia FW on each of them. Configuration points that are exclusively controlled by PHY firmware are not configured based on phydev->interface as well as new DT node properties.

The patch set introduces a couple of new interface types (XFI and USXGMII), introduces a couple of binding documents and updates the ENETC eth driver to use the new interface types.

Alex Marginean (11):
include: phy: define XFI and USXGMII interface types
include: phy: add data field for private driver data
drivers: net: aquantia: use XFI, USXGMII interface types
drivers: net: aquantia: add PHY generation information
drivers: net: aquantia: set up SI protocol based on interface type
drivers: net: aquantia: set MDI reversal based on DT property
drivers: net: aquantia: set SMBus addr based on DT property
drivers: net: aquantia: use SI and LI status in loop waiting for link
up
doc: bindings: add bindings document for PHY nodes
doc: bindings: Aquantia PHY node binding
drivers: net: fsl_enetc: use XFI, USXGMII interface type macros

  doc/device-tree-bindings/net/aquantia-phy.txt |  25 ++
  doc/device-tree-bindings/net/phy.txt          |  24 ++
  drivers/net/fsl_enetc.c                       |   2 +
  drivers/net/phy/aquantia.c                    | 219 ++++++++++++++++--
  include/phy.h                                 |   3 +
  include/phy_interface.h                       |   4 +
  6 files changed, 263 insertions(+), 14 deletions(-)
Quoted 3 lines

create mode 100644 doc/device-tree-bindings/net/aquantia-phy.txt create mode 100644 doc/device-tree-bindings/net/phy.txt

series superseded by
https://patchwork.ozlabs.org/project/uboot/list/?series=124595

Thanks!
Alex