nvme: add missing coroutine_fn annotations
[qemu.git] / hw / gpio / gpio_pwr.c
blobdbaf1c70c88ae5e0cef4d667be5c6e1b021b3e81
1 /*
2 * GPIO qemu power controller
4 * Copyright (c) 2020 Linaro Limited
6 * Author: Maxim Uvarov <maxim.uvarov@linaro.org>
8 * Virtual gpio driver which can be used on top of pl061
9 * to reboot and shutdown qemu virtual machine. One of use
10 * case is gpio driver for secure world application (ARM
11 * Trusted Firmware.).
13 * This work is licensed under the terms of the GNU GPL, version 2 or later.
14 * See the COPYING file in the top-level directory.
15 * SPDX-License-Identifier: GPL-2.0-or-later
19 * QEMU interface:
20 * two named input GPIO lines:
21 * 'reset' : when asserted, trigger system reset
22 * 'shutdown' : when asserted, trigger system shutdown
25 #include "qemu/osdep.h"
26 #include "hw/sysbus.h"
27 #include "sysemu/runstate.h"
29 #define TYPE_GPIOPWR "gpio-pwr"
30 OBJECT_DECLARE_SIMPLE_TYPE(GPIO_PWR_State, GPIOPWR)
32 struct GPIO_PWR_State {
33 SysBusDevice parent_obj;
36 static void gpio_pwr_reset(void *opaque, int n, int level)
38 if (level) {
39 qemu_system_reset_request(SHUTDOWN_CAUSE_GUEST_RESET);
43 static void gpio_pwr_shutdown(void *opaque, int n, int level)
45 if (level) {
46 qemu_system_shutdown_request(SHUTDOWN_CAUSE_GUEST_SHUTDOWN);
50 static void gpio_pwr_init(Object *obj)
52 DeviceState *dev = DEVICE(obj);
54 qdev_init_gpio_in_named(dev, gpio_pwr_reset, "reset", 1);
55 qdev_init_gpio_in_named(dev, gpio_pwr_shutdown, "shutdown", 1);
58 static const TypeInfo gpio_pwr_info = {
59 .name = TYPE_GPIOPWR,
60 .parent = TYPE_SYS_BUS_DEVICE,
61 .instance_size = sizeof(GPIO_PWR_State),
62 .instance_init = gpio_pwr_init,
65 static void gpio_pwr_register_types(void)
67 type_register_static(&gpio_pwr_info);
70 type_init(gpio_pwr_register_types)