3 * Copyright (c) 2018 Intel Corporation
4 * Copyright (c) 2019 Huawei Technologies R & D (UK) Ltd
5 * Written by Samuel Ortiz, Shameer Kolothum
7 * This program is free software; you can redistribute it and/or modify it
8 * under the terms and conditions of the GNU General Public License,
9 * version 2 or later, as published by the Free Software Foundation.
11 * The ACPI Generic Event Device (GED) is a hardware-reduced specific
12 * device[ACPI v6.1 Section 5.6.9] that handles all platform events,
13 * including the hotplug ones. Generic Event Device allows platforms
14 * to handle interrupts in ACPI ASL statements. It follows a very
15 * similar approach like the _EVT method from GPIO events. All
16 * interrupts are listed in _CRS and the handler is written in _EVT
17 * method. Here, we use a single interrupt for the GED device, relying
18 * on IO memory region to communicate the type of device affected by
19 * the interrupt. This way, we can support up to 32 events with a
26 * Name (_HID, "ACPI0013")
28 * Name (_CRS, ResourceTemplate ()
30 * Interrupt (ResourceConsumer, Edge, ActiveHigh, Exclusive, ,, )
35 * OperationRegion (EREG, SystemMemory, 0x09080000, 0x04)
36 * Field (EREG, DWordAcc, NoLock, WriteAsZeros)
41 * Method (_EVT, 1, Serialized) // _EVT: Event
43 * Local0 = ESEL // ESEL = IO memory region which specifies the
45 * If (((Local0 & One) == One))
49 * If ((Local0 & 0x2) == 0x2)
62 #include "hw/sysbus.h"
63 #include "hw/acpi/memory_hotplug.h"
65 #define ACPI_POWER_BUTTON_DEVICE "PWRB"
67 #define TYPE_ACPI_GED "acpi-ged"
68 #define ACPI_GED(obj) \
69 OBJECT_CHECK(AcpiGedState, (obj), TYPE_ACPI_GED)
71 #define ACPI_GED_EVT_SEL_OFFSET 0x0
72 #define ACPI_GED_EVT_SEL_LEN 0x4
74 #define GED_DEVICE "GED"
75 #define AML_GED_EVT_REG "EREG"
76 #define AML_GED_EVT_SEL "ESEL"
79 * Platforms need to specify the GED event bitmap
80 * to describe what kind of events they want to support
83 #define ACPI_GED_MEM_HOTPLUG_EVT 0x1
84 #define ACPI_GED_PWR_DOWN_EVT 0x2
85 #define ACPI_GED_NVDIMM_HOTPLUG_EVT 0x4
87 typedef struct GEDState
{
92 typedef struct AcpiGedState
{
93 SysBusDevice parent_obj
;
94 MemHotplugState memhp_state
;
95 MemoryRegion container_memhp
;
97 uint32_t ged_event_bitmap
;
101 void build_ged_aml(Aml
*table
, const char* name
, HotplugHandler
*hotplug_dev
,
102 uint32_t ged_irq
, AmlRegionSpace rs
, hwaddr ged_base
);