xref: /qemu/include/hw/misc/imx_ccm.h (revision 282e74c83fd8af08d14fb1220a960e34b60e505f)
1*282e74c8SJean-Christophe Dubois /*
2*282e74c8SJean-Christophe Dubois  * IMX31 Clock Control Module
3*282e74c8SJean-Christophe Dubois  *
4*282e74c8SJean-Christophe Dubois  * Copyright (C) 2012 NICTA
5*282e74c8SJean-Christophe Dubois  * Updated by Jean-Christophe Dubois <jcd@tribudubois.net>
6*282e74c8SJean-Christophe Dubois  *
7*282e74c8SJean-Christophe Dubois  * This work is licensed under the terms of the GNU GPL, version 2 or later.
8*282e74c8SJean-Christophe Dubois  * See the COPYING file in the top-level directory.
9*282e74c8SJean-Christophe Dubois  */
10*282e74c8SJean-Christophe Dubois 
11*282e74c8SJean-Christophe Dubois #ifndef IMX_CCM_H
12*282e74c8SJean-Christophe Dubois #define IMX_CCM_H
13*282e74c8SJean-Christophe Dubois 
14*282e74c8SJean-Christophe Dubois #include "hw/sysbus.h"
15*282e74c8SJean-Christophe Dubois 
16*282e74c8SJean-Christophe Dubois /* CCMR */
17*282e74c8SJean-Christophe Dubois #define CCMR_FPME (1<<0)
18*282e74c8SJean-Christophe Dubois #define CCMR_MPE  (1<<3)
19*282e74c8SJean-Christophe Dubois #define CCMR_MDS  (1<<7)
20*282e74c8SJean-Christophe Dubois #define CCMR_FPMF (1<<26)
21*282e74c8SJean-Christophe Dubois #define CCMR_PRCS (3<<1)
22*282e74c8SJean-Christophe Dubois 
23*282e74c8SJean-Christophe Dubois /* PDR0 */
24*282e74c8SJean-Christophe Dubois #define PDR0_MCU_PODF_SHIFT (0)
25*282e74c8SJean-Christophe Dubois #define PDR0_MCU_PODF_MASK (0x7)
26*282e74c8SJean-Christophe Dubois #define PDR0_MAX_PODF_SHIFT (3)
27*282e74c8SJean-Christophe Dubois #define PDR0_MAX_PODF_MASK (0x7)
28*282e74c8SJean-Christophe Dubois #define PDR0_IPG_PODF_SHIFT (6)
29*282e74c8SJean-Christophe Dubois #define PDR0_IPG_PODF_MASK (0x3)
30*282e74c8SJean-Christophe Dubois #define PDR0_NFC_PODF_SHIFT (8)
31*282e74c8SJean-Christophe Dubois #define PDR0_NFC_PODF_MASK (0x7)
32*282e74c8SJean-Christophe Dubois #define PDR0_HSP_PODF_SHIFT (11)
33*282e74c8SJean-Christophe Dubois #define PDR0_HSP_PODF_MASK (0x7)
34*282e74c8SJean-Christophe Dubois #define PDR0_PER_PODF_SHIFT (16)
35*282e74c8SJean-Christophe Dubois #define PDR0_PER_PODF_MASK (0x1f)
36*282e74c8SJean-Christophe Dubois #define PDR0_CSI_PODF_SHIFT (23)
37*282e74c8SJean-Christophe Dubois #define PDR0_CSI_PODF_MASK (0x1ff)
38*282e74c8SJean-Christophe Dubois 
39*282e74c8SJean-Christophe Dubois #define EXTRACT(value, name) (((value) >> PDR0_##name##_PODF_SHIFT) \
40*282e74c8SJean-Christophe Dubois                               & PDR0_##name##_PODF_MASK)
41*282e74c8SJean-Christophe Dubois #define INSERT(value, name) (((value) & PDR0_##name##_PODF_MASK) << \
42*282e74c8SJean-Christophe Dubois                              PDR0_##name##_PODF_SHIFT)
43*282e74c8SJean-Christophe Dubois 
44*282e74c8SJean-Christophe Dubois /* PLL control registers */
45*282e74c8SJean-Christophe Dubois #define PD(v) (((v) >> 26) & 0xf)
46*282e74c8SJean-Christophe Dubois #define MFD(v) (((v) >> 16) & 0x3ff)
47*282e74c8SJean-Christophe Dubois #define MFI(v) (((v) >> 10) & 0xf);
48*282e74c8SJean-Christophe Dubois #define MFN(v) ((v) & 0x3ff)
49*282e74c8SJean-Christophe Dubois 
50*282e74c8SJean-Christophe Dubois #define PLL_PD(x)               (((x) & 0xf) << 26)
51*282e74c8SJean-Christophe Dubois #define PLL_MFD(x)              (((x) & 0x3ff) << 16)
52*282e74c8SJean-Christophe Dubois #define PLL_MFI(x)              (((x) & 0xf) << 10)
53*282e74c8SJean-Christophe Dubois #define PLL_MFN(x)              (((x) & 0x3ff) << 0)
54*282e74c8SJean-Christophe Dubois 
55*282e74c8SJean-Christophe Dubois #define TYPE_IMX_CCM "imx.ccm"
56*282e74c8SJean-Christophe Dubois #define IMX_CCM(obj) OBJECT_CHECK(IMXCCMState, (obj), TYPE_IMX_CCM)
57*282e74c8SJean-Christophe Dubois 
58*282e74c8SJean-Christophe Dubois typedef struct IMXCCMState {
59*282e74c8SJean-Christophe Dubois     /* <private> */
60*282e74c8SJean-Christophe Dubois     SysBusDevice parent_obj;
61*282e74c8SJean-Christophe Dubois 
62*282e74c8SJean-Christophe Dubois     /* <public> */
63*282e74c8SJean-Christophe Dubois     MemoryRegion iomem;
64*282e74c8SJean-Christophe Dubois 
65*282e74c8SJean-Christophe Dubois     uint32_t ccmr;
66*282e74c8SJean-Christophe Dubois     uint32_t pdr0;
67*282e74c8SJean-Christophe Dubois     uint32_t pdr1;
68*282e74c8SJean-Christophe Dubois     uint32_t mpctl;
69*282e74c8SJean-Christophe Dubois     uint32_t spctl;
70*282e74c8SJean-Christophe Dubois     uint32_t cgr[3];
71*282e74c8SJean-Christophe Dubois     uint32_t pmcr0;
72*282e74c8SJean-Christophe Dubois     uint32_t pmcr1;
73*282e74c8SJean-Christophe Dubois 
74*282e74c8SJean-Christophe Dubois     /* Frequencies precalculated on register changes */
75*282e74c8SJean-Christophe Dubois     uint32_t pll_refclk_freq;
76*282e74c8SJean-Christophe Dubois     uint32_t mcu_clk_freq;
77*282e74c8SJean-Christophe Dubois     uint32_t hsp_clk_freq;
78*282e74c8SJean-Christophe Dubois     uint32_t ipg_clk_freq;
79*282e74c8SJean-Christophe Dubois } IMXCCMState;
80*282e74c8SJean-Christophe Dubois 
81*282e74c8SJean-Christophe Dubois typedef enum  {
82*282e74c8SJean-Christophe Dubois     NOCLK,
83*282e74c8SJean-Christophe Dubois     MCU,
84*282e74c8SJean-Christophe Dubois     HSP,
85*282e74c8SJean-Christophe Dubois     IPG,
86*282e74c8SJean-Christophe Dubois     CLK_32k
87*282e74c8SJean-Christophe Dubois } IMXClk;
88*282e74c8SJean-Christophe Dubois 
89*282e74c8SJean-Christophe Dubois uint32_t imx_clock_frequency(DeviceState *s, IMXClk clock);
90*282e74c8SJean-Christophe Dubois 
91*282e74c8SJean-Christophe Dubois #endif /* IMX_CCM_H */
92