[coreboot-gerrit] Change in coreboot[master]: drivers/net: add SSDT ACPI declaration and WOL feature

Gaggery Tsai (Code Review) gerrit at coreboot.org
Thu Nov 16 10:42:24 CET 2017


Gaggery Tsai has uploaded this change for review. ( https://review.coreboot.org/22480


Change subject: drivers/net: add SSDT ACPI declaration and WOL feature
......................................................................

drivers/net: add SSDT ACPI declaration and WOL feature

This patch adds SSDT ACPI generator and declares _UID, _DDN and also
_PRW for WOL feature. Besides, adds a wake variable in chip information.

BUG=b:69290148
BRANCH=None
TEST=Adds register "wake" = "GPE0_PCI_EXP" in devicetree under r8168
     chip driver && put system into S3 && sudo etherwake -i eth0 $MAC
     to make sure the system could be waken up by WOL package.

Change-Id: Ibc9115e8a08ba2bfcb3ee1e34c73cf1976a6ba2d
Signed-off-by: Gaggery Tsai <gaggery.tsai at intel.com>
---
M src/drivers/net/chip.h
M src/drivers/net/r8168.c
2 files changed, 51 insertions(+), 0 deletions(-)



  git pull ssh://review.coreboot.org:29418/coreboot refs/changes/80/22480/1

diff --git a/src/drivers/net/chip.h b/src/drivers/net/chip.h
index 7a37cde..8e8c02b 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 350dc37..7ce2cc7 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,56 @@
 		r8168_set_customized_led(dev, io_base);
 }
 
+#if IS_ENABLED(CONFIG_HAVE_ACPI_TABLES)
+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)
+		return;
+
+	/* Device */
+	acpigen_write_scope(path);
+	acpigen_write_device(acpi_device_name(dev));
+	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 && 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 "8168";
+}
+#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 +327,7 @@
 	.vendor = 0x10ec,
 	.device = 0x8168,
 };
+
+struct chip_operations drivers_net_ops = {
+    CHIP_NAME("Realtek r8168")
+};

-- 
To view, visit https://review.coreboot.org/22480
To unsubscribe, visit https://review.coreboot.org/settings

Gerrit-Project: coreboot
Gerrit-Branch: master
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ibc9115e8a08ba2bfcb3ee1e34c73cf1976a6ba2d
Gerrit-Change-Number: 22480
Gerrit-PatchSet: 1
Gerrit-Owner: Gaggery Tsai <gaggery.tsai at intel.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.coreboot.org/pipermail/coreboot-gerrit/attachments/20171116/6dbf90c9/attachment.html>


More information about the coreboot-gerrit mailing list