Mathew King has uploaded this change for review. ( https://review.coreboot.org/c/coreboot/+/36041 )
Change subject: drivers/gfx: Add generic graphics with SSDT generator ......................................................................
drivers/gfx: Add generic graphics with SSDT generator
This change adds a generic graphics driver that can be added to a devicetree which populates graphics related ACPI table. It will write the _DOD method (Enumerate All Devices Attached to the Display Adapter) and a device object for each device defined. The device may optionally have a connected privacy screen which can be controlled with a _DSM.
Example: chip drivers/generic/gfx register "device_count" = "1" register "device[0].name" = ""LCD"" register "device[0].addr" = "0x0400" register "device[0].privacy.enabled" = "1" register "device[0].privacy.detect_function" = ""\_SB.PCI0.PVSC.GPVD"" register "device[0].privacy.status_function" = ""\_SB.PCI0.PVSC.GPVX"" register "device[0].privacy.enable_function" = ""\_SB.PCI0.PVSC.EPVX"" register "device[0].privacy.disable_function" = ""\_SB.PCI0.LPCB.EC0.DPVX"" device generic 0 on end end
ASL Scope (_SB.PCI0.GFX0) { Method (_DOD, 0, NotSerialized) // _DOD: Display Output Devices { Return (Package (0x01) { 0x00000400 }) }
Device (LCD) { Name (_HID, "GOOG0010") // _HID: Hardware ID Name (_UID, One) // _UID: Unique ID Name (_ADR, 0x0400) // _ADR: Address Name (_STA, 0x0F) // _STA: Status Method (_DSM, 4, Serialized) // _DSM: Device-Specific Method { ToBuffer (Arg0, Local0) If ((Local0 == ToUUID ("c7033113-8720-4ceb-9090-9d52b3e52d73"))) { ToInteger (Arg2, Local1) If ((Local1 == Zero)) { Local2 = _SB.PCI0.PVSC.GPVD () If ((Local2 == One)) { Return (Buffer (One) { 0x0F }) } }
If ((Local1 == One)) { ToBuffer (_SB.PCI0.PVSC.GPVX (), Local2) Return (Local2) }
If ((Local1 == 0x02)) { _SB.PCI0.PVSC.EPVX () }
If ((Local1 == 0x03)) { _SB.PCI0.PVSC.DPVX () }
Return (Buffer (One) { 0x00 }) }
Return (Buffer (One) { 0x00 }) } } }
BUG=b:142237145 TEST=Added gfx to devicetree on sarien_cml and correct ASL in SSDT
Change-Id: Ida520dd7aad81ee7c1e5f2d0d3f5cc1a766d78a0 Signed-off-by: Mathew King mathewk@chromium.org --- A src/drivers/generic/gfx/Kconfig A src/drivers/generic/gfx/Makefile.inc A src/drivers/generic/gfx/chip.h A src/drivers/generic/gfx/gfx.c 4 files changed, 174 insertions(+), 0 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/41/36041/1
diff --git a/src/drivers/generic/gfx/Kconfig b/src/drivers/generic/gfx/Kconfig new file mode 100644 index 0000000..f59275a --- /dev/null +++ b/src/drivers/generic/gfx/Kconfig @@ -0,0 +1,4 @@ +config DRIVERS_GENERIC_GFX + bool + default n + depends on HAVE_ACPI_TABLES \ No newline at end of file diff --git a/src/drivers/generic/gfx/Makefile.inc b/src/drivers/generic/gfx/Makefile.inc new file mode 100644 index 0000000..c31986b --- /dev/null +++ b/src/drivers/generic/gfx/Makefile.inc @@ -0,0 +1 @@ +ramstage-$(CONFIG_DRIVERS_GENERIC_GFX) += gfx.c diff --git a/src/drivers/generic/gfx/chip.h b/src/drivers/generic/gfx/chip.h new file mode 100644 index 0000000..1d8f909 --- /dev/null +++ b/src/drivers/generic/gfx/chip.h @@ -0,0 +1,41 @@ +/* + * 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__ + +struct drivers_generic_gfx_privacy_screen_config +{ + int enabled; + const char *detect_function; + const char *status_function; + const char *enable_function; + const char *disable_function; +}; + +struct drivers_generic_gfx_device_config +{ + const char *name; + int addr; + struct drivers_generic_gfx_privacy_screen_config privacy; +}; + + +struct drivers_generic_gfx_config { + int device_count; + 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 new file mode 100644 index 0000000..40fc871 --- /dev/null +++ b/src/drivers/generic/gfx/gfx.c @@ -0,0 +1,128 @@ +/* + * 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 <arch/acpigen.h> +#include <device/device.h> +#include <stdint.h> +#include <string.h> +#include "chip.h" +#include <console/console.h> +#include <device/pci.h> +#include <device/pci_ids.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(TO_BUFFER_OP); + acpigen_emit_namestring(config->status_function); + acpigen_emit_byte(LOCAL2_OP); + acpigen_emit_byte(RETURN_OP); + acpigen_emit_byte(LOCAL2_OP); +} +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); + + 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) +{ + return "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 +};
Patrick Rudolph has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/36041 )
Change subject: drivers/gfx: Add generic graphics with SSDT generator ......................................................................
Patch Set 1:
(1 comment)
https://review.coreboot.org/c/coreboot/+/36041/1/src/drivers/generic/gfx/gfx... File src/drivers/generic/gfx/gfx.c:
https://review.coreboot.org/c/coreboot/+/36041/1/src/drivers/generic/gfx/gfx... PS1, Line 112: .acpi_fill_ssdt_generator = gfx_fill_ssdt_generator, please merge with drivers_intel_gma_displays_ssdt_generate()
Hello build bot (Jenkins), Patrick Georgi, Martin Roth,
I'd like you to reexamine a change. Please visit
https://review.coreboot.org/c/coreboot/+/36041
to look at the new patch set (#2).
Change subject: drivers/gfx: Add generic graphics with SSDT generator ......................................................................
drivers/gfx: Add generic graphics with SSDT generator
This change adds a generic graphics driver that can be added to a devicetree which populates graphics related ACPI table. It will write the _DOD method (Enumerate All Devices Attached to the Display Adapter) and a device object for each device defined. The device may optionally have a connected privacy screen which can be controlled with a _DSM.
Example: chip drivers/generic/gfx register "device_count" = "1" register "device[0].name" = ""LCD"" register "device[0].addr" = "0x0400" register "device[0].privacy.enabled" = "1" register "device[0].privacy.detect_function" = ""\_SB.PCI0.PVSC.GPVD"" register "device[0].privacy.status_function" = ""\_SB.PCI0.PVSC.GPVX"" register "device[0].privacy.enable_function" = ""\_SB.PCI0.PVSC.EPVX"" register "device[0].privacy.disable_function" = ""\_SB.PCI0.LPCB.EC0.DPVX"" device generic 0 on end end
ASL Scope (_SB.PCI0.GFX0) { Method (_DOD, 0, NotSerialized) // _DOD: Display Output Devices { Return (Package (0x01) { 0x00000400 }) }
Device (LCD) { Name (_HID, "GOOG0010") // _HID: Hardware ID Name (_UID, One) // _UID: Unique ID Name (_ADR, 0x0400) // _ADR: Address Name (_STA, 0x0F) // _STA: Status Method (_DSM, 4, Serialized) // _DSM: Device-Specific Method { ToBuffer (Arg0, Local0) If ((Local0 == ToUUID ("c7033113-8720-4ceb-9090-9d52b3e52d73"))) { ToInteger (Arg2, Local1) If ((Local1 == Zero)) { Local2 = _SB.PCI0.PVSC.GPVD () If ((Local2 == One)) { Return (Buffer (One) { 0x0F }) } }
If ((Local1 == One)) { ToBuffer (_SB.PCI0.PVSC.GPVX (), Local2) Return (Local2) }
If ((Local1 == 0x02)) { _SB.PCI0.PVSC.EPVX () }
If ((Local1 == 0x03)) { _SB.PCI0.PVSC.DPVX () }
Return (Buffer (One) { 0x00 }) }
Return (Buffer (One) { 0x00 }) } } }
BUG=b:142237145 TEST=Added gfx to devicetree on sarien_cml and correct ASL in SSDT
Change-Id: Ida520dd7aad81ee7c1e5f2d0d3f5cc1a766d78a0 Signed-off-by: Mathew King mathewk@chromium.org --- A src/drivers/generic/gfx/Kconfig A src/drivers/generic/gfx/Makefile.inc A src/drivers/generic/gfx/chip.h A src/drivers/generic/gfx/gfx.c 4 files changed, 176 insertions(+), 0 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/41/36041/2
build bot (Jenkins) has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/36041 )
Change subject: drivers/gfx: Add generic graphics with SSDT generator ......................................................................
Patch Set 2:
(2 comments)
https://review.coreboot.org/c/coreboot/+/36041/2/src/drivers/generic/gfx/chi... File src/drivers/generic/gfx/chip.h:
https://review.coreboot.org/c/coreboot/+/36041/2/src/drivers/generic/gfx/chi... PS2, Line 20: { open brace '{' following struct go on the same line
https://review.coreboot.org/c/coreboot/+/36041/2/src/drivers/generic/gfx/chi... PS2, Line 29: { open brace '{' following struct go on the same line
Hello build bot (Jenkins), Patrick Georgi, Martin Roth,
I'd like you to reexamine a change. Please visit
https://review.coreboot.org/c/coreboot/+/36041
to look at the new patch set (#3).
Change subject: drivers/gfx: Add generic graphics with SSDT generator ......................................................................
drivers/gfx: Add generic graphics with SSDT generator
This change adds a generic graphics driver that can be added to a devicetree which populates graphics related ACPI table. It will write the _DOD method (Enumerate All Devices Attached to the Display Adapter) and a device object for each device defined. The device may optionally have a connected privacy screen which can be controlled with a _DSM.
Example: chip drivers/generic/gfx register "device_count" = "1" register "device[0].name" = ""LCD"" register "device[0].addr" = "0x0400" register "device[0].privacy.enabled" = "1" register "device[0].privacy.detect_function" = ""\_SB.PCI0.PVSC.GPVD"" register "device[0].privacy.status_function" = ""\_SB.PCI0.PVSC.GPVX"" register "device[0].privacy.enable_function" = ""\_SB.PCI0.PVSC.EPVX"" register "device[0].privacy.disable_function" = ""\_SB.PCI0.PVSC.DPVX"" device generic 0 on end end
ASL Scope (_SB.PCI0.GFX0) { Method (_DOD, 0, NotSerialized) // _DOD: Display Output Devices { Return (Package (0x01) { 0x00000400 }) }
Device (LCD) { Name (_HID, "GOOG0010") // _HID: Hardware ID Name (_UID, One) // _UID: Unique ID Name (_ADR, 0x0400) // _ADR: Address Name (_STA, 0x0F) // _STA: Status Method (_DSM, 4, Serialized) // _DSM: Device-Specific Method { ToBuffer (Arg0, Local0) If ((Local0 == ToUUID ("c7033113-8720-4ceb-9090-9d52b3e52d73"))) { ToInteger (Arg2, Local1) If ((Local1 == Zero)) { Local2 = _SB.PCI0.PVSC.GPVD () If ((Local2 == One)) { Return (Buffer (One) { 0x0F }) } }
If ((Local1 == One)) { ToBuffer (_SB.PCI0.PVSC.GPVX (), Local2) Return (Local2) }
If ((Local1 == 0x02)) { _SB.PCI0.PVSC.EPVX () }
If ((Local1 == 0x03)) { _SB.PCI0.PVSC.DPVX () }
Return (Buffer (One) { 0x00 }) }
Return (Buffer (One) { 0x00 }) } } }
BUG=b:142237145 TEST=Added gfx to devicetree on sarien_cml and correct ASL in SSDT
Change-Id: Ida520dd7aad81ee7c1e5f2d0d3f5cc1a766d78a0 Signed-off-by: Mathew King mathewk@chromium.org --- A src/drivers/generic/gfx/Kconfig A src/drivers/generic/gfx/Makefile.inc A src/drivers/generic/gfx/chip.h A src/drivers/generic/gfx/gfx.c 4 files changed, 176 insertions(+), 0 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/41/36041/3
Hello build bot (Jenkins), Patrick Georgi, Martin Roth,
I'd like you to reexamine a change. Please visit
https://review.coreboot.org/c/coreboot/+/36041
to look at the new patch set (#4).
Change subject: drivers/gfx: Add generic graphics with SSDT generator ......................................................................
drivers/gfx: Add generic graphics with SSDT generator
This change adds a generic graphics driver that can be added to a devicetree which populates graphics related ACPI table. It will write the _DOD method (Enumerate All Devices Attached to the Display Adapter) and a device object for each device defined. The device may optionally have a connected privacy screen which can be controlled with a _DSM.
Example: chip drivers/generic/gfx register "device_count" = "1" register "device[0].name" = ""LCD"" register "device[0].addr" = "0x0400" register "device[0].privacy.enabled" = "1" register "device[0].privacy.detect_function" = ""\_SB.PCI0.PVSC.GPVD"" register "device[0].privacy.status_function" = ""\_SB.PCI0.PVSC.GPVX"" register "device[0].privacy.enable_function" = ""\_SB.PCI0.PVSC.EPVX"" register "device[0].privacy.disable_function" = ""\_SB.PCI0.PVSC.DPVX"" device generic 0 on end end
ASL Scope (_SB.PCI0.GFX0) { Method (_DOD, 0, NotSerialized) // _DOD: Display Output Devices { Return (Package (0x01) { 0x00000400 }) }
Device (LCD) { Name (_HID, "GOOG0010") // _HID: Hardware ID Name (_UID, One) // _UID: Unique ID Name (_ADR, 0x0400) // _ADR: Address Name (_STA, 0x0F) // _STA: Status Method (_DSM, 4, Serialized) // _DSM: Device-Specific Method { ToBuffer (Arg0, Local0) If ((Local0 == ToUUID ("c7033113-8720-4ceb-9090-9d52b3e52d73"))) { ToInteger (Arg2, Local1) If ((Local1 == Zero)) { Local2 = _SB.PCI0.PVSC.GPVD () If ((Local2 == One)) { Return (Buffer (One) { 0x0F }) } }
If ((Local1 == One)) { ToBuffer (_SB.PCI0.PVSC.GPVX (), Local2) Return (Local2) }
If ((Local1 == 0x02)) { _SB.PCI0.PVSC.EPVX () }
If ((Local1 == 0x03)) { _SB.PCI0.PVSC.DPVX () }
Return (Buffer (One) { 0x00 }) }
Return (Buffer (One) { 0x00 }) } } }
BUG=b:142237145 TEST=Added gfx to devicetree on sarien_cml and correct ASL in SSDT
Change-Id: Ida520dd7aad81ee7c1e5f2d0d3f5cc1a766d78a0 Signed-off-by: Mathew King mathewk@chromium.org --- A src/drivers/generic/gfx/Kconfig A src/drivers/generic/gfx/Makefile.inc A src/drivers/generic/gfx/chip.h A src/drivers/generic/gfx/gfx.c 4 files changed, 176 insertions(+), 0 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/41/36041/4
build bot (Jenkins) has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/36041 )
Change subject: drivers/gfx: Add generic graphics with SSDT generator ......................................................................
Patch Set 4:
(2 comments)
https://review.coreboot.org/c/coreboot/+/36041/4/src/drivers/generic/gfx/chi... File src/drivers/generic/gfx/chip.h:
https://review.coreboot.org/c/coreboot/+/36041/4/src/drivers/generic/gfx/chi... PS4, Line 20: { open brace '{' following struct go on the same line
https://review.coreboot.org/c/coreboot/+/36041/4/src/drivers/generic/gfx/chi... PS4, Line 29: { open brace '{' following struct go on the same line
Mathew King has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/36041 )
Change subject: drivers/gfx: Add generic graphics with SSDT generator ......................................................................
Patch Set 4:
(1 comment)
https://review.coreboot.org/c/coreboot/+/36041/1/src/drivers/generic/gfx/gfx... File src/drivers/generic/gfx/gfx.c:
https://review.coreboot.org/c/coreboot/+/36041/1/src/drivers/generic/gfx/gfx... PS1, Line 112: .acpi_fill_ssdt_generator = gfx_fill_ssdt_generator,
please merge with drivers_intel_gma_displays_ssdt_generate()
Filed b/142665012 to consolidate these two functions.
Hello Rajat Jain, Duncan Laurie, build bot (Jenkins), Patrick Georgi, Martin Roth,
I'd like you to reexamine a change. Please visit
https://review.coreboot.org/c/coreboot/+/36041
to look at the new patch set (#5).
Change subject: drivers/gfx: Add generic graphics with SSDT generator ......................................................................
drivers/gfx: Add generic graphics with SSDT generator
This change adds a generic graphics driver that can be added to a devicetree which populates graphics related ACPI table. It will write the _DOD method (Enumerate All Devices Attached to the Display Adapter) and a device object for each device defined. The device may optionally have a connected privacy screen which can be controlled with a _DSM.
Example: chip drivers/generic/gfx register "device_count" = "1" register "device[0].name" = ""LCD"" register "device[0].addr" = "0x0400" register "device[0].privacy.enabled" = "1" register "device[0].privacy.detect_function" = ""\_SB.PCI0.PVSC.GPVD"" register "device[0].privacy.status_function" = ""\_SB.PCI0.PVSC.GPVX"" register "device[0].privacy.enable_function" = ""\_SB.PCI0.PVSC.EPVX"" register "device[0].privacy.disable_function" = ""\_SB.PCI0.PVSC.DPVX"" device generic 0 on end end
ASL Scope (_SB.PCI0.GFX0) { Method (_DOD, 0, NotSerialized) // _DOD: Display Output Devices { Return (Package (0x01) { 0x00000400 }) }
Device (LCD) { Name (_HID, "GOOG0010") // _HID: Hardware ID Name (_UID, One) // _UID: Unique ID Name (_ADR, 0x0400) // _ADR: Address Name (_STA, 0x0F) // _STA: Status Method (_DSM, 4, Serialized) // _DSM: Device-Specific Method { ToBuffer (Arg0, Local0) If ((Local0 == ToUUID ("c7033113-8720-4ceb-9090-9d52b3e52d73"))) { ToInteger (Arg2, Local1) If ((Local1 == Zero)) { Local2 = _SB.PCI0.PVSC.GPVD () If ((Local2 == One)) { Return (Buffer (One) { 0x0F }) } }
If ((Local1 == One)) { ToBuffer (_SB.PCI0.PVSC.GPVX (), Local2) Return (Local2) }
If ((Local1 == 0x02)) { _SB.PCI0.PVSC.EPVX () }
If ((Local1 == 0x03)) { _SB.PCI0.PVSC.DPVX () }
Return (Buffer (One) { 0x00 }) }
Return (Buffer (One) { 0x00 }) } } }
BUG=b:142237145 TEST=Added gfx to devicetree on sarien_cml and correct ASL in SSDT
Change-Id: Ida520dd7aad81ee7c1e5f2d0d3f5cc1a766d78a0 Signed-off-by: Mathew King mathewk@chromium.org --- A src/drivers/generic/gfx/Kconfig A src/drivers/generic/gfx/Makefile.inc A src/drivers/generic/gfx/chip.h A src/drivers/generic/gfx/gfx.c 4 files changed, 174 insertions(+), 0 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/41/36041/5
Hello Rajat Jain, Duncan Laurie, build bot (Jenkins), Patrick Georgi, Martin Roth,
I'd like you to reexamine a change. Please visit
https://review.coreboot.org/c/coreboot/+/36041
to look at the new patch set (#6).
Change subject: drivers/gfx: Add generic graphics with SSDT generator ......................................................................
drivers/gfx: Add generic graphics with SSDT generator
This change adds a generic graphics driver that can be added to a devicetree which populates graphics related ACPI table. It will write the _DOD method (Enumerate All Devices Attached to the Display Adapter) and a device object for each device defined. The device may optionally have a connected privacy screen which can be controlled with a _DSM.
Example: chip drivers/generic/gfx register "device_count" = "1" register "device[0].name" = ""LCD"" register "device[0].addr" = "0x0400" register "device[0].privacy.enabled" = "1" register "device[0].privacy.detect_function" = ""\_SB.PCI0.PVSC.GPVD"" register "device[0].privacy.status_function" = ""\_SB.PCI0.PVSC.GPVX"" register "device[0].privacy.enable_function" = ""\_SB.PCI0.PVSC.EPVX"" register "device[0].privacy.disable_function" = ""\_SB.PCI0.PVSC.DPVX"" device generic 0 on end end
ASL Scope (_SB.PCI0.GFX0) { Method (_DOD, 0, NotSerialized) // _DOD: Display Output Devices { Return (Package (0x01) { 0x00000400 }) }
Device (LCD) { Name (_HID, "GOOG0010") // _HID: Hardware ID Name (_UID, One) // _UID: Unique ID Name (_ADR, 0x0400) // _ADR: Address Name (_STA, 0x0F) // _STA: Status Method (_DSM, 4, Serialized) // _DSM: Device-Specific Method { ToBuffer (Arg0, Local0) If ((Local0 == ToUUID ("c7033113-8720-4ceb-9090-9d52b3e52d73"))) { ToInteger (Arg2, Local1) If ((Local1 == Zero)) { Local2 = _SB.PCI0.PVSC.GPVD () If ((Local2 == One)) { Return (Buffer (One) { 0x0F }) } }
If ((Local1 == One)) { ToBuffer (_SB.PCI0.PVSC.GPVX (), Local2) Return (Local2) }
If ((Local1 == 0x02)) { _SB.PCI0.PVSC.EPVX () }
If ((Local1 == 0x03)) { _SB.PCI0.PVSC.DPVX () }
Return (Buffer (One) { 0x00 }) }
Return (Buffer (One) { 0x00 }) } } }
BUG=b:142237145 TEST=Added gfx to devicetree on sarien_cml and correct ASL in SSDT
Change-Id: Ida520dd7aad81ee7c1e5f2d0d3f5cc1a766d78a0 Signed-off-by: Mathew King mathewk@chromium.org --- A src/drivers/generic/gfx/Kconfig A src/drivers/generic/gfx/Makefile.inc A src/drivers/generic/gfx/chip.h A src/drivers/generic/gfx/gfx.c 4 files changed, 172 insertions(+), 0 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/41/36041/6
Hello Rajat Jain, Duncan Laurie, build bot (Jenkins), Patrick Georgi, Martin Roth,
I'd like you to reexamine a change. Please visit
https://review.coreboot.org/c/coreboot/+/36041
to look at the new patch set (#7).
Change subject: drivers/gfx: Add generic graphics with SSDT generator ......................................................................
drivers/gfx: Add generic graphics with SSDT generator
This change adds a generic graphics driver that can be added to a devicetree which populates graphics related ACPI table. It will write the _DOD method (Enumerate All Devices Attached to the Display Adapter) and a device object for each device defined. The device may optionally have a connected privacy screen which can be controlled with a _DSM.
Example: chip drivers/generic/gfx register "device_count" = "1" register "device[0].name" = ""LCD"" register "device[0].addr" = "0x0400" register "device[0].privacy.enabled" = "1" register "device[0].privacy.detect_function" = ""\_SB.PCI0.PVSC.GPVD"" register "device[0].privacy.status_function" = ""\_SB.PCI0.PVSC.GPVX"" register "device[0].privacy.enable_function" = ""\_SB.PCI0.PVSC.EPVX"" register "device[0].privacy.disable_function" = ""\_SB.PCI0.PVSC.DPVX"" device generic 0 on end end
ASL Scope (_SB.PCI0.GFX0) { Method (_DOD, 0, NotSerialized) // _DOD: Display Output Devices { Return (Package (0x01) { 0x00000400 }) }
Device (LCD) { Name (_ADR, 0x0400) // _ADR: Address Name (_STA, 0x0F) // _STA: Status Method (_DSM, 4, Serialized) // _DSM: Device-Specific Method { ToBuffer (Arg0, Local0) If ((Local0 == ToUUID ("c7033113-8720-4ceb-9090-9d52b3e52d73"))) { ToInteger (Arg2, Local1) If ((Local1 == Zero)) { Local2 = _SB.PCI0.PVSC.GPVD () If ((Local2 == One)) { Return (Buffer (One) { 0x0F }) } }
If ((Local1 == One)) { ToBuffer (_SB.PCI0.PVSC.GPVX (), Local2) Return (Local2) }
If ((Local1 == 0x02)) { _SB.PCI0.PVSC.EPVX () }
If ((Local1 == 0x03)) { _SB.PCI0.PVSC.DPVX () }
Return (Buffer (One) { 0x00 }) }
Return (Buffer (One) { 0x00 }) } } }
BUG=b:142237145 TEST=Added gfx to devicetree on sarien_cml and correct ASL in SSDT
Change-Id: Ida520dd7aad81ee7c1e5f2d0d3f5cc1a766d78a0 Signed-off-by: Mathew King mathewk@chromium.org --- A src/drivers/generic/gfx/Kconfig A src/drivers/generic/gfx/Makefile.inc A src/drivers/generic/gfx/chip.h A src/drivers/generic/gfx/gfx.c 4 files changed, 172 insertions(+), 0 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/41/36041/7
Patrick Rudolph has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/36041 )
Change subject: drivers/gfx: Add generic graphics with SSDT generator ......................................................................
Patch Set 7: Code-Review-1
(1 comment)
https://review.coreboot.org/c/coreboot/+/36041/7//COMMIT_MSG Commit Message:
https://review.coreboot.org/c/coreboot/+/36041/7//COMMIT_MSG@21 PS7, Line 21: register "device[0].privacy.detect_function" = ""\_SB.PCI0.PVSC.GPVD"" Why should you hardcode those values and not autodetect them at runtime? You would have to keep devicetree, DSDT and SSDT in sync, which seems a bad idea.
Mathew King has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/36041 )
Change subject: drivers/gfx: Add generic graphics with SSDT generator ......................................................................
Patch Set 7:
(1 comment)
https://review.coreboot.org/c/coreboot/+/36041/7//COMMIT_MSG Commit Message:
https://review.coreboot.org/c/coreboot/+/36041/7//COMMIT_MSG@21 PS7, Line 21: register "device[0].privacy.detect_function" = ""\_SB.PCI0.PVSC.GPVD""
Why should you hardcode those values and not autodetect them at runtime? […]
I don't think there is anything to detect at runtime. I need a way to add privacy screen control to a LCD panel. The way in which the panel is controlled will vary between different platforms, some will control with just a GPIO others will use EC commands. So this will allow for different ACPI functions to be called depending on the platform.
Hello Rajat Jain, Patrick Rudolph, Duncan Laurie, build bot (Jenkins), Patrick Georgi, Martin Roth,
I'd like you to reexamine a change. Please visit
https://review.coreboot.org/c/coreboot/+/36041
to look at the new patch set (#8).
Change subject: drivers/gfx: Add generic graphics with SSDT generator ......................................................................
drivers/gfx: Add generic graphics with SSDT generator
This change adds a generic graphics driver that can be added to a devicetree which populates graphics related ACPI table. It will write the _DOD method (Enumerate All Devices Attached to the Display Adapter) and a device object for each device defined. The device may optionally have a connected privacy screen which can be controlled with a _DSM.
Example: chip drivers/generic/gfx register "device_count" = "1" register "device[0].name" = ""LCD"" register "device[0].addr" = "0x0400" register "device[0].privacy.enabled" = "1" register "device[0].privacy.detect_function" = ""\_SB.PCI0.PVSC.GPVD"" register "device[0].privacy.status_function" = ""\_SB.PCI0.PVSC.GPVX"" register "device[0].privacy.enable_function" = ""\_SB.PCI0.PVSC.EPVX"" register "device[0].privacy.disable_function" = ""\_SB.PCI0.PVSC.DPVX"" device generic 0 on end end
ASL Scope (_SB.PCI0.GFX0) { Method (_DOD, 0, NotSerialized) // _DOD: Display Output Devices { Return (Package (0x01) { 0x00000400 }) }
Device (LCD) { Name (_ADR, 0x0400) // _ADR: Address Name (_STA, 0x0F) // _STA: Status Method (_DSM, 4, Serialized) // _DSM: Device-Specific Method { ToBuffer (Arg0, Local0) If ((Local0 == ToUUID ("c7033113-8720-4ceb-9090-9d52b3e52d73"))) { ToInteger (Arg2, Local1) If ((Local1 == Zero)) { Local2 = _SB.PCI0.PVSC.GPVD () If ((Local2 == One)) { Return (Buffer (One) { 0x0F }) } }
If ((Local1 == One)) { ToBuffer (_SB.PCI0.PVSC.GPVX (), Local2) Return (Local2) }
If ((Local1 == 0x02)) { _SB.PCI0.PVSC.EPVX () }
If ((Local1 == 0x03)) { _SB.PCI0.PVSC.DPVX () }
Return (Buffer (One) { 0x00 }) }
Return (Buffer (One) { 0x00 }) } } }
BUG=b:142237145 TEST=Added gfx to devicetree on sarien_cml and correct ASL in SSDT
Change-Id: Ida520dd7aad81ee7c1e5f2d0d3f5cc1a766d78a0 Signed-off-by: Mathew King mathewk@chromium.org --- A src/drivers/generic/gfx/Kconfig A src/drivers/generic/gfx/Makefile.inc A src/drivers/generic/gfx/chip.h A src/drivers/generic/gfx/gfx.c 4 files changed, 169 insertions(+), 0 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/41/36041/8
Patrick Rudolph has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/36041 )
Change subject: drivers/gfx: Add generic graphics with SSDT generator ......................................................................
Patch Set 8:
(1 comment)
https://review.coreboot.org/c/coreboot/+/36041/7//COMMIT_MSG Commit Message:
https://review.coreboot.org/c/coreboot/+/36041/7//COMMIT_MSG@21 PS7, Line 21: register "device[0].privacy.detect_function" = ""\_SB.PCI0.PVSC.GPVD""
I don't think there is anything to detect at runtime. […]
You can give the functions the same name and it will work across platforms, regardless of the implementation. The acpi path can be read at runtime using acpi_device_scope()
Mathew King has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/36041 )
Change subject: drivers/gfx: Add generic graphics with SSDT generator ......................................................................
Patch Set 8:
(1 comment)
https://review.coreboot.org/c/coreboot/+/36041/7//COMMIT_MSG Commit Message:
https://review.coreboot.org/c/coreboot/+/36041/7//COMMIT_MSG@21 PS7, Line 21: register "device[0].privacy.detect_function" = ""\_SB.PCI0.PVSC.GPVD""
You can give the functions the same name and it will work across platforms, regardless of the implem […]
I have 2 thoughts.
1. I feel that the explicit method names gives a better understanding of what the code is doing with more flexibility. With the method names the next person to add this feature to a new platform will know that those methods must be defined. Without method names it is not obvious that some exact method under some exact scope must be defined for this to work. Documentation can help with that but I usually error on the side of making things easier for the next developer that comes along.
2. I'm not sure the best scope to put these new methods. I could have them under _SB.PCI0.GFX0 but that would limit us to one privacy screen per device, admittedly that is probably fine for now but it may cause some headaches if we ever needed more than one screen. I could do it under the device created by this driver, _SB.PCI0.GFX0.LCD for this example, and for that to work the functions would need to be defined in the DSDT for a device that will be defined in the SSDT. Is that allowed in ACPI?
With that said I am not opposed to changing it, I just wanted to share my thought I why I did things this way.
Patrick Rudolph has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/36041 )
Change subject: drivers/gfx: Add generic graphics with SSDT generator ......................................................................
Patch Set 8:
(1 comment)
https://review.coreboot.org/c/coreboot/+/36041/7//COMMIT_MSG Commit Message:
https://review.coreboot.org/c/coreboot/+/36041/7//COMMIT_MSG@21 PS7, Line 21: register "device[0].privacy.detect_function" = ""\_SB.PCI0.PVSC.GPVD""
I have 2 thoughts. […]
I see, right now it's difficult to implement. Something like CB:35456 might help.
Mathew King has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/36041 )
Change subject: drivers/gfx: Add generic graphics with SSDT generator ......................................................................
Patch Set 8:
Are there any concerns with this approach?
Simon Glass has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/36041 )
Change subject: drivers/gfx: Add generic graphics with SSDT generator ......................................................................
Patch Set 8: Code-Review+1
(4 comments)
https://review.coreboot.org/c/coreboot/+/36041/8//COMMIT_MSG Commit Message:
https://review.coreboot.org/c/coreboot/+/36041/8//COMMIT_MSG@10 PS8, Line 10: -
https://review.coreboot.org/c/coreboot/+/36041/8/src/drivers/generic/gfx/Kco... File src/drivers/generic/gfx/Kconfig:
https://review.coreboot.org/c/coreboot/+/36041/8/src/drivers/generic/gfx/Kco... PS8, Line 2: bool help?
https://review.coreboot.org/c/coreboot/+/36041/8/src/drivers/generic/gfx/chi... File src/drivers/generic/gfx/chip.h:
https://review.coreboot.org/c/coreboot/+/36041/8/src/drivers/generic/gfx/chi... PS8, Line 19: drivers_generic_gfx_privacy_screen_config Should there be any comments on these structs?
https://review.coreboot.org/c/coreboot/+/36041/8/src/drivers/generic/gfx/gfx... File src/drivers/generic/gfx/gfx.c:
https://review.coreboot.org/c/coreboot/+/36041/8/src/drivers/generic/gfx/gfx... PS8, Line 20: chip Is there an ordering rule on includes?
Hello Simon Glass, Rajat Jain, Patrick Rudolph, Duncan Laurie, build bot (Jenkins), Furquan Shaikh, Patrick Georgi, Martin Roth,
I'd like you to reexamine a change. Please visit
https://review.coreboot.org/c/coreboot/+/36041
to look at the new patch set (#9).
Change subject: drivers/gfx: Add generic graphics with SSDT generator ......................................................................
drivers/gfx: Add generic graphics with SSDT generator
This change adds a generic graphics driver that can be added to a devicetree which populates graphics related ACPI table. It will write the _DOD method (Enumerate All Devices Attached to the Display Adapter) and a device object for each device defined. The device may optionally have a connected privacy screen which can be controlled with a _DSM.
Example: chip drivers/generic/gfx register "device_count" = "1" register "device[0].name" = ""LCD"" register "device[0].addr" = "0x0400" register "device[0].privacy.enabled" = "1" register "device[0].privacy.detect_function" = ""\_SB.PCI0.PVSC.GPVD"" register "device[0].privacy.status_function" = ""\_SB.PCI0.PVSC.GPVX"" register "device[0].privacy.enable_function" = ""\_SB.PCI0.PVSC.EPVX"" register "device[0].privacy.disable_function" = ""\_SB.PCI0.PVSC.DPVX"" device generic 0 on end end
ASL Scope (_SB.PCI0.GFX0) { Method (_DOD, 0, NotSerialized) // _DOD: Display Output Devices { Return (Package (0x01) { 0x00000400 }) }
Device (LCD) { Name (_ADR, 0x0400) // _ADR: Address Name (_STA, 0x0F) // _STA: Status Method (_DSM, 4, Serialized) // _DSM: Device-Specific Method { ToBuffer (Arg0, Local0) If ((Local0 == ToUUID ("c7033113-8720-4ceb-9090-9d52b3e52d73"))) { ToInteger (Arg2, Local1) If ((Local1 == Zero)) { Local2 = _SB.PCI0.PVSC.GPVD () If ((Local2 == One)) { Return (Buffer (One) { 0x0F }) } }
If ((Local1 == One)) { ToBuffer (_SB.PCI0.PVSC.GPVX (), Local2) Return (Local2) }
If ((Local1 == 0x02)) { _SB.PCI0.PVSC.EPVX () }
If ((Local1 == 0x03)) { _SB.PCI0.PVSC.DPVX () }
Return (Buffer (One) { 0x00 }) }
Return (Buffer (One) { 0x00 }) } } }
BUG=b:142237145 TEST=Added gfx to devicetree on sarien_cml and correct ASL in SSDT
Change-Id: Ida520dd7aad81ee7c1e5f2d0d3f5cc1a766d78a0 Signed-off-by: Mathew King mathewk@chromium.org --- A src/drivers/generic/gfx/Kconfig A src/drivers/generic/gfx/Makefile.inc A src/drivers/generic/gfx/chip.h A src/drivers/generic/gfx/gfx.c 4 files changed, 183 insertions(+), 0 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/41/36041/9
Hello Simon Glass, Rajat Jain, Patrick Rudolph, Duncan Laurie, build bot (Jenkins), Furquan Shaikh, Patrick Georgi, Martin Roth,
I'd like you to reexamine a change. Please visit
https://review.coreboot.org/c/coreboot/+/36041
to look at the new patch set (#10).
Change subject: drivers/gfx: Add generic graphics with SSDT generator ......................................................................
drivers/gfx: Add generic graphics with SSDT generator
This change adds a generic graphics driver that can be added to a devicetree which populates graphics-related ACPI table. It will write the _DOD method (Enumerate All Devices Attached to the Display Adapter) and a device object for each device defined. The device may optionally have a connected privacy screen which can be controlled with a _DSM.
Example: chip drivers/generic/gfx register "device_count" = "1" register "device[0].name" = ""LCD"" register "device[0].addr" = "0x0400" register "device[0].privacy.enabled" = "1" register "device[0].privacy.detect_function" = ""\_SB.PCI0.PVSC.GPVD"" register "device[0].privacy.status_function" = ""\_SB.PCI0.PVSC.GPVX"" register "device[0].privacy.enable_function" = ""\_SB.PCI0.PVSC.EPVX"" register "device[0].privacy.disable_function" = ""\_SB.PCI0.PVSC.DPVX"" device generic 0 on end end
ASL Scope (_SB.PCI0.GFX0) { Method (_DOD, 0, NotSerialized) // _DOD: Display Output Devices { Return (Package (0x01) { 0x00000400 }) }
Device (LCD) { Name (_ADR, 0x0400) // _ADR: Address Name (_STA, 0x0F) // _STA: Status Method (_DSM, 4, Serialized) // _DSM: Device-Specific Method { ToBuffer (Arg0, Local0) If ((Local0 == ToUUID ("c7033113-8720-4ceb-9090-9d52b3e52d73"))) { ToInteger (Arg2, Local1) If ((Local1 == Zero)) { Local2 = _SB.PCI0.PVSC.GPVD () If ((Local2 == One)) { Return (Buffer (One) { 0x0F }) } }
If ((Local1 == One)) { ToBuffer (_SB.PCI0.PVSC.GPVX (), Local2) Return (Local2) }
If ((Local1 == 0x02)) { _SB.PCI0.PVSC.EPVX () }
If ((Local1 == 0x03)) { _SB.PCI0.PVSC.DPVX () }
Return (Buffer (One) { 0x00 }) }
Return (Buffer (One) { 0x00 }) } } }
BUG=b:142237145 TEST=Added gfx to devicetree on sarien_cml and correct ASL in SSDT
Change-Id: Ida520dd7aad81ee7c1e5f2d0d3f5cc1a766d78a0 Signed-off-by: Mathew King mathewk@chromium.org --- A src/drivers/generic/gfx/Kconfig A src/drivers/generic/gfx/Makefile.inc A src/drivers/generic/gfx/chip.h A src/drivers/generic/gfx/gfx.c 4 files changed, 183 insertions(+), 0 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/41/36041/10
Mathew King has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/36041 )
Change subject: drivers/gfx: Add generic graphics with SSDT generator ......................................................................
Patch Set 10:
(4 comments)
https://review.coreboot.org/c/coreboot/+/36041/8//COMMIT_MSG Commit Message:
https://review.coreboot.org/c/coreboot/+/36041/8//COMMIT_MSG@10 PS8, Line 10:
Done
https://review.coreboot.org/c/coreboot/+/36041/8/src/drivers/generic/gfx/Kco... File src/drivers/generic/gfx/Kconfig:
https://review.coreboot.org/c/coreboot/+/36041/8/src/drivers/generic/gfx/Kco... PS8, Line 2: bool
help?
Done
https://review.coreboot.org/c/coreboot/+/36041/8/src/drivers/generic/gfx/chi... File src/drivers/generic/gfx/chip.h:
https://review.coreboot.org/c/coreboot/+/36041/8/src/drivers/generic/gfx/chi... PS8, Line 19: drivers_generic_gfx_privacy_screen_config
Should there be any comments on these structs?
Done
https://review.coreboot.org/c/coreboot/+/36041/8/src/drivers/generic/gfx/gfx... File src/drivers/generic/gfx/gfx.c:
https://review.coreboot.org/c/coreboot/+/36041/8/src/drivers/generic/gfx/gfx... PS8, Line 20: chip
Is there an ordering rule on includes?
Done
Duncan Laurie has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/36041 )
Change subject: drivers/gfx: Add generic graphics with SSDT generator ......................................................................
Patch Set 10:
(2 comments)
https://review.coreboot.org/c/coreboot/+/36041/10/src/drivers/generic/gfx/gf... File src/drivers/generic/gfx/gfx.c:
https://review.coreboot.org/c/coreboot/+/36041/10/src/drivers/generic/gfx/gf... PS10, Line 26: C7033113-8720-4CEB-9090-9D52B3E52D73 Since we're proposing a new interface for both BIOS and Kernel to use we might want to publish a design in docs/ for how the BIOS<>Kernel interaction is expected to work.
https://review.coreboot.org/c/coreboot/+/36041/10/src/drivers/generic/gfx/gf... PS10, Line 104: GFX0 It might be useful to have a devicetree config item to set this (with GFX0 being default if nothing is set) in case an SOC does not use GFX0 for the device name.
Rajat Jain has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/36041 )
Change subject: drivers/gfx: Add generic graphics with SSDT generator ......................................................................
Patch Set 10:
(1 comment)
https://review.coreboot.org/c/coreboot/+/36041/10/src/drivers/generic/gfx/gf... File src/drivers/generic/gfx/gfx.c:
https://review.coreboot.org/c/coreboot/+/36041/10/src/drivers/generic/gfx/gf... PS10, Line 26: C7033113-8720-4CEB-9090-9D52B3E52D73
Since we're proposing a new interface for both BIOS and Kernel to use we might want to publish a des […]
I plan to update the https://docs.google.com/document/d/1jyW_Q3swO9eEbjjdAUMJeJwVlJYOL9E5ZCyk4lgZ... once the dust over upstream kernel patch is settled, but apparently you mean the coreboot docs?
Duncan Laurie has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/36041 )
Change subject: drivers/gfx: Add generic graphics with SSDT generator ......................................................................
Patch Set 10:
(1 comment)
https://review.coreboot.org/c/coreboot/+/36041/10/src/drivers/generic/gfx/gf... File src/drivers/generic/gfx/gfx.c:
https://review.coreboot.org/c/coreboot/+/36041/10/src/drivers/generic/gfx/gf... PS10, Line 26: C7033113-8720-4CEB-9090-9D52B3E52D73
I plan to update the https://docs.google. […]
As long as it is available publicly in the end it should be fine.
Hello Simon Glass, Rajat Jain, Patrick Rudolph, Duncan Laurie, build bot (Jenkins), Furquan Shaikh, Patrick Georgi, Martin Roth,
I'd like you to reexamine a change. Please visit
https://review.coreboot.org/c/coreboot/+/36041
to look at the new patch set (#11).
Change subject: drivers/gfx: Add generic graphics with SSDT generator ......................................................................
drivers/gfx: Add generic graphics with SSDT generator
This change adds a generic graphics driver that can be added to a devicetree which populates graphics-related ACPI table. It will write the _DOD method (Enumerate All Devices Attached to the Display Adapter) and a device object for each device defined. The device may optionally have a connected privacy screen which can be controlled with a _DSM.
Example: chip drivers/generic/gfx register "device_count" = "1" register "device[0].name" = ""LCD"" register "device[0].addr" = "0x0400" register "device[0].privacy.enabled" = "1" register "device[0].privacy.detect_function" = ""\_SB.PCI0.PVSC.GPVD"" register "device[0].privacy.status_function" = ""\_SB.PCI0.PVSC.GPVX"" register "device[0].privacy.enable_function" = ""\_SB.PCI0.PVSC.EPVX"" register "device[0].privacy.disable_function" = ""\_SB.PCI0.PVSC.DPVX"" device generic 0 on end end
ASL Scope (_SB.PCI0.GFX0) { Method (_DOD, 0, NotSerialized) // _DOD: Display Output Devices { Return (Package (0x01) { 0x00000400 }) }
Device (LCD) { Name (_ADR, 0x0400) // _ADR: Address Name (_STA, 0x0F) // _STA: Status Method (_DSM, 4, Serialized) // _DSM: Device-Specific Method { ToBuffer (Arg0, Local0) If ((Local0 == ToUUID ("c7033113-8720-4ceb-9090-9d52b3e52d73"))) { ToInteger (Arg2, Local1) If ((Local1 == Zero)) { Local2 = _SB.PCI0.PVSC.GPVD () If ((Local2 == One)) { Return (Buffer (One) { 0x0F }) } }
If ((Local1 == One)) { ToBuffer (_SB.PCI0.PVSC.GPVX (), Local2) Return (Local2) }
If ((Local1 == 0x02)) { _SB.PCI0.PVSC.EPVX () }
If ((Local1 == 0x03)) { _SB.PCI0.PVSC.DPVX () }
Return (Buffer (One) { 0x00 }) }
Return (Buffer (One) { 0x00 }) } } }
BUG=b:142237145 TEST=Added gfx to devicetree on sarien_cml and correct ASL in SSDT
Change-Id: Ida520dd7aad81ee7c1e5f2d0d3f5cc1a766d78a0 Signed-off-by: Mathew King mathewk@chromium.org --- A src/drivers/generic/gfx/Kconfig A src/drivers/generic/gfx/Makefile.inc A src/drivers/generic/gfx/chip.h A src/drivers/generic/gfx/gfx.c 4 files changed, 190 insertions(+), 0 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/41/36041/11
Mathew King has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/36041 )
Change subject: drivers/gfx: Add generic graphics with SSDT generator ......................................................................
Patch Set 11:
(2 comments)
https://review.coreboot.org/c/coreboot/+/36041/10/src/drivers/generic/gfx/gf... File src/drivers/generic/gfx/gfx.c:
https://review.coreboot.org/c/coreboot/+/36041/10/src/drivers/generic/gfx/gf... PS10, Line 26: C7033113-8720-4CEB-9090-9D52B3E52D73
As long as it is available publicly in the end it should be fine.
Ack
https://review.coreboot.org/c/coreboot/+/36041/10/src/drivers/generic/gfx/gf... PS10, Line 104: GFX0
It might be useful to have a devicetree config item to set this (with GFX0 being default if nothing […]
Done
Mathew King has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/36041 )
Change subject: drivers/gfx: Add generic graphics with SSDT generator ......................................................................
Patch Set 13:
These changes are ready for review.
Simon Glass has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/36041 )
Change subject: drivers/gfx: Add generic graphics with SSDT generator ......................................................................
Patch Set 13: Code-Review+1
(1 comment)
https://review.coreboot.org/c/coreboot/+/36041/13/src/drivers/generic/gfx/gf... File src/drivers/generic/gfx/gfx.c:
https://review.coreboot.org/c/coreboot/+/36041/13/src/drivers/generic/gfx/gf... PS13, Line 59: privacy_screen_callbacks Could this become a structure instead of an array? That would let us name each member.
Simon Glass has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/36041 )
Change subject: drivers/gfx: Add generic graphics with SSDT generator ......................................................................
Patch Set 13:
(1 comment)
https://review.coreboot.org/c/coreboot/+/36041/13//COMMIT_MSG Commit Message:
https://review.coreboot.org/c/coreboot/+/36041/13//COMMIT_MSG@9 PS13, Line 9: This change a Best to use imperative tense...just say:
Add a generic graphics driver
Hello Simon Glass, Rajat Jain, Patrick Rudolph, Duncan Laurie, build bot (Jenkins), Furquan Shaikh, Patrick Georgi, Martin Roth,
I'd like you to reexamine a change. Please visit
https://review.coreboot.org/c/coreboot/+/36041
to look at the new patch set (#14).
Change subject: drivers/gfx: Add generic graphics with SSDT generator ......................................................................
drivers/gfx: Add generic graphics with SSDT generator
Add a generic graphics driver that can be added to a devicetree which populates graphics-related ACPI table. It will write the _DOD method (Enumerate All Devices Attached to the Display Adapter) and a device object for each device defined. The device may optionally have a connected privacy screen which can be controlled with a _DSM.
Example: chip drivers/generic/gfx register "device_count" = "1" register "device[0].name" = ""LCD"" register "device[0].addr" = "0x0400" register "device[0].privacy.enabled" = "1" register "device[0].privacy.detect_function" = ""\_SB.PCI0.PVSC.GPVD"" register "device[0].privacy.status_function" = ""\_SB.PCI0.PVSC.GPVX"" register "device[0].privacy.enable_function" = ""\_SB.PCI0.PVSC.EPVX"" register "device[0].privacy.disable_function" = ""\_SB.PCI0.PVSC.DPVX"" device generic 0 on end end
ASL Scope (_SB.PCI0.GFX0) { Method (_DOD, 0, NotSerialized) // _DOD: Display Output Devices { Return (Package (0x01) { 0x00000400 }) }
Device (LCD) { Name (_ADR, 0x0400) // _ADR: Address Name (_STA, 0x0F) // _STA: Status Method (_DSM, 4, Serialized) // _DSM: Device-Specific Method { ToBuffer (Arg0, Local0) If ((Local0 == ToUUID ("c7033113-8720-4ceb-9090-9d52b3e52d73"))) { ToInteger (Arg2, Local1) If ((Local1 == Zero)) { Local2 = _SB.PCI0.PVSC.GPVD () If ((Local2 == One)) { Return (Buffer (One) { 0x0F }) } }
If ((Local1 == One)) { ToBuffer (_SB.PCI0.PVSC.GPVX (), Local2) Return (Local2) }
If ((Local1 == 0x02)) { _SB.PCI0.PVSC.EPVX () }
If ((Local1 == 0x03)) { _SB.PCI0.PVSC.DPVX () }
Return (Buffer (One) { 0x00 }) }
Return (Buffer (One) { 0x00 }) } } }
BUG=b:142237145 TEST=Added gfx to devicetree on sarien_cml and correct ASL in SSDT
Change-Id: Ida520dd7aad81ee7c1e5f2d0d3f5cc1a766d78a0 Signed-off-by: Mathew King mathewk@chromium.org --- A src/drivers/generic/gfx/Kconfig A src/drivers/generic/gfx/Makefile.inc A src/drivers/generic/gfx/chip.h A src/drivers/generic/gfx/gfx.c 4 files changed, 190 insertions(+), 0 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/41/36041/14
Mathew King has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/36041 )
Change subject: drivers/gfx: Add generic graphics with SSDT generator ......................................................................
Patch Set 14:
(2 comments)
https://review.coreboot.org/c/coreboot/+/36041/13//COMMIT_MSG Commit Message:
https://review.coreboot.org/c/coreboot/+/36041/13//COMMIT_MSG@9 PS13, Line 9: This change a
Best to use imperative tense...just say: […]
Done
https://review.coreboot.org/c/coreboot/+/36041/13/src/drivers/generic/gfx/gf... File src/drivers/generic/gfx/gfx.c:
https://review.coreboot.org/c/coreboot/+/36041/13/src/drivers/generic/gfx/gf... PS13, Line 59: privacy_screen_callbacks
Could this become a structure instead of an array? That would let us name each member.
acpigen_write_dsm takes an array of callbacks
Simon Glass has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/36041 )
Change subject: drivers/gfx: Add generic graphics with SSDT generator ......................................................................
Patch Set 14: Code-Review+2
Hello Simon Glass, Rajat Jain, Patrick Rudolph, Duncan Laurie, build bot (Jenkins), Simon Glass, Furquan Shaikh, Patrick Georgi, Martin Roth,
I'd like you to reexamine a change. Please visit
https://review.coreboot.org/c/coreboot/+/36041
to look at the new patch set (#15).
Change subject: drivers/gfx: Add generic graphics with SSDT generator ......................................................................
drivers/gfx: Add generic graphics with SSDT generator
Adds a generic graphics driver that can be added to a devicetree which populates graphics-related ACPI table. It will write the _DOD method (Enumerate All Devices Attached to the Display Adapter) and a device object for each device defined. The device may optionally have a connected privacy screen which can be controlled with a _DSM.
Example: chip drivers/generic/gfx register "device_count" = "1" register "device[0].name" = ""LCD"" register "device[0].addr" = "0x0400" register "device[0].privacy.enabled" = "1" register "device[0].privacy.detect_function" = ""\_SB.PCI0.PVSC.GPVD"" register "device[0].privacy.status_function" = ""\_SB.PCI0.PVSC.GPVX"" register "device[0].privacy.enable_function" = ""\_SB.PCI0.PVSC.EPVX"" register "device[0].privacy.disable_function" = ""\_SB.PCI0.PVSC.DPVX"" device generic 0 on end end
ASL Scope (_SB.PCI0.GFX0) { Method (_DOD, 0, NotSerialized) // _DOD: Display Output Devices { Return (Package (0x01) { 0x00000400 }) }
Device (LCD) { Name (_ADR, 0x0400) // _ADR: Address Name (_STA, 0x0F) // _STA: Status Method (_DSM, 4, Serialized) // _DSM: Device-Specific Method { ToBuffer (Arg0, Local0) If ((Local0 == ToUUID ("c7033113-8720-4ceb-9090-9d52b3e52d73"))) { ToInteger (Arg2, Local1) If ((Local1 == Zero)) { Local2 = _SB.PCI0.PVSC.GPVD () If ((Local2 == One)) { Return (Buffer (One) { 0x0F }) } }
If ((Local1 == One)) { ToBuffer (_SB.PCI0.PVSC.GPVX (), Local2) Return (Local2) }
If ((Local1 == 0x02)) { _SB.PCI0.PVSC.EPVX () }
If ((Local1 == 0x03)) { _SB.PCI0.PVSC.DPVX () }
Return (Buffer (One) { 0x00 }) }
Return (Buffer (One) { 0x00 }) } } }
BUG=b:142237145 TEST=Added gfx to devicetree on sarien_cml and correct ASL in SSDT
Change-Id: Ida520dd7aad81ee7c1e5f2d0d3f5cc1a766d78a0 Signed-off-by: Mathew King mathewk@chromium.org --- A src/drivers/generic/gfx/Kconfig A src/drivers/generic/gfx/Makefile.inc A src/drivers/generic/gfx/chip.h A src/drivers/generic/gfx/gfx.c 4 files changed, 190 insertions(+), 0 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/41/36041/15
Simon Glass has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/36041 )
Change subject: drivers/gfx: Add generic graphics with SSDT generator ......................................................................
Patch Set 15: Code-Review+2
Duncan Laurie has submitted this change. ( https://review.coreboot.org/c/coreboot/+/36041 )
Change subject: drivers/gfx: Add generic graphics with SSDT generator ......................................................................
drivers/gfx: Add generic graphics with SSDT generator
Adds a generic graphics driver that can be added to a devicetree which populates graphics-related ACPI table. It will write the _DOD method (Enumerate All Devices Attached to the Display Adapter) and a device object for each device defined. The device may optionally have a connected privacy screen which can be controlled with a _DSM.
Example: chip drivers/generic/gfx register "device_count" = "1" register "device[0].name" = ""LCD"" register "device[0].addr" = "0x0400" register "device[0].privacy.enabled" = "1" register "device[0].privacy.detect_function" = ""\_SB.PCI0.PVSC.GPVD"" register "device[0].privacy.status_function" = ""\_SB.PCI0.PVSC.GPVX"" register "device[0].privacy.enable_function" = ""\_SB.PCI0.PVSC.EPVX"" register "device[0].privacy.disable_function" = ""\_SB.PCI0.PVSC.DPVX"" device generic 0 on end end
ASL Scope (_SB.PCI0.GFX0) { Method (_DOD, 0, NotSerialized) // _DOD: Display Output Devices { Return (Package (0x01) { 0x00000400 }) }
Device (LCD) { Name (_ADR, 0x0400) // _ADR: Address Name (_STA, 0x0F) // _STA: Status Method (_DSM, 4, Serialized) // _DSM: Device-Specific Method { ToBuffer (Arg0, Local0) If ((Local0 == ToUUID ("c7033113-8720-4ceb-9090-9d52b3e52d73"))) { ToInteger (Arg2, Local1) If ((Local1 == Zero)) { Local2 = _SB.PCI0.PVSC.GPVD () If ((Local2 == One)) { Return (Buffer (One) { 0x0F }) } }
If ((Local1 == One)) { ToBuffer (_SB.PCI0.PVSC.GPVX (), Local2) Return (Local2) }
If ((Local1 == 0x02)) { _SB.PCI0.PVSC.EPVX () }
If ((Local1 == 0x03)) { _SB.PCI0.PVSC.DPVX () }
Return (Buffer (One) { 0x00 }) }
Return (Buffer (One) { 0x00 }) } } }
BUG=b:142237145 TEST=Added gfx to devicetree on sarien_cml and correct ASL in SSDT
Change-Id: Ida520dd7aad81ee7c1e5f2d0d3f5cc1a766d78a0 Signed-off-by: Mathew King mathewk@chromium.org Reviewed-on: https://review.coreboot.org/c/coreboot/+/36041 Reviewed-by: Simon Glass sjg@chromium.org Tested-by: build bot (Jenkins) no-reply@coreboot.org --- A src/drivers/generic/gfx/Kconfig A src/drivers/generic/gfx/Makefile.inc A src/drivers/generic/gfx/chip.h A src/drivers/generic/gfx/gfx.c 4 files changed, 190 insertions(+), 0 deletions(-)
Approvals: build bot (Jenkins): Verified Simon Glass: Looks good to me, approved
diff --git a/src/drivers/generic/gfx/Kconfig b/src/drivers/generic/gfx/Kconfig new file mode 100644 index 0000000..1152f5b --- /dev/null +++ b/src/drivers/generic/gfx/Kconfig @@ -0,0 +1,6 @@ +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 new file mode 100644 index 0000000..c31986b --- /dev/null +++ b/src/drivers/generic/gfx/Makefile.inc @@ -0,0 +1 @@ +ramstage-$(CONFIG_DRIVERS_GENERIC_GFX) += gfx.c diff --git a/src/drivers/generic/gfx/chip.h b/src/drivers/generic/gfx/chip.h new file mode 100644 index 0000000..ee5bd1f --- /dev/null +++ b/src/drivers/generic/gfx/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_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 new file mode 100644 index 0000000..76d311c --- /dev/null +++ b/src/drivers/generic/gfx/gfx.c @@ -0,0 +1,127 @@ +/* + * 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 <arch/acpigen.h> +#include <console/console.h> +#include <device/device.h> +#include <device/pci.h> +#include <device/pci_ids.h> +#include <stdint.h> +#include <string.h> + +#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); + + 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 +};