From a0b0d42d691f163b0a5a8268da1087c9c5f28eaa Mon Sep 17 00:00:00 2001 From: Furquan Shaikh Date: Fri, 21 Feb 2020 09:57:54 -0800 Subject: gfx: Move drivers/generic/gfx to drivers/gfx/generic This change creates gfx directory under drivers/ so that all drivers handling gfx devices can be located in the same place. In follow-up CLs, we will be adding another driver that handles gfx devices. This change also updates the names used within the driver from *generic_gfx* to *gfx_generic*. In addition to that, mainboard drallion using this driver is updated to match the correct path and Kconfig name. TEST=Verified that drallion still builds. Change-Id: I377743e0f6d770eed143c7b6041dab2a101e6252 Signed-off-by: Furquan Shaikh Reviewed-on: https://review.coreboot.org/c/coreboot/+/39047 Tested-by: build bot (Jenkins) Reviewed-by: Tim Wawrzynczak Reviewed-by: Mathew King --- src/drivers/generic/gfx/Kconfig | 6 - src/drivers/generic/gfx/Makefile.inc | 1 - src/drivers/generic/gfx/chip.h | 56 --------- src/drivers/generic/gfx/gfx.c | 129 --------------------- src/drivers/gfx/generic/Kconfig | 6 + src/drivers/gfx/generic/Makefile.inc | 1 + src/drivers/gfx/generic/chip.h | 56 +++++++++ src/drivers/gfx/generic/generic.c | 129 +++++++++++++++++++++ src/mainboard/google/drallion/Kconfig | 2 +- .../drallion/variants/drallion/devicetree.cb | 2 +- 10 files changed, 194 insertions(+), 194 deletions(-) delete mode 100644 src/drivers/generic/gfx/Kconfig delete mode 100644 src/drivers/generic/gfx/Makefile.inc delete mode 100644 src/drivers/generic/gfx/chip.h delete mode 100644 src/drivers/generic/gfx/gfx.c create mode 100644 src/drivers/gfx/generic/Kconfig create mode 100644 src/drivers/gfx/generic/Makefile.inc create mode 100644 src/drivers/gfx/generic/chip.h create mode 100644 src/drivers/gfx/generic/generic.c (limited to 'src') diff --git a/src/drivers/generic/gfx/Kconfig b/src/drivers/generic/gfx/Kconfig deleted file mode 100644 index 1152f5bb7d..0000000000 --- a/src/drivers/generic/gfx/Kconfig +++ /dev/null @@ -1,6 +0,0 @@ -config DRIVERS_GENERIC_GFX - bool - default n - depends on HAVE_ACPI_TABLES - help - Include support for generic graphics device in devicetree diff --git a/src/drivers/generic/gfx/Makefile.inc b/src/drivers/generic/gfx/Makefile.inc deleted file mode 100644 index c31986be46..0000000000 --- a/src/drivers/generic/gfx/Makefile.inc +++ /dev/null @@ -1 +0,0 @@ -ramstage-$(CONFIG_DRIVERS_GENERIC_GFX) += gfx.c diff --git a/src/drivers/generic/gfx/chip.h b/src/drivers/generic/gfx/chip.h deleted file mode 100644 index ee5bd1ff88..0000000000 --- a/src/drivers/generic/gfx/chip.h +++ /dev/null @@ -1,56 +0,0 @@ -/* - * This file is part of the coreboot project. - * - * Copyright 2019 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 __DRIVERS_GENERIC_GFX_CHIP_H__ -#define __DRIVERS_GENERIC_GFX_CHIP_H__ - -/* Config for electronic privacy screen */ -struct drivers_generic_gfx_privacy_screen_config { - /* Is privacy screen available on this graphics device */ - int enabled; - /* ACPI namespace path to privacy screen detection function */ - const char *detect_function; - /* ACPI namespace path to privacy screen status function */ - const char *status_function; - /* ACPI namespace path to privacy screen enable function */ - const char *enable_function; - /* ACPI namespace path to privacy screen disable function */ - const char *disable_function; -}; - -/* Config for an output device as defined in section A.5 of the ACPI spec */ -struct drivers_generic_gfx_device_config { - /* ACPI device name of the output device */ - const char *name; - /* The address of the output device. See section A.3.2 */ - unsigned int addr; - /* Electronic privacy screen specific config */ - struct drivers_generic_gfx_privacy_screen_config privacy; -}; - -/* Config for an ACPI video device defined in Appendix A of the ACPI spec */ -struct drivers_generic_gfx_config { - /* - * ACPI device name of the graphics card, "GFX0" will be used if name is - * not set - */ - const char *name; - /* The number of output devices defined */ - int device_count; - /* Config for output devices */ - struct drivers_generic_gfx_device_config device[5]; -}; - -#endif /* __DRIVERS_GENERIC_GFX_CHIP_H__ */ diff --git a/src/drivers/generic/gfx/gfx.c b/src/drivers/generic/gfx/gfx.c deleted file mode 100644 index 0386e9b2ef..0000000000 --- a/src/drivers/generic/gfx/gfx.c +++ /dev/null @@ -1,129 +0,0 @@ -/* - * This file is part of the coreboot project. - * - * Copyright 2019 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 -#include -#include -#include -#include -#include - -#include "chip.h" - -#define ACPI_DSM_PRIVACY_SCREEN_UUID "C7033113-8720-4CEB-9090-9D52B3E52D73" - -static void privacy_screen_detect_cb(void *arg) -{ - struct drivers_generic_gfx_privacy_screen_config *config = arg; - - acpigen_write_store(); - acpigen_emit_namestring(config->detect_function); - acpigen_emit_byte(LOCAL2_OP); - acpigen_write_if_lequal_op_int(LOCAL2_OP, 1); - acpigen_write_return_singleton_buffer(0xF); - acpigen_pop_len(); -} -static void privacy_screen_get_status_cb(void *arg) -{ - struct drivers_generic_gfx_privacy_screen_config *config = arg; - - acpigen_emit_byte(RETURN_OP); - acpigen_emit_namestring(config->status_function); -} -static void privacy_screen_enable_cb(void *arg) -{ - struct drivers_generic_gfx_privacy_screen_config *config = arg; - - acpigen_emit_namestring(config->enable_function); -} -static void privacy_screen_disable_cb(void *arg) -{ - struct drivers_generic_gfx_privacy_screen_config *config = arg; - - acpigen_emit_namestring(config->disable_function); -} - -static void (*privacy_screen_callbacks[])(void *) = { - privacy_screen_detect_cb, - privacy_screen_get_status_cb, - privacy_screen_enable_cb, - privacy_screen_disable_cb, -}; - -static void gfx_fill_ssdt_generator(struct device *dev) -{ - size_t i; - struct drivers_generic_gfx_config *config = dev->chip_info; - - const char *scope = acpi_device_scope(dev); - - if (!scope) - return; - - acpigen_write_scope(scope); - - /* Method (_DOD, 0) */ - acpigen_write_method("_DOD", 0); - acpigen_emit_byte(RETURN_OP); - acpigen_write_package(config->device_count); - for (i = 0; i < config->device_count; i++) - acpigen_write_dword(config->device[i].addr); - acpigen_pop_len(); /* End Package. */ - acpigen_pop_len(); /* End Method. */ - - 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); - } - - acpigen_pop_len(); /* Device */ - } - acpigen_pop_len(); /* Scope */ -} - -static const char *gfx_acpi_name(const struct device *dev) -{ - struct drivers_generic_gfx_config *config = dev->chip_info; - - return config->name ? : "GFX0"; -} - -static struct device_operations gfx_ops = { - .acpi_name = gfx_acpi_name, - .acpi_fill_ssdt_generator = gfx_fill_ssdt_generator, -}; - -static void gfx_enable(struct device *dev) -{ - struct drivers_generic_gfx_config *config = dev->chip_info; - - if (!config) - return; - - dev->ops = &gfx_ops; -} - -struct chip_operations drivers_generic_gfx_ops = { - CHIP_NAME("Graphics Device") - .enable_dev = gfx_enable -}; diff --git a/src/drivers/gfx/generic/Kconfig b/src/drivers/gfx/generic/Kconfig new file mode 100644 index 0000000000..dcd1a8bc01 --- /dev/null +++ b/src/drivers/gfx/generic/Kconfig @@ -0,0 +1,6 @@ +config DRIVERS_GFX_GENERIC + bool + default n + depends on HAVE_ACPI_TABLES + help + Include support for generic graphics device in devicetree diff --git a/src/drivers/gfx/generic/Makefile.inc b/src/drivers/gfx/generic/Makefile.inc new file mode 100644 index 0000000000..4ffe8dcc80 --- /dev/null +++ b/src/drivers/gfx/generic/Makefile.inc @@ -0,0 +1 @@ +ramstage-$(CONFIG_DRIVERS_GFX_GENERIC) += generic.c diff --git a/src/drivers/gfx/generic/chip.h b/src/drivers/gfx/generic/chip.h new file mode 100644 index 0000000000..5e855e3853 --- /dev/null +++ b/src/drivers/gfx/generic/chip.h @@ -0,0 +1,56 @@ +/* + * This file is part of the coreboot project. + * + * Copyright 2019 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 __DRIVERS_GFX_GENERIC_CHIP_H__ +#define __DRIVERS_GFX_GENERIC_CHIP_H__ + +/* Config for electronic privacy screen */ +struct drivers_gfx_generic_privacy_screen_config { + /* Is privacy screen available on this graphics device */ + int enabled; + /* ACPI namespace path to privacy screen detection function */ + const char *detect_function; + /* ACPI namespace path to privacy screen status function */ + const char *status_function; + /* ACPI namespace path to privacy screen enable function */ + const char *enable_function; + /* ACPI namespace path to privacy screen disable function */ + const char *disable_function; +}; + +/* Config for an output device as defined in section A.5 of the ACPI spec */ +struct drivers_gfx_generic_device_config { + /* ACPI device name of the output device */ + const char *name; + /* The address of the output device. See section A.3.2 */ + unsigned int addr; + /* Electronic privacy screen specific config */ + struct drivers_gfx_generic_privacy_screen_config privacy; +}; + +/* Config for an ACPI video device defined in Appendix A of the ACPI spec */ +struct drivers_gfx_generic_config { + /* + * ACPI device name of the graphics card, "GFX0" will be used if name is + * not set + */ + const char *name; + /* The number of output devices defined */ + int device_count; + /* Config for output devices */ + struct drivers_gfx_generic_device_config device[5]; +}; + +#endif /* __DRIVERS_GFX_GENERIC_CHIP_H__ */ diff --git a/src/drivers/gfx/generic/generic.c b/src/drivers/gfx/generic/generic.c new file mode 100644 index 0000000000..8488040d30 --- /dev/null +++ b/src/drivers/gfx/generic/generic.c @@ -0,0 +1,129 @@ +/* + * This file is part of the coreboot project. + * + * Copyright 2019 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 +#include +#include +#include +#include +#include + +#include "chip.h" + +#define ACPI_DSM_PRIVACY_SCREEN_UUID "C7033113-8720-4CEB-9090-9D52B3E52D73" + +static void privacy_screen_detect_cb(void *arg) +{ + struct drivers_gfx_generic_privacy_screen_config *config = arg; + + acpigen_write_store(); + acpigen_emit_namestring(config->detect_function); + acpigen_emit_byte(LOCAL2_OP); + acpigen_write_if_lequal_op_int(LOCAL2_OP, 1); + acpigen_write_return_singleton_buffer(0xF); + acpigen_pop_len(); +} +static void privacy_screen_get_status_cb(void *arg) +{ + struct drivers_gfx_generic_privacy_screen_config *config = arg; + + acpigen_emit_byte(RETURN_OP); + acpigen_emit_namestring(config->status_function); +} +static void privacy_screen_enable_cb(void *arg) +{ + struct drivers_gfx_generic_privacy_screen_config *config = arg; + + acpigen_emit_namestring(config->enable_function); +} +static void privacy_screen_disable_cb(void *arg) +{ + struct drivers_gfx_generic_privacy_screen_config *config = arg; + + acpigen_emit_namestring(config->disable_function); +} + +static void (*privacy_screen_callbacks[])(void *) = { + privacy_screen_detect_cb, + privacy_screen_get_status_cb, + privacy_screen_enable_cb, + privacy_screen_disable_cb, +}; + +static void gfx_fill_ssdt_generator(struct device *dev) +{ + size_t i; + struct drivers_gfx_generic_config *config = dev->chip_info; + + const char *scope = acpi_device_scope(dev); + + if (!scope) + return; + + acpigen_write_scope(scope); + + /* Method (_DOD, 0) */ + acpigen_write_method("_DOD", 0); + acpigen_emit_byte(RETURN_OP); + acpigen_write_package(config->device_count); + for (i = 0; i < config->device_count; i++) + acpigen_write_dword(config->device[i].addr); + acpigen_pop_len(); /* End Package. */ + acpigen_pop_len(); /* End Method. */ + + 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); + } + + acpigen_pop_len(); /* Device */ + } + acpigen_pop_len(); /* Scope */ +} + +static const char *gfx_acpi_name(const struct device *dev) +{ + struct drivers_gfx_generic_config *config = dev->chip_info; + + return config->name ? : "GFX0"; +} + +static struct device_operations gfx_ops = { + .acpi_name = gfx_acpi_name, + .acpi_fill_ssdt_generator = gfx_fill_ssdt_generator, +}; + +static void gfx_enable(struct device *dev) +{ + struct drivers_gfx_generic_config *config = dev->chip_info; + + if (!config) + return; + + dev->ops = &gfx_ops; +} + +struct chip_operations drivers_gfx_generic_ops = { + CHIP_NAME("Generic Graphics Device") + .enable_dev = gfx_enable +}; diff --git a/src/mainboard/google/drallion/Kconfig b/src/mainboard/google/drallion/Kconfig index a0068580c7..61bae2b03d 100644 --- a/src/mainboard/google/drallion/Kconfig +++ b/src/mainboard/google/drallion/Kconfig @@ -2,7 +2,7 @@ config BOARD_GOOGLE_BASEBOARD_DRALLION def_bool n select BOARD_ROMSIZE_KB_32768 - select DRIVERS_GENERIC_GFX + select DRIVERS_GFX_GENERIC select DRIVERS_I2C_GENERIC select DRIVERS_I2C_HID select DRIVERS_INTEL_ISH diff --git a/src/mainboard/google/drallion/variants/drallion/devicetree.cb b/src/mainboard/google/drallion/variants/drallion/devicetree.cb index cdb6288173..d0006d64d7 100644 --- a/src/mainboard/google/drallion/variants/drallion/devicetree.cb +++ b/src/mainboard/google/drallion/variants/drallion/devicetree.cb @@ -226,7 +226,7 @@ chip soc/intel/cannonlake device domain 0 on device pci 00.0 on end # Host Bridge device pci 02.0 on - chip drivers/generic/gfx + chip drivers/gfx/generic register "device_count" = "1" register "device[0].name" = ""LCD"" # Address is set following the ACPI spec section A.3.2 -- cgit v1.2.3