Patrick Georgi submitted this change.

View Change

Approvals: build bot (Jenkins): Verified Furquan Shaikh: Looks good to me, approved
drivers/usb/acpi: Add support for privacy_gpio

Some devices, such as cameras, can implement a physical switch to
disable the input on demand. Think of it like the typical privacy
sticker on the notebooks, but more elegant.

In order to notify the system about the status this feature, a GPIO is
typically used.

The map between a GPIO and the feature is done via ACPI, the same way as
the reset_gpio works.

This patch implements an extra field for the described privacy gpio.
This gpio does not require any extra handling from the power management.

BUG=b:169840271

Change-Id: Idcc65c9a13eca6f076ac3c68aaa1bed3c481df3d
Signed-off-by: Ricardo Ribalda <ribalda@chromium.org>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/46961
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Furquan Shaikh <furquan@google.com>
---
M src/drivers/usb/acpi/chip.h
M src/drivers/usb/acpi/usb_acpi.c
2 files changed, 44 insertions(+), 10 deletions(-)

diff --git a/src/drivers/usb/acpi/chip.h b/src/drivers/usb/acpi/chip.h
index 8afdf6f..73c69cc 100644
--- a/src/drivers/usb/acpi/chip.h
+++ b/src/drivers/usb/acpi/chip.h
@@ -59,6 +59,13 @@
unsigned int enable_delay_ms;
/* Delay to be inserted after device is disabled. */
unsigned int enable_off_delay_ms;
+
+ /*
+ * Define a GPIO that shows the privacy status of the USB device.
+ * E.g. On a camera: if it is one, it is recording black frames.
+ * E.g. On a mic: if it is one, it is recording white-noise.
+ */
+ struct acpi_gpio privacy_gpio;
};

#endif /* __USB_ACPI_CHIP_H__ */
diff --git a/src/drivers/usb/acpi/usb_acpi.c b/src/drivers/usb/acpi/usb_acpi.c
index 8a597e3..9d68d0a 100644
--- a/src/drivers/usb/acpi/usb_acpi.c
+++ b/src/drivers/usb/acpi/usb_acpi.c
@@ -10,14 +10,27 @@

static bool usb_acpi_add_gpios_to_crs(struct drivers_usb_acpi_config *cfg)
{
- /*
- * Return false if reset GPIO is not provided or is provided as part of power
- * resource.
- */
- if (cfg->has_power_resource || cfg->reset_gpio.pin_count == 0)
- return false;
+ if (cfg->privacy_gpio.pin_count)
+ return true;

- return true;
+ if (cfg->reset_gpio.pin_count && !cfg->has_power_resource)
+ return true;
+
+ return false;
+}
+
+static int usb_acpi_write_gpio(struct acpi_gpio *gpio, int *curr_index)
+{
+ int ret = -1;
+
+ if (gpio->pin_count == 0)
+ return ret;
+
+ acpi_device_write_gpio(gpio);
+ ret = *curr_index;
+ (*curr_index)++;
+
+ return ret;
}

static void usb_acpi_fill_ssdt_generator(const struct device *dev)
@@ -50,15 +63,29 @@
/* Resources */
if (usb_acpi_add_gpios_to_crs(config) == true) {
struct acpi_dp *dsd;
+ int idx = 0;
+ int reset_gpio_index = -1;
+ int privacy_gpio_index;

acpigen_write_name("_CRS");
acpigen_write_resourcetemplate_header();
- acpi_device_write_gpio(&config->reset_gpio);
+ if (!config->has_power_resource) {
+ reset_gpio_index = usb_acpi_write_gpio(
+ &config->reset_gpio, &idx);
+ }
+ privacy_gpio_index = usb_acpi_write_gpio(&config->privacy_gpio,
+ &idx);
acpigen_write_resourcetemplate_footer();

dsd = acpi_dp_new_table("_DSD");
- acpi_dp_add_gpio(dsd, "reset-gpio", path, 0, 0,
- config->reset_gpio.active_low);
+ if (reset_gpio_index >= 0)
+ acpi_dp_add_gpio(dsd, "reset-gpio", path,
+ reset_gpio_index, 0,
+ config->reset_gpio.active_low);
+ if (privacy_gpio_index >= 0)
+ acpi_dp_add_gpio(dsd, "privacy-gpio", path,
+ privacy_gpio_index, 0,
+ config->privacy_gpio.active_low);
acpi_dp_write(dsd);
}


To view, visit change 46961. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-Project: coreboot
Gerrit-Branch: master
Gerrit-Change-Id: Idcc65c9a13eca6f076ac3c68aaa1bed3c481df3d
Gerrit-Change-Number: 46961
Gerrit-PatchSet: 7
Gerrit-Owner: Ricardo Ribalda <ribalda@chromium.org>
Gerrit-Reviewer: Angel Pons <th3fanbus@gmail.com>
Gerrit-Reviewer: Furquan Shaikh <furquan@google.com>
Gerrit-Reviewer: Patrick Georgi <pgeorgi@google.com>
Gerrit-Reviewer: build bot (Jenkins) <no-reply@coreboot.org>
Gerrit-CC: Paul Menzel <paulepanter@users.sourceforge.net>
Gerrit-CC: Tim Wawrzynczak <twawrzynczak@chromium.org>
Gerrit-MessageType: merged