Rajat Jain has uploaded this change for review. ( https://review.coreboot.org/c/coreboot/+/39154 )
Change subject: drivers/gfx/generic: Add support for gpio based EPS ......................................................................
drivers/gfx/generic: Add support for gpio based EPS
Add support to control EPS via a PCH gpio
Change-Id: I6f570fd43e1649fb23255b0890e01086e34f844a Signed-off-by: Rajat Jain rajatja@google.com --- M src/drivers/gfx/generic/chip.h M src/drivers/gfx/generic/generic.c 2 files changed, 73 insertions(+), 11 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/54/39154/1
diff --git a/src/drivers/gfx/generic/chip.h b/src/drivers/gfx/generic/chip.h index 5e855e3..ef7d9db 100644 --- a/src/drivers/gfx/generic/chip.h +++ b/src/drivers/gfx/generic/chip.h @@ -28,6 +28,12 @@ const char *enable_function; /* ACPI namespace path to privacy screen disable function */ const char *disable_function; + /* + * GPIO used for controlling the privacy screen. If provided, + * the gpio mechanism takes preference over the functions ptrs + * above, if any (GPIO functions override the function ptrs). + */ + struct acpi_gpio gpio; };
/* Config for an output device as defined in section A.5 of the ACPI spec */ @@ -53,4 +59,6 @@ struct drivers_gfx_generic_device_config device[5]; };
+extern struct device *find_gfx_dev(void); + #endif /* __DRIVERS_GFX_GENERIC_CHIP_H__ */ diff --git a/src/drivers/gfx/generic/generic.c b/src/drivers/gfx/generic/generic.c index 8488040..7b5ddc7 100644 --- a/src/drivers/gfx/generic/generic.c +++ b/src/drivers/gfx/generic/generic.c @@ -24,6 +24,11 @@
#define ACPI_DSM_PRIVACY_SCREEN_UUID "C7033113-8720-4CEB-9090-9D52B3E52D73"
+#define ACPI_METHOD_EPS_PRESENT "EPSP" +#define ACPI_METHOD_EPS_STATE "EPSS" +#define ACPI_METHOD_EPS_ENABLE "EPSE" +#define ACPI_METHOD_EPS_DISABLE "EPSD" + static void privacy_screen_detect_cb(void *arg) { struct drivers_gfx_generic_privacy_screen_config *config = arg; @@ -62,6 +67,52 @@ privacy_screen_disable_cb, };
+static void privacy_gpio_acpigen(struct acpi_gpio *gpio) +{ + /* EPS Present */ + acpigen_write_method(ACPI_METHOD_EPS_PRESENT, 0); + acpigen_write_return_byte(1); + acpigen_pop_len(); + + /* EPS State */ + acpigen_write_method(ACPI_METHOD_EPS_STATE, 0); + acpigen_get_rx_gpio(gpio); + acpigen_emit_byte(RETURN_OP); + acpigen_emit_byte(LOCAL0_OP); + acpigen_pop_len(); + + /* EPS Enable */ + acpigen_write_method(ACPI_METHOD_EPS_ENABLE, 0); + acpigen_enable_tx_gpio(gpio); + acpigen_pop_len(); + + /* EPS Disable */ + acpigen_write_method(ACPI_METHOD_EPS_DISABLE, 0); + acpigen_disable_tx_gpio(gpio); + acpigen_pop_len(); +} + +static void gfx_fill_privacy_screen_dsm(struct + drivers_gfx_generic_privacy_screen_config *privacy) +{ + if (!privacy->enabled) + return; + + /* Populate ACPI methods, if EPS controlled via gpio */ + if (privacy->gpio.pin_count == 1) { + privacy_gpio_acpigen(&privacy->gpio); + privacy->detect_function = ACPI_METHOD_EPS_PRESENT; + privacy->status_function = ACPI_METHOD_EPS_STATE; + privacy->enable_function = ACPI_METHOD_EPS_ENABLE; + privacy->disable_function = ACPI_METHOD_EPS_DISABLE; + } + + acpigen_write_dsm(ACPI_DSM_PRIVACY_SCREEN_UUID, + privacy_screen_callbacks, + ARRAY_SIZE(privacy_screen_callbacks), + privacy); +} + static void gfx_fill_ssdt_generator(struct device *dev) { size_t i; @@ -69,7 +120,7 @@
const char *scope = acpi_device_scope(dev);
- if (!scope) + if (!scope || !dev->enabled) return;
acpigen_write_scope(scope); @@ -85,17 +136,9 @@
for (i = 0; i < config->device_count; i++) { acpigen_write_device(config->device[i].name); - acpigen_write_name_integer("_ADR", config->device[i].addr); acpigen_write_name_integer("_STA", 0xF); - - if (config->device[i].privacy.enabled) { - acpigen_write_dsm(ACPI_DSM_PRIVACY_SCREEN_UUID, - privacy_screen_callbacks, - ARRAY_SIZE(privacy_screen_callbacks), - &config->device[i].privacy); - } - + gfx_fill_privacy_screen_dsm(&config->device[i].privacy); acpigen_pop_len(); /* Device */ } acpigen_pop_len(); /* Scope */ @@ -117,7 +160,7 @@ { struct drivers_gfx_generic_config *config = dev->chip_info;
- if (!config) + if (!config || !dev->enabled) return;
dev->ops = &gfx_ops; @@ -127,3 +170,14 @@ CHIP_NAME("Generic Graphics Device") .enable_dev = gfx_enable }; + +struct device *find_gfx_dev(void) +{ + struct device *dev; + + for (dev = all_devices; dev; dev = dev->next) { + if (dev->chip_ops && dev->chip_ops == &drivers_gfx_generic_ops) + return dev; + } + return NULL; +}
build bot (Jenkins) has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/39154 )
Change subject: drivers/gfx/generic: Add support for gpio based EPS ......................................................................
Patch Set 1:
(2 comments)
https://review.coreboot.org/c/coreboot/+/39154/1/src/drivers/gfx/generic/gen... File src/drivers/gfx/generic/generic.c:
https://review.coreboot.org/c/coreboot/+/39154/1/src/drivers/gfx/generic/gen... PS1, Line 89: /* EPS Disable */ code indent should use tabs where possible
https://review.coreboot.org/c/coreboot/+/39154/1/src/drivers/gfx/generic/gen... PS1, Line 96: drivers_gfx_generic_privacy_screen_config *privacy) need consistent spacing around '*' (ctx:WxV)
Hello Mathew King, Tim Wawrzynczak, Duncan Laurie, Shelley Chen, build bot (Jenkins), Furquan Shaikh,
I'd like you to reexamine a change. Please visit
https://review.coreboot.org/c/coreboot/+/39154
to look at the new patch set (#2).
Change subject: drivers/gfx/generic: Add support for gpio based EPS ......................................................................
drivers/gfx/generic: Add support for gpio based EPS
Add support to control EPS via a PCH gpio
Change-Id: I6f570fd43e1649fb23255b0890e01086e34f844a Signed-off-by: Rajat Jain rajatja@google.com --- M src/drivers/gfx/generic/chip.h M src/drivers/gfx/generic/generic.c 2 files changed, 75 insertions(+), 11 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/54/39154/2
Rajat Jain has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/39154 )
Change subject: drivers/gfx/generic: Add support for gpio based EPS ......................................................................
Patch Set 2:
(2 comments)
https://review.coreboot.org/c/coreboot/+/39154/1/src/drivers/gfx/generic/gen... File src/drivers/gfx/generic/generic.c:
https://review.coreboot.org/c/coreboot/+/39154/1/src/drivers/gfx/generic/gen... PS1, Line 89: /* EPS Disable */
code indent should use tabs where possible
Done
https://review.coreboot.org/c/coreboot/+/39154/1/src/drivers/gfx/generic/gen... PS1, Line 96: drivers_gfx_generic_privacy_screen_config *privacy)
need consistent spacing around '*' (ctx:WxV)
Done
Mathew King has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/39154 )
Change subject: drivers/gfx/generic: Add support for gpio based EPS ......................................................................
Patch Set 2: Code-Review+2
Patrick Georgi has submitted this change. ( https://review.coreboot.org/c/coreboot/+/39154 )
Change subject: drivers/gfx/generic: Add support for gpio based EPS ......................................................................
drivers/gfx/generic: Add support for gpio based EPS
Add support to control EPS via a PCH gpio
Change-Id: I6f570fd43e1649fb23255b0890e01086e34f844a Signed-off-by: Rajat Jain rajatja@google.com Reviewed-on: https://review.coreboot.org/c/coreboot/+/39154 Tested-by: build bot (Jenkins) no-reply@coreboot.org Reviewed-by: Mathew King mathewk@chromium.org --- M src/drivers/gfx/generic/chip.h M src/drivers/gfx/generic/generic.c 2 files changed, 75 insertions(+), 11 deletions(-)
Approvals: build bot (Jenkins): Verified Mathew King: Looks good to me, approved
diff --git a/src/drivers/gfx/generic/chip.h b/src/drivers/gfx/generic/chip.h index 5e855e3..714a8ab 100644 --- a/src/drivers/gfx/generic/chip.h +++ b/src/drivers/gfx/generic/chip.h @@ -16,6 +16,8 @@ #ifndef __DRIVERS_GFX_GENERIC_CHIP_H__ #define __DRIVERS_GFX_GENERIC_CHIP_H__
+#include <arch/acpi_device.h> + /* Config for electronic privacy screen */ struct drivers_gfx_generic_privacy_screen_config { /* Is privacy screen available on this graphics device */ @@ -28,6 +30,12 @@ const char *enable_function; /* ACPI namespace path to privacy screen disable function */ const char *disable_function; + /* + * GPIO used for controlling the privacy screen. If provided, + * the gpio mechanism takes preference over the functions ptrs + * above, if any (GPIO functions override the function ptrs). + */ + struct acpi_gpio gpio; };
/* Config for an output device as defined in section A.5 of the ACPI spec */ @@ -53,4 +61,6 @@ struct drivers_gfx_generic_device_config device[5]; };
+extern struct device *find_gfx_dev(void); + #endif /* __DRIVERS_GFX_GENERIC_CHIP_H__ */ diff --git a/src/drivers/gfx/generic/generic.c b/src/drivers/gfx/generic/generic.c index 8488040..0b3fcca 100644 --- a/src/drivers/gfx/generic/generic.c +++ b/src/drivers/gfx/generic/generic.c @@ -24,6 +24,11 @@
#define ACPI_DSM_PRIVACY_SCREEN_UUID "C7033113-8720-4CEB-9090-9D52B3E52D73"
+#define ACPI_METHOD_EPS_PRESENT "EPSP" +#define ACPI_METHOD_EPS_STATE "EPSS" +#define ACPI_METHOD_EPS_ENABLE "EPSE" +#define ACPI_METHOD_EPS_DISABLE "EPSD" + static void privacy_screen_detect_cb(void *arg) { struct drivers_gfx_generic_privacy_screen_config *config = arg; @@ -62,6 +67,52 @@ privacy_screen_disable_cb, };
+static void privacy_gpio_acpigen(struct acpi_gpio *gpio) +{ + /* EPS Present */ + acpigen_write_method(ACPI_METHOD_EPS_PRESENT, 0); + acpigen_write_return_byte(1); + acpigen_pop_len(); + + /* EPS State */ + acpigen_write_method(ACPI_METHOD_EPS_STATE, 0); + acpigen_get_rx_gpio(gpio); + acpigen_emit_byte(RETURN_OP); + acpigen_emit_byte(LOCAL0_OP); + acpigen_pop_len(); + + /* EPS Enable */ + acpigen_write_method(ACPI_METHOD_EPS_ENABLE, 0); + acpigen_enable_tx_gpio(gpio); + acpigen_pop_len(); + + /* EPS Disable */ + acpigen_write_method(ACPI_METHOD_EPS_DISABLE, 0); + acpigen_disable_tx_gpio(gpio); + acpigen_pop_len(); +} + +static void gfx_fill_privacy_screen_dsm( + struct drivers_gfx_generic_privacy_screen_config *privacy) +{ + if (!privacy->enabled) + return; + + /* Populate ACPI methods, if EPS controlled via gpio */ + if (privacy->gpio.pin_count == 1) { + privacy_gpio_acpigen(&privacy->gpio); + privacy->detect_function = ACPI_METHOD_EPS_PRESENT; + privacy->status_function = ACPI_METHOD_EPS_STATE; + privacy->enable_function = ACPI_METHOD_EPS_ENABLE; + privacy->disable_function = ACPI_METHOD_EPS_DISABLE; + } + + acpigen_write_dsm(ACPI_DSM_PRIVACY_SCREEN_UUID, + privacy_screen_callbacks, + ARRAY_SIZE(privacy_screen_callbacks), + privacy); +} + static void gfx_fill_ssdt_generator(struct device *dev) { size_t i; @@ -69,7 +120,7 @@
const char *scope = acpi_device_scope(dev);
- if (!scope) + if (!scope || !dev->enabled) return;
acpigen_write_scope(scope); @@ -85,17 +136,9 @@
for (i = 0; i < config->device_count; i++) { acpigen_write_device(config->device[i].name); - acpigen_write_name_integer("_ADR", config->device[i].addr); acpigen_write_name_integer("_STA", 0xF); - - if (config->device[i].privacy.enabled) { - acpigen_write_dsm(ACPI_DSM_PRIVACY_SCREEN_UUID, - privacy_screen_callbacks, - ARRAY_SIZE(privacy_screen_callbacks), - &config->device[i].privacy); - } - + gfx_fill_privacy_screen_dsm(&config->device[i].privacy); acpigen_pop_len(); /* Device */ } acpigen_pop_len(); /* Scope */ @@ -117,7 +160,7 @@ { struct drivers_gfx_generic_config *config = dev->chip_info;
- if (!config) + if (!config || !dev->enabled) return;
dev->ops = &gfx_ops; @@ -127,3 +170,14 @@ CHIP_NAME("Generic Graphics Device") .enable_dev = gfx_enable }; + +struct device *find_gfx_dev(void) +{ + struct device *dev; + + for (dev = all_devices; dev; dev = dev->next) { + if (dev->chip_ops && dev->chip_ops == &drivers_gfx_generic_ops) + return dev; + } + return NULL; +}