linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [Patch v1] driver/eth/usb/asix.ko: Support for 88772C in Rev-RMII
@ 2025-07-23 15:35 msobchuk
  0 siblings, 0 replies; only message in thread
From: msobchuk @ 2025-07-23 15:35 UTC (permalink / raw)
  To: linux-kernel, linux-usb; +Cc: Dave Tyree, Mike Sobchuk


[-- Attachment #1.1: Type: text/plain, Size: 1250 bytes --]

This Patch adds support to the asix.ko driver for the AX88772C in
Reverse-RMII mode.

 

The 'asix.ko' driver is designed to support 88772A, B and C.

The AX88772C supports running in Reverse-RMII mode to enable MAC to MAC
communication.

The base 'asix.ko' driver does NOT currently support the AX88772C in
Reverse-RMII mode.

 

This is due to several reasons:

1.	The AX88772C PHY register "LINK STATUS" Link value never is set to
1. 

a.	This prevents the drivers from setting the interface 'UP'

2.	The AX88772C PHY-ID is hard coded to 0x10, this configures the chip
to use the internal PHY not an external PHY.

a.	To use the AX88772C in Reverse-RMII mode, the chip must be
configured to use the external 'PHY'.

 

Asix provides a dedicated AX88772C driver which supports Reverse-RMII. This
'C' driver was references to add Reverse-RMII support to the base asix.ko
driver.

To resolve the issue, the following changes were made:

1.	MDIO_READ prior to configuring chip to determine what operational
mode it is in (Internal, RMII, or Reverse-RMII)
2.	If in Reverse-RMII mode, force chip to be configured as if it had an
external PHY.
3.	If in Reverse-RMII mode, set the interface status to UP regardless
of the value of the 'LINK STATUS' bit.


[-- Attachment #1.2: Type: text/html, Size: 7490 bytes --]

[-- Attachment #2: 0001-Subject-Patch-v1-driver-eth-usb-asix.ko-Support-for-.patch --]
[-- Type: application/octet-stream, Size: 3862 bytes --]

From fe97ec1812e6befc8bddc319fdf9cc913f45617f Mon Sep 17 00:00:00 2001
From: Mike <msobchuk@newagemicro.com>
Date: Tue, 22 Jul 2025 16:16:44 -0400
Subject: [PATCH] Subject: [Patch v1] driver/eth/usb/asix.ko: Support for
 88772C in Rev-RMII

From: Mike Sobchuk <msobchuk@newagemicro.com>
AX88772C in Reverse-RMII mode does not set LINK status to 1.
Results in driver being unable to set interface up.
PHY-ID forces driver to configure chip to use internal PHY not external.
Patch provides support for AX88772C in Reverse-RMII with the following
changes:
mdio_read to determine operational mode (Internal, RMII, or REV-RMII).
if in REV-RMII, configure mac to use external PHY (Same as RMII mode).
if in REV-RMII, force LINK status to UP regardless of PHY 'LINK status'
register value.

Signed-off-by: Mike Sobchuk <msobchuk@newagemicro.com>
---
 drivers/net/usb/asix.h         | 12 +++++++++++-
 drivers/net/usb/asix_devices.c | 19 +++++++++++++++++++
 2 files changed, 30 insertions(+), 1 deletion(-)

diff --git a/drivers/net/usb/asix.h b/drivers/net/usb/asix.h
index 74162190bccc..70e63e278720 100644
--- a/drivers/net/usb/asix.h
+++ b/drivers/net/usb/asix.h
@@ -32,6 +32,7 @@
 #define DRIVER_VERSION "22-Dec-2011"
 #define DRIVER_NAME "asix"
 
+
 /* ASIX AX8817X based USB 2.0 Ethernet Devices */
 
 #define AX_CMD_SET_SW_MII		0x06
@@ -72,7 +73,12 @@
 #define AX_HOST_EN			0x01
 
 #define AX_PHYSEL_PSEL			0x01
-#define AX_PHYSEL_SSMII			0
+#define AX_PHYSEL_SSMII			0x00
+#define AX_PHYSEL_ASEL			0x02
+#define AX_PHYSEL_MASK			0x0C
+#define AX_PHYSEL_SSMII			0x00
+#define AX_PHYSEL_SSRMII		0x04
+#define AX_PHYSEL_SSRRMII		0x0C
 #define AX_PHYSEL_SSEN			0x10
 
 #define AX_PHY_SELECT_MASK		(BIT(3) | BIT(2))
@@ -160,6 +166,9 @@
 
 #define AX_EMBD_PHY_ADDR	0x10
 
+#define OPERATION_MAC_MODE	0
+#define OPERATION_PHY_MODE 	1
+
 /* This structure cannot exceed sizeof(unsigned long [5]) AKA 20 bytes */
 struct asix_data {
 	u8 multi_filter[AX_MCAST_FILTER_SIZE];
@@ -191,6 +200,7 @@ struct asix_common_private {
 	u16 phy_addr;
 	bool embd_phy;
 	u8 chipcode;
+	u8 OperationMode;
 };
 
 extern const struct driver_info ax88172a_info;
diff --git a/drivers/net/usb/asix_devices.c b/drivers/net/usb/asix_devices.c
index f7cff58fe044..28223d13ef1e 100644
--- a/drivers/net/usb/asix_devices.c
+++ b/drivers/net/usb/asix_devices.c
@@ -42,11 +42,17 @@ struct ax88172_int_data {
 
 static void asix_status(struct usbnet *dev, struct urb *urb)
 {
+	struct asix_common_private *priv = dev->driver_priv;
 	struct ax88172_int_data *event;
 	int link;
 
 	if (urb->actual_length < 8)
 		return;
+        if (priv->OperationMode == OPERATION_PHY_MODE){
+                usbnet_link_change(dev, 1, 0);
+                return;
+        }
+
 
 	event = urb->transfer_buffer;
 	link = event->link & 0x01;
@@ -836,6 +842,15 @@ static int ax88772_bind(struct usbnet *dev, struct usb_interface *intf)
 
 	usbnet_get_endpoints(dev, intf);
 
+        ret = asix_read_cmd(dev, AX_CMD_SW_PHY_STATUS, 0, 0, 1, buf, 0);
+        *buf &= AX_PHYSEL_MASK;
+
+        if(*buf == AX_PHYSEL_SSRRMII){
+               priv->OperationMode = OPERATION_PHY_MODE;
+               netdev_dbg(dev->net, "PHY MODE\n");
+        }
+
+
 	/* Maybe the boot loader passed the MAC address via device tree */
 	if (!eth_platform_get_mac_address(&dev->udev->dev, buf)) {
 		netif_dbg(dev, ifup, dev->net,
@@ -876,6 +891,10 @@ static int ax88772_bind(struct usbnet *dev, struct usb_interface *intf)
 	priv->phy_addr = ret;
 	priv->embd_phy = ((priv->phy_addr & 0x1f) == AX_EMBD_PHY_ADDR);
 
+	if(priv->OperationMode == OPERATION_PHY_MODE) {
+		priv->embd_phy = 0;
+	}
+
 	ret = asix_read_cmd(dev, AX_CMD_STATMNGSTS_REG, 0, 0, 1,
 			    &priv->chipcode, 0);
 	if (ret < 0) {
-- 
2.43.0


^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2025-07-23 15:43 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-07-23 15:35 [Patch v1] driver/eth/usb/asix.ko: Support for 88772C in Rev-RMII msobchuk

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).