xref: /qemu/include/hw/misc/imx_ccm.h (revision db1015e92e04835c9eb50c29625fe566d1202dbd)
1 /*
2  * IMX Clock Control Module base class
3  *
4  * Copyright (C) 2012 NICTA
5  * Updated by Jean-Christophe Dubois <jcd@tribudubois.net>
6  *
7  * This work is licensed under the terms of the GNU GPL, version 2 or later.
8  * See the COPYING file in the top-level directory.
9  */
10 
11 #ifndef IMX_CCM_H
12 #define IMX_CCM_H
13 
14 #include "hw/sysbus.h"
15 #include "qom/object.h"
16 
17 #define CKIL_FREQ 32768 /* nominal 32khz clock */
18 
19 /* PLL control registers */
20 #define PD(v) (((v) >> 26) & 0xf)
21 #define MFD(v) (((v) >> 16) & 0x3ff)
22 #define MFI(v) (((v) >> 10) & 0xf);
23 #define MFN(v) ((v) & 0x3ff)
24 
25 #define PLL_PD(x)               (((x) & 0xf) << 26)
26 #define PLL_MFD(x)              (((x) & 0x3ff) << 16)
27 #define PLL_MFI(x)              (((x) & 0xf) << 10)
28 #define PLL_MFN(x)              (((x) & 0x3ff) << 0)
29 
30 #define TYPE_IMX_CCM "imx.ccm"
31 typedef struct IMXCCMClass IMXCCMClass;
32 typedef struct IMXCCMState IMXCCMState;
33 #define IMX_CCM(obj) \
34      OBJECT_CHECK(IMXCCMState, (obj), TYPE_IMX_CCM)
35 #define IMX_CCM_CLASS(klass) \
36      OBJECT_CLASS_CHECK(IMXCCMClass, (klass), TYPE_IMX_CCM)
37 #define IMX_CCM_GET_CLASS(obj) \
38      OBJECT_GET_CLASS(IMXCCMClass, (obj), TYPE_IMX_CCM)
39 
40 struct IMXCCMState {
41     /* <private> */
42     SysBusDevice parent_obj;
43 
44     /* <public> */
45 
46 };
47 
48 typedef enum  {
49     CLK_NONE,
50     CLK_IPG,
51     CLK_IPG_HIGH,
52     CLK_32k,
53     CLK_EXT,
54     CLK_HIGH_DIV,
55     CLK_HIGH,
56 } IMXClk;
57 
58 struct IMXCCMClass {
59     /* <private> */
60     SysBusDeviceClass parent_class;
61 
62     /* <public> */
63     uint32_t (*get_clock_frequency)(IMXCCMState *s, IMXClk clk);
64 };
65 
66 uint32_t imx_ccm_calc_pll(uint32_t pllreg, uint32_t base_freq);
67 
68 uint32_t imx_ccm_get_clock_frequency(IMXCCMState *s, IMXClk clock);
69 
70 #endif /* IMX_CCM_H */
71