Skip to content

Commit 16626b0

Browse files
Christian Rieschdavem330
authored andcommitted
asix: Add a new driver for the AX88172A
The Asix AX88172A is a USB 2.0 Ethernet interface that supports both an internal PHY as well as an external PHY (connected via MII). This patch adds a driver for the AX88172A and provides support for both modes and the phylib. Signed-off-by: Christian Riesch <christian.riesch@omicron.at> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 607740b commit 16626b0

5 files changed

Lines changed: 437 additions & 3 deletions

File tree

‎drivers/net/usb/Makefile‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ obj-$(CONFIG_USB_PEGASUS) += pegasus.o
88
obj-$(CONFIG_USB_RTL8150) += rtl8150.o
99
obj-$(CONFIG_USB_HSO) += hso.o
1010
obj-$(CONFIG_USB_NET_AX8817X) += asix.o
11-
asix-y := asix_devices.o asix_common.o
11+
asix-y := asix_devices.o asix_common.o ax88172a.o
1212
obj-$(CONFIG_USB_NET_CDCETHER) += cdc_ether.o
1313
obj-$(CONFIG_USB_NET_CDC_EEM) += cdc_eem.o
1414
obj-$(CONFIG_USB_NET_DM9601) += dm9601.o

‎drivers/net/usb/asix.h‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,10 @@
7474
#define AX_CMD_SW_PHY_STATUS 0x21
7575
#define AX_CMD_SW_PHY_SELECT 0x22
7676

77+
#define AX_PHY_SELECT_MASK (BIT(3) | BIT(2))
78+
#define AX_PHY_SELECT_INTERNAL 0
79+
#define AX_PHY_SELECT_EXTERNAL BIT(2)
80+
7781
#define AX_MONITOR_MODE 0x01
7882
#define AX_MONITOR_LINK 0x02
7983
#define AX_MONITOR_MAGIC 0x04
@@ -181,6 +185,7 @@ struct sk_buff *asix_tx_fixup(struct usbnet *dev, struct sk_buff *skb,
181185
int asix_set_sw_mii(struct usbnet *dev);
182186
int asix_set_hw_mii(struct usbnet *dev);
183187

188+
int asix_read_phy_addr(struct usbnet *dev, int internal);
184189
int asix_get_phy_addr(struct usbnet *dev);
185190

186191
int asix_sw_reset(struct usbnet *dev, u8 flags);

‎drivers/net/usb/asix_common.c‎

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -258,8 +258,9 @@ int asix_set_hw_mii(struct usbnet *dev)
258258
return ret;
259259
}
260260

261-
int asix_get_phy_addr(struct usbnet *dev)
261+
int asix_read_phy_addr(struct usbnet *dev, int internal)
262262
{
263+
int offset = (internal ? 1 : 0);
263264
u8 buf[2];
264265
int ret = asix_read_cmd(dev, AX_CMD_READ_PHY_ID, 0, 0, 2, buf);
265266

@@ -271,12 +272,19 @@ int asix_get_phy_addr(struct usbnet *dev)
271272
}
272273
netdev_dbg(dev->net, "asix_get_phy_addr() returning 0x%04x\n",
273274
*((__le16 *)buf));
274-
ret = buf[1];
275+
ret = buf[offset];
275276

276277
out:
277278
return ret;
278279
}
279280

281+
int asix_get_phy_addr(struct usbnet *dev)
282+
{
283+
/* return the address of the internal phy */
284+
return asix_read_phy_addr(dev, 1);
285+
}
286+
287+
280288
int asix_sw_reset(struct usbnet *dev, u8 flags)
281289
{
282290
int ret;

‎drivers/net/usb/asix_devices.c‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -872,6 +872,8 @@ static const struct driver_info ax88178_info = {
872872
.tx_fixup = asix_tx_fixup,
873873
};
874874

875+
extern const struct driver_info ax88172a_info;
876+
875877
static const struct usb_device_id products [] = {
876878
{
877879
// Linksys USB200M
@@ -997,6 +999,10 @@ static const struct usb_device_id products [] = {
997999
// Asus USB Ethernet Adapter
9981000
USB_DEVICE (0x0b95, 0x7e2b),
9991001
.driver_info = (unsigned long) &ax88772_info,
1002+
}, {
1003+
/* ASIX 88172a demo board */
1004+
USB_DEVICE(0x0b95, 0x172a),
1005+
.driver_info = (unsigned long) &ax88172a_info,
10001006
},
10011007
{ }, // END
10021008
};

0 commit comments

Comments
 (0)