1781182e1SJean-Christophe Dubois /* 2781182e1SJean-Christophe Dubois * IMX6UL Clock Control Module 3781182e1SJean-Christophe Dubois * 4781182e1SJean-Christophe Dubois * Copyright (C) 2018 by Jean-Christophe Dubois <jcd@tribudubois.net> 5781182e1SJean-Christophe Dubois * 6781182e1SJean-Christophe Dubois * This work is licensed under the terms of the GNU GPL, version 2 or later. 7781182e1SJean-Christophe Dubois * See the COPYING file in the top-level directory. 8781182e1SJean-Christophe Dubois */ 9781182e1SJean-Christophe Dubois 10781182e1SJean-Christophe Dubois #ifndef IMX6UL_CCM_H 11781182e1SJean-Christophe Dubois #define IMX6UL_CCM_H 12781182e1SJean-Christophe Dubois 13781182e1SJean-Christophe Dubois #include "hw/misc/imx_ccm.h" 14781182e1SJean-Christophe Dubois #include "qemu/bitops.h" 15db1015e9SEduardo Habkost #include "qom/object.h" 16781182e1SJean-Christophe Dubois 17781182e1SJean-Christophe Dubois #define CCM_CCR 0 18781182e1SJean-Christophe Dubois #define CCM_CCDR 1 19781182e1SJean-Christophe Dubois #define CCM_CSR 2 20781182e1SJean-Christophe Dubois #define CCM_CCSR 3 21781182e1SJean-Christophe Dubois #define CCM_CACRR 4 22781182e1SJean-Christophe Dubois #define CCM_CBCDR 5 23781182e1SJean-Christophe Dubois #define CCM_CBCMR 6 24781182e1SJean-Christophe Dubois #define CCM_CSCMR1 7 25781182e1SJean-Christophe Dubois #define CCM_CSCMR2 8 26781182e1SJean-Christophe Dubois #define CCM_CSCDR1 9 27781182e1SJean-Christophe Dubois #define CCM_CS1CDR 10 28781182e1SJean-Christophe Dubois #define CCM_CS2CDR 11 29781182e1SJean-Christophe Dubois #define CCM_CDCDR 12 30781182e1SJean-Christophe Dubois #define CCM_CHSCCDR 13 31781182e1SJean-Christophe Dubois #define CCM_CSCDR2 14 32781182e1SJean-Christophe Dubois #define CCM_CSCDR3 15 33781182e1SJean-Christophe Dubois #define CCM_CDHIPR 18 34781182e1SJean-Christophe Dubois #define CCM_CTOR 20 35781182e1SJean-Christophe Dubois #define CCM_CLPCR 21 36781182e1SJean-Christophe Dubois #define CCM_CISR 22 37781182e1SJean-Christophe Dubois #define CCM_CIMR 23 38781182e1SJean-Christophe Dubois #define CCM_CCOSR 24 39781182e1SJean-Christophe Dubois #define CCM_CGPR 25 40781182e1SJean-Christophe Dubois #define CCM_CCGR0 26 41781182e1SJean-Christophe Dubois #define CCM_CCGR1 27 42781182e1SJean-Christophe Dubois #define CCM_CCGR2 28 43781182e1SJean-Christophe Dubois #define CCM_CCGR3 29 44781182e1SJean-Christophe Dubois #define CCM_CCGR4 30 45781182e1SJean-Christophe Dubois #define CCM_CCGR5 31 46781182e1SJean-Christophe Dubois #define CCM_CCGR6 32 47781182e1SJean-Christophe Dubois #define CCM_CMEOR 34 48781182e1SJean-Christophe Dubois #define CCM_MAX 35 49781182e1SJean-Christophe Dubois 50781182e1SJean-Christophe Dubois #define CCM_ANALOG_PLL_ARM 0 51781182e1SJean-Christophe Dubois #define CCM_ANALOG_PLL_ARM_SET 1 52781182e1SJean-Christophe Dubois #define CCM_ANALOG_PLL_ARM_CLR 2 53781182e1SJean-Christophe Dubois #define CCM_ANALOG_PLL_ARM_TOG 3 54781182e1SJean-Christophe Dubois #define CCM_ANALOG_PLL_USB1 4 55781182e1SJean-Christophe Dubois #define CCM_ANALOG_PLL_USB1_SET 5 56781182e1SJean-Christophe Dubois #define CCM_ANALOG_PLL_USB1_CLR 6 57781182e1SJean-Christophe Dubois #define CCM_ANALOG_PLL_USB1_TOG 7 58781182e1SJean-Christophe Dubois #define CCM_ANALOG_PLL_USB2 8 59781182e1SJean-Christophe Dubois #define CCM_ANALOG_PLL_USB2_SET 9 60781182e1SJean-Christophe Dubois #define CCM_ANALOG_PLL_USB2_CLR 10 61781182e1SJean-Christophe Dubois #define CCM_ANALOG_PLL_USB2_TOG 11 62781182e1SJean-Christophe Dubois #define CCM_ANALOG_PLL_SYS 12 63781182e1SJean-Christophe Dubois #define CCM_ANALOG_PLL_SYS_SET 13 64781182e1SJean-Christophe Dubois #define CCM_ANALOG_PLL_SYS_CLR 14 65781182e1SJean-Christophe Dubois #define CCM_ANALOG_PLL_SYS_TOG 15 66781182e1SJean-Christophe Dubois #define CCM_ANALOG_PLL_SYS_SS 16 67781182e1SJean-Christophe Dubois #define CCM_ANALOG_PLL_SYS_NUM 20 68781182e1SJean-Christophe Dubois #define CCM_ANALOG_PLL_SYS_DENOM 24 69781182e1SJean-Christophe Dubois #define CCM_ANALOG_PLL_AUDIO 28 70781182e1SJean-Christophe Dubois #define CCM_ANALOG_PLL_AUDIO_SET 29 71781182e1SJean-Christophe Dubois #define CCM_ANALOG_PLL_AUDIO_CLR 30 72781182e1SJean-Christophe Dubois #define CCM_ANALOG_PLL_AUDIO_TOG 31 73781182e1SJean-Christophe Dubois #define CCM_ANALOG_PLL_AUDIO_NUM 32 74781182e1SJean-Christophe Dubois #define CCM_ANALOG_PLL_AUDIO_DENOM 36 75781182e1SJean-Christophe Dubois #define CCM_ANALOG_PLL_VIDEO 40 76781182e1SJean-Christophe Dubois #define CCM_ANALOG_PLL_VIDEO_SET 41 77781182e1SJean-Christophe Dubois #define CCM_ANALOG_PLL_VIDEO_CLR 42 78781182e1SJean-Christophe Dubois #define CCM_ANALOG_PLL_VIDEO_TOG 44 79781182e1SJean-Christophe Dubois #define CCM_ANALOG_PLL_VIDEO_NUM 46 80781182e1SJean-Christophe Dubois #define CCM_ANALOG_PLL_VIDEO_DENOM 48 81781182e1SJean-Christophe Dubois #define CCM_ANALOG_PLL_ENET 56 82781182e1SJean-Christophe Dubois #define CCM_ANALOG_PLL_ENET_SET 57 83781182e1SJean-Christophe Dubois #define CCM_ANALOG_PLL_ENET_CLR 58 84781182e1SJean-Christophe Dubois #define CCM_ANALOG_PLL_ENET_TOG 59 85781182e1SJean-Christophe Dubois #define CCM_ANALOG_PFD_480 60 86781182e1SJean-Christophe Dubois #define CCM_ANALOG_PFD_480_SET 61 87781182e1SJean-Christophe Dubois #define CCM_ANALOG_PFD_480_CLR 62 88781182e1SJean-Christophe Dubois #define CCM_ANALOG_PFD_480_TOG 63 89781182e1SJean-Christophe Dubois #define CCM_ANALOG_PFD_528 64 90781182e1SJean-Christophe Dubois #define CCM_ANALOG_PFD_528_SET 65 91781182e1SJean-Christophe Dubois #define CCM_ANALOG_PFD_528_CLR 66 92781182e1SJean-Christophe Dubois #define CCM_ANALOG_PFD_528_TOG 67 93781182e1SJean-Christophe Dubois 94781182e1SJean-Christophe Dubois /* PMU registers */ 95781182e1SJean-Christophe Dubois #define PMU_REG_1P1 68 96781182e1SJean-Christophe Dubois #define PMU_REG_3P0 72 97781182e1SJean-Christophe Dubois #define PMU_REG_2P5 76 98781182e1SJean-Christophe Dubois #define PMU_REG_CORE 80 99781182e1SJean-Christophe Dubois 100781182e1SJean-Christophe Dubois #define CCM_ANALOG_MISC0 84 101781182e1SJean-Christophe Dubois #define PMU_MISC0 CCM_ANALOG_MISC0 102781182e1SJean-Christophe Dubois #define CCM_ANALOG_MISC0_SET 85 103781182e1SJean-Christophe Dubois #define PMU_MISC0_SET CCM_ANALOG_MISC0_SET 104781182e1SJean-Christophe Dubois #define CCM_ANALOG_MISC0_CLR 86 105781182e1SJean-Christophe Dubois #define PMU_MISC0_CLR CCM_ANALOG_MISC0_CLR 106781182e1SJean-Christophe Dubois #define CCM_ANALOG_MISC0_TOG 87 107781182e1SJean-Christophe Dubois #define PMU_MISC0_TOG CCM_ANALOG_MISC0_TOG 108781182e1SJean-Christophe Dubois 109781182e1SJean-Christophe Dubois #define CCM_ANALOG_MISC1 88 110781182e1SJean-Christophe Dubois #define PMU_MISC1 CCM_ANALOG_MISC1 111781182e1SJean-Christophe Dubois #define CCM_ANALOG_MISC1_SET 89 112781182e1SJean-Christophe Dubois #define PMU_MISC1_SET CCM_ANALOG_MISC1_SET 113781182e1SJean-Christophe Dubois #define CCM_ANALOG_MISC1_CLR 90 114781182e1SJean-Christophe Dubois #define PMU_MISC1_CLR CCM_ANALOG_MISC1_CLR 115781182e1SJean-Christophe Dubois #define CCM_ANALOG_MISC1_TOG 91 116781182e1SJean-Christophe Dubois #define PMU_MISC1_TOG CCM_ANALOG_MISC1_TOG 117781182e1SJean-Christophe Dubois 118781182e1SJean-Christophe Dubois #define CCM_ANALOG_MISC2 92 119781182e1SJean-Christophe Dubois #define PMU_MISC2 CCM_ANALOG_MISC2 120781182e1SJean-Christophe Dubois #define CCM_ANALOG_MISC2_SET 93 121781182e1SJean-Christophe Dubois #define PMU_MISC2_SET CCM_ANALOG_MISC2_SET 122781182e1SJean-Christophe Dubois #define CCM_ANALOG_MISC2_CLR 94 123781182e1SJean-Christophe Dubois #define PMU_MISC2_CLR CCM_ANALOG_MISC2_CLR 124781182e1SJean-Christophe Dubois #define CCM_ANALOG_MISC2_TOG 95 125781182e1SJean-Christophe Dubois #define PMU_MISC2_TOG CCM_ANALOG_MISC2_TOG 126781182e1SJean-Christophe Dubois 127781182e1SJean-Christophe Dubois #define TEMPMON_TEMPSENSE0 96 128781182e1SJean-Christophe Dubois #define TEMPMON_TEMPSENSE0_SET 97 129781182e1SJean-Christophe Dubois #define TEMPMON_TEMPSENSE0_CLR 98 130781182e1SJean-Christophe Dubois #define TEMPMON_TEMPSENSE0_TOG 99 131781182e1SJean-Christophe Dubois #define TEMPMON_TEMPSENSE1 100 132781182e1SJean-Christophe Dubois #define TEMPMON_TEMPSENSE1_SET 101 133781182e1SJean-Christophe Dubois #define TEMPMON_TEMPSENSE1_CLR 102 134781182e1SJean-Christophe Dubois #define TEMPMON_TEMPSENSE1_TOG 103 135781182e1SJean-Christophe Dubois #define TEMPMON_TEMPSENSE2 164 136781182e1SJean-Christophe Dubois #define TEMPMON_TEMPSENSE2_SET 165 137781182e1SJean-Christophe Dubois #define TEMPMON_TEMPSENSE2_CLR 166 138781182e1SJean-Christophe Dubois #define TEMPMON_TEMPSENSE2_TOG 167 139781182e1SJean-Christophe Dubois 140781182e1SJean-Christophe Dubois #define PMU_LOWPWR_CTRL 155 141781182e1SJean-Christophe Dubois #define PMU_LOWPWR_CTRL_SET 156 142781182e1SJean-Christophe Dubois #define PMU_LOWPWR_CTRL_CLR 157 143781182e1SJean-Christophe Dubois #define PMU_LOWPWR_CTRL_TOG 158 144781182e1SJean-Christophe Dubois 145781182e1SJean-Christophe Dubois #define USB_ANALOG_USB1_VBUS_DETECT 104 146781182e1SJean-Christophe Dubois #define USB_ANALOG_USB1_VBUS_DETECT_SET 105 147781182e1SJean-Christophe Dubois #define USB_ANALOG_USB1_VBUS_DETECT_CLR 106 148781182e1SJean-Christophe Dubois #define USB_ANALOG_USB1_VBUS_DETECT_TOG 107 149781182e1SJean-Christophe Dubois #define USB_ANALOG_USB1_CHRG_DETECT 108 150781182e1SJean-Christophe Dubois #define USB_ANALOG_USB1_CHRG_DETECT_SET 109 151781182e1SJean-Christophe Dubois #define USB_ANALOG_USB1_CHRG_DETECT_CLR 110 152781182e1SJean-Christophe Dubois #define USB_ANALOG_USB1_CHRG_DETECT_TOG 111 153781182e1SJean-Christophe Dubois #define USB_ANALOG_USB1_VBUS_DETECT_STAT 112 154781182e1SJean-Christophe Dubois #define USB_ANALOG_USB1_CHRG_DETECT_STAT 116 155781182e1SJean-Christophe Dubois #define USB_ANALOG_USB1_MISC 124 156781182e1SJean-Christophe Dubois #define USB_ANALOG_USB1_MISC_SET 125 157781182e1SJean-Christophe Dubois #define USB_ANALOG_USB1_MISC_CLR 126 158781182e1SJean-Christophe Dubois #define USB_ANALOG_USB1_MISC_TOG 127 159781182e1SJean-Christophe Dubois #define USB_ANALOG_USB2_VBUS_DETECT 128 160781182e1SJean-Christophe Dubois #define USB_ANALOG_USB2_VBUS_DETECT_SET 129 161781182e1SJean-Christophe Dubois #define USB_ANALOG_USB2_VBUS_DETECT_CLR 130 162781182e1SJean-Christophe Dubois #define USB_ANALOG_USB2_VBUS_DETECT_TOG 131 163781182e1SJean-Christophe Dubois #define USB_ANALOG_USB2_CHRG_DETECT 132 164781182e1SJean-Christophe Dubois #define USB_ANALOG_USB2_CHRG_DETECT_SET 133 165781182e1SJean-Christophe Dubois #define USB_ANALOG_USB2_CHRG_DETECT_CLR 134 166781182e1SJean-Christophe Dubois #define USB_ANALOG_USB2_CHRG_DETECT_TOG 135 167781182e1SJean-Christophe Dubois #define USB_ANALOG_USB2_VBUS_DETECT_STAT 136 168781182e1SJean-Christophe Dubois #define USB_ANALOG_USB2_CHRG_DETECT_STAT 140 169781182e1SJean-Christophe Dubois #define USB_ANALOG_USB2_MISC 148 170781182e1SJean-Christophe Dubois #define USB_ANALOG_USB2_MISC_SET 149 171781182e1SJean-Christophe Dubois #define USB_ANALOG_USB2_MISC_CLR 150 172781182e1SJean-Christophe Dubois #define USB_ANALOG_USB2_MISC_TOG 151 173781182e1SJean-Christophe Dubois #define USB_ANALOG_DIGPROG 152 174781182e1SJean-Christophe Dubois #define CCM_ANALOG_MAX 4096 175781182e1SJean-Christophe Dubois 176781182e1SJean-Christophe Dubois /* CCM_CBCMR */ 177781182e1SJean-Christophe Dubois #define R_CBCMR_PRE_PERIPH_CLK_SEL_SHIFT (18) 178781182e1SJean-Christophe Dubois #define R_CBCMR_PRE_PERIPH_CLK_SEL_LENGTH (2) 179781182e1SJean-Christophe Dubois #define R_CBCMR_PERIPH_CLK2_SEL_SHIFT (12) 180781182e1SJean-Christophe Dubois #define R_CBCMR_PERIPH_CLK2_SEL_LENGTH (2) 181781182e1SJean-Christophe Dubois 182781182e1SJean-Christophe Dubois /* CCM_CBCDR */ 183781182e1SJean-Christophe Dubois #define R_CBCDR_AHB_PODF_SHIFT (10) 184781182e1SJean-Christophe Dubois #define R_CBCDR_AHB_PODF_LENGTH (3) 185781182e1SJean-Christophe Dubois #define R_CBCDR_IPG_PODF_SHIFT (8) 186781182e1SJean-Christophe Dubois #define R_CBCDR_IPG_PODF_LENGTH (2) 187781182e1SJean-Christophe Dubois #define R_CBCDR_PERIPH_CLK_SEL_SHIFT (25) 188781182e1SJean-Christophe Dubois #define R_CBCDR_PERIPH_CLK_SEL_LENGTH (1) 189781182e1SJean-Christophe Dubois #define R_CBCDR_PERIPH_CLK2_PODF_SHIFT (27) 190781182e1SJean-Christophe Dubois #define R_CBCDR_PERIPH_CLK2_PODF_LENGTH (3) 191781182e1SJean-Christophe Dubois 192781182e1SJean-Christophe Dubois /* CCM_CSCMR1 */ 193781182e1SJean-Christophe Dubois #define R_CSCMR1_PERCLK_PODF_SHIFT (0) 194781182e1SJean-Christophe Dubois #define R_CSCMR1_PERCLK_PODF_LENGTH (6) 195781182e1SJean-Christophe Dubois #define R_CSCMR1_PERCLK_CLK_SEL_SHIFT (6) 196781182e1SJean-Christophe Dubois #define R_CSCMR1_PERCLK_CLK_SEL_LENGTH (1) 197781182e1SJean-Christophe Dubois 198781182e1SJean-Christophe Dubois /* CCM_ANALOG_PFD_528 */ 199781182e1SJean-Christophe Dubois #define R_ANALOG_PFD_528_PFD0_FRAC_SHIFT (0) 200781182e1SJean-Christophe Dubois #define R_ANALOG_PFD_528_PFD0_FRAC_LENGTH (6) 201781182e1SJean-Christophe Dubois #define R_ANALOG_PFD_528_PFD2_FRAC_SHIFT (16) 202781182e1SJean-Christophe Dubois #define R_ANALOG_PFD_528_PFD2_FRAC_LENGTH (6) 203781182e1SJean-Christophe Dubois 204781182e1SJean-Christophe Dubois /* CCM_ANALOG_PLL_SYS */ 205781182e1SJean-Christophe Dubois #define R_ANALOG_PLL_SYS_DIV_SELECT_SHIFT (0) 206781182e1SJean-Christophe Dubois #define R_ANALOG_PLL_SYS_DIV_SELECT_LENGTH (1) 207781182e1SJean-Christophe Dubois 208781182e1SJean-Christophe Dubois #define CCM_ANALOG_PLL_LOCK (1 << 31); 209781182e1SJean-Christophe Dubois 210781182e1SJean-Christophe Dubois #define TYPE_IMX6UL_CCM "imx6ul.ccm" 211*8063396bSEduardo Habkost OBJECT_DECLARE_SIMPLE_TYPE(IMX6ULCCMState, IMX6UL_CCM) 212781182e1SJean-Christophe Dubois 213db1015e9SEduardo Habkost struct IMX6ULCCMState { 214781182e1SJean-Christophe Dubois /* <private> */ 215781182e1SJean-Christophe Dubois IMXCCMState parent_obj; 216781182e1SJean-Christophe Dubois 217781182e1SJean-Christophe Dubois /* <public> */ 218781182e1SJean-Christophe Dubois MemoryRegion container; 219781182e1SJean-Christophe Dubois MemoryRegion ioccm; 220781182e1SJean-Christophe Dubois MemoryRegion ioanalog; 221781182e1SJean-Christophe Dubois 222781182e1SJean-Christophe Dubois uint32_t ccm[CCM_MAX]; 223781182e1SJean-Christophe Dubois uint32_t analog[CCM_ANALOG_MAX]; 224781182e1SJean-Christophe Dubois 225db1015e9SEduardo Habkost }; 226781182e1SJean-Christophe Dubois 227781182e1SJean-Christophe Dubois #endif /* IMX6UL_CCM_H */ 228