Changeset cbfece7 in mainline for uspace/drv/nic/rtl8169/driver.c
- Timestamp:
- 2014-07-21T22:10:18Z (11 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 1f1fa64
- Parents:
- 96e368a (diff), 54a1ca7 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/nic/rtl8169/driver.c
r96e368a rcbfece7 33 33 #include <align.h> 34 34 #include <byteorder.h> 35 #include <irc.h> 35 36 #include <libarch/barrier.h> 36 37 … … 388 389 rtl8169_t *rtl8169 = nic_get_specific(nic_data); 389 390 391 /* Get PCI VID & PID */ 392 rc = pci_config_space_read_16(ddf_dev_parent_sess_get(dev), 393 PCI_VENDOR_ID, &rtl8169->pci_vid); 394 if (rc != EOK) 395 return rc; 396 397 rc = pci_config_space_read_16(ddf_dev_parent_sess_get(dev), 398 PCI_DEVICE_ID, &rtl8169->pci_pid); 399 if (rc != EOK) 400 return rc; 401 390 402 /* Map register space */ 391 403 rc = pio_enable(rtl8169->regs_phys, RTL8169_IO_SIZE, &rtl8169->regs); … … 418 430 uint8_t cr_value = pio_read_8(rtl8169->regs + CR); 419 431 pio_write_8(rtl8169->regs + CR, cr_value | CR_TE | CR_RE); 420 421 rc = nic_connect_to_services(nic_data);422 if (rc != EOK) {423 ddf_msg(LVL_ERROR, "Failed to connect to services (%d)", rc);424 goto err_irq;425 }426 432 427 433 fun = ddf_fun_create(nic_get_ddf_dev(nic_data), fun_exposed, "port0"); … … 473 479 int rc; 474 480 475 rtl8169_set_hwaddr(rtl8169, addr); 481 fibril_mutex_lock(&rtl8169->rx_lock); 482 fibril_mutex_lock(&rtl8169->tx_lock); 476 483 477 484 rc = nic_report_address(nic_data, addr); … … 479 486 return rc; 480 487 488 rtl8169_set_hwaddr(rtl8169, addr); 489 490 fibril_mutex_unlock(&rtl8169->rx_lock); 491 fibril_mutex_unlock(&rtl8169->tx_lock); 492 481 493 return EOK; 482 494 } … … 484 496 static int rtl8169_get_device_info(ddf_fun_t *fun, nic_device_info_t *info) 485 497 { 486 487 str_cpy(info->vendor_name, NIC_VENDOR_MAX_LENGTH, "Realtek"); 488 str_cpy(info->model_name, NIC_MODEL_MAX_LENGTH, "RTL8169"); 498 nic_t *nic_data = nic_get_from_ddf_fun(fun); 499 rtl8169_t *rtl8169 = nic_get_specific(nic_data); 500 501 str_cpy(info->vendor_name, NIC_VENDOR_MAX_LENGTH, "Unknown"); 502 str_cpy(info->model_name, NIC_MODEL_MAX_LENGTH, "Unknown"); 503 504 if (rtl8169->pci_vid == PCI_VID_REALTEK) 505 str_cpy(info->vendor_name, NIC_VENDOR_MAX_LENGTH, "Realtek"); 506 507 if (rtl8169->pci_vid == PCI_VID_DLINK) 508 str_cpy(info->vendor_name, NIC_VENDOR_MAX_LENGTH, "D-Link"); 509 510 if (rtl8169->pci_pid == 0x8168) 511 str_cpy(info->model_name, NIC_MODEL_MAX_LENGTH, "RTL8168"); 512 513 if (rtl8169->pci_pid == 0x8169) 514 str_cpy(info->model_name, NIC_MODEL_MAX_LENGTH, "RTL8169"); 515 516 if (rtl8169->pci_pid == 0x8110) 517 str_cpy(info->model_name, NIC_MODEL_MAX_LENGTH, "RTL8110"); 489 518 490 519 return EOK; … … 541 570 bmcr &= ~(BMCR_DUPLEX | BMCR_SPD_100 | BMCR_SPD_1000); 542 571 572 /* Disable autonegotiation */ 573 bmcr &= ~BMCR_AN_ENABLE; 574 543 575 if (duplex == NIC_CM_FULL_DUPLEX) 544 576 bmcr |= BMCR_DUPLEX; … … 609 641 static int rtl8169_autoneg_restart(ddf_fun_t *fun) 610 642 { 643 rtl8169_t *rtl8169 = nic_get_specific(nic_get_from_ddf_fun(fun)); 644 uint16_t bmcr = rtl8169_mii_read(rtl8169, MII_BMCR); 645 646 bmcr |= BMCR_AN_ENABLE; 647 rtl8169_mii_write(rtl8169, MII_BMCR, bmcr); 611 648 return EOK; 612 649 } … … 706 743 707 744 pio_write_16(rtl8169->regs + IMR, 0xffff); 708 nic_enable_interrupt(nic_data,rtl8169->irq);745 irc_enable_interrupt(rtl8169->irq); 709 746 710 747 return EOK; … … 888 925 } 889 926 927 /* Receive underrun */ 928 if (isr & INT_RXOVW) { 929 /* just ack.. */ 930 pio_write_16(rtl8169->regs + ISR, INT_RXOVW); 931 } 932 890 933 if (isr & INT_SERR) { 891 934 ddf_msg(LVL_ERROR, "System error interrupt");
Note:
See TracChangeset
for help on using the changeset viewer.