From 6919a9376e1fefc1072b638d754588d8ba287aed Mon Sep 17 00:00:00 2001 From: Gaggery Tsai Date: Thu, 16 Nov 2017 17:21:23 +0800 Subject: 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 Reviewed-on: https://review.coreboot.org/22480 Tested-by: build bot (Jenkins) Reviewed-by: Paul Menzel Reviewed-by: Duncan Laurie Reviewed-by: Furquan Shaikh --- src/drivers/net/chip.h | 1 + src/drivers/net/r8168.c | 52 +++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 53 insertions(+) (limited to 'src/drivers/net') 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 +#include +#include #include #include #include @@ -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") +}; -- cgit v1.2.3