2020-04-06 15:52:44 +02:00
|
|
|
/*
|
|
|
|
* Clock migration structure
|
|
|
|
*
|
|
|
|
* Copyright GreenSocs 2019-2020
|
|
|
|
*
|
|
|
|
* Authors:
|
|
|
|
* Damien Hedde
|
|
|
|
*
|
|
|
|
* This work is licensed under the terms of the GNU GPL, version 2 or later.
|
|
|
|
* See the COPYING file in the top-level directory.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "qemu/osdep.h"
|
|
|
|
#include "migration/vmstate.h"
|
|
|
|
#include "hw/clock.h"
|
|
|
|
|
2021-08-12 11:33:40 +02:00
|
|
|
static bool muldiv_needed(void *opaque)
|
|
|
|
{
|
|
|
|
Clock *clk = opaque;
|
|
|
|
|
|
|
|
return clk->multiplier != 1 || clk->divider != 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int clock_pre_load(void *opaque)
|
|
|
|
{
|
|
|
|
Clock *clk = opaque;
|
|
|
|
/*
|
|
|
|
* The initial out-of-reset settings of the Clock might have been
|
|
|
|
* configured by the device to be different from what we set
|
|
|
|
* in clock_initfn(), so we must here set the default values to
|
|
|
|
* be used if they are not in the inbound migration state.
|
|
|
|
*/
|
|
|
|
clk->multiplier = 1;
|
|
|
|
clk->divider = 1;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
const VMStateDescription vmstate_muldiv = {
|
|
|
|
.name = "clock/muldiv",
|
|
|
|
.version_id = 1,
|
|
|
|
.minimum_version_id = 1,
|
|
|
|
.needed = muldiv_needed,
|
2023-12-21 04:16:00 +01:00
|
|
|
.fields = (const VMStateField[]) {
|
2021-08-12 11:33:40 +02:00
|
|
|
VMSTATE_UINT32(multiplier, Clock),
|
|
|
|
VMSTATE_UINT32(divider, Clock),
|
2022-01-11 11:19:34 +01:00
|
|
|
VMSTATE_END_OF_LIST()
|
2021-08-12 11:33:40 +02:00
|
|
|
},
|
|
|
|
};
|
|
|
|
|
2020-04-06 15:52:44 +02:00
|
|
|
const VMStateDescription vmstate_clock = {
|
|
|
|
.name = "clock",
|
|
|
|
.version_id = 0,
|
|
|
|
.minimum_version_id = 0,
|
2021-08-12 11:33:40 +02:00
|
|
|
.pre_load = clock_pre_load,
|
2023-12-21 04:16:00 +01:00
|
|
|
.fields = (const VMStateField[]) {
|
2020-04-06 15:52:44 +02:00
|
|
|
VMSTATE_UINT64(period, Clock),
|
|
|
|
VMSTATE_END_OF_LIST()
|
2021-08-12 11:33:40 +02:00
|
|
|
},
|
2023-12-21 04:16:00 +01:00
|
|
|
.subsections = (const VMStateDescription * const []) {
|
2021-08-12 11:33:40 +02:00
|
|
|
&vmstate_muldiv,
|
|
|
|
NULL
|
|
|
|
},
|
2020-04-06 15:52:44 +02:00
|
|
|
};
|