1 /* SPDX-License-Identifier: GPL-2.0+ or BSD-3-Clause */ 2 /* 3 * Copyright (C) 2005 Ivan Kokshaysky 4 * Copyright (C) SAN People 5 * 6 * Power Management Controller (PMC) - System peripherals registers. 7 * Based on AT91RM9200 datasheet revision E. 8 */ 9 10 #ifndef DRIVERS_CLK_SAM_AT91_PM_H 11 #define DRIVERS_CLK_SAM_AT91_PM_H 12 13 #include <util.h> 14 15 #define AT91_PMC_V1 (1) 16 #define AT91_PMC_V2 (2) 17 18 #define AT91_PMC_SCER 0x00 19 #define AT91_PMC_SCDR 0x04 20 21 #define AT91_PMC_SCSR 0x08 22 #define AT91_PMC_PCK BIT(0) 23 #define AT91RM9200_PMC_UDP BIT(1) 24 #define AT91RM9200_PMC_MCKUDP BIT(2) 25 #define AT91RM9200_PMC_UHP BIT(4) 26 #define AT91SAM926x_PMC_UHP BIT(6) 27 #define AT91SAM926x_PMC_UDP BIT(7) 28 #define AT91_PMC_PCK0 BIT(8) 29 #define AT91_PMC_PCK1 BIT(9) 30 #define AT91_PMC_PCK2 BIT(10) 31 #define AT91_PMC_PCK3 BIT(11) 32 #define AT91_PMC_PCK4 BIT(12) 33 #define AT91_PMC_HCK0 BIT(16) 34 #define AT91_PMC_HCK1 BIT(17) 35 36 #define AT91_PMC_PLL_CTRL0 0x0C 37 #define AT91_PMC_PLL_CTRL0_ENPLL BIT(28) 38 #define AT91_PMC_PLL_CTRL0_ENPLLCK BIT(29) 39 #define AT91_PMC_PLL_CTRL0_ENLOCK BIT(31) 40 41 #define AT91_PMC_PLL_CTRL1 0x10 42 43 #define AT91_PMC_PCER 0x10 44 #define AT91_PMC_PCDR 0x14 45 #define AT91_PMC_PCSR 0x18 46 47 #define AT91_PMC_PLL_ACR 0x18 48 #define AT91_PMC_PLL_ACR_DEFAULT_UPLL 0x12020010UL 49 #define AT91_PMC_PLL_ACR_DEFAULT_PLLA 0x00020010UL 50 #define AT91_PMC_PLL_ACR_UTMIVR BIT(12) 51 #define AT91_PMC_PLL_ACR_UTMIBG BIT(13) 52 53 #define AT91_CKGR_UCKR 0x1C 54 #define AT91_PMC_UPLLEN BIT(16) 55 #define AT91_PMC_UPLLCOUNT (0xf << 20) 56 #define AT91_PMC_BIASEN BIT(24) 57 #define AT91_PMC_BIASCOUNT (0xf << 28) 58 59 #define AT91_PMC_PLL_UPDT 0x1C 60 #define AT91_PMC_PLL_UPDT_UPDATE BIT(8) 61 #define AT91_PMC_PLL_UPDT_ID BIT(0) 62 #define AT91_PMC_PLL_UPDT_ID_MASK GENMASK_32(3, 0) 63 #define AT91_PMC_PLL_UPDT_STUPTIM (0xff << 16) 64 65 #define AT91_CKGR_MOR 0x20 66 #define AT91_PMC_MOSCEN BIT(0) 67 #define AT91_PMC_OSCBYPASS BIT(1) 68 #define AT91_PMC_WAITMODE BIT(2) 69 #define AT91_PMC_MOSCRCEN BIT(3) 70 #define AT91_PMC_OSCOUNT (0xff << 8) 71 #define AT91_PMC_KEY_MASK (0xff << 16) 72 #define AT91_PMC_KEY (0x37 << 16) 73 #define AT91_PMC_MOSCSEL BIT(24) 74 #define AT91_PMC_CFDEN BIT(25) 75 76 #define AT91_CKGR_MCFR 0x24 77 #define AT91_PMC_MAINF (0xffff << 0) 78 #define AT91_PMC_MAINRDY BIT(16) 79 80 #define AT91_CKGR_PLLAR 0x28 81 #define AT91_CKGR_PLLBR 0x2c 82 #define AT91_PMC_DIV (0xff << 0) 83 #define AT91_PMC_PLLCOUNT (0x3f << 8) 84 #define AT91_PMC_OUT (3 << 14) 85 #define AT91_PMC_MUL (0x7ff << 16) 86 #define AT91_PMC_MUL_GET(n) ((n) >> 16 & 0x7ff) 87 #define AT91_PMC3_MUL (0x7f << 18) 88 #define AT91_PMC3_MUL_GET(n) ((n) >> 18 & 0x7f) 89 #define AT91_PMC_USBDIV (3 << 28) 90 #define AT91_PMC_USBDIV_1 (0 << 28) 91 #define AT91_PMC_USBDIV_2 BIT(28) 92 #define AT91_PMC_USBDIV_4 (2 << 28) 93 #define AT91_PMC_USB96M BIT(28) 94 95 #define AT91_PMC_CPU_CKR 0x28 96 97 #define AT91_PMC_MCKR 0x30 98 #define AT91_PMC_CSS (3 << 0) 99 #define AT91_PMC_CSS_SLOW (0 << 0) 100 #define AT91_PMC_CSS_MAIN BIT(0) 101 #define AT91_PMC_CSS_PLLA (2 << 0) 102 #define AT91_PMC_CSS_PLLB (3 << 0) 103 #define AT91_PMC_CSS_UPLL (3 << 0) 104 #define PMC_PRES_OFFSET 2 105 #define AT91_PMC_PRES (7 << PMC_PRES_OFFSET) 106 #define AT91_PMC_PRES_1 (0 << PMC_PRES_OFFSET) 107 #define AT91_PMC_PRES_2 BIT(PMC_PRES_OFFSET) 108 #define AT91_PMC_PRES_4 (2 << PMC_PRES_OFFSET) 109 #define AT91_PMC_PRES_8 (3 << PMC_PRES_OFFSET) 110 #define AT91_PMC_PRES_16 (4 << PMC_PRES_OFFSET) 111 #define AT91_PMC_PRES_32 (5 << PMC_PRES_OFFSET) 112 #define AT91_PMC_PRES_64 (6 << PMC_PRES_OFFSET) 113 #define PMC_ALT_PRES_OFFSET 4 114 #define AT91_PMC_ALT_PRES (7 << PMC_ALT_PRES_OFFSET) 115 #define AT91_PMC_ALT_PRES_1 (0 << PMC_ALT_PRES_OFFSET) 116 #define AT91_PMC_ALT_PRES_2 BIT(PMC_ALT_PRES_OFFSET) 117 #define AT91_PMC_ALT_PRES_4 (2 << PMC_ALT_PRES_OFFSET) 118 #define AT91_PMC_ALT_PRES_8 (3 << PMC_ALT_PRES_OFFSET) 119 #define AT91_PMC_ALT_PRES_16 (4 << PMC_ALT_PRES_OFFSET) 120 #define AT91_PMC_ALT_PRES_32 (5 << PMC_ALT_PRES_OFFSET) 121 #define AT91_PMC_ALT_PRES_64 (6 << PMC_ALT_PRES_OFFSET) 122 #define AT91_PMC_MDIV (3 << 8) 123 #define AT91RM9200_PMC_MDIV_1 (0 << 8) 124 #define AT91RM9200_PMC_MDIV_2 BIT(8) 125 #define AT91RM9200_PMC_MDIV_3 (2 << 8) 126 #define AT91RM9200_PMC_MDIV_4 (3 << 8) 127 #define AT91SAM9_PMC_MDIV_1 (0 << 8) 128 #define AT91SAM9_PMC_MDIV_2 BIT(8) 129 #define AT91SAM9_PMC_MDIV_4 (2 << 8) 130 #define AT91SAM9_PMC_MDIV_6 (3 << 8) 131 #define AT91SAM9_PMC_MDIV_3 (3 << 8) 132 #define AT91_PMC_PDIV BIT(12) 133 #define AT91_PMC_PDIV_1 (0 << 12) 134 #define AT91_PMC_PDIV_2 BIT(12) 135 #define AT91_PMC_PLLADIV2 BIT(12) 136 #define AT91_PMC_PLLADIV2_OFF (0 << 12) 137 #define AT91_PMC_PLLADIV2_ON BIT(12) 138 #define AT91_PMC_H32MXDIV BIT(24) 139 140 /* definitions for the PMC register of SAMA7G5 */ 141 #define AT91_PMC_MCR_V2 0x30 142 #define AT91_PMC_MCR_V2_ID_MASK GENMASK_32(3, 0) 143 #define AT91_PMC_MCR_V2_ID(_id) ((_id) & AT91_PMC_MCR_V2_ID_MASK) 144 #define AT91_PMC_MCR_V2_CMD BIT(7) 145 #define AT91_PMC_MCR_V2_DIV_MASK GENMASK_32(10, 8) 146 #define AT91_PMC_MCR_V2_DIV1 SHIFT_U32(0, 8) 147 #define AT91_PMC_MCR_V2_DIV2 SHIFT_U32(1, 8) 148 #define AT91_PMC_MCR_V2_DIV4 SHIFT_U32(2, 8) 149 #define AT91_PMC_MCR_V2_DIV8 SHIFT_U32(3, 8) 150 #define AT91_PMC_MCR_V2_DIV16 SHIFT_U32(4, 8) 151 #define AT91_PMC_MCR_V2_DIV32 SHIFT_U32(5, 8) 152 #define AT91_PMC_MCR_V2_DIV64 SHIFT_U32(6, 8) 153 #define AT91_PMC_MCR_V2_DIV3 SHIFT_U32(7, 8) 154 #define AT91_PMC_MCR_V2_CSS_SHIFT 16 155 #define AT91_PMC_MCR_V2_CSS_MASK GENMASK_32(20, 16) 156 #define AT91_PMC_MCR_V2_CSS_MD_SLCK SHIFT_U32(0, 16) 157 #define AT91_PMC_MCR_V2_CSS_TD_SLCK SHIFT_U32(1, 16) 158 #define AT91_PMC_MCR_V2_CSS_MAINCK SHIFT_U32(2, 16) 159 #define AT91_PMC_MCR_V2_CSS_MCK0 SHIFT_U32(3, 16) 160 #define AT91_PMC_MCR_V2_CSS_SYSPLL SHIFT_U32(5, 16) 161 #define AT91_PMC_MCR_V2_CSS_DDRPLL SHIFT_U32(6, 16) 162 #define AT91_PMC_MCR_V2_CSS_IMGPLL SHIFT_U32(7, 16) 163 #define AT91_PMC_MCR_V2_CSS_BAUDPLL SHIFT_U32(8, 16) 164 #define AT91_PMC_MCR_V2_CSS_AUDIOPLL SHIFT_U32(9, 16) 165 #define AT91_PMC_MCR_V2_CSS_ETHPLL SHIFT_U32(10, 16) 166 #define AT91_PMC_MCR_V2_EN BIT(28) 167 168 #define AT91_PMC_XTALF 0x34 169 #define AT91_PMC_XTALF_XTALF 7 170 171 #define AT91_PMC_USB 0x38 172 #define AT91_PMC_USBS (0x1 << 0) 173 #define AT91_PMC_USBS_PLLA (0 << 0) 174 #define AT91_PMC_USBS_UPLL BIT(0) 175 #define AT91_PMC_USBS_PLLB BIT(0) 176 #define AT91_PMC_OHCIUSBDIV (0xF << 8) 177 #define AT91_PMC_OHCIUSBDIV_1 (0x0 << 8) 178 #define AT91_PMC_OHCIUSBDIV_2 (0x1 << 8) 179 180 #define AT91_PMC_SMD 0x3c 181 #define AT91_PMC_SMDS (0x1 << 0) 182 #define AT91_PMC_SMD_DIV (0x1f << 8) 183 #define AT91_PMC_SMDDIV(n) (((n) << 8) & AT91_PMC_SMD_DIV) 184 185 #define AT91_PMC_PCKR(n) (0x40 + ((n) * 4)) 186 #define AT91_PMC_ALT_PCKR_CSS (0x7 << 0) 187 #define AT91_PMC_CSS_MASTER (4 << 0) 188 #define AT91_PMC_CSSMCK (0x1 << 8) 189 #define AT91_PMC_CSSMCK_CSS (0 << 8) 190 #define AT91_PMC_CSSMCK_MCK BIT(8) 191 192 #define AT91_PMC_IER 0x60 193 #define AT91_PMC_IDR 0x64 194 #define AT91_PMC_SR 0x68 195 #define AT91_PMC_MOSCS BIT(0) 196 #define AT91_PMC_LOCKA BIT(1) 197 #define AT91_PMC_LOCKB BIT(2) 198 #define AT91_PMC_MCKRDY BIT(3) 199 #define AT91_PMC_LOCKU BIT(6) 200 #define AT91_PMC_OSCSEL BIT(7) 201 #define AT91_PMC_PCK0RDY BIT(8) 202 #define AT91_PMC_PCK1RDY BIT(9) 203 #define AT91_PMC_PCK2RDY BIT(10) 204 #define AT91_PMC_PCK3RDY BIT(11) 205 #define AT91_PMC_MOSCSELS BIT(16) 206 #define AT91_PMC_MOSCRCS BIT(17) 207 #define AT91_PMC_CFDEV BIT(18) 208 #define AT91_PMC_GCKRDY BIT(24) 209 #define AT91_PMC_MCKXRDY BIT(26) 210 #define AT91_PMC_IMR 0x6c 211 212 #define AT91_PMC_FSMR 0x70 213 #define AT91_PMC_FSTT(n) BIT(n) 214 #define AT91_PMC_RTTAL BIT(16) 215 #define AT91_PMC_RTCAL BIT(17) 216 #define AT91_PMC_USBAL BIT(18) 217 #define AT91_PMC_SDMMC_CD BIT(19) 218 #define AT91_PMC_LPM BIT(20) 219 #define AT91_PMC_RXLP_MCE BIT(24) 220 #define AT91_PMC_ACC_CE BIT(25) 221 222 #define AT91_PMC_FSPR 0x74 223 224 #define AT91_PMC_FS_INPUT_MASK 0x7ff 225 226 #define AT91_PMC_PLLICPR 0x80 227 228 #define AT91_PMC_PROT 0xe4 229 #define AT91_PMC_WPEN (0x1 << 0) 230 #define AT91_PMC_WPKEY (0xffffff << 8) 231 #define AT91_PMC_PROTKEY (0x504d43 << 8) 232 233 #define AT91_PMC_WPSR 0xe8 234 #define AT91_PMC_WPVS (0x1 << 0) 235 #define AT91_PMC_WPVSRC (0xffff << 8) 236 237 #define AT91_PMC_PLL_ISR0 0xEC 238 239 #define AT91_PMC_PCER1 0x100 240 #define AT91_PMC_PCDR1 0x104 241 #define AT91_PMC_PCSR1 0x108 242 243 #define AT91_PMC_PCR 0x10c 244 #define AT91_PMC_PCR_PID_MASK 0x3f 245 #define AT91_PMC_PCR_CMD (0x1 << 12) 246 #define AT91_PMC_PCR_GCKDIV_SHIFT 20 247 #define AT91_PMC_PCR_GCKDIV_MASK \ 248 GENMASK_32(27, AT91_PMC_PCR_GCKDIV_SHIFT) 249 #define AT91_PMC_PCR_EN (0x1 << 28) 250 #define AT91_PMC_PCR_GCKEN (0x1 << 29) 251 252 #define AT91_PMC_AUDIO_PLL0 0x14c 253 #define AT91_PMC_AUDIO_PLL_PLLEN BIT(0) 254 #define AT91_PMC_AUDIO_PLL_PADEN BIT(1) 255 #define AT91_PMC_AUDIO_PLL_PMCEN BIT(2) 256 #define AT91_PMC_AUDIO_PLL_RESETN BIT(3) 257 #define AT91_PMC_AUDIO_PLL_ND_OFFSET 8 258 #define AT91_PMC_AUDIO_PLL_ND_MASK \ 259 (0x7f << AT91_PMC_AUDIO_PLL_ND_OFFSET) 260 #define AT91_PMC_AUDIO_PLL_ND(n) \ 261 SHIFT_U32(n, AT91_PMC_AUDIO_PLL_ND_OFFSET) 262 #define AT91_PMC_AUDIO_PLL_QDPMC_OFFSET 16 263 #define AT91_PMC_AUDIO_PLL_QDPMC_MASK \ 264 (0x7f << AT91_PMC_AUDIO_PLL_QDPMC_OFFSET) 265 #define AT91_PMC_AUDIO_PLL_QDPMC(n) \ 266 SHIFT_U32(n, AT91_PMC_AUDIO_PLL_QDPMC_OFFSET) 267 268 #define AT91_PMC_AUDIO_PLL1 0x150 269 #define AT91_PMC_AUDIO_PLL_FRACR_MASK 0x3fffff 270 #define AT91_PMC_AUDIO_PLL_QDPAD_OFFSET 24 271 #define AT91_PMC_AUDIO_PLL_QDPAD_MASK \ 272 (0x7f << AT91_PMC_AUDIO_PLL_QDPAD_OFFSET) 273 #define AT91_PMC_AUDIO_PLL_QDPAD(n) \ 274 SHIFT_U32(n, AT91_PMC_AUDIO_PLL_QDPAD_OFFSET) 275 #define AT91_PMC_AUDIO_PLL_QDPAD_DIV_OFFSET \ 276 AT91_PMC_AUDIO_PLL_QDPAD_OFFSET 277 #define AT91_PMC_AUDIO_PLL_QDPAD_DIV_MASK \ 278 (0x3 << AT91_PMC_AUDIO_PLL_QDPAD_DIV_OFFSET) 279 #define AT91_PMC_AUDIO_PLL_QDPAD_DIV(n) \ 280 SHIFT_U32(n, AT91_PMC_AUDIO_PLL_QDPAD_DIV_OFFSET) 281 #define AT91_PMC_AUDIO_PLL_QDPAD_EXTDIV_OFFSET 26 282 #define AT91_PMC_AUDIO_PLL_QDPAD_EXTDIV_MAX 0x1f 283 #define AT91_PMC_AUDIO_PLL_QDPAD_EXTDIV_MASK \ 284 (AT91_PMC_AUDIO_PLL_QDPAD_EXTDIV_MAX << \ 285 AT91_PMC_AUDIO_PLL_QDPAD_EXTDIV_OFFSET) 286 #define AT91_PMC_AUDIO_PLL_QDPAD_EXTDIV(n) \ 287 SHIFT_U32(n, AT91_PMC_AUDIO_PLL_QDPAD_EXTDIV_OFFSET) 288 289 #endif 290