+#endif
+
+#ifdef CONFIG_DM_ETH
+static int e1000_init_one(struct e1000_hw *hw, int cardnum,
+ struct udevice *devno, unsigned char enetaddr[6])
+#else
+static int e1000_init_one(struct e1000_hw *hw, int cardnum, pci_dev_t devno,
+ unsigned char enetaddr[6])
+#endif
+{
+ u32 val;
+
+ /* Assign the passed-in values */
+#ifdef CONFIG_DM_ETH
+ hw->pdev = devno;
+#else
+ hw->pdev = devno;
+#endif
+ hw->cardnum = cardnum;
+
+ /* Print a debug message with the IO base address */
+#ifdef CONFIG_DM_ETH
+ dm_pci_read_config32(devno, PCI_BASE_ADDRESS_0, &val);
+#else
+ pci_read_config_dword(devno, PCI_BASE_ADDRESS_0, &val);
+#endif
+ E1000_DBG(hw, "iobase 0x%08x\n", val & 0xfffffff0);
+
+ /* Try to enable I/O accesses and bus-mastering */
+ val = PCI_COMMAND_MEMORY | PCI_COMMAND_MASTER;
+#ifdef CONFIG_DM_ETH
+ dm_pci_write_config32(devno, PCI_COMMAND, val);
+#else
+ pci_write_config_dword(devno, PCI_COMMAND, val);
+#endif
+
+ /* Make sure it worked */
+#ifdef CONFIG_DM_ETH
+ dm_pci_read_config32(devno, PCI_COMMAND, &val);
+#else
+ pci_read_config_dword(devno, PCI_COMMAND, &val);
+#endif
+ if (!(val & PCI_COMMAND_MEMORY)) {
+ E1000_ERR(hw, "Can't enable I/O memory\n");
+ return -ENOSPC;
+ }
+ if (!(val & PCI_COMMAND_MASTER)) {
+ E1000_ERR(hw, "Can't enable bus-mastering\n");
+ return -EPERM;
+ }
+
+ /* Are these variables needed? */
+ hw->fc = e1000_fc_default;
+ hw->original_fc = e1000_fc_default;
+ hw->autoneg_failed = 0;
+ hw->autoneg = 1;
+ hw->get_link_status = true;
+#ifndef CONFIG_E1000_NO_NVM
+ hw->eeprom_semaphore_present = true;
+#endif
+#ifdef CONFIG_DM_ETH
+ hw->hw_addr = dm_pci_map_bar(devno, PCI_BASE_ADDRESS_0,
+ PCI_REGION_MEM);
+#else
+ hw->hw_addr = pci_map_bar(devno, PCI_BASE_ADDRESS_0,
+ PCI_REGION_MEM);
+#endif
+ hw->mac_type = e1000_undefined;
+
+ /* MAC and Phy settings */
+ if (e1000_sw_init(hw) < 0) {
+ E1000_ERR(hw, "Software init failed\n");
+ return -EIO;
+ }
+ if (e1000_check_phy_reset_block(hw))
+ E1000_ERR(hw, "PHY Reset is blocked!\n");
+
+ /* Basic init was OK, reset the hardware and allow SPI access */
+ e1000_reset_hw(hw);
+
+#ifndef CONFIG_E1000_NO_NVM
+ /* Validate the EEPROM and get chipset information */
+ if (e1000_init_eeprom_params(hw)) {
+ E1000_ERR(hw, "EEPROM is invalid!\n");
+ return -EINVAL;
+ }
+ if ((E1000_READ_REG(hw, I210_EECD) & E1000_EECD_FLUPD) &&
+ e1000_validate_eeprom_checksum(hw))
+ return -ENXIO;
+ e1000_read_mac_addr(hw, enetaddr);
+#endif
+ e1000_get_bus_type(hw);
+
+#ifndef CONFIG_E1000_NO_NVM
+ printf("e1000: %02x:%02x:%02x:%02x:%02x:%02x\n ",
+ enetaddr[0], enetaddr[1], enetaddr[2],
+ enetaddr[3], enetaddr[4], enetaddr[5]);
+#else
+ memset(enetaddr, 0, 6);
+ printf("e1000: no NVM\n");
+#endif
+
+ return 0;
+}
+
+/* Put the name of a device in a string */
+static void e1000_name(char *str, int cardnum)
+{
+ sprintf(str, "e1000#%u", cardnum);
+}
+
+#ifndef CONFIG_DM_ETH
+/**************************************************************************
+TRANSMIT - Transmit a frame
+***************************************************************************/
+static int e1000_transmit(struct eth_device *nic, void *txpacket, int length)
+{
+ struct e1000_hw *hw = nic->priv;
+
+ return _e1000_transmit(hw, txpacket, length);
+}
+
+/**************************************************************************
+DISABLE - Turn off ethernet interface
+***************************************************************************/
+static void
+e1000_disable(struct eth_device *nic)
+{
+ struct e1000_hw *hw = nic->priv;
+
+ _e1000_disable(hw);
+}
+
+/**************************************************************************
+INIT - set up ethernet interface(s)
+***************************************************************************/
+static int
+e1000_init(struct eth_device *nic, bd_t *bis)
+{
+ struct e1000_hw *hw = nic->priv;
+
+ return _e1000_init(hw, nic->enetaddr);
+}
+
+static int
+e1000_poll(struct eth_device *nic)
+{
+ struct e1000_hw *hw = nic->priv;
+ int len;
+
+ len = _e1000_poll(hw);
+ if (len) {
+ net_process_received_packet((uchar *)packet, len);
+ fill_rx(hw);
+ }
+
+ return len ? 1 : 0;
+}