Peter De Schrijver | 2cb5efe | 2013-04-03 17:40:45 +0300 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2012, 2013, NVIDIA CORPORATION. All rights reserved. |
| 3 | * |
| 4 | * This program is free software; you can redistribute it and/or modify it |
| 5 | * under the terms and conditions of the GNU General Public License, |
| 6 | * version 2, as published by the Free Software Foundation. |
| 7 | * |
| 8 | * This program is distributed in the hope it will be useful, but WITHOUT |
| 9 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
| 10 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for |
| 11 | * more details. |
| 12 | * |
| 13 | * You should have received a copy of the GNU General Public License |
| 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 15 | */ |
| 16 | |
| 17 | #include <linux/io.h> |
| 18 | #include <linux/clk.h> |
| 19 | #include <linux/clk-provider.h> |
| 20 | #include <linux/clkdev.h> |
| 21 | #include <linux/of.h> |
| 22 | #include <linux/of_address.h> |
| 23 | #include <linux/delay.h> |
Paul Walmsley | 25c9ded | 2013-06-07 06:18:58 -0600 | [diff] [blame^] | 24 | #include <linux/export.h> |
Peter De Schrijver | 2cb5efe | 2013-04-03 17:40:45 +0300 | [diff] [blame] | 25 | #include <linux/clk/tegra.h> |
| 26 | |
| 27 | #include "clk.h" |
| 28 | |
| 29 | #define RST_DEVICES_L 0x004 |
| 30 | #define RST_DEVICES_H 0x008 |
| 31 | #define RST_DEVICES_U 0x00C |
| 32 | #define RST_DEVICES_V 0x358 |
| 33 | #define RST_DEVICES_W 0x35C |
| 34 | #define RST_DEVICES_X 0x28C |
| 35 | #define RST_DEVICES_SET_L 0x300 |
| 36 | #define RST_DEVICES_CLR_L 0x304 |
| 37 | #define RST_DEVICES_SET_H 0x308 |
| 38 | #define RST_DEVICES_CLR_H 0x30c |
| 39 | #define RST_DEVICES_SET_U 0x310 |
| 40 | #define RST_DEVICES_CLR_U 0x314 |
| 41 | #define RST_DEVICES_SET_V 0x430 |
| 42 | #define RST_DEVICES_CLR_V 0x434 |
| 43 | #define RST_DEVICES_SET_W 0x438 |
| 44 | #define RST_DEVICES_CLR_W 0x43c |
Paul Walmsley | 25c9ded | 2013-06-07 06:18:58 -0600 | [diff] [blame^] | 45 | #define CPU_FINETRIM_SELECT 0x4d4 /* override default prop dlys */ |
| 46 | #define CPU_FINETRIM_DR 0x4d8 /* rise->rise prop dly A */ |
| 47 | #define CPU_FINETRIM_R 0x4e4 /* rise->rise prop dly inc A */ |
Peter De Schrijver | 2cb5efe | 2013-04-03 17:40:45 +0300 | [diff] [blame] | 48 | #define RST_DEVICES_NUM 5 |
| 49 | |
Paul Walmsley | 25c9ded | 2013-06-07 06:18:58 -0600 | [diff] [blame^] | 50 | /* CPU_FINETRIM_SELECT and CPU_FINETRIM_DR bitfields */ |
| 51 | #define CPU_FINETRIM_1_FCPU_1 BIT(0) /* fcpu0 */ |
| 52 | #define CPU_FINETRIM_1_FCPU_2 BIT(1) /* fcpu1 */ |
| 53 | #define CPU_FINETRIM_1_FCPU_3 BIT(2) /* fcpu2 */ |
| 54 | #define CPU_FINETRIM_1_FCPU_4 BIT(3) /* fcpu3 */ |
| 55 | #define CPU_FINETRIM_1_FCPU_5 BIT(4) /* fl2 */ |
| 56 | #define CPU_FINETRIM_1_FCPU_6 BIT(5) /* ftop */ |
| 57 | |
| 58 | /* CPU_FINETRIM_R bitfields */ |
| 59 | #define CPU_FINETRIM_R_FCPU_1_SHIFT 0 /* fcpu0 */ |
| 60 | #define CPU_FINETRIM_R_FCPU_1_MASK (0x3 << CPU_FINETRIM_R_FCPU_1_SHIFT) |
| 61 | #define CPU_FINETRIM_R_FCPU_2_SHIFT 2 /* fcpu1 */ |
| 62 | #define CPU_FINETRIM_R_FCPU_2_MASK (0x3 << CPU_FINETRIM_R_FCPU_2_SHIFT) |
| 63 | #define CPU_FINETRIM_R_FCPU_3_SHIFT 4 /* fcpu2 */ |
| 64 | #define CPU_FINETRIM_R_FCPU_3_MASK (0x3 << CPU_FINETRIM_R_FCPU_3_SHIFT) |
| 65 | #define CPU_FINETRIM_R_FCPU_4_SHIFT 6 /* fcpu3 */ |
| 66 | #define CPU_FINETRIM_R_FCPU_4_MASK (0x3 << CPU_FINETRIM_R_FCPU_4_SHIFT) |
| 67 | #define CPU_FINETRIM_R_FCPU_5_SHIFT 8 /* fl2 */ |
| 68 | #define CPU_FINETRIM_R_FCPU_5_MASK (0x3 << CPU_FINETRIM_R_FCPU_5_SHIFT) |
| 69 | #define CPU_FINETRIM_R_FCPU_6_SHIFT 10 /* ftop */ |
| 70 | #define CPU_FINETRIM_R_FCPU_6_MASK (0x3 << CPU_FINETRIM_R_FCPU_6_SHIFT) |
| 71 | |
Peter De Schrijver | 2cb5efe | 2013-04-03 17:40:45 +0300 | [diff] [blame] | 72 | #define CLK_OUT_ENB_L 0x010 |
| 73 | #define CLK_OUT_ENB_H 0x014 |
| 74 | #define CLK_OUT_ENB_U 0x018 |
| 75 | #define CLK_OUT_ENB_V 0x360 |
| 76 | #define CLK_OUT_ENB_W 0x364 |
| 77 | #define CLK_OUT_ENB_X 0x280 |
| 78 | #define CLK_OUT_ENB_SET_L 0x320 |
| 79 | #define CLK_OUT_ENB_CLR_L 0x324 |
| 80 | #define CLK_OUT_ENB_SET_H 0x328 |
| 81 | #define CLK_OUT_ENB_CLR_H 0x32c |
| 82 | #define CLK_OUT_ENB_SET_U 0x330 |
| 83 | #define CLK_OUT_ENB_CLR_U 0x334 |
| 84 | #define CLK_OUT_ENB_SET_V 0x440 |
| 85 | #define CLK_OUT_ENB_CLR_V 0x444 |
| 86 | #define CLK_OUT_ENB_SET_W 0x448 |
| 87 | #define CLK_OUT_ENB_CLR_W 0x44c |
| 88 | #define CLK_OUT_ENB_SET_X 0x284 |
| 89 | #define CLK_OUT_ENB_CLR_X 0x288 |
| 90 | #define CLK_OUT_ENB_NUM 6 |
| 91 | |
| 92 | #define PLLC_BASE 0x80 |
| 93 | #define PLLC_MISC2 0x88 |
| 94 | #define PLLC_MISC 0x8c |
| 95 | #define PLLC2_BASE 0x4e8 |
| 96 | #define PLLC2_MISC 0x4ec |
| 97 | #define PLLC3_BASE 0x4fc |
| 98 | #define PLLC3_MISC 0x500 |
| 99 | #define PLLM_BASE 0x90 |
| 100 | #define PLLM_MISC 0x9c |
| 101 | #define PLLP_BASE 0xa0 |
| 102 | #define PLLP_MISC 0xac |
| 103 | #define PLLX_BASE 0xe0 |
| 104 | #define PLLX_MISC 0xe4 |
| 105 | #define PLLX_MISC2 0x514 |
| 106 | #define PLLX_MISC3 0x518 |
| 107 | #define PLLD_BASE 0xd0 |
| 108 | #define PLLD_MISC 0xdc |
| 109 | #define PLLD2_BASE 0x4b8 |
| 110 | #define PLLD2_MISC 0x4bc |
| 111 | #define PLLE_BASE 0xe8 |
| 112 | #define PLLE_MISC 0xec |
| 113 | #define PLLA_BASE 0xb0 |
| 114 | #define PLLA_MISC 0xbc |
| 115 | #define PLLU_BASE 0xc0 |
| 116 | #define PLLU_MISC 0xcc |
| 117 | #define PLLRE_BASE 0x4c4 |
| 118 | #define PLLRE_MISC 0x4c8 |
| 119 | |
| 120 | #define PLL_MISC_LOCK_ENABLE 18 |
| 121 | #define PLLC_MISC_LOCK_ENABLE 24 |
| 122 | #define PLLDU_MISC_LOCK_ENABLE 22 |
| 123 | #define PLLE_MISC_LOCK_ENABLE 9 |
| 124 | #define PLLRE_MISC_LOCK_ENABLE 30 |
| 125 | |
| 126 | #define PLLC_IDDQ_BIT 26 |
| 127 | #define PLLX_IDDQ_BIT 3 |
| 128 | #define PLLRE_IDDQ_BIT 16 |
| 129 | |
| 130 | #define PLL_BASE_LOCK BIT(27) |
| 131 | #define PLLE_MISC_LOCK BIT(11) |
| 132 | #define PLLRE_MISC_LOCK BIT(24) |
| 133 | #define PLLCX_BASE_LOCK (BIT(26)|BIT(27)) |
| 134 | |
| 135 | #define PLLE_AUX 0x48c |
| 136 | #define PLLC_OUT 0x84 |
| 137 | #define PLLM_OUT 0x94 |
| 138 | #define PLLP_OUTA 0xa4 |
| 139 | #define PLLP_OUTB 0xa8 |
| 140 | #define PLLA_OUT 0xb4 |
| 141 | |
| 142 | #define AUDIO_SYNC_CLK_I2S0 0x4a0 |
| 143 | #define AUDIO_SYNC_CLK_I2S1 0x4a4 |
| 144 | #define AUDIO_SYNC_CLK_I2S2 0x4a8 |
| 145 | #define AUDIO_SYNC_CLK_I2S3 0x4ac |
| 146 | #define AUDIO_SYNC_CLK_I2S4 0x4b0 |
| 147 | #define AUDIO_SYNC_CLK_SPDIF 0x4b4 |
| 148 | |
| 149 | #define AUDIO_SYNC_DOUBLER 0x49c |
| 150 | |
| 151 | #define PMC_CLK_OUT_CNTRL 0x1a8 |
| 152 | #define PMC_DPD_PADS_ORIDE 0x1c |
| 153 | #define PMC_DPD_PADS_ORIDE_BLINK_ENB 20 |
| 154 | #define PMC_CTRL 0 |
| 155 | #define PMC_CTRL_BLINK_ENB 7 |
Alexandre Courbot | 9139227 | 2013-05-26 11:56:31 +0900 | [diff] [blame] | 156 | #define PMC_BLINK_TIMER 0x40 |
Peter De Schrijver | 2cb5efe | 2013-04-03 17:40:45 +0300 | [diff] [blame] | 157 | |
| 158 | #define OSC_CTRL 0x50 |
| 159 | #define OSC_CTRL_OSC_FREQ_SHIFT 28 |
| 160 | #define OSC_CTRL_PLL_REF_DIV_SHIFT 26 |
| 161 | |
| 162 | #define PLLXC_SW_MAX_P 6 |
| 163 | |
| 164 | #define CCLKG_BURST_POLICY 0x368 |
| 165 | #define CCLKLP_BURST_POLICY 0x370 |
| 166 | #define SCLK_BURST_POLICY 0x028 |
| 167 | #define SYSTEM_CLK_RATE 0x030 |
| 168 | |
| 169 | #define UTMIP_PLL_CFG2 0x488 |
| 170 | #define UTMIP_PLL_CFG2_STABLE_COUNT(x) (((x) & 0xffff) << 6) |
| 171 | #define UTMIP_PLL_CFG2_ACTIVE_DLY_COUNT(x) (((x) & 0x3f) << 18) |
| 172 | #define UTMIP_PLL_CFG2_FORCE_PD_SAMP_A_POWERDOWN BIT(0) |
| 173 | #define UTMIP_PLL_CFG2_FORCE_PD_SAMP_B_POWERDOWN BIT(2) |
| 174 | #define UTMIP_PLL_CFG2_FORCE_PD_SAMP_C_POWERDOWN BIT(4) |
| 175 | |
| 176 | #define UTMIP_PLL_CFG1 0x484 |
| 177 | #define UTMIP_PLL_CFG1_ENABLE_DLY_COUNT(x) (((x) & 0x1f) << 6) |
| 178 | #define UTMIP_PLL_CFG1_XTAL_FREQ_COUNT(x) (((x) & 0xfff) << 0) |
| 179 | #define UTMIP_PLL_CFG1_FORCE_PLLU_POWERUP BIT(17) |
| 180 | #define UTMIP_PLL_CFG1_FORCE_PLLU_POWERDOWN BIT(16) |
| 181 | #define UTMIP_PLL_CFG1_FORCE_PLL_ENABLE_POWERUP BIT(15) |
| 182 | #define UTMIP_PLL_CFG1_FORCE_PLL_ENABLE_POWERDOWN BIT(14) |
| 183 | #define UTMIP_PLL_CFG1_FORCE_PLL_ACTIVE_POWERDOWN BIT(12) |
| 184 | |
| 185 | #define UTMIPLL_HW_PWRDN_CFG0 0x52c |
| 186 | #define UTMIPLL_HW_PWRDN_CFG0_SEQ_START_STATE BIT(25) |
| 187 | #define UTMIPLL_HW_PWRDN_CFG0_SEQ_ENABLE BIT(24) |
| 188 | #define UTMIPLL_HW_PWRDN_CFG0_USE_LOCKDET BIT(6) |
| 189 | #define UTMIPLL_HW_PWRDN_CFG0_SEQ_RESET_INPUT_VALUE BIT(5) |
| 190 | #define UTMIPLL_HW_PWRDN_CFG0_SEQ_IN_SWCTL BIT(4) |
| 191 | #define UTMIPLL_HW_PWRDN_CFG0_CLK_ENABLE_SWCTL BIT(2) |
| 192 | #define UTMIPLL_HW_PWRDN_CFG0_IDDQ_OVERRIDE BIT(1) |
| 193 | #define UTMIPLL_HW_PWRDN_CFG0_IDDQ_SWCTL BIT(0) |
| 194 | |
| 195 | #define CLK_SOURCE_I2S0 0x1d8 |
| 196 | #define CLK_SOURCE_I2S1 0x100 |
| 197 | #define CLK_SOURCE_I2S2 0x104 |
| 198 | #define CLK_SOURCE_NDFLASH 0x160 |
| 199 | #define CLK_SOURCE_I2S3 0x3bc |
| 200 | #define CLK_SOURCE_I2S4 0x3c0 |
| 201 | #define CLK_SOURCE_SPDIF_OUT 0x108 |
| 202 | #define CLK_SOURCE_SPDIF_IN 0x10c |
| 203 | #define CLK_SOURCE_PWM 0x110 |
| 204 | #define CLK_SOURCE_ADX 0x638 |
| 205 | #define CLK_SOURCE_AMX 0x63c |
| 206 | #define CLK_SOURCE_HDA 0x428 |
| 207 | #define CLK_SOURCE_HDA2CODEC_2X 0x3e4 |
| 208 | #define CLK_SOURCE_SBC1 0x134 |
| 209 | #define CLK_SOURCE_SBC2 0x118 |
| 210 | #define CLK_SOURCE_SBC3 0x11c |
| 211 | #define CLK_SOURCE_SBC4 0x1b4 |
| 212 | #define CLK_SOURCE_SBC5 0x3c8 |
| 213 | #define CLK_SOURCE_SBC6 0x3cc |
| 214 | #define CLK_SOURCE_SATA_OOB 0x420 |
| 215 | #define CLK_SOURCE_SATA 0x424 |
| 216 | #define CLK_SOURCE_NDSPEED 0x3f8 |
| 217 | #define CLK_SOURCE_VFIR 0x168 |
| 218 | #define CLK_SOURCE_SDMMC1 0x150 |
| 219 | #define CLK_SOURCE_SDMMC2 0x154 |
| 220 | #define CLK_SOURCE_SDMMC3 0x1bc |
| 221 | #define CLK_SOURCE_SDMMC4 0x164 |
| 222 | #define CLK_SOURCE_VDE 0x1c8 |
| 223 | #define CLK_SOURCE_CSITE 0x1d4 |
| 224 | #define CLK_SOURCE_LA 0x1f8 |
| 225 | #define CLK_SOURCE_TRACE 0x634 |
| 226 | #define CLK_SOURCE_OWR 0x1cc |
| 227 | #define CLK_SOURCE_NOR 0x1d0 |
| 228 | #define CLK_SOURCE_MIPI 0x174 |
| 229 | #define CLK_SOURCE_I2C1 0x124 |
| 230 | #define CLK_SOURCE_I2C2 0x198 |
| 231 | #define CLK_SOURCE_I2C3 0x1b8 |
| 232 | #define CLK_SOURCE_I2C4 0x3c4 |
| 233 | #define CLK_SOURCE_I2C5 0x128 |
| 234 | #define CLK_SOURCE_UARTA 0x178 |
| 235 | #define CLK_SOURCE_UARTB 0x17c |
| 236 | #define CLK_SOURCE_UARTC 0x1a0 |
| 237 | #define CLK_SOURCE_UARTD 0x1c0 |
| 238 | #define CLK_SOURCE_UARTE 0x1c4 |
| 239 | #define CLK_SOURCE_UARTA_DBG 0x178 |
| 240 | #define CLK_SOURCE_UARTB_DBG 0x17c |
| 241 | #define CLK_SOURCE_UARTC_DBG 0x1a0 |
| 242 | #define CLK_SOURCE_UARTD_DBG 0x1c0 |
| 243 | #define CLK_SOURCE_UARTE_DBG 0x1c4 |
| 244 | #define CLK_SOURCE_3D 0x158 |
| 245 | #define CLK_SOURCE_2D 0x15c |
| 246 | #define CLK_SOURCE_VI_SENSOR 0x1a8 |
| 247 | #define CLK_SOURCE_VI 0x148 |
| 248 | #define CLK_SOURCE_EPP 0x16c |
| 249 | #define CLK_SOURCE_MSENC 0x1f0 |
| 250 | #define CLK_SOURCE_TSEC 0x1f4 |
| 251 | #define CLK_SOURCE_HOST1X 0x180 |
| 252 | #define CLK_SOURCE_HDMI 0x18c |
| 253 | #define CLK_SOURCE_DISP1 0x138 |
| 254 | #define CLK_SOURCE_DISP2 0x13c |
| 255 | #define CLK_SOURCE_CILAB 0x614 |
| 256 | #define CLK_SOURCE_CILCD 0x618 |
| 257 | #define CLK_SOURCE_CILE 0x61c |
| 258 | #define CLK_SOURCE_DSIALP 0x620 |
| 259 | #define CLK_SOURCE_DSIBLP 0x624 |
| 260 | #define CLK_SOURCE_TSENSOR 0x3b8 |
| 261 | #define CLK_SOURCE_D_AUDIO 0x3d0 |
| 262 | #define CLK_SOURCE_DAM0 0x3d8 |
| 263 | #define CLK_SOURCE_DAM1 0x3dc |
| 264 | #define CLK_SOURCE_DAM2 0x3e0 |
| 265 | #define CLK_SOURCE_ACTMON 0x3e8 |
| 266 | #define CLK_SOURCE_EXTERN1 0x3ec |
| 267 | #define CLK_SOURCE_EXTERN2 0x3f0 |
| 268 | #define CLK_SOURCE_EXTERN3 0x3f4 |
| 269 | #define CLK_SOURCE_I2CSLOW 0x3fc |
| 270 | #define CLK_SOURCE_SE 0x42c |
| 271 | #define CLK_SOURCE_MSELECT 0x3b4 |
| 272 | #define CLK_SOURCE_SOC_THERM 0x644 |
| 273 | #define CLK_SOURCE_XUSB_HOST_SRC 0x600 |
| 274 | #define CLK_SOURCE_XUSB_FALCON_SRC 0x604 |
| 275 | #define CLK_SOURCE_XUSB_FS_SRC 0x608 |
| 276 | #define CLK_SOURCE_XUSB_SS_SRC 0x610 |
| 277 | #define CLK_SOURCE_XUSB_DEV_SRC 0x60c |
| 278 | #define CLK_SOURCE_EMC 0x19c |
| 279 | |
Peter De Schrijver | d53442e | 2013-06-06 13:47:29 +0300 | [diff] [blame] | 280 | /* PLLM override registers */ |
| 281 | #define PMC_PLLM_WB0_OVERRIDE 0x1dc |
| 282 | #define PMC_PLLM_WB0_OVERRIDE_2 0x2b0 |
| 283 | |
Peter De Schrijver | 2cb5efe | 2013-04-03 17:40:45 +0300 | [diff] [blame] | 284 | static int periph_clk_enb_refcnt[CLK_OUT_ENB_NUM * 32]; |
| 285 | |
| 286 | static void __iomem *clk_base; |
| 287 | static void __iomem *pmc_base; |
| 288 | |
| 289 | static DEFINE_SPINLOCK(pll_d_lock); |
| 290 | static DEFINE_SPINLOCK(pll_d2_lock); |
| 291 | static DEFINE_SPINLOCK(pll_u_lock); |
| 292 | static DEFINE_SPINLOCK(pll_div_lock); |
| 293 | static DEFINE_SPINLOCK(pll_re_lock); |
| 294 | static DEFINE_SPINLOCK(clk_doubler_lock); |
| 295 | static DEFINE_SPINLOCK(clk_out_lock); |
| 296 | static DEFINE_SPINLOCK(sysrate_lock); |
| 297 | |
Peter De Schrijver | fd428ad | 2013-06-05 16:51:26 +0300 | [diff] [blame] | 298 | static struct div_nmp pllxc_nmp = { |
| 299 | .divm_shift = 0, |
| 300 | .divm_width = 8, |
| 301 | .divn_shift = 8, |
| 302 | .divn_width = 8, |
| 303 | .divp_shift = 20, |
| 304 | .divp_width = 4, |
| 305 | }; |
| 306 | |
Peter De Schrijver | 2cb5efe | 2013-04-03 17:40:45 +0300 | [diff] [blame] | 307 | static struct pdiv_map pllxc_p[] = { |
| 308 | { .pdiv = 1, .hw_val = 0 }, |
| 309 | { .pdiv = 2, .hw_val = 1 }, |
| 310 | { .pdiv = 3, .hw_val = 2 }, |
| 311 | { .pdiv = 4, .hw_val = 3 }, |
| 312 | { .pdiv = 5, .hw_val = 4 }, |
| 313 | { .pdiv = 6, .hw_val = 5 }, |
| 314 | { .pdiv = 8, .hw_val = 6 }, |
| 315 | { .pdiv = 10, .hw_val = 7 }, |
| 316 | { .pdiv = 12, .hw_val = 8 }, |
| 317 | { .pdiv = 16, .hw_val = 9 }, |
| 318 | { .pdiv = 12, .hw_val = 10 }, |
| 319 | { .pdiv = 16, .hw_val = 11 }, |
| 320 | { .pdiv = 20, .hw_val = 12 }, |
| 321 | { .pdiv = 24, .hw_val = 13 }, |
| 322 | { .pdiv = 32, .hw_val = 14 }, |
| 323 | { .pdiv = 0, .hw_val = 0 }, |
| 324 | }; |
| 325 | |
| 326 | static struct tegra_clk_pll_freq_table pll_c_freq_table[] = { |
| 327 | { 12000000, 624000000, 104, 0, 2}, |
| 328 | { 12000000, 600000000, 100, 0, 2}, |
| 329 | { 13000000, 600000000, 92, 0, 2}, /* actual: 598.0 MHz */ |
| 330 | { 16800000, 600000000, 71, 0, 2}, /* actual: 596.4 MHz */ |
| 331 | { 19200000, 600000000, 62, 0, 2}, /* actual: 595.2 MHz */ |
| 332 | { 26000000, 600000000, 92, 1, 2}, /* actual: 598.0 MHz */ |
| 333 | { 0, 0, 0, 0, 0, 0 }, |
| 334 | }; |
| 335 | |
| 336 | static struct tegra_clk_pll_params pll_c_params = { |
| 337 | .input_min = 12000000, |
| 338 | .input_max = 800000000, |
| 339 | .cf_min = 12000000, |
| 340 | .cf_max = 19200000, /* s/w policy, h/w capability 50 MHz */ |
| 341 | .vco_min = 600000000, |
| 342 | .vco_max = 1400000000, |
| 343 | .base_reg = PLLC_BASE, |
| 344 | .misc_reg = PLLC_MISC, |
| 345 | .lock_mask = PLL_BASE_LOCK, |
| 346 | .lock_enable_bit_idx = PLLC_MISC_LOCK_ENABLE, |
| 347 | .lock_delay = 300, |
| 348 | .iddq_reg = PLLC_MISC, |
| 349 | .iddq_bit_idx = PLLC_IDDQ_BIT, |
| 350 | .max_p = PLLXC_SW_MAX_P, |
| 351 | .dyn_ramp_reg = PLLC_MISC2, |
| 352 | .stepa_shift = 17, |
| 353 | .stepb_shift = 9, |
| 354 | .pdiv_tohw = pllxc_p, |
Peter De Schrijver | fd428ad | 2013-06-05 16:51:26 +0300 | [diff] [blame] | 355 | .div_nmp = &pllxc_nmp, |
| 356 | }; |
| 357 | |
| 358 | static struct div_nmp pllcx_nmp = { |
| 359 | .divm_shift = 0, |
| 360 | .divm_width = 2, |
| 361 | .divn_shift = 8, |
| 362 | .divn_width = 8, |
| 363 | .divp_shift = 20, |
| 364 | .divp_width = 3, |
Peter De Schrijver | 2cb5efe | 2013-04-03 17:40:45 +0300 | [diff] [blame] | 365 | }; |
| 366 | |
| 367 | static struct pdiv_map pllc_p[] = { |
| 368 | { .pdiv = 1, .hw_val = 0 }, |
| 369 | { .pdiv = 2, .hw_val = 1 }, |
| 370 | { .pdiv = 4, .hw_val = 3 }, |
| 371 | { .pdiv = 8, .hw_val = 5 }, |
| 372 | { .pdiv = 16, .hw_val = 7 }, |
| 373 | { .pdiv = 0, .hw_val = 0 }, |
| 374 | }; |
| 375 | |
| 376 | static struct tegra_clk_pll_freq_table pll_cx_freq_table[] = { |
| 377 | {12000000, 600000000, 100, 0, 2}, |
| 378 | {13000000, 600000000, 92, 0, 2}, /* actual: 598.0 MHz */ |
| 379 | {16800000, 600000000, 71, 0, 2}, /* actual: 596.4 MHz */ |
| 380 | {19200000, 600000000, 62, 0, 2}, /* actual: 595.2 MHz */ |
| 381 | {26000000, 600000000, 92, 1, 2}, /* actual: 598.0 MHz */ |
| 382 | {0, 0, 0, 0, 0, 0}, |
| 383 | }; |
| 384 | |
| 385 | static struct tegra_clk_pll_params pll_c2_params = { |
| 386 | .input_min = 12000000, |
| 387 | .input_max = 48000000, |
| 388 | .cf_min = 12000000, |
| 389 | .cf_max = 19200000, |
| 390 | .vco_min = 600000000, |
| 391 | .vco_max = 1200000000, |
| 392 | .base_reg = PLLC2_BASE, |
| 393 | .misc_reg = PLLC2_MISC, |
| 394 | .lock_mask = PLL_BASE_LOCK, |
| 395 | .lock_enable_bit_idx = PLL_MISC_LOCK_ENABLE, |
| 396 | .lock_delay = 300, |
| 397 | .pdiv_tohw = pllc_p, |
Peter De Schrijver | fd428ad | 2013-06-05 16:51:26 +0300 | [diff] [blame] | 398 | .div_nmp = &pllcx_nmp, |
| 399 | .max_p = 7, |
Peter De Schrijver | 2cb5efe | 2013-04-03 17:40:45 +0300 | [diff] [blame] | 400 | .ext_misc_reg[0] = 0x4f0, |
| 401 | .ext_misc_reg[1] = 0x4f4, |
| 402 | .ext_misc_reg[2] = 0x4f8, |
| 403 | }; |
| 404 | |
| 405 | static struct tegra_clk_pll_params pll_c3_params = { |
| 406 | .input_min = 12000000, |
| 407 | .input_max = 48000000, |
| 408 | .cf_min = 12000000, |
| 409 | .cf_max = 19200000, |
| 410 | .vco_min = 600000000, |
| 411 | .vco_max = 1200000000, |
| 412 | .base_reg = PLLC3_BASE, |
| 413 | .misc_reg = PLLC3_MISC, |
| 414 | .lock_mask = PLL_BASE_LOCK, |
| 415 | .lock_enable_bit_idx = PLL_MISC_LOCK_ENABLE, |
| 416 | .lock_delay = 300, |
| 417 | .pdiv_tohw = pllc_p, |
Peter De Schrijver | fd428ad | 2013-06-05 16:51:26 +0300 | [diff] [blame] | 418 | .div_nmp = &pllcx_nmp, |
| 419 | .max_p = 7, |
Peter De Schrijver | 2cb5efe | 2013-04-03 17:40:45 +0300 | [diff] [blame] | 420 | .ext_misc_reg[0] = 0x504, |
| 421 | .ext_misc_reg[1] = 0x508, |
| 422 | .ext_misc_reg[2] = 0x50c, |
| 423 | }; |
| 424 | |
Peter De Schrijver | fd428ad | 2013-06-05 16:51:26 +0300 | [diff] [blame] | 425 | static struct div_nmp pllm_nmp = { |
| 426 | .divm_shift = 0, |
| 427 | .divm_width = 8, |
Peter De Schrijver | d53442e | 2013-06-06 13:47:29 +0300 | [diff] [blame] | 428 | .override_divm_shift = 0, |
Peter De Schrijver | fd428ad | 2013-06-05 16:51:26 +0300 | [diff] [blame] | 429 | .divn_shift = 8, |
| 430 | .divn_width = 8, |
Peter De Schrijver | d53442e | 2013-06-06 13:47:29 +0300 | [diff] [blame] | 431 | .override_divn_shift = 8, |
Peter De Schrijver | fd428ad | 2013-06-05 16:51:26 +0300 | [diff] [blame] | 432 | .divp_shift = 20, |
| 433 | .divp_width = 1, |
Peter De Schrijver | d53442e | 2013-06-06 13:47:29 +0300 | [diff] [blame] | 434 | .override_divp_shift = 27, |
Peter De Schrijver | fd428ad | 2013-06-05 16:51:26 +0300 | [diff] [blame] | 435 | }; |
| 436 | |
Peter De Schrijver | 2cb5efe | 2013-04-03 17:40:45 +0300 | [diff] [blame] | 437 | static struct pdiv_map pllm_p[] = { |
| 438 | { .pdiv = 1, .hw_val = 0 }, |
| 439 | { .pdiv = 2, .hw_val = 1 }, |
| 440 | { .pdiv = 0, .hw_val = 0 }, |
| 441 | }; |
| 442 | |
| 443 | static struct tegra_clk_pll_freq_table pll_m_freq_table[] = { |
| 444 | {12000000, 800000000, 66, 0, 1}, /* actual: 792.0 MHz */ |
| 445 | {13000000, 800000000, 61, 0, 1}, /* actual: 793.0 MHz */ |
| 446 | {16800000, 800000000, 47, 0, 1}, /* actual: 789.6 MHz */ |
| 447 | {19200000, 800000000, 41, 0, 1}, /* actual: 787.2 MHz */ |
| 448 | {26000000, 800000000, 61, 1, 1}, /* actual: 793.0 MHz */ |
| 449 | {0, 0, 0, 0, 0, 0}, |
| 450 | }; |
| 451 | |
| 452 | static struct tegra_clk_pll_params pll_m_params = { |
| 453 | .input_min = 12000000, |
| 454 | .input_max = 500000000, |
| 455 | .cf_min = 12000000, |
| 456 | .cf_max = 19200000, /* s/w policy, h/w capability 50 MHz */ |
| 457 | .vco_min = 400000000, |
| 458 | .vco_max = 1066000000, |
| 459 | .base_reg = PLLM_BASE, |
| 460 | .misc_reg = PLLM_MISC, |
| 461 | .lock_mask = PLL_BASE_LOCK, |
| 462 | .lock_enable_bit_idx = PLL_MISC_LOCK_ENABLE, |
| 463 | .lock_delay = 300, |
| 464 | .max_p = 2, |
| 465 | .pdiv_tohw = pllm_p, |
Peter De Schrijver | fd428ad | 2013-06-05 16:51:26 +0300 | [diff] [blame] | 466 | .div_nmp = &pllm_nmp, |
Peter De Schrijver | d53442e | 2013-06-06 13:47:29 +0300 | [diff] [blame] | 467 | .pmc_divnm_reg = PMC_PLLM_WB0_OVERRIDE, |
| 468 | .pmc_divp_reg = PMC_PLLM_WB0_OVERRIDE_2, |
Peter De Schrijver | fd428ad | 2013-06-05 16:51:26 +0300 | [diff] [blame] | 469 | }; |
| 470 | |
| 471 | static struct div_nmp pllp_nmp = { |
| 472 | .divm_shift = 0, |
| 473 | .divm_width = 5, |
| 474 | .divn_shift = 8, |
| 475 | .divn_width = 10, |
| 476 | .divp_shift = 20, |
| 477 | .divp_width = 3, |
Peter De Schrijver | 2cb5efe | 2013-04-03 17:40:45 +0300 | [diff] [blame] | 478 | }; |
| 479 | |
| 480 | static struct tegra_clk_pll_freq_table pll_p_freq_table[] = { |
| 481 | {12000000, 216000000, 432, 12, 1, 8}, |
| 482 | {13000000, 216000000, 432, 13, 1, 8}, |
| 483 | {16800000, 216000000, 360, 14, 1, 8}, |
| 484 | {19200000, 216000000, 360, 16, 1, 8}, |
| 485 | {26000000, 216000000, 432, 26, 1, 8}, |
| 486 | {0, 0, 0, 0, 0, 0}, |
| 487 | }; |
| 488 | |
| 489 | static struct tegra_clk_pll_params pll_p_params = { |
| 490 | .input_min = 2000000, |
| 491 | .input_max = 31000000, |
| 492 | .cf_min = 1000000, |
| 493 | .cf_max = 6000000, |
| 494 | .vco_min = 200000000, |
| 495 | .vco_max = 700000000, |
| 496 | .base_reg = PLLP_BASE, |
| 497 | .misc_reg = PLLP_MISC, |
| 498 | .lock_mask = PLL_BASE_LOCK, |
| 499 | .lock_enable_bit_idx = PLL_MISC_LOCK_ENABLE, |
| 500 | .lock_delay = 300, |
Peter De Schrijver | fd428ad | 2013-06-05 16:51:26 +0300 | [diff] [blame] | 501 | .div_nmp = &pllp_nmp, |
Peter De Schrijver | 2cb5efe | 2013-04-03 17:40:45 +0300 | [diff] [blame] | 502 | }; |
| 503 | |
| 504 | static struct tegra_clk_pll_freq_table pll_a_freq_table[] = { |
| 505 | {9600000, 282240000, 147, 5, 0, 4}, |
| 506 | {9600000, 368640000, 192, 5, 0, 4}, |
| 507 | {9600000, 240000000, 200, 8, 0, 8}, |
| 508 | |
| 509 | {28800000, 282240000, 245, 25, 0, 8}, |
| 510 | {28800000, 368640000, 320, 25, 0, 8}, |
| 511 | {28800000, 240000000, 200, 24, 0, 8}, |
| 512 | {0, 0, 0, 0, 0, 0}, |
| 513 | }; |
| 514 | |
| 515 | |
| 516 | static struct tegra_clk_pll_params pll_a_params = { |
| 517 | .input_min = 2000000, |
| 518 | .input_max = 31000000, |
| 519 | .cf_min = 1000000, |
| 520 | .cf_max = 6000000, |
| 521 | .vco_min = 200000000, |
| 522 | .vco_max = 700000000, |
| 523 | .base_reg = PLLA_BASE, |
| 524 | .misc_reg = PLLA_MISC, |
| 525 | .lock_mask = PLL_BASE_LOCK, |
| 526 | .lock_enable_bit_idx = PLL_MISC_LOCK_ENABLE, |
| 527 | .lock_delay = 300, |
Peter De Schrijver | fd428ad | 2013-06-05 16:51:26 +0300 | [diff] [blame] | 528 | .div_nmp = &pllp_nmp, |
Peter De Schrijver | 2cb5efe | 2013-04-03 17:40:45 +0300 | [diff] [blame] | 529 | }; |
| 530 | |
| 531 | static struct tegra_clk_pll_freq_table pll_d_freq_table[] = { |
| 532 | {12000000, 216000000, 864, 12, 2, 12}, |
| 533 | {13000000, 216000000, 864, 13, 2, 12}, |
| 534 | {16800000, 216000000, 720, 14, 2, 12}, |
| 535 | {19200000, 216000000, 720, 16, 2, 12}, |
| 536 | {26000000, 216000000, 864, 26, 2, 12}, |
| 537 | |
| 538 | {12000000, 594000000, 594, 12, 0, 12}, |
| 539 | {13000000, 594000000, 594, 13, 0, 12}, |
| 540 | {16800000, 594000000, 495, 14, 0, 12}, |
| 541 | {19200000, 594000000, 495, 16, 0, 12}, |
| 542 | {26000000, 594000000, 594, 26, 0, 12}, |
| 543 | |
| 544 | {12000000, 1000000000, 1000, 12, 0, 12}, |
| 545 | {13000000, 1000000000, 1000, 13, 0, 12}, |
| 546 | {19200000, 1000000000, 625, 12, 0, 12}, |
| 547 | {26000000, 1000000000, 1000, 26, 0, 12}, |
| 548 | |
| 549 | {0, 0, 0, 0, 0, 0}, |
| 550 | }; |
| 551 | |
| 552 | static struct tegra_clk_pll_params pll_d_params = { |
| 553 | .input_min = 2000000, |
| 554 | .input_max = 40000000, |
| 555 | .cf_min = 1000000, |
| 556 | .cf_max = 6000000, |
| 557 | .vco_min = 500000000, |
| 558 | .vco_max = 1000000000, |
| 559 | .base_reg = PLLD_BASE, |
| 560 | .misc_reg = PLLD_MISC, |
| 561 | .lock_mask = PLL_BASE_LOCK, |
| 562 | .lock_enable_bit_idx = PLLDU_MISC_LOCK_ENABLE, |
| 563 | .lock_delay = 1000, |
Peter De Schrijver | fd428ad | 2013-06-05 16:51:26 +0300 | [diff] [blame] | 564 | .div_nmp = &pllp_nmp, |
Peter De Schrijver | 2cb5efe | 2013-04-03 17:40:45 +0300 | [diff] [blame] | 565 | }; |
| 566 | |
| 567 | static struct tegra_clk_pll_params pll_d2_params = { |
| 568 | .input_min = 2000000, |
| 569 | .input_max = 40000000, |
| 570 | .cf_min = 1000000, |
| 571 | .cf_max = 6000000, |
| 572 | .vco_min = 500000000, |
| 573 | .vco_max = 1000000000, |
| 574 | .base_reg = PLLD2_BASE, |
| 575 | .misc_reg = PLLD2_MISC, |
| 576 | .lock_mask = PLL_BASE_LOCK, |
| 577 | .lock_enable_bit_idx = PLLDU_MISC_LOCK_ENABLE, |
| 578 | .lock_delay = 1000, |
Peter De Schrijver | fd428ad | 2013-06-05 16:51:26 +0300 | [diff] [blame] | 579 | .div_nmp = &pllp_nmp, |
Peter De Schrijver | 2cb5efe | 2013-04-03 17:40:45 +0300 | [diff] [blame] | 580 | }; |
| 581 | |
| 582 | static struct pdiv_map pllu_p[] = { |
| 583 | { .pdiv = 1, .hw_val = 1 }, |
| 584 | { .pdiv = 2, .hw_val = 0 }, |
| 585 | { .pdiv = 0, .hw_val = 0 }, |
| 586 | }; |
| 587 | |
Peter De Schrijver | fd428ad | 2013-06-05 16:51:26 +0300 | [diff] [blame] | 588 | static struct div_nmp pllu_nmp = { |
| 589 | .divm_shift = 0, |
| 590 | .divm_width = 5, |
| 591 | .divn_shift = 8, |
| 592 | .divn_width = 10, |
| 593 | .divp_shift = 20, |
| 594 | .divp_width = 1, |
| 595 | }; |
| 596 | |
Peter De Schrijver | 2cb5efe | 2013-04-03 17:40:45 +0300 | [diff] [blame] | 597 | static struct tegra_clk_pll_freq_table pll_u_freq_table[] = { |
| 598 | {12000000, 480000000, 960, 12, 0, 12}, |
| 599 | {13000000, 480000000, 960, 13, 0, 12}, |
| 600 | {16800000, 480000000, 400, 7, 0, 5}, |
| 601 | {19200000, 480000000, 200, 4, 0, 3}, |
| 602 | {26000000, 480000000, 960, 26, 0, 12}, |
| 603 | {0, 0, 0, 0, 0, 0}, |
| 604 | }; |
| 605 | |
| 606 | static struct tegra_clk_pll_params pll_u_params = { |
| 607 | .input_min = 2000000, |
| 608 | .input_max = 40000000, |
| 609 | .cf_min = 1000000, |
| 610 | .cf_max = 6000000, |
| 611 | .vco_min = 480000000, |
| 612 | .vco_max = 960000000, |
| 613 | .base_reg = PLLU_BASE, |
| 614 | .misc_reg = PLLU_MISC, |
| 615 | .lock_mask = PLL_BASE_LOCK, |
| 616 | .lock_enable_bit_idx = PLLDU_MISC_LOCK_ENABLE, |
| 617 | .lock_delay = 1000, |
| 618 | .pdiv_tohw = pllu_p, |
Peter De Schrijver | fd428ad | 2013-06-05 16:51:26 +0300 | [diff] [blame] | 619 | .div_nmp = &pllu_nmp, |
Peter De Schrijver | 2cb5efe | 2013-04-03 17:40:45 +0300 | [diff] [blame] | 620 | }; |
| 621 | |
| 622 | static struct tegra_clk_pll_freq_table pll_x_freq_table[] = { |
| 623 | /* 1 GHz */ |
| 624 | {12000000, 1000000000, 83, 0, 1}, /* actual: 996.0 MHz */ |
| 625 | {13000000, 1000000000, 76, 0, 1}, /* actual: 988.0 MHz */ |
| 626 | {16800000, 1000000000, 59, 0, 1}, /* actual: 991.2 MHz */ |
| 627 | {19200000, 1000000000, 52, 0, 1}, /* actual: 998.4 MHz */ |
| 628 | {26000000, 1000000000, 76, 1, 1}, /* actual: 988.0 MHz */ |
| 629 | |
| 630 | {0, 0, 0, 0, 0, 0}, |
| 631 | }; |
| 632 | |
| 633 | static struct tegra_clk_pll_params pll_x_params = { |
| 634 | .input_min = 12000000, |
| 635 | .input_max = 800000000, |
| 636 | .cf_min = 12000000, |
| 637 | .cf_max = 19200000, /* s/w policy, h/w capability 50 MHz */ |
| 638 | .vco_min = 700000000, |
| 639 | .vco_max = 2400000000U, |
| 640 | .base_reg = PLLX_BASE, |
| 641 | .misc_reg = PLLX_MISC, |
| 642 | .lock_mask = PLL_BASE_LOCK, |
| 643 | .lock_enable_bit_idx = PLL_MISC_LOCK_ENABLE, |
| 644 | .lock_delay = 300, |
| 645 | .iddq_reg = PLLX_MISC3, |
| 646 | .iddq_bit_idx = PLLX_IDDQ_BIT, |
| 647 | .max_p = PLLXC_SW_MAX_P, |
| 648 | .dyn_ramp_reg = PLLX_MISC2, |
| 649 | .stepa_shift = 16, |
| 650 | .stepb_shift = 24, |
| 651 | .pdiv_tohw = pllxc_p, |
Peter De Schrijver | fd428ad | 2013-06-05 16:51:26 +0300 | [diff] [blame] | 652 | .div_nmp = &pllxc_nmp, |
Peter De Schrijver | 2cb5efe | 2013-04-03 17:40:45 +0300 | [diff] [blame] | 653 | }; |
| 654 | |
| 655 | static struct tegra_clk_pll_freq_table pll_e_freq_table[] = { |
| 656 | /* PLLE special case: use cpcon field to store cml divider value */ |
| 657 | {336000000, 100000000, 100, 21, 16, 11}, |
| 658 | {312000000, 100000000, 200, 26, 24, 13}, |
| 659 | {0, 0, 0, 0, 0, 0}, |
| 660 | }; |
| 661 | |
Peter De Schrijver | fd428ad | 2013-06-05 16:51:26 +0300 | [diff] [blame] | 662 | static struct div_nmp plle_nmp = { |
| 663 | .divm_shift = 0, |
| 664 | .divm_width = 8, |
| 665 | .divn_shift = 8, |
| 666 | .divn_width = 8, |
| 667 | .divp_shift = 24, |
| 668 | .divp_width = 4, |
| 669 | }; |
| 670 | |
Peter De Schrijver | 2cb5efe | 2013-04-03 17:40:45 +0300 | [diff] [blame] | 671 | static struct tegra_clk_pll_params pll_e_params = { |
| 672 | .input_min = 12000000, |
| 673 | .input_max = 1000000000, |
| 674 | .cf_min = 12000000, |
| 675 | .cf_max = 75000000, |
| 676 | .vco_min = 1600000000, |
| 677 | .vco_max = 2400000000U, |
| 678 | .base_reg = PLLE_BASE, |
| 679 | .misc_reg = PLLE_MISC, |
| 680 | .aux_reg = PLLE_AUX, |
| 681 | .lock_mask = PLLE_MISC_LOCK, |
| 682 | .lock_enable_bit_idx = PLLE_MISC_LOCK_ENABLE, |
| 683 | .lock_delay = 300, |
Peter De Schrijver | fd428ad | 2013-06-05 16:51:26 +0300 | [diff] [blame] | 684 | .div_nmp = &plle_nmp, |
| 685 | }; |
| 686 | |
| 687 | static struct div_nmp pllre_nmp = { |
| 688 | .divm_shift = 0, |
| 689 | .divm_width = 8, |
| 690 | .divn_shift = 8, |
| 691 | .divn_width = 8, |
| 692 | .divp_shift = 16, |
| 693 | .divp_width = 4, |
Peter De Schrijver | 2cb5efe | 2013-04-03 17:40:45 +0300 | [diff] [blame] | 694 | }; |
| 695 | |
| 696 | static struct tegra_clk_pll_params pll_re_vco_params = { |
| 697 | .input_min = 12000000, |
| 698 | .input_max = 1000000000, |
| 699 | .cf_min = 12000000, |
| 700 | .cf_max = 19200000, /* s/w policy, h/w capability 38 MHz */ |
| 701 | .vco_min = 300000000, |
| 702 | .vco_max = 600000000, |
| 703 | .base_reg = PLLRE_BASE, |
| 704 | .misc_reg = PLLRE_MISC, |
| 705 | .lock_mask = PLLRE_MISC_LOCK, |
| 706 | .lock_enable_bit_idx = PLLRE_MISC_LOCK_ENABLE, |
| 707 | .lock_delay = 300, |
| 708 | .iddq_reg = PLLRE_MISC, |
| 709 | .iddq_bit_idx = PLLRE_IDDQ_BIT, |
Peter De Schrijver | fd428ad | 2013-06-05 16:51:26 +0300 | [diff] [blame] | 710 | .div_nmp = &pllre_nmp, |
Peter De Schrijver | 2cb5efe | 2013-04-03 17:40:45 +0300 | [diff] [blame] | 711 | }; |
| 712 | |
| 713 | /* Peripheral clock registers */ |
| 714 | |
| 715 | static struct tegra_clk_periph_regs periph_l_regs = { |
| 716 | .enb_reg = CLK_OUT_ENB_L, |
| 717 | .enb_set_reg = CLK_OUT_ENB_SET_L, |
| 718 | .enb_clr_reg = CLK_OUT_ENB_CLR_L, |
| 719 | .rst_reg = RST_DEVICES_L, |
| 720 | .rst_set_reg = RST_DEVICES_SET_L, |
| 721 | .rst_clr_reg = RST_DEVICES_CLR_L, |
| 722 | }; |
| 723 | |
| 724 | static struct tegra_clk_periph_regs periph_h_regs = { |
| 725 | .enb_reg = CLK_OUT_ENB_H, |
| 726 | .enb_set_reg = CLK_OUT_ENB_SET_H, |
| 727 | .enb_clr_reg = CLK_OUT_ENB_CLR_H, |
| 728 | .rst_reg = RST_DEVICES_H, |
| 729 | .rst_set_reg = RST_DEVICES_SET_H, |
| 730 | .rst_clr_reg = RST_DEVICES_CLR_H, |
| 731 | }; |
| 732 | |
| 733 | static struct tegra_clk_periph_regs periph_u_regs = { |
| 734 | .enb_reg = CLK_OUT_ENB_U, |
| 735 | .enb_set_reg = CLK_OUT_ENB_SET_U, |
| 736 | .enb_clr_reg = CLK_OUT_ENB_CLR_U, |
| 737 | .rst_reg = RST_DEVICES_U, |
| 738 | .rst_set_reg = RST_DEVICES_SET_U, |
| 739 | .rst_clr_reg = RST_DEVICES_CLR_U, |
| 740 | }; |
| 741 | |
| 742 | static struct tegra_clk_periph_regs periph_v_regs = { |
| 743 | .enb_reg = CLK_OUT_ENB_V, |
| 744 | .enb_set_reg = CLK_OUT_ENB_SET_V, |
| 745 | .enb_clr_reg = CLK_OUT_ENB_CLR_V, |
| 746 | .rst_reg = RST_DEVICES_V, |
| 747 | .rst_set_reg = RST_DEVICES_SET_V, |
| 748 | .rst_clr_reg = RST_DEVICES_CLR_V, |
| 749 | }; |
| 750 | |
| 751 | static struct tegra_clk_periph_regs periph_w_regs = { |
| 752 | .enb_reg = CLK_OUT_ENB_W, |
| 753 | .enb_set_reg = CLK_OUT_ENB_SET_W, |
| 754 | .enb_clr_reg = CLK_OUT_ENB_CLR_W, |
| 755 | .rst_reg = RST_DEVICES_W, |
| 756 | .rst_set_reg = RST_DEVICES_SET_W, |
| 757 | .rst_clr_reg = RST_DEVICES_CLR_W, |
| 758 | }; |
| 759 | |
| 760 | /* possible OSC frequencies in Hz */ |
| 761 | static unsigned long tegra114_input_freq[] = { |
| 762 | [0] = 13000000, |
| 763 | [1] = 16800000, |
| 764 | [4] = 19200000, |
| 765 | [5] = 38400000, |
| 766 | [8] = 12000000, |
| 767 | [9] = 48000000, |
| 768 | [12] = 260000000, |
| 769 | }; |
| 770 | |
| 771 | #define MASK(x) (BIT(x) - 1) |
| 772 | |
| 773 | #define TEGRA_INIT_DATA_MUX(_name, _con_id, _dev_id, _parents, _offset, \ |
| 774 | _clk_num, _regs, _gate_flags, _clk_id) \ |
| 775 | TEGRA_INIT_DATA_TABLE(_name, _con_id, _dev_id, _parents, _offset,\ |
| 776 | 30, MASK(2), 0, 0, 8, 1, 0, _regs, _clk_num, \ |
| 777 | periph_clk_enb_refcnt, _gate_flags, _clk_id, \ |
| 778 | _parents##_idx, 0) |
| 779 | |
| 780 | #define TEGRA_INIT_DATA_MUX_FLAGS(_name, _con_id, _dev_id, _parents, _offset,\ |
| 781 | _clk_num, _regs, _gate_flags, _clk_id, flags)\ |
| 782 | TEGRA_INIT_DATA_TABLE(_name, _con_id, _dev_id, _parents, _offset,\ |
| 783 | 30, MASK(2), 0, 0, 8, 1, 0, _regs, _clk_num, \ |
| 784 | periph_clk_enb_refcnt, _gate_flags, _clk_id, \ |
| 785 | _parents##_idx, flags) |
| 786 | |
| 787 | #define TEGRA_INIT_DATA_MUX8(_name, _con_id, _dev_id, _parents, _offset, \ |
| 788 | _clk_num, _regs, _gate_flags, _clk_id) \ |
| 789 | TEGRA_INIT_DATA_TABLE(_name, _con_id, _dev_id, _parents, _offset,\ |
| 790 | 29, MASK(3), 0, 0, 8, 1, 0, _regs, _clk_num, \ |
| 791 | periph_clk_enb_refcnt, _gate_flags, _clk_id, \ |
| 792 | _parents##_idx, 0) |
| 793 | |
| 794 | #define TEGRA_INIT_DATA_INT(_name, _con_id, _dev_id, _parents, _offset, \ |
| 795 | _clk_num, _regs, _gate_flags, _clk_id) \ |
| 796 | TEGRA_INIT_DATA_TABLE(_name, _con_id, _dev_id, _parents, _offset,\ |
| 797 | 30, MASK(2), 0, 0, 8, 1, TEGRA_DIVIDER_INT, _regs,\ |
| 798 | _clk_num, periph_clk_enb_refcnt, _gate_flags, \ |
| 799 | _clk_id, _parents##_idx, 0) |
| 800 | |
| 801 | #define TEGRA_INIT_DATA_INT_FLAGS(_name, _con_id, _dev_id, _parents, _offset,\ |
| 802 | _clk_num, _regs, _gate_flags, _clk_id, flags)\ |
| 803 | TEGRA_INIT_DATA_TABLE(_name, _con_id, _dev_id, _parents, _offset,\ |
| 804 | 30, MASK(2), 0, 0, 8, 1, TEGRA_DIVIDER_INT, _regs,\ |
| 805 | _clk_num, periph_clk_enb_refcnt, _gate_flags, \ |
| 806 | _clk_id, _parents##_idx, flags) |
| 807 | |
| 808 | #define TEGRA_INIT_DATA_INT8(_name, _con_id, _dev_id, _parents, _offset,\ |
| 809 | _clk_num, _regs, _gate_flags, _clk_id) \ |
| 810 | TEGRA_INIT_DATA_TABLE(_name, _con_id, _dev_id, _parents, _offset,\ |
| 811 | 29, MASK(3), 0, 0, 8, 1, TEGRA_DIVIDER_INT, _regs,\ |
| 812 | _clk_num, periph_clk_enb_refcnt, _gate_flags, \ |
| 813 | _clk_id, _parents##_idx, 0) |
| 814 | |
| 815 | #define TEGRA_INIT_DATA_UART(_name, _con_id, _dev_id, _parents, _offset,\ |
| 816 | _clk_num, _regs, _clk_id) \ |
| 817 | TEGRA_INIT_DATA_TABLE(_name, _con_id, _dev_id, _parents, _offset,\ |
| 818 | 30, MASK(2), 0, 0, 16, 1, TEGRA_DIVIDER_UART, _regs,\ |
| 819 | _clk_num, periph_clk_enb_refcnt, 0, _clk_id, \ |
| 820 | _parents##_idx, 0) |
| 821 | |
| 822 | #define TEGRA_INIT_DATA_I2C(_name, _con_id, _dev_id, _parents, _offset,\ |
| 823 | _clk_num, _regs, _clk_id) \ |
| 824 | TEGRA_INIT_DATA_TABLE(_name, _con_id, _dev_id, _parents, _offset,\ |
| 825 | 30, MASK(2), 0, 0, 16, 0, 0, _regs, _clk_num, \ |
| 826 | periph_clk_enb_refcnt, 0, _clk_id, _parents##_idx, 0) |
| 827 | |
| 828 | #define TEGRA_INIT_DATA_NODIV(_name, _con_id, _dev_id, _parents, _offset, \ |
| 829 | _mux_shift, _mux_mask, _clk_num, _regs, \ |
| 830 | _gate_flags, _clk_id) \ |
| 831 | TEGRA_INIT_DATA_TABLE(_name, _con_id, _dev_id, _parents, _offset,\ |
| 832 | _mux_shift, _mux_mask, 0, 0, 0, 0, 0, _regs, \ |
| 833 | _clk_num, periph_clk_enb_refcnt, _gate_flags, \ |
| 834 | _clk_id, _parents##_idx, 0) |
| 835 | |
| 836 | #define TEGRA_INIT_DATA_XUSB(_name, _con_id, _dev_id, _parents, _offset, \ |
| 837 | _clk_num, _regs, _gate_flags, _clk_id) \ |
| 838 | TEGRA_INIT_DATA_TABLE(_name, _con_id, _dev_id, _parents, _offset, \ |
| 839 | 29, MASK(3), 0, 0, 8, 1, TEGRA_DIVIDER_INT, _regs, \ |
| 840 | _clk_num, periph_clk_enb_refcnt, _gate_flags, \ |
| 841 | _clk_id, _parents##_idx, 0) |
| 842 | |
| 843 | #define TEGRA_INIT_DATA_AUDIO(_name, _con_id, _dev_id, _offset, _clk_num,\ |
| 844 | _regs, _gate_flags, _clk_id) \ |
| 845 | TEGRA_INIT_DATA_TABLE(_name, _con_id, _dev_id, mux_d_audio_clk, \ |
| 846 | _offset, 16, 0xE01F, 0, 0, 8, 1, 0, _regs, _clk_num, \ |
| 847 | periph_clk_enb_refcnt, _gate_flags , _clk_id, \ |
| 848 | mux_d_audio_clk_idx, 0) |
| 849 | |
| 850 | enum tegra114_clk { |
| 851 | rtc = 4, timer = 5, uarta = 6, sdmmc2 = 9, i2s1 = 11, i2c1 = 12, |
| 852 | ndflash = 13, sdmmc1 = 14, sdmmc4 = 15, pwm = 17, i2s2 = 18, epp = 19, |
| 853 | gr_2d = 21, usbd = 22, isp = 23, gr_3d = 24, disp2 = 26, disp1 = 27, |
| 854 | host1x = 28, vcp = 29, i2s0 = 30, apbdma = 34, kbc = 36, kfuse = 40, |
| 855 | sbc1 = 41, nor = 42, sbc2 = 44, sbc3 = 46, i2c5 = 47, dsia = 48, |
| 856 | mipi = 50, hdmi = 51, csi = 52, i2c2 = 54, uartc = 55, mipi_cal = 56, |
| 857 | emc, usb2, usb3, vde = 61, bsea = 62, bsev = 63, uartd = 65, |
| 858 | i2c3 = 67, sbc4 = 68, sdmmc3 = 69, owr = 71, csite = 73, |
| 859 | la = 76, trace = 77, soc_therm = 78, dtv = 79, ndspeed = 80, |
| 860 | i2cslow = 81, dsib = 82, tsec = 83, xusb_host = 89, msenc = 91, |
| 861 | csus = 92, mselect = 99, tsensor = 100, i2s3 = 101, i2s4 = 102, |
| 862 | i2c4 = 103, sbc5 = 104, sbc6 = 105, d_audio, apbif = 107, dam0, dam1, |
| 863 | dam2, hda2codec_2x = 111, audio0_2x = 113, audio1_2x, audio2_2x, |
| 864 | audio3_2x, audio4_2x, spdif_2x, actmon = 119, extern1 = 120, |
| 865 | extern2 = 121, extern3 = 122, hda = 125, se = 127, hda2hdmi = 128, |
| 866 | cilab = 144, cilcd = 145, cile = 146, dsialp = 147, dsiblp = 148, |
| 867 | dds = 150, dp2 = 152, amx = 153, adx = 154, xusb_ss = 156, uartb = 192, |
| 868 | vfir, spdif_in, spdif_out, vi, vi_sensor, fuse, fuse_burn, clk_32k, |
| 869 | clk_m, clk_m_div2, clk_m_div4, pll_ref, pll_c, pll_c_out1, pll_c2, |
| 870 | pll_c3, pll_m, pll_m_out1, pll_p, pll_p_out1, pll_p_out2, pll_p_out3, |
| 871 | pll_p_out4, pll_a, pll_a_out0, pll_d, pll_d_out0, pll_d2, pll_d2_out0, |
| 872 | pll_u, pll_u_480M, pll_u_60M, pll_u_48M, pll_u_12M, pll_x, pll_x_out0, |
| 873 | pll_re_vco, pll_re_out, pll_e_out0, spdif_in_sync, i2s0_sync, |
| 874 | i2s1_sync, i2s2_sync, i2s3_sync, i2s4_sync, vimclk_sync, audio0, |
| 875 | audio1, audio2, audio3, audio4, spdif, clk_out_1, clk_out_2, clk_out_3, |
Stephen Warren | 964ea47 | 2013-04-04 17:13:54 -0600 | [diff] [blame] | 876 | blink, xusb_host_src = 252, xusb_falcon_src, xusb_fs_src, xusb_ss_src, |
Peter De Schrijver | 2cb5efe | 2013-04-03 17:40:45 +0300 | [diff] [blame] | 877 | xusb_dev_src, xusb_dev, xusb_hs_src, sclk, hclk, pclk, cclk_g, cclk_lp, |
| 878 | |
| 879 | /* Mux clocks */ |
| 880 | |
| 881 | audio0_mux = 300, audio1_mux, audio2_mux, audio3_mux, audio4_mux, |
| 882 | spdif_mux, clk_out_1_mux, clk_out_2_mux, clk_out_3_mux, dsia_mux, |
| 883 | dsib_mux, clk_max, |
| 884 | }; |
| 885 | |
| 886 | struct utmi_clk_param { |
| 887 | /* Oscillator Frequency in KHz */ |
| 888 | u32 osc_frequency; |
| 889 | /* UTMIP PLL Enable Delay Count */ |
| 890 | u8 enable_delay_count; |
| 891 | /* UTMIP PLL Stable count */ |
| 892 | u8 stable_count; |
| 893 | /* UTMIP PLL Active delay count */ |
| 894 | u8 active_delay_count; |
| 895 | /* UTMIP PLL Xtal frequency count */ |
| 896 | u8 xtal_freq_count; |
| 897 | }; |
| 898 | |
| 899 | static const struct utmi_clk_param utmi_parameters[] = { |
| 900 | {.osc_frequency = 13000000, .enable_delay_count = 0x02, |
| 901 | .stable_count = 0x33, .active_delay_count = 0x05, |
| 902 | .xtal_freq_count = 0x7F}, |
| 903 | {.osc_frequency = 19200000, .enable_delay_count = 0x03, |
| 904 | .stable_count = 0x4B, .active_delay_count = 0x06, |
| 905 | .xtal_freq_count = 0xBB}, |
| 906 | {.osc_frequency = 12000000, .enable_delay_count = 0x02, |
| 907 | .stable_count = 0x2F, .active_delay_count = 0x04, |
| 908 | .xtal_freq_count = 0x76}, |
| 909 | {.osc_frequency = 26000000, .enable_delay_count = 0x04, |
| 910 | .stable_count = 0x66, .active_delay_count = 0x09, |
| 911 | .xtal_freq_count = 0xFE}, |
| 912 | {.osc_frequency = 16800000, .enable_delay_count = 0x03, |
| 913 | .stable_count = 0x41, .active_delay_count = 0x0A, |
| 914 | .xtal_freq_count = 0xA4}, |
| 915 | }; |
| 916 | |
| 917 | /* peripheral mux definitions */ |
| 918 | |
| 919 | #define MUX_I2S_SPDIF(_id) \ |
| 920 | static const char *mux_pllaout0_##_id##_2x_pllp_clkm[] = { "pll_a_out0", \ |
| 921 | #_id, "pll_p",\ |
| 922 | "clk_m"}; |
| 923 | MUX_I2S_SPDIF(audio0) |
| 924 | MUX_I2S_SPDIF(audio1) |
| 925 | MUX_I2S_SPDIF(audio2) |
| 926 | MUX_I2S_SPDIF(audio3) |
| 927 | MUX_I2S_SPDIF(audio4) |
| 928 | MUX_I2S_SPDIF(audio) |
| 929 | |
| 930 | #define mux_pllaout0_audio0_2x_pllp_clkm_idx NULL |
| 931 | #define mux_pllaout0_audio1_2x_pllp_clkm_idx NULL |
| 932 | #define mux_pllaout0_audio2_2x_pllp_clkm_idx NULL |
| 933 | #define mux_pllaout0_audio3_2x_pllp_clkm_idx NULL |
| 934 | #define mux_pllaout0_audio4_2x_pllp_clkm_idx NULL |
| 935 | #define mux_pllaout0_audio_2x_pllp_clkm_idx NULL |
| 936 | |
| 937 | static const char *mux_pllp_pllc_pllm_clkm[] = { |
| 938 | "pll_p", "pll_c", "pll_m", "clk_m" |
| 939 | }; |
| 940 | #define mux_pllp_pllc_pllm_clkm_idx NULL |
| 941 | |
| 942 | static const char *mux_pllp_pllc_pllm[] = { "pll_p", "pll_c", "pll_m" }; |
| 943 | #define mux_pllp_pllc_pllm_idx NULL |
| 944 | |
| 945 | static const char *mux_pllp_pllc_clk32_clkm[] = { |
| 946 | "pll_p", "pll_c", "clk_32k", "clk_m" |
| 947 | }; |
| 948 | #define mux_pllp_pllc_clk32_clkm_idx NULL |
| 949 | |
| 950 | static const char *mux_plla_pllc_pllp_clkm[] = { |
| 951 | "pll_a_out0", "pll_c", "pll_p", "clk_m" |
| 952 | }; |
| 953 | #define mux_plla_pllc_pllp_clkm_idx mux_pllp_pllc_pllm_clkm_idx |
| 954 | |
| 955 | static const char *mux_pllp_pllc2_c_c3_pllm_clkm[] = { |
| 956 | "pll_p", "pll_c2", "pll_c", "pll_c3", "pll_m", "clk_m" |
| 957 | }; |
| 958 | static u32 mux_pllp_pllc2_c_c3_pllm_clkm_idx[] = { |
| 959 | [0] = 0, [1] = 1, [2] = 2, [3] = 3, [4] = 4, [5] = 6, |
| 960 | }; |
| 961 | |
| 962 | static const char *mux_pllp_clkm[] = { |
| 963 | "pll_p", "clk_m" |
| 964 | }; |
| 965 | static u32 mux_pllp_clkm_idx[] = { |
| 966 | [0] = 0, [1] = 3, |
| 967 | }; |
| 968 | |
| 969 | static const char *mux_pllm_pllc2_c_c3_pllp_plla[] = { |
| 970 | "pll_m", "pll_c2", "pll_c", "pll_c3", "pll_p", "pll_a_out0" |
| 971 | }; |
| 972 | #define mux_pllm_pllc2_c_c3_pllp_plla_idx mux_pllp_pllc2_c_c3_pllm_clkm_idx |
| 973 | |
| 974 | static const char *mux_pllp_pllm_plld_plla_pllc_plld2_clkm[] = { |
| 975 | "pll_p", "pll_m", "pll_d_out0", "pll_a_out0", "pll_c", |
| 976 | "pll_d2_out0", "clk_m" |
| 977 | }; |
| 978 | #define mux_pllp_pllm_plld_plla_pllc_plld2_clkm_idx NULL |
| 979 | |
| 980 | static const char *mux_pllm_pllc_pllp_plla[] = { |
| 981 | "pll_m", "pll_c", "pll_p", "pll_a_out0" |
| 982 | }; |
| 983 | #define mux_pllm_pllc_pllp_plla_idx mux_pllp_pllc_pllm_clkm_idx |
| 984 | |
| 985 | static const char *mux_pllp_pllc_clkm[] = { |
| 986 | "pll_p", "pll_c", "pll_m" |
| 987 | }; |
| 988 | static u32 mux_pllp_pllc_clkm_idx[] = { |
| 989 | [0] = 0, [1] = 1, [2] = 3, |
| 990 | }; |
| 991 | |
| 992 | static const char *mux_pllp_pllc_clkm_clk32[] = { |
| 993 | "pll_p", "pll_c", "clk_m", "clk_32k" |
| 994 | }; |
| 995 | #define mux_pllp_pllc_clkm_clk32_idx NULL |
| 996 | |
| 997 | static const char *mux_plla_clk32_pllp_clkm_plle[] = { |
| 998 | "pll_a_out0", "clk_32k", "pll_p", "clk_m", "pll_e_out0" |
| 999 | }; |
| 1000 | #define mux_plla_clk32_pllp_clkm_plle_idx NULL |
| 1001 | |
| 1002 | static const char *mux_clkm_pllp_pllc_pllre[] = { |
| 1003 | "clk_m", "pll_p", "pll_c", "pll_re_out" |
| 1004 | }; |
| 1005 | static u32 mux_clkm_pllp_pllc_pllre_idx[] = { |
| 1006 | [0] = 0, [1] = 1, [2] = 3, [3] = 5, |
| 1007 | }; |
| 1008 | |
| 1009 | static const char *mux_clkm_48M_pllp_480M[] = { |
| 1010 | "clk_m", "pll_u_48M", "pll_p", "pll_u_480M" |
| 1011 | }; |
| 1012 | #define mux_clkm_48M_pllp_480M_idx NULL |
| 1013 | |
| 1014 | static const char *mux_clkm_pllre_clk32_480M_pllc_ref[] = { |
| 1015 | "clk_m", "pll_re_out", "clk_32k", "pll_u_480M", "pll_c", "pll_ref" |
| 1016 | }; |
| 1017 | static u32 mux_clkm_pllre_clk32_480M_pllc_ref_idx[] = { |
| 1018 | [0] = 0, [1] = 1, [2] = 3, [3] = 3, [4] = 4, [5] = 7, |
| 1019 | }; |
| 1020 | |
| 1021 | static const char *mux_plld_out0_plld2_out0[] = { |
| 1022 | "pll_d_out0", "pll_d2_out0", |
| 1023 | }; |
| 1024 | #define mux_plld_out0_plld2_out0_idx NULL |
| 1025 | |
| 1026 | static const char *mux_d_audio_clk[] = { |
| 1027 | "pll_a_out0", "pll_p", "clk_m", "spdif_in_sync", "i2s0_sync", |
| 1028 | "i2s1_sync", "i2s2_sync", "i2s3_sync", "i2s4_sync", "vimclk_sync", |
| 1029 | }; |
| 1030 | static u32 mux_d_audio_clk_idx[] = { |
| 1031 | [0] = 0, [1] = 0x8000, [2] = 0xc000, [3] = 0xE000, [4] = 0xE001, |
| 1032 | [5] = 0xE002, [6] = 0xE003, [7] = 0xE004, [8] = 0xE005, [9] = 0xE007, |
| 1033 | }; |
| 1034 | |
| 1035 | static const char *mux_pllmcp_clkm[] = { |
| 1036 | "pll_m_out0", "pll_c_out0", "pll_p_out0", "clk_m", "pll_m_ud", |
| 1037 | }; |
| 1038 | |
| 1039 | static const struct clk_div_table pll_re_div_table[] = { |
| 1040 | { .val = 0, .div = 1 }, |
| 1041 | { .val = 1, .div = 2 }, |
| 1042 | { .val = 2, .div = 3 }, |
| 1043 | { .val = 3, .div = 4 }, |
| 1044 | { .val = 4, .div = 5 }, |
| 1045 | { .val = 5, .div = 6 }, |
| 1046 | { .val = 0, .div = 0 }, |
| 1047 | }; |
| 1048 | |
| 1049 | static struct clk *clks[clk_max]; |
| 1050 | static struct clk_onecell_data clk_data; |
| 1051 | |
| 1052 | static unsigned long osc_freq; |
| 1053 | static unsigned long pll_ref_freq; |
| 1054 | |
| 1055 | static int __init tegra114_osc_clk_init(void __iomem *clk_base) |
| 1056 | { |
| 1057 | struct clk *clk; |
| 1058 | u32 val, pll_ref_div; |
| 1059 | |
| 1060 | val = readl_relaxed(clk_base + OSC_CTRL); |
| 1061 | |
| 1062 | osc_freq = tegra114_input_freq[val >> OSC_CTRL_OSC_FREQ_SHIFT]; |
| 1063 | if (!osc_freq) { |
| 1064 | WARN_ON(1); |
| 1065 | return -EINVAL; |
| 1066 | } |
| 1067 | |
| 1068 | /* clk_m */ |
| 1069 | clk = clk_register_fixed_rate(NULL, "clk_m", NULL, CLK_IS_ROOT, |
| 1070 | osc_freq); |
| 1071 | clk_register_clkdev(clk, "clk_m", NULL); |
| 1072 | clks[clk_m] = clk; |
| 1073 | |
| 1074 | /* pll_ref */ |
| 1075 | val = (val >> OSC_CTRL_PLL_REF_DIV_SHIFT) & 3; |
| 1076 | pll_ref_div = 1 << val; |
| 1077 | clk = clk_register_fixed_factor(NULL, "pll_ref", "clk_m", |
| 1078 | CLK_SET_RATE_PARENT, 1, pll_ref_div); |
| 1079 | clk_register_clkdev(clk, "pll_ref", NULL); |
| 1080 | clks[pll_ref] = clk; |
| 1081 | |
| 1082 | pll_ref_freq = osc_freq / pll_ref_div; |
| 1083 | |
| 1084 | return 0; |
| 1085 | } |
| 1086 | |
| 1087 | static void __init tegra114_fixed_clk_init(void __iomem *clk_base) |
| 1088 | { |
| 1089 | struct clk *clk; |
| 1090 | |
| 1091 | /* clk_32k */ |
| 1092 | clk = clk_register_fixed_rate(NULL, "clk_32k", NULL, CLK_IS_ROOT, |
| 1093 | 32768); |
| 1094 | clk_register_clkdev(clk, "clk_32k", NULL); |
| 1095 | clks[clk_32k] = clk; |
| 1096 | |
| 1097 | /* clk_m_div2 */ |
| 1098 | clk = clk_register_fixed_factor(NULL, "clk_m_div2", "clk_m", |
| 1099 | CLK_SET_RATE_PARENT, 1, 2); |
| 1100 | clk_register_clkdev(clk, "clk_m_div2", NULL); |
| 1101 | clks[clk_m_div2] = clk; |
| 1102 | |
| 1103 | /* clk_m_div4 */ |
| 1104 | clk = clk_register_fixed_factor(NULL, "clk_m_div4", "clk_m", |
| 1105 | CLK_SET_RATE_PARENT, 1, 4); |
| 1106 | clk_register_clkdev(clk, "clk_m_div4", NULL); |
| 1107 | clks[clk_m_div4] = clk; |
| 1108 | |
| 1109 | } |
| 1110 | |
| 1111 | static __init void tegra114_utmi_param_configure(void __iomem *clk_base) |
| 1112 | { |
| 1113 | u32 reg; |
| 1114 | int i; |
| 1115 | |
| 1116 | for (i = 0; i < ARRAY_SIZE(utmi_parameters); i++) { |
| 1117 | if (osc_freq == utmi_parameters[i].osc_frequency) |
| 1118 | break; |
| 1119 | } |
| 1120 | |
| 1121 | if (i >= ARRAY_SIZE(utmi_parameters)) { |
| 1122 | pr_err("%s: Unexpected oscillator freq %lu\n", __func__, |
| 1123 | osc_freq); |
| 1124 | return; |
| 1125 | } |
| 1126 | |
| 1127 | reg = readl_relaxed(clk_base + UTMIP_PLL_CFG2); |
| 1128 | |
| 1129 | /* Program UTMIP PLL stable and active counts */ |
| 1130 | /* [FIXME] arclk_rst.h says WRONG! This should be 1ms -> 0x50 Check! */ |
| 1131 | reg &= ~UTMIP_PLL_CFG2_STABLE_COUNT(~0); |
| 1132 | reg |= UTMIP_PLL_CFG2_STABLE_COUNT(utmi_parameters[i].stable_count); |
| 1133 | |
| 1134 | reg &= ~UTMIP_PLL_CFG2_ACTIVE_DLY_COUNT(~0); |
| 1135 | |
| 1136 | reg |= UTMIP_PLL_CFG2_ACTIVE_DLY_COUNT(utmi_parameters[i]. |
| 1137 | active_delay_count); |
| 1138 | |
| 1139 | /* Remove power downs from UTMIP PLL control bits */ |
| 1140 | reg &= ~UTMIP_PLL_CFG2_FORCE_PD_SAMP_A_POWERDOWN; |
| 1141 | reg &= ~UTMIP_PLL_CFG2_FORCE_PD_SAMP_B_POWERDOWN; |
| 1142 | reg &= ~UTMIP_PLL_CFG2_FORCE_PD_SAMP_C_POWERDOWN; |
| 1143 | |
| 1144 | writel_relaxed(reg, clk_base + UTMIP_PLL_CFG2); |
| 1145 | |
| 1146 | /* Program UTMIP PLL delay and oscillator frequency counts */ |
| 1147 | reg = readl_relaxed(clk_base + UTMIP_PLL_CFG1); |
| 1148 | reg &= ~UTMIP_PLL_CFG1_ENABLE_DLY_COUNT(~0); |
| 1149 | |
| 1150 | reg |= UTMIP_PLL_CFG1_ENABLE_DLY_COUNT(utmi_parameters[i]. |
| 1151 | enable_delay_count); |
| 1152 | |
| 1153 | reg &= ~UTMIP_PLL_CFG1_XTAL_FREQ_COUNT(~0); |
| 1154 | reg |= UTMIP_PLL_CFG1_XTAL_FREQ_COUNT(utmi_parameters[i]. |
| 1155 | xtal_freq_count); |
| 1156 | |
| 1157 | /* Remove power downs from UTMIP PLL control bits */ |
| 1158 | reg &= ~UTMIP_PLL_CFG1_FORCE_PLL_ENABLE_POWERDOWN; |
| 1159 | reg &= ~UTMIP_PLL_CFG1_FORCE_PLL_ACTIVE_POWERDOWN; |
| 1160 | reg &= ~UTMIP_PLL_CFG1_FORCE_PLLU_POWERUP; |
| 1161 | reg &= ~UTMIP_PLL_CFG1_FORCE_PLLU_POWERDOWN; |
| 1162 | writel_relaxed(reg, clk_base + UTMIP_PLL_CFG1); |
| 1163 | |
| 1164 | /* Setup HW control of UTMIPLL */ |
| 1165 | reg = readl_relaxed(clk_base + UTMIPLL_HW_PWRDN_CFG0); |
| 1166 | reg |= UTMIPLL_HW_PWRDN_CFG0_USE_LOCKDET; |
| 1167 | reg &= ~UTMIPLL_HW_PWRDN_CFG0_CLK_ENABLE_SWCTL; |
| 1168 | reg |= UTMIPLL_HW_PWRDN_CFG0_SEQ_START_STATE; |
| 1169 | writel_relaxed(reg, clk_base + UTMIPLL_HW_PWRDN_CFG0); |
| 1170 | |
| 1171 | reg = readl_relaxed(clk_base + UTMIP_PLL_CFG1); |
| 1172 | reg &= ~UTMIP_PLL_CFG1_FORCE_PLL_ENABLE_POWERUP; |
| 1173 | reg &= ~UTMIP_PLL_CFG1_FORCE_PLL_ENABLE_POWERDOWN; |
| 1174 | writel_relaxed(reg, clk_base + UTMIP_PLL_CFG1); |
| 1175 | |
| 1176 | udelay(1); |
| 1177 | |
| 1178 | /* Setup SW override of UTMIPLL assuming USB2.0 |
| 1179 | ports are assigned to USB2 */ |
| 1180 | reg = readl_relaxed(clk_base + UTMIPLL_HW_PWRDN_CFG0); |
| 1181 | reg |= UTMIPLL_HW_PWRDN_CFG0_IDDQ_SWCTL; |
| 1182 | reg &= ~UTMIPLL_HW_PWRDN_CFG0_IDDQ_OVERRIDE; |
| 1183 | writel_relaxed(reg, clk_base + UTMIPLL_HW_PWRDN_CFG0); |
| 1184 | |
| 1185 | udelay(1); |
| 1186 | |
| 1187 | /* Enable HW control UTMIPLL */ |
| 1188 | reg = readl_relaxed(clk_base + UTMIPLL_HW_PWRDN_CFG0); |
| 1189 | reg |= UTMIPLL_HW_PWRDN_CFG0_SEQ_ENABLE; |
| 1190 | writel_relaxed(reg, clk_base + UTMIPLL_HW_PWRDN_CFG0); |
| 1191 | } |
| 1192 | |
| 1193 | static void __init _clip_vco_min(struct tegra_clk_pll_params *pll_params) |
| 1194 | { |
| 1195 | pll_params->vco_min = |
| 1196 | DIV_ROUND_UP(pll_params->vco_min, pll_ref_freq) * pll_ref_freq; |
| 1197 | } |
| 1198 | |
| 1199 | static int __init _setup_dynamic_ramp(struct tegra_clk_pll_params *pll_params, |
| 1200 | void __iomem *clk_base) |
| 1201 | { |
| 1202 | u32 val; |
| 1203 | u32 step_a, step_b; |
| 1204 | |
| 1205 | switch (pll_ref_freq) { |
| 1206 | case 12000000: |
| 1207 | case 13000000: |
| 1208 | case 26000000: |
| 1209 | step_a = 0x2B; |
| 1210 | step_b = 0x0B; |
| 1211 | break; |
| 1212 | case 16800000: |
| 1213 | step_a = 0x1A; |
| 1214 | step_b = 0x09; |
| 1215 | break; |
| 1216 | case 19200000: |
| 1217 | step_a = 0x12; |
| 1218 | step_b = 0x08; |
| 1219 | break; |
| 1220 | default: |
| 1221 | pr_err("%s: Unexpected reference rate %lu\n", |
| 1222 | __func__, pll_ref_freq); |
| 1223 | WARN_ON(1); |
| 1224 | return -EINVAL; |
| 1225 | } |
| 1226 | |
| 1227 | val = step_a << pll_params->stepa_shift; |
| 1228 | val |= step_b << pll_params->stepb_shift; |
| 1229 | writel_relaxed(val, clk_base + pll_params->dyn_ramp_reg); |
| 1230 | |
| 1231 | return 0; |
| 1232 | } |
| 1233 | |
| 1234 | static void __init _init_iddq(struct tegra_clk_pll_params *pll_params, |
| 1235 | void __iomem *clk_base) |
| 1236 | { |
| 1237 | u32 val, val_iddq; |
| 1238 | |
| 1239 | val = readl_relaxed(clk_base + pll_params->base_reg); |
| 1240 | val_iddq = readl_relaxed(clk_base + pll_params->iddq_reg); |
| 1241 | |
| 1242 | if (val & BIT(30)) |
| 1243 | WARN_ON(val_iddq & BIT(pll_params->iddq_bit_idx)); |
| 1244 | else { |
| 1245 | val_iddq |= BIT(pll_params->iddq_bit_idx); |
| 1246 | writel_relaxed(val_iddq, clk_base + pll_params->iddq_reg); |
| 1247 | } |
| 1248 | } |
| 1249 | |
| 1250 | static void __init tegra114_pll_init(void __iomem *clk_base, |
| 1251 | void __iomem *pmc) |
| 1252 | { |
| 1253 | u32 val; |
| 1254 | struct clk *clk; |
| 1255 | |
| 1256 | /* PLLC */ |
| 1257 | _clip_vco_min(&pll_c_params); |
| 1258 | if (_setup_dynamic_ramp(&pll_c_params, clk_base) >= 0) { |
| 1259 | _init_iddq(&pll_c_params, clk_base); |
| 1260 | clk = tegra_clk_register_pllxc("pll_c", "pll_ref", clk_base, |
| 1261 | pmc, 0, 0, &pll_c_params, TEGRA_PLL_USE_LOCK, |
| 1262 | pll_c_freq_table, NULL); |
| 1263 | clk_register_clkdev(clk, "pll_c", NULL); |
| 1264 | clks[pll_c] = clk; |
| 1265 | |
| 1266 | /* PLLC_OUT1 */ |
| 1267 | clk = tegra_clk_register_divider("pll_c_out1_div", "pll_c", |
| 1268 | clk_base + PLLC_OUT, 0, TEGRA_DIVIDER_ROUND_UP, |
| 1269 | 8, 8, 1, NULL); |
| 1270 | clk = tegra_clk_register_pll_out("pll_c_out1", "pll_c_out1_div", |
| 1271 | clk_base + PLLC_OUT, 1, 0, |
| 1272 | CLK_SET_RATE_PARENT, 0, NULL); |
| 1273 | clk_register_clkdev(clk, "pll_c_out1", NULL); |
| 1274 | clks[pll_c_out1] = clk; |
| 1275 | } |
| 1276 | |
| 1277 | /* PLLC2 */ |
| 1278 | _clip_vco_min(&pll_c2_params); |
| 1279 | clk = tegra_clk_register_pllc("pll_c2", "pll_ref", clk_base, pmc, 0, 0, |
| 1280 | &pll_c2_params, TEGRA_PLL_USE_LOCK, |
| 1281 | pll_cx_freq_table, NULL); |
| 1282 | clk_register_clkdev(clk, "pll_c2", NULL); |
| 1283 | clks[pll_c2] = clk; |
| 1284 | |
| 1285 | /* PLLC3 */ |
| 1286 | _clip_vco_min(&pll_c3_params); |
| 1287 | clk = tegra_clk_register_pllc("pll_c3", "pll_ref", clk_base, pmc, 0, 0, |
| 1288 | &pll_c3_params, TEGRA_PLL_USE_LOCK, |
| 1289 | pll_cx_freq_table, NULL); |
| 1290 | clk_register_clkdev(clk, "pll_c3", NULL); |
| 1291 | clks[pll_c3] = clk; |
| 1292 | |
| 1293 | /* PLLP */ |
| 1294 | clk = tegra_clk_register_pll("pll_p", "pll_ref", clk_base, pmc, 0, |
| 1295 | 408000000, &pll_p_params, |
| 1296 | TEGRA_PLL_FIXED | TEGRA_PLL_USE_LOCK, |
| 1297 | pll_p_freq_table, NULL); |
| 1298 | clk_register_clkdev(clk, "pll_p", NULL); |
| 1299 | clks[pll_p] = clk; |
| 1300 | |
| 1301 | /* PLLP_OUT1 */ |
| 1302 | clk = tegra_clk_register_divider("pll_p_out1_div", "pll_p", |
| 1303 | clk_base + PLLP_OUTA, 0, TEGRA_DIVIDER_FIXED | |
| 1304 | TEGRA_DIVIDER_ROUND_UP, 8, 8, 1, &pll_div_lock); |
| 1305 | clk = tegra_clk_register_pll_out("pll_p_out1", "pll_p_out1_div", |
| 1306 | clk_base + PLLP_OUTA, 1, 0, |
| 1307 | CLK_IGNORE_UNUSED | CLK_SET_RATE_PARENT, 0, |
| 1308 | &pll_div_lock); |
| 1309 | clk_register_clkdev(clk, "pll_p_out1", NULL); |
| 1310 | clks[pll_p_out1] = clk; |
| 1311 | |
| 1312 | /* PLLP_OUT2 */ |
| 1313 | clk = tegra_clk_register_divider("pll_p_out2_div", "pll_p", |
| 1314 | clk_base + PLLP_OUTA, 0, TEGRA_DIVIDER_FIXED | |
Peter De Schrijver | c388eee | 2013-06-05 16:37:17 +0300 | [diff] [blame] | 1315 | TEGRA_DIVIDER_ROUND_UP | TEGRA_DIVIDER_INT, 24, |
| 1316 | 8, 1, &pll_div_lock); |
Peter De Schrijver | 2cb5efe | 2013-04-03 17:40:45 +0300 | [diff] [blame] | 1317 | clk = tegra_clk_register_pll_out("pll_p_out2", "pll_p_out2_div", |
| 1318 | clk_base + PLLP_OUTA, 17, 16, |
| 1319 | CLK_IGNORE_UNUSED | CLK_SET_RATE_PARENT, 0, |
| 1320 | &pll_div_lock); |
| 1321 | clk_register_clkdev(clk, "pll_p_out2", NULL); |
| 1322 | clks[pll_p_out2] = clk; |
| 1323 | |
| 1324 | /* PLLP_OUT3 */ |
| 1325 | clk = tegra_clk_register_divider("pll_p_out3_div", "pll_p", |
| 1326 | clk_base + PLLP_OUTB, 0, TEGRA_DIVIDER_FIXED | |
| 1327 | TEGRA_DIVIDER_ROUND_UP, 8, 8, 1, &pll_div_lock); |
| 1328 | clk = tegra_clk_register_pll_out("pll_p_out3", "pll_p_out3_div", |
| 1329 | clk_base + PLLP_OUTB, 1, 0, |
| 1330 | CLK_IGNORE_UNUSED | CLK_SET_RATE_PARENT, 0, |
| 1331 | &pll_div_lock); |
| 1332 | clk_register_clkdev(clk, "pll_p_out3", NULL); |
| 1333 | clks[pll_p_out3] = clk; |
| 1334 | |
| 1335 | /* PLLP_OUT4 */ |
| 1336 | clk = tegra_clk_register_divider("pll_p_out4_div", "pll_p", |
| 1337 | clk_base + PLLP_OUTB, 0, TEGRA_DIVIDER_FIXED | |
| 1338 | TEGRA_DIVIDER_ROUND_UP, 24, 8, 1, |
| 1339 | &pll_div_lock); |
| 1340 | clk = tegra_clk_register_pll_out("pll_p_out4", "pll_p_out4_div", |
| 1341 | clk_base + PLLP_OUTB, 17, 16, |
| 1342 | CLK_IGNORE_UNUSED | CLK_SET_RATE_PARENT, 0, |
| 1343 | &pll_div_lock); |
| 1344 | clk_register_clkdev(clk, "pll_p_out4", NULL); |
| 1345 | clks[pll_p_out4] = clk; |
| 1346 | |
| 1347 | /* PLLM */ |
| 1348 | _clip_vco_min(&pll_m_params); |
| 1349 | clk = tegra_clk_register_pllm("pll_m", "pll_ref", clk_base, pmc, |
| 1350 | CLK_IGNORE_UNUSED | CLK_SET_RATE_GATE, 0, |
| 1351 | &pll_m_params, TEGRA_PLL_USE_LOCK, |
| 1352 | pll_m_freq_table, NULL); |
| 1353 | clk_register_clkdev(clk, "pll_m", NULL); |
| 1354 | clks[pll_m] = clk; |
| 1355 | |
| 1356 | /* PLLM_OUT1 */ |
| 1357 | clk = tegra_clk_register_divider("pll_m_out1_div", "pll_m", |
| 1358 | clk_base + PLLM_OUT, 0, TEGRA_DIVIDER_ROUND_UP, |
| 1359 | 8, 8, 1, NULL); |
| 1360 | clk = tegra_clk_register_pll_out("pll_m_out1", "pll_m_out1_div", |
| 1361 | clk_base + PLLM_OUT, 1, 0, CLK_IGNORE_UNUSED | |
| 1362 | CLK_SET_RATE_PARENT, 0, NULL); |
| 1363 | clk_register_clkdev(clk, "pll_m_out1", NULL); |
| 1364 | clks[pll_m_out1] = clk; |
| 1365 | |
| 1366 | /* PLLM_UD */ |
| 1367 | clk = clk_register_fixed_factor(NULL, "pll_m_ud", "pll_m", |
| 1368 | CLK_SET_RATE_PARENT, 1, 1); |
| 1369 | |
| 1370 | /* PLLX */ |
| 1371 | _clip_vco_min(&pll_x_params); |
| 1372 | if (_setup_dynamic_ramp(&pll_x_params, clk_base) >= 0) { |
| 1373 | _init_iddq(&pll_x_params, clk_base); |
| 1374 | clk = tegra_clk_register_pllxc("pll_x", "pll_ref", clk_base, |
| 1375 | pmc, CLK_IGNORE_UNUSED, 0, &pll_x_params, |
| 1376 | TEGRA_PLL_USE_LOCK, pll_x_freq_table, NULL); |
| 1377 | clk_register_clkdev(clk, "pll_x", NULL); |
| 1378 | clks[pll_x] = clk; |
| 1379 | } |
| 1380 | |
| 1381 | /* PLLX_OUT0 */ |
| 1382 | clk = clk_register_fixed_factor(NULL, "pll_x_out0", "pll_x", |
| 1383 | CLK_SET_RATE_PARENT, 1, 2); |
| 1384 | clk_register_clkdev(clk, "pll_x_out0", NULL); |
| 1385 | clks[pll_x_out0] = clk; |
| 1386 | |
| 1387 | /* PLLU */ |
| 1388 | val = readl(clk_base + pll_u_params.base_reg); |
| 1389 | val &= ~BIT(24); /* disable PLLU_OVERRIDE */ |
| 1390 | writel(val, clk_base + pll_u_params.base_reg); |
| 1391 | |
| 1392 | clk = tegra_clk_register_pll("pll_u", "pll_ref", clk_base, pmc, 0, |
| 1393 | 0, &pll_u_params, TEGRA_PLLU | |
| 1394 | TEGRA_PLL_HAS_CPCON | TEGRA_PLL_SET_LFCON | |
| 1395 | TEGRA_PLL_USE_LOCK, pll_u_freq_table, &pll_u_lock); |
| 1396 | clk_register_clkdev(clk, "pll_u", NULL); |
| 1397 | clks[pll_u] = clk; |
| 1398 | |
| 1399 | tegra114_utmi_param_configure(clk_base); |
| 1400 | |
| 1401 | /* PLLU_480M */ |
| 1402 | clk = clk_register_gate(NULL, "pll_u_480M", "pll_u", |
| 1403 | CLK_SET_RATE_PARENT, clk_base + PLLU_BASE, |
| 1404 | 22, 0, &pll_u_lock); |
| 1405 | clk_register_clkdev(clk, "pll_u_480M", NULL); |
| 1406 | clks[pll_u_480M] = clk; |
| 1407 | |
| 1408 | /* PLLU_60M */ |
| 1409 | clk = clk_register_fixed_factor(NULL, "pll_u_60M", "pll_u", |
| 1410 | CLK_SET_RATE_PARENT, 1, 8); |
| 1411 | clk_register_clkdev(clk, "pll_u_60M", NULL); |
| 1412 | clks[pll_u_60M] = clk; |
| 1413 | |
| 1414 | /* PLLU_48M */ |
| 1415 | clk = clk_register_fixed_factor(NULL, "pll_u_48M", "pll_u", |
| 1416 | CLK_SET_RATE_PARENT, 1, 10); |
| 1417 | clk_register_clkdev(clk, "pll_u_48M", NULL); |
| 1418 | clks[pll_u_48M] = clk; |
| 1419 | |
| 1420 | /* PLLU_12M */ |
| 1421 | clk = clk_register_fixed_factor(NULL, "pll_u_12M", "pll_u", |
| 1422 | CLK_SET_RATE_PARENT, 1, 40); |
| 1423 | clk_register_clkdev(clk, "pll_u_12M", NULL); |
| 1424 | clks[pll_u_12M] = clk; |
| 1425 | |
| 1426 | /* PLLD */ |
| 1427 | clk = tegra_clk_register_pll("pll_d", "pll_ref", clk_base, pmc, 0, |
| 1428 | 0, &pll_d_params, |
| 1429 | TEGRA_PLL_HAS_CPCON | TEGRA_PLL_SET_LFCON | |
| 1430 | TEGRA_PLL_USE_LOCK, pll_d_freq_table, &pll_d_lock); |
| 1431 | clk_register_clkdev(clk, "pll_d", NULL); |
| 1432 | clks[pll_d] = clk; |
| 1433 | |
| 1434 | /* PLLD_OUT0 */ |
| 1435 | clk = clk_register_fixed_factor(NULL, "pll_d_out0", "pll_d", |
| 1436 | CLK_SET_RATE_PARENT, 1, 2); |
| 1437 | clk_register_clkdev(clk, "pll_d_out0", NULL); |
| 1438 | clks[pll_d_out0] = clk; |
| 1439 | |
| 1440 | /* PLLD2 */ |
| 1441 | clk = tegra_clk_register_pll("pll_d2", "pll_ref", clk_base, pmc, 0, |
| 1442 | 0, &pll_d2_params, |
| 1443 | TEGRA_PLL_HAS_CPCON | TEGRA_PLL_SET_LFCON | |
| 1444 | TEGRA_PLL_USE_LOCK, pll_d_freq_table, &pll_d2_lock); |
| 1445 | clk_register_clkdev(clk, "pll_d2", NULL); |
| 1446 | clks[pll_d2] = clk; |
| 1447 | |
| 1448 | /* PLLD2_OUT0 */ |
| 1449 | clk = clk_register_fixed_factor(NULL, "pll_d2_out0", "pll_d2", |
| 1450 | CLK_SET_RATE_PARENT, 1, 2); |
| 1451 | clk_register_clkdev(clk, "pll_d2_out0", NULL); |
| 1452 | clks[pll_d2_out0] = clk; |
| 1453 | |
| 1454 | /* PLLA */ |
| 1455 | clk = tegra_clk_register_pll("pll_a", "pll_p_out1", clk_base, pmc, 0, |
| 1456 | 0, &pll_a_params, TEGRA_PLL_HAS_CPCON | |
| 1457 | TEGRA_PLL_USE_LOCK, pll_a_freq_table, NULL); |
| 1458 | clk_register_clkdev(clk, "pll_a", NULL); |
| 1459 | clks[pll_a] = clk; |
| 1460 | |
| 1461 | /* PLLA_OUT0 */ |
| 1462 | clk = tegra_clk_register_divider("pll_a_out0_div", "pll_a", |
| 1463 | clk_base + PLLA_OUT, 0, TEGRA_DIVIDER_ROUND_UP, |
| 1464 | 8, 8, 1, NULL); |
| 1465 | clk = tegra_clk_register_pll_out("pll_a_out0", "pll_a_out0_div", |
| 1466 | clk_base + PLLA_OUT, 1, 0, CLK_IGNORE_UNUSED | |
| 1467 | CLK_SET_RATE_PARENT, 0, NULL); |
| 1468 | clk_register_clkdev(clk, "pll_a_out0", NULL); |
| 1469 | clks[pll_a_out0] = clk; |
| 1470 | |
| 1471 | /* PLLRE */ |
| 1472 | _clip_vco_min(&pll_re_vco_params); |
| 1473 | clk = tegra_clk_register_pllre("pll_re_vco", "pll_ref", clk_base, pmc, |
| 1474 | 0, 0, &pll_re_vco_params, TEGRA_PLL_USE_LOCK, |
| 1475 | NULL, &pll_re_lock, pll_ref_freq); |
| 1476 | clk_register_clkdev(clk, "pll_re_vco", NULL); |
| 1477 | clks[pll_re_vco] = clk; |
| 1478 | |
| 1479 | clk = clk_register_divider_table(NULL, "pll_re_out", "pll_re_vco", 0, |
| 1480 | clk_base + PLLRE_BASE, 16, 4, 0, |
| 1481 | pll_re_div_table, &pll_re_lock); |
| 1482 | clk_register_clkdev(clk, "pll_re_out", NULL); |
| 1483 | clks[pll_re_out] = clk; |
| 1484 | |
| 1485 | /* PLLE */ |
| 1486 | clk = tegra_clk_register_plle_tegra114("pll_e_out0", "pll_re_vco", |
| 1487 | clk_base, 0, 100000000, &pll_e_params, |
| 1488 | pll_e_freq_table, NULL); |
| 1489 | clk_register_clkdev(clk, "pll_e_out0", NULL); |
| 1490 | clks[pll_e_out0] = clk; |
| 1491 | } |
| 1492 | |
| 1493 | static const char *mux_audio_sync_clk[] = { "spdif_in_sync", "i2s0_sync", |
| 1494 | "i2s1_sync", "i2s2_sync", "i2s3_sync", "i2s4_sync", "vimclk_sync", |
| 1495 | }; |
| 1496 | |
| 1497 | static const char *clk_out1_parents[] = { "clk_m", "clk_m_div2", |
| 1498 | "clk_m_div4", "extern1", |
| 1499 | }; |
| 1500 | |
| 1501 | static const char *clk_out2_parents[] = { "clk_m", "clk_m_div2", |
| 1502 | "clk_m_div4", "extern2", |
| 1503 | }; |
| 1504 | |
| 1505 | static const char *clk_out3_parents[] = { "clk_m", "clk_m_div2", |
| 1506 | "clk_m_div4", "extern3", |
| 1507 | }; |
| 1508 | |
| 1509 | static void __init tegra114_audio_clk_init(void __iomem *clk_base) |
| 1510 | { |
| 1511 | struct clk *clk; |
| 1512 | |
| 1513 | /* spdif_in_sync */ |
| 1514 | clk = tegra_clk_register_sync_source("spdif_in_sync", 24000000, |
| 1515 | 24000000); |
| 1516 | clk_register_clkdev(clk, "spdif_in_sync", NULL); |
| 1517 | clks[spdif_in_sync] = clk; |
| 1518 | |
| 1519 | /* i2s0_sync */ |
| 1520 | clk = tegra_clk_register_sync_source("i2s0_sync", 24000000, 24000000); |
| 1521 | clk_register_clkdev(clk, "i2s0_sync", NULL); |
| 1522 | clks[i2s0_sync] = clk; |
| 1523 | |
| 1524 | /* i2s1_sync */ |
| 1525 | clk = tegra_clk_register_sync_source("i2s1_sync", 24000000, 24000000); |
| 1526 | clk_register_clkdev(clk, "i2s1_sync", NULL); |
| 1527 | clks[i2s1_sync] = clk; |
| 1528 | |
| 1529 | /* i2s2_sync */ |
| 1530 | clk = tegra_clk_register_sync_source("i2s2_sync", 24000000, 24000000); |
| 1531 | clk_register_clkdev(clk, "i2s2_sync", NULL); |
| 1532 | clks[i2s2_sync] = clk; |
| 1533 | |
| 1534 | /* i2s3_sync */ |
| 1535 | clk = tegra_clk_register_sync_source("i2s3_sync", 24000000, 24000000); |
| 1536 | clk_register_clkdev(clk, "i2s3_sync", NULL); |
| 1537 | clks[i2s3_sync] = clk; |
| 1538 | |
| 1539 | /* i2s4_sync */ |
| 1540 | clk = tegra_clk_register_sync_source("i2s4_sync", 24000000, 24000000); |
| 1541 | clk_register_clkdev(clk, "i2s4_sync", NULL); |
| 1542 | clks[i2s4_sync] = clk; |
| 1543 | |
| 1544 | /* vimclk_sync */ |
| 1545 | clk = tegra_clk_register_sync_source("vimclk_sync", 24000000, 24000000); |
| 1546 | clk_register_clkdev(clk, "vimclk_sync", NULL); |
| 1547 | clks[vimclk_sync] = clk; |
| 1548 | |
| 1549 | /* audio0 */ |
| 1550 | clk = clk_register_mux(NULL, "audio0_mux", mux_audio_sync_clk, |
| 1551 | ARRAY_SIZE(mux_audio_sync_clk), 0, |
| 1552 | clk_base + AUDIO_SYNC_CLK_I2S0, 0, 3, 0, |
| 1553 | NULL); |
| 1554 | clks[audio0_mux] = clk; |
| 1555 | clk = clk_register_gate(NULL, "audio0", "audio0_mux", 0, |
| 1556 | clk_base + AUDIO_SYNC_CLK_I2S0, 4, |
| 1557 | CLK_GATE_SET_TO_DISABLE, NULL); |
| 1558 | clk_register_clkdev(clk, "audio0", NULL); |
| 1559 | clks[audio0] = clk; |
| 1560 | |
| 1561 | /* audio1 */ |
| 1562 | clk = clk_register_mux(NULL, "audio1_mux", mux_audio_sync_clk, |
| 1563 | ARRAY_SIZE(mux_audio_sync_clk), 0, |
| 1564 | clk_base + AUDIO_SYNC_CLK_I2S1, 0, 3, 0, |
| 1565 | NULL); |
| 1566 | clks[audio1_mux] = clk; |
| 1567 | clk = clk_register_gate(NULL, "audio1", "audio1_mux", 0, |
| 1568 | clk_base + AUDIO_SYNC_CLK_I2S1, 4, |
| 1569 | CLK_GATE_SET_TO_DISABLE, NULL); |
| 1570 | clk_register_clkdev(clk, "audio1", NULL); |
| 1571 | clks[audio1] = clk; |
| 1572 | |
| 1573 | /* audio2 */ |
| 1574 | clk = clk_register_mux(NULL, "audio2_mux", mux_audio_sync_clk, |
| 1575 | ARRAY_SIZE(mux_audio_sync_clk), 0, |
| 1576 | clk_base + AUDIO_SYNC_CLK_I2S2, 0, 3, 0, |
| 1577 | NULL); |
| 1578 | clks[audio2_mux] = clk; |
| 1579 | clk = clk_register_gate(NULL, "audio2", "audio2_mux", 0, |
| 1580 | clk_base + AUDIO_SYNC_CLK_I2S2, 4, |
| 1581 | CLK_GATE_SET_TO_DISABLE, NULL); |
| 1582 | clk_register_clkdev(clk, "audio2", NULL); |
| 1583 | clks[audio2] = clk; |
| 1584 | |
| 1585 | /* audio3 */ |
| 1586 | clk = clk_register_mux(NULL, "audio3_mux", mux_audio_sync_clk, |
| 1587 | ARRAY_SIZE(mux_audio_sync_clk), 0, |
| 1588 | clk_base + AUDIO_SYNC_CLK_I2S3, 0, 3, 0, |
| 1589 | NULL); |
| 1590 | clks[audio3_mux] = clk; |
| 1591 | clk = clk_register_gate(NULL, "audio3", "audio3_mux", 0, |
| 1592 | clk_base + AUDIO_SYNC_CLK_I2S3, 4, |
| 1593 | CLK_GATE_SET_TO_DISABLE, NULL); |
| 1594 | clk_register_clkdev(clk, "audio3", NULL); |
| 1595 | clks[audio3] = clk; |
| 1596 | |
| 1597 | /* audio4 */ |
| 1598 | clk = clk_register_mux(NULL, "audio4_mux", mux_audio_sync_clk, |
| 1599 | ARRAY_SIZE(mux_audio_sync_clk), 0, |
| 1600 | clk_base + AUDIO_SYNC_CLK_I2S4, 0, 3, 0, |
| 1601 | NULL); |
| 1602 | clks[audio4_mux] = clk; |
| 1603 | clk = clk_register_gate(NULL, "audio4", "audio4_mux", 0, |
| 1604 | clk_base + AUDIO_SYNC_CLK_I2S4, 4, |
| 1605 | CLK_GATE_SET_TO_DISABLE, NULL); |
| 1606 | clk_register_clkdev(clk, "audio4", NULL); |
| 1607 | clks[audio4] = clk; |
| 1608 | |
| 1609 | /* spdif */ |
| 1610 | clk = clk_register_mux(NULL, "spdif_mux", mux_audio_sync_clk, |
| 1611 | ARRAY_SIZE(mux_audio_sync_clk), 0, |
| 1612 | clk_base + AUDIO_SYNC_CLK_SPDIF, 0, 3, 0, |
| 1613 | NULL); |
| 1614 | clks[spdif_mux] = clk; |
| 1615 | clk = clk_register_gate(NULL, "spdif", "spdif_mux", 0, |
| 1616 | clk_base + AUDIO_SYNC_CLK_SPDIF, 4, |
| 1617 | CLK_GATE_SET_TO_DISABLE, NULL); |
| 1618 | clk_register_clkdev(clk, "spdif", NULL); |
| 1619 | clks[spdif] = clk; |
| 1620 | |
| 1621 | /* audio0_2x */ |
| 1622 | clk = clk_register_fixed_factor(NULL, "audio0_doubler", "audio0", |
| 1623 | CLK_SET_RATE_PARENT, 2, 1); |
| 1624 | clk = tegra_clk_register_divider("audio0_div", "audio0_doubler", |
| 1625 | clk_base + AUDIO_SYNC_DOUBLER, 0, 0, 24, 1, |
| 1626 | 0, &clk_doubler_lock); |
| 1627 | clk = tegra_clk_register_periph_gate("audio0_2x", "audio0_div", |
| 1628 | TEGRA_PERIPH_NO_RESET, clk_base, |
| 1629 | CLK_SET_RATE_PARENT, 113, &periph_v_regs, |
| 1630 | periph_clk_enb_refcnt); |
| 1631 | clk_register_clkdev(clk, "audio0_2x", NULL); |
| 1632 | clks[audio0_2x] = clk; |
| 1633 | |
| 1634 | /* audio1_2x */ |
| 1635 | clk = clk_register_fixed_factor(NULL, "audio1_doubler", "audio1", |
| 1636 | CLK_SET_RATE_PARENT, 2, 1); |
| 1637 | clk = tegra_clk_register_divider("audio1_div", "audio1_doubler", |
| 1638 | clk_base + AUDIO_SYNC_DOUBLER, 0, 0, 25, 1, |
| 1639 | 0, &clk_doubler_lock); |
| 1640 | clk = tegra_clk_register_periph_gate("audio1_2x", "audio1_div", |
| 1641 | TEGRA_PERIPH_NO_RESET, clk_base, |
| 1642 | CLK_SET_RATE_PARENT, 114, &periph_v_regs, |
| 1643 | periph_clk_enb_refcnt); |
| 1644 | clk_register_clkdev(clk, "audio1_2x", NULL); |
| 1645 | clks[audio1_2x] = clk; |
| 1646 | |
| 1647 | /* audio2_2x */ |
| 1648 | clk = clk_register_fixed_factor(NULL, "audio2_doubler", "audio2", |
| 1649 | CLK_SET_RATE_PARENT, 2, 1); |
| 1650 | clk = tegra_clk_register_divider("audio2_div", "audio2_doubler", |
| 1651 | clk_base + AUDIO_SYNC_DOUBLER, 0, 0, 26, 1, |
| 1652 | 0, &clk_doubler_lock); |
| 1653 | clk = tegra_clk_register_periph_gate("audio2_2x", "audio2_div", |
| 1654 | TEGRA_PERIPH_NO_RESET, clk_base, |
| 1655 | CLK_SET_RATE_PARENT, 115, &periph_v_regs, |
| 1656 | periph_clk_enb_refcnt); |
| 1657 | clk_register_clkdev(clk, "audio2_2x", NULL); |
| 1658 | clks[audio2_2x] = clk; |
| 1659 | |
| 1660 | /* audio3_2x */ |
| 1661 | clk = clk_register_fixed_factor(NULL, "audio3_doubler", "audio3", |
| 1662 | CLK_SET_RATE_PARENT, 2, 1); |
| 1663 | clk = tegra_clk_register_divider("audio3_div", "audio3_doubler", |
| 1664 | clk_base + AUDIO_SYNC_DOUBLER, 0, 0, 27, 1, |
| 1665 | 0, &clk_doubler_lock); |
| 1666 | clk = tegra_clk_register_periph_gate("audio3_2x", "audio3_div", |
| 1667 | TEGRA_PERIPH_NO_RESET, clk_base, |
| 1668 | CLK_SET_RATE_PARENT, 116, &periph_v_regs, |
| 1669 | periph_clk_enb_refcnt); |
| 1670 | clk_register_clkdev(clk, "audio3_2x", NULL); |
| 1671 | clks[audio3_2x] = clk; |
| 1672 | |
| 1673 | /* audio4_2x */ |
| 1674 | clk = clk_register_fixed_factor(NULL, "audio4_doubler", "audio4", |
| 1675 | CLK_SET_RATE_PARENT, 2, 1); |
| 1676 | clk = tegra_clk_register_divider("audio4_div", "audio4_doubler", |
| 1677 | clk_base + AUDIO_SYNC_DOUBLER, 0, 0, 28, 1, |
| 1678 | 0, &clk_doubler_lock); |
| 1679 | clk = tegra_clk_register_periph_gate("audio4_2x", "audio4_div", |
| 1680 | TEGRA_PERIPH_NO_RESET, clk_base, |
| 1681 | CLK_SET_RATE_PARENT, 117, &periph_v_regs, |
| 1682 | periph_clk_enb_refcnt); |
| 1683 | clk_register_clkdev(clk, "audio4_2x", NULL); |
| 1684 | clks[audio4_2x] = clk; |
| 1685 | |
| 1686 | /* spdif_2x */ |
| 1687 | clk = clk_register_fixed_factor(NULL, "spdif_doubler", "spdif", |
| 1688 | CLK_SET_RATE_PARENT, 2, 1); |
| 1689 | clk = tegra_clk_register_divider("spdif_div", "spdif_doubler", |
| 1690 | clk_base + AUDIO_SYNC_DOUBLER, 0, 0, 29, 1, |
| 1691 | 0, &clk_doubler_lock); |
| 1692 | clk = tegra_clk_register_periph_gate("spdif_2x", "spdif_div", |
| 1693 | TEGRA_PERIPH_NO_RESET, clk_base, |
| 1694 | CLK_SET_RATE_PARENT, 118, |
| 1695 | &periph_v_regs, periph_clk_enb_refcnt); |
| 1696 | clk_register_clkdev(clk, "spdif_2x", NULL); |
| 1697 | clks[spdif_2x] = clk; |
| 1698 | } |
| 1699 | |
| 1700 | static void __init tegra114_pmc_clk_init(void __iomem *pmc_base) |
| 1701 | { |
| 1702 | struct clk *clk; |
| 1703 | |
| 1704 | /* clk_out_1 */ |
| 1705 | clk = clk_register_mux(NULL, "clk_out_1_mux", clk_out1_parents, |
| 1706 | ARRAY_SIZE(clk_out1_parents), 0, |
| 1707 | pmc_base + PMC_CLK_OUT_CNTRL, 6, 3, 0, |
| 1708 | &clk_out_lock); |
| 1709 | clks[clk_out_1_mux] = clk; |
| 1710 | clk = clk_register_gate(NULL, "clk_out_1", "clk_out_1_mux", 0, |
| 1711 | pmc_base + PMC_CLK_OUT_CNTRL, 2, 0, |
| 1712 | &clk_out_lock); |
| 1713 | clk_register_clkdev(clk, "extern1", "clk_out_1"); |
| 1714 | clks[clk_out_1] = clk; |
| 1715 | |
| 1716 | /* clk_out_2 */ |
| 1717 | clk = clk_register_mux(NULL, "clk_out_2_mux", clk_out2_parents, |
Prashant Gaikwad | 995968e | 2013-05-27 13:24:39 +0530 | [diff] [blame] | 1718 | ARRAY_SIZE(clk_out2_parents), 0, |
Peter De Schrijver | 2cb5efe | 2013-04-03 17:40:45 +0300 | [diff] [blame] | 1719 | pmc_base + PMC_CLK_OUT_CNTRL, 14, 3, 0, |
| 1720 | &clk_out_lock); |
| 1721 | clks[clk_out_2_mux] = clk; |
| 1722 | clk = clk_register_gate(NULL, "clk_out_2", "clk_out_2_mux", 0, |
| 1723 | pmc_base + PMC_CLK_OUT_CNTRL, 10, 0, |
| 1724 | &clk_out_lock); |
| 1725 | clk_register_clkdev(clk, "extern2", "clk_out_2"); |
| 1726 | clks[clk_out_2] = clk; |
| 1727 | |
| 1728 | /* clk_out_3 */ |
| 1729 | clk = clk_register_mux(NULL, "clk_out_3_mux", clk_out3_parents, |
Prashant Gaikwad | 995968e | 2013-05-27 13:24:39 +0530 | [diff] [blame] | 1730 | ARRAY_SIZE(clk_out3_parents), 0, |
Peter De Schrijver | 2cb5efe | 2013-04-03 17:40:45 +0300 | [diff] [blame] | 1731 | pmc_base + PMC_CLK_OUT_CNTRL, 22, 3, 0, |
| 1732 | &clk_out_lock); |
| 1733 | clks[clk_out_3_mux] = clk; |
| 1734 | clk = clk_register_gate(NULL, "clk_out_3", "clk_out_3_mux", 0, |
| 1735 | pmc_base + PMC_CLK_OUT_CNTRL, 18, 0, |
| 1736 | &clk_out_lock); |
| 1737 | clk_register_clkdev(clk, "extern3", "clk_out_3"); |
| 1738 | clks[clk_out_3] = clk; |
| 1739 | |
| 1740 | /* blink */ |
Alexandre Courbot | 9139227 | 2013-05-26 11:56:31 +0900 | [diff] [blame] | 1741 | /* clear the blink timer register to directly output clk_32k */ |
| 1742 | writel_relaxed(0, pmc_base + PMC_BLINK_TIMER); |
Peter De Schrijver | 2cb5efe | 2013-04-03 17:40:45 +0300 | [diff] [blame] | 1743 | clk = clk_register_gate(NULL, "blink_override", "clk_32k", 0, |
| 1744 | pmc_base + PMC_DPD_PADS_ORIDE, |
| 1745 | PMC_DPD_PADS_ORIDE_BLINK_ENB, 0, NULL); |
| 1746 | clk = clk_register_gate(NULL, "blink", "blink_override", 0, |
| 1747 | pmc_base + PMC_CTRL, |
| 1748 | PMC_CTRL_BLINK_ENB, 0, NULL); |
| 1749 | clk_register_clkdev(clk, "blink", NULL); |
| 1750 | clks[blink] = clk; |
| 1751 | |
| 1752 | } |
| 1753 | |
| 1754 | static const char *sclk_parents[] = { "clk_m", "pll_c_out1", "pll_p_out4", |
Peter De Schrijver | 29b0944 | 2013-06-05 17:29:28 +0300 | [diff] [blame] | 1755 | "pll_p", "pll_p_out2", "unused", |
Peter De Schrijver | 2cb5efe | 2013-04-03 17:40:45 +0300 | [diff] [blame] | 1756 | "clk_32k", "pll_m_out1" }; |
| 1757 | |
| 1758 | static const char *cclk_g_parents[] = { "clk_m", "pll_c", "clk_32k", "pll_m", |
| 1759 | "pll_p", "pll_p_out4", "unused", |
| 1760 | "unused", "pll_x" }; |
| 1761 | |
| 1762 | static const char *cclk_lp_parents[] = { "clk_m", "pll_c", "clk_32k", "pll_m", |
| 1763 | "pll_p", "pll_p_out4", "unused", |
| 1764 | "unused", "pll_x", "pll_x_out0" }; |
| 1765 | |
| 1766 | static void __init tegra114_super_clk_init(void __iomem *clk_base) |
| 1767 | { |
| 1768 | struct clk *clk; |
| 1769 | |
| 1770 | /* CCLKG */ |
| 1771 | clk = tegra_clk_register_super_mux("cclk_g", cclk_g_parents, |
| 1772 | ARRAY_SIZE(cclk_g_parents), |
| 1773 | CLK_SET_RATE_PARENT, |
| 1774 | clk_base + CCLKG_BURST_POLICY, |
| 1775 | 0, 4, 0, 0, NULL); |
| 1776 | clk_register_clkdev(clk, "cclk_g", NULL); |
| 1777 | clks[cclk_g] = clk; |
| 1778 | |
| 1779 | /* CCLKLP */ |
| 1780 | clk = tegra_clk_register_super_mux("cclk_lp", cclk_lp_parents, |
| 1781 | ARRAY_SIZE(cclk_lp_parents), |
| 1782 | CLK_SET_RATE_PARENT, |
| 1783 | clk_base + CCLKLP_BURST_POLICY, |
| 1784 | 0, 4, 8, 9, NULL); |
| 1785 | clk_register_clkdev(clk, "cclk_lp", NULL); |
| 1786 | clks[cclk_lp] = clk; |
| 1787 | |
| 1788 | /* SCLK */ |
| 1789 | clk = tegra_clk_register_super_mux("sclk", sclk_parents, |
| 1790 | ARRAY_SIZE(sclk_parents), |
| 1791 | CLK_SET_RATE_PARENT, |
| 1792 | clk_base + SCLK_BURST_POLICY, |
| 1793 | 0, 4, 0, 0, NULL); |
| 1794 | clk_register_clkdev(clk, "sclk", NULL); |
| 1795 | clks[sclk] = clk; |
| 1796 | |
| 1797 | /* HCLK */ |
| 1798 | clk = clk_register_divider(NULL, "hclk_div", "sclk", 0, |
| 1799 | clk_base + SYSTEM_CLK_RATE, 4, 2, 0, |
| 1800 | &sysrate_lock); |
| 1801 | clk = clk_register_gate(NULL, "hclk", "hclk_div", CLK_SET_RATE_PARENT | |
| 1802 | CLK_IGNORE_UNUSED, clk_base + SYSTEM_CLK_RATE, |
| 1803 | 7, CLK_GATE_SET_TO_DISABLE, &sysrate_lock); |
| 1804 | clk_register_clkdev(clk, "hclk", NULL); |
| 1805 | clks[hclk] = clk; |
| 1806 | |
| 1807 | /* PCLK */ |
| 1808 | clk = clk_register_divider(NULL, "pclk_div", "hclk", 0, |
| 1809 | clk_base + SYSTEM_CLK_RATE, 0, 2, 0, |
| 1810 | &sysrate_lock); |
| 1811 | clk = clk_register_gate(NULL, "pclk", "pclk_div", CLK_SET_RATE_PARENT | |
| 1812 | CLK_IGNORE_UNUSED, clk_base + SYSTEM_CLK_RATE, |
| 1813 | 3, CLK_GATE_SET_TO_DISABLE, &sysrate_lock); |
| 1814 | clk_register_clkdev(clk, "pclk", NULL); |
| 1815 | clks[pclk] = clk; |
| 1816 | } |
| 1817 | |
| 1818 | static struct tegra_periph_init_data tegra_periph_clk_list[] = { |
| 1819 | TEGRA_INIT_DATA_MUX("i2s0", NULL, "tegra30-i2s.0", mux_pllaout0_audio0_2x_pllp_clkm, CLK_SOURCE_I2S0, 30, &periph_l_regs, TEGRA_PERIPH_ON_APB, i2s0), |
| 1820 | TEGRA_INIT_DATA_MUX("i2s1", NULL, "tegra30-i2s.1", mux_pllaout0_audio1_2x_pllp_clkm, CLK_SOURCE_I2S1, 11, &periph_l_regs, TEGRA_PERIPH_ON_APB, i2s1), |
| 1821 | TEGRA_INIT_DATA_MUX("i2s2", NULL, "tegra30-i2s.2", mux_pllaout0_audio2_2x_pllp_clkm, CLK_SOURCE_I2S2, 18, &periph_l_regs, TEGRA_PERIPH_ON_APB, i2s2), |
| 1822 | TEGRA_INIT_DATA_MUX("i2s3", NULL, "tegra30-i2s.3", mux_pllaout0_audio3_2x_pllp_clkm, CLK_SOURCE_I2S3, 101, &periph_v_regs, TEGRA_PERIPH_ON_APB, i2s3), |
| 1823 | TEGRA_INIT_DATA_MUX("i2s4", NULL, "tegra30-i2s.4", mux_pllaout0_audio4_2x_pllp_clkm, CLK_SOURCE_I2S4, 102, &periph_v_regs, TEGRA_PERIPH_ON_APB, i2s4), |
| 1824 | TEGRA_INIT_DATA_MUX("spdif_out", "spdif_out", "tegra30-spdif", mux_pllaout0_audio_2x_pllp_clkm, CLK_SOURCE_SPDIF_OUT, 10, &periph_l_regs, TEGRA_PERIPH_ON_APB, spdif_out), |
| 1825 | TEGRA_INIT_DATA_MUX("spdif_in", "spdif_in", "tegra30-spdif", mux_pllp_pllc_pllm, CLK_SOURCE_SPDIF_IN, 10, &periph_l_regs, TEGRA_PERIPH_ON_APB, spdif_in), |
| 1826 | TEGRA_INIT_DATA_MUX("pwm", NULL, "pwm", mux_pllp_pllc_clk32_clkm, CLK_SOURCE_PWM, 17, &periph_l_regs, TEGRA_PERIPH_ON_APB, pwm), |
| 1827 | TEGRA_INIT_DATA_MUX("adx", NULL, "adx", mux_plla_pllc_pllp_clkm, CLK_SOURCE_ADX, 154, &periph_w_regs, TEGRA_PERIPH_ON_APB, adx), |
| 1828 | TEGRA_INIT_DATA_MUX("amx", NULL, "amx", mux_plla_pllc_pllp_clkm, CLK_SOURCE_AMX, 153, &periph_w_regs, TEGRA_PERIPH_ON_APB, amx), |
| 1829 | TEGRA_INIT_DATA_MUX("hda", "hda", "tegra30-hda", mux_pllp_pllc_pllm_clkm, CLK_SOURCE_HDA, 125, &periph_v_regs, TEGRA_PERIPH_ON_APB, hda), |
| 1830 | TEGRA_INIT_DATA_MUX("hda2codec_2x", "hda2codec", "tegra30-hda", mux_pllp_pllc_pllm_clkm, CLK_SOURCE_HDA2CODEC_2X, 111, &periph_v_regs, TEGRA_PERIPH_ON_APB, hda2codec_2x), |
| 1831 | TEGRA_INIT_DATA_MUX("sbc1", NULL, "tegra11-spi.0", mux_pllp_pllc_pllm_clkm, CLK_SOURCE_SBC1, 41, &periph_h_regs, TEGRA_PERIPH_ON_APB, sbc1), |
| 1832 | TEGRA_INIT_DATA_MUX("sbc2", NULL, "tegra11-spi.1", mux_pllp_pllc_pllm_clkm, CLK_SOURCE_SBC2, 44, &periph_h_regs, TEGRA_PERIPH_ON_APB, sbc2), |
| 1833 | TEGRA_INIT_DATA_MUX("sbc3", NULL, "tegra11-spi.2", mux_pllp_pllc_pllm_clkm, CLK_SOURCE_SBC3, 46, &periph_h_regs, TEGRA_PERIPH_ON_APB, sbc3), |
| 1834 | TEGRA_INIT_DATA_MUX("sbc4", NULL, "tegra11-spi.3", mux_pllp_pllc_pllm_clkm, CLK_SOURCE_SBC4, 68, &periph_u_regs, TEGRA_PERIPH_ON_APB, sbc4), |
| 1835 | TEGRA_INIT_DATA_MUX("sbc5", NULL, "tegra11-spi.4", mux_pllp_pllc_pllm_clkm, CLK_SOURCE_SBC5, 104, &periph_v_regs, TEGRA_PERIPH_ON_APB, sbc5), |
| 1836 | TEGRA_INIT_DATA_MUX("sbc6", NULL, "tegra11-spi.5", mux_pllp_pllc_pllm_clkm, CLK_SOURCE_SBC6, 105, &periph_v_regs, TEGRA_PERIPH_ON_APB, sbc6), |
| 1837 | TEGRA_INIT_DATA_MUX8("ndflash", NULL, "tegra_nand", mux_pllp_pllc2_c_c3_pllm_clkm, CLK_SOURCE_NDFLASH, 13, &periph_u_regs, TEGRA_PERIPH_ON_APB, ndspeed), |
| 1838 | TEGRA_INIT_DATA_MUX8("ndspeed", NULL, "tegra_nand_speed", mux_pllp_pllc2_c_c3_pllm_clkm, CLK_SOURCE_NDSPEED, 80, &periph_u_regs, TEGRA_PERIPH_ON_APB, ndspeed), |
| 1839 | TEGRA_INIT_DATA_MUX("vfir", NULL, "vfir", mux_pllp_pllc_pllm_clkm, CLK_SOURCE_VFIR, 7, &periph_l_regs, TEGRA_PERIPH_ON_APB, vfir), |
| 1840 | TEGRA_INIT_DATA_MUX("sdmmc1", NULL, "sdhci-tegra.0", mux_pllp_pllc_pllm_clkm, CLK_SOURCE_SDMMC1, 14, &periph_l_regs, 0, sdmmc1), |
| 1841 | TEGRA_INIT_DATA_MUX("sdmmc2", NULL, "sdhci-tegra.1", mux_pllp_pllc_pllm_clkm, CLK_SOURCE_SDMMC2, 9, &periph_l_regs, 0, sdmmc2), |
| 1842 | TEGRA_INIT_DATA_MUX("sdmmc3", NULL, "sdhci-tegra.2", mux_pllp_pllc_pllm_clkm, CLK_SOURCE_SDMMC3, 69, &periph_u_regs, 0, sdmmc3), |
| 1843 | TEGRA_INIT_DATA_MUX("sdmmc4", NULL, "sdhci-tegra.3", mux_pllp_pllc_pllm_clkm, CLK_SOURCE_SDMMC4, 15, &periph_l_regs, 0, sdmmc4), |
| 1844 | TEGRA_INIT_DATA_INT("vde", NULL, "vde", mux_pllp_pllc2_c_c3_pllm_clkm, CLK_SOURCE_VDE, 61, &periph_h_regs, 0, vde), |
| 1845 | TEGRA_INIT_DATA_MUX_FLAGS("csite", NULL, "csite", mux_pllp_pllc_pllm_clkm, CLK_SOURCE_CSITE, 73, &periph_u_regs, TEGRA_PERIPH_ON_APB, csite, CLK_IGNORE_UNUSED), |
| 1846 | TEGRA_INIT_DATA_MUX("la", NULL, "la", mux_pllp_pllc_pllm_clkm, CLK_SOURCE_LA, 76, &periph_u_regs, TEGRA_PERIPH_ON_APB, la), |
| 1847 | TEGRA_INIT_DATA_MUX("trace", NULL, "trace", mux_pllp_pllc_pllm_clkm, CLK_SOURCE_TRACE, 77, &periph_u_regs, TEGRA_PERIPH_ON_APB, trace), |
| 1848 | TEGRA_INIT_DATA_MUX("owr", NULL, "tegra_w1", mux_pllp_pllc_pllm_clkm, CLK_SOURCE_OWR, 71, &periph_u_regs, TEGRA_PERIPH_ON_APB, owr), |
| 1849 | TEGRA_INIT_DATA_MUX("nor", NULL, "tegra-nor", mux_pllp_pllc_pllm_clkm, CLK_SOURCE_NOR, 42, &periph_h_regs, 0, nor), |
| 1850 | TEGRA_INIT_DATA_MUX("mipi", NULL, "mipi", mux_pllp_pllc_pllm_clkm, CLK_SOURCE_MIPI, 50, &periph_h_regs, TEGRA_PERIPH_ON_APB, mipi), |
| 1851 | TEGRA_INIT_DATA_I2C("i2c1", "div-clk", "tegra11-i2c.0", mux_pllp_clkm, CLK_SOURCE_I2C1, 12, &periph_l_regs, i2c1), |
| 1852 | TEGRA_INIT_DATA_I2C("i2c2", "div-clk", "tegra11-i2c.1", mux_pllp_clkm, CLK_SOURCE_I2C2, 54, &periph_h_regs, i2c2), |
| 1853 | TEGRA_INIT_DATA_I2C("i2c3", "div-clk", "tegra11-i2c.2", mux_pllp_clkm, CLK_SOURCE_I2C3, 67, &periph_u_regs, i2c3), |
| 1854 | TEGRA_INIT_DATA_I2C("i2c4", "div-clk", "tegra11-i2c.3", mux_pllp_clkm, CLK_SOURCE_I2C4, 103, &periph_v_regs, i2c4), |
| 1855 | TEGRA_INIT_DATA_I2C("i2c5", "div-clk", "tegra11-i2c.4", mux_pllp_clkm, CLK_SOURCE_I2C5, 47, &periph_h_regs, i2c5), |
| 1856 | TEGRA_INIT_DATA_UART("uarta", NULL, "tegra_uart.0", mux_pllp_pllc_pllm_clkm, CLK_SOURCE_UARTA, 6, &periph_l_regs, uarta), |
| 1857 | TEGRA_INIT_DATA_UART("uartb", NULL, "tegra_uart.1", mux_pllp_pllc_pllm_clkm, CLK_SOURCE_UARTB, 7, &periph_l_regs, uartb), |
| 1858 | TEGRA_INIT_DATA_UART("uartc", NULL, "tegra_uart.2", mux_pllp_pllc_pllm_clkm, CLK_SOURCE_UARTC, 55, &periph_h_regs, uartc), |
| 1859 | TEGRA_INIT_DATA_UART("uartd", NULL, "tegra_uart.3", mux_pllp_pllc_pllm_clkm, CLK_SOURCE_UARTD, 65, &periph_u_regs, uartd), |
| 1860 | TEGRA_INIT_DATA_INT("3d", NULL, "3d", mux_pllm_pllc2_c_c3_pllp_plla, CLK_SOURCE_3D, 24, &periph_l_regs, 0, gr_3d), |
| 1861 | TEGRA_INIT_DATA_INT("2d", NULL, "2d", mux_pllm_pllc2_c_c3_pllp_plla, CLK_SOURCE_2D, 21, &periph_l_regs, 0, gr_2d), |
| 1862 | TEGRA_INIT_DATA_MUX("vi_sensor", "vi_sensor", "tegra_camera", mux_pllm_pllc2_c_c3_pllp_plla, CLK_SOURCE_VI_SENSOR, 20, &periph_l_regs, TEGRA_PERIPH_NO_RESET, vi_sensor), |
| 1863 | TEGRA_INIT_DATA_INT8("vi", "vi", "tegra_camera", mux_pllm_pllc2_c_c3_pllp_plla, CLK_SOURCE_VI, 20, &periph_l_regs, 0, vi), |
| 1864 | TEGRA_INIT_DATA_INT8("epp", NULL, "epp", mux_pllm_pllc2_c_c3_pllp_plla, CLK_SOURCE_EPP, 19, &periph_l_regs, 0, epp), |
Mikko Perttunen | 8823598 | 2013-06-04 14:25:43 +0300 | [diff] [blame] | 1865 | TEGRA_INIT_DATA_INT8("msenc", NULL, "msenc", mux_pllm_pllc2_c_c3_pllp_plla, CLK_SOURCE_MSENC, 91, &periph_u_regs, TEGRA_PERIPH_WAR_1005168, msenc), |
Peter De Schrijver | 2cb5efe | 2013-04-03 17:40:45 +0300 | [diff] [blame] | 1866 | TEGRA_INIT_DATA_INT8("tsec", NULL, "tsec", mux_pllp_pllc2_c_c3_pllm_clkm, CLK_SOURCE_TSEC, 83, &periph_u_regs, 0, tsec), |
| 1867 | TEGRA_INIT_DATA_INT8("host1x", NULL, "host1x", mux_pllm_pllc2_c_c3_pllp_plla, CLK_SOURCE_HOST1X, 28, &periph_l_regs, 0, host1x), |
| 1868 | TEGRA_INIT_DATA_MUX8("hdmi", NULL, "hdmi", mux_pllp_pllm_plld_plla_pllc_plld2_clkm, CLK_SOURCE_HDMI, 51, &periph_h_regs, 0, hdmi), |
| 1869 | TEGRA_INIT_DATA_MUX("cilab", "cilab", "tegra_camera", mux_pllp_pllc_clkm, CLK_SOURCE_CILAB, 144, &periph_w_regs, 0, cilab), |
| 1870 | TEGRA_INIT_DATA_MUX("cilcd", "cilcd", "tegra_camera", mux_pllp_pllc_clkm, CLK_SOURCE_CILCD, 145, &periph_w_regs, 0, cilcd), |
| 1871 | TEGRA_INIT_DATA_MUX("cile", "cile", "tegra_camera", mux_pllp_pllc_clkm, CLK_SOURCE_CILE, 146, &periph_w_regs, 0, cile), |
| 1872 | TEGRA_INIT_DATA_MUX("dsialp", "dsialp", "tegradc.0", mux_pllp_pllc_clkm, CLK_SOURCE_DSIALP, 147, &periph_w_regs, 0, dsialp), |
| 1873 | TEGRA_INIT_DATA_MUX("dsiblp", "dsiblp", "tegradc.1", mux_pllp_pllc_clkm, CLK_SOURCE_DSIBLP, 148, &periph_w_regs, 0, dsiblp), |
| 1874 | TEGRA_INIT_DATA_MUX("tsensor", NULL, "tegra-tsensor", mux_pllp_pllc_clkm_clk32, CLK_SOURCE_TSENSOR, 100, &periph_v_regs, TEGRA_PERIPH_ON_APB, tsensor), |
| 1875 | TEGRA_INIT_DATA_MUX("actmon", NULL, "actmon", mux_pllp_pllc_clk32_clkm, CLK_SOURCE_ACTMON, 119, &periph_v_regs, 0, actmon), |
| 1876 | TEGRA_INIT_DATA_MUX8("extern1", NULL, "extern1", mux_plla_clk32_pllp_clkm_plle, CLK_SOURCE_EXTERN1, 120, &periph_v_regs, 0, extern1), |
| 1877 | TEGRA_INIT_DATA_MUX8("extern2", NULL, "extern2", mux_plla_clk32_pllp_clkm_plle, CLK_SOURCE_EXTERN2, 121, &periph_v_regs, 0, extern2), |
| 1878 | TEGRA_INIT_DATA_MUX8("extern3", NULL, "extern3", mux_plla_clk32_pllp_clkm_plle, CLK_SOURCE_EXTERN3, 122, &periph_v_regs, 0, extern3), |
| 1879 | TEGRA_INIT_DATA_MUX("i2cslow", NULL, "i2cslow", mux_pllp_pllc_clk32_clkm, CLK_SOURCE_I2CSLOW, 81, &periph_u_regs, TEGRA_PERIPH_ON_APB, i2cslow), |
| 1880 | TEGRA_INIT_DATA_INT8("se", NULL, "se", mux_pllp_pllc2_c_c3_pllm_clkm, CLK_SOURCE_SE, 127, &periph_v_regs, TEGRA_PERIPH_ON_APB, se), |
| 1881 | TEGRA_INIT_DATA_INT_FLAGS("mselect", NULL, "mselect", mux_pllp_clkm, CLK_SOURCE_MSELECT, 99, &periph_v_regs, 0, mselect, CLK_IGNORE_UNUSED), |
| 1882 | TEGRA_INIT_DATA_MUX8("soc_therm", NULL, "soc_therm", mux_pllm_pllc_pllp_plla, CLK_SOURCE_SOC_THERM, 78, &periph_u_regs, TEGRA_PERIPH_ON_APB, soc_therm), |
| 1883 | TEGRA_INIT_DATA_XUSB("xusb_host_src", "host_src", "tegra_xhci", mux_clkm_pllp_pllc_pllre, CLK_SOURCE_XUSB_HOST_SRC, 143, &periph_w_regs, TEGRA_PERIPH_ON_APB | TEGRA_PERIPH_NO_RESET, xusb_host_src), |
| 1884 | TEGRA_INIT_DATA_XUSB("xusb_falcon_src", "falcon_src", "tegra_xhci", mux_clkm_pllp_pllc_pllre, CLK_SOURCE_XUSB_FALCON_SRC, 143, &periph_w_regs, TEGRA_PERIPH_NO_RESET, xusb_falcon_src), |
| 1885 | TEGRA_INIT_DATA_XUSB("xusb_fs_src", "fs_src", "tegra_xhci", mux_clkm_48M_pllp_480M, CLK_SOURCE_XUSB_FS_SRC, 143, &periph_w_regs, TEGRA_PERIPH_NO_RESET, xusb_fs_src), |
| 1886 | TEGRA_INIT_DATA_XUSB("xusb_ss_src", "ss_src", "tegra_xhci", mux_clkm_pllre_clk32_480M_pllc_ref, CLK_SOURCE_XUSB_SS_SRC, 143, &periph_w_regs, TEGRA_PERIPH_NO_RESET, xusb_ss_src), |
| 1887 | TEGRA_INIT_DATA_XUSB("xusb_dev_src", "dev_src", "tegra_xhci", mux_clkm_pllp_pllc_pllre, CLK_SOURCE_XUSB_DEV_SRC, 95, &periph_u_regs, TEGRA_PERIPH_ON_APB | TEGRA_PERIPH_NO_RESET, xusb_dev_src), |
| 1888 | TEGRA_INIT_DATA_AUDIO("d_audio", "d_audio", "tegra30-ahub", CLK_SOURCE_D_AUDIO, 106, &periph_v_regs, TEGRA_PERIPH_ON_APB, d_audio), |
| 1889 | TEGRA_INIT_DATA_AUDIO("dam0", NULL, "tegra30-dam.0", CLK_SOURCE_DAM0, 108, &periph_v_regs, TEGRA_PERIPH_ON_APB, dam0), |
| 1890 | TEGRA_INIT_DATA_AUDIO("dam1", NULL, "tegra30-dam.1", CLK_SOURCE_DAM1, 109, &periph_v_regs, TEGRA_PERIPH_ON_APB, dam1), |
| 1891 | TEGRA_INIT_DATA_AUDIO("dam2", NULL, "tegra30-dam.2", CLK_SOURCE_DAM2, 110, &periph_v_regs, TEGRA_PERIPH_ON_APB, dam2), |
| 1892 | }; |
| 1893 | |
| 1894 | static struct tegra_periph_init_data tegra_periph_nodiv_clk_list[] = { |
| 1895 | TEGRA_INIT_DATA_NODIV("disp1", NULL, "tegradc.0", mux_pllp_pllm_plld_plla_pllc_plld2_clkm, CLK_SOURCE_DISP1, 29, 7, 27, &periph_l_regs, 0, disp1), |
| 1896 | TEGRA_INIT_DATA_NODIV("disp2", NULL, "tegradc.1", mux_pllp_pllm_plld_plla_pllc_plld2_clkm, CLK_SOURCE_DISP2, 29, 7, 26, &periph_l_regs, 0, disp2), |
| 1897 | }; |
| 1898 | |
| 1899 | static __init void tegra114_periph_clk_init(void __iomem *clk_base) |
| 1900 | { |
| 1901 | struct tegra_periph_init_data *data; |
| 1902 | struct clk *clk; |
| 1903 | int i; |
| 1904 | u32 val; |
| 1905 | |
| 1906 | /* apbdma */ |
| 1907 | clk = tegra_clk_register_periph_gate("apbdma", "clk_m", 0, clk_base, |
| 1908 | 0, 34, &periph_h_regs, |
| 1909 | periph_clk_enb_refcnt); |
| 1910 | clks[apbdma] = clk; |
| 1911 | |
| 1912 | /* rtc */ |
| 1913 | clk = tegra_clk_register_periph_gate("rtc", "clk_32k", |
| 1914 | TEGRA_PERIPH_ON_APB | |
| 1915 | TEGRA_PERIPH_NO_RESET, clk_base, |
| 1916 | 0, 4, &periph_l_regs, |
| 1917 | periph_clk_enb_refcnt); |
| 1918 | clk_register_clkdev(clk, NULL, "rtc-tegra"); |
| 1919 | clks[rtc] = clk; |
| 1920 | |
| 1921 | /* kbc */ |
| 1922 | clk = tegra_clk_register_periph_gate("kbc", "clk_32k", |
| 1923 | TEGRA_PERIPH_ON_APB | |
| 1924 | TEGRA_PERIPH_NO_RESET, clk_base, |
| 1925 | 0, 36, &periph_h_regs, |
| 1926 | periph_clk_enb_refcnt); |
| 1927 | clks[kbc] = clk; |
| 1928 | |
| 1929 | /* timer */ |
| 1930 | clk = tegra_clk_register_periph_gate("timer", "clk_m", 0, clk_base, |
| 1931 | 0, 5, &periph_l_regs, |
| 1932 | periph_clk_enb_refcnt); |
| 1933 | clk_register_clkdev(clk, NULL, "timer"); |
| 1934 | clks[timer] = clk; |
| 1935 | |
| 1936 | /* kfuse */ |
| 1937 | clk = tegra_clk_register_periph_gate("kfuse", "clk_m", |
| 1938 | TEGRA_PERIPH_ON_APB, clk_base, 0, 40, |
| 1939 | &periph_h_regs, periph_clk_enb_refcnt); |
| 1940 | clks[kfuse] = clk; |
| 1941 | |
| 1942 | /* fuse */ |
| 1943 | clk = tegra_clk_register_periph_gate("fuse", "clk_m", |
| 1944 | TEGRA_PERIPH_ON_APB, clk_base, 0, 39, |
| 1945 | &periph_h_regs, periph_clk_enb_refcnt); |
| 1946 | clks[fuse] = clk; |
| 1947 | |
| 1948 | /* fuse_burn */ |
| 1949 | clk = tegra_clk_register_periph_gate("fuse_burn", "clk_m", |
| 1950 | TEGRA_PERIPH_ON_APB, clk_base, 0, 39, |
| 1951 | &periph_h_regs, periph_clk_enb_refcnt); |
| 1952 | clks[fuse_burn] = clk; |
| 1953 | |
| 1954 | /* apbif */ |
| 1955 | clk = tegra_clk_register_periph_gate("apbif", "clk_m", |
| 1956 | TEGRA_PERIPH_ON_APB, clk_base, 0, 107, |
| 1957 | &periph_v_regs, periph_clk_enb_refcnt); |
| 1958 | clks[apbif] = clk; |
| 1959 | |
| 1960 | /* hda2hdmi */ |
| 1961 | clk = tegra_clk_register_periph_gate("hda2hdmi", "clk_m", |
| 1962 | TEGRA_PERIPH_ON_APB, clk_base, 0, 128, |
| 1963 | &periph_w_regs, periph_clk_enb_refcnt); |
| 1964 | clks[hda2hdmi] = clk; |
| 1965 | |
| 1966 | /* vcp */ |
| 1967 | clk = tegra_clk_register_periph_gate("vcp", "clk_m", 0, clk_base, 0, |
| 1968 | 29, &periph_l_regs, |
| 1969 | periph_clk_enb_refcnt); |
| 1970 | clks[vcp] = clk; |
| 1971 | |
| 1972 | /* bsea */ |
| 1973 | clk = tegra_clk_register_periph_gate("bsea", "clk_m", 0, clk_base, |
| 1974 | 0, 62, &periph_h_regs, |
| 1975 | periph_clk_enb_refcnt); |
| 1976 | clks[bsea] = clk; |
| 1977 | |
| 1978 | /* bsev */ |
| 1979 | clk = tegra_clk_register_periph_gate("bsev", "clk_m", 0, clk_base, |
| 1980 | 0, 63, &periph_h_regs, |
| 1981 | periph_clk_enb_refcnt); |
| 1982 | clks[bsev] = clk; |
| 1983 | |
| 1984 | /* mipi-cal */ |
| 1985 | clk = tegra_clk_register_periph_gate("mipi-cal", "clk_m", 0, clk_base, |
| 1986 | 0, 56, &periph_h_regs, |
| 1987 | periph_clk_enb_refcnt); |
| 1988 | clks[mipi_cal] = clk; |
| 1989 | |
| 1990 | /* usbd */ |
| 1991 | clk = tegra_clk_register_periph_gate("usbd", "clk_m", 0, clk_base, |
| 1992 | 0, 22, &periph_l_regs, |
| 1993 | periph_clk_enb_refcnt); |
| 1994 | clks[usbd] = clk; |
| 1995 | |
| 1996 | /* usb2 */ |
| 1997 | clk = tegra_clk_register_periph_gate("usb2", "clk_m", 0, clk_base, |
| 1998 | 0, 58, &periph_h_regs, |
| 1999 | periph_clk_enb_refcnt); |
| 2000 | clks[usb2] = clk; |
| 2001 | |
| 2002 | /* usb3 */ |
| 2003 | clk = tegra_clk_register_periph_gate("usb3", "clk_m", 0, clk_base, |
| 2004 | 0, 59, &periph_h_regs, |
| 2005 | periph_clk_enb_refcnt); |
| 2006 | clks[usb3] = clk; |
| 2007 | |
| 2008 | /* csi */ |
| 2009 | clk = tegra_clk_register_periph_gate("csi", "pll_p_out3", 0, clk_base, |
| 2010 | 0, 52, &periph_h_regs, |
| 2011 | periph_clk_enb_refcnt); |
| 2012 | clks[csi] = clk; |
| 2013 | |
| 2014 | /* isp */ |
| 2015 | clk = tegra_clk_register_periph_gate("isp", "clk_m", 0, clk_base, 0, |
| 2016 | 23, &periph_l_regs, |
| 2017 | periph_clk_enb_refcnt); |
| 2018 | clks[isp] = clk; |
| 2019 | |
| 2020 | /* csus */ |
| 2021 | clk = tegra_clk_register_periph_gate("csus", "clk_m", |
| 2022 | TEGRA_PERIPH_NO_RESET, clk_base, 0, 92, |
| 2023 | &periph_u_regs, periph_clk_enb_refcnt); |
| 2024 | clks[csus] = clk; |
| 2025 | |
| 2026 | /* dds */ |
| 2027 | clk = tegra_clk_register_periph_gate("dds", "clk_m", |
| 2028 | TEGRA_PERIPH_ON_APB, clk_base, 0, 150, |
| 2029 | &periph_w_regs, periph_clk_enb_refcnt); |
| 2030 | clks[dds] = clk; |
| 2031 | |
| 2032 | /* dp2 */ |
| 2033 | clk = tegra_clk_register_periph_gate("dp2", "clk_m", |
| 2034 | TEGRA_PERIPH_ON_APB, clk_base, 0, 152, |
| 2035 | &periph_w_regs, periph_clk_enb_refcnt); |
| 2036 | clks[dp2] = clk; |
| 2037 | |
| 2038 | /* dtv */ |
| 2039 | clk = tegra_clk_register_periph_gate("dtv", "clk_m", |
| 2040 | TEGRA_PERIPH_ON_APB, clk_base, 0, 79, |
| 2041 | &periph_u_regs, periph_clk_enb_refcnt); |
| 2042 | clks[dtv] = clk; |
| 2043 | |
| 2044 | /* dsia */ |
| 2045 | clk = clk_register_mux(NULL, "dsia_mux", mux_plld_out0_plld2_out0, |
| 2046 | ARRAY_SIZE(mux_plld_out0_plld2_out0), 0, |
| 2047 | clk_base + PLLD_BASE, 25, 1, 0, &pll_d_lock); |
| 2048 | clks[dsia_mux] = clk; |
| 2049 | clk = tegra_clk_register_periph_gate("dsia", "dsia_mux", 0, clk_base, |
| 2050 | 0, 48, &periph_h_regs, |
| 2051 | periph_clk_enb_refcnt); |
| 2052 | clks[dsia] = clk; |
| 2053 | |
| 2054 | /* dsib */ |
| 2055 | clk = clk_register_mux(NULL, "dsib_mux", mux_plld_out0_plld2_out0, |
| 2056 | ARRAY_SIZE(mux_plld_out0_plld2_out0), 0, |
| 2057 | clk_base + PLLD2_BASE, 25, 1, 0, &pll_d2_lock); |
| 2058 | clks[dsib_mux] = clk; |
| 2059 | clk = tegra_clk_register_periph_gate("dsib", "dsib_mux", 0, clk_base, |
| 2060 | 0, 82, &periph_u_regs, |
| 2061 | periph_clk_enb_refcnt); |
| 2062 | clks[dsib] = clk; |
| 2063 | |
| 2064 | /* xusb_hs_src */ |
| 2065 | val = readl(clk_base + CLK_SOURCE_XUSB_SS_SRC); |
| 2066 | val |= BIT(25); /* always select PLLU_60M */ |
| 2067 | writel(val, clk_base + CLK_SOURCE_XUSB_SS_SRC); |
| 2068 | |
| 2069 | clk = clk_register_fixed_factor(NULL, "xusb_hs_src", "pll_u_60M", 0, |
| 2070 | 1, 1); |
| 2071 | clks[xusb_hs_src] = clk; |
| 2072 | |
| 2073 | /* xusb_host */ |
| 2074 | clk = tegra_clk_register_periph_gate("xusb_host", "xusb_host_src", 0, |
| 2075 | clk_base, 0, 89, &periph_u_regs, |
| 2076 | periph_clk_enb_refcnt); |
| 2077 | clks[xusb_host] = clk; |
| 2078 | |
| 2079 | /* xusb_ss */ |
| 2080 | clk = tegra_clk_register_periph_gate("xusb_ss", "xusb_ss_src", 0, |
| 2081 | clk_base, 0, 156, &periph_w_regs, |
| 2082 | periph_clk_enb_refcnt); |
| 2083 | clks[xusb_host] = clk; |
| 2084 | |
| 2085 | /* xusb_dev */ |
| 2086 | clk = tegra_clk_register_periph_gate("xusb_dev", "xusb_dev_src", 0, |
| 2087 | clk_base, 0, 95, &periph_u_regs, |
| 2088 | periph_clk_enb_refcnt); |
| 2089 | clks[xusb_dev] = clk; |
| 2090 | |
| 2091 | /* emc */ |
| 2092 | clk = clk_register_mux(NULL, "emc_mux", mux_pllmcp_clkm, |
| 2093 | ARRAY_SIZE(mux_pllmcp_clkm), 0, |
| 2094 | clk_base + CLK_SOURCE_EMC, |
| 2095 | 29, 3, 0, NULL); |
| 2096 | clk = tegra_clk_register_periph_gate("emc", "emc_mux", 0, clk_base, |
| 2097 | CLK_IGNORE_UNUSED, 57, &periph_h_regs, |
| 2098 | periph_clk_enb_refcnt); |
| 2099 | clks[emc] = clk; |
| 2100 | |
| 2101 | for (i = 0; i < ARRAY_SIZE(tegra_periph_clk_list); i++) { |
| 2102 | data = &tegra_periph_clk_list[i]; |
| 2103 | clk = tegra_clk_register_periph(data->name, data->parent_names, |
| 2104 | data->num_parents, &data->periph, |
| 2105 | clk_base, data->offset, data->flags); |
| 2106 | clks[data->clk_id] = clk; |
| 2107 | } |
| 2108 | |
| 2109 | for (i = 0; i < ARRAY_SIZE(tegra_periph_nodiv_clk_list); i++) { |
| 2110 | data = &tegra_periph_nodiv_clk_list[i]; |
| 2111 | clk = tegra_clk_register_periph_nodiv(data->name, |
| 2112 | data->parent_names, data->num_parents, |
| 2113 | &data->periph, clk_base, data->offset); |
| 2114 | clks[data->clk_id] = clk; |
| 2115 | } |
| 2116 | } |
| 2117 | |
| 2118 | static struct tegra_cpu_car_ops tegra114_cpu_car_ops; |
| 2119 | |
| 2120 | static const struct of_device_id pmc_match[] __initconst = { |
| 2121 | { .compatible = "nvidia,tegra114-pmc" }, |
| 2122 | {}, |
| 2123 | }; |
| 2124 | |
| 2125 | static __initdata struct tegra_clk_init_table init_table[] = { |
| 2126 | {uarta, pll_p, 408000000, 0}, |
| 2127 | {uartb, pll_p, 408000000, 0}, |
| 2128 | {uartc, pll_p, 408000000, 0}, |
Peter De Schrijver | c604283 | 2013-04-03 17:40:49 +0300 | [diff] [blame] | 2129 | {uartd, pll_p, 408000000, 0}, |
Peter De Schrijver | 2cb5efe | 2013-04-03 17:40:45 +0300 | [diff] [blame] | 2130 | {pll_a, clk_max, 564480000, 1}, |
| 2131 | {pll_a_out0, clk_max, 11289600, 1}, |
| 2132 | {extern1, pll_a_out0, 0, 1}, |
| 2133 | {clk_out_1_mux, extern1, 0, 1}, |
| 2134 | {clk_out_1, clk_max, 0, 1}, |
| 2135 | {i2s0, pll_a_out0, 11289600, 0}, |
| 2136 | {i2s1, pll_a_out0, 11289600, 0}, |
| 2137 | {i2s2, pll_a_out0, 11289600, 0}, |
| 2138 | {i2s3, pll_a_out0, 11289600, 0}, |
| 2139 | {i2s4, pll_a_out0, 11289600, 0}, |
| 2140 | {clk_max, clk_max, 0, 0}, /* This MUST be the last entry. */ |
| 2141 | }; |
| 2142 | |
| 2143 | static void __init tegra114_clock_apply_init_table(void) |
| 2144 | { |
| 2145 | tegra_init_from_table(init_table, clks, clk_max); |
| 2146 | } |
| 2147 | |
Paul Walmsley | 25c9ded | 2013-06-07 06:18:58 -0600 | [diff] [blame^] | 2148 | |
| 2149 | /** |
| 2150 | * tegra114_car_barrier - wait for pending writes to the CAR to complete |
| 2151 | * |
| 2152 | * Wait for any outstanding writes to the CAR MMIO space from this CPU |
| 2153 | * to complete before continuing execution. No return value. |
| 2154 | */ |
| 2155 | static void tegra114_car_barrier(void) |
| 2156 | { |
| 2157 | wmb(); /* probably unnecessary */ |
| 2158 | readl_relaxed(clk_base + CPU_FINETRIM_SELECT); |
| 2159 | } |
| 2160 | |
| 2161 | /** |
| 2162 | * tegra114_clock_tune_cpu_trimmers_high - use high-voltage propagation delays |
| 2163 | * |
| 2164 | * When the CPU rail voltage is in the high-voltage range, use the |
| 2165 | * built-in hardwired clock propagation delays in the CPU clock |
| 2166 | * shaper. No return value. |
| 2167 | */ |
| 2168 | void tegra114_clock_tune_cpu_trimmers_high(void) |
| 2169 | { |
| 2170 | u32 select = 0; |
| 2171 | |
| 2172 | /* Use hardwired rise->rise & fall->fall clock propagation delays */ |
| 2173 | select |= ~(CPU_FINETRIM_1_FCPU_1 | CPU_FINETRIM_1_FCPU_2 | |
| 2174 | CPU_FINETRIM_1_FCPU_3 | CPU_FINETRIM_1_FCPU_4 | |
| 2175 | CPU_FINETRIM_1_FCPU_5 | CPU_FINETRIM_1_FCPU_6); |
| 2176 | writel_relaxed(select, clk_base + CPU_FINETRIM_SELECT); |
| 2177 | |
| 2178 | tegra114_car_barrier(); |
| 2179 | } |
| 2180 | EXPORT_SYMBOL(tegra114_clock_tune_cpu_trimmers_high); |
| 2181 | |
| 2182 | /** |
| 2183 | * tegra114_clock_tune_cpu_trimmers_low - use low-voltage propagation delays |
| 2184 | * |
| 2185 | * When the CPU rail voltage is in the low-voltage range, use the |
| 2186 | * extended clock propagation delays set by |
| 2187 | * tegra114_clock_tune_cpu_trimmers_init(). The intention is to |
| 2188 | * maintain the input clock duty cycle that the FCPU subsystem |
| 2189 | * expects. No return value. |
| 2190 | */ |
| 2191 | void tegra114_clock_tune_cpu_trimmers_low(void) |
| 2192 | { |
| 2193 | u32 select = 0; |
| 2194 | |
| 2195 | /* |
| 2196 | * Use software-specified rise->rise & fall->fall clock |
| 2197 | * propagation delays (from |
| 2198 | * tegra114_clock_tune_cpu_trimmers_init() |
| 2199 | */ |
| 2200 | select |= (CPU_FINETRIM_1_FCPU_1 | CPU_FINETRIM_1_FCPU_2 | |
| 2201 | CPU_FINETRIM_1_FCPU_3 | CPU_FINETRIM_1_FCPU_4 | |
| 2202 | CPU_FINETRIM_1_FCPU_5 | CPU_FINETRIM_1_FCPU_6); |
| 2203 | writel_relaxed(select, clk_base + CPU_FINETRIM_SELECT); |
| 2204 | |
| 2205 | tegra114_car_barrier(); |
| 2206 | } |
| 2207 | EXPORT_SYMBOL(tegra114_clock_tune_cpu_trimmers_low); |
| 2208 | |
| 2209 | /** |
| 2210 | * tegra114_clock_tune_cpu_trimmers_init - set up and enable clk prop delays |
| 2211 | * |
| 2212 | * Program extended clock propagation delays into the FCPU clock |
| 2213 | * shaper and enable them. XXX Define the purpose - peak current |
| 2214 | * reduction? No return value. |
| 2215 | */ |
| 2216 | /* XXX Initial voltage rail state assumption issues? */ |
| 2217 | void tegra114_clock_tune_cpu_trimmers_init(void) |
| 2218 | { |
| 2219 | u32 dr = 0, r = 0; |
| 2220 | |
| 2221 | /* Increment the rise->rise clock delay by four steps */ |
| 2222 | r |= (CPU_FINETRIM_R_FCPU_1_MASK | CPU_FINETRIM_R_FCPU_2_MASK | |
| 2223 | CPU_FINETRIM_R_FCPU_3_MASK | CPU_FINETRIM_R_FCPU_4_MASK | |
| 2224 | CPU_FINETRIM_R_FCPU_5_MASK | CPU_FINETRIM_R_FCPU_6_MASK); |
| 2225 | writel_relaxed(r, clk_base + CPU_FINETRIM_R); |
| 2226 | |
| 2227 | /* |
| 2228 | * Use the rise->rise clock propagation delay specified in the |
| 2229 | * r field |
| 2230 | */ |
| 2231 | dr |= (CPU_FINETRIM_1_FCPU_1 | CPU_FINETRIM_1_FCPU_2 | |
| 2232 | CPU_FINETRIM_1_FCPU_3 | CPU_FINETRIM_1_FCPU_4 | |
| 2233 | CPU_FINETRIM_1_FCPU_5 | CPU_FINETRIM_1_FCPU_6); |
| 2234 | writel_relaxed(dr, clk_base + CPU_FINETRIM_DR); |
| 2235 | |
| 2236 | tegra114_clock_tune_cpu_trimmers_low(); |
| 2237 | } |
| 2238 | EXPORT_SYMBOL(tegra114_clock_tune_cpu_trimmers_init); |
| 2239 | |
Prashant Gaikwad | 061cec9 | 2013-05-27 13:10:09 +0530 | [diff] [blame] | 2240 | static void __init tegra114_clock_init(struct device_node *np) |
Peter De Schrijver | 2cb5efe | 2013-04-03 17:40:45 +0300 | [diff] [blame] | 2241 | { |
| 2242 | struct device_node *node; |
| 2243 | int i; |
| 2244 | |
| 2245 | clk_base = of_iomap(np, 0); |
| 2246 | if (!clk_base) { |
| 2247 | pr_err("ioremap tegra114 CAR failed\n"); |
| 2248 | return; |
| 2249 | } |
| 2250 | |
| 2251 | node = of_find_matching_node(NULL, pmc_match); |
| 2252 | if (!node) { |
| 2253 | pr_err("Failed to find pmc node\n"); |
| 2254 | WARN_ON(1); |
| 2255 | return; |
| 2256 | } |
| 2257 | |
| 2258 | pmc_base = of_iomap(node, 0); |
| 2259 | if (!pmc_base) { |
| 2260 | pr_err("Can't map pmc registers\n"); |
| 2261 | WARN_ON(1); |
| 2262 | return; |
| 2263 | } |
| 2264 | |
| 2265 | if (tegra114_osc_clk_init(clk_base) < 0) |
| 2266 | return; |
| 2267 | |
| 2268 | tegra114_fixed_clk_init(clk_base); |
| 2269 | tegra114_pll_init(clk_base, pmc_base); |
| 2270 | tegra114_periph_clk_init(clk_base); |
| 2271 | tegra114_audio_clk_init(clk_base); |
| 2272 | tegra114_pmc_clk_init(pmc_base); |
| 2273 | tegra114_super_clk_init(clk_base); |
| 2274 | |
| 2275 | for (i = 0; i < ARRAY_SIZE(clks); i++) { |
| 2276 | if (IS_ERR(clks[i])) { |
| 2277 | pr_err |
| 2278 | ("Tegra114 clk %d: register failed with %ld\n", |
| 2279 | i, PTR_ERR(clks[i])); |
| 2280 | } |
| 2281 | if (!clks[i]) |
| 2282 | clks[i] = ERR_PTR(-EINVAL); |
| 2283 | } |
| 2284 | |
| 2285 | clk_data.clks = clks; |
| 2286 | clk_data.clk_num = ARRAY_SIZE(clks); |
| 2287 | of_clk_add_provider(np, of_clk_src_onecell_get, &clk_data); |
| 2288 | |
| 2289 | tegra_clk_apply_init_table = tegra114_clock_apply_init_table; |
| 2290 | |
| 2291 | tegra_cpu_car_ops = &tegra114_cpu_car_ops; |
| 2292 | } |
Prashant Gaikwad | 061cec9 | 2013-05-27 13:10:09 +0530 | [diff] [blame] | 2293 | CLK_OF_DECLARE(tegra114, "nvidia,tegra114-car", tegra114_clock_init); |