* [Qemu-devel] [PATCH v5 00/10] Add system_powerdown support on ARM for ACPI and DT
@ 2015-12-11 3:21 Shannon Zhao
2015-12-11 3:21 ` [Qemu-devel] [PATCH v5 01/10] acpi: support serialized method Shannon Zhao
` (10 more replies)
0 siblings, 11 replies; 21+ messages in thread
From: Shannon Zhao @ 2015-12-11 3:21 UTC (permalink / raw)
To: qemu-arm, peter.maydell, imammedo, mst, wei
Cc: peter.huangpeng, zhaoshenglong, qemu-devel, graeme.gregory,
shannon.zhao
From: Shannon Zhao <shannon.zhao@linaro.org>
ACPI SPEC 5.0 defines GPIO-signaled ACPI Events for Hardware-reduced
platforms(like ARM). It uses GPIO pin to trigger an event to the guest.
For QEMU, here we add PL061 GPIO controller and use PIN 3 for
system_powerdown, reserving PIN 0, 1, 2 for PCI hotplug, CPU hotplug and
memory hotplug.
This patchset adds system_powerdown support on ARM through both ACPI and
DT ways. It adds a GPIO controller(here is PL061) in machine virt and
uses GPIO-singled event for ACPI while gpio-keys for DT. It has been
tested for the guests starting by ACPI or DT while guests use systemd or
acpid.
a) ACPI way. Since Graeme send a patchset to make ACPI on ARM64 support
amba device[1], it could use PL061 directly without modification to its
kernel driver code. In addition, we should use ACPI to start VM,
referring to below script. QEMU_EFI.fd can be fetched from [2].
qemu-system-aarch64 \
-smp 1 -m 1024 -M virt \
-cpu cortex-a57 -nographic \
-monitor telnet::4444,server,nowait \
-bios QEMU_EFI.fd \
-kernel Image \
-initrd guestfs.cpio.gz \
-append "rdinit=/sbin/init console=ttyAMA0 mem=512M root=/dev/ram
earlycon=pl011,0x9000000 rw acpi=force"
b) DT way. Start vm as usual.
qemu-system-aarch64 \
-smp 1 -m 1024 -M virt \
-cpu cortex-a57 -nographic \
-monitor telnet::4444,server,nowait \
-kernel Image \
-initrd guestfs.cpio.gz \
-append "rdinit=/sbin/init console=ttyAMA0 mem=512M root=/dev/ram
earlycon=pl011,0x9000000 rw"
Guest internal setup:
If your guest FS uses systemd, you should check file
/lib/udev/rules.d/70-power-switch.rules and add the following line in it
if it doesn't exist.
SUBSYSTEM=="input", KERNEL=="event*", SUBSYSTEMS=="platform",
ATTRS{keys}=="116", TAG+="power-switch"
If your guest FS uses acpid, you should check it has
/etc/acpi/powerbtn.sh and /etc/acpi/events/powerbtn. Refer to [3] for
the setup of acpid.
Thanks,
Shannon
[1] https://lkml.org/lkml/2015/9/30/392
[2] http://people.linaro.org/~shannon.zhao/ACPI_ARM/QEMU_EFI.fd
[3] https://wiki.linaro.org/LEG/Engineering/Kernel/ACPI/GPIOPowerButton
Changes since v4:
* Include two ACPI AML API patches which change the use of those API,
rebase this patch set on top of them
* Use new aml_interrupt() in PATCH 4
* Use new aml_method() and AML_CONSUMER for aml_gpio_int() in PATCH 8
Changes since v3:
* address Igor's comments on ACPI part
* drop "autorepeat" for /gpio-keys
Changes since v2:
* rebased on upstream QEMU
* adjust irq signalling for PowerButton of PATCH 7/8 (Peter Maydell)
* Add several Reviewed-bys and Tested-bys from Wei Huang, thanks!
Changes since v1:
* rewrite GPIO Connection Descriptor (Michael)
Igor Mammedov (1):
acpi: extend aml_interrupt() to support multiple irqs
Shannon Zhao (8):
ARM: Virt: Add a GPIO controller
ARM: ACPI: Add GPIO controller in ACPI DSDT table
ARM: ACPI: Add power button device in ACPI DSDT table
ACPI: Add GPIO Connection Descriptor
ACPI: Add aml_gpio_int() wrapper for GPIO Interrupt Connection
ARM: ACPI: Add _E03 for Power Button
ARM: Virt: Add QEMU powerdown notifier and hook it to GPIO Pin 3
ARM: Virt: Add gpio-keys node for Poweroff using DT
Xiao Guangrong (1):
acpi: support serialized method
hw/acpi/aml-build.c | 127 ++++++++++++++++++++++++++++++++++++++++----
hw/arm/virt-acpi-build.c | 77 +++++++++++++++++++++------
hw/arm/virt.c | 60 +++++++++++++++++++++
hw/i386/acpi-build.c | 41 +++++++-------
include/hw/acpi/aml-build.h | 37 ++++++++++++-
include/hw/arm/virt.h | 1 +
6 files changed, 294 insertions(+), 49 deletions(-)
--
2.0.4
^ permalink raw reply [flat|nested] 21+ messages in thread
* [Qemu-devel] [PATCH v5 01/10] acpi: support serialized method
2015-12-11 3:21 [Qemu-devel] [PATCH v5 00/10] Add system_powerdown support on ARM for ACPI and DT Shannon Zhao
@ 2015-12-11 3:21 ` Shannon Zhao
2015-12-15 16:54 ` Peter Maydell
2015-12-11 3:21 ` [Qemu-devel] [PATCH v5 02/10] acpi: extend aml_interrupt() to support multiple irqs Shannon Zhao
` (9 subsequent siblings)
10 siblings, 1 reply; 21+ messages in thread
From: Shannon Zhao @ 2015-12-11 3:21 UTC (permalink / raw)
To: qemu-arm, peter.maydell, imammedo, mst, wei
Cc: peter.huangpeng, zhaoshenglong, qemu-devel, graeme.gregory,
shannon.zhao
From: Xiao Guangrong <guangrong.xiao@linux.intel.com>
Add serialized method support so that explicit Mutex can be
avoided
Signed-off-by: Xiao Guangrong <guangrong.xiao@linux.intel.com>
Signed-off-by: Igor Mammedov <imammedo@redhat.com>
Reviewed-by: Shannon Zhao <shannon.zhao@linaro.org>
---
hw/acpi/aml-build.c | 17 +++++++++++++++--
hw/arm/virt-acpi-build.c | 10 +++++-----
hw/i386/acpi-build.c | 41 +++++++++++++++++++++--------------------
include/hw/acpi/aml-build.h | 8 +++++++-
4 files changed, 48 insertions(+), 28 deletions(-)
diff --git a/hw/acpi/aml-build.c b/hw/acpi/aml-build.c
index a00a0ab..411c0e5 100644
--- a/hw/acpi/aml-build.c
+++ b/hw/acpi/aml-build.c
@@ -696,11 +696,24 @@ Aml *aml_while(Aml *predicate)
}
/* ACPI 1.0b: 16.2.5.2 Named Objects Encoding: DefMethod */
-Aml *aml_method(const char *name, int arg_count)
+Aml *aml_method(const char *name, int arg_count, AmlSerializeFlag sflag)
{
Aml *var = aml_bundle(0x14 /* MethodOp */, AML_PACKAGE);
+ int methodflags;
+
+ /*
+ * MethodFlags:
+ * bit 0-2: ArgCount (0-7)
+ * bit 3: SerializeFlag
+ * 0: NotSerialized
+ * 1: Serialized
+ * bit 4-7: reserved (must be 0)
+ */
+ assert(arg_count < 8);
+ methodflags = arg_count | (sflag << 3);
+
build_append_namestring(var->buf, "%s", name);
- build_append_byte(var->buf, arg_count); /* MethodFlags: ArgCount */
+ build_append_byte(var->buf, methodflags); /* MethodFlags: ArgCount */
return var;
}
diff --git a/hw/arm/virt-acpi-build.c b/hw/arm/virt-acpi-build.c
index 3c2c5d6..38ab844 100644
--- a/hw/arm/virt-acpi-build.c
+++ b/hw/arm/virt-acpi-build.c
@@ -212,16 +212,16 @@ static void acpi_dsdt_add_pci(Aml *scope, const MemMapEntry *memmap, int irq,
aml_interrupt(AML_CONSUMER, AML_LEVEL, AML_ACTIVE_HIGH,
AML_EXCLUSIVE, irq + i));
aml_append(dev_gsi, aml_name_decl("_CRS", crs));
- method = aml_method("_SRS", 1);
+ method = aml_method("_SRS", 1, AML_NOTSERIALIZED);
aml_append(dev_gsi, method);
aml_append(dev, dev_gsi);
}
- method = aml_method("_CBA", 0);
+ method = aml_method("_CBA", 0, AML_NOTSERIALIZED);
aml_append(method, aml_return(aml_int(base_ecam)));
aml_append(dev, method);
- method = aml_method("_CRS", 0);
+ method = aml_method("_CRS", 0, AML_NOTSERIALIZED);
Aml *rbuf = aml_resource_template();
aml_append(rbuf,
aml_word_bus_number(AML_MIN_FIXED, AML_MAX_FIXED, AML_POS_DECODE,
@@ -254,7 +254,7 @@ static void acpi_dsdt_add_pci(Aml *scope, const MemMapEntry *memmap, int irq,
/* Declare an _OSC (OS Control Handoff) method */
aml_append(dev, aml_name_decl("SUPP", aml_int(0)));
aml_append(dev, aml_name_decl("CTRL", aml_int(0)));
- method = aml_method("_OSC", 4);
+ method = aml_method("_OSC", 4, AML_NOTSERIALIZED);
aml_append(method,
aml_create_dword_field(aml_arg(3), aml_int(0), "CDW1"));
@@ -296,7 +296,7 @@ static void acpi_dsdt_add_pci(Aml *scope, const MemMapEntry *memmap, int irq,
aml_append(method, elsectx);
aml_append(dev, method);
- method = aml_method("_DSM", 4);
+ method = aml_method("_DSM", 4, AML_NOTSERIALIZED);
/* PCI Firmware Specification 3.0
* 4.6.1. _DSM for PCI Express Slot Information
diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c
index 95e0c65..5856329 100644
--- a/hw/i386/acpi-build.c
+++ b/hw/i386/acpi-build.c
@@ -487,7 +487,7 @@ static void build_append_pci_bus_devices(Aml *parent_scope, PCIBus *bus,
int64_t bsel_val = qint_get_int(qobject_to_qint(bsel));
aml_append(parent_scope, aml_name_decl("BSEL", aml_int(bsel_val)));
- notify_method = aml_method("DVNT", 2);
+ notify_method = aml_method("DVNT", 2, AML_NOTSERIALIZED);
}
for (i = 0; i < ARRAY_SIZE(bus->devices); i += PCI_FUNC_MAX) {
@@ -503,7 +503,7 @@ static void build_append_pci_bus_devices(Aml *parent_scope, PCIBus *bus,
dev = aml_device("S%.02X", PCI_DEVFN(slot, 0));
aml_append(dev, aml_name_decl("_SUN", aml_int(slot)));
aml_append(dev, aml_name_decl("_ADR", aml_int(slot << 16)));
- method = aml_method("_EJ0", 1);
+ method = aml_method("_EJ0", 1, AML_NOTSERIALIZED);
aml_append(method,
aml_call2("PCEJ", aml_name("BSEL"), aml_name("_SUN"))
);
@@ -546,22 +546,22 @@ static void build_append_pci_bus_devices(Aml *parent_scope, PCIBus *bus,
s3d = 0;
}
- method = aml_method("_S1D", 0);
+ method = aml_method("_S1D", 0, AML_NOTSERIALIZED);
aml_append(method, aml_return(aml_int(0)));
aml_append(dev, method);
- method = aml_method("_S2D", 0);
+ method = aml_method("_S2D", 0, AML_NOTSERIALIZED);
aml_append(method, aml_return(aml_int(0)));
aml_append(dev, method);
- method = aml_method("_S3D", 0);
+ method = aml_method("_S3D", 0, AML_NOTSERIALIZED);
aml_append(method, aml_return(aml_int(s3d)));
aml_append(dev, method);
} else if (hotplug_enabled_dev) {
/* add _SUN/_EJ0 to make slot hotpluggable */
aml_append(dev, aml_name_decl("_SUN", aml_int(slot)));
- method = aml_method("_EJ0", 1);
+ method = aml_method("_EJ0", 1, AML_NOTSERIALIZED);
aml_append(method,
aml_call2("PCEJ", aml_name("BSEL"), aml_name("_SUN"))
);
@@ -590,7 +590,7 @@ static void build_append_pci_bus_devices(Aml *parent_scope, PCIBus *bus,
/* Append PCNT method to notify about events on local and child buses.
* Add unconditionally for root since DSDT expects it.
*/
- method = aml_method("PCNT", 0);
+ method = aml_method("PCNT", 0, AML_NOTSERIALIZED);
/* If bus supports hotplug select it and notify about local events */
if (bsel) {
@@ -651,7 +651,7 @@ static Aml *build_prt(void)
{
Aml *method, *while_ctx, *pin, *res;
- method = aml_method("_PRT", 0);
+ method = aml_method("_PRT", 0, AML_NOTSERIALIZED);
res = aml_local(0);
pin = aml_local(1);
aml_append(method, aml_store(aml_package(128), res));
@@ -1112,12 +1112,12 @@ build_ssdt(GArray *table_data, GArray *linker,
/* device present, functioning, decoding, shown in UI */
aml_append(dev, aml_name_decl("_STA", aml_int(0xF)));
- method = aml_method("RDPT", 0);
+ method = aml_method("RDPT", 0, AML_NOTSERIALIZED);
aml_append(method, aml_store(aml_name("PEPT"), aml_local(0)));
aml_append(method, aml_return(aml_local(0)));
aml_append(dev, method);
- method = aml_method("WRPT", 1);
+ method = aml_method("WRPT", 1, AML_NOTSERIALIZED);
aml_append(method, aml_store(aml_arg(0), aml_name("PEPT")));
aml_append(dev, method);
@@ -1153,15 +1153,15 @@ build_ssdt(GArray *table_data, GArray *linker,
for (i = 0; i < acpi_cpus; i++) {
dev = aml_processor(i, 0, 0, "CP%.02X", i);
- method = aml_method("_MAT", 0);
+ method = aml_method("_MAT", 0, AML_NOTSERIALIZED);
aml_append(method, aml_return(aml_call1("CPMA", aml_int(i))));
aml_append(dev, method);
- method = aml_method("_STA", 0);
+ method = aml_method("_STA", 0, AML_NOTSERIALIZED);
aml_append(method, aml_return(aml_call1("CPST", aml_int(i))));
aml_append(dev, method);
- method = aml_method("_EJ0", 1);
+ method = aml_method("_EJ0", 1, AML_NOTSERIALIZED);
aml_append(method,
aml_return(aml_call2("CPEJ", aml_int(i), aml_arg(0)))
);
@@ -1174,7 +1174,7 @@ build_ssdt(GArray *table_data, GArray *linker,
* Method(NTFY, 2) {If (LEqual(Arg0, 0x00)) {Notify(CP00, Arg1)} ...}
*/
/* Arg0 = Processor ID = APIC ID */
- method = aml_method("NTFY", 2);
+ method = aml_method("NTFY", 2, AML_NOTSERIALIZED);
for (i = 0; i < acpi_cpus; i++) {
ifctx = aml_if(aml_equal(aml_arg(0), aml_int(i)));
aml_append(ifctx,
@@ -1269,29 +1269,29 @@ build_ssdt(GArray *table_data, GArray *linker,
aml_append(dev, aml_name_decl("_UID", aml_string("0x%02X", i)));
aml_append(dev, aml_name_decl("_HID", aml_eisaid("PNP0C80")));
- method = aml_method("_CRS", 0);
+ method = aml_method("_CRS", 0, AML_NOTSERIALIZED);
s = BASEPATH stringify(MEMORY_SLOT_CRS_METHOD);
aml_append(method, aml_return(aml_call1(s, aml_name("_UID"))));
aml_append(dev, method);
- method = aml_method("_STA", 0);
+ method = aml_method("_STA", 0, AML_NOTSERIALIZED);
s = BASEPATH stringify(MEMORY_SLOT_STATUS_METHOD);
aml_append(method, aml_return(aml_call1(s, aml_name("_UID"))));
aml_append(dev, method);
- method = aml_method("_PXM", 0);
+ method = aml_method("_PXM", 0, AML_NOTSERIALIZED);
s = BASEPATH stringify(MEMORY_SLOT_PROXIMITY_METHOD);
aml_append(method, aml_return(aml_call1(s, aml_name("_UID"))));
aml_append(dev, method);
- method = aml_method("_OST", 3);
+ method = aml_method("_OST", 3, AML_NOTSERIALIZED);
s = BASEPATH stringify(MEMORY_SLOT_OST_METHOD);
aml_append(method, aml_return(aml_call4(
s, aml_name("_UID"), aml_arg(0), aml_arg(1), aml_arg(2)
)));
aml_append(dev, method);
- method = aml_method("_EJ0", 1);
+ method = aml_method("_EJ0", 1, AML_NOTSERIALIZED);
s = BASEPATH stringify(MEMORY_SLOT_EJECT_METHOD);
aml_append(method, aml_return(aml_call2(
s, aml_name("_UID"), aml_arg(0))));
@@ -1303,7 +1303,8 @@ build_ssdt(GArray *table_data, GArray *linker,
/* build Method(MEMORY_SLOT_NOTIFY_METHOD, 2) {
* If (LEqual(Arg0, 0x00)) {Notify(MP00, Arg1)} ... }
*/
- method = aml_method(stringify(MEMORY_SLOT_NOTIFY_METHOD), 2);
+ method = aml_method(stringify(MEMORY_SLOT_NOTIFY_METHOD), 2,
+ AML_NOTSERIALIZED);
for (i = 0; i < nr_mem; i++) {
ifctx = aml_if(aml_equal(aml_arg(0), aml_int(i)));
aml_append(ifctx,
diff --git a/include/hw/acpi/aml-build.h b/include/hw/acpi/aml-build.h
index 1b632dc..a3580e1 100644
--- a/include/hw/acpi/aml-build.h
+++ b/include/hw/acpi/aml-build.h
@@ -148,6 +148,12 @@ typedef enum {
AML_SHARED_AND_WAKE = 3,
} AmlShared;
+/* ACPI 1.0b: 16.2.5.2 Named Objects Encoding: MethodFlags */
+typedef enum {
+ AML_NOTSERIALIZED = 0,
+ AML_SERIALIZED = 1,
+} AmlSerializeFlag;
+
typedef
struct AcpiBuildTables {
GArray *table_data;
@@ -262,7 +268,7 @@ Aml *aml_qword_memory(AmlDecode dec, AmlMinFixed min_fixed,
/* Block AML object primitives */
Aml *aml_scope(const char *name_format, ...) GCC_FMT_ATTR(1, 2);
Aml *aml_device(const char *name_format, ...) GCC_FMT_ATTR(1, 2);
-Aml *aml_method(const char *name, int arg_count);
+Aml *aml_method(const char *name, int arg_count, AmlSerializeFlag sflag);
Aml *aml_if(Aml *predicate);
Aml *aml_else(void);
Aml *aml_while(Aml *predicate);
--
2.0.4
^ permalink raw reply related [flat|nested] 21+ messages in thread
* [Qemu-devel] [PATCH v5 02/10] acpi: extend aml_interrupt() to support multiple irqs
2015-12-11 3:21 [Qemu-devel] [PATCH v5 00/10] Add system_powerdown support on ARM for ACPI and DT Shannon Zhao
2015-12-11 3:21 ` [Qemu-devel] [PATCH v5 01/10] acpi: support serialized method Shannon Zhao
@ 2015-12-11 3:21 ` Shannon Zhao
2015-12-15 16:55 ` Peter Maydell
2015-12-11 3:21 ` [Qemu-devel] [PATCH v5 03/10] ARM: Virt: Add a GPIO controller Shannon Zhao
` (8 subsequent siblings)
10 siblings, 1 reply; 21+ messages in thread
From: Shannon Zhao @ 2015-12-11 3:21 UTC (permalink / raw)
To: qemu-arm, peter.maydell, imammedo, mst, wei
Cc: peter.huangpeng, zhaoshenglong, qemu-devel, graeme.gregory,
shannon.zhao
From: Igor Mammedov <imammedo@redhat.com>
ASL Interrupt() macro translates to Extended Interrupt Descriptor
which supports variable number of IRQs. It will be used for
conversion of ASL code for pc/q35 machines that use it for
returning several IRQs in _PSR object.
Signed-off-by: Igor Mammedov <imammedo@redhat.com>
Reviewed-by: Shannon Zhao <shannon.zhao@linaro.org>
---
hw/acpi/aml-build.c | 22 +++++++++++++---------
hw/arm/virt-acpi-build.c | 23 ++++++++++++-----------
include/hw/acpi/aml-build.h | 2 +-
3 files changed, 26 insertions(+), 21 deletions(-)
diff --git a/hw/acpi/aml-build.c b/hw/acpi/aml-build.c
index 411c0e5..cd25d06 100644
--- a/hw/acpi/aml-build.c
+++ b/hw/acpi/aml-build.c
@@ -598,23 +598,27 @@ Aml *aml_memory32_fixed(uint32_t addr, uint32_t size,
Aml *aml_interrupt(AmlConsumerAndProducer con_and_pro,
AmlLevelAndEdge level_and_edge,
AmlActiveHighAndLow high_and_low, AmlShared shared,
- uint32_t irq)
+ uint32_t *irq_list, uint8_t irq_count)
{
+ int i;
Aml *var = aml_alloc();
uint8_t irq_flags = con_and_pro | (level_and_edge << 1)
| (high_and_low << 2) | (shared << 3);
+ const int header_bytes_in_len = 2;
+ uint16_t len = header_bytes_in_len + irq_count * sizeof(uint32_t);
+
+ assert(irq_count > 0);
build_append_byte(var->buf, 0x89); /* Extended irq descriptor */
- build_append_byte(var->buf, 6); /* Length, bits[7:0] minimum value = 6 */
- build_append_byte(var->buf, 0); /* Length, bits[15:8] minimum value = 0 */
+ build_append_byte(var->buf, len & 0xFF); /* Length, bits[7:0] */
+ build_append_byte(var->buf, len >> 8); /* Length, bits[15:8] */
build_append_byte(var->buf, irq_flags); /* Interrupt Vector Information. */
- build_append_byte(var->buf, 0x01); /* Interrupt table length = 1 */
+ build_append_byte(var->buf, irq_count); /* Interrupt table length */
- /* Interrupt Number */
- build_append_byte(var->buf, extract32(irq, 0, 8)); /* bits[7:0] */
- build_append_byte(var->buf, extract32(irq, 8, 8)); /* bits[15:8] */
- build_append_byte(var->buf, extract32(irq, 16, 8)); /* bits[23:16] */
- build_append_byte(var->buf, extract32(irq, 24, 8)); /* bits[31:24] */
+ /* Interrupt Number List */
+ for (i = 0; i < irq_count; i++) {
+ build_append_int_noprefix(var->buf, irq_list[i], 4);
+ }
return var;
}
diff --git a/hw/arm/virt-acpi-build.c b/hw/arm/virt-acpi-build.c
index 38ab844..1deebfe 100644
--- a/hw/arm/virt-acpi-build.c
+++ b/hw/arm/virt-acpi-build.c
@@ -71,7 +71,7 @@ static void acpi_dsdt_add_cpus(Aml *scope, int smp_cpus)
}
static void acpi_dsdt_add_uart(Aml *scope, const MemMapEntry *uart_memmap,
- int uart_irq)
+ uint32_t uart_irq)
{
Aml *dev = aml_device("COM0");
aml_append(dev, aml_name_decl("_HID", aml_string("ARMH0011")));
@@ -82,7 +82,7 @@ static void acpi_dsdt_add_uart(Aml *scope, const MemMapEntry *uart_memmap,
uart_memmap->size, AML_READ_WRITE));
aml_append(crs,
aml_interrupt(AML_CONSUMER, AML_LEVEL, AML_ACTIVE_HIGH,
- AML_EXCLUSIVE, uart_irq));
+ AML_EXCLUSIVE, &uart_irq, 1));
aml_append(dev, aml_name_decl("_CRS", crs));
/* The _ADR entry is used to link this device to the UART described
@@ -94,7 +94,7 @@ static void acpi_dsdt_add_uart(Aml *scope, const MemMapEntry *uart_memmap,
}
static void acpi_dsdt_add_rtc(Aml *scope, const MemMapEntry *rtc_memmap,
- int rtc_irq)
+ uint32_t rtc_irq)
{
Aml *dev = aml_device("RTC0");
aml_append(dev, aml_name_decl("_HID", aml_string("LNRO0013")));
@@ -105,7 +105,7 @@ static void acpi_dsdt_add_rtc(Aml *scope, const MemMapEntry *rtc_memmap,
rtc_memmap->size, AML_READ_WRITE));
aml_append(crs,
aml_interrupt(AML_CONSUMER, AML_LEVEL, AML_ACTIVE_HIGH,
- AML_EXCLUSIVE, rtc_irq));
+ AML_EXCLUSIVE, &rtc_irq, 1));
aml_append(dev, aml_name_decl("_CRS", crs));
aml_append(scope, dev);
}
@@ -136,14 +136,14 @@ static void acpi_dsdt_add_flash(Aml *scope, const MemMapEntry *flash_memmap)
static void acpi_dsdt_add_virtio(Aml *scope,
const MemMapEntry *virtio_mmio_memmap,
- int mmio_irq, int num)
+ uint32_t mmio_irq, int num)
{
hwaddr base = virtio_mmio_memmap->base;
hwaddr size = virtio_mmio_memmap->size;
- int irq = mmio_irq;
int i;
for (i = 0; i < num; i++) {
+ uint32_t irq = mmio_irq + i;
Aml *dev = aml_device("VR%02u", i);
aml_append(dev, aml_name_decl("_HID", aml_string("LNRO0005")));
aml_append(dev, aml_name_decl("_UID", aml_int(i)));
@@ -152,15 +152,15 @@ static void acpi_dsdt_add_virtio(Aml *scope,
aml_append(crs, aml_memory32_fixed(base, size, AML_READ_WRITE));
aml_append(crs,
aml_interrupt(AML_CONSUMER, AML_LEVEL, AML_ACTIVE_HIGH,
- AML_EXCLUSIVE, irq + i));
+ AML_EXCLUSIVE, &irq, 1));
aml_append(dev, aml_name_decl("_CRS", crs));
aml_append(scope, dev);
base += size;
}
}
-static void acpi_dsdt_add_pci(Aml *scope, const MemMapEntry *memmap, int irq,
- bool use_highmem)
+static void acpi_dsdt_add_pci(Aml *scope, const MemMapEntry *memmap,
+ uint32_t irq, bool use_highmem)
{
Aml *method, *crs, *ifctx, *UUID, *ifctx1, *elsectx, *buf;
int i, bus_no;
@@ -199,18 +199,19 @@ static void acpi_dsdt_add_pci(Aml *scope, const MemMapEntry *memmap, int irq,
/* Create GSI link device */
for (i = 0; i < PCI_NUM_PINS; i++) {
+ uint32_t irqs = irq + i;
Aml *dev_gsi = aml_device("GSI%d", i);
aml_append(dev_gsi, aml_name_decl("_HID", aml_string("PNP0C0F")));
aml_append(dev_gsi, aml_name_decl("_UID", aml_int(0)));
crs = aml_resource_template();
aml_append(crs,
aml_interrupt(AML_CONSUMER, AML_LEVEL, AML_ACTIVE_HIGH,
- AML_EXCLUSIVE, irq + i));
+ AML_EXCLUSIVE, &irqs, 1));
aml_append(dev_gsi, aml_name_decl("_PRS", crs));
crs = aml_resource_template();
aml_append(crs,
aml_interrupt(AML_CONSUMER, AML_LEVEL, AML_ACTIVE_HIGH,
- AML_EXCLUSIVE, irq + i));
+ AML_EXCLUSIVE, &irqs, 1));
aml_append(dev_gsi, aml_name_decl("_CRS", crs));
method = aml_method("_SRS", 1, AML_NOTSERIALIZED);
aml_append(dev_gsi, method);
diff --git a/include/hw/acpi/aml-build.h b/include/hw/acpi/aml-build.h
index a3580e1..c2c0be3 100644
--- a/include/hw/acpi/aml-build.h
+++ b/include/hw/acpi/aml-build.h
@@ -223,7 +223,7 @@ Aml *aml_memory32_fixed(uint32_t addr, uint32_t size,
Aml *aml_interrupt(AmlConsumerAndProducer con_and_pro,
AmlLevelAndEdge level_and_edge,
AmlActiveHighAndLow high_and_low, AmlShared shared,
- uint32_t irq);
+ uint32_t *irq_list, uint8_t irq_count);
Aml *aml_io(AmlIODecode dec, uint16_t min_base, uint16_t max_base,
uint8_t aln, uint8_t len);
Aml *aml_operation_region(const char *name, AmlRegionSpace rs,
--
2.0.4
^ permalink raw reply related [flat|nested] 21+ messages in thread
* [Qemu-devel] [PATCH v5 03/10] ARM: Virt: Add a GPIO controller
2015-12-11 3:21 [Qemu-devel] [PATCH v5 00/10] Add system_powerdown support on ARM for ACPI and DT Shannon Zhao
2015-12-11 3:21 ` [Qemu-devel] [PATCH v5 01/10] acpi: support serialized method Shannon Zhao
2015-12-11 3:21 ` [Qemu-devel] [PATCH v5 02/10] acpi: extend aml_interrupt() to support multiple irqs Shannon Zhao
@ 2015-12-11 3:21 ` Shannon Zhao
2015-12-11 3:21 ` [Qemu-devel] [PATCH v5 04/10] ARM: ACPI: Add GPIO controller in ACPI DSDT table Shannon Zhao
` (7 subsequent siblings)
10 siblings, 0 replies; 21+ messages in thread
From: Shannon Zhao @ 2015-12-11 3:21 UTC (permalink / raw)
To: qemu-arm, peter.maydell, imammedo, mst, wei
Cc: peter.huangpeng, zhaoshenglong, qemu-devel, graeme.gregory,
shannon.zhao
From: Shannon Zhao <shannon.zhao@linaro.org>
ACPI 5.0 supports GPIO-signaled ACPI Events. This can be used for
powerdown, hotplug evnets. Add a GPIO controller in machine virt,
to support powerdown, maybe can be used for cpu hotplug. And
here we use pl061.
Signed-off-by: Shannon Zhao <zhaoshenglong@huawei.com>
Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
Reviewed-by: Wei Huang <wei@redhat.com>
Tested-by: Wei Huang <wei@redhat.com>
---
hw/arm/virt.c | 30 ++++++++++++++++++++++++++++++
include/hw/arm/virt.h | 1 +
2 files changed, 31 insertions(+)
diff --git a/hw/arm/virt.c b/hw/arm/virt.c
index 9c6792c..7977e3c 100644
--- a/hw/arm/virt.c
+++ b/hw/arm/virt.c
@@ -120,6 +120,7 @@ static const MemMapEntry a15memmap[] = {
[VIRT_UART] = { 0x09000000, 0x00001000 },
[VIRT_RTC] = { 0x09010000, 0x00001000 },
[VIRT_FW_CFG] = { 0x09020000, 0x00000018 },
+ [VIRT_GPIO] = { 0x09030000, 0x00001000 },
[VIRT_MMIO] = { 0x0a000000, 0x00000200 },
/* ...repeating for a total of NUM_VIRTIO_TRANSPORTS, each of that size */
[VIRT_PLATFORM_BUS] = { 0x0c000000, 0x02000000 },
@@ -135,6 +136,7 @@ static const int a15irqmap[] = {
[VIRT_UART] = 1,
[VIRT_RTC] = 2,
[VIRT_PCIE] = 3, /* ... to 6 */
+ [VIRT_GPIO] = 7,
[VIRT_MMIO] = 16, /* ...to 16 + NUM_VIRTIO_TRANSPORTS - 1 */
[VIRT_GIC_V2M] = 48, /* ...to 48 + NUM_GICV2M_SPIS - 1 */
[VIRT_PLATFORM_BUS] = 112, /* ...to 112 + PLATFORM_BUS_NUM_IRQS -1 */
@@ -538,6 +540,32 @@ static void create_rtc(const VirtBoardInfo *vbi, qemu_irq *pic)
g_free(nodename);
}
+static void create_gpio(const VirtBoardInfo *vbi, qemu_irq *pic)
+{
+ char *nodename;
+ hwaddr base = vbi->memmap[VIRT_GPIO].base;
+ hwaddr size = vbi->memmap[VIRT_GPIO].size;
+ int irq = vbi->irqmap[VIRT_GPIO];
+ const char compat[] = "arm,pl061\0arm,primecell";
+
+ sysbus_create_simple("pl061", base, pic[irq]);
+
+ nodename = g_strdup_printf("/pl061@%" PRIx64, base);
+ qemu_fdt_add_subnode(vbi->fdt, nodename);
+ qemu_fdt_setprop_sized_cells(vbi->fdt, nodename, "reg",
+ 2, base, 2, size);
+ qemu_fdt_setprop(vbi->fdt, nodename, "compatible", compat, sizeof(compat));
+ qemu_fdt_setprop_cell(vbi->fdt, nodename, "#gpio-cells", 2);
+ qemu_fdt_setprop(vbi->fdt, nodename, "gpio-controller", NULL, 0);
+ qemu_fdt_setprop_cells(vbi->fdt, nodename, "interrupts",
+ GIC_FDT_IRQ_TYPE_SPI, irq,
+ GIC_FDT_IRQ_FLAGS_LEVEL_HI);
+ qemu_fdt_setprop_cell(vbi->fdt, nodename, "clocks", vbi->clock_phandle);
+ qemu_fdt_setprop_string(vbi->fdt, nodename, "clock-names", "apb_pclk");
+
+ g_free(nodename);
+}
+
static void create_virtio_devices(const VirtBoardInfo *vbi, qemu_irq *pic)
{
int i;
@@ -1041,6 +1069,8 @@ static void machvirt_init(MachineState *machine)
create_pcie(vbi, pic, vms->highmem);
+ create_gpio(vbi, pic);
+
/* Create mmio transports, so the user can create virtio backends
* (which will be automatically plugged in to the transports). If
* no backend is created the transport will just sit harmlessly idle.
diff --git a/include/hw/arm/virt.h b/include/hw/arm/virt.h
index f464586..925faa7 100644
--- a/include/hw/arm/virt.h
+++ b/include/hw/arm/virt.h
@@ -59,6 +59,7 @@ enum {
VIRT_PCIE_ECAM,
VIRT_PLATFORM_BUS,
VIRT_PCIE_MMIO_HIGH,
+ VIRT_GPIO,
};
typedef struct MemMapEntry {
--
2.0.4
^ permalink raw reply related [flat|nested] 21+ messages in thread
* [Qemu-devel] [PATCH v5 04/10] ARM: ACPI: Add GPIO controller in ACPI DSDT table
2015-12-11 3:21 [Qemu-devel] [PATCH v5 00/10] Add system_powerdown support on ARM for ACPI and DT Shannon Zhao
` (2 preceding siblings ...)
2015-12-11 3:21 ` [Qemu-devel] [PATCH v5 03/10] ARM: Virt: Add a GPIO controller Shannon Zhao
@ 2015-12-11 3:21 ` Shannon Zhao
2015-12-16 15:48 ` Igor Mammedov
2015-12-11 3:21 ` [Qemu-devel] [PATCH v5 05/10] ARM: ACPI: Add power button device " Shannon Zhao
` (6 subsequent siblings)
10 siblings, 1 reply; 21+ messages in thread
From: Shannon Zhao @ 2015-12-11 3:21 UTC (permalink / raw)
To: qemu-arm, peter.maydell, imammedo, mst, wei
Cc: peter.huangpeng, zhaoshenglong, qemu-devel, graeme.gregory,
shannon.zhao
From: Shannon Zhao <shannon.zhao@linaro.org>
Add GPIO controller in ACPI DSDT table. It can be used for gpio event.
Signed-off-by: Shannon Zhao <zhaoshenglong@huawei.com>
Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
Tested-by: Wei Huang <wei@redhat.com>
---
hw/arm/virt-acpi-build.c | 19 +++++++++++++++++++
1 file changed, 19 insertions(+)
diff --git a/hw/arm/virt-acpi-build.c b/hw/arm/virt-acpi-build.c
index 1deebfe..fcc08f7 100644
--- a/hw/arm/virt-acpi-build.c
+++ b/hw/arm/virt-acpi-build.c
@@ -324,6 +324,23 @@ static void acpi_dsdt_add_pci(Aml *scope, const MemMapEntry *memmap,
aml_append(scope, dev);
}
+static void acpi_dsdt_add_gpio(Aml *scope, const MemMapEntry *gpio_memmap,
+ uint32_t gpio_irq)
+{
+ Aml *dev = aml_device("GPO0");
+ aml_append(dev, aml_name_decl("_HID", aml_string("ARMH0061")));
+ aml_append(dev, aml_name_decl("_ADR", aml_int(0)));
+ aml_append(dev, aml_name_decl("_UID", aml_int(0)));
+
+ Aml *crs = aml_resource_template();
+ aml_append(crs, aml_memory32_fixed(gpio_memmap->base, gpio_memmap->size,
+ AML_READ_WRITE));
+ aml_append(crs, aml_interrupt(AML_CONSUMER, AML_LEVEL, AML_ACTIVE_HIGH,
+ AML_EXCLUSIVE, &gpio_irq, 1));
+ aml_append(dev, aml_name_decl("_CRS", crs));
+ aml_append(scope, dev);
+}
+
/* RSDP */
static GArray *
build_rsdp(GArray *rsdp_table, GArray *linker, unsigned rsdt)
@@ -540,6 +557,8 @@ build_dsdt(GArray *table_data, GArray *linker, VirtGuestInfo *guest_info)
(irqmap[VIRT_MMIO] + ARM_SPI_BASE), NUM_VIRTIO_TRANSPORTS);
acpi_dsdt_add_pci(scope, memmap, (irqmap[VIRT_PCIE] + ARM_SPI_BASE),
guest_info->use_highmem);
+ acpi_dsdt_add_gpio(scope, &memmap[VIRT_GPIO],
+ (irqmap[VIRT_GPIO] + ARM_SPI_BASE));
aml_append(dsdt, scope);
--
2.0.4
^ permalink raw reply related [flat|nested] 21+ messages in thread
* [Qemu-devel] [PATCH v5 05/10] ARM: ACPI: Add power button device in ACPI DSDT table
2015-12-11 3:21 [Qemu-devel] [PATCH v5 00/10] Add system_powerdown support on ARM for ACPI and DT Shannon Zhao
` (3 preceding siblings ...)
2015-12-11 3:21 ` [Qemu-devel] [PATCH v5 04/10] ARM: ACPI: Add GPIO controller in ACPI DSDT table Shannon Zhao
@ 2015-12-11 3:21 ` Shannon Zhao
2015-12-11 3:21 ` [Qemu-devel] [PATCH v5 06/10] ACPI: Add GPIO Connection Descriptor Shannon Zhao
` (5 subsequent siblings)
10 siblings, 0 replies; 21+ messages in thread
From: Shannon Zhao @ 2015-12-11 3:21 UTC (permalink / raw)
To: qemu-arm, peter.maydell, imammedo, mst, wei
Cc: peter.huangpeng, zhaoshenglong, qemu-devel, graeme.gregory,
shannon.zhao
From: Shannon Zhao <shannon.zhao@linaro.org>
Add power button device in ACPI DSDT table.
Signed-off-by: Shannon Zhao <zhaoshenglong@huawei.com>
Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
Reviewed-by: Wei Huang <wei@redhat.com>
Tested-by: Wei Huang <wei@redhat.com>
Reviewed-by: Igor Mammedov <imammedo@redhat.com>
---
hw/arm/virt-acpi-build.c | 11 +++++++++++
1 file changed, 11 insertions(+)
diff --git a/hw/arm/virt-acpi-build.c b/hw/arm/virt-acpi-build.c
index fcc08f7..e5dc2d5 100644
--- a/hw/arm/virt-acpi-build.c
+++ b/hw/arm/virt-acpi-build.c
@@ -43,6 +43,7 @@
#include "hw/pci/pci.h"
#define ARM_SPI_BASE 32
+#define ACPI_POWER_BUTTON_DEVICE "PWRB"
typedef struct VirtAcpiCpuInfo {
DECLARE_BITMAP(found_cpus, VIRT_ACPI_CPU_ID_LIMIT);
@@ -341,6 +342,15 @@ static void acpi_dsdt_add_gpio(Aml *scope, const MemMapEntry *gpio_memmap,
aml_append(scope, dev);
}
+static void acpi_dsdt_add_power_button(Aml *scope)
+{
+ Aml *dev = aml_device(ACPI_POWER_BUTTON_DEVICE);
+ aml_append(dev, aml_name_decl("_HID", aml_string("PNP0C0C")));
+ aml_append(dev, aml_name_decl("_ADR", aml_int(0)));
+ aml_append(dev, aml_name_decl("_UID", aml_int(0)));
+ aml_append(scope, dev);
+}
+
/* RSDP */
static GArray *
build_rsdp(GArray *rsdp_table, GArray *linker, unsigned rsdt)
@@ -559,6 +569,7 @@ build_dsdt(GArray *table_data, GArray *linker, VirtGuestInfo *guest_info)
guest_info->use_highmem);
acpi_dsdt_add_gpio(scope, &memmap[VIRT_GPIO],
(irqmap[VIRT_GPIO] + ARM_SPI_BASE));
+ acpi_dsdt_add_power_button(scope);
aml_append(dsdt, scope);
--
2.0.4
^ permalink raw reply related [flat|nested] 21+ messages in thread
* [Qemu-devel] [PATCH v5 06/10] ACPI: Add GPIO Connection Descriptor
2015-12-11 3:21 [Qemu-devel] [PATCH v5 00/10] Add system_powerdown support on ARM for ACPI and DT Shannon Zhao
` (4 preceding siblings ...)
2015-12-11 3:21 ` [Qemu-devel] [PATCH v5 05/10] ARM: ACPI: Add power button device " Shannon Zhao
@ 2015-12-11 3:21 ` Shannon Zhao
2015-12-11 3:21 ` [Qemu-devel] [PATCH v5 07/10] ACPI: Add aml_gpio_int() wrapper for GPIO Interrupt Connection Shannon Zhao
` (4 subsequent siblings)
10 siblings, 0 replies; 21+ messages in thread
From: Shannon Zhao @ 2015-12-11 3:21 UTC (permalink / raw)
To: qemu-arm, peter.maydell, imammedo, mst, wei
Cc: peter.huangpeng, zhaoshenglong, qemu-devel, graeme.gregory,
shannon.zhao
From: Shannon Zhao <shannon.zhao@linaro.org>
Signed-off-by: Shannon Zhao <zhaoshenglong@huawei.com>
Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
Tested-by: Wei Huang <wei@redhat.com>
Reviewed-by: Igor Mammedov <imammedo@redhat.com>
---
hw/acpi/aml-build.c | 68 +++++++++++++++++++++++++++++++++++++++++++++
include/hw/acpi/aml-build.h | 20 +++++++++++++
2 files changed, 88 insertions(+)
diff --git a/hw/acpi/aml-build.c b/hw/acpi/aml-build.c
index cd25d06..d8c33a2 100644
--- a/hw/acpi/aml-build.c
+++ b/hw/acpi/aml-build.c
@@ -565,6 +565,74 @@ Aml *aml_call4(const char *method, Aml *arg1, Aml *arg2, Aml *arg3, Aml *arg4)
}
/*
+ * ACPI 5.0: 6.4.3.8.1 GPIO Connection Descriptor
+ * Type 1, Large Item Name 0xC
+ */
+
+static Aml *aml_gpio_connection(AmlGpioConnectionType type,
+ AmlConsumerAndProducer con_and_pro,
+ uint8_t flags, AmlPinConfig pin_config,
+ uint16_t output_drive,
+ uint16_t debounce_timeout,
+ const uint32_t pin_list[], uint32_t pin_count,
+ const char *resource_source_name,
+ const uint8_t *vendor_data,
+ uint16_t vendor_data_len)
+{
+ Aml *var = aml_alloc();
+ const uint16_t min_desc_len = 0x16;
+ uint16_t resource_source_name_len, length;
+ uint16_t pin_table_offset, resource_source_name_offset, vendor_data_offset;
+ uint32_t i;
+
+ assert(resource_source_name);
+ resource_source_name_len = strlen(resource_source_name) + 1;
+ length = min_desc_len + resource_source_name_len + vendor_data_len;
+ pin_table_offset = min_desc_len + 1;
+ resource_source_name_offset = pin_table_offset + pin_count * 2;
+ vendor_data_offset = resource_source_name_offset + resource_source_name_len;
+
+ build_append_byte(var->buf, 0x8C); /* GPIO Connection Descriptor */
+ build_append_int_noprefix(var->buf, length, 2); /* Length */
+ build_append_byte(var->buf, 1); /* Revision ID */
+ build_append_byte(var->buf, type); /* GPIO Connection Type */
+ /* General Flags (2 bytes) */
+ build_append_int_noprefix(var->buf, con_and_pro, 2);
+ /* Interrupt and IO Flags (2 bytes) */
+ build_append_int_noprefix(var->buf, flags, 2);
+ /* Pin Configuration 0 = Default 1 = Pull-up 2 = Pull-down 3 = No Pull */
+ build_append_byte(var->buf, pin_config);
+ /* Output Drive Strength (2 bytes) */
+ build_append_int_noprefix(var->buf, output_drive, 2);
+ /* Debounce Timeout (2 bytes) */
+ build_append_int_noprefix(var->buf, debounce_timeout, 2);
+ /* Pin Table Offset (2 bytes) */
+ build_append_int_noprefix(var->buf, pin_table_offset, 2);
+ build_append_byte(var->buf, 0); /* Resource Source Index */
+ /* Resource Source Name Offset (2 bytes) */
+ build_append_int_noprefix(var->buf, resource_source_name_offset, 2);
+ /* Vendor Data Offset (2 bytes) */
+ build_append_int_noprefix(var->buf, vendor_data_offset, 2);
+ /* Vendor Data Length (2 bytes) */
+ build_append_int_noprefix(var->buf, vendor_data_len, 2);
+ /* Pin Number (2n bytes)*/
+ for (i = 0; i < pin_count; i++) {
+ build_append_int_noprefix(var->buf, pin_list[i], 2);
+ }
+
+ /* Resource Source Name */
+ build_append_namestring(var->buf, "%s", resource_source_name);
+ build_append_byte(var->buf, '\0');
+
+ /* Vendor-defined Data */
+ if (vendor_data != NULL) {
+ g_array_append_vals(var->buf, vendor_data, vendor_data_len);
+ }
+
+ return var;
+}
+
+/*
* ACPI 1.0b: 6.4.3.4 32-Bit Fixed Location Memory Range Descriptor
* (Type 1, Large Item Name 0x6)
*/
diff --git a/include/hw/acpi/aml-build.h b/include/hw/acpi/aml-build.h
index c2c0be3..f1817e4 100644
--- a/include/hw/acpi/aml-build.h
+++ b/include/hw/acpi/aml-build.h
@@ -154,6 +154,26 @@ typedef enum {
AML_SERIALIZED = 1,
} AmlSerializeFlag;
+/*
+ * ACPI 5.0: Table 6-189 GPIO Connection Descriptor Definition
+ * GPIO Connection Type
+ */
+typedef enum {
+ AML_INTERRUPT_CONNECTION = 0,
+ AML_IO_CONNECTION = 1,
+} AmlGpioConnectionType;
+
+/*
+ * ACPI 5.0: Table 6-189 GPIO Connection Descriptor Definition
+ * _PPI field definition
+ */
+typedef enum {
+ AML_PULL_DEFAULT = 0,
+ AML_PULL_UP = 1,
+ AML_PULL_DOWN = 2,
+ AML_PULL_NONE = 3,
+} AmlPinConfig;
+
typedef
struct AcpiBuildTables {
GArray *table_data;
--
2.0.4
^ permalink raw reply related [flat|nested] 21+ messages in thread
* [Qemu-devel] [PATCH v5 07/10] ACPI: Add aml_gpio_int() wrapper for GPIO Interrupt Connection
2015-12-11 3:21 [Qemu-devel] [PATCH v5 00/10] Add system_powerdown support on ARM for ACPI and DT Shannon Zhao
` (5 preceding siblings ...)
2015-12-11 3:21 ` [Qemu-devel] [PATCH v5 06/10] ACPI: Add GPIO Connection Descriptor Shannon Zhao
@ 2015-12-11 3:21 ` Shannon Zhao
2015-12-11 3:21 ` [Qemu-devel] [PATCH v5 08/10] ARM: ACPI: Add _E03 for Power Button Shannon Zhao
` (3 subsequent siblings)
10 siblings, 0 replies; 21+ messages in thread
From: Shannon Zhao @ 2015-12-11 3:21 UTC (permalink / raw)
To: qemu-arm, peter.maydell, imammedo, mst, wei
Cc: peter.huangpeng, zhaoshenglong, qemu-devel, graeme.gregory,
shannon.zhao
From: Shannon Zhao <shannon.zhao@linaro.org>
Signed-off-by: Shannon Zhao <zhaoshenglong@huawei.com>
Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
Tested-by: Wei Huang <wei@redhat.com>
Reviewed-by: Igor Mammedov <imammedo@redhat.com>
---
hw/acpi/aml-build.c | 20 ++++++++++++++++++++
include/hw/acpi/aml-build.h | 7 +++++++
2 files changed, 27 insertions(+)
diff --git a/hw/acpi/aml-build.c b/hw/acpi/aml-build.c
index d8c33a2..302cf01 100644
--- a/hw/acpi/aml-build.c
+++ b/hw/acpi/aml-build.c
@@ -633,6 +633,26 @@ static Aml *aml_gpio_connection(AmlGpioConnectionType type,
}
/*
+ * ACPI 5.0: 19.5.53
+ * GpioInt(GPIO Interrupt Connection Resource Descriptor Macro)
+ */
+Aml *aml_gpio_int(AmlConsumerAndProducer con_and_pro,
+ AmlLevelAndEdge edge_level,
+ AmlActiveHighAndLow active_level, AmlShared shared,
+ AmlPinConfig pin_config, uint16_t debounce_timeout,
+ const uint32_t pin_list[], uint32_t pin_count,
+ const char *resource_source_name,
+ const uint8_t *vendor_data, uint16_t vendor_data_len)
+{
+ uint8_t flags = edge_level | (active_level << 1) | (shared << 3);
+
+ return aml_gpio_connection(AML_INTERRUPT_CONNECTION, con_and_pro, flags,
+ pin_config, 0, debounce_timeout, pin_list,
+ pin_count, resource_source_name, vendor_data,
+ vendor_data_len);
+}
+
+/*
* ACPI 1.0b: 6.4.3.4 32-Bit Fixed Location Memory Range Descriptor
* (Type 1, Large Item Name 0x6)
*/
diff --git a/include/hw/acpi/aml-build.h b/include/hw/acpi/aml-build.h
index f1817e4..0d36453 100644
--- a/include/hw/acpi/aml-build.h
+++ b/include/hw/acpi/aml-build.h
@@ -238,6 +238,13 @@ Aml *aml_call1(const char *method, Aml *arg1);
Aml *aml_call2(const char *method, Aml *arg1, Aml *arg2);
Aml *aml_call3(const char *method, Aml *arg1, Aml *arg2, Aml *arg3);
Aml *aml_call4(const char *method, Aml *arg1, Aml *arg2, Aml *arg3, Aml *arg4);
+Aml *aml_gpio_int(AmlConsumerAndProducer con_and_pro,
+ AmlLevelAndEdge edge_level,
+ AmlActiveHighAndLow active_level, AmlShared shared,
+ AmlPinConfig pin_config, uint16_t debounce_timeout,
+ const uint32_t pin_list[], uint32_t pin_count,
+ const char *resource_source_name,
+ const uint8_t *vendor_data, uint16_t vendor_data_len);
Aml *aml_memory32_fixed(uint32_t addr, uint32_t size,
AmlReadAndWrite read_and_write);
Aml *aml_interrupt(AmlConsumerAndProducer con_and_pro,
--
2.0.4
^ permalink raw reply related [flat|nested] 21+ messages in thread
* [Qemu-devel] [PATCH v5 08/10] ARM: ACPI: Add _E03 for Power Button
2015-12-11 3:21 [Qemu-devel] [PATCH v5 00/10] Add system_powerdown support on ARM for ACPI and DT Shannon Zhao
` (6 preceding siblings ...)
2015-12-11 3:21 ` [Qemu-devel] [PATCH v5 07/10] ACPI: Add aml_gpio_int() wrapper for GPIO Interrupt Connection Shannon Zhao
@ 2015-12-11 3:21 ` Shannon Zhao
2015-12-16 15:51 ` Igor Mammedov
2015-12-11 3:21 ` [Qemu-devel] [PATCH v5 09/10] ARM: Virt: Add QEMU powerdown notifier and hook it to GPIO Pin 3 Shannon Zhao
` (2 subsequent siblings)
10 siblings, 1 reply; 21+ messages in thread
From: Shannon Zhao @ 2015-12-11 3:21 UTC (permalink / raw)
To: qemu-arm, peter.maydell, imammedo, mst, wei
Cc: peter.huangpeng, zhaoshenglong, qemu-devel, graeme.gregory,
shannon.zhao
From: Shannon Zhao <shannon.zhao@linaro.org>
Here GPIO pin 3 is used for Power Button, add _E03 in ACPI DSDT table.
Signed-off-by: Shannon Zhao <zhaoshenglong@huawei.com>
Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
Tested-by: Wei Huang <wei@redhat.com>
---
hw/arm/virt-acpi-build.c | 14 ++++++++++++++
1 file changed, 14 insertions(+)
diff --git a/hw/arm/virt-acpi-build.c b/hw/arm/virt-acpi-build.c
index e5dc2d5..1ffff62 100644
--- a/hw/arm/virt-acpi-build.c
+++ b/hw/arm/virt-acpi-build.c
@@ -339,6 +339,20 @@ static void acpi_dsdt_add_gpio(Aml *scope, const MemMapEntry *gpio_memmap,
aml_append(crs, aml_interrupt(AML_CONSUMER, AML_LEVEL, AML_ACTIVE_HIGH,
AML_EXCLUSIVE, &gpio_irq, 1));
aml_append(dev, aml_name_decl("_CRS", crs));
+
+ Aml *aei = aml_resource_template();
+ /* Pin 3 for power button */
+ const uint32_t pin_list[1] = {3};
+ aml_append(aei, aml_gpio_int(AML_CONSUMER, AML_EDGE, AML_ACTIVE_HIGH,
+ AML_EXCLUSIVE, AML_PULL_UP, 0, pin_list, 1,
+ "GPO0", NULL, 0));
+ aml_append(dev, aml_name_decl("_AEI", aei));
+
+ /* _E03 is handle for power button */
+ Aml *method = aml_method("_E03", 0, AML_NOTSERIALIZED);
+ aml_append(method, aml_notify(aml_name(ACPI_POWER_BUTTON_DEVICE),
+ aml_int(0x80)));
+ aml_append(dev, method);
aml_append(scope, dev);
}
--
2.0.4
^ permalink raw reply related [flat|nested] 21+ messages in thread
* [Qemu-devel] [PATCH v5 09/10] ARM: Virt: Add QEMU powerdown notifier and hook it to GPIO Pin 3
2015-12-11 3:21 [Qemu-devel] [PATCH v5 00/10] Add system_powerdown support on ARM for ACPI and DT Shannon Zhao
` (7 preceding siblings ...)
2015-12-11 3:21 ` [Qemu-devel] [PATCH v5 08/10] ARM: ACPI: Add _E03 for Power Button Shannon Zhao
@ 2015-12-11 3:21 ` Shannon Zhao
2015-12-11 3:21 ` [Qemu-devel] [PATCH v5 10/10] ARM: Virt: Add gpio-keys node for Poweroff using DT Shannon Zhao
2015-12-15 18:36 ` [Qemu-devel] [PATCH v5 00/10] Add system_powerdown support on ARM for ACPI and DT Peter Maydell
10 siblings, 0 replies; 21+ messages in thread
From: Shannon Zhao @ 2015-12-11 3:21 UTC (permalink / raw)
To: qemu-arm, peter.maydell, imammedo, mst, wei
Cc: peter.huangpeng, zhaoshenglong, qemu-devel, graeme.gregory,
shannon.zhao
From: Shannon Zhao <shannon.zhao@linaro.org>
Currently mach-virt model doesn't support powerdown request. Guest VM
doesn't react to system_powerdown from monitor console (or QMP) because
there is no communication mechanism for such requests. This patch registers
GPIO Pin 3 with powerdown notification. So guest VM can receive notification
when such powerdown request is triggered.
Signed-off-by: Wei Huang <wei@redhat.com>
Signed-off-by: Shannon Zhao <zhaoshenglong@huawei.com>
Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
Reviewed-by: Wei Huang <wei@redhat.com>
Tested-by: Wei Huang <wei@redhat.com>
---
hw/arm/virt.c | 16 +++++++++++++++-
1 file changed, 15 insertions(+), 1 deletion(-)
diff --git a/hw/arm/virt.c b/hw/arm/virt.c
index 7977e3c..cb1d45b 100644
--- a/hw/arm/virt.c
+++ b/hw/arm/virt.c
@@ -540,6 +540,17 @@ static void create_rtc(const VirtBoardInfo *vbi, qemu_irq *pic)
g_free(nodename);
}
+static DeviceState *pl061_dev;
+static void virt_powerdown_req(Notifier *n, void *opaque)
+{
+ /* use gpio Pin 3 for power button event */
+ qemu_set_irq(qdev_get_gpio_in(pl061_dev, 3), 1);
+}
+
+static Notifier virt_system_powerdown_notifier = {
+ .notify = virt_powerdown_req
+};
+
static void create_gpio(const VirtBoardInfo *vbi, qemu_irq *pic)
{
char *nodename;
@@ -548,7 +559,7 @@ static void create_gpio(const VirtBoardInfo *vbi, qemu_irq *pic)
int irq = vbi->irqmap[VIRT_GPIO];
const char compat[] = "arm,pl061\0arm,primecell";
- sysbus_create_simple("pl061", base, pic[irq]);
+ pl061_dev = sysbus_create_simple("pl061", base, pic[irq]);
nodename = g_strdup_printf("/pl061@%" PRIx64, base);
qemu_fdt_add_subnode(vbi->fdt, nodename);
@@ -563,6 +574,9 @@ static void create_gpio(const VirtBoardInfo *vbi, qemu_irq *pic)
qemu_fdt_setprop_cell(vbi->fdt, nodename, "clocks", vbi->clock_phandle);
qemu_fdt_setprop_string(vbi->fdt, nodename, "clock-names", "apb_pclk");
+ /* connect powerdown request */
+ qemu_register_powerdown_notifier(&virt_system_powerdown_notifier);
+
g_free(nodename);
}
--
2.0.4
^ permalink raw reply related [flat|nested] 21+ messages in thread
* [Qemu-devel] [PATCH v5 10/10] ARM: Virt: Add gpio-keys node for Poweroff using DT
2015-12-11 3:21 [Qemu-devel] [PATCH v5 00/10] Add system_powerdown support on ARM for ACPI and DT Shannon Zhao
` (8 preceding siblings ...)
2015-12-11 3:21 ` [Qemu-devel] [PATCH v5 09/10] ARM: Virt: Add QEMU powerdown notifier and hook it to GPIO Pin 3 Shannon Zhao
@ 2015-12-11 3:21 ` Shannon Zhao
2015-12-17 13:39 ` Peter Maydell
2015-12-15 18:36 ` [Qemu-devel] [PATCH v5 00/10] Add system_powerdown support on ARM for ACPI and DT Peter Maydell
10 siblings, 1 reply; 21+ messages in thread
From: Shannon Zhao @ 2015-12-11 3:21 UTC (permalink / raw)
To: qemu-arm, peter.maydell, imammedo, mst, wei
Cc: peter.huangpeng, zhaoshenglong, qemu-devel, graeme.gregory,
shannon.zhao
From: Shannon Zhao <shannon.zhao@linaro.org>
Add a gpio-keys node. This is used for Poweroff for the systems which
use DT not ACPI.
Signed-off-by: Shannon Zhao <zhaoshenglong@huawei.com>
Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
Tested-by: Wei Huang <wei@redhat.com>
---
hw/arm/virt.c | 16 ++++++++++++++++
1 file changed, 16 insertions(+)
diff --git a/hw/arm/virt.c b/hw/arm/virt.c
index cb1d45b..bd6781bd 100644
--- a/hw/arm/virt.c
+++ b/hw/arm/virt.c
@@ -52,6 +52,7 @@
#include "kvm_arm.h"
#include "hw/smbios/smbios.h"
#include "qapi/visitor.h"
+#include <linux/input.h>
/* Number of external interrupt lines to configure the GIC with */
#define NUM_IRQS 256
@@ -561,6 +562,7 @@ static void create_gpio(const VirtBoardInfo *vbi, qemu_irq *pic)
pl061_dev = sysbus_create_simple("pl061", base, pic[irq]);
+ uint32_t phandle = qemu_fdt_alloc_phandle(vbi->fdt);
nodename = g_strdup_printf("/pl061@%" PRIx64, base);
qemu_fdt_add_subnode(vbi->fdt, nodename);
qemu_fdt_setprop_sized_cells(vbi->fdt, nodename, "reg",
@@ -573,6 +575,20 @@ static void create_gpio(const VirtBoardInfo *vbi, qemu_irq *pic)
GIC_FDT_IRQ_FLAGS_LEVEL_HI);
qemu_fdt_setprop_cell(vbi->fdt, nodename, "clocks", vbi->clock_phandle);
qemu_fdt_setprop_string(vbi->fdt, nodename, "clock-names", "apb_pclk");
+ qemu_fdt_setprop_cell(vbi->fdt, nodename, "phandle", phandle);
+
+ qemu_fdt_add_subnode(vbi->fdt, "/gpio-keys");
+ qemu_fdt_setprop_string(vbi->fdt, "/gpio-keys", "compatible", "gpio-keys");
+ qemu_fdt_setprop_cell(vbi->fdt, "/gpio-keys", "#size-cells", 0);
+ qemu_fdt_setprop_cell(vbi->fdt, "/gpio-keys", "#address-cells", 1);
+
+ qemu_fdt_add_subnode(vbi->fdt, "/gpio-keys/poweroff");
+ qemu_fdt_setprop_string(vbi->fdt, "/gpio-keys/poweroff",
+ "label", "GPIO Key Poweroff");
+ qemu_fdt_setprop_cell(vbi->fdt, "/gpio-keys/poweroff", "linux,code",
+ KEY_POWER);
+ qemu_fdt_setprop_cells(vbi->fdt, "/gpio-keys/poweroff",
+ "gpios", phandle, 3, 0);
/* connect powerdown request */
qemu_register_powerdown_notifier(&virt_system_powerdown_notifier);
--
2.0.4
^ permalink raw reply related [flat|nested] 21+ messages in thread
* Re: [Qemu-devel] [PATCH v5 01/10] acpi: support serialized method
2015-12-11 3:21 ` [Qemu-devel] [PATCH v5 01/10] acpi: support serialized method Shannon Zhao
@ 2015-12-15 16:54 ` Peter Maydell
2015-12-15 16:58 ` Shannon Zhao
0 siblings, 1 reply; 21+ messages in thread
From: Peter Maydell @ 2015-12-15 16:54 UTC (permalink / raw)
To: Shannon Zhao
Cc: Wei Huang, G Gregory, Michael S. Tsirkin, QEMU Developers,
Huangpeng (Peter), qemu-arm, Shannon Zhao, Igor Mammedov
On 11 December 2015 at 03:21, Shannon Zhao <zhaoshenglong@huawei.com> wrote:
> From: Xiao Guangrong <guangrong.xiao@linux.intel.com>
>
> Add serialized method support so that explicit Mutex can be
> avoided
>
> Signed-off-by: Xiao Guangrong <guangrong.xiao@linux.intel.com>
> Signed-off-by: Igor Mammedov <imammedo@redhat.com>
> Reviewed-by: Shannon Zhao <shannon.zhao@linaro.org>
Shannon, this patch needs a Signed-off-by: line from you,
since you're sending it to the list on behalf of somebody
else. (You can just reply to this email to provide it,
you don't need to resend the series.)
thanks
-- PMM
^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [Qemu-devel] [PATCH v5 02/10] acpi: extend aml_interrupt() to support multiple irqs
2015-12-11 3:21 ` [Qemu-devel] [PATCH v5 02/10] acpi: extend aml_interrupt() to support multiple irqs Shannon Zhao
@ 2015-12-15 16:55 ` Peter Maydell
2015-12-15 16:59 ` Shannon Zhao
0 siblings, 1 reply; 21+ messages in thread
From: Peter Maydell @ 2015-12-15 16:55 UTC (permalink / raw)
To: Shannon Zhao
Cc: Wei Huang, G Gregory, Michael S. Tsirkin, QEMU Developers,
Huangpeng (Peter), qemu-arm, Shannon Zhao, Igor Mammedov
On 11 December 2015 at 03:21, Shannon Zhao <zhaoshenglong@huawei.com> wrote:
> From: Igor Mammedov <imammedo@redhat.com>
>
> ASL Interrupt() macro translates to Extended Interrupt Descriptor
> which supports variable number of IRQs. It will be used for
> conversion of ASL code for pc/q35 machines that use it for
> returning several IRQs in _PSR object.
>
> Signed-off-by: Igor Mammedov <imammedo@redhat.com>
> Reviewed-by: Shannon Zhao <shannon.zhao@linaro.org>
Shannon, this one needs your Signed-off-by too.
thanks
-- PMM
^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [Qemu-devel] [PATCH v5 01/10] acpi: support serialized method
2015-12-15 16:54 ` Peter Maydell
@ 2015-12-15 16:58 ` Shannon Zhao
0 siblings, 0 replies; 21+ messages in thread
From: Shannon Zhao @ 2015-12-15 16:58 UTC (permalink / raw)
To: Peter Maydell, Shannon Zhao
Cc: Wei Huang, G Gregory, Michael S. Tsirkin, QEMU Developers,
Huangpeng (Peter), qemu-arm, Igor Mammedov
On 2015/12/16 0:54, Peter Maydell wrote:
> On 11 December 2015 at 03:21, Shannon Zhao<zhaoshenglong@huawei.com> wrote:
>> >From: Xiao Guangrong<guangrong.xiao@linux.intel.com>
>> >
>> >Add serialized method support so that explicit Mutex can be
>> >avoided
>> >
>> >Signed-off-by: Xiao Guangrong<guangrong.xiao@linux.intel.com>
>> >Signed-off-by: Igor Mammedov<imammedo@redhat.com>
>> >Reviewed-by: Shannon Zhao<shannon.zhao@linaro.org>
> Shannon, this patch needs a Signed-off-by: line from you,
> since you're sending it to the list on behalf of somebody
> else. (You can just reply to this email to provide it,
> you don't need to resend the series.)
Sure. Thanks.
Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
--
Shannon
^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [Qemu-devel] [PATCH v5 02/10] acpi: extend aml_interrupt() to support multiple irqs
2015-12-15 16:55 ` Peter Maydell
@ 2015-12-15 16:59 ` Shannon Zhao
0 siblings, 0 replies; 21+ messages in thread
From: Shannon Zhao @ 2015-12-15 16:59 UTC (permalink / raw)
To: Peter Maydell, Shannon Zhao
Cc: Wei Huang, G Gregory, Michael S. Tsirkin, QEMU Developers,
Huangpeng (Peter), qemu-arm, Igor Mammedov
On 2015/12/16 0:55, Peter Maydell wrote:
> On 11 December 2015 at 03:21, Shannon Zhao<zhaoshenglong@huawei.com> wrote:
>> >From: Igor Mammedov<imammedo@redhat.com>
>> >
>> >ASL Interrupt() macro translates to Extended Interrupt Descriptor
>> >which supports variable number of IRQs. It will be used for
>> >conversion of ASL code for pc/q35 machines that use it for
>> >returning several IRQs in _PSR object.
>> >
>> >Signed-off-by: Igor Mammedov<imammedo@redhat.com>
>> >Reviewed-by: Shannon Zhao<shannon.zhao@linaro.org>
> Shannon, this one needs your Signed-off-by too.
Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
Thanks,
--
Shannon
^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [Qemu-devel] [PATCH v5 00/10] Add system_powerdown support on ARM for ACPI and DT
2015-12-11 3:21 [Qemu-devel] [PATCH v5 00/10] Add system_powerdown support on ARM for ACPI and DT Shannon Zhao
` (9 preceding siblings ...)
2015-12-11 3:21 ` [Qemu-devel] [PATCH v5 10/10] ARM: Virt: Add gpio-keys node for Poweroff using DT Shannon Zhao
@ 2015-12-15 18:36 ` Peter Maydell
10 siblings, 0 replies; 21+ messages in thread
From: Peter Maydell @ 2015-12-15 18:36 UTC (permalink / raw)
To: Shannon Zhao
Cc: Wei Huang, G Gregory, Michael S. Tsirkin, QEMU Developers,
Huangpeng (Peter), qemu-arm, Shannon Zhao, Igor Mammedov
On 11 December 2015 at 03:21, Shannon Zhao <zhaoshenglong@huawei.com> wrote:
> From: Shannon Zhao <shannon.zhao@linaro.org>
>
> ACPI SPEC 5.0 defines GPIO-signaled ACPI Events for Hardware-reduced
> platforms(like ARM). It uses GPIO pin to trigger an event to the guest.
> For QEMU, here we add PL061 GPIO controller and use PIN 3 for
> system_powerdown, reserving PIN 0, 1, 2 for PCI hotplug, CPU hotplug and
> memory hotplug.
>
> This patchset adds system_powerdown support on ARM through both ACPI and
> DT ways. It adds a GPIO controller(here is PL061) in machine virt and
> uses GPIO-singled event for ACPI while gpio-keys for DT. It has been
> tested for the guests starting by ACPI or DT while guests use systemd or
> acpid.
Thanks, applied to target-arm.next.
-- PMM
^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [Qemu-devel] [PATCH v5 04/10] ARM: ACPI: Add GPIO controller in ACPI DSDT table
2015-12-11 3:21 ` [Qemu-devel] [PATCH v5 04/10] ARM: ACPI: Add GPIO controller in ACPI DSDT table Shannon Zhao
@ 2015-12-16 15:48 ` Igor Mammedov
0 siblings, 0 replies; 21+ messages in thread
From: Igor Mammedov @ 2015-12-16 15:48 UTC (permalink / raw)
To: Shannon Zhao
Cc: wei, peter.maydell, graeme.gregory, mst, qemu-devel,
peter.huangpeng, qemu-arm, shannon.zhao
On Fri, 11 Dec 2015 11:21:20 +0800
Shannon Zhao <zhaoshenglong@huawei.com> wrote:
> From: Shannon Zhao <shannon.zhao@linaro.org>
>
> Add GPIO controller in ACPI DSDT table. It can be used for gpio event.
>
> Signed-off-by: Shannon Zhao <zhaoshenglong@huawei.com>
> Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
> Tested-by: Wei Huang <wei@redhat.com>
Reviewed-by: Igor Mammedov <imammedo@redhat.com>
> ---
> hw/arm/virt-acpi-build.c | 19 +++++++++++++++++++
> 1 file changed, 19 insertions(+)
>
> diff --git a/hw/arm/virt-acpi-build.c b/hw/arm/virt-acpi-build.c
> index 1deebfe..fcc08f7 100644
> --- a/hw/arm/virt-acpi-build.c
> +++ b/hw/arm/virt-acpi-build.c
> @@ -324,6 +324,23 @@ static void acpi_dsdt_add_pci(Aml *scope, const
> MemMapEntry *memmap, aml_append(scope, dev);
> }
>
> +static void acpi_dsdt_add_gpio(Aml *scope, const MemMapEntry
> *gpio_memmap,
> + uint32_t gpio_irq)
> +{
> + Aml *dev = aml_device("GPO0");
> + aml_append(dev, aml_name_decl("_HID", aml_string("ARMH0061")));
> + aml_append(dev, aml_name_decl("_ADR", aml_int(0)));
> + aml_append(dev, aml_name_decl("_UID", aml_int(0)));
> +
> + Aml *crs = aml_resource_template();
> + aml_append(crs, aml_memory32_fixed(gpio_memmap->base,
> gpio_memmap->size,
> + AML_READ_WRITE));
> + aml_append(crs, aml_interrupt(AML_CONSUMER, AML_LEVEL,
> AML_ACTIVE_HIGH,
> + AML_EXCLUSIVE, &gpio_irq, 1));
> + aml_append(dev, aml_name_decl("_CRS", crs));
> + aml_append(scope, dev);
> +}
> +
> /* RSDP */
> static GArray *
> build_rsdp(GArray *rsdp_table, GArray *linker, unsigned rsdt)
> @@ -540,6 +557,8 @@ build_dsdt(GArray *table_data, GArray *linker,
> VirtGuestInfo *guest_info) (irqmap[VIRT_MMIO] + ARM_SPI_BASE),
> NUM_VIRTIO_TRANSPORTS); acpi_dsdt_add_pci(scope, memmap,
> (irqmap[VIRT_PCIE] + ARM_SPI_BASE), guest_info->use_highmem);
> + acpi_dsdt_add_gpio(scope, &memmap[VIRT_GPIO],
> + (irqmap[VIRT_GPIO] + ARM_SPI_BASE));
>
> aml_append(dsdt, scope);
>
^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [Qemu-devel] [PATCH v5 08/10] ARM: ACPI: Add _E03 for Power Button
2015-12-11 3:21 ` [Qemu-devel] [PATCH v5 08/10] ARM: ACPI: Add _E03 for Power Button Shannon Zhao
@ 2015-12-16 15:51 ` Igor Mammedov
2015-12-16 16:07 ` Peter Maydell
0 siblings, 1 reply; 21+ messages in thread
From: Igor Mammedov @ 2015-12-16 15:51 UTC (permalink / raw)
To: Shannon Zhao
Cc: wei, peter.maydell, graeme.gregory, mst, qemu-devel,
peter.huangpeng, qemu-arm, shannon.zhao
On Fri, 11 Dec 2015 11:21:24 +0800
Shannon Zhao <zhaoshenglong@huawei.com> wrote:
> From: Shannon Zhao <shannon.zhao@linaro.org>
>
> Here GPIO pin 3 is used for Power Button, add _E03 in ACPI DSDT table.
>
> Signed-off-by: Shannon Zhao <zhaoshenglong@huawei.com>
> Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
> Tested-by: Wei Huang <wei@redhat.com>
> ---
> hw/arm/virt-acpi-build.c | 14 ++++++++++++++
> 1 file changed, 14 insertions(+)
>
> diff --git a/hw/arm/virt-acpi-build.c b/hw/arm/virt-acpi-build.c
> index e5dc2d5..1ffff62 100644
> --- a/hw/arm/virt-acpi-build.c
> +++ b/hw/arm/virt-acpi-build.c
> @@ -339,6 +339,20 @@ static void acpi_dsdt_add_gpio(Aml *scope, const
> MemMapEntry *gpio_memmap, aml_append(crs, aml_interrupt(AML_CONSUMER,
> AML_LEVEL, AML_ACTIVE_HIGH, AML_EXCLUSIVE, &gpio_irq, 1));
> aml_append(dev, aml_name_decl("_CRS", crs));
> +
> + Aml *aei = aml_resource_template();
> + /* Pin 3 for power button */
> + const uint32_t pin_list[1] = {3};
Sorry, just noticed,
do we allow declarations in the middle of the block?
The same applies to 'Aml *method' below.
> + aml_append(aei, aml_gpio_int(AML_CONSUMER, AML_EDGE,
> AML_ACTIVE_HIGH,
> + AML_EXCLUSIVE, AML_PULL_UP, 0,
> pin_list, 1,
> + "GPO0", NULL, 0));
> + aml_append(dev, aml_name_decl("_AEI", aei));
> +
> + /* _E03 is handle for power button */
> + Aml *method = aml_method("_E03", 0, AML_NOTSERIALIZED);
> + aml_append(method, aml_notify(aml_name(ACPI_POWER_BUTTON_DEVICE),
> + aml_int(0x80)));
> + aml_append(dev, method);
> aml_append(scope, dev);
> }
>
^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [Qemu-devel] [PATCH v5 08/10] ARM: ACPI: Add _E03 for Power Button
2015-12-16 15:51 ` Igor Mammedov
@ 2015-12-16 16:07 ` Peter Maydell
0 siblings, 0 replies; 21+ messages in thread
From: Peter Maydell @ 2015-12-16 16:07 UTC (permalink / raw)
To: Igor Mammedov
Cc: Wei Huang, G Gregory, Michael S. Tsirkin, QEMU Developers,
Huangpeng (Peter), qemu-arm, Shannon Zhao, Shannon Zhao
On 16 December 2015 at 15:51, Igor Mammedov <imammedo@redhat.com> wrote:
> On Fri, 11 Dec 2015 11:21:24 +0800
> Shannon Zhao <zhaoshenglong@huawei.com> wrote:
>
>> From: Shannon Zhao <shannon.zhao@linaro.org>
>>
>> Here GPIO pin 3 is used for Power Button, add _E03 in ACPI DSDT table.
>>
>> Signed-off-by: Shannon Zhao <zhaoshenglong@huawei.com>
>> Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
>> Tested-by: Wei Huang <wei@redhat.com>
>> ---
>> hw/arm/virt-acpi-build.c | 14 ++++++++++++++
>> 1 file changed, 14 insertions(+)
>>
>> diff --git a/hw/arm/virt-acpi-build.c b/hw/arm/virt-acpi-build.c
>> index e5dc2d5..1ffff62 100644
>> --- a/hw/arm/virt-acpi-build.c
>> +++ b/hw/arm/virt-acpi-build.c
>> @@ -339,6 +339,20 @@ static void acpi_dsdt_add_gpio(Aml *scope, const
>> MemMapEntry *gpio_memmap, aml_append(crs, aml_interrupt(AML_CONSUMER,
>> AML_LEVEL, AML_ACTIVE_HIGH, AML_EXCLUSIVE, &gpio_irq, 1));
>> aml_append(dev, aml_name_decl("_CRS", crs));
>> +
>> + Aml *aei = aml_resource_template();
>> + /* Pin 3 for power button */
>> + const uint32_t pin_list[1] = {3};
> Sorry, just noticed,
> do we allow declarations in the middle of the block?
> The same applies to 'Aml *method' below.
No, we prefer not to, but the file is full of them already...
thanks
-- PMM
^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [Qemu-devel] [PATCH v5 10/10] ARM: Virt: Add gpio-keys node for Poweroff using DT
2015-12-11 3:21 ` [Qemu-devel] [PATCH v5 10/10] ARM: Virt: Add gpio-keys node for Poweroff using DT Shannon Zhao
@ 2015-12-17 13:39 ` Peter Maydell
2015-12-17 13:43 ` Shannon Zhao
0 siblings, 1 reply; 21+ messages in thread
From: Peter Maydell @ 2015-12-17 13:39 UTC (permalink / raw)
To: Shannon Zhao
Cc: Wei Huang, G Gregory, Michael S. Tsirkin, QEMU Developers,
Huangpeng (Peter), qemu-arm, Shannon Zhao, Igor Mammedov
On 11 December 2015 at 03:21, Shannon Zhao <zhaoshenglong@huawei.com> wrote:
> From: Shannon Zhao <shannon.zhao@linaro.org>
>
> Add a gpio-keys node. This is used for Poweroff for the systems which
> use DT not ACPI.
>
> Signed-off-by: Shannon Zhao <zhaoshenglong@huawei.com>
> Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
> Tested-by: Wei Huang <wei@redhat.com>
> ---
> hw/arm/virt.c | 16 ++++++++++++++++
> 1 file changed, 16 insertions(+)
>
> diff --git a/hw/arm/virt.c b/hw/arm/virt.c
> index cb1d45b..bd6781bd 100644
> --- a/hw/arm/virt.c
> +++ b/hw/arm/virt.c
> @@ -52,6 +52,7 @@
> #include "kvm_arm.h"
> #include "hw/smbios/smbios.h"
> #include "qapi/visitor.h"
> +#include <linux/input.h>
You can't include <linux/> headers -- this will cause the build to
fail on non-Linux hosts. You need "standard-headers/linux/input.h"
(which is what I suggested you use initially).
I'll fix this up in my tree.
thanks
-- PMM
^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [Qemu-devel] [PATCH v5 10/10] ARM: Virt: Add gpio-keys node for Poweroff using DT
2015-12-17 13:39 ` Peter Maydell
@ 2015-12-17 13:43 ` Shannon Zhao
0 siblings, 0 replies; 21+ messages in thread
From: Shannon Zhao @ 2015-12-17 13:43 UTC (permalink / raw)
To: Peter Maydell
Cc: Wei Huang, G Gregory, Michael S. Tsirkin, QEMU Developers,
Huangpeng (Peter), qemu-arm, Shannon Zhao, Igor Mammedov
On 2015/12/17 21:39, Peter Maydell wrote:
> On 11 December 2015 at 03:21, Shannon Zhao <zhaoshenglong@huawei.com> wrote:
>> > From: Shannon Zhao <shannon.zhao@linaro.org>
>> >
>> > Add a gpio-keys node. This is used for Poweroff for the systems which
>> > use DT not ACPI.
>> >
>> > Signed-off-by: Shannon Zhao <zhaoshenglong@huawei.com>
>> > Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
>> > Tested-by: Wei Huang <wei@redhat.com>
>> > ---
>> > hw/arm/virt.c | 16 ++++++++++++++++
>> > 1 file changed, 16 insertions(+)
>> >
>> > diff --git a/hw/arm/virt.c b/hw/arm/virt.c
>> > index cb1d45b..bd6781bd 100644
>> > --- a/hw/arm/virt.c
>> > +++ b/hw/arm/virt.c
>> > @@ -52,6 +52,7 @@
>> > #include "kvm_arm.h"
>> > #include "hw/smbios/smbios.h"
>> > #include "qapi/visitor.h"
>> > +#include <linux/input.h>
> You can't include <linux/> headers -- this will cause the build to
> fail on non-Linux hosts. You need "standard-headers/linux/input.h"
> (which is what I suggested you use initially).
>
Oh, sorry for this.
> I'll fix this up in my tree.
Thanks!
--
Shannon
^ permalink raw reply [flat|nested] 21+ messages in thread
end of thread, other threads:[~2015-12-17 13:49 UTC | newest]
Thread overview: 21+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-12-11 3:21 [Qemu-devel] [PATCH v5 00/10] Add system_powerdown support on ARM for ACPI and DT Shannon Zhao
2015-12-11 3:21 ` [Qemu-devel] [PATCH v5 01/10] acpi: support serialized method Shannon Zhao
2015-12-15 16:54 ` Peter Maydell
2015-12-15 16:58 ` Shannon Zhao
2015-12-11 3:21 ` [Qemu-devel] [PATCH v5 02/10] acpi: extend aml_interrupt() to support multiple irqs Shannon Zhao
2015-12-15 16:55 ` Peter Maydell
2015-12-15 16:59 ` Shannon Zhao
2015-12-11 3:21 ` [Qemu-devel] [PATCH v5 03/10] ARM: Virt: Add a GPIO controller Shannon Zhao
2015-12-11 3:21 ` [Qemu-devel] [PATCH v5 04/10] ARM: ACPI: Add GPIO controller in ACPI DSDT table Shannon Zhao
2015-12-16 15:48 ` Igor Mammedov
2015-12-11 3:21 ` [Qemu-devel] [PATCH v5 05/10] ARM: ACPI: Add power button device " Shannon Zhao
2015-12-11 3:21 ` [Qemu-devel] [PATCH v5 06/10] ACPI: Add GPIO Connection Descriptor Shannon Zhao
2015-12-11 3:21 ` [Qemu-devel] [PATCH v5 07/10] ACPI: Add aml_gpio_int() wrapper for GPIO Interrupt Connection Shannon Zhao
2015-12-11 3:21 ` [Qemu-devel] [PATCH v5 08/10] ARM: ACPI: Add _E03 for Power Button Shannon Zhao
2015-12-16 15:51 ` Igor Mammedov
2015-12-16 16:07 ` Peter Maydell
2015-12-11 3:21 ` [Qemu-devel] [PATCH v5 09/10] ARM: Virt: Add QEMU powerdown notifier and hook it to GPIO Pin 3 Shannon Zhao
2015-12-11 3:21 ` [Qemu-devel] [PATCH v5 10/10] ARM: Virt: Add gpio-keys node for Poweroff using DT Shannon Zhao
2015-12-17 13:39 ` Peter Maydell
2015-12-17 13:43 ` Shannon Zhao
2015-12-15 18:36 ` [Qemu-devel] [PATCH v5 00/10] Add system_powerdown support on ARM for ACPI and DT Peter Maydell
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).