Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

net: asix: Add in_pm parameter

From: Freddy Xin <freddy@asix.com.tw>

In order to R/W registers in suspend/resume functions, in_pm flags are
added to some functions to determine whether the nopm version of usb
functions is called.

Save BMCR and ANAR PHY registers in suspend function and restore them
in resume function.

Reset HW in resume function to ensure the PHY works correctly.

Signed-off-by: Freddy Xin <freddy@asix.com.tw>
Signed-off-by: Robert Foss <robert.foss@collabora.com>
Tested-by: Robert Foss <robert.foss@collabora.com>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Robert Foss and committed by
David S. Miller
d9fe64e5 c7735f1b

+489 -167
+30 -10
drivers/net/usb/asix.h
··· 46 46 #define AX_CMD_SET_SW_MII 0x06 47 47 #define AX_CMD_READ_MII_REG 0x07 48 48 #define AX_CMD_WRITE_MII_REG 0x08 49 + #define AX_CMD_STATMNGSTS_REG 0x09 49 50 #define AX_CMD_SET_HW_MII 0x0a 50 51 #define AX_CMD_READ_EEPROM 0x0b 51 52 #define AX_CMD_WRITE_EEPROM 0x0c ··· 72 71 #define AX_CMD_SW_RESET 0x20 73 72 #define AX_CMD_SW_PHY_STATUS 0x21 74 73 #define AX_CMD_SW_PHY_SELECT 0x22 74 + #define AX_QCTCTRL 0x2A 75 + 76 + #define AX_CHIPCODE_MASK 0x70 77 + #define AX_AX88772_CHIPCODE 0x00 78 + #define AX_AX88772A_CHIPCODE 0x10 79 + #define AX_AX88772B_CHIPCODE 0x20 80 + #define AX_HOST_EN 0x01 81 + 82 + #define AX_PHYSEL_PSEL 0x01 83 + #define AX_PHYSEL_SSMII 0 84 + #define AX_PHYSEL_SSEN 0x10 75 85 76 86 #define AX_PHY_SELECT_MASK (BIT(3) | BIT(2)) 77 87 #define AX_PHY_SELECT_INTERNAL 0 ··· 185 173 }; 186 174 187 175 struct asix_common_private { 176 + void (*resume)(struct usbnet *dev); 177 + void (*suspend)(struct usbnet *dev); 178 + u16 presvd_phy_advertise; 179 + u16 presvd_phy_bmcr; 188 180 struct asix_rx_fixup_info rx_fixup_info; 189 181 }; 190 182 ··· 198 182 #define FLAG_EEPROM_MAC (1UL << 0) /* init device MAC from eeprom */ 199 183 200 184 int asix_read_cmd(struct usbnet *dev, u8 cmd, u16 value, u16 index, 201 - u16 size, void *data); 185 + u16 size, void *data, int in_pm); 202 186 203 187 int asix_write_cmd(struct usbnet *dev, u8 cmd, u16 value, u16 index, 204 - u16 size, void *data); 188 + u16 size, void *data, int in_pm); 205 189 206 190 void asix_write_cmd_async(struct usbnet *dev, u8 cmd, u16 value, 207 191 u16 index, u16 size, void *data); ··· 213 197 struct sk_buff *asix_tx_fixup(struct usbnet *dev, struct sk_buff *skb, 214 198 gfp_t flags); 215 199 216 - int asix_set_sw_mii(struct usbnet *dev); 217 - int asix_set_hw_mii(struct usbnet *dev); 200 + int asix_set_sw_mii(struct usbnet *dev, int in_pm); 201 + int asix_set_hw_mii(struct usbnet *dev, int in_pm); 218 202 219 203 int asix_read_phy_addr(struct usbnet *dev, int internal); 220 204 int asix_get_phy_addr(struct usbnet *dev); 221 205 222 - int asix_sw_reset(struct usbnet *dev, u8 flags); 206 + int asix_sw_reset(struct usbnet *dev, u8 flags, int in_pm); 223 207 224 - u16 asix_read_rx_ctl(struct usbnet *dev); 225 - int asix_write_rx_ctl(struct usbnet *dev, u16 mode); 208 + u16 asix_read_rx_ctl(struct usbnet *dev, int in_pm); 209 + int asix_write_rx_ctl(struct usbnet *dev, u16 mode, int in_pm); 226 210 227 - u16 asix_read_medium_status(struct usbnet *dev); 228 - int asix_write_medium_mode(struct usbnet *dev, u16 mode); 211 + u16 asix_read_medium_status(struct usbnet *dev, int in_pm); 212 + int asix_write_medium_mode(struct usbnet *dev, u16 mode, int in_pm); 229 213 230 - int asix_write_gpio(struct usbnet *dev, u16 value, int sleep); 214 + int asix_write_gpio(struct usbnet *dev, u16 value, int sleep, int in_pm); 231 215 232 216 void asix_set_multicast(struct net_device *net); 233 217 234 218 int asix_mdio_read(struct net_device *netdev, int phy_id, int loc); 235 219 void asix_mdio_write(struct net_device *netdev, int phy_id, int loc, int val); 220 + 221 + int asix_mdio_read_nopm(struct net_device *netdev, int phy_id, int loc); 222 + void asix_mdio_write_nopm(struct net_device *netdev, int phy_id, int loc, 223 + int val); 236 224 237 225 void asix_get_wol(struct net_device *net, struct ethtool_wolinfo *wolinfo); 238 226 int asix_set_wol(struct net_device *net, struct ethtool_wolinfo *wolinfo);
+137 -43
drivers/net/usb/asix_common.c
··· 22 22 #include "asix.h" 23 23 24 24 int asix_read_cmd(struct usbnet *dev, u8 cmd, u16 value, u16 index, 25 - u16 size, void *data) 25 + u16 size, void *data, int in_pm) 26 26 { 27 27 int ret; 28 - ret = usbnet_read_cmd(dev, cmd, 29 - USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_DEVICE, 30 - value, index, data, size); 28 + int (*fn)(struct usbnet *, u8, u8, u16, u16, void *, u16); 31 29 32 - if (ret != size && ret >= 0) 33 - return -EINVAL; 30 + BUG_ON(!dev); 31 + 32 + if (!in_pm) 33 + fn = usbnet_read_cmd; 34 + else 35 + fn = usbnet_read_cmd_nopm; 36 + 37 + ret = fn(dev, cmd, USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_DEVICE, 38 + value, index, data, size); 39 + 40 + if (unlikely(ret < 0)) 41 + netdev_warn(dev->net, "Failed to read reg index 0x%04x: %d\n", 42 + index, ret); 43 + 34 44 return ret; 35 45 } 36 46 37 47 int asix_write_cmd(struct usbnet *dev, u8 cmd, u16 value, u16 index, 38 - u16 size, void *data) 48 + u16 size, void *data, int in_pm) 39 49 { 40 - return usbnet_write_cmd(dev, cmd, 41 - USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE, 42 - value, index, data, size); 50 + int ret; 51 + int (*fn)(struct usbnet *, u8, u8, u16, u16, const void *, u16); 52 + 53 + BUG_ON(!dev); 54 + 55 + if (!in_pm) 56 + fn = usbnet_write_cmd; 57 + else 58 + fn = usbnet_write_cmd_nopm; 59 + 60 + ret = fn(dev, cmd, USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE, 61 + value, index, data, size); 62 + 63 + if (unlikely(ret < 0)) 64 + netdev_warn(dev->net, "Failed to write reg index 0x%04x: %d\n", 65 + index, ret); 66 + 67 + return ret; 43 68 } 44 69 45 70 void asix_write_cmd_async(struct usbnet *dev, u8 cmd, u16 value, u16 index, ··· 250 225 return skb; 251 226 } 252 227 253 - int asix_set_sw_mii(struct usbnet *dev) 228 + int asix_set_sw_mii(struct usbnet *dev, int in_pm) 254 229 { 255 230 int ret; 256 - ret = asix_write_cmd(dev, AX_CMD_SET_SW_MII, 0x0000, 0, 0, NULL); 231 + ret = asix_write_cmd(dev, AX_CMD_SET_SW_MII, 0x0000, 0, 0, NULL, in_pm); 232 + 257 233 if (ret < 0) 258 234 netdev_err(dev->net, "Failed to enable software MII access\n"); 259 235 return ret; 260 236 } 261 237 262 - int asix_set_hw_mii(struct usbnet *dev) 238 + int asix_set_hw_mii(struct usbnet *dev, int in_pm) 263 239 { 264 240 int ret; 265 - ret = asix_write_cmd(dev, AX_CMD_SET_HW_MII, 0x0000, 0, 0, NULL); 241 + ret = asix_write_cmd(dev, AX_CMD_SET_HW_MII, 0x0000, 0, 0, NULL, in_pm); 266 242 if (ret < 0) 267 243 netdev_err(dev->net, "Failed to enable hardware MII access\n"); 268 244 return ret; ··· 273 247 { 274 248 int offset = (internal ? 1 : 0); 275 249 u8 buf[2]; 276 - int ret = asix_read_cmd(dev, AX_CMD_READ_PHY_ID, 0, 0, 2, buf); 250 + int ret = asix_read_cmd(dev, AX_CMD_READ_PHY_ID, 0, 0, 2, buf, 0); 277 251 278 252 netdev_dbg(dev->net, "asix_get_phy_addr()\n"); 279 253 ··· 296 270 } 297 271 298 272 299 - int asix_sw_reset(struct usbnet *dev, u8 flags) 273 + int asix_sw_reset(struct usbnet *dev, u8 flags, int in_pm) 300 274 { 301 275 int ret; 302 276 303 - ret = asix_write_cmd(dev, AX_CMD_SW_RESET, flags, 0, 0, NULL); 277 + ret = asix_write_cmd(dev, AX_CMD_SW_RESET, flags, 0, 0, NULL, in_pm); 304 278 if (ret < 0) 305 279 netdev_err(dev->net, "Failed to send software reset: %02x\n", ret); 306 280 307 281 return ret; 308 282 } 309 283 310 - u16 asix_read_rx_ctl(struct usbnet *dev) 284 + u16 asix_read_rx_ctl(struct usbnet *dev, int in_pm) 311 285 { 312 286 __le16 v; 313 - int ret = asix_read_cmd(dev, AX_CMD_READ_RX_CTL, 0, 0, 2, &v); 287 + int ret = asix_read_cmd(dev, AX_CMD_READ_RX_CTL, 0, 0, 2, &v, in_pm); 314 288 315 289 if (ret < 0) { 316 290 netdev_err(dev->net, "Error reading RX_CTL register: %02x\n", ret); ··· 321 295 return ret; 322 296 } 323 297 324 - int asix_write_rx_ctl(struct usbnet *dev, u16 mode) 298 + int asix_write_rx_ctl(struct usbnet *dev, u16 mode, int in_pm) 325 299 { 326 300 int ret; 327 301 328 302 netdev_dbg(dev->net, "asix_write_rx_ctl() - mode = 0x%04x\n", mode); 329 - ret = asix_write_cmd(dev, AX_CMD_WRITE_RX_CTL, mode, 0, 0, NULL); 303 + ret = asix_write_cmd(dev, AX_CMD_WRITE_RX_CTL, mode, 0, 0, NULL, in_pm); 330 304 if (ret < 0) 331 305 netdev_err(dev->net, "Failed to write RX_CTL mode to 0x%04x: %02x\n", 332 306 mode, ret); ··· 334 308 return ret; 335 309 } 336 310 337 - u16 asix_read_medium_status(struct usbnet *dev) 311 + u16 asix_read_medium_status(struct usbnet *dev, int in_pm) 338 312 { 339 313 __le16 v; 340 - int ret = asix_read_cmd(dev, AX_CMD_READ_MEDIUM_STATUS, 0, 0, 2, &v); 314 + int ret = asix_read_cmd(dev, AX_CMD_READ_MEDIUM_STATUS, 315 + 0, 0, 2, &v, in_pm); 341 316 342 317 if (ret < 0) { 343 318 netdev_err(dev->net, "Error reading Medium Status register: %02x\n", ··· 350 323 351 324 } 352 325 353 - int asix_write_medium_mode(struct usbnet *dev, u16 mode) 326 + int asix_write_medium_mode(struct usbnet *dev, u16 mode, int in_pm) 354 327 { 355 328 int ret; 356 329 357 330 netdev_dbg(dev->net, "asix_write_medium_mode() - mode = 0x%04x\n", mode); 358 - ret = asix_write_cmd(dev, AX_CMD_WRITE_MEDIUM_MODE, mode, 0, 0, NULL); 331 + ret = asix_write_cmd(dev, AX_CMD_WRITE_MEDIUM_MODE, 332 + mode, 0, 0, NULL, in_pm); 359 333 if (ret < 0) 360 334 netdev_err(dev->net, "Failed to write Medium Mode mode to 0x%04x: %02x\n", 361 335 mode, ret); ··· 364 336 return ret; 365 337 } 366 338 367 - int asix_write_gpio(struct usbnet *dev, u16 value, int sleep) 339 + int asix_write_gpio(struct usbnet *dev, u16 value, int sleep, int in_pm) 368 340 { 369 341 int ret; 370 342 371 343 netdev_dbg(dev->net, "asix_write_gpio() - value = 0x%04x\n", value); 372 - ret = asix_write_cmd(dev, AX_CMD_WRITE_GPIOS, value, 0, 0, NULL); 344 + ret = asix_write_cmd(dev, AX_CMD_WRITE_GPIOS, value, 0, 0, NULL, in_pm); 373 345 if (ret < 0) 374 346 netdev_err(dev->net, "Failed to write GPIO value 0x%04x: %02x\n", 375 347 value, ret); ··· 426 398 { 427 399 struct usbnet *dev = netdev_priv(netdev); 428 400 __le16 res; 401 + u8 smsr; 402 + int i = 0; 429 403 430 404 mutex_lock(&dev->phy_mutex); 431 - asix_set_sw_mii(dev); 405 + do { 406 + asix_set_sw_mii(dev, 0); 407 + usleep_range(1000, 1100); 408 + asix_read_cmd(dev, AX_CMD_STATMNGSTS_REG, 0, 0, 1, &smsr, 0); 409 + } while (!(smsr & AX_HOST_EN) && (i++ < 30)); 410 + 432 411 asix_read_cmd(dev, AX_CMD_READ_MII_REG, phy_id, 433 - (__u16)loc, 2, &res); 434 - asix_set_hw_mii(dev); 412 + (__u16)loc, 2, &res, 0); 413 + asix_set_hw_mii(dev, 0); 435 414 mutex_unlock(&dev->phy_mutex); 436 415 437 416 netdev_dbg(dev->net, "asix_mdio_read() phy_id=0x%02x, loc=0x%02x, returns=0x%04x\n", 438 - phy_id, loc, le16_to_cpu(res)); 417 + phy_id, loc, le16_to_cpu(res)); 439 418 440 419 return le16_to_cpu(res); 441 420 } ··· 451 416 { 452 417 struct usbnet *dev = netdev_priv(netdev); 453 418 __le16 res = cpu_to_le16(val); 419 + u8 smsr; 420 + int i = 0; 454 421 455 422 netdev_dbg(dev->net, "asix_mdio_write() phy_id=0x%02x, loc=0x%02x, val=0x%04x\n", 456 - phy_id, loc, val); 423 + phy_id, loc, val); 424 + 457 425 mutex_lock(&dev->phy_mutex); 458 - asix_set_sw_mii(dev); 459 - asix_write_cmd(dev, AX_CMD_WRITE_MII_REG, phy_id, (__u16)loc, 2, &res); 460 - asix_set_hw_mii(dev); 426 + do { 427 + asix_set_sw_mii(dev, 0); 428 + usleep_range(1000, 1100); 429 + asix_read_cmd(dev, AX_CMD_STATMNGSTS_REG, 0, 0, 1, &smsr, 0); 430 + } while (!(smsr & AX_HOST_EN) && (i++ < 30)); 431 + 432 + asix_write_cmd(dev, AX_CMD_WRITE_MII_REG, phy_id, 433 + (__u16)loc, 2, &res, 0); 434 + asix_set_hw_mii(dev, 0); 435 + mutex_unlock(&dev->phy_mutex); 436 + } 437 + 438 + int asix_mdio_read_nopm(struct net_device *netdev, int phy_id, int loc) 439 + { 440 + struct usbnet *dev = netdev_priv(netdev); 441 + __le16 res; 442 + u8 smsr; 443 + int i = 0; 444 + 445 + mutex_lock(&dev->phy_mutex); 446 + do { 447 + asix_set_sw_mii(dev, 1); 448 + usleep_range(1000, 1100); 449 + asix_read_cmd(dev, AX_CMD_STATMNGSTS_REG, 0, 0, 1, &smsr, 1); 450 + } while (!(smsr & AX_HOST_EN) && (i++ < 30)); 451 + 452 + asix_read_cmd(dev, AX_CMD_READ_MII_REG, phy_id, 453 + (__u16)loc, 2, &res, 1); 454 + asix_set_hw_mii(dev, 1); 455 + mutex_unlock(&dev->phy_mutex); 456 + 457 + netdev_dbg(dev->net, "asix_mdio_read_nopm() phy_id=0x%02x, loc=0x%02x, returns=0x%04x\n", 458 + phy_id, loc, le16_to_cpu(res)); 459 + 460 + return le16_to_cpu(res); 461 + } 462 + 463 + void 464 + asix_mdio_write_nopm(struct net_device *netdev, int phy_id, int loc, int val) 465 + { 466 + struct usbnet *dev = netdev_priv(netdev); 467 + __le16 res = cpu_to_le16(val); 468 + u8 smsr; 469 + int i = 0; 470 + 471 + netdev_dbg(dev->net, "asix_mdio_write() phy_id=0x%02x, loc=0x%02x, val=0x%04x\n", 472 + phy_id, loc, val); 473 + 474 + mutex_lock(&dev->phy_mutex); 475 + do { 476 + asix_set_sw_mii(dev, 1); 477 + usleep_range(1000, 1100); 478 + asix_read_cmd(dev, AX_CMD_STATMNGSTS_REG, 0, 0, 1, &smsr, 1); 479 + } while (!(smsr & AX_HOST_EN) && (i++ < 30)); 480 + 481 + asix_write_cmd(dev, AX_CMD_WRITE_MII_REG, phy_id, 482 + (__u16)loc, 2, &res, 1); 483 + asix_set_hw_mii(dev, 1); 461 484 mutex_unlock(&dev->phy_mutex); 462 485 } 463 486 ··· 524 431 struct usbnet *dev = netdev_priv(net); 525 432 u8 opt; 526 433 527 - if (asix_read_cmd(dev, AX_CMD_READ_MONITOR_MODE, 0, 0, 1, &opt) < 0) { 434 + if (asix_read_cmd(dev, AX_CMD_READ_MONITOR_MODE, 435 + 0, 0, 1, &opt, 0) < 0) { 528 436 wolinfo->supported = 0; 529 437 wolinfo->wolopts = 0; 530 438 return; ··· 549 455 opt |= AX_MONITOR_MAGIC; 550 456 551 457 if (asix_write_cmd(dev, AX_CMD_WRITE_MONITOR_MODE, 552 - opt, 0, 0, NULL) < 0) 458 + opt, 0, 0, NULL, 0) < 0) 553 459 return -EINVAL; 554 460 555 461 return 0; ··· 584 490 /* ax8817x returns 2 bytes from eeprom on read */ 585 491 for (i = first_word; i <= last_word; i++) { 586 492 if (asix_read_cmd(dev, AX_CMD_READ_EEPROM, i, 0, 2, 587 - &(eeprom_buff[i - first_word])) < 0) { 493 + &eeprom_buff[i - first_word], 0) < 0) { 588 494 kfree(eeprom_buff); 589 495 return -EIO; 590 496 } ··· 625 531 the EEPROM */ 626 532 if (eeprom->offset & 1) { 627 533 ret = asix_read_cmd(dev, AX_CMD_READ_EEPROM, first_word, 0, 2, 628 - &(eeprom_buff[0])); 534 + &eeprom_buff[0], 0); 629 535 if (ret < 0) { 630 536 netdev_err(net, "Failed to read EEPROM at offset 0x%02x.\n", first_word); 631 537 goto free; ··· 634 540 635 541 if ((eeprom->offset + eeprom->len) & 1) { 636 542 ret = asix_read_cmd(dev, AX_CMD_READ_EEPROM, last_word, 0, 2, 637 - &(eeprom_buff[last_word - first_word])); 543 + &eeprom_buff[last_word - first_word], 0); 638 544 if (ret < 0) { 639 545 netdev_err(net, "Failed to read EEPROM at offset 0x%02x.\n", last_word); 640 546 goto free; ··· 644 550 memcpy((u8 *)eeprom_buff + (eeprom->offset & 1), data, eeprom->len); 645 551 646 552 /* write data to EEPROM */ 647 - ret = asix_write_cmd(dev, AX_CMD_WRITE_ENABLE, 0x0000, 0, 0, NULL); 553 + ret = asix_write_cmd(dev, AX_CMD_WRITE_ENABLE, 0x0000, 0, 0, NULL, 0); 648 554 if (ret < 0) { 649 555 netdev_err(net, "Failed to enable EEPROM write\n"); 650 556 goto free; ··· 655 561 netdev_dbg(net, "write to EEPROM at offset 0x%02x, data 0x%04x\n", 656 562 i, eeprom_buff[i - first_word]); 657 563 ret = asix_write_cmd(dev, AX_CMD_WRITE_EEPROM, i, 658 - eeprom_buff[i - first_word], 0, NULL); 564 + eeprom_buff[i - first_word], 0, NULL, 0); 659 565 if (ret < 0) { 660 566 netdev_err(net, "Failed to write EEPROM at offset 0x%02x.\n", 661 567 i); ··· 664 570 msleep(20); 665 571 } 666 572 667 - ret = asix_write_cmd(dev, AX_CMD_WRITE_DISABLE, 0x0000, 0, 0, NULL); 573 + ret = asix_write_cmd(dev, AX_CMD_WRITE_DISABLE, 0x0000, 0, 0, NULL, 0); 668 574 if (ret < 0) { 669 575 netdev_err(net, "Failed to disable EEPROM write\n"); 670 576 goto free;
+307 -100
drivers/net/usb/asix_devices.c
··· 184 184 netdev_dbg(dev->net, "ax88172_link_reset() speed: %u duplex: %d setting mode to 0x%04x\n", 185 185 ethtool_cmd_speed(&ecmd), ecmd.duplex, mode); 186 186 187 - asix_write_medium_mode(dev, mode); 187 + asix_write_medium_mode(dev, mode, 0); 188 188 189 189 return 0; 190 190 } ··· 213 213 /* Toggle the GPIOs in a manufacturer/model specific way */ 214 214 for (i = 2; i >= 0; i--) { 215 215 ret = asix_write_cmd(dev, AX_CMD_WRITE_GPIOS, 216 - (gpio_bits >> (i * 8)) & 0xff, 0, 0, NULL); 216 + (gpio_bits >> (i * 8)) & 0xff, 0, 0, NULL, 0); 217 217 if (ret < 0) 218 218 goto out; 219 219 msleep(5); 220 220 } 221 221 222 - ret = asix_write_rx_ctl(dev, 0x80); 222 + ret = asix_write_rx_ctl(dev, 0x80, 0); 223 223 if (ret < 0) 224 224 goto out; 225 225 226 226 /* Get the MAC address */ 227 - ret = asix_read_cmd(dev, AX88172_CMD_READ_NODE_ID, 0, 0, ETH_ALEN, buf); 227 + ret = asix_read_cmd(dev, AX88172_CMD_READ_NODE_ID, 228 + 0, 0, ETH_ALEN, buf, 0); 228 229 if (ret < 0) { 229 230 netdev_dbg(dev->net, "read AX_CMD_READ_NODE_ID failed: %d\n", 230 231 ret); ··· 291 290 netdev_dbg(dev->net, "ax88772_link_reset() speed: %u duplex: %d setting mode to 0x%04x\n", 292 291 ethtool_cmd_speed(&ecmd), ecmd.duplex, mode); 293 292 294 - asix_write_medium_mode(dev, mode); 293 + asix_write_medium_mode(dev, mode, 0); 295 294 296 295 return 0; 297 296 } ··· 299 298 static int ax88772_reset(struct usbnet *dev) 300 299 { 301 300 struct asix_data *data = (struct asix_data *)&dev->data; 302 - int ret, embd_phy; 303 - u16 rx_ctl; 301 + int ret; 304 302 305 - ret = asix_write_gpio(dev, 306 - AX_GPIO_RSE | AX_GPIO_GPO_2 | AX_GPIO_GPO2EN, 5); 303 + /* Rewrite MAC address */ 304 + ether_addr_copy(data->mac_addr, dev->net->dev_addr); 305 + ret = asix_write_cmd(dev, AX_CMD_WRITE_NODE_ID, 0, 0, 306 + ETH_ALEN, data->mac_addr, 0); 307 307 if (ret < 0) 308 308 goto out; 309 309 310 - embd_phy = ((asix_get_phy_addr(dev) & 0x1f) == 0x10 ? 1 : 0); 310 + /* Set RX_CTL to default values with 2k buffer, and enable cactus */ 311 + ret = asix_write_rx_ctl(dev, AX_DEFAULT_RX_CTL, 0); 312 + if (ret < 0) 313 + goto out; 311 314 312 - ret = asix_write_cmd(dev, AX_CMD_SW_PHY_SELECT, embd_phy, 0, 0, NULL); 315 + asix_write_medium_mode(dev, AX88772_MEDIUM_DEFAULT, 0); 316 + if (ret < 0) 317 + goto out; 318 + 319 + return 0; 320 + 321 + out: 322 + return ret; 323 + } 324 + 325 + static int ax88772_hw_reset(struct usbnet *dev, int in_pm) 326 + { 327 + struct asix_data *data = (struct asix_data *)&dev->data; 328 + int ret, embd_phy; 329 + u16 rx_ctl; 330 + 331 + ret = asix_write_gpio(dev, AX_GPIO_RSE | AX_GPIO_GPO_2 | 332 + AX_GPIO_GPO2EN, 5, in_pm); 333 + if (ret < 0) 334 + goto out; 335 + 336 + embd_phy = ((dev->mii.phy_id & 0x1f) == 0x10 ? 1 : 0); 337 + 338 + ret = asix_write_cmd(dev, AX_CMD_SW_PHY_SELECT, embd_phy, 339 + 0, 0, NULL, in_pm); 313 340 if (ret < 0) { 314 341 netdev_dbg(dev->net, "Select PHY #1 failed: %d\n", ret); 315 342 goto out; 316 343 } 317 344 318 - ret = asix_sw_reset(dev, AX_SWRESET_IPPD | AX_SWRESET_PRL); 319 - if (ret < 0) 320 - goto out; 321 - 322 - msleep(150); 323 - 324 - ret = asix_sw_reset(dev, AX_SWRESET_CLEAR); 325 - if (ret < 0) 326 - goto out; 327 - 328 - msleep(150); 329 - 330 345 if (embd_phy) { 331 - ret = asix_sw_reset(dev, AX_SWRESET_IPRL); 346 + ret = asix_sw_reset(dev, AX_SWRESET_IPPD, in_pm); 347 + if (ret < 0) 348 + goto out; 349 + 350 + usleep_range(10000, 11000); 351 + 352 + ret = asix_sw_reset(dev, AX_SWRESET_CLEAR, in_pm); 353 + if (ret < 0) 354 + goto out; 355 + 356 + msleep(60); 357 + 358 + ret = asix_sw_reset(dev, AX_SWRESET_IPRL | AX_SWRESET_PRL, 359 + in_pm); 332 360 if (ret < 0) 333 361 goto out; 334 362 } else { 335 - ret = asix_sw_reset(dev, AX_SWRESET_PRTE); 363 + ret = asix_sw_reset(dev, AX_SWRESET_IPPD | AX_SWRESET_PRL, 364 + in_pm); 336 365 if (ret < 0) 337 366 goto out; 338 367 } 339 368 340 369 msleep(150); 341 - rx_ctl = asix_read_rx_ctl(dev); 342 - netdev_dbg(dev->net, "RX_CTL is 0x%04x after software reset\n", rx_ctl); 343 - ret = asix_write_rx_ctl(dev, 0x0000); 370 + 371 + if (in_pm && (!asix_mdio_read_nopm(dev->net, dev->mii.phy_id, 372 + MII_PHYSID1))){ 373 + ret = -EIO; 374 + goto out; 375 + } 376 + 377 + ret = asix_write_rx_ctl(dev, AX_DEFAULT_RX_CTL, in_pm); 344 378 if (ret < 0) 345 379 goto out; 346 380 347 - rx_ctl = asix_read_rx_ctl(dev); 348 - netdev_dbg(dev->net, "RX_CTL is 0x%04x setting to 0x0000\n", rx_ctl); 349 - 350 - ret = asix_sw_reset(dev, AX_SWRESET_PRL); 351 - if (ret < 0) 352 - goto out; 353 - 354 - msleep(150); 355 - 356 - ret = asix_sw_reset(dev, AX_SWRESET_IPRL | AX_SWRESET_PRL); 357 - if (ret < 0) 358 - goto out; 359 - 360 - msleep(150); 361 - 362 - asix_mdio_write(dev->net, dev->mii.phy_id, MII_BMCR, BMCR_RESET); 363 - asix_mdio_write(dev->net, dev->mii.phy_id, MII_ADVERTISE, 364 - ADVERTISE_ALL | ADVERTISE_CSMA); 365 - mii_nway_restart(&dev->mii); 366 - 367 - ret = asix_write_medium_mode(dev, AX88772_MEDIUM_DEFAULT); 381 + ret = asix_write_medium_mode(dev, AX88772_MEDIUM_DEFAULT, in_pm); 368 382 if (ret < 0) 369 383 goto out; 370 384 371 385 ret = asix_write_cmd(dev, AX_CMD_WRITE_IPG0, 372 - AX88772_IPG0_DEFAULT | AX88772_IPG1_DEFAULT, 373 - AX88772_IPG2_DEFAULT, 0, NULL); 386 + AX88772_IPG0_DEFAULT | AX88772_IPG1_DEFAULT, 387 + AX88772_IPG2_DEFAULT, 0, NULL, in_pm); 374 388 if (ret < 0) { 375 389 netdev_dbg(dev->net, "Write IPG,IPG1,IPG2 failed: %d\n", ret); 376 390 goto out; 377 391 } 378 392 379 393 /* Rewrite MAC address */ 380 - memcpy(data->mac_addr, dev->net->dev_addr, ETH_ALEN); 381 - ret = asix_write_cmd(dev, AX_CMD_WRITE_NODE_ID, 0, 0, ETH_ALEN, 382 - data->mac_addr); 394 + ether_addr_copy(data->mac_addr, dev->net->dev_addr); 395 + ret = asix_write_cmd(dev, AX_CMD_WRITE_NODE_ID, 0, 0, 396 + ETH_ALEN, data->mac_addr, in_pm); 383 397 if (ret < 0) 384 398 goto out; 385 399 386 400 /* Set RX_CTL to default values with 2k buffer, and enable cactus */ 387 - ret = asix_write_rx_ctl(dev, AX_DEFAULT_RX_CTL); 401 + ret = asix_write_rx_ctl(dev, AX_DEFAULT_RX_CTL, in_pm); 388 402 if (ret < 0) 389 403 goto out; 390 404 391 - rx_ctl = asix_read_rx_ctl(dev); 405 + rx_ctl = asix_read_rx_ctl(dev, in_pm); 392 406 netdev_dbg(dev->net, "RX_CTL is 0x%04x after all initializations\n", 393 407 rx_ctl); 394 408 395 - rx_ctl = asix_read_medium_status(dev); 409 + rx_ctl = asix_read_medium_status(dev, in_pm); 396 410 netdev_dbg(dev->net, 397 411 "Medium Status is 0x%04x after all initializations\n", 398 412 rx_ctl); ··· 416 400 417 401 out: 418 402 return ret; 403 + } 419 404 405 + static int ax88772a_hw_reset(struct usbnet *dev, int in_pm) 406 + { 407 + struct asix_data *data = (struct asix_data *)&dev->data; 408 + int ret, embd_phy; 409 + u16 rx_ctl; 410 + u8 chipcode = 0; 411 + 412 + ret = asix_write_gpio(dev, AX_GPIO_RSE, 5, in_pm); 413 + if (ret < 0) 414 + goto out; 415 + 416 + embd_phy = ((dev->mii.phy_id & 0x1f) == 0x10 ? 1 : 0); 417 + 418 + ret = asix_write_cmd(dev, AX_CMD_SW_PHY_SELECT, embd_phy | 419 + AX_PHYSEL_SSEN, 0, 0, NULL, in_pm); 420 + if (ret < 0) { 421 + netdev_dbg(dev->net, "Select PHY #1 failed: %d\n", ret); 422 + goto out; 423 + } 424 + usleep_range(10000, 11000); 425 + 426 + ret = asix_sw_reset(dev, AX_SWRESET_IPPD | AX_SWRESET_IPRL, in_pm); 427 + if (ret < 0) 428 + goto out; 429 + 430 + usleep_range(10000, 11000); 431 + 432 + ret = asix_sw_reset(dev, AX_SWRESET_IPRL, in_pm); 433 + if (ret < 0) 434 + goto out; 435 + 436 + msleep(160); 437 + 438 + ret = asix_sw_reset(dev, AX_SWRESET_CLEAR, in_pm); 439 + if (ret < 0) 440 + goto out; 441 + 442 + ret = asix_sw_reset(dev, AX_SWRESET_IPRL, in_pm); 443 + if (ret < 0) 444 + goto out; 445 + 446 + msleep(200); 447 + 448 + if (in_pm && (!asix_mdio_read_nopm(dev->net, dev->mii.phy_id, 449 + MII_PHYSID1))) { 450 + ret = -1; 451 + goto out; 452 + } 453 + 454 + ret = asix_read_cmd(dev, AX_CMD_STATMNGSTS_REG, 0, 455 + 0, 1, &chipcode, in_pm); 456 + if (ret < 0) 457 + goto out; 458 + 459 + if ((chipcode & AX_CHIPCODE_MASK) == AX_AX88772B_CHIPCODE) { 460 + ret = asix_write_cmd(dev, AX_QCTCTRL, 0x8000, 0x8001, 461 + 0, NULL, in_pm); 462 + if (ret < 0) { 463 + netdev_dbg(dev->net, "Write BQ setting failed: %d\n", 464 + ret); 465 + goto out; 466 + } 467 + } 468 + 469 + ret = asix_write_cmd(dev, AX_CMD_WRITE_IPG0, 470 + AX88772_IPG0_DEFAULT | AX88772_IPG1_DEFAULT, 471 + AX88772_IPG2_DEFAULT, 0, NULL, in_pm); 472 + if (ret < 0) { 473 + netdev_dbg(dev->net, "Write IPG,IPG1,IPG2 failed: %d\n", ret); 474 + goto out; 475 + } 476 + 477 + /* Rewrite MAC address */ 478 + memcpy(data->mac_addr, dev->net->dev_addr, ETH_ALEN); 479 + ret = asix_write_cmd(dev, AX_CMD_WRITE_NODE_ID, 0, 0, ETH_ALEN, 480 + data->mac_addr, in_pm); 481 + if (ret < 0) 482 + goto out; 483 + 484 + /* Set RX_CTL to default values with 2k buffer, and enable cactus */ 485 + ret = asix_write_rx_ctl(dev, AX_DEFAULT_RX_CTL, in_pm); 486 + if (ret < 0) 487 + goto out; 488 + 489 + ret = asix_write_medium_mode(dev, AX88772_MEDIUM_DEFAULT, in_pm); 490 + if (ret < 0) 491 + return ret; 492 + 493 + /* Set RX_CTL to default values with 2k buffer, and enable cactus */ 494 + ret = asix_write_rx_ctl(dev, AX_DEFAULT_RX_CTL, in_pm); 495 + if (ret < 0) 496 + goto out; 497 + 498 + rx_ctl = asix_read_rx_ctl(dev, in_pm); 499 + netdev_dbg(dev->net, "RX_CTL is 0x%04x after all initializations\n", 500 + rx_ctl); 501 + 502 + rx_ctl = asix_read_medium_status(dev, in_pm); 503 + netdev_dbg(dev->net, 504 + "Medium Status is 0x%04x after all initializations\n", 505 + rx_ctl); 506 + 507 + return 0; 508 + 509 + out: 510 + return ret; 420 511 } 421 512 422 513 static const struct net_device_ops ax88772_netdev_ops = { ··· 538 415 .ndo_set_rx_mode = asix_set_multicast, 539 416 }; 540 417 418 + static void ax88772_suspend(struct usbnet *dev) 419 + { 420 + struct asix_common_private *priv = dev->driver_priv; 421 + 422 + /* Preserve BMCR for restoring */ 423 + priv->presvd_phy_bmcr = 424 + asix_mdio_read_nopm(dev->net, dev->mii.phy_id, MII_BMCR); 425 + 426 + /* Preserve ANAR for restoring */ 427 + priv->presvd_phy_advertise = 428 + asix_mdio_read_nopm(dev->net, dev->mii.phy_id, MII_ADVERTISE); 429 + } 430 + 431 + static int asix_suspend(struct usb_interface *intf, pm_message_t message) 432 + { 433 + struct usbnet *dev = usb_get_intfdata(intf); 434 + struct asix_common_private *priv = dev->driver_priv; 435 + 436 + if (priv->suspend) 437 + priv->suspend(dev); 438 + 439 + return usbnet_suspend(intf, message); 440 + } 441 + 442 + static void ax88772_restore_phy(struct usbnet *dev) 443 + { 444 + struct asix_common_private *priv = dev->driver_priv; 445 + 446 + if (priv->presvd_phy_advertise) { 447 + /* Restore Advertisement control reg */ 448 + asix_mdio_write_nopm(dev->net, dev->mii.phy_id, MII_ADVERTISE, 449 + priv->presvd_phy_advertise); 450 + 451 + /* Restore BMCR */ 452 + asix_mdio_write_nopm(dev->net, dev->mii.phy_id, MII_BMCR, 453 + priv->presvd_phy_bmcr); 454 + 455 + priv->presvd_phy_advertise = 0; 456 + priv->presvd_phy_bmcr = 0; 457 + } 458 + } 459 + 460 + static void ax88772_resume(struct usbnet *dev) 461 + { 462 + int i; 463 + 464 + for (i = 0; i < 3; i++) 465 + if (!ax88772_hw_reset(dev, 1)) 466 + break; 467 + ax88772_restore_phy(dev); 468 + } 469 + 470 + static void ax88772a_resume(struct usbnet *dev) 471 + { 472 + int i; 473 + 474 + for (i = 0; i < 3; i++) { 475 + if (!ax88772a_hw_reset(dev, 1)) 476 + break; 477 + } 478 + 479 + ax88772_restore_phy(dev); 480 + } 481 + 482 + static int asix_resume(struct usb_interface *intf) 483 + { 484 + struct usbnet *dev = usb_get_intfdata(intf); 485 + struct asix_common_private *priv = dev->driver_priv; 486 + 487 + if (priv->resume) 488 + priv->resume(dev); 489 + 490 + return usbnet_resume(intf); 491 + } 492 + 541 493 static int ax88772_bind(struct usbnet *dev, struct usb_interface *intf) 542 494 { 543 - int ret, embd_phy, i; 544 - u8 buf[ETH_ALEN]; 495 + int ret, i; 496 + u8 buf[ETH_ALEN], chipcode = 0; 545 497 u32 phyid; 498 + struct asix_common_private *priv; 546 499 547 500 usbnet_get_endpoints(dev,intf); 548 501 ··· 626 427 if (dev->driver_info->data & FLAG_EEPROM_MAC) { 627 428 for (i = 0; i < (ETH_ALEN >> 1); i++) { 628 429 ret = asix_read_cmd(dev, AX_CMD_READ_EEPROM, 0x04 + i, 629 - 0, 2, buf + i * 2); 430 + 0, 2, buf + i * 2, 0); 630 431 if (ret < 0) 631 432 break; 632 433 } 633 434 } else { 634 435 ret = asix_read_cmd(dev, AX_CMD_READ_NODE_ID, 635 - 0, 0, ETH_ALEN, buf); 436 + 0, 0, ETH_ALEN, buf, 0); 636 437 } 637 438 638 439 if (ret < 0) { ··· 655 456 dev->net->needed_headroom = 4; /* cf asix_tx_fixup() */ 656 457 dev->net->needed_tailroom = 4; /* cf asix_tx_fixup() */ 657 458 658 - embd_phy = ((dev->mii.phy_id & 0x1f) == 0x10 ? 1 : 0); 459 + asix_read_cmd(dev, AX_CMD_STATMNGSTS_REG, 0, 0, 1, &chipcode, 0); 460 + chipcode &= AX_CHIPCODE_MASK; 659 461 660 - /* Reset the PHY to normal operation mode */ 661 - ret = asix_write_cmd(dev, AX_CMD_SW_PHY_SELECT, embd_phy, 0, 0, NULL); 662 - if (ret < 0) { 663 - netdev_dbg(dev->net, "Select PHY #1 failed: %d\n", ret); 664 - return ret; 665 - } 666 - 667 - ax88772_reset(dev); 462 + (chipcode == AX_AX88772_CHIPCODE) ? ax88772_hw_reset(dev, 0) : 463 + ax88772a_hw_reset(dev, 0); 668 464 669 465 /* Read PHYID register *AFTER* the PHY was reset properly */ 670 466 phyid = asix_get_phyid(dev); ··· 675 481 dev->driver_priv = kzalloc(sizeof(struct asix_common_private), GFP_KERNEL); 676 482 if (!dev->driver_priv) 677 483 return -ENOMEM; 484 + 485 + priv = dev->driver_priv; 486 + 487 + priv->presvd_phy_bmcr = 0; 488 + priv->presvd_phy_advertise = 0; 489 + if (chipcode == AX_AX88772_CHIPCODE) { 490 + priv->resume = ax88772_resume; 491 + priv->suspend = ax88772_suspend; 492 + } else { 493 + priv->resume = ax88772a_resume; 494 + priv->suspend = ax88772_suspend; 495 + } 678 496 679 497 return 0; 680 498 } ··· 799 593 int gpio0 = 0; 800 594 u32 phyid; 801 595 802 - asix_read_cmd(dev, AX_CMD_READ_GPIOS, 0, 0, 1, &status); 596 + asix_read_cmd(dev, AX_CMD_READ_GPIOS, 0, 0, 1, &status, 0); 803 597 netdev_dbg(dev->net, "GPIO Status: 0x%04x\n", status); 804 598 805 - asix_write_cmd(dev, AX_CMD_WRITE_ENABLE, 0, 0, 0, NULL); 806 - asix_read_cmd(dev, AX_CMD_READ_EEPROM, 0x0017, 0, 2, &eeprom); 807 - asix_write_cmd(dev, AX_CMD_WRITE_DISABLE, 0, 0, 0, NULL); 599 + asix_write_cmd(dev, AX_CMD_WRITE_ENABLE, 0, 0, 0, NULL, 0); 600 + asix_read_cmd(dev, AX_CMD_READ_EEPROM, 0x0017, 0, 2, &eeprom, 0); 601 + asix_write_cmd(dev, AX_CMD_WRITE_DISABLE, 0, 0, 0, NULL, 0); 808 602 809 603 netdev_dbg(dev->net, "EEPROM index 0x17 is 0x%04x\n", eeprom); 810 604 ··· 820 614 netdev_dbg(dev->net, "GPIO0: %d, PhyMode: %d\n", gpio0, data->phymode); 821 615 822 616 /* Power up external GigaPHY through AX88178 GPIO pin */ 823 - asix_write_gpio(dev, AX_GPIO_RSE | AX_GPIO_GPO_1 | AX_GPIO_GPO1EN, 40); 617 + asix_write_gpio(dev, AX_GPIO_RSE | AX_GPIO_GPO_1 | 618 + AX_GPIO_GPO1EN, 40, 0); 824 619 if ((le16_to_cpu(eeprom) >> 8) != 1) { 825 - asix_write_gpio(dev, 0x003c, 30); 826 - asix_write_gpio(dev, 0x001c, 300); 827 - asix_write_gpio(dev, 0x003c, 30); 620 + asix_write_gpio(dev, 0x003c, 30, 0); 621 + asix_write_gpio(dev, 0x001c, 300, 0); 622 + asix_write_gpio(dev, 0x003c, 30, 0); 828 623 } else { 829 624 netdev_dbg(dev->net, "gpio phymode == 1 path\n"); 830 - asix_write_gpio(dev, AX_GPIO_GPO1EN, 30); 831 - asix_write_gpio(dev, AX_GPIO_GPO1EN | AX_GPIO_GPO_1, 30); 625 + asix_write_gpio(dev, AX_GPIO_GPO1EN, 30, 0); 626 + asix_write_gpio(dev, AX_GPIO_GPO1EN | AX_GPIO_GPO_1, 30, 0); 832 627 } 833 628 834 629 /* Read PHYID register *AFTER* powering up PHY */ ··· 837 630 netdev_dbg(dev->net, "PHYID=0x%08x\n", phyid); 838 631 839 632 /* Set AX88178 to enable MII/GMII/RGMII interface for external PHY */ 840 - asix_write_cmd(dev, AX_CMD_SW_PHY_SELECT, 0, 0, 0, NULL); 633 + asix_write_cmd(dev, AX_CMD_SW_PHY_SELECT, 0, 0, 0, NULL, 0); 841 634 842 - asix_sw_reset(dev, 0); 635 + asix_sw_reset(dev, 0, 0); 843 636 msleep(150); 844 637 845 - asix_sw_reset(dev, AX_SWRESET_PRL | AX_SWRESET_IPPD); 638 + asix_sw_reset(dev, AX_SWRESET_PRL | AX_SWRESET_IPPD, 0); 846 639 msleep(150); 847 640 848 - asix_write_rx_ctl(dev, 0); 641 + asix_write_rx_ctl(dev, 0, 0); 849 642 850 643 if (data->phymode == PHY_MODE_MARVELL) { 851 644 marvell_phy_init(dev); ··· 862 655 863 656 mii_nway_restart(&dev->mii); 864 657 865 - ret = asix_write_medium_mode(dev, AX88178_MEDIUM_DEFAULT); 658 + ret = asix_write_medium_mode(dev, AX88178_MEDIUM_DEFAULT, 0); 866 659 if (ret < 0) 867 660 return ret; 868 661 869 662 /* Rewrite MAC address */ 870 663 memcpy(data->mac_addr, dev->net->dev_addr, ETH_ALEN); 871 664 ret = asix_write_cmd(dev, AX_CMD_WRITE_NODE_ID, 0, 0, ETH_ALEN, 872 - data->mac_addr); 665 + data->mac_addr, 0); 873 666 if (ret < 0) 874 667 return ret; 875 668 876 - ret = asix_write_rx_ctl(dev, AX_DEFAULT_RX_CTL); 669 + ret = asix_write_rx_ctl(dev, AX_DEFAULT_RX_CTL, 0); 877 670 if (ret < 0) 878 671 return ret; 879 672 ··· 911 704 netdev_dbg(dev->net, "ax88178_link_reset() speed: %u duplex: %d setting mode to 0x%04x\n", 912 705 speed, ecmd.duplex, mode); 913 706 914 - asix_write_medium_mode(dev, mode); 707 + asix_write_medium_mode(dev, mode, 0); 915 708 916 709 if (data->phymode == PHY_MODE_MARVELL && data->ledmode) 917 710 marvell_led_status(dev, speed); ··· 940 733 mfb = AX_RX_CTL_MFB_16384; 941 734 } 942 735 943 - rxctl = asix_read_rx_ctl(dev); 944 - asix_write_rx_ctl(dev, (rxctl & ~AX_RX_CTL_MFB_16384) | mfb); 736 + rxctl = asix_read_rx_ctl(dev, 0); 737 + asix_write_rx_ctl(dev, (rxctl & ~AX_RX_CTL_MFB_16384) | mfb, 0); 945 738 946 - medium = asix_read_medium_status(dev); 739 + medium = asix_read_medium_status(dev, 0); 947 740 if (dev->net->mtu > 1500) 948 741 medium |= AX_MEDIUM_JFE; 949 742 else 950 743 medium &= ~AX_MEDIUM_JFE; 951 - asix_write_medium_mode(dev, medium); 744 + asix_write_medium_mode(dev, medium, 0); 952 745 953 746 if (dev->rx_urb_size > old_rx_urb_size) 954 747 usbnet_unlink_rx_urbs(dev); ··· 997 790 usbnet_get_endpoints(dev,intf); 998 791 999 792 /* Get the MAC address */ 1000 - ret = asix_read_cmd(dev, AX_CMD_READ_NODE_ID, 0, 0, ETH_ALEN, buf); 793 + ret = asix_read_cmd(dev, AX_CMD_READ_NODE_ID, 0, 0, ETH_ALEN, buf, 0); 1001 794 if (ret < 0) { 1002 795 netdev_dbg(dev->net, "Failed to read MAC address: %d\n", ret); 1003 796 return ret; ··· 1018 811 dev->net->ethtool_ops = &ax88178_ethtool_ops; 1019 812 1020 813 /* Blink LEDS so users know driver saw dongle */ 1021 - asix_sw_reset(dev, 0); 814 + asix_sw_reset(dev, 0, 0); 1022 815 msleep(150); 1023 816 1024 - asix_sw_reset(dev, AX_SWRESET_PRL | AX_SWRESET_IPPD); 817 + asix_sw_reset(dev, AX_SWRESET_PRL | AX_SWRESET_IPPD, 0); 1025 818 msleep(150); 1026 819 1027 820 /* Asix framing packs multiple eth frames into a 2K usb bulk transfer */ ··· 1084 877 .unbind = ax88772_unbind, 1085 878 .status = asix_status, 1086 879 .link_reset = ax88772_link_reset, 1087 - .reset = ax88772_link_reset, 880 + .reset = ax88772_reset, 1088 881 .flags = FLAG_ETHER | FLAG_FRAMING_AX | FLAG_LINK_INTR | FLAG_MULTI_PACKET, 1089 882 .rx_fixup = asix_rx_fixup_common, 1090 883 .tx_fixup = asix_tx_fixup, ··· 1212 1005 }, { 1213 1006 // Lenovo U2L100P 10/100 1214 1007 USB_DEVICE (0x17ef, 0x7203), 1215 - .driver_info = (unsigned long) &ax88772_info, 1008 + .driver_info = (unsigned long)&ax88772b_info, 1216 1009 }, { 1217 1010 // ASIX AX88772B 10/100 1218 1011 USB_DEVICE (0x0b95, 0x772b), ··· 1280 1073 }, { 1281 1074 // Asus USB Ethernet Adapter 1282 1075 USB_DEVICE (0x0b95, 0x7e2b), 1283 - .driver_info = (unsigned long) &ax88772_info, 1076 + .driver_info = (unsigned long)&ax88772b_info, 1284 1077 }, { 1285 1078 /* ASIX 88172a demo board */ 1286 1079 USB_DEVICE(0x0b95, 0x172a), ··· 1302 1095 .name = DRIVER_NAME, 1303 1096 .id_table = products, 1304 1097 .probe = usbnet_probe, 1305 - .suspend = usbnet_suspend, 1306 - .resume = usbnet_resume, 1098 + .suspend = asix_suspend, 1099 + .resume = asix_resume, 1307 1100 .disconnect = usbnet_disconnect, 1308 1101 .supports_autosuspend = 1, 1309 1102 .disable_hub_initiated_lpm = 1,
+15 -14
drivers/net/usb/ax88172a.c
··· 81 81 } 82 82 83 83 if (mode != priv->oldmode) { 84 - asix_write_medium_mode(dev, mode); 84 + asix_write_medium_mode(dev, mode, 0); 85 85 priv->oldmode = mode; 86 86 netdev_dbg(netdev, "speed %u duplex %d, setting mode to 0x%04x\n", 87 87 phydev->speed, phydev->duplex, mode); ··· 176 176 { 177 177 int ret; 178 178 179 - ret = asix_sw_reset(dev, AX_SWRESET_IPPD); 179 + ret = asix_sw_reset(dev, AX_SWRESET_IPPD, 0); 180 180 if (ret < 0) 181 181 goto err; 182 182 183 183 msleep(150); 184 - ret = asix_sw_reset(dev, AX_SWRESET_CLEAR); 184 + ret = asix_sw_reset(dev, AX_SWRESET_CLEAR, 0); 185 185 if (ret < 0) 186 186 goto err; 187 187 188 188 msleep(150); 189 189 190 - ret = asix_sw_reset(dev, embd_phy ? AX_SWRESET_IPRL : AX_SWRESET_IPPD); 190 + ret = asix_sw_reset(dev, embd_phy ? AX_SWRESET_IPRL : AX_SWRESET_IPPD, 191 + 0); 191 192 if (ret < 0) 192 193 goto err; 193 194 ··· 214 213 dev->driver_priv = priv; 215 214 216 215 /* Get the MAC address */ 217 - ret = asix_read_cmd(dev, AX_CMD_READ_NODE_ID, 0, 0, ETH_ALEN, buf); 216 + ret = asix_read_cmd(dev, AX_CMD_READ_NODE_ID, 0, 0, ETH_ALEN, buf, 0); 218 217 if (ret < 0) { 219 218 netdev_err(dev->net, "Failed to read MAC address: %d\n", ret); 220 219 goto free; ··· 225 224 dev->net->ethtool_ops = &ax88172a_ethtool_ops; 226 225 227 226 /* are we using the internal or the external phy? */ 228 - ret = asix_read_cmd(dev, AX_CMD_SW_PHY_STATUS, 0, 0, 1, buf); 227 + ret = asix_read_cmd(dev, AX_CMD_SW_PHY_STATUS, 0, 0, 1, buf, 0); 229 228 if (ret < 0) { 230 229 netdev_err(dev->net, "Failed to read software interface selection register: %d\n", 231 230 ret); ··· 304 303 ax88172a_reset_phy(dev, priv->use_embdphy); 305 304 306 305 msleep(150); 307 - rx_ctl = asix_read_rx_ctl(dev); 306 + rx_ctl = asix_read_rx_ctl(dev, 0); 308 307 netdev_dbg(dev->net, "RX_CTL is 0x%04x after software reset\n", rx_ctl); 309 - ret = asix_write_rx_ctl(dev, 0x0000); 308 + ret = asix_write_rx_ctl(dev, 0x0000, 0); 310 309 if (ret < 0) 311 310 goto out; 312 311 313 - rx_ctl = asix_read_rx_ctl(dev); 312 + rx_ctl = asix_read_rx_ctl(dev, 0); 314 313 netdev_dbg(dev->net, "RX_CTL is 0x%04x setting to 0x0000\n", rx_ctl); 315 314 316 315 msleep(150); 317 316 318 317 ret = asix_write_cmd(dev, AX_CMD_WRITE_IPG0, 319 318 AX88772_IPG0_DEFAULT | AX88772_IPG1_DEFAULT, 320 - AX88772_IPG2_DEFAULT, 0, NULL); 319 + AX88772_IPG2_DEFAULT, 0, NULL, 0); 321 320 if (ret < 0) { 322 321 netdev_err(dev->net, "Write IPG,IPG1,IPG2 failed: %d\n", ret); 323 322 goto out; ··· 326 325 /* Rewrite MAC address */ 327 326 memcpy(data->mac_addr, dev->net->dev_addr, ETH_ALEN); 328 327 ret = asix_write_cmd(dev, AX_CMD_WRITE_NODE_ID, 0, 0, ETH_ALEN, 329 - data->mac_addr); 328 + data->mac_addr, 0); 330 329 if (ret < 0) 331 330 goto out; 332 331 333 332 /* Set RX_CTL to default values with 2k buffer, and enable cactus */ 334 - ret = asix_write_rx_ctl(dev, AX_DEFAULT_RX_CTL); 333 + ret = asix_write_rx_ctl(dev, AX_DEFAULT_RX_CTL, 0); 335 334 if (ret < 0) 336 335 goto out; 337 336 338 - rx_ctl = asix_read_rx_ctl(dev); 337 + rx_ctl = asix_read_rx_ctl(dev, 0); 339 338 netdev_dbg(dev->net, "RX_CTL is 0x%04x after all initializations\n", 340 339 rx_ctl); 341 340 342 - rx_ctl = asix_read_medium_status(dev); 341 + rx_ctl = asix_read_medium_status(dev, 0); 343 342 netdev_dbg(dev->net, "Medium Status is 0x%04x after all initializations\n", 344 343 rx_ctl); 345 344