Skip to contentSkip to conversation

net: fsl: Fix busy flag polling register

PATCH In review Markus Koch 3 participants 3 messages Jan 11, 2022 – Jan 15, 2022 Network drivers

lore
Share & tools
lore
#0 lore raw

PATCH v3 1/1 net: fsl: Fix busy flag polling register

NXP's mEMAC reference manual, Chapter 6.5.5 "MDIO Ethernet Management Interface usage", specifies to poll the BSY (0) bit in the CFG/STAT register to wait until a transaction has finished, not bit 31 in the data register.

In the Linux kernel, this has already been fixed in commit 26eee0210ad7 ("net/fsl: fix a bug in xgmac_mdio").

This patch changes the register in the fman_mdio and fsl_ls_mdio drivers.

As the MDIO_DATA_BSY define is no longer in use, this patch also removes its definition from the fsl_memac header.

---
v1->v2:
* Fix register
v2->v3:
* Also apply fix to fsl_ls_mdio
* Add note about define-removal in commit message

Thanks, Camelia!

 drivers/net/fm/memac_phy.c | 2 +-
 drivers/net/fsl_ls_mdio.c  | 4 ++--
 include/fsl_memac.h        | 1 -
 3 files changed, 3 insertions(+), 4 deletions(-)
drivers/net/fm/memac_phy.c +1 -1
index 72b500a6d1..3ddae97e09 100644
@@ -64,7 +64,7 @@ static int memac_wait_until_done(struct memac_mdio_controller *regs)
 {
 	unsigned int timeout = MAX_NUM_RETRIES;
 
-	while ((memac_in_32(&regs->mdio_data) & MDIO_DATA_BSY) && timeout--)
+	while ((memac_in_32(&regs->mdio_stat) & MDIO_STAT_BSY) && timeout--)
 		;
 
 	if (!timeout) {
drivers/net/fsl_ls_mdio.c +2 -2
index 6d4e682fdf..f213e0dd85 100644
@@ -84,7 +84,7 @@ static int dm_fsl_ls_mdio_read(struct udevice *dev, int addr,
 	memac_out_32(&regs->mdio_ctl, mdio_ctl);
 
 	/* Wait till the MDIO write is complete */
-	while ((memac_in_32(&regs->mdio_data)) & MDIO_DATA_BSY)
+	while ((memac_in_32(&regs->mdio_stat)) & MDIO_STAT_BSY)
 		;
 
 	/* Return all Fs if nothing was there */
@@ -107,7 +107,7 @@ static int dm_fsl_ls_mdio_write(struct udevice *dev, int addr, int devad,
 	memac_out_32(&regs->mdio_data, MDIO_DATA(val));
 
 	/* Wait till the MDIO write is complete */
-	while ((memac_in_32(&regs->mdio_data)) & MDIO_DATA_BSY)
+	while ((memac_in_32(&regs->mdio_stat)) & MDIO_STAT_BSY)
 		;
 
 	return 0;
include/fsl_memac.h +0 -1
index d067f1511c..6ac1e558b9 100644
@@ -254,7 +254,6 @@ struct memac_mdio_controller {
 #define MDIO_CTL_READ		(1 << 15)
 
 #define MDIO_DATA(x)		(x & 0xffff)
-#define MDIO_DATA_BSY		(1 << 31)
 
 struct fsl_enet_mac;
 
Signature · 1 line
2.34.1
Reviewed-by Camelia Groza on v3 1/1
#1 lore raw
Quoted 26 lines

-----Original Message-----
From: U-Boot <[email protected]> On Behalf Of Markus Koch
Sent: Tuesday, January 11, 2022 20:23
To: Camelia Alexandra Groza <[email protected]>; [email protected]; [email protected]
Cc: Madalin Bucur (OSS) <[email protected]>; Ioana Ciornei <[email protected]>; [email protected]; Markus Koch <[email protected]>
Subject: [PATCH v3] net: fsl: Fix busy flag polling register

NXP's mEMAC reference manual, Chapter 6.5.5 "MDIO Ethernet Management
Interface usage", specifies to poll the BSY (0) bit in the CFG/STAT register to wait until a transaction has finished, not bit 31 in the data register.

In the Linux kernel, this has already been fixed in commit 26eee0210ad7 ("net/fsl: fix a bug in xgmac_mdio").

This patch changes the register in the fman_mdio and fsl_ls_mdio drivers.

As the MDIO_DATA_BSY define is no longer in use, this patch also removes its definition from the fsl_memac header.

Quoted 8 lines

---
v1->v2:
* Fix register
v2->v3:
* Also apply fix to fsl_ls_mdio
* Add note about define-removal in commit message

Thanks, Camelia!

Thanks for the patch.

#2 lore raw
Quoted 34 lines · Camelia Alexandra Groza (OSS)
Quoted 34 lines

-----Original Message-----
From: U-Boot <[email protected]> On Behalf Of Markus Koch
Sent: Tuesday, January 11, 2022 20:23
To: Camelia Alexandra Groza <[email protected]>; [email protected]; [email protected]
Cc: Madalin Bucur (OSS) <[email protected]>; Ioana Ciornei <[email protected]>; [email protected]; Markus Koch <[email protected]>
Subject: [PATCH v3] net: fsl: Fix busy flag polling register

NXP's mEMAC reference manual, Chapter 6.5.5 "MDIO Ethernet Management
Interface usage", specifies to poll the BSY (0) bit in the CFG/STAT register to wait until a transaction has finished, not bit 31 in the data register.

In the Linux kernel, this has already been fixed in commit 26eee0210ad7 ("net/fsl: fix a bug in xgmac_mdio").

This patch changes the register in the fman_mdio and fsl_ls_mdio drivers.

As the MDIO_DATA_BSY define is no longer in use, this patch also removes its definition from the fsl_memac header.

---
v1->v2:
* Fix register
v2->v3:
* Also apply fix to fsl_ls_mdio
* Add note about define-removal in commit message

Quoted 6 lines
Quoted 1 line

Thanks, Camelia!

Thanks for the patch.

Applied to u-boot-net/next
Thanks !