1 /* 2 * Copyright (c) 2017, Impinj, Inc. 3 * 4 * i.MX7 CCM, PMU and ANALOG IP blocks emulation code 5 * 6 * Author: Andrey Smirnov <andrew.smirnov@gmail.com> 7 * 8 * This work is licensed under the terms of the GNU GPL, version 2 or later. 9 * See the COPYING file in the top-level directory. 10 */ 11 12 #ifndef IMX7_CCM_H 13 #define IMX7_CCM_H 14 15 #include "hw/misc/imx_ccm.h" 16 #include "qemu/bitops.h" 17 #include "qom/object.h" 18 19 enum IMX7AnalogRegisters { 20 ANALOG_PLL_ARM, 21 ANALOG_PLL_ARM_SET, 22 ANALOG_PLL_ARM_CLR, 23 ANALOG_PLL_ARM_TOG, 24 ANALOG_PLL_DDR, 25 ANALOG_PLL_DDR_SET, 26 ANALOG_PLL_DDR_CLR, 27 ANALOG_PLL_DDR_TOG, 28 ANALOG_PLL_DDR_SS, 29 ANALOG_PLL_DDR_SS_SET, 30 ANALOG_PLL_DDR_SS_CLR, 31 ANALOG_PLL_DDR_SS_TOG, 32 ANALOG_PLL_DDR_NUM, 33 ANALOG_PLL_DDR_NUM_SET, 34 ANALOG_PLL_DDR_NUM_CLR, 35 ANALOG_PLL_DDR_NUM_TOG, 36 ANALOG_PLL_DDR_DENOM, 37 ANALOG_PLL_DDR_DENOM_SET, 38 ANALOG_PLL_DDR_DENOM_CLR, 39 ANALOG_PLL_DDR_DENOM_TOG, 40 ANALOG_PLL_480, 41 ANALOG_PLL_480_SET, 42 ANALOG_PLL_480_CLR, 43 ANALOG_PLL_480_TOG, 44 ANALOG_PLL_480A, 45 ANALOG_PLL_480A_SET, 46 ANALOG_PLL_480A_CLR, 47 ANALOG_PLL_480A_TOG, 48 ANALOG_PLL_480B, 49 ANALOG_PLL_480B_SET, 50 ANALOG_PLL_480B_CLR, 51 ANALOG_PLL_480B_TOG, 52 ANALOG_PLL_ENET, 53 ANALOG_PLL_ENET_SET, 54 ANALOG_PLL_ENET_CLR, 55 ANALOG_PLL_ENET_TOG, 56 ANALOG_PLL_AUDIO, 57 ANALOG_PLL_AUDIO_SET, 58 ANALOG_PLL_AUDIO_CLR, 59 ANALOG_PLL_AUDIO_TOG, 60 ANALOG_PLL_AUDIO_SS, 61 ANALOG_PLL_AUDIO_SS_SET, 62 ANALOG_PLL_AUDIO_SS_CLR, 63 ANALOG_PLL_AUDIO_SS_TOG, 64 ANALOG_PLL_AUDIO_NUM, 65 ANALOG_PLL_AUDIO_NUM_SET, 66 ANALOG_PLL_AUDIO_NUM_CLR, 67 ANALOG_PLL_AUDIO_NUM_TOG, 68 ANALOG_PLL_AUDIO_DENOM, 69 ANALOG_PLL_AUDIO_DENOM_SET, 70 ANALOG_PLL_AUDIO_DENOM_CLR, 71 ANALOG_PLL_AUDIO_DENOM_TOG, 72 ANALOG_PLL_VIDEO, 73 ANALOG_PLL_VIDEO_SET, 74 ANALOG_PLL_VIDEO_CLR, 75 ANALOG_PLL_VIDEO_TOG, 76 ANALOG_PLL_VIDEO_SS, 77 ANALOG_PLL_VIDEO_SS_SET, 78 ANALOG_PLL_VIDEO_SS_CLR, 79 ANALOG_PLL_VIDEO_SS_TOG, 80 ANALOG_PLL_VIDEO_NUM, 81 ANALOG_PLL_VIDEO_NUM_SET, 82 ANALOG_PLL_VIDEO_NUM_CLR, 83 ANALOG_PLL_VIDEO_NUM_TOG, 84 ANALOG_PLL_VIDEO_DENOM, 85 ANALOG_PLL_VIDEO_DENOM_SET, 86 ANALOG_PLL_VIDEO_DENOM_CLR, 87 ANALOG_PLL_VIDEO_DENOM_TOG, 88 ANALOG_PLL_MISC0, 89 ANALOG_PLL_MISC0_SET, 90 ANALOG_PLL_MISC0_CLR, 91 ANALOG_PLL_MISC0_TOG, 92 93 ANALOG_DIGPROG = 0x800 / sizeof(uint32_t), 94 ANALOG_MAX, 95 96 ANALOG_PLL_LOCK = BIT(31) 97 }; 98 99 enum IMX7CCMRegisters { 100 CCM_MAX = 0xBE00 / sizeof(uint32_t) + 1, 101 }; 102 103 enum IMX7PMURegisters { 104 PMU_MAX = 0x140 / sizeof(uint32_t), 105 }; 106 107 #define TYPE_IMX7_CCM "imx7.ccm" 108 typedef struct IMX7CCMState IMX7CCMState; 109 DECLARE_INSTANCE_CHECKER(IMX7CCMState, IMX7_CCM, 110 TYPE_IMX7_CCM) 111 112 struct IMX7CCMState { 113 /* <private> */ 114 IMXCCMState parent_obj; 115 116 /* <public> */ 117 MemoryRegion iomem; 118 119 uint32_t ccm[CCM_MAX]; 120 }; 121 122 123 #define TYPE_IMX7_ANALOG "imx7.analog" 124 typedef struct IMX7AnalogState IMX7AnalogState; 125 DECLARE_INSTANCE_CHECKER(IMX7AnalogState, IMX7_ANALOG, 126 TYPE_IMX7_ANALOG) 127 128 struct IMX7AnalogState { 129 /* <private> */ 130 IMXCCMState parent_obj; 131 132 /* <public> */ 133 struct { 134 MemoryRegion container; 135 MemoryRegion analog; 136 MemoryRegion digprog; 137 MemoryRegion pmu; 138 } mmio; 139 140 uint32_t analog[ANALOG_MAX]; 141 uint32_t pmu[PMU_MAX]; 142 }; 143 144 #endif /* IMX7_CCM_H */ 145