- Fix two issues with the asix88179 driver
This commit is contained in:
Tom Rini 2024-11-25 15:32:16 -06:00
commit b71edd464f

View file

@ -173,9 +173,10 @@
#define USB_BULK_SEND_TIMEOUT 5000 #define USB_BULK_SEND_TIMEOUT 5000
#define USB_BULK_RECV_TIMEOUT 5000 #define USB_BULK_RECV_TIMEOUT 5000
#define AX_RX_URB_SIZE 1024 * 0x12 #define AX_RX_URB_SIZE 1024 * 0x1a
#define BLK_FRAME_SIZE 0x200 #define BLK_FRAME_SIZE 0x200
#define PHY_CONNECT_TIMEOUT 5000 #define PHY_CONNECT_TIMEOUT 5000
#define PHY_RESET_TIMEOUT 500
#define TIMEOUT_RESOLUTION 50 /* ms */ #define TIMEOUT_RESOLUTION 50 /* ms */
@ -192,10 +193,10 @@
static const struct { static const struct {
unsigned char ctrl, timer_l, timer_h, size, ifg; unsigned char ctrl, timer_l, timer_h, size, ifg;
} AX88179_BULKIN_SIZE[] = { } AX88179_BULKIN_SIZE[] = {
{7, 0x4f, 0, 0x02, 0xff}, {7, 0x4f, 0, 0x12, 0xff},
{7, 0x20, 3, 0x03, 0xff}, {7, 0x20, 3, 0x16, 0xff},
{7, 0xae, 7, 0x04, 0xff}, {7, 0xae, 7, 0x18, 0xff},
{7, 0xcc, 0x4c, 0x04, 8}, {7, 0xcc, 0x4c, 0x18, 8},
}; };
/* driver private */ /* driver private */
@ -285,6 +286,26 @@ static int asix_write_mac(struct ueth_data *dev, uint8_t *enetaddr)
return ret; return ret;
} }
static int asix_reset_phy(struct ueth_data *dev)
{
u16 bmcr;
u32 t;
/* Reset the PHY */
bmcr = BMCR_RESET;
asix_write_cmd(dev, AX_ACCESS_PHY, 0x03, MII_BMCR, 2, &bmcr);
for (t = 0; t < PHY_RESET_TIMEOUT; t += TIMEOUT_RESOLUTION) {
asix_read_cmd(dev, AX_ACCESS_PHY, 0x03, MII_BMCR, 2, &bmcr);
if (!(bmcr & BMCR_RESET))
return 0;
mdelay(TIMEOUT_RESOLUTION);
}
debug("Reset PHY timeout\n");
return -ETIMEDOUT;
}
static int asix_basic_reset(struct ueth_data *dev, static int asix_basic_reset(struct ueth_data *dev,
struct asix_private *dev_priv) struct asix_private *dev_priv)
{ {
@ -311,7 +332,7 @@ static int asix_basic_reset(struct ueth_data *dev,
memcpy(tmp, &AX88179_BULKIN_SIZE[0], 5); memcpy(tmp, &AX88179_BULKIN_SIZE[0], 5);
asix_write_cmd(dev, AX_ACCESS_MAC, AX_RX_BULKIN_QCTRL, 5, 5, tmp); asix_write_cmd(dev, AX_ACCESS_MAC, AX_RX_BULKIN_QCTRL, 5, 5, tmp);
dev_priv->rx_urb_size = 128 * 20; dev_priv->rx_urb_size = 1024 * 20;
/* Water Level configuration */ /* Water Level configuration */
*tmp = 0x34; *tmp = 0x34;
@ -344,14 +365,22 @@ static int asix_basic_reset(struct ueth_data *dev,
AX_MEDIUM_GIGAMODE | AX_MEDIUM_JUMBO_EN; AX_MEDIUM_GIGAMODE | AX_MEDIUM_JUMBO_EN;
asix_write_cmd(dev, AX_ACCESS_MAC, AX_MEDIUM_STATUS_MODE, 2, 2, tmp16); asix_write_cmd(dev, AX_ACCESS_MAC, AX_MEDIUM_STATUS_MODE, 2, 2, tmp16);
asix_reset_phy(dev);
u16 adv = 0; u16 adv = 0;
adv = ADVERTISE_ALL | ADVERTISE_CSMA | ADVERTISE_LPACK | adv = ADVERTISE_ALL | ADVERTISE_CSMA |
ADVERTISE_NPAGE | ADVERTISE_PAUSE_ASYM | ADVERTISE_PAUSE_CAP; ADVERTISE_PAUSE_ASYM | ADVERTISE_PAUSE_CAP;
asix_write_cmd(dev, AX_ACCESS_PHY, 0x03, MII_ADVERTISE, 2, &adv); asix_write_cmd(dev, AX_ACCESS_PHY, 0x03, MII_ADVERTISE, 2, &adv);
adv = ADVERTISE_1000FULL; adv = ADVERTISE_1000FULL;
asix_write_cmd(dev, AX_ACCESS_PHY, 0x03, MII_CTRL1000, 2, &adv); asix_write_cmd(dev, AX_ACCESS_PHY, 0x03, MII_CTRL1000, 2, &adv);
/* Restart auto-negotiation */
u16 bmcr = 0;
asix_read_cmd(dev, AX_ACCESS_PHY, 0x03, MII_BMCR, 2, &bmcr);
bmcr |= BMCR_ANENABLE | BMCR_ANRESTART;
asix_write_cmd(dev, AX_ACCESS_PHY, 0x03, MII_BMCR, 2, &bmcr);
return 0; return 0;
} }