2 * Clock migration structure
4 * Copyright GreenSocs 2019-2020
9 * This work is licensed under the terms of the GNU GPL, version 2 or later.
10 * See the COPYING file in the top-level directory.
13 #include "qemu/osdep.h"
14 #include "migration/vmstate.h"
17 static bool muldiv_needed(void *opaque)
21 return clk->multiplier != 1 || clk->divider != 1;
24 static int clock_pre_load(void *opaque)
28 * The initial out-of-reset settings of the Clock might have been
29 * configured by the device to be different from what we set
30 * in clock_initfn(), so we must here set the default values to
31 * be used if they are not in the inbound migration state.
39 const VMStateDescription vmstate_muldiv = {
40 .name = "clock/muldiv",
42 .minimum_version_id = 1,
43 .needed = muldiv_needed,
44 .fields = (VMStateField[]) {
45 VMSTATE_UINT32(multiplier, Clock),
46 VMSTATE_UINT32(divider, Clock),
51 const VMStateDescription vmstate_clock = {
54 .minimum_version_id = 0,
55 .pre_load = clock_pre_load,
56 .fields = (VMStateField[]) {
57 VMSTATE_UINT64(period, Clock),
60 .subsections = (const VMStateDescription*[]) {