drivers/intel/wifi: Add support for generating SSDT table

Intel WiFi devices that support wake-on-wifi need to declare a Power
Resource for this wake pin.  Typically this has been done with a
static declaration in the DSDT for each mainboard.  By adding it to
the existing intel/wifi driver it can be done based on a
configuration register in the devicetree.

Additionally the WiFi regulatory domain can be set in the SSDT
directly instead of needing to use NVS to pass the value to the DSDT.

Also add device IDs for Wilkins Peak 2 and Stone Peak 2 devices that
are found on Chromebooks, and clean up a long line and some comment
formatting.

This was tested by booting on an HP Chromebook 13 device and comparing
that the output in the SSDT matches what used to be in the DSDT.  The
WRDD value is read from VPD, if present, not from devicetree.cb.

Additionally the case where CONFIG_DRIVERS_INTEL_WIFI is enabled but
the wifi device is not described in devicetree.cb is tested to ensure
it still generates the AML but does not include the _PRW wake pin.

Example:

devicetree.cb:
  device pci 1c.0 on
    chip drivers/intel/wifi
      register "wake" = "GPE0_DW0_16"
      device pci 00.0 on end
    end
  end

VPD:
  "region"="us"

SSDT.dsl:
  Scope (\_SB.PCI0.RP01) {
    Device (WIFI) {
      Name (_UID, Zero)
      Name (_DDN, "Intel WiFi")
      Name (_ADR, 0x00000000)
      Name (_PRW, Package () { 16, 3 })
      Name (WRDD, Package () {
        Zero,
        Package () {
          0x00000007,
          0x00004150
        }
      })
    }
  }

Change-Id: I8b5c916f1a04742507dc1ecc9a20c19d3822b18c
Signed-off-by: Duncan Laurie <dlaurie@chromium.org>
Reviewed-on: https://review.coreboot.org/15019
Tested-by: build bot (Jenkins)
Reviewed-by: Aaron Durbin <adurbin@chromium.org>
This commit is contained in:
Duncan Laurie 2016-05-11 14:05:07 -07:00
parent 9fed935f5a
commit 5c026445f0
2 changed files with 96 additions and 13 deletions

View File

@ -0,0 +1,3 @@
struct drivers_intel_wifi_config {
unsigned wake; /* Wake pin for ACPI _PRW */
};

View File

@ -14,12 +14,16 @@
* GNU General Public License for more details. * GNU General Public License for more details.
*/ */
#include <arch/acpi_device.h>
#include <arch/acpigen.h>
#include <console/console.h> #include <console/console.h>
#include <device/device.h> #include <device/device.h>
#include <device/pci.h> #include <device/pci.h>
#include <device/pci_ids.h> #include <device/pci_ids.h>
#include <smbios.h> #include <smbios.h>
#include <string.h> #include <string.h>
#include <wrdd.h>
#include "chip.h"
static int smbios_write_wifi(struct device *dev, int *handle, static int smbios_write_wifi(struct device *dev, int *handle,
unsigned long *current) unsigned long *current)
@ -32,15 +36,17 @@ static int smbios_write_wifi(struct device *dev, int *handle,
char eos[2]; char eos[2];
} __attribute__((packed)); } __attribute__((packed));
struct smbios_type_intel_wifi *t = (struct smbios_type_intel_wifi *)*current; struct smbios_type_intel_wifi *t =
(struct smbios_type_intel_wifi *)*current;
int len = sizeof(struct smbios_type_intel_wifi); int len = sizeof(struct smbios_type_intel_wifi);
memset(t, 0, sizeof(struct smbios_type_intel_wifi)); memset(t, 0, sizeof(struct smbios_type_intel_wifi));
t->type = 0x85; t->type = 0x85;
t->length = len - 2; t->length = len - 2;
t->handle = *handle; t->handle = *handle;
/* Intel wifi driver expects this string to be in the table 0x85 /*
with PCI IDs enumerated below. * Intel wifi driver expects this string to be in the table 0x85
* with PCI IDs enumerated below.
*/ */
t->str = smbios_add_string(t->eos, "KHOIHGIUCCHHII"); t->str = smbios_add_string(t->eos, "KHOIHGIUCCHHII");
@ -50,30 +56,104 @@ static int smbios_write_wifi(struct device *dev, int *handle,
return len; return len;
} }
#if IS_ENABLED(CONFIG_HAVE_ACPI_TABLES)
static void intel_wifi_fill_ssdt(struct device *dev)
{
struct drivers_intel_wifi_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);
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);
/* Fill regulatory domain structure */
if (IS_ENABLED(CONFIG_HAVE_REGULATORY_DOMAIN)) {
/*
* Name ("WRDD", Package () {
* WRDD_REVISION, // Revision
* Package () {
* WRDD_DOMAIN_TYPE_WIFI, // Domain Type, 7:WiFi
* wifi_regulatory_domain() // Country Identifier
* }
* })
*/
acpigen_write_name("WRDD");
acpigen_write_package(2);
acpigen_write_integer(WRDD_REVISION);
acpigen_write_package(2);
acpigen_write_dword(WRDD_DOMAIN_TYPE_WIFI);
acpigen_write_dword(wifi_regulatory_domain());
acpigen_pop_len();
acpigen_pop_len();
}
acpigen_pop_len(); /* Device */
acpigen_pop_len(); /* Scope */
printk(BIOS_INFO, "%s.%s: %s %s\n", path, acpi_device_name(dev),
dev->chip_ops->name, dev_path(dev));
}
static const char *intel_wifi_acpi_name(struct device *dev)
{
return "WIFI";
}
#endif
static struct pci_operations pci_ops = { static struct pci_operations pci_ops = {
.set_subsystem = pci_dev_set_subsystem, .set_subsystem = pci_dev_set_subsystem,
}; };
struct device_operations device_ops = { struct device_operations device_ops = {
.read_resources = pci_dev_read_resources, .read_resources = pci_dev_read_resources,
.set_resources = pci_dev_set_resources, .set_resources = pci_dev_set_resources,
.enable_resources = pci_dev_enable_resources, .enable_resources = pci_dev_enable_resources,
.init = pci_dev_init, .init = pci_dev_init,
.scan_bus = 0, .get_smbios_data = smbios_write_wifi,
.enable = 0, .ops_pci = &pci_ops,
.get_smbios_data = smbios_write_wifi, #if IS_ENABLED(CONFIG_HAVE_ACPI_TABLES)
.ops_pci = &pci_ops, .acpi_name = &intel_wifi_acpi_name,
.acpi_fill_ssdt_generator = &intel_wifi_fill_ssdt,
#endif
}; };
static const unsigned short pci_device_ids[] = { static const unsigned short pci_device_ids[] = {
0x0084, 0x0085, 0x0089, 0x008b, 0x008e, 0x0090, 0x0084, 0x0085, 0x0089, 0x008b, 0x008e, 0x0090,
0x0886, 0x0888, 0x0891, 0x0893, 0x0895, 0x088f, 0x0886, 0x0888, 0x0891, 0x0893, 0x0895, 0x088f,
0x4236, 0x4237, 0x4238, 0x4239, 0x423b, 0x423d, 0x4236, 0x4237, 0x4238, 0x4239, 0x423b, 0x423d,
0 }; 0x08b1, 0x08b2, /* Wilkins Peak 2 */
0x095a, 0x095b, /* Stone Peak 2 */
0
};
static const struct pci_driver pch_intel_wifi __pci_driver = { static const struct pci_driver pch_intel_wifi __pci_driver = {
.ops = &device_ops, .ops = &device_ops,
.vendor = PCI_VENDOR_ID_INTEL, .vendor = PCI_VENDOR_ID_INTEL,
.devices = pci_device_ids, .devices = pci_device_ids,
}; };
static void intel_wifi_enable(struct device *dev)
{
dev->ops = &device_ops;
}
struct chip_operations drivers_intel_wifi_ops = {
CHIP_NAME("Intel WiFi")
.enable_dev = &intel_wifi_enable
};