diff options
author | Gaggery Tsai <gaggery.tsai@intel.com> | 2017-11-16 17:21:23 +0800 |
---|---|---|
committer | Furquan Shaikh <furquan@google.com> | 2017-11-27 02:44:02 +0000 |
commit | 6919a9376e1fefc1072b638d754588d8ba287aed (patch) | |
tree | 6c093177dc8d9ec48fda7d6dce17d1a29905f2de | |
parent | 73add175cd866a5acd2bddb662080d6b03179d8b (diff) |
drivers/net: add SSDT ACPI declaration and WOL feature
This patch adds SSDT ACPI generator and declares _UID, _HID, _DDN and
also _PRW for WOL feature. Besides, adds a wake variable in chip
information.
BUG=b:69290148
BRANCH=None
TEST=Add register "wake" = "GPE0_PCI_EXP" in devicetree under r8168
chip driver && dump SSDT to make sure _UID, _HID, _DDN and _PRW
are filled correctly && put system into S3 && sudo etherwake -i
eth0 $MAC to make sure the system could be woken up by WOL package.
Change-Id: Ibc9115e8a08ba2bfcb3ee1e34c73cf1976a6ba2d
Signed-off-by: Gaggery Tsai <gaggery.tsai@intel.com>
Reviewed-on: https://review.coreboot.org/22480
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Paul Menzel <paulepanter@users.sourceforge.net>
Reviewed-by: Duncan Laurie <dlaurie@chromium.org>
Reviewed-by: Furquan Shaikh <furquan@google.com>
-rw-r--r-- | src/drivers/net/chip.h | 1 | ||||
-rw-r--r-- | src/drivers/net/r8168.c | 52 |
2 files changed, 53 insertions, 0 deletions
diff --git a/src/drivers/net/chip.h b/src/drivers/net/chip.h index 7a37cdedb9..8e8c02b002 100644 --- a/src/drivers/net/chip.h +++ b/src/drivers/net/chip.h @@ -16,6 +16,7 @@ struct drivers_net_config { uint16_t customized_leds; + unsigned wake; /* Wake pin for ACPI _PRW */ }; #endif /* __DRIVERS_R8168_CHIP_H__ */ diff --git a/src/drivers/net/r8168.c b/src/drivers/net/r8168.c index 350dc37322..4c17017440 100644 --- a/src/drivers/net/r8168.c +++ b/src/drivers/net/r8168.c @@ -22,6 +22,8 @@ */ #include <cbfs.h> +#include <arch/acpi_device.h> +#include <arch/acpigen.h> #include <string.h> #include <arch/io.h> #include <console/console.h> @@ -268,12 +270,58 @@ static void r8168_init(struct device *dev) r8168_set_customized_led(dev, io_base); } +#if IS_ENABLED(CONFIG_HAVE_ACPI_TABLES) +#define R8168_ACPI_HID "R8168" +static void r8168_net_fill_ssdt(struct device *dev) +{ + struct drivers_net_config *config = dev->chip_info; + const char *path = acpi_device_path(dev->bus->dev); + u32 address; + + if (!path || !config) + return; + + /* Device */ + acpigen_write_scope(path); + acpigen_write_device(acpi_device_name(dev)); + acpigen_write_name_string("_HID", R8168_ACPI_HID); + acpigen_write_name_integer("_UID", 0); + if (dev->chip_ops) + acpigen_write_name_string("_DDN", dev->chip_ops->name); + + /* Address */ + address = PCI_SLOT(dev->path.pci.devfn) & 0xffff; + address <<= 16; + address |= PCI_FUNC(dev->path.pci.devfn) & 0xffff; + acpigen_write_name_dword("_ADR", address); + + /* Wake capabilities */ + if (config->wake) + acpigen_write_PRW(config->wake, 3); + + acpigen_pop_len(); /* Device */ + acpigen_pop_len(); /* Scope */ + + printk(BIOS_INFO, "%s.%s: %s %s\n", path, acpi_device_name(dev), + dev->chip_ops ? dev->chip_ops->name : "", dev_path(dev)); +} + +static const char *r8168_net_acpi_name(const struct device *dev) +{ + return "RLTK"; +} +#endif + static struct device_operations r8168_ops = { .read_resources = pci_dev_read_resources, .set_resources = pci_dev_set_resources, .enable_resources = pci_dev_enable_resources, .init = r8168_init, .scan_bus = 0, +#if IS_ENABLED(CONFIG_HAVE_ACPI_TABLES) + .acpi_name = &r8168_net_acpi_name, + .acpi_fill_ssdt_generator = &r8168_net_fill_ssdt, +#endif }; static const struct pci_driver r8168_driver __pci_driver = { @@ -281,3 +329,7 @@ static const struct pci_driver r8168_driver __pci_driver = { .vendor = 0x10ec, .device = 0x8168, }; + +struct chip_operations drivers_net_ops = { + CHIP_NAME("Realtek r8168") +}; |