Ricardo Ribalda has uploaded this change for review. ( https://review.coreboot.org/c/coreboot/+/46961 )
Change subject: acpi: Add support for privacy_gpio ......................................................................
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.
Change-Id: Idcc65c9a13eca6f076ac3c68aaa1bed3c481df3d Signed-off-by: Ricardo Ribalda ribalda@chromium.org --- M src/drivers/usb/acpi/chip.h M src/drivers/usb/acpi/usb_acpi.c 2 files changed, 18 insertions(+), 6 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/61/46961/1
diff --git a/src/drivers/usb/acpi/chip.h b/src/drivers/usb/acpi/chip.h index 8cd9268..4a55cc6 100644 --- a/src/drivers/usb/acpi/chip.h +++ b/src/drivers/usb/acpi/chip.h @@ -45,6 +45,7 @@ struct acpi_pld custom_pld;
struct acpi_gpio reset_gpio; + 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 d33b7de..9b45483 100644 --- a/src/drivers/usb/acpi/usb_acpi.c +++ b/src/drivers/usb/acpi/usb_acpi.c @@ -13,10 +13,13 @@ /* * Return false if reset GPIO is not provided. */ - if (cfg->reset_gpio.pin_count == 0) - return false; + if (cfg->reset_gpio.pin_count) + return true;
- return true; + if (cfg->privacy_gpio.pin_count) + return true; + + return false; }
static void usb_acpi_fill_ssdt_generator(const struct device *dev) @@ -49,15 +52,23 @@ /* Resources */ if (usb_acpi_add_gpios_to_crs(config) == true) { struct acpi_dp *dsd; + int idx = 0;
acpigen_write_name("_CRS"); acpigen_write_resourcetemplate_header(); - acpi_device_write_gpio(&config->reset_gpio); + if (config->reset_gpio.pin_count) + acpi_device_write_gpio(&config->reset_gpio); + if (config->privacy_gpio.pin_count) + acpi_device_write_gpio(&config->privacy_gpio); 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 (config->reset_gpio.pin_count) + acpi_dp_add_gpio(dsd, "reset-gpio", path, idx++, 0, + config->reset_gpio.active_low); + if (config->privacy_gpio.pin_count) + acpi_dp_add_gpio(dsd, "privacy-gpio", path, idx++, 0, + config->privacy_gpio.active_low); acpi_dp_write(dsd); }
Angel Pons has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/46961 )
Change subject: acpi: Add support for privacy_gpio ......................................................................
Patch Set 1: Code-Review+1
Tim Wawrzynczak has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/46961 )
Change subject: acpi: Add support for privacy_gpio ......................................................................
Patch Set 1:
(1 comment)
https://review.coreboot.org/c/coreboot/+/46961/1//COMMIT_MSG Commit Message:
https://review.coreboot.org/c/coreboot/+/46961/1//COMMIT_MSG@7 PS1, Line 7: acpi drivers/usb/acpi
Hello build bot (Jenkins), Furquan Shaikh, Angel Pons,
I'd like you to reexamine a change. Please visit
https://review.coreboot.org/c/coreboot/+/46961
to look at the new patch set (#2).
Change subject: drivers/usb/acpi: Add support for privacy_gpio ......................................................................
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.
Change-Id: Idcc65c9a13eca6f076ac3c68aaa1bed3c481df3d Signed-off-by: Ricardo Ribalda ribalda@chromium.org --- M src/drivers/usb/acpi/chip.h M src/drivers/usb/acpi/usb_acpi.c 2 files changed, 18 insertions(+), 6 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/61/46961/2
Ricardo Ribalda has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/46961 )
Change subject: drivers/usb/acpi: Add support for privacy_gpio ......................................................................
Patch Set 2:
(1 comment)
https://review.coreboot.org/c/coreboot/+/46961/1//COMMIT_MSG Commit Message:
https://review.coreboot.org/c/coreboot/+/46961/1//COMMIT_MSG@7 PS1, Line 7: acpi
drivers/usb/acpi
Ack
Tim Wawrzynczak has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/46961 )
Change subject: drivers/usb/acpi: Add support for privacy_gpio ......................................................................
Patch Set 2:
(1 comment)
https://review.coreboot.org/c/coreboot/+/46961/2//COMMIT_MSG Commit Message:
https://review.coreboot.org/c/coreboot/+/46961/2//COMMIT_MSG@13 PS2, Line 13: 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. Would you mind pointing me to the patches that implement this on the kernel side?
Ricardo Ribalda has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/46961 )
Change subject: drivers/usb/acpi: Add support for privacy_gpio ......................................................................
Patch Set 2:
(1 comment)
https://review.coreboot.org/c/coreboot/+/46961/2//COMMIT_MSG Commit Message:
https://review.coreboot.org/c/coreboot/+/46961/2//COMMIT_MSG@13 PS2, Line 13: 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.
Would you mind pointing me to the patches that implement this on the kernel side?
For the privacy_pin, this is the series: https://patchwork.linuxtv.org/project/linux-media/list/?series=3787
for the reset_gpio https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/driv... https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Docu...
Furquan Shaikh has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/46961 )
Change subject: drivers/usb/acpi: Add support for privacy_gpio ......................................................................
Patch Set 2:
(4 comments)
https://review.coreboot.org/c/coreboot/+/46961/2/src/drivers/usb/acpi/chip.h File src/drivers/usb/acpi/chip.h:
https://review.coreboot.org/c/coreboot/+/46961/2/src/drivers/usb/acpi/chip.h... PS2, Line 48: privacy If we decide to go with this name, I think we should have a comment block explaining what this is used for and what kind of devices would use it.
https://review.coreboot.org/c/coreboot/+/46961/2/src/drivers/usb/acpi/usb_ac... File src/drivers/usb/acpi/usb_acpi.c:
https://review.coreboot.org/c/coreboot/+/46961/2/src/drivers/usb/acpi/usb_ac... PS2, Line 13: /* : * Return false if reset GPIO is not provided. : */ Comment needs update. Or we can probably drop it since it isn't really very helpful.
https://review.coreboot.org/c/coreboot/+/46961/2/src/drivers/usb/acpi/usb_ac... PS2, Line 60: I think it would be safer to set reset_index and privacy_index here instead of expecting the same order of _CRS and _DSD writes for the GPIOs.
reset_index = acpi_device_write_gpio(&config->reset_gpio, &index); privacy_index = acpi_device_write_gpio(&config->privacy_gpio, &index);
acpi_device_write_gpio() can return -1 if gpio.pin_count is 0. Else the index used for the GPIO and increment current index.
https://review.coreboot.org/c/coreboot/+/46961/2/src/drivers/usb/acpi/usb_ac... PS2, Line 70: privacy Do we have the liberty to choose the gpio name string that the driver uses? I would prefer using "irq-gpio" if possible because it aligns well with how the other drivers are written and the GPIOs they expose.
Hello build bot (Jenkins), Furquan Shaikh, Angel Pons,
I'd like you to reexamine a change. Please visit
https://review.coreboot.org/c/coreboot/+/46961
to look at the new patch set (#3).
Change subject: drivers/usb/acpi: Add support for privacy_gpio ......................................................................
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.
Change-Id: Idcc65c9a13eca6f076ac3c68aaa1bed3c481df3d Signed-off-by: Ricardo Ribalda ribalda@chromium.org --- M src/drivers/usb/acpi/chip.h M src/drivers/usb/acpi/usb_acpi.c 2 files changed, 42 insertions(+), 9 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/61/46961/3
Ricardo Ribalda has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/46961 )
Change subject: drivers/usb/acpi: Add support for privacy_gpio ......................................................................
Patch Set 3:
(4 comments)
https://review.coreboot.org/c/coreboot/+/46961/2/src/drivers/usb/acpi/chip.h File src/drivers/usb/acpi/chip.h:
https://review.coreboot.org/c/coreboot/+/46961/2/src/drivers/usb/acpi/chip.h... PS2, Line 48: privacy
If we decide to go with this name, I think we should have a comment block explaining what this is us […]
Done
https://review.coreboot.org/c/coreboot/+/46961/2/src/drivers/usb/acpi/usb_ac... File src/drivers/usb/acpi/usb_acpi.c:
https://review.coreboot.org/c/coreboot/+/46961/2/src/drivers/usb/acpi/usb_ac... PS2, Line 13: /* : * Return false if reset GPIO is not provided. : */
Comment needs update. Or we can probably drop it since it isn't really very helpful.
Done
https://review.coreboot.org/c/coreboot/+/46961/2/src/drivers/usb/acpi/usb_ac... PS2, Line 60:
I think it would be safer to set reset_index and privacy_index here instead of expecting the same or […]
Done
https://review.coreboot.org/c/coreboot/+/46961/2/src/drivers/usb/acpi/usb_ac... PS2, Line 70: privacy
Do we have the liberty to choose the gpio name string that the driver uses? I would prefer using "ir […]
I think I prefer the privacy-gpio name. It shows the function of the pin and also allows device to have privacy and irq pins.
Furquan Shaikh has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/46961 )
Change subject: drivers/usb/acpi: Add support for privacy_gpio ......................................................................
Patch Set 3: Code-Review+1
(2 comments)
LGTM. We just need to co-ordinate with CB:46713 to ensure the changes don't conflict.
https://review.coreboot.org/c/coreboot/+/46961/3/src/drivers/usb/acpi/chip.h File src/drivers/usb/acpi/chip.h:
https://review.coreboot.org/c/coreboot/+/46961/3/src/drivers/usb/acpi/chip.h... PS3, Line 51: recodring nit: recording
https://review.coreboot.org/c/coreboot/+/46961/3/src/drivers/usb/acpi/usb_ac... File src/drivers/usb/acpi/usb_acpi.c:
https://review.coreboot.org/c/coreboot/+/46961/3/src/drivers/usb/acpi/usb_ac... PS3, Line 11: usb_acpi_add_gpios_to_crs Looks like there is another change that is touching the same file/function - CB:46713.
We will have to rebase on top of it.
Ricardo Ribalda has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/46961 )
Change subject: drivers/usb/acpi: Add support for privacy_gpio ......................................................................
Patch Set 3:
(2 comments)
https://review.coreboot.org/c/coreboot/+/46961/3/src/drivers/usb/acpi/chip.h File src/drivers/usb/acpi/chip.h:
https://review.coreboot.org/c/coreboot/+/46961/3/src/drivers/usb/acpi/chip.h... PS3, Line 51: recodring
nit: recording
Done
https://review.coreboot.org/c/coreboot/+/46961/3/src/drivers/usb/acpi/usb_ac... File src/drivers/usb/acpi/usb_acpi.c:
https://review.coreboot.org/c/coreboot/+/46961/3/src/drivers/usb/acpi/usb_ac... PS3, Line 11: usb_acpi_add_gpios_to_crs
Looks like there is another change that is touching the same file/function - CB:46713. […]
Done
Hello build bot (Jenkins), Furquan Shaikh, Angel Pons,
I'd like you to reexamine a change. Please visit
https://review.coreboot.org/c/coreboot/+/46961
to look at the new patch set (#4).
Change subject: drivers/usb/acpi: Add support for privacy_gpio ......................................................................
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.
Change-Id: Idcc65c9a13eca6f076ac3c68aaa1bed3c481df3d Signed-off-by: Ricardo Ribalda ribalda@chromium.org --- M src/drivers/usb/acpi/chip.h M src/drivers/usb/acpi/usb_acpi.c 2 files changed, 44 insertions(+), 10 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/61/46961/4
build bot (Jenkins) has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/46961 )
Change subject: drivers/usb/acpi: Add support for privacy_gpio ......................................................................
Patch Set 4:
(1 comment)
https://review.coreboot.org/c/coreboot/+/46961/4/src/drivers/usb/acpi/usb_ac... File src/drivers/usb/acpi/usb_acpi.c:
https://review.coreboot.org/c/coreboot/+/46961/4/src/drivers/usb/acpi/usb_ac... PS4, Line 16: if (cfg->reset_gpio.pin_count && !cfg->has_power_resource ) space prohibited before that close parenthesis ')'
Hello build bot (Jenkins), Furquan Shaikh, Angel Pons,
I'd like you to reexamine a change. Please visit
https://review.coreboot.org/c/coreboot/+/46961
to look at the new patch set (#5).
Change subject: drivers/usb/acpi: Add support for privacy_gpio ......................................................................
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.
Change-Id: Idcc65c9a13eca6f076ac3c68aaa1bed3c481df3d Signed-off-by: Ricardo Ribalda ribalda@chromium.org --- M src/drivers/usb/acpi/chip.h M src/drivers/usb/acpi/usb_acpi.c 2 files changed, 44 insertions(+), 10 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/61/46961/5
Tim Wawrzynczak has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/46961 )
Change subject: drivers/usb/acpi: Add support for privacy_gpio ......................................................................
Patch Set 5:
(1 comment)
https://review.coreboot.org/c/coreboot/+/46961/5/src/drivers/usb/acpi/usb_ac... File src/drivers/usb/acpi/usb_acpi.c:
https://review.coreboot.org/c/coreboot/+/46961/5/src/drivers/usb/acpi/usb_ac... PS5, Line 22: int *curr_index The caller doesn't seem to use the 'idx' parameter anywhere else, could it just be a static variable in this function?
Furquan Shaikh has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/46961 )
Change subject: drivers/usb/acpi: Add support for privacy_gpio ......................................................................
Patch Set 5: Code-Review+1
(3 comments)
https://review.coreboot.org/c/coreboot/+/46961/5/src/drivers/usb/acpi/usb_ac... File src/drivers/usb/acpi/usb_acpi.c:
https://review.coreboot.org/c/coreboot/+/46961/5/src/drivers/usb/acpi/usb_ac... PS5, Line 22: int *curr_index
The caller doesn't seem to use the 'idx' parameter anywhere else, could it just be a static variable […]
No, because the chip driver can be used by multiple devices. And we want to ensure that the index count starts from 0 for each device.
https://review.coreboot.org/c/coreboot/+/46961/5/src/drivers/usb/acpi/usb_ac... PS5, Line 67: 1 -1? Since that is used to skip adding the gpio to DSD.
https://review.coreboot.org/c/coreboot/+/46961/5/src/drivers/usb/acpi/usb_ac... PS5, Line 68: = 1 nit: not required since it is set before using.
Furquan Shaikh has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/46961 )
Change subject: drivers/usb/acpi: Add support for privacy_gpio ......................................................................
Patch Set 5:
(1 comment)
https://review.coreboot.org/c/coreboot/+/46961/5//COMMIT_MSG Commit Message:
https://review.coreboot.org/c/coreboot/+/46961/5//COMMIT_MSG@21 PS5, Line 21: You probably want to add BUG=b:<>
to ensure that the bug gets updated when the CL is cherry-picked to chromium tree.
Tim Wawrzynczak has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/46961 )
Change subject: drivers/usb/acpi: Add support for privacy_gpio ......................................................................
Patch Set 5:
(1 comment)
https://review.coreboot.org/c/coreboot/+/46961/5/src/drivers/usb/acpi/usb_ac... File src/drivers/usb/acpi/usb_acpi.c:
https://review.coreboot.org/c/coreboot/+/46961/5/src/drivers/usb/acpi/usb_ac... PS5, Line 22: int *curr_index
No, because the chip driver can be used by multiple devices. […]
True, this is just ugly... I guess you could use a file-level static and reset it on calls to fill_ssdt, but that isn't much better
Furquan Shaikh has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/46961 )
Change subject: drivers/usb/acpi: Add support for privacy_gpio ......................................................................
Patch Set 5:
(1 comment)
https://review.coreboot.org/c/coreboot/+/46961/5/src/drivers/usb/acpi/usb_ac... File src/drivers/usb/acpi/usb_acpi.c:
https://review.coreboot.org/c/coreboot/+/46961/5/src/drivers/usb/acpi/usb_ac... PS5, Line 22: int *curr_index
True, this is just ugly... […]
Yeah. I think we need a way to tie the adding of gpios to _CRS such that it can be used to add GPIOs to _DSD later. Anyways, out of scope for this change, but something we should think about for making SSDT generation easier.
Ricardo Ribalda has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/46961 )
Change subject: drivers/usb/acpi: Add support for privacy_gpio ......................................................................
Patch Set 5:
(2 comments)
https://review.coreboot.org/c/coreboot/+/46961/5/src/drivers/usb/acpi/usb_ac... File src/drivers/usb/acpi/usb_acpi.c:
https://review.coreboot.org/c/coreboot/+/46961/5/src/drivers/usb/acpi/usb_ac... PS5, Line 67: 1
-1? Since that is used to skip adding the gpio to DSD.
Done
https://review.coreboot.org/c/coreboot/+/46961/5/src/drivers/usb/acpi/usb_ac... PS5, Line 68: = 1
nit: not required since it is set before using.
Done
Ricardo Ribalda has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/46961 )
Change subject: drivers/usb/acpi: Add support for privacy_gpio ......................................................................
Patch Set 5:
(1 comment)
https://review.coreboot.org/c/coreboot/+/46961/5//COMMIT_MSG Commit Message:
https://review.coreboot.org/c/coreboot/+/46961/5//COMMIT_MSG@21 PS5, Line 21:
You probably want to add […]
Done
Hello build bot (Jenkins), Furquan Shaikh, Angel Pons,
I'd like you to reexamine a change. Please visit
https://review.coreboot.org/c/coreboot/+/46961
to look at the new patch set (#6).
Change subject: drivers/usb/acpi: Add support for privacy_gpio ......................................................................
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 --- M src/drivers/usb/acpi/chip.h M src/drivers/usb/acpi/usb_acpi.c 2 files changed, 44 insertions(+), 10 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/61/46961/6
Furquan Shaikh has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/46961 )
Change subject: drivers/usb/acpi: Add support for privacy_gpio ......................................................................
Patch Set 6: Code-Review+2
Patrick Georgi has submitted this change. ( https://review.coreboot.org/c/coreboot/+/46961 )
Change subject: drivers/usb/acpi: Add support for privacy_gpio ......................................................................
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(-)
Approvals: build bot (Jenkins): Verified Furquan Shaikh: Looks good to me, approved
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); }