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