xref: /openbmc/qemu/include/hw/misc/imx_ccm.h (revision 709395f8)
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 
16 #define CKIL_FREQ 32768 /* nominal 32khz clock */
17 
18 /* PLL control registers */
19 #define PD(v) (((v) >> 26) & 0xf)
20 #define MFD(v) (((v) >> 16) & 0x3ff)
21 #define MFI(v) (((v) >> 10) & 0xf);
22 #define MFN(v) ((v) & 0x3ff)
23 
24 #define PLL_PD(x)               (((x) & 0xf) << 26)
25 #define PLL_MFD(x)              (((x) & 0x3ff) << 16)
26 #define PLL_MFI(x)              (((x) & 0xf) << 10)
27 #define PLL_MFN(x)              (((x) & 0x3ff) << 0)
28 
29 #define TYPE_IMX_CCM "imx.ccm"
30 #define IMX_CCM(obj) \
31      OBJECT_CHECK(IMXCCMState, (obj), TYPE_IMX_CCM)
32 #define IMX_CCM_CLASS(klass) \
33      OBJECT_CLASS_CHECK(IMXCCMClass, (klass), TYPE_IMX_CCM)
34 #define IMX_GET_CLASS(obj) \
35      OBJECT_GET_CLASS(IMXCCMClass, (obj), TYPE_IMX_CCM)
36 
37 typedef struct IMXCCMState {
38     /* <private> */
39     SysBusDevice parent_obj;
40 
41     /* <public> */
42 
43 } IMXCCMState;
44 
45 typedef enum  {
46     CLK_NONE,
47     CLK_IPG,
48     CLK_IPG_HIGH,
49     CLK_32k,
50     CLK_EXT,
51     CLK_HIGH_DIV,
52     CLK_HIGH,
53 } IMXClk;
54 
55 typedef struct IMXCCMClass {
56     /* <private> */
57     SysBusDeviceClass parent_class;
58 
59     /* <public> */
60     uint32_t (*get_clock_frequency)(IMXCCMState *s, IMXClk clk);
61 } IMXCCMClass;
62 
63 uint32_t imx_ccm_calc_pll(uint32_t pllreg, uint32_t base_freq);
64 
65 uint32_t imx_ccm_get_clock_frequency(IMXCCMState *s, IMXClk clock);
66 
67 #endif /* IMX_CCM_H */
68