Ley Foon Tan | c168fc7 | 2019-11-27 15:55:22 +0800 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0 */ |
| 2 | /* |
| 3 | * Copyright (C) 2019 Intel Corporation <www.intel.com> |
| 4 | */ |
| 5 | |
| 6 | #ifndef _CLK_AGILEX_ |
| 7 | #define _CLK_AGILEX_ |
| 8 | |
| 9 | #define CM_REG_READL(plat, reg) \ |
| 10 | readl((plat)->regs + (reg)) |
| 11 | |
| 12 | #define CM_REG_WRITEL(plat, data, reg) \ |
| 13 | writel(data, (plat)->regs + (reg)) |
| 14 | |
| 15 | #define CM_REG_CLRBITS(plat, reg, clear) \ |
| 16 | clrbits_le32((plat)->regs + (reg), (clear)) |
| 17 | |
| 18 | #define CM_REG_SETBITS(plat, reg, set) \ |
| 19 | setbits_le32((plat)->regs + (reg), (set)) |
| 20 | |
| 21 | struct cm_config { |
| 22 | /* main group */ |
| 23 | u32 main_pll_mpuclk; |
| 24 | u32 main_pll_nocclk; |
| 25 | u32 main_pll_nocdiv; |
| 26 | u32 main_pll_pllglob; |
| 27 | u32 main_pll_fdbck; |
| 28 | u32 main_pll_pllc0; |
| 29 | u32 main_pll_pllc1; |
| 30 | u32 main_pll_pllc2; |
| 31 | u32 main_pll_pllc3; |
| 32 | u32 main_pll_pllm; |
| 33 | |
| 34 | /* peripheral group */ |
| 35 | u32 per_pll_emacctl; |
| 36 | u32 per_pll_gpiodiv; |
| 37 | u32 per_pll_pllglob; |
| 38 | u32 per_pll_fdbck; |
| 39 | u32 per_pll_pllc0; |
| 40 | u32 per_pll_pllc1; |
| 41 | u32 per_pll_pllc2; |
| 42 | u32 per_pll_pllc3; |
| 43 | u32 per_pll_pllm; |
| 44 | |
| 45 | /* altera group */ |
| 46 | u32 alt_emacactr; |
| 47 | u32 alt_emacbctr; |
| 48 | u32 alt_emacptpctr; |
| 49 | u32 alt_gpiodbctr; |
| 50 | u32 alt_sdmmcctr; |
| 51 | u32 alt_s2fuser0ctr; |
| 52 | u32 alt_s2fuser1ctr; |
| 53 | u32 alt_psirefctr; |
| 54 | |
| 55 | /* incoming clock */ |
| 56 | u32 hps_osc_clk_hz; |
| 57 | u32 fpga_clk_hz; |
| 58 | u32 spare[3]; |
| 59 | }; |
| 60 | |
| 61 | /* Clock Manager registers */ |
| 62 | #define CLKMGR_CTRL 0 |
| 63 | #define CLKMGR_STAT 4 |
| 64 | #define CLKMGR_TESTIOCTRL 8 |
| 65 | #define CLKMGR_INTRGEN 0x0c |
| 66 | #define CLKMGR_INTRMSK 0x10 |
| 67 | #define CLKMGR_INTRCLR 0x14 |
| 68 | #define CLKMGR_INTRSTS 0x18 |
| 69 | #define CLKMGR_INTRSTK 0x1c |
| 70 | #define CLKMGR_INTRRAW 0x20 |
| 71 | |
| 72 | /* Clock Manager Main PPL group registers */ |
| 73 | #define CLKMGR_MAINPLL_EN 0x24 |
| 74 | #define CLKMGR_MAINPLL_ENS 0x28 |
| 75 | #define CLKMGR_MAINPLL_ENR 0x2c |
| 76 | #define CLKMGR_MAINPLL_BYPASS 0x30 |
| 77 | #define CLKMGR_MAINPLL_BYPASSS 0x34 |
| 78 | #define CLKMGR_MAINPLL_BYPASSR 0x38 |
| 79 | #define CLKMGR_MAINPLL_MPUCLK 0x3c |
| 80 | #define CLKMGR_MAINPLL_NOCCLK 0x40 |
| 81 | #define CLKMGR_MAINPLL_NOCDIV 0x44 |
| 82 | #define CLKMGR_MAINPLL_PLLGLOB 0x48 |
| 83 | #define CLKMGR_MAINPLL_FDBCK 0x4c |
| 84 | #define CLKMGR_MAINPLL_MEM 0x50 |
| 85 | #define CLKMGR_MAINPLL_MEMSTAT 0x54 |
| 86 | #define CLKMGR_MAINPLL_PLLC0 0x58 |
| 87 | #define CLKMGR_MAINPLL_PLLC1 0x5c |
| 88 | #define CLKMGR_MAINPLL_VCOCALIB 0x60 |
| 89 | #define CLKMGR_MAINPLL_PLLC2 0x64 |
| 90 | #define CLKMGR_MAINPLL_PLLC3 0x68 |
| 91 | #define CLKMGR_MAINPLL_PLLM 0x6c |
| 92 | #define CLKMGR_MAINPLL_FHOP 0x70 |
| 93 | #define CLKMGR_MAINPLL_SSC 0x74 |
| 94 | #define CLKMGR_MAINPLL_LOSTLOCK 0x78 |
| 95 | |
| 96 | /* Clock Manager Peripheral PPL group registers */ |
| 97 | #define CLKMGR_PERPLL_EN 0x7c |
| 98 | #define CLKMGR_PERPLL_ENS 0x80 |
| 99 | #define CLKMGR_PERPLL_ENR 0x84 |
| 100 | #define CLKMGR_PERPLL_BYPASS 0x88 |
| 101 | #define CLKMGR_PERPLL_BYPASSS 0x8c |
| 102 | #define CLKMGR_PERPLL_BYPASSR 0x90 |
| 103 | #define CLKMGR_PERPLL_EMACCTL 0x94 |
| 104 | #define CLKMGR_PERPLL_GPIODIV 0x98 |
| 105 | #define CLKMGR_PERPLL_PLLGLOB 0x9c |
| 106 | #define CLKMGR_PERPLL_FDBCK 0xa0 |
| 107 | #define CLKMGR_PERPLL_MEM 0xa4 |
| 108 | #define CLKMGR_PERPLL_MEMSTAT 0xa8 |
| 109 | #define CLKMGR_PERPLL_PLLC0 0xac |
| 110 | #define CLKMGR_PERPLL_PLLC1 0xb0 |
| 111 | #define CLKMGR_PERPLL_VCOCALIB 0xb4 |
| 112 | #define CLKMGR_PERPLL_PLLC2 0xb8 |
| 113 | #define CLKMGR_PERPLL_PLLC3 0xbc |
| 114 | #define CLKMGR_PERPLL_PLLM 0xc0 |
| 115 | #define CLKMGR_PERPLL_FHOP 0xc4 |
| 116 | #define CLKMGR_PERPLL_SSC 0xc8 |
| 117 | #define CLKMGR_PERPLL_LOSTLOCK 0xcc |
| 118 | |
| 119 | /* Clock Manager Altera group registers */ |
| 120 | #define CLKMGR_ALTR_JTAG 0xd0 |
| 121 | #define CLKMGR_ALTR_EMACACTR 0xd4 |
| 122 | #define CLKMGR_ALTR_EMACBCTR 0xd8 |
| 123 | #define CLKMGR_ALTR_EMACPTPCTR 0xdc |
| 124 | #define CLKMGR_ALTR_GPIODBCTR 0xe0 |
| 125 | #define CLKMGR_ALTR_SDMMCCTR 0xe4 |
| 126 | #define CLKMGR_ALTR_S2FUSER0CTR 0xe8 |
| 127 | #define CLKMGR_ALTR_S2FUSER1CTR 0xec |
| 128 | #define CLKMGR_ALTR_PSIREFCTR 0xf0 |
| 129 | #define CLKMGR_ALTR_EXTCNTRST 0xf4 |
| 130 | |
| 131 | #define CLKMGR_CTRL_BOOTMODE BIT(0) |
| 132 | |
| 133 | #define CLKMGR_STAT_BUSY BIT(0) |
| 134 | #define CLKMGR_STAT_MAINPLL_LOCKED BIT(8) |
| 135 | #define CLKMGR_STAT_MAIN_TRANS BIT(9) |
| 136 | #define CLKMGR_STAT_PERPLL_LOCKED BIT(16) |
| 137 | #define CLKMGR_STAT_PERF_TRANS BIT(17) |
| 138 | #define CLKMGR_STAT_BOOTMODE BIT(24) |
| 139 | #define CLKMGR_STAT_BOOTCLKSRC BIT(25) |
| 140 | |
| 141 | #define CLKMGR_STAT_ALLPLL_LOCKED_MASK \ |
| 142 | (CLKMGR_STAT_MAINPLL_LOCKED | CLKMGR_STAT_PERPLL_LOCKED) |
| 143 | |
| 144 | #define CLKMGR_INTER_MAINPLLLOCKED_MASK 0x00000001 |
| 145 | #define CLKMGR_INTER_PERPLLLOCKED_MASK 0x00000002 |
| 146 | #define CLKMGR_INTER_MAINPLLLOST_MASK 0x00000004 |
| 147 | #define CLKMGR_INTER_PERPLLLOST_MASK 0x00000008 |
| 148 | |
| 149 | #define CLKMGR_CLKSRC_MASK GENMASK(18, 16) |
| 150 | #define CLKMGR_CLKSRC_OFFSET 16 |
| 151 | #define CLKMGR_CLKSRC_MAIN 0 |
| 152 | #define CLKMGR_CLKSRC_PER 1 |
| 153 | #define CLKMGR_CLKSRC_OSC1 2 |
| 154 | #define CLKMGR_CLKSRC_INTOSC 3 |
| 155 | #define CLKMGR_CLKSRC_FPGA 4 |
| 156 | #define CLKMGR_CLKCNT_MSK GENMASK(10, 0) |
| 157 | |
| 158 | #define CLKMGR_BYPASS_MAINPLL_ALL 0x7 |
| 159 | #define CLKMGR_BYPASS_PERPLL_ALL 0x7f |
| 160 | |
| 161 | #define CLKMGR_NOCDIV_L4MAIN_OFFSET 0 |
| 162 | #define CLKMGR_NOCDIV_L4MPCLK_OFFSET 8 |
| 163 | #define CLKMGR_NOCDIV_L4SPCLK_OFFSET 16 |
| 164 | #define CLKMGR_NOCDIV_CSATCLK_OFFSET 24 |
| 165 | #define CLKMGR_NOCDIV_CSTRACECLK_OFFSET 26 |
| 166 | #define CLKMGR_NOCDIV_CSPDBGCLK_OFFSET 28 |
| 167 | #define CLKMGR_NOCDIV_DIVIDER_MASK 0x3 |
| 168 | |
| 169 | #define CLKMGR_PLLGLOB_PD_MASK BIT(0) |
| 170 | #define CLKMGR_PLLGLOB_RST_MASK BIT(1) |
| 171 | #define CLKMGR_PLLGLOB_AREFCLKDIV_MASK GENMASK(11, 8) |
| 172 | #define CLKMGR_PLLGLOB_DREFCLKDIV_MASK GENMASK(13, 12) |
| 173 | #define CLKMGR_PLLGLOB_REFCLKDIV_MASK GENMASK(13, 8) |
| 174 | #define CLKMGR_PLLGLOB_MODCLKDIV_MASK GENMASK(24, 27) |
| 175 | #define CLKMGR_PLLGLOB_AREFCLKDIV_OFFSET 8 |
| 176 | #define CLKMGR_PLLGLOB_DREFCLKDIV_OFFSET 12 |
| 177 | #define CLKMGR_PLLGLOB_REFCLKDIV_OFFSET 8 |
| 178 | #define CLKMGR_PLLGLOB_MODCLKDIV_OFFSET 24 |
| 179 | #define CLKMGR_PLLGLOB_VCO_PSRC_MASK GENMASK(17, 16) |
| 180 | #define CLKMGR_PLLGLOB_VCO_PSRC_OFFSET 16 |
| 181 | #define CLKMGR_PLLGLOB_CLR_LOSTLOCK_BYPASS_MASK BIT(29) |
| 182 | |
| 183 | #define CLKMGR_VCO_PSRC_EOSC1 0 |
| 184 | #define CLKMGR_VCO_PSRC_INTOSC 1 |
| 185 | #define CLKMGR_VCO_PSRC_F2S 2 |
| 186 | |
| 187 | #define CLKMGR_MEM_REQ_SET_MSK BIT(24) |
| 188 | #define CLKMGR_MEM_WR_SET_MSK BIT(25) |
| 189 | #define CLKMGR_MEM_ERR_MSK BIT(26) |
| 190 | #define CLKMGR_MEM_WDAT_LSB_OFFSET 16 |
| 191 | #define CLKMGR_MEM_ADDR_MASK GENMASK(15, 0) |
| 192 | #define CLKMGR_MEM_ADDR_START 0x00004000 |
| 193 | |
| 194 | #define CLKMGR_PLLCX_EN_SET_MSK BIT(27) |
| 195 | #define CLKMGR_PLLCX_MUTE_SET_MSK BIT(28) |
| 196 | |
| 197 | #define CLKMGR_VCOCALIB_MSCNT_MASK GENMASK(23, 16) |
| 198 | #define CLKMGR_VCOCALIB_MSCNT_OFFSET 16 |
| 199 | #define CLKMGR_VCOCALIB_HSCNT_MASK GENMASK(9, 0) |
| 200 | #define CLKMGR_VCOCALIB_MSCNT_CONST 100 |
| 201 | #define CLKMGR_VCOCALIB_HSCNT_CONST 4 |
| 202 | |
| 203 | #define CLKMGR_PLLM_MDIV_MASK GENMASK(9, 0) |
| 204 | |
| 205 | #define CLKMGR_LOSTLOCK_SET_MASK BIT(0) |
| 206 | |
| 207 | #define CLKMGR_PERPLLGRP_EN_SDMMCCLK_MASK BIT(5) |
| 208 | #define CLKMGR_PERPLLGRP_EMACCTL_EMAC0SELB_OFFSET 26 |
| 209 | #define CLKMGR_PERPLLGRP_EMACCTL_EMAC0SELB_MASK BIT(26) |
| 210 | #define CLKMGR_PERPLLGRP_EMACCTL_EMAC1SELB_OFFSET 27 |
| 211 | #define CLKMGR_PERPLLGRP_EMACCTL_EMAC1SELB_MASK BIT(27) |
| 212 | #define CLKMGR_PERPLLGRP_EMACCTL_EMAC2SELB_OFFSET 28 |
| 213 | #define CLKMGR_PERPLLGRP_EMACCTL_EMAC2SELB_MASK BIT(28) |
| 214 | |
| 215 | #define CLKMGR_ALT_EMACCTR_SRC_OFFSET 16 |
| 216 | #define CLKMGR_ALT_EMACCTR_SRC_MASK GENMASK(18, 16) |
| 217 | #define CLKMGR_ALT_EMACCTR_CNT_OFFSET 0 |
| 218 | #define CLKMGR_ALT_EMACCTR_CNT_MASK GENMASK(10, 0) |
| 219 | |
| 220 | #define CLKMGR_ALT_EXTCNTRST_EMACACNTRST BIT(0) |
| 221 | #define CLKMGR_ALT_EXTCNTRST_EMACBCNTRST BIT(1) |
| 222 | #define CLKMGR_ALT_EXTCNTRST_EMACPTPCNTRST BIT(2) |
| 223 | #define CLKMGR_ALT_EXTCNTRST_GPIODBCNTRST BIT(3) |
| 224 | #define CLKMGR_ALT_EXTCNTRST_SDMMCCNTRST BIT(4) |
| 225 | #define CLKMGR_ALT_EXTCNTRST_S2FUSER0CNTRST BIT(5) |
| 226 | #define CLKMGR_ALT_EXTCNTRST_S2FUSER1CNTRST BIT(6) |
| 227 | #define CLKMGR_ALT_EXTCNTRST_PSIREFCNTRST BIT(7) |
| 228 | #define CLKMGR_ALT_EXTCNTRST_ALLCNTRST \ |
| 229 | (CLKMGR_ALT_EXTCNTRST_EMACACNTRST | \ |
| 230 | CLKMGR_ALT_EXTCNTRST_EMACBCNTRST | \ |
| 231 | CLKMGR_ALT_EXTCNTRST_EMACPTPCNTRST | \ |
| 232 | CLKMGR_ALT_EXTCNTRST_GPIODBCNTRST | \ |
| 233 | CLKMGR_ALT_EXTCNTRST_SDMMCCNTRST | \ |
| 234 | CLKMGR_ALT_EXTCNTRST_S2FUSER0CNTRST | \ |
| 235 | CLKMGR_ALT_EXTCNTRST_S2FUSER1CNTRST | \ |
| 236 | CLKMGR_ALT_EXTCNTRST_PSIREFCNTRST) |
| 237 | #endif /* _CLK_AGILEX_ */ |