diff --git a/drivers/ethernet/Kconfig.e1000 b/drivers/ethernet/Kconfig.e1000 index 5e89d3ea77e..0a4b128a9cf 100644 --- a/drivers/ethernet/Kconfig.e1000 +++ b/drivers/ethernet/Kconfig.e1000 @@ -8,7 +8,7 @@ menuconfig ETH_E1000 bool "Intel(R) PRO/1000 Gigabit Ethernet driver" - depends on PCI_ENUMERATION + depends on PCIE help Enable Intel(R) PRO/1000 Gigabit Ethernet driver. diff --git a/drivers/ethernet/eth_e1000.c b/drivers/ethernet/eth_e1000.c index afb556b7431..8f78cc62a99 100644 --- a/drivers/ethernet/eth_e1000.c +++ b/drivers/ethernet/eth_e1000.c @@ -12,7 +12,7 @@ LOG_MODULE_REGISTER(LOG_MODULE_NAME); #include #include #include -#include +#include #include "eth_e1000_priv.h" static const char *e1000_reg_to_string(enum e1000_reg_t r) @@ -132,24 +132,24 @@ static void e1000_isr(struct device *device) } } +#define PCI_VENDOR_ID_INTEL 0x8086 +#define PCI_DEVICE_ID_I82540EM 0x100e + int e1000_probe(struct device *device) { + const pcie_bdf_t bdf = PCIE_BDF(0, 3, 0); struct e1000_dev *dev = device->driver_data; + int retval = -ENODEV; - pci_bus_scan_init(); - - if (pci_bus_scan(&dev->pci)) { - - pci_enable_regs(&dev->pci); - - pci_enable_bus_master(&dev->pci); - - pci_show(&dev->pci); - - return 0; + if (pcie_probe(bdf, PCIE_ID(PCI_VENDOR_ID_INTEL, + PCI_DEVICE_ID_I82540EM))) { + dev->address = pcie_get_mbar(bdf, 0); + pcie_set_cmd(bdf, PCIE_CONF_CMDSTAT_MEM | + PCIE_CONF_CMDSTAT_MASTER, true); + retval = 0; } - return -ENODEV; + return retval; } static struct device DEVICE_NAME_GET(eth_e1000); @@ -210,13 +210,7 @@ static void e1000_init(struct net_if *iface) LOG_DBG("done"); } -#define PCI_VENDOR_ID_INTEL 0x8086 -#define PCI_DEVICE_ID_I82540EM 0x100e - -static struct e1000_dev e1000_dev = { - .pci.vendor_id = PCI_VENDOR_ID_INTEL, - .pci.device_id = PCI_DEVICE_ID_I82540EM, -}; +static struct e1000_dev e1000_dev; static const struct ethernet_api e1000_api = { .iface_api.init = e1000_init, diff --git a/drivers/ethernet/eth_e1000_priv.h b/drivers/ethernet/eth_e1000_priv.h index 9fcd5733b38..e3824e7efe0 100644 --- a/drivers/ethernet/eth_e1000_priv.h +++ b/drivers/ethernet/eth_e1000_priv.h @@ -77,7 +77,7 @@ struct e1000_rx { struct e1000_dev { volatile struct e1000_tx tx __aligned(16); volatile struct e1000_rx rx __aligned(16); - struct pci_dev_info pci; + u32_t address; struct net_if *iface; u8_t mac[ETH_ALEN]; u8_t txb[NET_ETH_MTU]; @@ -88,13 +88,13 @@ static const char *e1000_reg_to_string(enum e1000_reg_t r) __attribute__((unused)); #define iow32(_dev, _reg, _val) do { \ - LOG_DBG("iow32 %s 0x%08x", e1000_reg_to_string(_reg), _val); \ - sys_write32(_val, (_dev)->pci.addr + _reg); \ + LOG_DBG("iow32 %s 0x%08x", e1000_reg_to_string(_reg), (_val)); \ + sys_write32(_val, (_dev)->address + (_reg)); \ } while (0) #define ior32(_dev, _reg) \ ({ \ - u32_t val = sys_read32((_dev)->pci.addr + (_reg)); \ + u32_t val = sys_read32((_dev)->address + (_reg)); \ LOG_DBG("ior32 %s 0x%08x", e1000_reg_to_string(_reg), val); \ val; \ }) diff --git a/samples/net/dhcpv4_client/overlay-e1000.conf b/samples/net/dhcpv4_client/overlay-e1000.conf index cb5be851d40..faaf64fb3df 100644 --- a/samples/net/dhcpv4_client/overlay-e1000.conf +++ b/samples/net/dhcpv4_client/overlay-e1000.conf @@ -3,7 +3,6 @@ CONFIG_NET_QEMU_ETHERNET=y CONFIG_ETH_E1000=y -CONFIG_PCI_ENUMERATION=y -CONFIG_PCI=y +CONFIG_PCIE=y #CONFIG_ETHERNET_LOG_LEVEL_DBG=y diff --git a/samples/net/sockets/big_http_download/overlay-e1000.conf b/samples/net/sockets/big_http_download/overlay-e1000.conf index cb5be851d40..faaf64fb3df 100644 --- a/samples/net/sockets/big_http_download/overlay-e1000.conf +++ b/samples/net/sockets/big_http_download/overlay-e1000.conf @@ -3,7 +3,6 @@ CONFIG_NET_QEMU_ETHERNET=y CONFIG_ETH_E1000=y -CONFIG_PCI_ENUMERATION=y -CONFIG_PCI=y +CONFIG_PCIE=y #CONFIG_ETHERNET_LOG_LEVEL_DBG=y diff --git a/samples/net/sockets/dumb_http_server/overlay-e1000.conf b/samples/net/sockets/dumb_http_server/overlay-e1000.conf index cb5be851d40..faaf64fb3df 100644 --- a/samples/net/sockets/dumb_http_server/overlay-e1000.conf +++ b/samples/net/sockets/dumb_http_server/overlay-e1000.conf @@ -3,7 +3,6 @@ CONFIG_NET_QEMU_ETHERNET=y CONFIG_ETH_E1000=y -CONFIG_PCI_ENUMERATION=y -CONFIG_PCI=y +CONFIG_PCIE=y #CONFIG_ETHERNET_LOG_LEVEL_DBG=y diff --git a/samples/net/sockets/echo_server/overlay-e1000.conf b/samples/net/sockets/echo_server/overlay-e1000.conf index cb5be851d40..faaf64fb3df 100644 --- a/samples/net/sockets/echo_server/overlay-e1000.conf +++ b/samples/net/sockets/echo_server/overlay-e1000.conf @@ -3,7 +3,6 @@ CONFIG_NET_QEMU_ETHERNET=y CONFIG_ETH_E1000=y -CONFIG_PCI_ENUMERATION=y -CONFIG_PCI=y +CONFIG_PCIE=y #CONFIG_ETHERNET_LOG_LEVEL_DBG=y