summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/drivers/usb/acpi/Kconfig4
-rw-r--r--src/drivers/usb/acpi/Makefile.inc1
-rw-r--r--src/drivers/usb/acpi/chip.h54
-rw-r--r--src/drivers/usb/acpi/usb_acpi.c75
4 files changed, 134 insertions, 0 deletions
diff --git a/src/drivers/usb/acpi/Kconfig b/src/drivers/usb/acpi/Kconfig
new file mode 100644
index 0000000000..290e11055c
--- /dev/null
+++ b/src/drivers/usb/acpi/Kconfig
@@ -0,0 +1,4 @@
+config DRIVERS_USB_ACPI
+ bool
+ default n
+ depends on HAVE_ACPI_TABLES
diff --git a/src/drivers/usb/acpi/Makefile.inc b/src/drivers/usb/acpi/Makefile.inc
new file mode 100644
index 0000000000..2e111078ad
--- /dev/null
+++ b/src/drivers/usb/acpi/Makefile.inc
@@ -0,0 +1 @@
+ramstage-$(CONFIG_DRIVERS_USB_ACPI) += usb_acpi.c
diff --git a/src/drivers/usb/acpi/chip.h b/src/drivers/usb/acpi/chip.h
new file mode 100644
index 0000000000..f3f629abff
--- /dev/null
+++ b/src/drivers/usb/acpi/chip.h
@@ -0,0 +1,54 @@
+/*
+ * This file is part of the coreboot project.
+ *
+ * Copyright 2018 Google LLC
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ */
+
+#ifndef __USB_ACPI_CHIP_H__
+#define __USB_ACPI_CHIP_H__
+
+#include <arch/acpi.h>
+#include <arch/acpi_pld.h>
+
+struct drivers_usb_acpi_config {
+ const char *desc;
+
+ /*
+ * Physical ports that are user visible
+ *
+ * UPC_TYPE_A
+ * UPC_TYPE_MINI_AB
+ * UPC_TYPE_EXPRESSCARD
+ * UPC_TYPE_USB3_A
+ * UPC_TYPE_USB3_B
+ * UPC_TYPE_USB3_MICRO_B
+ * UPC_TYPE_USB3_MICRO_AB
+ * UPC_TYPE_USB3_POWER_B
+ * UPC_TYPE_C_USB2_ONLY
+ * UPC_TYPE_C_USB2_SS_SWITCH
+ * UPC_TYPE_C_USB2_SS
+ *
+ * Non-visible ports or special devices
+ *
+ * UPC_TYPE_PROPRIETARY
+ * UPC_TYPE_INTERNAL
+ * UPC_TYPE_UNUSED
+ * UPC_TYPE_HUB
+ */
+ enum acpi_upc_type type;
+
+ /* Define a custom physical location for the port */
+ bool use_custom_pld;
+ struct acpi_pld custom_pld;
+};
+
+#endif /* __USB_ACPI_CHIP_H__ */
diff --git a/src/drivers/usb/acpi/usb_acpi.c b/src/drivers/usb/acpi/usb_acpi.c
new file mode 100644
index 0000000000..65f1f82acd
--- /dev/null
+++ b/src/drivers/usb/acpi/usb_acpi.c
@@ -0,0 +1,75 @@
+/*
+ * This file is part of the coreboot project.
+ *
+ * Copyright 2018 Google LLC
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ */
+
+#include <arch/acpi_device.h>
+#include <arch/acpi_pld.h>
+#include <arch/acpigen.h>
+#include <console/console.h>
+#include <device/device.h>
+#include <device/path.h>
+#include <stdint.h>
+#include <string.h>
+#include "chip.h"
+
+static void usb_acpi_fill_ssdt_generator(struct device *dev)
+{
+ struct drivers_usb_acpi_config *config = dev->chip_info;
+ const char *path = acpi_device_path(dev);
+
+ if (!dev->enabled || !path || !config)
+ return;
+
+ /* Don't generate output for hubs, only ports */
+ if (config->type == UPC_TYPE_HUB)
+ return;
+
+ acpigen_write_scope(path);
+ if (config->desc)
+ acpigen_write_name_string("_DDN", config->desc);
+ acpigen_write_upc(config->type);
+
+ if (config->use_custom_pld) {
+ /* Use board defined PLD */
+ acpigen_write_pld(&config->custom_pld);
+ } else {
+ /* Fill PLD strucutre based on port type */
+ struct acpi_pld pld;
+ acpi_pld_fill_usb(&pld, config->type);
+ acpigen_write_pld(&pld);
+ }
+
+ acpigen_pop_len();
+
+ printk(BIOS_INFO, "%s: %s at %s\n", path,
+ config->desc ? : dev->chip_ops->name, dev_path(dev));
+}
+
+static struct device_operations usb_acpi_ops = {
+ .read_resources = DEVICE_NOOP,
+ .set_resources = DEVICE_NOOP,
+ .enable_resources = DEVICE_NOOP,
+ .scan_bus = &scan_usb_bus,
+ .acpi_fill_ssdt_generator = &usb_acpi_fill_ssdt_generator,
+};
+
+static void usb_acpi_enable(struct device *dev)
+{
+ dev->ops = &usb_acpi_ops;
+}
+
+struct chip_operations drivers_usb_acpi_ops = {
+ CHIP_NAME("USB ACPI Device")
+ .enable_dev = &usb_acpi_enable
+};