Attention is currently required from: Arthur Heymans. Hello Arthur Heymans,
I'd like you to do a code review. Please visit
https://review.coreboot.org/c/coreboot/+/59389
to review the following change.
Change subject: [NOTWORKING]mb/prodrive/hermes: WOL i211 driver?? ......................................................................
[NOTWORKING]mb/prodrive/hermes: WOL i211 driver??
Does not work...
Change-Id: Ia984020b969bfc5e59cfc74730cc34ccd63f3e00 Signed-off-by: Arthur Heymans arthur@aheymans.xyz --- M src/drivers/net/Kconfig M src/drivers/net/Makefile.inc A src/drivers/net/i211.c A src/drivers/net/i211.h M src/mainboard/prodrive/hermes/Kconfig M src/mainboard/prodrive/hermes/mainboard.c 6 files changed, 78 insertions(+), 3 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/89/59389/1
diff --git a/src/drivers/net/Kconfig b/src/drivers/net/Kconfig index 7e111f6..c6abf80 100644 --- a/src/drivers/net/Kconfig +++ b/src/drivers/net/Kconfig @@ -53,3 +53,8 @@ It must be in the form of "xx:xx:xx:xx:xx:xx", where x is a hexadecimal number for it to be valid. Failing to do so will result in the default MAC address being used. + +config INTEL_I211_WOL + bool + help + Select this to be able to configure the WOL state of the NIC. diff --git a/src/drivers/net/Makefile.inc b/src/drivers/net/Makefile.inc index 33c8211..6a1bde9 100644 --- a/src/drivers/net/Makefile.inc +++ b/src/drivers/net/Makefile.inc @@ -22,3 +22,5 @@ atl1e-macaddress-file := $(obj)/atl1e-macaddress atl1e-macaddress-type := raw endif + +ramstage-$(CONFIG_INTEL_I211_WOL) += i211.c diff --git a/src/drivers/net/i211.c b/src/drivers/net/i211.c new file mode 100644 index 0000000..8fcdecb --- /dev/null +++ b/src/drivers/net/i211.c @@ -0,0 +1,50 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ + +#include <arch/mmio.h> +#include <console/console.h> +#include <device/device.h> +#include <device/mmio.h> +#include <device/pci.h> + +#include "commonlib/loglevel.h" +#include "i211.h" + +#define E1000_WUC 0x05800 /* Wakeup Control - RW */ +#define E1000_WUC_APME 0x00000001 /* APM Enable */ +#define E1000_WUC_PME_EN 0x00000002 /* PME Enable */ +#define E1000_WUC_PME_STATUS 0x00000004 /* PME Status */ +#define E1000_WUC_APMPME 0x00000008 /* Assert PME on APM Wakeup */ +#define E1000_WUFC 0x05808 + +static void i211_init(struct device *dev) +{ + /* Get the resource of the NIC mmio */ + struct resource *nic_res = find_resource(dev, PCI_BASE_ADDRESS_0); + + if (nic_res == NULL) { + printk(BIOS_ERR, "i211: resource not found\n"); + return; + } + + void *wuc = res2mmio(nic_res, E1000_WUC, 0); + void *wufc = res2mmio(nic_res, E1000_WUFC, 0); + printk(BIOS_DEBUG, "i211: WUC 0x%x, WUFC 0x%x\n", read32(wuc), read32(wufc)); + if (i211_disable_wol()) + clrbits32(wuc, E1000_WUC_APME | E1000_WUC_PME_EN | E1000_WUC_APMPME); + else + setbits32(wuc, E1000_WUC_APME | E1000_WUC_PME_EN | E1000_WUC_APMPME); + printk(BIOS_DEBUG, "i211: WUC 0x%x, WUFC 0x%x\n", read32(wuc), read32(wufc)); +} + +static struct device_operations i211_ops = { + .read_resources = pci_dev_read_resources, + .set_resources = pci_dev_set_resources, + .enable_resources = pci_dev_enable_resources, + .init = i211_init, +}; + +static const struct pci_driver i211_driver __pci_driver = { + .ops = &i211_ops, + .vendor = 0x8086, + .device = 0x1539, +}; diff --git a/src/drivers/net/i211.h b/src/drivers/net/i211.h new file mode 100644 index 0000000..c8070d3 --- /dev/null +++ b/src/drivers/net/i211.h @@ -0,0 +1,8 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + +#ifndef __DRIVERS_INTEL_I211_H__ +#define __DRIVERS_INTEL_I211_H__ + +bool i211_disable_wol(void); + +#endif diff --git a/src/mainboard/prodrive/hermes/Kconfig b/src/mainboard/prodrive/hermes/Kconfig index 2fecc06..acd2c58 100644 --- a/src/mainboard/prodrive/hermes/Kconfig +++ b/src/mainboard/prodrive/hermes/Kconfig @@ -16,6 +16,7 @@ select ONBOARD_VGA_IS_PRIMARY select HAVE_ACPI_RESUME if !HERMES_USES_SPS_FIRMWARE select DISABLE_ACPI_HIBERNATE if HERMES_USES_SPS_FIRMWARE + select INTEL_I211_WOL
if BOARD_PRODRIVE_HERMES_BASEBOARD
diff --git a/src/mainboard/prodrive/hermes/mainboard.c b/src/mainboard/prodrive/hermes/mainboard.c index addd110..73d8643 100644 --- a/src/mainboard/prodrive/hermes/mainboard.c +++ b/src/mainboard/prodrive/hermes/mainboard.c @@ -8,6 +8,7 @@ #include <bootstate.h> #include <device/device.h> #include <device/dram/spd.h> +#include <drivers/net/i211.h> #include <intelblocks/pmclib.h> #include <types.h> #include <smbios.h> @@ -179,11 +180,14 @@
acpigen_write_method("\_SB.MPTS", 1); { - if (board_cfg->wol == 0) { - acpigen_write_if_lequal_op_int(ARG0_OP, 3); + if (board_cfg->wol == 0 || 1) { + acpigen_write_if(); + acpigen_emit_byte(LLESS_OP); + acpigen_emit_byte(ARG0_OP); + acpigen_write_integer(6); { /* Disable the NIC so WOL is also disabled. */ - acpigen_soc_set_tx_gpio(GPD11); + acpigen_soc_clear_tx_gpio(GPD11); } acpigen_pop_len(); } @@ -198,6 +202,11 @@ } #endif
+bool i211_disable_wol(void) +{ + return true; +} + static void mainboard_enable(struct device *dev) { /* FIXME: Do runtime configuration once the board is production ready */