|
@@ -198,7 +198,7 @@ static NPCM7xxClockPLL find_pll_by_reg(enum NPCM7xxCLKRegisters reg)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-static void npcm7xx_clk_update_all_plls(NPCM7xxCLKState *clk)
|
|
|
+static void npcm7xx_clk_update_all_plls(NPCMCLKState *clk)
|
|
|
{
|
|
|
int i;
|
|
|
|
|
@@ -207,7 +207,7 @@ static void npcm7xx_clk_update_all_plls(NPCM7xxCLKState *clk)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-static void npcm7xx_clk_update_all_sels(NPCM7xxCLKState *clk)
|
|
|
+static void npcm7xx_clk_update_all_sels(NPCMCLKState *clk)
|
|
|
{
|
|
|
int i;
|
|
|
|
|
@@ -216,7 +216,7 @@ static void npcm7xx_clk_update_all_sels(NPCM7xxCLKState *clk)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-static void npcm7xx_clk_update_all_dividers(NPCM7xxCLKState *clk)
|
|
|
+static void npcm7xx_clk_update_all_dividers(NPCMCLKState *clk)
|
|
|
{
|
|
|
int i;
|
|
|
|
|
@@ -225,7 +225,7 @@ static void npcm7xx_clk_update_all_dividers(NPCM7xxCLKState *clk)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-static void npcm7xx_clk_update_all_clocks(NPCM7xxCLKState *clk)
|
|
|
+static void npcm7xx_clk_update_all_clocks(NPCMCLKState *clk)
|
|
|
{
|
|
|
clock_update_hz(clk->clkref, NPCM7XX_CLOCK_REF_HZ);
|
|
|
npcm7xx_clk_update_all_plls(clk);
|
|
@@ -635,7 +635,7 @@ static void npcm7xx_clk_divider_init(Object *obj)
|
|
|
}
|
|
|
|
|
|
static void npcm7xx_init_clock_pll(NPCM7xxClockPLLState *pll,
|
|
|
- NPCM7xxCLKState *clk, const PLLInitInfo *init_info)
|
|
|
+ NPCMCLKState *clk, const PLLInitInfo *init_info)
|
|
|
{
|
|
|
pll->name = init_info->name;
|
|
|
pll->clk = clk;
|
|
@@ -647,7 +647,7 @@ static void npcm7xx_init_clock_pll(NPCM7xxClockPLLState *pll,
|
|
|
}
|
|
|
|
|
|
static void npcm7xx_init_clock_sel(NPCM7xxClockSELState *sel,
|
|
|
- NPCM7xxCLKState *clk, const SELInitInfo *init_info)
|
|
|
+ NPCMCLKState *clk, const SELInitInfo *init_info)
|
|
|
{
|
|
|
int input_size = init_info->input_size;
|
|
|
|
|
@@ -664,7 +664,7 @@ static void npcm7xx_init_clock_sel(NPCM7xxClockSELState *sel,
|
|
|
}
|
|
|
|
|
|
static void npcm7xx_init_clock_divider(NPCM7xxClockDividerState *div,
|
|
|
- NPCM7xxCLKState *clk, const DividerInitInfo *init_info)
|
|
|
+ NPCMCLKState *clk, const DividerInitInfo *init_info)
|
|
|
{
|
|
|
div->name = init_info->name;
|
|
|
div->clk = clk;
|
|
@@ -683,7 +683,7 @@ static void npcm7xx_init_clock_divider(NPCM7xxClockDividerState *div,
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-static Clock *npcm7xx_get_clock(NPCM7xxCLKState *clk, ClockSrcType type,
|
|
|
+static Clock *npcm7xx_get_clock(NPCMCLKState *clk, ClockSrcType type,
|
|
|
int index)
|
|
|
{
|
|
|
switch (type) {
|
|
@@ -700,7 +700,7 @@ static Clock *npcm7xx_get_clock(NPCM7xxCLKState *clk, ClockSrcType type,
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-static void npcm7xx_connect_clocks(NPCM7xxCLKState *clk)
|
|
|
+static void npcm7xx_connect_clocks(NPCMCLKState *clk)
|
|
|
{
|
|
|
int i, j;
|
|
|
Clock *src;
|
|
@@ -724,10 +724,10 @@ static void npcm7xx_connect_clocks(NPCM7xxCLKState *clk)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-static uint64_t npcm7xx_clk_read(void *opaque, hwaddr offset, unsigned size)
|
|
|
+static uint64_t npcm_clk_read(void *opaque, hwaddr offset, unsigned size)
|
|
|
{
|
|
|
uint32_t reg = offset / sizeof(uint32_t);
|
|
|
- NPCM7xxCLKState *s = opaque;
|
|
|
+ NPCMCLKState *s = opaque;
|
|
|
int64_t now_ns;
|
|
|
uint32_t value = 0;
|
|
|
|
|
@@ -766,19 +766,19 @@ static uint64_t npcm7xx_clk_read(void *opaque, hwaddr offset, unsigned size)
|
|
|
break;
|
|
|
};
|
|
|
|
|
|
- trace_npcm7xx_clk_read(offset, value);
|
|
|
+ trace_npcm_clk_read(offset, value);
|
|
|
|
|
|
return value;
|
|
|
}
|
|
|
|
|
|
-static void npcm7xx_clk_write(void *opaque, hwaddr offset,
|
|
|
+static void npcm_clk_write(void *opaque, hwaddr offset,
|
|
|
uint64_t v, unsigned size)
|
|
|
{
|
|
|
uint32_t reg = offset / sizeof(uint32_t);
|
|
|
- NPCM7xxCLKState *s = opaque;
|
|
|
+ NPCMCLKState *s = opaque;
|
|
|
uint32_t value = v;
|
|
|
|
|
|
- trace_npcm7xx_clk_write(offset, value);
|
|
|
+ trace_npcm_clk_write(offset, value);
|
|
|
|
|
|
if (reg >= NPCM7XX_CLK_NR_REGS) {
|
|
|
qemu_log_mask(LOG_GUEST_ERROR,
|
|
@@ -842,7 +842,7 @@ static void npcm7xx_clk_write(void *opaque, hwaddr offset,
|
|
|
static void npcm7xx_clk_perform_watchdog_reset(void *opaque, int n,
|
|
|
int level)
|
|
|
{
|
|
|
- NPCM7xxCLKState *clk = NPCM7XX_CLK(opaque);
|
|
|
+ NPCMCLKState *clk = NPCM_CLK(opaque);
|
|
|
uint32_t rcr;
|
|
|
|
|
|
g_assert(n >= 0 && n <= NPCM7XX_NR_WATCHDOGS);
|
|
@@ -856,9 +856,9 @@ static void npcm7xx_clk_perform_watchdog_reset(void *opaque, int n,
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-static const struct MemoryRegionOps npcm7xx_clk_ops = {
|
|
|
- .read = npcm7xx_clk_read,
|
|
|
- .write = npcm7xx_clk_write,
|
|
|
+static const struct MemoryRegionOps npcm_clk_ops = {
|
|
|
+ .read = npcm_clk_read,
|
|
|
+ .write = npcm_clk_write,
|
|
|
.endianness = DEVICE_LITTLE_ENDIAN,
|
|
|
.valid = {
|
|
|
.min_access_size = 4,
|
|
@@ -867,9 +867,9 @@ static const struct MemoryRegionOps npcm7xx_clk_ops = {
|
|
|
},
|
|
|
};
|
|
|
|
|
|
-static void npcm7xx_clk_enter_reset(Object *obj, ResetType type)
|
|
|
+static void npcm_clk_enter_reset(Object *obj, ResetType type)
|
|
|
{
|
|
|
- NPCM7xxCLKState *s = NPCM7XX_CLK(obj);
|
|
|
+ NPCMCLKState *s = NPCM_CLK(obj);
|
|
|
|
|
|
QEMU_BUILD_BUG_ON(sizeof(s->regs) != sizeof(cold_reset_values));
|
|
|
|
|
@@ -882,7 +882,7 @@ static void npcm7xx_clk_enter_reset(Object *obj, ResetType type)
|
|
|
*/
|
|
|
}
|
|
|
|
|
|
-static void npcm7xx_clk_init_clock_hierarchy(NPCM7xxCLKState *s)
|
|
|
+static void npcm7xx_clk_init_clock_hierarchy(NPCMCLKState *s)
|
|
|
{
|
|
|
int i;
|
|
|
|
|
@@ -918,19 +918,19 @@ static void npcm7xx_clk_init_clock_hierarchy(NPCM7xxCLKState *s)
|
|
|
clock_update_hz(s->clkref, NPCM7XX_CLOCK_REF_HZ);
|
|
|
}
|
|
|
|
|
|
-static void npcm7xx_clk_init(Object *obj)
|
|
|
+static void npcm_clk_init(Object *obj)
|
|
|
{
|
|
|
- NPCM7xxCLKState *s = NPCM7XX_CLK(obj);
|
|
|
+ NPCMCLKState *s = NPCM_CLK(obj);
|
|
|
|
|
|
- memory_region_init_io(&s->iomem, obj, &npcm7xx_clk_ops, s,
|
|
|
- TYPE_NPCM7XX_CLK, 4 * KiB);
|
|
|
+ memory_region_init_io(&s->iomem, obj, &npcm_clk_ops, s,
|
|
|
+ TYPE_NPCM_CLK, 4 * KiB);
|
|
|
sysbus_init_mmio(SYS_BUS_DEVICE(s), &s->iomem);
|
|
|
}
|
|
|
|
|
|
-static int npcm7xx_clk_post_load(void *opaque, int version_id)
|
|
|
+static int npcm_clk_post_load(void *opaque, int version_id)
|
|
|
{
|
|
|
if (version_id >= 1) {
|
|
|
- NPCM7xxCLKState *clk = opaque;
|
|
|
+ NPCMCLKState *clk = opaque;
|
|
|
|
|
|
npcm7xx_clk_update_all_clocks(clk);
|
|
|
}
|
|
@@ -938,10 +938,10 @@ static int npcm7xx_clk_post_load(void *opaque, int version_id)
|
|
|
return 0;
|
|
|
}
|
|
|
|
|
|
-static void npcm7xx_clk_realize(DeviceState *dev, Error **errp)
|
|
|
+static void npcm_clk_realize(DeviceState *dev, Error **errp)
|
|
|
{
|
|
|
int i;
|
|
|
- NPCM7xxCLKState *s = NPCM7XX_CLK(dev);
|
|
|
+ NPCMCLKState *s = NPCM_CLK(dev);
|
|
|
|
|
|
qdev_init_gpio_in_named(DEVICE(s), npcm7xx_clk_perform_watchdog_reset,
|
|
|
NPCM7XX_WATCHDOG_RESET_GPIO_IN, NPCM7XX_NR_WATCHDOGS);
|
|
@@ -996,15 +996,15 @@ static const VMStateDescription vmstate_npcm7xx_clk_divider = {
|
|
|
},
|
|
|
};
|
|
|
|
|
|
-static const VMStateDescription vmstate_npcm7xx_clk = {
|
|
|
- .name = "npcm7xx-clk",
|
|
|
- .version_id = 1,
|
|
|
- .minimum_version_id = 1,
|
|
|
- .post_load = npcm7xx_clk_post_load,
|
|
|
+static const VMStateDescription vmstate_npcm_clk = {
|
|
|
+ .name = "npcm-clk",
|
|
|
+ .version_id = 2,
|
|
|
+ .minimum_version_id = 2,
|
|
|
+ .post_load = npcm_clk_post_load,
|
|
|
.fields = (const VMStateField[]) {
|
|
|
- VMSTATE_UINT32_ARRAY(regs, NPCM7xxCLKState, NPCM7XX_CLK_NR_REGS),
|
|
|
- VMSTATE_INT64(ref_ns, NPCM7xxCLKState),
|
|
|
- VMSTATE_CLOCK(clkref, NPCM7xxCLKState),
|
|
|
+ VMSTATE_UINT32_ARRAY(regs, NPCMCLKState, NPCM_CLK_MAX_NR_REGS),
|
|
|
+ VMSTATE_INT64(ref_ns, NPCMCLKState),
|
|
|
+ VMSTATE_CLOCK(clkref, NPCMCLKState),
|
|
|
VMSTATE_END_OF_LIST(),
|
|
|
},
|
|
|
};
|
|
@@ -1033,17 +1033,23 @@ static void npcm7xx_clk_divider_class_init(ObjectClass *klass, void *data)
|
|
|
dc->vmsd = &vmstate_npcm7xx_clk_divider;
|
|
|
}
|
|
|
|
|
|
-static void npcm7xx_clk_class_init(ObjectClass *klass, void *data)
|
|
|
+static void npcm_clk_class_init(ObjectClass *klass, void *data)
|
|
|
{
|
|
|
ResettableClass *rc = RESETTABLE_CLASS(klass);
|
|
|
DeviceClass *dc = DEVICE_CLASS(klass);
|
|
|
|
|
|
- QEMU_BUILD_BUG_ON(NPCM7XX_CLK_REGS_END > NPCM7XX_CLK_NR_REGS);
|
|
|
+ dc->vmsd = &vmstate_npcm_clk;
|
|
|
+ dc->realize = npcm_clk_realize;
|
|
|
+ rc->phases.enter = npcm_clk_enter_reset;
|
|
|
+}
|
|
|
+
|
|
|
+static void npcm7xx_clk_class_init(ObjectClass *klass, void *data)
|
|
|
+{
|
|
|
+ DeviceClass *dc = DEVICE_CLASS(klass);
|
|
|
|
|
|
+ QEMU_BUILD_BUG_ON(NPCM7XX_CLK_REGS_END > NPCM_CLK_MAX_NR_REGS);
|
|
|
+ QEMU_BUILD_BUG_ON(NPCM7XX_CLK_REGS_END != NPCM7XX_CLK_NR_REGS);
|
|
|
dc->desc = "NPCM7xx Clock Control Registers";
|
|
|
- dc->vmsd = &vmstate_npcm7xx_clk;
|
|
|
- dc->realize = npcm7xx_clk_realize;
|
|
|
- rc->phases.enter = npcm7xx_clk_enter_reset;
|
|
|
}
|
|
|
|
|
|
static const TypeInfo npcm7xx_clk_pll_info = {
|
|
@@ -1070,11 +1076,18 @@ static const TypeInfo npcm7xx_clk_divider_info = {
|
|
|
.class_init = npcm7xx_clk_divider_class_init,
|
|
|
};
|
|
|
|
|
|
+static const TypeInfo npcm_clk_info = {
|
|
|
+ .name = TYPE_NPCM_CLK,
|
|
|
+ .parent = TYPE_SYS_BUS_DEVICE,
|
|
|
+ .instance_size = sizeof(NPCMCLKState),
|
|
|
+ .instance_init = npcm_clk_init,
|
|
|
+ .class_init = npcm_clk_class_init,
|
|
|
+ .abstract = true,
|
|
|
+};
|
|
|
+
|
|
|
static const TypeInfo npcm7xx_clk_info = {
|
|
|
.name = TYPE_NPCM7XX_CLK,
|
|
|
- .parent = TYPE_SYS_BUS_DEVICE,
|
|
|
- .instance_size = sizeof(NPCM7xxCLKState),
|
|
|
- .instance_init = npcm7xx_clk_init,
|
|
|
+ .parent = TYPE_NPCM_CLK,
|
|
|
.class_init = npcm7xx_clk_class_init,
|
|
|
};
|
|
|
|
|
@@ -1083,6 +1096,7 @@ static void npcm7xx_clk_register_type(void)
|
|
|
type_register_static(&npcm7xx_clk_pll_info);
|
|
|
type_register_static(&npcm7xx_clk_sel_info);
|
|
|
type_register_static(&npcm7xx_clk_divider_info);
|
|
|
+ type_register_static(&npcm_clk_info);
|
|
|
type_register_static(&npcm7xx_clk_info);
|
|
|
}
|
|
|
type_init(npcm7xx_clk_register_type);
|