cputlb: Move tlb_lock to CPUTLBCommon
[qemu/ar7.git] / hw / misc / imx2_wdt.c
blobe47e442592248f001c8c31af23e37a2d738efdbd
1 /*
2 * Copyright (c) 2018, Impinj, Inc.
4 * i.MX2 Watchdog IP block
6 * Author: Andrey Smirnov <andrew.smirnov@gmail.com>
8 * This work is licensed under the terms of the GNU GPL, version 2 or later.
9 * See the COPYING file in the top-level directory.
12 #include "qemu/osdep.h"
13 #include "qemu/bitops.h"
14 #include "sysemu/watchdog.h"
16 #include "hw/misc/imx2_wdt.h"
18 #define IMX2_WDT_WCR_WDA BIT(5) /* -> External Reset WDOG_B */
19 #define IMX2_WDT_WCR_SRS BIT(4) /* -> Software Reset Signal */
21 static uint64_t imx2_wdt_read(void *opaque, hwaddr addr,
22 unsigned int size)
24 return 0;
27 static void imx2_wdt_write(void *opaque, hwaddr addr,
28 uint64_t value, unsigned int size)
30 if (addr == IMX2_WDT_WCR &&
31 (value & (IMX2_WDT_WCR_WDA | IMX2_WDT_WCR_SRS))) {
32 watchdog_perform_action();
36 static const MemoryRegionOps imx2_wdt_ops = {
37 .read = imx2_wdt_read,
38 .write = imx2_wdt_write,
39 .endianness = DEVICE_NATIVE_ENDIAN,
40 .impl = {
42 * Our device would not work correctly if the guest was doing
43 * unaligned access. This might not be a limitation on the
44 * real device but in practice there is no reason for a guest
45 * to access this device unaligned.
47 .min_access_size = 4,
48 .max_access_size = 4,
49 .unaligned = false,
53 static void imx2_wdt_realize(DeviceState *dev, Error **errp)
55 IMX2WdtState *s = IMX2_WDT(dev);
57 memory_region_init_io(&s->mmio, OBJECT(dev),
58 &imx2_wdt_ops, s,
59 TYPE_IMX2_WDT".mmio",
60 IMX2_WDT_REG_NUM * sizeof(uint16_t));
61 sysbus_init_mmio(SYS_BUS_DEVICE(dev), &s->mmio);
64 static void imx2_wdt_class_init(ObjectClass *klass, void *data)
66 DeviceClass *dc = DEVICE_CLASS(klass);
68 dc->realize = imx2_wdt_realize;
69 set_bit(DEVICE_CATEGORY_MISC, dc->categories);
72 static const TypeInfo imx2_wdt_info = {
73 .name = TYPE_IMX2_WDT,
74 .parent = TYPE_SYS_BUS_DEVICE,
75 .instance_size = sizeof(IMX2WdtState),
76 .class_init = imx2_wdt_class_init,
79 static WatchdogTimerModel model = {
80 .wdt_name = "imx2-watchdog",
81 .wdt_description = "i.MX2 Watchdog",
84 static void imx2_wdt_register_type(void)
86 watchdog_add_model(&model);
87 type_register_static(&imx2_wdt_info);
89 type_init(imx2_wdt_register_type)