enetc: Support building the driver as a loadable module.

Function level reset has to be done in attach in order to put the
hardware in a known state before configuring it.
The order of DRIVER_MODULEs was changed to ensure that the miibus driver
is loaded when mii_attach is called.

Obtained from: Semihalf
Sponsored by: Alstom Group
This commit is contained in:
Kornel Duleba 2021-07-28 11:23:23 +02:00 committed by Marcin Wojtas
parent bfce69ae9a
commit 5ad6d28cbe
3 changed files with 15 additions and 1 deletions

View File

@ -158,8 +158,8 @@ static driver_t enetc_driver = {
};
static devclass_t enetc_devclass;
DRIVER_MODULE(enetc, pci, enetc_driver, enetc_devclass, NULL, NULL);
DRIVER_MODULE(miibus, enetc, miibus_driver, miibus_devclass, NULL, NULL);
DRIVER_MODULE(enetc, pci, enetc_driver, enetc_devclass, NULL, NULL);
MODULE_VERSION(enetc, 1);
IFLIB_PNP_INFO(pci, enetc, enetc_vendor_info_array);
@ -366,6 +366,10 @@ enetc_attach_pre(if_ctx_t ctx)
sc->shared = scctx;
ifp = iflib_get_ifp(ctx);
pci_save_state(sc->dev);
pcie_flr(sc->dev, 1000, false);
pci_restore_state(sc->dev);
rid = PCIR_BAR(ENETC_BAR_REGS);
sc->regs = bus_alloc_resource_any(sc->dev, SYS_RES_MEMORY, &rid, RF_ACTIVE);
if (sc->regs == NULL) {

View File

@ -111,6 +111,7 @@ SUBDIR= \
${_efirt} \
${_em} \
${_ena} \
${_enetc} \
esp \
${_et} \
evdev \
@ -612,6 +613,7 @@ _allwinner= allwinner
_armv8crypto= armv8crypto
_dwwdt= dwwdt
_em= em
_enetc= enetc
_felix= felix
_rockchip= rockchip
.endif

View File

@ -0,0 +1,8 @@
#$FreeBSD$
.PATH: ${SRCTOP}/sys/dev/enetc
KMOD = if_enetc
SRCS = if_enetc.c enetc_mdio.c
.include <bsd.kmod.mk>