From patchwork Wed May 22 16:22:51 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shameerali Kolothum Thodi X-Patchwork-Id: 1103464 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=huawei.com Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 458J6p2myjz9s55 for ; Thu, 23 May 2019 02:31:30 +1000 (AEST) Received: from localhost ([127.0.0.1]:47621 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hTU9I-00035n-BL for incoming@patchwork.ozlabs.org; Wed, 22 May 2019 12:31:28 -0400 Received: from eggs.gnu.org ([209.51.188.92]:34131) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hTU3G-0006lO-L7 for qemu-devel@nongnu.org; Wed, 22 May 2019 12:25:15 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hTU3E-0002KW-LB for qemu-devel@nongnu.org; Wed, 22 May 2019 12:25:14 -0400 Received: from szxga04-in.huawei.com ([45.249.212.190]:2223 helo=huawei.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hTU3A-000271-Ia; Wed, 22 May 2019 12:25:09 -0400 Received: from DGGEMS404-HUB.china.huawei.com (unknown [172.30.72.58]) by Forcepoint Email with ESMTP id 0689F80F60C90003982B; Thu, 23 May 2019 00:25:03 +0800 (CST) Received: from S00345302A-PC.china.huawei.com (10.202.227.237) by DGGEMS404-HUB.china.huawei.com (10.3.19.204) with Microsoft SMTP Server id 14.3.439.0; Thu, 23 May 2019 00:24:21 +0800 From: Shameer Kolothum To: , , , Date: Wed, 22 May 2019 17:22:51 +0100 Message-ID: <20190522162252.28568-8-shameerali.kolothum.thodi@huawei.com> X-Mailer: git-send-email 2.12.0.windows.1 In-Reply-To: <20190522162252.28568-1-shameerali.kolothum.thodi@huawei.com> References: <20190522162252.28568-1-shameerali.kolothum.thodi@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.202.227.237] X-CFilter-Loop: Reflected X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 45.249.212.190 Subject: [Qemu-devel] [PATCH v5 7/8] hw/acpi: Add system power down support to GED X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.maydell@linaro.org, sameo@linux.intel.com, ard.biesheuvel@linaro.org, linuxarm@huawei.com, xuwei5@hisilicon.com, shannon.zhaosl@gmail.com, sebastien.boeuf@intel.com, lersek@redhat.com Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" This adds support to use GED for system power down event. Signed-off-by: Shameer Kolothum Reviewed-by: Eric Auger --- hw/acpi/generic_event_device.c | 16 ++++++++++++++++ include/hw/acpi/generic_event_device.h | 4 ++++ 2 files changed, 20 insertions(+) diff --git a/hw/acpi/generic_event_device.c b/hw/acpi/generic_event_device.c index 914fe64716..27c1bb40d4 100644 --- a/hw/acpi/generic_event_device.c +++ b/hw/acpi/generic_event_device.c @@ -20,6 +20,7 @@ static const uint32_t ged_supported_events[] = { ACPI_GED_MEM_HOTPLUG_EVT, + ACPI_GED_PWR_DOWN_EVT, }; /* @@ -104,6 +105,11 @@ void build_ged_aml(Aml *table, const char *name, HotplugHandler *hotplug_dev, aml_append(if_ctx, aml_call0(MEMORY_DEVICES_CONTAINER "." MEMORY_SLOT_SCAN_METHOD)); break; + case ACPI_GED_PWR_DOWN_EVT: + aml_append(if_ctx, + aml_notify(aml_name(ACPI_POWER_BUTTON_DEVICE), + aml_int(0x80))); + break; default: /* * Please make sure all the events in ged_supported_events[] @@ -228,6 +234,13 @@ static void acpi_ged_send_event(AcpiDeviceIf *adev, AcpiEventStatusBits ev) acpi_ged_event(s, sel); } +static void acpi_ged_pm_powerdown_req(Notifier *n, void *opaque) +{ + AcpiGedState *s = container_of(n, AcpiGedState, powerdown_notifier); + + acpi_ged_event(s, ACPI_GED_PWR_DOWN_EVT); +} + static void acpi_ged_device_realize(DeviceState *dev, Error **errp) { AcpiGedState *s = ACPI_GED(dev); @@ -239,6 +252,9 @@ static void acpi_ged_device_realize(DeviceState *dev, Error **errp) } acpi_ged_init(get_system_memory(), dev, &s->ged_state); + + s->powerdown_notifier.notify = acpi_ged_pm_powerdown_req; + qemu_register_powerdown_notifier(&s->powerdown_notifier); } static Property acpi_ged_properties[] = { diff --git a/include/hw/acpi/generic_event_device.h b/include/hw/acpi/generic_event_device.h index f69d084c89..9e63b72cb9 100644 --- a/include/hw/acpi/generic_event_device.h +++ b/include/hw/acpi/generic_event_device.h @@ -61,6 +61,8 @@ #include "hw/acpi/memory_hotplug.h" +#define ACPI_POWER_BUTTON_DEVICE "PWRB" + #define TYPE_ACPI_GED "acpi-ged" #define ACPI_GED(obj) \ OBJECT_CHECK(AcpiGedState, (obj), TYPE_ACPI_GED) @@ -79,6 +81,7 @@ * through GED. */ #define ACPI_GED_MEM_HOTPLUG_EVT 0x1 +#define ACPI_GED_PWR_DOWN_EVT 0x2 typedef struct GEDState { MemoryRegion io; @@ -88,6 +91,7 @@ typedef struct GEDState { typedef struct AcpiGedState { DeviceClass parent_obj; + Notifier powerdown_notifier; MemHotplugState memhp_state; hwaddr memhp_base; hwaddr ged_base;