xref: /openbmc/qemu/hw/misc/imx25_ccm.c (revision 28ae3179fc52d2e4d870b635c4a412aab99759e7)
192eccc6eSJean-Christophe Dubois /*
292eccc6eSJean-Christophe Dubois  * IMX25 Clock Control Module
392eccc6eSJean-Christophe Dubois  *
492eccc6eSJean-Christophe Dubois  * Copyright (C) 2012 NICTA
592eccc6eSJean-Christophe Dubois  * Updated by Jean-Christophe Dubois <jcd@tribudubois.net>
692eccc6eSJean-Christophe Dubois  *
792eccc6eSJean-Christophe Dubois  * This work is licensed under the terms of the GNU GPL, version 2 or later.
892eccc6eSJean-Christophe Dubois  * See the COPYING file in the top-level directory.
992eccc6eSJean-Christophe Dubois  *
1092eccc6eSJean-Christophe Dubois  * To get the timer frequencies right, we need to emulate at least part of
1192eccc6eSJean-Christophe Dubois  * the CCM.
1292eccc6eSJean-Christophe Dubois  */
1392eccc6eSJean-Christophe Dubois 
148ef94f0bSPeter Maydell #include "qemu/osdep.h"
1592eccc6eSJean-Christophe Dubois #include "hw/misc/imx25_ccm.h"
16d6454270SMarkus Armbruster #include "migration/vmstate.h"
1703dd024fSPaolo Bonzini #include "qemu/log.h"
180b8fa32fSMarkus Armbruster #include "qemu/module.h"
1992eccc6eSJean-Christophe Dubois 
2092eccc6eSJean-Christophe Dubois #ifndef DEBUG_IMX25_CCM
2192eccc6eSJean-Christophe Dubois #define DEBUG_IMX25_CCM 0
2292eccc6eSJean-Christophe Dubois #endif
2392eccc6eSJean-Christophe Dubois 
2492eccc6eSJean-Christophe Dubois #define DPRINTF(fmt, args...) \
2592eccc6eSJean-Christophe Dubois     do { \
2692eccc6eSJean-Christophe Dubois         if (DEBUG_IMX25_CCM) { \
2792eccc6eSJean-Christophe Dubois             fprintf(stderr, "[%s]%s: " fmt , TYPE_IMX25_CCM, \
2892eccc6eSJean-Christophe Dubois                                              __func__, ##args); \
2992eccc6eSJean-Christophe Dubois         } \
3092eccc6eSJean-Christophe Dubois     } while (0)
3192eccc6eSJean-Christophe Dubois 
imx25_ccm_reg_name(uint32_t reg)32d675765aSPeter Maydell static const char *imx25_ccm_reg_name(uint32_t reg)
3392eccc6eSJean-Christophe Dubois {
3492eccc6eSJean-Christophe Dubois     static char unknown[20];
3592eccc6eSJean-Christophe Dubois 
3692eccc6eSJean-Christophe Dubois     switch (reg) {
3792eccc6eSJean-Christophe Dubois     case IMX25_CCM_MPCTL_REG:
3892eccc6eSJean-Christophe Dubois         return "mpctl";
3992eccc6eSJean-Christophe Dubois     case IMX25_CCM_UPCTL_REG:
4092eccc6eSJean-Christophe Dubois         return "upctl";
4192eccc6eSJean-Christophe Dubois     case IMX25_CCM_CCTL_REG:
4292eccc6eSJean-Christophe Dubois         return "cctl";
4392eccc6eSJean-Christophe Dubois     case IMX25_CCM_CGCR0_REG:
4492eccc6eSJean-Christophe Dubois         return "cgcr0";
4592eccc6eSJean-Christophe Dubois     case IMX25_CCM_CGCR1_REG:
4692eccc6eSJean-Christophe Dubois         return "cgcr1";
4792eccc6eSJean-Christophe Dubois     case IMX25_CCM_CGCR2_REG:
4892eccc6eSJean-Christophe Dubois         return "cgcr2";
4992eccc6eSJean-Christophe Dubois     case IMX25_CCM_PCDR0_REG:
5092eccc6eSJean-Christophe Dubois         return "pcdr0";
5192eccc6eSJean-Christophe Dubois     case IMX25_CCM_PCDR1_REG:
5292eccc6eSJean-Christophe Dubois         return "pcdr1";
5392eccc6eSJean-Christophe Dubois     case IMX25_CCM_PCDR2_REG:
5492eccc6eSJean-Christophe Dubois         return "pcdr2";
5592eccc6eSJean-Christophe Dubois     case IMX25_CCM_PCDR3_REG:
5692eccc6eSJean-Christophe Dubois         return "pcdr3";
5792eccc6eSJean-Christophe Dubois     case IMX25_CCM_RCSR_REG:
5892eccc6eSJean-Christophe Dubois         return "rcsr";
5992eccc6eSJean-Christophe Dubois     case IMX25_CCM_CRDR_REG:
6092eccc6eSJean-Christophe Dubois         return "crdr";
6192eccc6eSJean-Christophe Dubois     case IMX25_CCM_DCVR0_REG:
6292eccc6eSJean-Christophe Dubois         return "dcvr0";
6392eccc6eSJean-Christophe Dubois     case IMX25_CCM_DCVR1_REG:
6492eccc6eSJean-Christophe Dubois         return "dcvr1";
6592eccc6eSJean-Christophe Dubois     case IMX25_CCM_DCVR2_REG:
6692eccc6eSJean-Christophe Dubois         return "dcvr2";
6792eccc6eSJean-Christophe Dubois     case IMX25_CCM_DCVR3_REG:
6892eccc6eSJean-Christophe Dubois         return "dcvr3";
6992eccc6eSJean-Christophe Dubois     case IMX25_CCM_LTR0_REG:
7092eccc6eSJean-Christophe Dubois         return "ltr0";
7192eccc6eSJean-Christophe Dubois     case IMX25_CCM_LTR1_REG:
7292eccc6eSJean-Christophe Dubois         return "ltr1";
7392eccc6eSJean-Christophe Dubois     case IMX25_CCM_LTR2_REG:
7492eccc6eSJean-Christophe Dubois         return "ltr2";
7592eccc6eSJean-Christophe Dubois     case IMX25_CCM_LTR3_REG:
7692eccc6eSJean-Christophe Dubois         return "ltr3";
7792eccc6eSJean-Christophe Dubois     case IMX25_CCM_LTBR0_REG:
7892eccc6eSJean-Christophe Dubois         return "ltbr0";
7992eccc6eSJean-Christophe Dubois     case IMX25_CCM_LTBR1_REG:
8092eccc6eSJean-Christophe Dubois         return "ltbr1";
8192eccc6eSJean-Christophe Dubois     case IMX25_CCM_PMCR0_REG:
8292eccc6eSJean-Christophe Dubois         return "pmcr0";
8392eccc6eSJean-Christophe Dubois     case IMX25_CCM_PMCR1_REG:
8492eccc6eSJean-Christophe Dubois         return "pmcr1";
8592eccc6eSJean-Christophe Dubois     case IMX25_CCM_PMCR2_REG:
8692eccc6eSJean-Christophe Dubois         return "pmcr2";
8792eccc6eSJean-Christophe Dubois     case IMX25_CCM_MCR_REG:
8892eccc6eSJean-Christophe Dubois         return "mcr";
8992eccc6eSJean-Christophe Dubois     case IMX25_CCM_LPIMR0_REG:
9092eccc6eSJean-Christophe Dubois         return "lpimr0";
9192eccc6eSJean-Christophe Dubois     case IMX25_CCM_LPIMR1_REG:
9292eccc6eSJean-Christophe Dubois         return "lpimr1";
9392eccc6eSJean-Christophe Dubois     default:
94ca4af17cSPhilippe Mathieu-Daudé         snprintf(unknown, sizeof(unknown), "[%u ?]", reg);
9592eccc6eSJean-Christophe Dubois         return unknown;
9692eccc6eSJean-Christophe Dubois     }
9792eccc6eSJean-Christophe Dubois }
9892eccc6eSJean-Christophe Dubois #define CKIH_FREQ 24000000 /* 24MHz crystal input */
9992eccc6eSJean-Christophe Dubois 
10092eccc6eSJean-Christophe Dubois static const VMStateDescription vmstate_imx25_ccm = {
10192eccc6eSJean-Christophe Dubois     .name = TYPE_IMX25_CCM,
10292eccc6eSJean-Christophe Dubois     .version_id = 1,
10392eccc6eSJean-Christophe Dubois     .minimum_version_id = 1,
104e4ea952fSRichard Henderson     .fields = (const VMStateField[]) {
10592eccc6eSJean-Christophe Dubois         VMSTATE_UINT32_ARRAY(reg, IMX25CCMState, IMX25_CCM_MAX_REG),
10692eccc6eSJean-Christophe Dubois         VMSTATE_END_OF_LIST()
10792eccc6eSJean-Christophe Dubois     },
10892eccc6eSJean-Christophe Dubois };
10992eccc6eSJean-Christophe Dubois 
imx25_ccm_get_mpll_clk(IMXCCMState * dev)11092eccc6eSJean-Christophe Dubois static uint32_t imx25_ccm_get_mpll_clk(IMXCCMState *dev)
11192eccc6eSJean-Christophe Dubois {
11292eccc6eSJean-Christophe Dubois     uint32_t freq;
11392eccc6eSJean-Christophe Dubois     IMX25CCMState *s = IMX25_CCM(dev);
11492eccc6eSJean-Christophe Dubois 
11592eccc6eSJean-Christophe Dubois     if (EXTRACT(s->reg[IMX25_CCM_CCTL_REG], MPLL_BYPASS)) {
11692eccc6eSJean-Christophe Dubois         freq = CKIH_FREQ;
11792eccc6eSJean-Christophe Dubois     } else {
11892eccc6eSJean-Christophe Dubois         freq = imx_ccm_calc_pll(s->reg[IMX25_CCM_MPCTL_REG], CKIH_FREQ);
11992eccc6eSJean-Christophe Dubois     }
12092eccc6eSJean-Christophe Dubois 
12126c69099SAlex Chen     DPRINTF("freq = %u\n", freq);
12292eccc6eSJean-Christophe Dubois 
12392eccc6eSJean-Christophe Dubois     return freq;
12492eccc6eSJean-Christophe Dubois }
12592eccc6eSJean-Christophe Dubois 
imx25_ccm_get_mcu_clk(IMXCCMState * dev)12692eccc6eSJean-Christophe Dubois static uint32_t imx25_ccm_get_mcu_clk(IMXCCMState *dev)
12792eccc6eSJean-Christophe Dubois {
12892eccc6eSJean-Christophe Dubois     uint32_t freq;
12992eccc6eSJean-Christophe Dubois     IMX25CCMState *s = IMX25_CCM(dev);
13092eccc6eSJean-Christophe Dubois 
13192eccc6eSJean-Christophe Dubois     freq = imx25_ccm_get_mpll_clk(dev);
13292eccc6eSJean-Christophe Dubois 
13392eccc6eSJean-Christophe Dubois     if (EXTRACT(s->reg[IMX25_CCM_CCTL_REG], ARM_SRC)) {
13492eccc6eSJean-Christophe Dubois         freq = (freq * 3 / 4);
13592eccc6eSJean-Christophe Dubois     }
13692eccc6eSJean-Christophe Dubois 
13792eccc6eSJean-Christophe Dubois     freq = freq / (1 + EXTRACT(s->reg[IMX25_CCM_CCTL_REG], ARM_CLK_DIV));
13892eccc6eSJean-Christophe Dubois 
13926c69099SAlex Chen     DPRINTF("freq = %u\n", freq);
14092eccc6eSJean-Christophe Dubois 
14192eccc6eSJean-Christophe Dubois     return freq;
14292eccc6eSJean-Christophe Dubois }
14392eccc6eSJean-Christophe Dubois 
imx25_ccm_get_ahb_clk(IMXCCMState * dev)14492eccc6eSJean-Christophe Dubois static uint32_t imx25_ccm_get_ahb_clk(IMXCCMState *dev)
14592eccc6eSJean-Christophe Dubois {
14692eccc6eSJean-Christophe Dubois     uint32_t freq;
14792eccc6eSJean-Christophe Dubois     IMX25CCMState *s = IMX25_CCM(dev);
14892eccc6eSJean-Christophe Dubois 
14992eccc6eSJean-Christophe Dubois     freq = imx25_ccm_get_mcu_clk(dev)
15092eccc6eSJean-Christophe Dubois            / (1 + EXTRACT(s->reg[IMX25_CCM_CCTL_REG], AHB_CLK_DIV));
15192eccc6eSJean-Christophe Dubois 
15226c69099SAlex Chen     DPRINTF("freq = %u\n", freq);
15392eccc6eSJean-Christophe Dubois 
15492eccc6eSJean-Christophe Dubois     return freq;
15592eccc6eSJean-Christophe Dubois }
15692eccc6eSJean-Christophe Dubois 
imx25_ccm_get_ipg_clk(IMXCCMState * dev)15792eccc6eSJean-Christophe Dubois static uint32_t imx25_ccm_get_ipg_clk(IMXCCMState *dev)
15892eccc6eSJean-Christophe Dubois {
15992eccc6eSJean-Christophe Dubois     uint32_t freq;
16092eccc6eSJean-Christophe Dubois 
16192eccc6eSJean-Christophe Dubois     freq = imx25_ccm_get_ahb_clk(dev) / 2;
16292eccc6eSJean-Christophe Dubois 
16326c69099SAlex Chen     DPRINTF("freq = %u\n", freq);
16492eccc6eSJean-Christophe Dubois 
16592eccc6eSJean-Christophe Dubois     return freq;
16692eccc6eSJean-Christophe Dubois }
16792eccc6eSJean-Christophe Dubois 
imx25_ccm_get_clock_frequency(IMXCCMState * dev,IMXClk clock)16892eccc6eSJean-Christophe Dubois static uint32_t imx25_ccm_get_clock_frequency(IMXCCMState *dev, IMXClk clock)
16992eccc6eSJean-Christophe Dubois {
17092eccc6eSJean-Christophe Dubois     uint32_t freq = 0;
17192eccc6eSJean-Christophe Dubois     DPRINTF("Clock = %d)\n", clock);
17292eccc6eSJean-Christophe Dubois 
17392eccc6eSJean-Christophe Dubois     switch (clock) {
174c91a5883SJean-Christophe Dubois     case CLK_NONE:
17592eccc6eSJean-Christophe Dubois         break;
17692eccc6eSJean-Christophe Dubois     case CLK_IPG:
177d552f675SJean-Christophe Dubois     case CLK_IPG_HIGH:
17892eccc6eSJean-Christophe Dubois         freq = imx25_ccm_get_ipg_clk(dev);
17992eccc6eSJean-Christophe Dubois         break;
18092eccc6eSJean-Christophe Dubois     case CLK_32k:
18192eccc6eSJean-Christophe Dubois         freq = CKIL_FREQ;
18292eccc6eSJean-Christophe Dubois         break;
18392eccc6eSJean-Christophe Dubois     default:
18492eccc6eSJean-Christophe Dubois         qemu_log_mask(LOG_GUEST_ERROR, "[%s]%s: unsupported clock %d\n",
18592eccc6eSJean-Christophe Dubois                       TYPE_IMX25_CCM, __func__, clock);
18692eccc6eSJean-Christophe Dubois         break;
18792eccc6eSJean-Christophe Dubois     }
18892eccc6eSJean-Christophe Dubois 
18926c69099SAlex Chen     DPRINTF("Clock = %d) = %u\n", clock, freq);
19092eccc6eSJean-Christophe Dubois 
19192eccc6eSJean-Christophe Dubois     return freq;
19292eccc6eSJean-Christophe Dubois }
19392eccc6eSJean-Christophe Dubois 
imx25_ccm_reset(DeviceState * dev)19492eccc6eSJean-Christophe Dubois static void imx25_ccm_reset(DeviceState *dev)
19592eccc6eSJean-Christophe Dubois {
19692eccc6eSJean-Christophe Dubois     IMX25CCMState *s = IMX25_CCM(dev);
19792eccc6eSJean-Christophe Dubois 
19892eccc6eSJean-Christophe Dubois     DPRINTF("\n");
19992eccc6eSJean-Christophe Dubois 
20092eccc6eSJean-Christophe Dubois     memset(s->reg, 0, IMX25_CCM_MAX_REG * sizeof(uint32_t));
20192eccc6eSJean-Christophe Dubois     s->reg[IMX25_CCM_MPCTL_REG] = 0x800b2c01;
20292eccc6eSJean-Christophe Dubois     s->reg[IMX25_CCM_UPCTL_REG] = 0x84042800;
20392eccc6eSJean-Christophe Dubois     /*
20492eccc6eSJean-Christophe Dubois      * The value below gives:
20592eccc6eSJean-Christophe Dubois      * CPU = 133 MHz, AHB = 66,5 MHz, IPG = 33 MHz.
20692eccc6eSJean-Christophe Dubois      */
20792eccc6eSJean-Christophe Dubois     s->reg[IMX25_CCM_CCTL_REG]  = 0xd0030000;
20892eccc6eSJean-Christophe Dubois     s->reg[IMX25_CCM_CGCR0_REG] = 0x028A0100;
20992eccc6eSJean-Christophe Dubois     s->reg[IMX25_CCM_CGCR1_REG] = 0x04008100;
21092eccc6eSJean-Christophe Dubois     s->reg[IMX25_CCM_CGCR2_REG] = 0x00000438;
21192eccc6eSJean-Christophe Dubois     s->reg[IMX25_CCM_PCDR0_REG] = 0x01010101;
21292eccc6eSJean-Christophe Dubois     s->reg[IMX25_CCM_PCDR1_REG] = 0x01010101;
21392eccc6eSJean-Christophe Dubois     s->reg[IMX25_CCM_PCDR2_REG] = 0x01010101;
21492eccc6eSJean-Christophe Dubois     s->reg[IMX25_CCM_PCDR3_REG] = 0x01010101;
21592eccc6eSJean-Christophe Dubois     s->reg[IMX25_CCM_PMCR0_REG] = 0x00A00000;
21692eccc6eSJean-Christophe Dubois     s->reg[IMX25_CCM_PMCR1_REG] = 0x0000A030;
21792eccc6eSJean-Christophe Dubois     s->reg[IMX25_CCM_PMCR2_REG] = 0x0000A030;
21892eccc6eSJean-Christophe Dubois     s->reg[IMX25_CCM_MCR_REG]   = 0x43000000;
21992eccc6eSJean-Christophe Dubois 
22092eccc6eSJean-Christophe Dubois     /*
22192eccc6eSJean-Christophe Dubois      * default boot will change the reset values to allow:
22292eccc6eSJean-Christophe Dubois      * CPU = 399 MHz, AHB = 133 MHz, IPG = 66,5 MHz.
22392eccc6eSJean-Christophe Dubois      * For some reason, this doesn't work. With the value below, linux
22492eccc6eSJean-Christophe Dubois      * detects a 88 MHz IPG CLK instead of 66,5 MHz.
22592eccc6eSJean-Christophe Dubois     s->reg[IMX25_CCM_CCTL_REG]  = 0x20032000;
22692eccc6eSJean-Christophe Dubois      */
22792eccc6eSJean-Christophe Dubois }
22892eccc6eSJean-Christophe Dubois 
imx25_ccm_read(void * opaque,hwaddr offset,unsigned size)22992eccc6eSJean-Christophe Dubois static uint64_t imx25_ccm_read(void *opaque, hwaddr offset, unsigned size)
23092eccc6eSJean-Christophe Dubois {
2313a87d009SPeter Maydell     uint32_t value = 0;
23292eccc6eSJean-Christophe Dubois     IMX25CCMState *s = (IMX25CCMState *)opaque;
23392eccc6eSJean-Christophe Dubois 
23492eccc6eSJean-Christophe Dubois     if (offset < 0x70) {
23592eccc6eSJean-Christophe Dubois         value = s->reg[offset >> 2];
23692eccc6eSJean-Christophe Dubois     } else {
23792eccc6eSJean-Christophe Dubois         qemu_log_mask(LOG_GUEST_ERROR, "[%s]%s: Bad register at offset 0x%"
23892eccc6eSJean-Christophe Dubois                       HWADDR_PRIx "\n", TYPE_IMX25_CCM, __func__, offset);
23992eccc6eSJean-Christophe Dubois     }
24092eccc6eSJean-Christophe Dubois 
24192eccc6eSJean-Christophe Dubois     DPRINTF("reg[%s] => 0x%" PRIx32 "\n", imx25_ccm_reg_name(offset >> 2),
24292eccc6eSJean-Christophe Dubois             value);
24392eccc6eSJean-Christophe Dubois 
24492eccc6eSJean-Christophe Dubois     return value;
24592eccc6eSJean-Christophe Dubois }
24692eccc6eSJean-Christophe Dubois 
imx25_ccm_write(void * opaque,hwaddr offset,uint64_t value,unsigned size)24792eccc6eSJean-Christophe Dubois static void imx25_ccm_write(void *opaque, hwaddr offset, uint64_t value,
24892eccc6eSJean-Christophe Dubois                             unsigned size)
24992eccc6eSJean-Christophe Dubois {
25092eccc6eSJean-Christophe Dubois     IMX25CCMState *s = (IMX25CCMState *)opaque;
25192eccc6eSJean-Christophe Dubois 
25292eccc6eSJean-Christophe Dubois     DPRINTF("reg[%s] <= 0x%" PRIx32 "\n", imx25_ccm_reg_name(offset >> 2),
25392eccc6eSJean-Christophe Dubois             (uint32_t)value);
25492eccc6eSJean-Christophe Dubois 
25592eccc6eSJean-Christophe Dubois     if (offset < 0x70) {
25692eccc6eSJean-Christophe Dubois         /*
25792eccc6eSJean-Christophe Dubois          * We will do a better implementation later. In particular some bits
25892eccc6eSJean-Christophe Dubois          * cannot be written to.
25992eccc6eSJean-Christophe Dubois          */
26092eccc6eSJean-Christophe Dubois         s->reg[offset >> 2] = value;
26192eccc6eSJean-Christophe Dubois     } else {
26292eccc6eSJean-Christophe Dubois         qemu_log_mask(LOG_GUEST_ERROR, "[%s]%s: Bad register at offset 0x%"
26392eccc6eSJean-Christophe Dubois                       HWADDR_PRIx "\n", TYPE_IMX25_CCM, __func__, offset);
26492eccc6eSJean-Christophe Dubois     }
26592eccc6eSJean-Christophe Dubois }
26692eccc6eSJean-Christophe Dubois 
26792eccc6eSJean-Christophe Dubois static const struct MemoryRegionOps imx25_ccm_ops = {
26892eccc6eSJean-Christophe Dubois     .read = imx25_ccm_read,
26992eccc6eSJean-Christophe Dubois     .write = imx25_ccm_write,
27092eccc6eSJean-Christophe Dubois     .endianness = DEVICE_NATIVE_ENDIAN,
27192eccc6eSJean-Christophe Dubois     .valid = {
27292eccc6eSJean-Christophe Dubois         /*
27392eccc6eSJean-Christophe Dubois          * Our device would not work correctly if the guest was doing
27492eccc6eSJean-Christophe Dubois          * unaligned access. This might not be a limitation on the real
27592eccc6eSJean-Christophe Dubois          * device but in practice there is no reason for a guest to access
27692eccc6eSJean-Christophe Dubois          * this device unaligned.
27792eccc6eSJean-Christophe Dubois          */
27892eccc6eSJean-Christophe Dubois         .min_access_size = 4,
27992eccc6eSJean-Christophe Dubois         .max_access_size = 4,
28092eccc6eSJean-Christophe Dubois         .unaligned = false,
28192eccc6eSJean-Christophe Dubois     },
28292eccc6eSJean-Christophe Dubois };
28392eccc6eSJean-Christophe Dubois 
imx25_ccm_init(Object * obj)28492eccc6eSJean-Christophe Dubois static void imx25_ccm_init(Object *obj)
28592eccc6eSJean-Christophe Dubois {
28692eccc6eSJean-Christophe Dubois     DeviceState *dev = DEVICE(obj);
28792eccc6eSJean-Christophe Dubois     SysBusDevice *sd = SYS_BUS_DEVICE(obj);
28892eccc6eSJean-Christophe Dubois     IMX25CCMState *s = IMX25_CCM(obj);
28992eccc6eSJean-Christophe Dubois 
29092eccc6eSJean-Christophe Dubois     memory_region_init_io(&s->iomem, OBJECT(dev), &imx25_ccm_ops, s,
29192eccc6eSJean-Christophe Dubois                           TYPE_IMX25_CCM, 0x1000);
29292eccc6eSJean-Christophe Dubois     sysbus_init_mmio(sd, &s->iomem);
29392eccc6eSJean-Christophe Dubois }
29492eccc6eSJean-Christophe Dubois 
imx25_ccm_class_init(ObjectClass * klass,void * data)29592eccc6eSJean-Christophe Dubois static void imx25_ccm_class_init(ObjectClass *klass, void *data)
29692eccc6eSJean-Christophe Dubois {
29792eccc6eSJean-Christophe Dubois     DeviceClass *dc = DEVICE_CLASS(klass);
29892eccc6eSJean-Christophe Dubois     IMXCCMClass *ccm = IMX_CCM_CLASS(klass);
29992eccc6eSJean-Christophe Dubois 
300*e3d08143SPeter Maydell     device_class_set_legacy_reset(dc, imx25_ccm_reset);
30192eccc6eSJean-Christophe Dubois     dc->vmsd = &vmstate_imx25_ccm;
30292eccc6eSJean-Christophe Dubois     dc->desc = "i.MX25 Clock Control Module";
30392eccc6eSJean-Christophe Dubois 
30492eccc6eSJean-Christophe Dubois     ccm->get_clock_frequency = imx25_ccm_get_clock_frequency;
30592eccc6eSJean-Christophe Dubois }
30692eccc6eSJean-Christophe Dubois 
30792eccc6eSJean-Christophe Dubois static const TypeInfo imx25_ccm_info = {
30892eccc6eSJean-Christophe Dubois     .name          = TYPE_IMX25_CCM,
30992eccc6eSJean-Christophe Dubois     .parent        = TYPE_IMX_CCM,
31092eccc6eSJean-Christophe Dubois     .instance_size = sizeof(IMX25CCMState),
31192eccc6eSJean-Christophe Dubois     .instance_init = imx25_ccm_init,
31292eccc6eSJean-Christophe Dubois     .class_init    = imx25_ccm_class_init,
31392eccc6eSJean-Christophe Dubois };
31492eccc6eSJean-Christophe Dubois 
imx25_ccm_register_types(void)31592eccc6eSJean-Christophe Dubois static void imx25_ccm_register_types(void)
31692eccc6eSJean-Christophe Dubois {
31792eccc6eSJean-Christophe Dubois     type_register_static(&imx25_ccm_info);
31892eccc6eSJean-Christophe Dubois }
31992eccc6eSJean-Christophe Dubois 
32092eccc6eSJean-Christophe Dubois type_init(imx25_ccm_register_types)
321