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