blob: 698c7ab9560d26317e4d5a271b8b130ad49d1fe2 [file] [log] [blame]
Tom Rini10e47792018-05-06 17:58:06 -04001// SPDX-License-Identifier: GPL-2.0+
Tom Warren61c6d0e2012-12-11 13:34:15 +00002/*
Tom Warrena8480ef2015-06-25 09:50:44 -07003 * (C) Copyright 2010-2015
4 * NVIDIA Corporation <www.nvidia.com>
Tom Warren61c6d0e2012-12-11 13:34:15 +00005 */
6
7/* Tegra30 Clock control functions */
8
9#include <common.h>
Thierry Reding4bf98692014-12-09 22:25:06 -070010#include <errno.h>
Simon Glass97589732020-05-10 11:40:02 -060011#include <init.h>
Simon Glass0f2af882020-05-10 11:40:05 -060012#include <log.h>
Tom Warren61c6d0e2012-12-11 13:34:15 +000013#include <asm/io.h>
14#include <asm/arch/clock.h>
15#include <asm/arch/tegra.h>
16#include <asm/arch-tegra/clk_rst.h>
17#include <asm/arch-tegra/timer.h>
18#include <div64.h>
19#include <fdtdec.h>
Simon Glassdbd79542020-05-10 11:40:11 -060020#include <linux/delay.h>
Simon Glassbdd5f812023-09-14 18:21:46 -060021#include <linux/printk.h>
Tom Warren61c6d0e2012-12-11 13:34:15 +000022
Svyatoslav Ryhel19a5b032023-02-14 19:35:25 +020023#include <dt-bindings/clock/tegra30-car.h>
24
Tom Warren61c6d0e2012-12-11 13:34:15 +000025/*
Tom Warren795f9d72013-01-23 14:01:01 -070026 * Clock types that we can use as a source. The Tegra30 has muxes for the
Tom Warren61c6d0e2012-12-11 13:34:15 +000027 * peripheral clocks, and in most cases there are four options for the clock
28 * source. This gives us a clock 'type' and exploits what commonality exists
29 * in the device.
30 *
31 * Letters are obvious, except for T which means CLK_M, and S which means the
32 * clock derived from 32KHz. Beware that CLK_M (also called OSC in the
33 * datasheet) and PLL_M are different things. The former is the basic
34 * clock supplied to the SOC from an external oscillator. The latter is the
35 * memory clock PLL.
36 *
37 * See definitions in clock_id in the header file.
38 */
39enum clock_type_id {
40 CLOCK_TYPE_AXPT, /* PLL_A, PLL_X, PLL_P, CLK_M */
41 CLOCK_TYPE_MCPA, /* and so on */
42 CLOCK_TYPE_MCPT,
43 CLOCK_TYPE_PCM,
44 CLOCK_TYPE_PCMT,
Tom Warrenea226042012-12-21 15:02:45 -070045 CLOCK_TYPE_PCMT16,
Tom Warren61c6d0e2012-12-11 13:34:15 +000046 CLOCK_TYPE_PDCT,
47 CLOCK_TYPE_ACPT,
48 CLOCK_TYPE_ASPTE,
49 CLOCK_TYPE_PMDACD2T,
50 CLOCK_TYPE_PCST,
51
52 CLOCK_TYPE_COUNT,
Tom Warren795f9d72013-01-23 14:01:01 -070053 CLOCK_TYPE_NONE = -1, /* invalid clock type */
Tom Warren61c6d0e2012-12-11 13:34:15 +000054};
55
Tom Warren61c6d0e2012-12-11 13:34:15 +000056enum {
Tom Warren795f9d72013-01-23 14:01:01 -070057 CLOCK_MAX_MUX = 8 /* number of source options for each clock */
Tom Warren61c6d0e2012-12-11 13:34:15 +000058};
59
Tom Warren61c6d0e2012-12-11 13:34:15 +000060/*
61 * Clock source mux for each clock type. This just converts our enum into
62 * a list of mux sources for use by the code.
63 *
64 * Note:
65 * The extra column in each clock source array is used to store the mask
66 * bits in its register for the source.
67 */
68#define CLK(x) CLOCK_ID_ ## x
69static enum clock_id clock_source[CLOCK_TYPE_COUNT][CLOCK_MAX_MUX+1] = {
Tom Warren795f9d72013-01-23 14:01:01 -070070 { CLK(AUDIO), CLK(XCPU), CLK(PERIPH), CLK(OSC),
71 CLK(NONE), CLK(NONE), CLK(NONE), CLK(NONE),
Tom Warren61c6d0e2012-12-11 13:34:15 +000072 MASK_BITS_31_30},
Tom Warren795f9d72013-01-23 14:01:01 -070073 { CLK(MEMORY), CLK(CGENERAL), CLK(PERIPH), CLK(AUDIO),
74 CLK(NONE), CLK(NONE), CLK(NONE), CLK(NONE),
Tom Warren61c6d0e2012-12-11 13:34:15 +000075 MASK_BITS_31_30},
Tom Warren795f9d72013-01-23 14:01:01 -070076 { CLK(MEMORY), CLK(CGENERAL), CLK(PERIPH), CLK(OSC),
77 CLK(NONE), CLK(NONE), CLK(NONE), CLK(NONE),
Tom Warren61c6d0e2012-12-11 13:34:15 +000078 MASK_BITS_31_30},
Tom Warren795f9d72013-01-23 14:01:01 -070079 { CLK(PERIPH), CLK(CGENERAL), CLK(MEMORY), CLK(NONE),
80 CLK(NONE), CLK(NONE), CLK(NONE), CLK(NONE),
Tom Warren61c6d0e2012-12-11 13:34:15 +000081 MASK_BITS_31_30},
Tom Warren795f9d72013-01-23 14:01:01 -070082 { CLK(PERIPH), CLK(CGENERAL), CLK(MEMORY), CLK(OSC),
83 CLK(NONE), CLK(NONE), CLK(NONE), CLK(NONE),
Tom Warren61c6d0e2012-12-11 13:34:15 +000084 MASK_BITS_31_30},
Tom Warren795f9d72013-01-23 14:01:01 -070085 { CLK(PERIPH), CLK(CGENERAL), CLK(MEMORY), CLK(OSC),
86 CLK(NONE), CLK(NONE), CLK(NONE), CLK(NONE),
Tom Warrenea226042012-12-21 15:02:45 -070087 MASK_BITS_31_30},
Tom Warren795f9d72013-01-23 14:01:01 -070088 { CLK(PERIPH), CLK(DISPLAY), CLK(CGENERAL), CLK(OSC),
89 CLK(NONE), CLK(NONE), CLK(NONE), CLK(NONE),
Tom Warren61c6d0e2012-12-11 13:34:15 +000090 MASK_BITS_31_30},
Tom Warren795f9d72013-01-23 14:01:01 -070091 { CLK(AUDIO), CLK(CGENERAL), CLK(PERIPH), CLK(OSC),
92 CLK(NONE), CLK(NONE), CLK(NONE), CLK(NONE),
Tom Warren61c6d0e2012-12-11 13:34:15 +000093 MASK_BITS_31_30},
Tom Warren795f9d72013-01-23 14:01:01 -070094 { CLK(AUDIO), CLK(SFROM32KHZ), CLK(PERIPH), CLK(OSC),
95 CLK(EPCI), CLK(NONE), CLK(NONE), CLK(NONE),
Tom Warren61c6d0e2012-12-11 13:34:15 +000096 MASK_BITS_31_29},
Tom Warren795f9d72013-01-23 14:01:01 -070097 { CLK(PERIPH), CLK(MEMORY), CLK(DISPLAY), CLK(AUDIO),
98 CLK(CGENERAL), CLK(DISPLAY2), CLK(OSC), CLK(NONE),
Tom Warren61c6d0e2012-12-11 13:34:15 +000099 MASK_BITS_31_29},
Tom Warren795f9d72013-01-23 14:01:01 -0700100 { CLK(PERIPH), CLK(CGENERAL), CLK(SFROM32KHZ), CLK(OSC),
101 CLK(NONE), CLK(NONE), CLK(NONE), CLK(NONE),
Stephen Warren510c0ae2014-01-24 10:16:18 -0700102 MASK_BITS_31_28}
Tom Warren61c6d0e2012-12-11 13:34:15 +0000103};
104
Tom Warren61c6d0e2012-12-11 13:34:15 +0000105/*
106 * Clock type for each peripheral clock source. We put the name in each
107 * record just so it is easy to match things up
108 */
109#define TYPE(name, type) type
110static enum clock_type_id clock_periph_type[PERIPHC_COUNT] = {
111 /* 0x00 */
112 TYPE(PERIPHC_I2S1, CLOCK_TYPE_AXPT),
Tom Warren795f9d72013-01-23 14:01:01 -0700113 TYPE(PERIPHC_I2S2, CLOCK_TYPE_AXPT),
114 TYPE(PERIPHC_SPDIF_OUT, CLOCK_TYPE_AXPT),
115 TYPE(PERIPHC_SPDIF_IN, CLOCK_TYPE_PCM),
116 TYPE(PERIPHC_PWM, CLOCK_TYPE_PCST), /* only PWM uses b29:28 */
117 TYPE(PERIPHC_NONE, CLOCK_TYPE_NONE),
118 TYPE(PERIPHC_SBC2, CLOCK_TYPE_PCMT),
119 TYPE(PERIPHC_SBC3, CLOCK_TYPE_PCMT),
Tom Warren61c6d0e2012-12-11 13:34:15 +0000120
121 /* 0x08 */
Tom Warren795f9d72013-01-23 14:01:01 -0700122 TYPE(PERIPHC_NONE, CLOCK_TYPE_NONE),
123 TYPE(PERIPHC_I2C1, CLOCK_TYPE_PCMT16),
124 TYPE(PERIPHC_DVC_I2C, CLOCK_TYPE_PCMT16),
125 TYPE(PERIPHC_NONE, CLOCK_TYPE_NONE),
126 TYPE(PERIPHC_NONE, CLOCK_TYPE_NONE),
127 TYPE(PERIPHC_SBC1, CLOCK_TYPE_PCMT),
128 TYPE(PERIPHC_DISP1, CLOCK_TYPE_PMDACD2T),
129 TYPE(PERIPHC_DISP2, CLOCK_TYPE_PMDACD2T),
Tom Warren61c6d0e2012-12-11 13:34:15 +0000130
131 /* 0x10 */
Tom Warren795f9d72013-01-23 14:01:01 -0700132 TYPE(PERIPHC_CVE, CLOCK_TYPE_PDCT),
133 TYPE(PERIPHC_NONE, CLOCK_TYPE_NONE),
Tom Warren61c6d0e2012-12-11 13:34:15 +0000134 TYPE(PERIPHC_VI, CLOCK_TYPE_MCPA),
Tom Warren795f9d72013-01-23 14:01:01 -0700135 TYPE(PERIPHC_NONE, CLOCK_TYPE_NONE),
136 TYPE(PERIPHC_SDMMC1, CLOCK_TYPE_PCMT),
Tom Warren61c6d0e2012-12-11 13:34:15 +0000137 TYPE(PERIPHC_SDMMC2, CLOCK_TYPE_PCMT),
138 TYPE(PERIPHC_G3D, CLOCK_TYPE_MCPA),
139 TYPE(PERIPHC_G2D, CLOCK_TYPE_MCPA),
140
141 /* 0x18 */
142 TYPE(PERIPHC_NDFLASH, CLOCK_TYPE_PCMT),
143 TYPE(PERIPHC_SDMMC4, CLOCK_TYPE_PCMT),
Tom Warren795f9d72013-01-23 14:01:01 -0700144 TYPE(PERIPHC_VFIR, CLOCK_TYPE_PCMT),
145 TYPE(PERIPHC_EPP, CLOCK_TYPE_MCPA),
146 TYPE(PERIPHC_MPE, CLOCK_TYPE_MCPA),
147 TYPE(PERIPHC_MIPI, CLOCK_TYPE_PCMT), /* MIPI base-band HSI */
148 TYPE(PERIPHC_UART1, CLOCK_TYPE_PCMT),
149 TYPE(PERIPHC_UART2, CLOCK_TYPE_PCMT),
Tom Warren61c6d0e2012-12-11 13:34:15 +0000150
151 /* 0x20 */
Tom Warren795f9d72013-01-23 14:01:01 -0700152 TYPE(PERIPHC_HOST1X, CLOCK_TYPE_MCPA),
153 TYPE(PERIPHC_NONE, CLOCK_TYPE_NONE),
154 TYPE(PERIPHC_TVO, CLOCK_TYPE_PDCT),
155 TYPE(PERIPHC_HDMI, CLOCK_TYPE_PMDACD2T),
156 TYPE(PERIPHC_NONE, CLOCK_TYPE_NONE),
157 TYPE(PERIPHC_TVDAC, CLOCK_TYPE_PDCT),
158 TYPE(PERIPHC_I2C2, CLOCK_TYPE_PCMT16),
Tom Warren61c6d0e2012-12-11 13:34:15 +0000159 TYPE(PERIPHC_EMC, CLOCK_TYPE_MCPT),
160
161 /* 0x28 */
162 TYPE(PERIPHC_UART3, CLOCK_TYPE_PCMT),
163 TYPE(PERIPHC_NONE, CLOCK_TYPE_NONE),
164 TYPE(PERIPHC_VI, CLOCK_TYPE_MCPA),
Tom Warren795f9d72013-01-23 14:01:01 -0700165 TYPE(PERIPHC_NONE, CLOCK_TYPE_NONE),
166 TYPE(PERIPHC_NONE, CLOCK_TYPE_NONE),
167 TYPE(PERIPHC_SBC4, CLOCK_TYPE_PCMT),
168 TYPE(PERIPHC_I2C3, CLOCK_TYPE_PCMT16),
169 TYPE(PERIPHC_SDMMC3, CLOCK_TYPE_PCMT),
Tom Warren61c6d0e2012-12-11 13:34:15 +0000170
171 /* 0x30 */
172 TYPE(PERIPHC_UART4, CLOCK_TYPE_PCMT),
173 TYPE(PERIPHC_UART5, CLOCK_TYPE_PCMT),
174 TYPE(PERIPHC_VDE, CLOCK_TYPE_PCMT),
Tom Warren795f9d72013-01-23 14:01:01 -0700175 TYPE(PERIPHC_OWR, CLOCK_TYPE_PCMT),
176 TYPE(PERIPHC_NOR, CLOCK_TYPE_PCMT),
177 TYPE(PERIPHC_CSITE, CLOCK_TYPE_PCMT),
178 TYPE(PERIPHC_I2S0, CLOCK_TYPE_AXPT),
179 TYPE(PERIPHC_NONE, CLOCK_TYPE_NONE),
Tom Warren61c6d0e2012-12-11 13:34:15 +0000180
Tom Warren795f9d72013-01-23 14:01:01 -0700181 /* 0x38h */ /* Jumps to reg offset 0x3B0h - new for T30 */
182 TYPE(PERIPHC_G3D2, CLOCK_TYPE_MCPA),
183 TYPE(PERIPHC_MSELECT, CLOCK_TYPE_PCMT),
184 TYPE(PERIPHC_TSENSOR, CLOCK_TYPE_PCST), /* s/b PCTS */
185 TYPE(PERIPHC_I2S3, CLOCK_TYPE_AXPT),
186 TYPE(PERIPHC_I2S4, CLOCK_TYPE_AXPT),
187 TYPE(PERIPHC_I2C4, CLOCK_TYPE_PCMT16),
188 TYPE(PERIPHC_SBC5, CLOCK_TYPE_PCMT),
189 TYPE(PERIPHC_SBC6, CLOCK_TYPE_PCMT),
Tom Warren61c6d0e2012-12-11 13:34:15 +0000190
191 /* 0x40 */
Tom Warren795f9d72013-01-23 14:01:01 -0700192 TYPE(PERIPHC_AUDIO, CLOCK_TYPE_ACPT),
193 TYPE(PERIPHC_NONE, CLOCK_TYPE_NONE),
194 TYPE(PERIPHC_DAM0, CLOCK_TYPE_ACPT),
195 TYPE(PERIPHC_DAM1, CLOCK_TYPE_ACPT),
196 TYPE(PERIPHC_DAM2, CLOCK_TYPE_ACPT),
Tom Warren61c6d0e2012-12-11 13:34:15 +0000197 TYPE(PERIPHC_HDA2CODEC2X, CLOCK_TYPE_PCMT),
Tom Warren795f9d72013-01-23 14:01:01 -0700198 TYPE(PERIPHC_ACTMON, CLOCK_TYPE_PCST), /* MASK 31:30 */
Tom Warren61c6d0e2012-12-11 13:34:15 +0000199 TYPE(PERIPHC_EXTPERIPH1, CLOCK_TYPE_ASPTE),
200
201 /* 0x48 */
202 TYPE(PERIPHC_EXTPERIPH2, CLOCK_TYPE_ASPTE),
203 TYPE(PERIPHC_EXTPERIPH3, CLOCK_TYPE_ASPTE),
Tom Warren795f9d72013-01-23 14:01:01 -0700204 TYPE(PERIPHC_NANDSPEED, CLOCK_TYPE_PCMT),
205 TYPE(PERIPHC_I2CSLOW, CLOCK_TYPE_PCST), /* MASK 31:30 */
206 TYPE(PERIPHC_SYS, CLOCK_TYPE_NONE),
207 TYPE(PERIPHC_SPEEDO, CLOCK_TYPE_PCMT),
208 TYPE(PERIPHC_NONE, CLOCK_TYPE_NONE),
209 TYPE(PERIPHC_NONE, CLOCK_TYPE_NONE),
Tom Warren61c6d0e2012-12-11 13:34:15 +0000210
211 /* 0x50 */
Tom Warren795f9d72013-01-23 14:01:01 -0700212 TYPE(PERIPHC_NONE, CLOCK_TYPE_NONE),
213 TYPE(PERIPHC_NONE, CLOCK_TYPE_NONE),
214 TYPE(PERIPHC_NONE, CLOCK_TYPE_NONE),
215 TYPE(PERIPHC_NONE, CLOCK_TYPE_NONE),
216 TYPE(PERIPHC_SATAOOB, CLOCK_TYPE_PCMT), /* offset 0x420h */
217 TYPE(PERIPHC_SATA, CLOCK_TYPE_PCMT),
218 TYPE(PERIPHC_HDA, CLOCK_TYPE_PCMT),
Tom Warren61c6d0e2012-12-11 13:34:15 +0000219};
220
221/*
222 * This array translates a periph_id to a periphc_internal_id
223 *
224 * Not present/matched up:
225 * uint vi_sensor; _VI_SENSOR_0, 0x1A8
226 * SPDIF - which is both 0x08 and 0x0c
227 *
228 */
229#define NONE(name) (-1)
230#define OFFSET(name, value) PERIPHC_ ## name
231static s8 periph_id_to_internal_id[PERIPH_ID_COUNT] = {
232 /* Low word: 31:0 */
233 NONE(CPU),
234 NONE(COP),
235 NONE(TRIGSYS),
236 NONE(RESERVED3),
237 NONE(RESERVED4),
238 NONE(TMR),
239 PERIPHC_UART1,
Tom Warren795f9d72013-01-23 14:01:01 -0700240 PERIPHC_UART2, /* and vfir 0x68 */
Tom Warren61c6d0e2012-12-11 13:34:15 +0000241
242 /* 8 */
243 NONE(GPIO),
244 PERIPHC_SDMMC2,
Tom Warren795f9d72013-01-23 14:01:01 -0700245 NONE(SPDIF), /* 0x08 and 0x0c, unclear which to use */
Tom Warren61c6d0e2012-12-11 13:34:15 +0000246 PERIPHC_I2S1,
247 PERIPHC_I2C1,
248 PERIPHC_NDFLASH,
249 PERIPHC_SDMMC1,
250 PERIPHC_SDMMC4,
251
252 /* 16 */
253 NONE(RESERVED16),
254 PERIPHC_PWM,
255 PERIPHC_I2S2,
256 PERIPHC_EPP,
257 PERIPHC_VI,
258 PERIPHC_G2D,
259 NONE(USBD),
260 NONE(ISP),
261
262 /* 24 */
263 PERIPHC_G3D,
264 NONE(RESERVED25),
265 PERIPHC_DISP2,
266 PERIPHC_DISP1,
267 PERIPHC_HOST1X,
268 NONE(VCP),
269 PERIPHC_I2S0,
270 NONE(CACHE2),
271
272 /* Middle word: 63:32 */
273 NONE(MEM),
274 NONE(AHBDMA),
275 NONE(APBDMA),
276 NONE(RESERVED35),
277 NONE(RESERVED36),
278 NONE(STAT_MON),
279 NONE(RESERVED38),
280 NONE(RESERVED39),
281
282 /* 40 */
283 NONE(KFUSE),
Allen Martin3f419f82013-01-29 13:51:25 +0000284 PERIPHC_SBC1,
Tom Warren61c6d0e2012-12-11 13:34:15 +0000285 PERIPHC_NOR,
286 NONE(RESERVED43),
287 PERIPHC_SBC2,
288 NONE(RESERVED45),
289 PERIPHC_SBC3,
290 PERIPHC_DVC_I2C,
291
292 /* 48 */
293 NONE(DSI),
Tom Warren795f9d72013-01-23 14:01:01 -0700294 PERIPHC_TVO, /* also CVE 0x40 */
Tom Warren61c6d0e2012-12-11 13:34:15 +0000295 PERIPHC_MIPI,
296 PERIPHC_HDMI,
297 NONE(CSI),
298 PERIPHC_TVDAC,
299 PERIPHC_I2C2,
300 PERIPHC_UART3,
301
302 /* 56 */
303 NONE(RESERVED56),
304 PERIPHC_EMC,
305 NONE(USB2),
306 NONE(USB3),
307 PERIPHC_MPE,
308 PERIPHC_VDE,
309 NONE(BSEA),
310 NONE(BSEV),
311
312 /* Upper word 95:64 */
313 PERIPHC_SPEEDO,
314 PERIPHC_UART4,
315 PERIPHC_UART5,
316 PERIPHC_I2C3,
317 PERIPHC_SBC4,
318 PERIPHC_SDMMC3,
319 NONE(PCIE),
320 PERIPHC_OWR,
321
322 /* 72 */
323 NONE(AFI),
324 PERIPHC_CSITE,
325 NONE(PCIEXCLK),
326 NONE(AVPUCQ),
327 NONE(RESERVED76),
328 NONE(RESERVED77),
329 NONE(RESERVED78),
330 NONE(DTV),
331
332 /* 80 */
333 PERIPHC_NANDSPEED,
334 PERIPHC_I2CSLOW,
335 NONE(DSIB),
336 NONE(RESERVED83),
337 NONE(IRAMA),
338 NONE(IRAMB),
339 NONE(IRAMC),
340 NONE(IRAMD),
341
342 /* 88 */
343 NONE(CRAM2),
344 NONE(RESERVED89),
345 NONE(MDOUBLER),
346 NONE(RESERVED91),
347 NONE(SUSOUT),
348 NONE(RESERVED93),
349 NONE(RESERVED94),
350 NONE(RESERVED95),
351
352 /* V word: 31:0 */
353 NONE(CPUG),
354 NONE(CPULP),
355 PERIPHC_G3D2,
356 PERIPHC_MSELECT,
357 PERIPHC_TSENSOR,
358 PERIPHC_I2S3,
359 PERIPHC_I2S4,
360 PERIPHC_I2C4,
361
362 /* 08 */
363 PERIPHC_SBC5,
364 PERIPHC_SBC6,
365 PERIPHC_AUDIO,
366 NONE(APBIF),
367 PERIPHC_DAM0,
368 PERIPHC_DAM1,
369 PERIPHC_DAM2,
370 PERIPHC_HDA2CODEC2X,
371
372 /* 16 */
373 NONE(ATOMICS),
374 NONE(RESERVED17),
375 NONE(RESERVED18),
376 NONE(RESERVED19),
377 NONE(RESERVED20),
378 NONE(RESERVED21),
379 NONE(RESERVED22),
380 PERIPHC_ACTMON,
381
382 /* 24 */
Svyatoslav Ryheld956f352023-02-14 19:35:23 +0200383 PERIPHC_EXTPERIPH1,
384 PERIPHC_EXTPERIPH2,
385 PERIPHC_EXTPERIPH3,
Tom Warren61c6d0e2012-12-11 13:34:15 +0000386 NONE(RESERVED27),
387 PERIPHC_SATA,
388 PERIPHC_HDA,
389 NONE(RESERVED30),
390 NONE(RESERVED31),
391
392 /* W word: 31:0 */
393 NONE(HDA2HDMICODEC),
394 NONE(SATACOLD),
395 NONE(RESERVED0_PCIERX0),
396 NONE(RESERVED1_PCIERX1),
397 NONE(RESERVED2_PCIERX2),
398 NONE(RESERVED3_PCIERX3),
399 NONE(RESERVED4_PCIERX4),
400 NONE(RESERVED5_PCIERX5),
401
402 /* 40 */
403 NONE(CEC),
404 NONE(RESERVED6_PCIE2),
405 NONE(RESERVED7_EMC),
406 NONE(RESERVED8_HDMI),
407 NONE(RESERVED9_SATA),
408 NONE(RESERVED10_MIPI),
409 NONE(EX_RESERVED46),
410 NONE(EX_RESERVED47),
411};
412
413/*
Tom Warrena8480ef2015-06-25 09:50:44 -0700414 * PLL divider shift/mask tables for all PLL IDs.
415 */
416struct clk_pll_info tegra_pll_info_table[CLOCK_ID_PLL_COUNT] = {
417 /*
418 * T30: some deviations from T2x.
419 * NOTE: If kcp_mask/kvco_mask == 0, they're not used in that PLL (PLLX, etc.)
420 * If lock_ena or lock_det are >31, they're not used in that PLL.
421 */
422
423 { .m_shift = 0, .m_mask = 0xFF, .n_shift = 8, .n_mask = 0x3FF, .p_shift = 20, .p_mask = 0x0F,
424 .lock_ena = 24, .lock_det = 27, .kcp_shift = 28, .kcp_mask = 3, .kvco_shift = 27, .kvco_mask = 1 }, /* PLLC */
425 { .m_shift = 0, .m_mask = 0xFF, .n_shift = 8, .n_mask = 0x3FF, .p_shift = 0, .p_mask = 0,
426 .lock_ena = 0, .lock_det = 27, .kcp_shift = 1, .kcp_mask = 3, .kvco_shift = 0, .kvco_mask = 1 }, /* PLLM */
427 { .m_shift = 0, .m_mask = 0x1F, .n_shift = 8, .n_mask = 0x3FF, .p_shift = 20, .p_mask = 0x07,
428 .lock_ena = 18, .lock_det = 27, .kcp_shift = 8, .kcp_mask = 0xF, .kvco_shift = 4, .kvco_mask = 0xF }, /* PLLP */
429 { .m_shift = 0, .m_mask = 0x1F, .n_shift = 8, .n_mask = 0x3FF, .p_shift = 20, .p_mask = 0x07,
430 .lock_ena = 18, .lock_det = 27, .kcp_shift = 8, .kcp_mask = 0xF, .kvco_shift = 4, .kvco_mask = 0xF }, /* PLLA */
431 { .m_shift = 0, .m_mask = 0x1F, .n_shift = 8, .n_mask = 0x3FF, .p_shift = 20, .p_mask = 0x01,
432 .lock_ena = 22, .lock_det = 27, .kcp_shift = 8, .kcp_mask = 0xF, .kvco_shift = 4, .kvco_mask = 0xF }, /* PLLU */
433 { .m_shift = 0, .m_mask = 0x1F, .n_shift = 8, .n_mask = 0x3FF, .p_shift = 20, .p_mask = 0x07,
434 .lock_ena = 22, .lock_det = 27, .kcp_shift = 8, .kcp_mask = 0xF, .kvco_shift = 4, .kvco_mask = 0xF }, /* PLLD */
435 { .m_shift = 0, .m_mask = 0xFF, .n_shift = 8, .n_mask = 0xFF, .p_shift = 20, .p_mask = 0x0F,
436 .lock_ena = 18, .lock_det = 27, .kcp_shift = 8, .kcp_mask = 0xF, .kvco_shift = 0, .kvco_mask = 0 }, /* PLLX */
437 { .m_shift = 0, .m_mask = 0xFF, .n_shift = 8, .n_mask = 0xFF, .p_shift = 0, .p_mask = 0,
438 .lock_ena = 9, .lock_det = 11, .kcp_shift = 6, .kcp_mask = 3, .kvco_shift = 0, .kvco_mask = 1 }, /* PLLE */
439 { .m_shift = 0, .m_mask = 0x0F, .n_shift = 8, .n_mask = 0x3FF, .p_shift = 20, .p_mask = 0x07,
440 .lock_ena = 18, .lock_det = 27, .kcp_shift = 8, .kcp_mask = 0xF, .kvco_shift = 4, .kvco_mask = 0xF }, /* PLLS (RESERVED) */
441};
442
443/*
Tom Warren61c6d0e2012-12-11 13:34:15 +0000444 * Get the oscillator frequency, from the corresponding hardware configuration
Svyatoslav Ryhel7f4ab332023-02-01 10:53:01 +0200445 * field. Note that T30+ supports 3 new higher freqs.
Tom Warren61c6d0e2012-12-11 13:34:15 +0000446 */
447enum clock_osc_freq clock_get_osc_freq(void)
448{
449 struct clk_rst_ctlr *clkrst =
450 (struct clk_rst_ctlr *)NV_PA_CLK_RST_BASE;
451 u32 reg;
452
453 reg = readl(&clkrst->crc_osc_ctrl);
Svyatoslav Ryhel7f4ab332023-02-01 10:53:01 +0200454 return (reg & OSC_FREQ_MASK) >> OSC_FREQ_SHIFT;
Tom Warren61c6d0e2012-12-11 13:34:15 +0000455}
456
457/* Returns a pointer to the clock source register for a peripheral */
Tom Warren795f9d72013-01-23 14:01:01 -0700458u32 *get_periph_source_reg(enum periph_id periph_id)
Tom Warren61c6d0e2012-12-11 13:34:15 +0000459{
460 struct clk_rst_ctlr *clkrst =
Tom Warren795f9d72013-01-23 14:01:01 -0700461 (struct clk_rst_ctlr *)NV_PA_CLK_RST_BASE;
Tom Warren61c6d0e2012-12-11 13:34:15 +0000462 enum periphc_internal_id internal_id;
463
464 /* Coresight is a special case */
465 if (periph_id == PERIPH_ID_CSI)
466 return &clkrst->crc_clk_src[PERIPH_ID_CSI+1];
467
468 assert(periph_id >= PERIPH_ID_FIRST && periph_id < PERIPH_ID_COUNT);
469 internal_id = periph_id_to_internal_id[periph_id];
470 assert(internal_id != -1);
471 if (internal_id >= PERIPHC_VW_FIRST) {
472 internal_id -= PERIPHC_VW_FIRST;
473 return &clkrst->crc_clk_src_vw[internal_id];
474 } else
475 return &clkrst->crc_clk_src[internal_id];
476}
477
Stephen Warren532543c2016-09-13 10:45:56 -0600478int get_periph_clock_info(enum periph_id periph_id, int *mux_bits,
479 int *divider_bits, int *type)
480{
481 enum periphc_internal_id internal_id;
482
483 if (!clock_periph_id_isvalid(periph_id))
484 return -1;
485
486 internal_id = periph_id_to_internal_id[periph_id];
487 if (!periphc_internal_id_isvalid(internal_id))
488 return -1;
489
490 *type = clock_periph_type[internal_id];
491 if (!clock_type_id_isvalid(*type))
492 return -1;
493
494 *mux_bits = clock_source[*type][CLOCK_MAX_MUX];
495
496 if (*type == CLOCK_TYPE_PCMT16)
497 *divider_bits = 16;
498 else
499 *divider_bits = 8;
500
501 return 0;
502}
503
504enum clock_id get_periph_clock_id(enum periph_id periph_id, int source)
505{
506 enum periphc_internal_id internal_id;
507 int type;
508
509 if (!clock_periph_id_isvalid(periph_id))
510 return CLOCK_ID_NONE;
511
512 internal_id = periph_id_to_internal_id[periph_id];
513 if (!periphc_internal_id_isvalid(internal_id))
514 return CLOCK_ID_NONE;
515
516 type = clock_periph_type[internal_id];
517 if (!clock_type_id_isvalid(type))
518 return CLOCK_ID_NONE;
519
520 return clock_source[type][source];
521}
522
Tom Warren61c6d0e2012-12-11 13:34:15 +0000523/**
524 * Given a peripheral ID and the required source clock, this returns which
525 * value should be programmed into the source mux for that peripheral.
526 *
527 * There is special code here to handle the one source type with 5 sources.
528 *
529 * @param periph_id peripheral to start
530 * @param source PLL id of required parent clock
531 * @param mux_bits Set to number of bits in mux register: 2 or 4
Tom Warren795f9d72013-01-23 14:01:01 -0700532 * @param divider_bits Set to number of divider bits (8 or 16)
Heinrich Schuchardt47b4c022022-01-19 18:05:50 +0100533 * Return: mux value (0-4, or -1 if not found)
Tom Warren61c6d0e2012-12-11 13:34:15 +0000534 */
Tom Warren795f9d72013-01-23 14:01:01 -0700535int get_periph_clock_source(enum periph_id periph_id,
536 enum clock_id parent, int *mux_bits, int *divider_bits)
Tom Warren61c6d0e2012-12-11 13:34:15 +0000537{
538 enum clock_type_id type;
Stephen Warren532543c2016-09-13 10:45:56 -0600539 int mux, err;
Tom Warren61c6d0e2012-12-11 13:34:15 +0000540
Stephen Warren532543c2016-09-13 10:45:56 -0600541 err = get_periph_clock_info(periph_id, mux_bits, divider_bits, &type);
542 assert(!err);
Tom Warrenea226042012-12-21 15:02:45 -0700543
Tom Warren61c6d0e2012-12-11 13:34:15 +0000544 for (mux = 0; mux < CLOCK_MAX_MUX; mux++)
545 if (clock_source[type][mux] == parent)
546 return mux;
547
548 /* if we get here, either us or the caller has made a mistake */
549 printf("Caller requested bad clock: periph=%d, parent=%d\n", periph_id,
550 parent);
551 return -1;
552}
553
Tom Warren61c6d0e2012-12-11 13:34:15 +0000554void clock_set_enable(enum periph_id periph_id, int enable)
555{
556 struct clk_rst_ctlr *clkrst =
557 (struct clk_rst_ctlr *)NV_PA_CLK_RST_BASE;
558 u32 *clk;
559 u32 reg;
560
561 /* Enable/disable the clock to this peripheral */
562 assert(clock_periph_id_isvalid(periph_id));
563 if ((int)periph_id < (int)PERIPH_ID_VW_FIRST)
564 clk = &clkrst->crc_clk_out_enb[PERIPH_REG(periph_id)];
565 else
566 clk = &clkrst->crc_clk_out_enb_vw[PERIPH_REG(periph_id)];
567 reg = readl(clk);
568 if (enable)
569 reg |= PERIPH_MASK(periph_id);
570 else
571 reg &= ~PERIPH_MASK(periph_id);
572 writel(reg, clk);
573}
574
Tom Warren61c6d0e2012-12-11 13:34:15 +0000575void reset_set_enable(enum periph_id periph_id, int enable)
576{
577 struct clk_rst_ctlr *clkrst =
578 (struct clk_rst_ctlr *)NV_PA_CLK_RST_BASE;
579 u32 *reset;
580 u32 reg;
581
582 /* Enable/disable reset to the peripheral */
583 assert(clock_periph_id_isvalid(periph_id));
584 if (periph_id < PERIPH_ID_VW_FIRST)
585 reset = &clkrst->crc_rst_dev[PERIPH_REG(periph_id)];
586 else
587 reset = &clkrst->crc_rst_dev_vw[PERIPH_REG(periph_id)];
588 reg = readl(reset);
589 if (enable)
590 reg |= PERIPH_MASK(periph_id);
591 else
592 reg &= ~PERIPH_MASK(periph_id);
593 writel(reg, reset);
594}
595
Masahiro Yamada366b24f2015-08-12 07:31:55 +0900596#if CONFIG_IS_ENABLED(OF_CONTROL)
Tom Warren61c6d0e2012-12-11 13:34:15 +0000597/*
598 * Convert a device tree clock ID to our peripheral ID. They are mostly
599 * the same but we are very cautious so we check that a valid clock ID is
600 * provided.
601 *
Tom Warrenea226042012-12-21 15:02:45 -0700602 * @param clk_id Clock ID according to tegra30 device tree binding
Heinrich Schuchardt47b4c022022-01-19 18:05:50 +0100603 * Return: peripheral ID, or PERIPH_ID_NONE if the clock ID is invalid
Tom Warren61c6d0e2012-12-11 13:34:15 +0000604 */
Tom Warren795f9d72013-01-23 14:01:01 -0700605enum periph_id clk_id_to_periph_id(int clk_id)
Tom Warren61c6d0e2012-12-11 13:34:15 +0000606{
Tom Warrenea226042012-12-21 15:02:45 -0700607 if (clk_id > PERIPH_ID_COUNT)
Tom Warren61c6d0e2012-12-11 13:34:15 +0000608 return PERIPH_ID_NONE;
609
610 switch (clk_id) {
Tom Warrenea226042012-12-21 15:02:45 -0700611 case PERIPH_ID_RESERVED3:
612 case PERIPH_ID_RESERVED4:
613 case PERIPH_ID_RESERVED16:
614 case PERIPH_ID_RESERVED24:
615 case PERIPH_ID_RESERVED35:
616 case PERIPH_ID_RESERVED43:
617 case PERIPH_ID_RESERVED45:
618 case PERIPH_ID_RESERVED56:
Thierry Reding289fc682014-12-09 22:25:07 -0700619 case PERIPH_ID_PCIEXCLK:
Tom Warrenea226042012-12-21 15:02:45 -0700620 case PERIPH_ID_RESERVED76:
621 case PERIPH_ID_RESERVED77:
622 case PERIPH_ID_RESERVED78:
623 case PERIPH_ID_RESERVED83:
624 case PERIPH_ID_RESERVED89:
625 case PERIPH_ID_RESERVED91:
626 case PERIPH_ID_RESERVED93:
627 case PERIPH_ID_RESERVED94:
628 case PERIPH_ID_RESERVED95:
Tom Warren61c6d0e2012-12-11 13:34:15 +0000629 return PERIPH_ID_NONE;
630 default:
631 return clk_id;
632 }
633}
Svyatoslav Ryhel19a5b032023-02-14 19:35:25 +0200634
635/*
636 * Convert a device tree clock ID to our PLL ID.
637 *
638 * @param clk_id Clock ID according to tegra30 device tree binding
639 * Return: clock ID, or CLOCK_ID_NONE if the clock ID is invalid
640 */
641enum clock_id clk_id_to_pll_id(int clk_id)
642{
643 switch (clk_id) {
644 case TEGRA30_CLK_PLL_C:
645 return CLOCK_ID_CGENERAL;
646 case TEGRA30_CLK_PLL_M:
647 return CLOCK_ID_MEMORY;
648 case TEGRA30_CLK_PLL_P:
649 return CLOCK_ID_PERIPH;
650 case TEGRA30_CLK_PLL_A:
651 return CLOCK_ID_AUDIO;
652 case TEGRA30_CLK_PLL_U:
653 return CLOCK_ID_USB;
654 case TEGRA30_CLK_PLL_D:
655 case TEGRA30_CLK_PLL_D_OUT0:
656 return CLOCK_ID_DISPLAY;
657 case TEGRA30_CLK_PLL_X:
658 return CLOCK_ID_XCPU;
659 case TEGRA30_CLK_PLL_E:
660 return CLOCK_ID_EPCI;
661 case TEGRA30_CLK_CLK_32K:
662 return CLOCK_ID_32KHZ;
663 case TEGRA30_CLK_CLK_M:
664 return CLOCK_ID_CLK_M;
665 default:
666 return CLOCK_ID_NONE;
667 }
668}
Masahiro Yamada366b24f2015-08-12 07:31:55 +0900669#endif /* CONFIG_IS_ENABLED(OF_CONTROL) */
Tom Warren61c6d0e2012-12-11 13:34:15 +0000670
Tom Warren61c6d0e2012-12-11 13:34:15 +0000671void clock_early_init(void)
672{
Svyatoslav Ryhel7646ba52023-02-14 19:35:27 +0200673 struct clk_rst_ctlr *clkrst =
674 (struct clk_rst_ctlr *)NV_PA_CLK_RST_BASE;
675 struct clk_pll_info *pllinfo;
676 u32 data;
677
Jimmy Zhang2a544db2014-01-24 10:37:36 -0700678 tegra30_set_up_pllp();
Svyatoslav Ryhel7646ba52023-02-14 19:35:27 +0200679
680 /*
681 * PLLD output frequency set to 925Mhz
682 */
683 switch (clock_get_osc_freq()) {
684 case CLOCK_OSC_FREQ_12_0: /* OSC is 12Mhz */
685 case CLOCK_OSC_FREQ_48_0: /* OSC is 48Mhz */
686 clock_set_rate(CLOCK_ID_DISPLAY, 925, 12, 0, 12);
687 break;
688
689 case CLOCK_OSC_FREQ_26_0: /* OSC is 26Mhz */
690 clock_set_rate(CLOCK_ID_DISPLAY, 925, 26, 0, 12);
691 break;
692
693 case CLOCK_OSC_FREQ_13_0: /* OSC is 13Mhz */
694 case CLOCK_OSC_FREQ_16_8: /* OSC is 16.8Mhz */
695 clock_set_rate(CLOCK_ID_DISPLAY, 925, 13, 0, 12);
696 break;
697
698 case CLOCK_OSC_FREQ_19_2:
699 case CLOCK_OSC_FREQ_38_4:
700 default:
701 /*
702 * These are not supported. It is too early to print a
703 * message and the UART likely won't work anyway due to the
704 * oscillator being wrong.
705 */
706 break;
707 }
708
709 /* PLLD_MISC: Set CLKENABLE, CPCON 12, LFCON 1, and enable lock */
710 pllinfo = &tegra_pll_info_table[CLOCK_ID_DISPLAY];
711 data = (12 << pllinfo->kcp_shift) | (1 << pllinfo->kvco_shift);
712 data |= (1 << PLLD_CLKENABLE) | (1 << pllinfo->lock_ena);
713 writel(data, &clkrst->crc_pll[CLOCK_ID_DISPLAY].pll_misc);
714 udelay(2);
Tom Warren61c6d0e2012-12-11 13:34:15 +0000715}
Tom Warrenfbef3552013-04-01 15:48:54 -0700716
717void arch_timer_init(void)
718{
719}
Thierry Reding4bf98692014-12-09 22:25:06 -0700720
721#define PMC_SATA_PWRGT 0x1ac
722#define PMC_SATA_PWRGT_PLLE_IDDQ_OVERRIDE (1 << 5)
723#define PMC_SATA_PWRGT_PLLE_IDDQ_SWCTL (1 << 4)
724
725#define PLLE_SS_CNTL 0x68
726#define PLLE_SS_CNTL_SSCINCINTRV(x) (((x) & 0x3f) << 24)
727#define PLLE_SS_CNTL_SSCINC(x) (((x) & 0xff) << 16)
728#define PLLE_SS_CNTL_SSCBYP (1 << 12)
729#define PLLE_SS_CNTL_INTERP_RESET (1 << 11)
730#define PLLE_SS_CNTL_BYPASS_SS (1 << 10)
731#define PLLE_SS_CNTL_SSCMAX(x) (((x) & 0x1ff) << 0)
732
733#define PLLE_BASE 0x0e8
734#define PLLE_BASE_ENABLE_CML (1 << 31)
735#define PLLE_BASE_ENABLE (1 << 30)
736#define PLLE_BASE_PLDIV_CML(x) (((x) & 0xf) << 24)
737#define PLLE_BASE_PLDIV(x) (((x) & 0x3f) << 16)
738#define PLLE_BASE_NDIV(x) (((x) & 0xff) << 8)
739#define PLLE_BASE_MDIV(x) (((x) & 0xff) << 0)
740
741#define PLLE_MISC 0x0ec
742#define PLLE_MISC_SETUP_BASE(x) (((x) & 0xffff) << 16)
743#define PLLE_MISC_PLL_READY (1 << 15)
744#define PLLE_MISC_LOCK (1 << 11)
745#define PLLE_MISC_LOCK_ENABLE (1 << 9)
746#define PLLE_MISC_SETUP_EXT(x) (((x) & 0x3) << 2)
747
748static int tegra_plle_train(void)
749{
750 unsigned int timeout = 2000;
751 unsigned long value;
752
753 value = readl(NV_PA_PMC_BASE + PMC_SATA_PWRGT);
754 value |= PMC_SATA_PWRGT_PLLE_IDDQ_OVERRIDE;
755 writel(value, NV_PA_PMC_BASE + PMC_SATA_PWRGT);
756
757 value = readl(NV_PA_PMC_BASE + PMC_SATA_PWRGT);
758 value |= PMC_SATA_PWRGT_PLLE_IDDQ_SWCTL;
759 writel(value, NV_PA_PMC_BASE + PMC_SATA_PWRGT);
760
761 value = readl(NV_PA_PMC_BASE + PMC_SATA_PWRGT);
762 value &= ~PMC_SATA_PWRGT_PLLE_IDDQ_OVERRIDE;
763 writel(value, NV_PA_PMC_BASE + PMC_SATA_PWRGT);
764
765 do {
766 value = readl(NV_PA_CLK_RST_BASE + PLLE_MISC);
767 if (value & PLLE_MISC_PLL_READY)
768 break;
769
770 udelay(100);
771 } while (--timeout);
772
773 if (timeout == 0) {
Masahiro Yamada81e10422017-09-16 14:10:41 +0900774 pr_err("timeout waiting for PLLE to become ready");
Thierry Reding4bf98692014-12-09 22:25:06 -0700775 return -ETIMEDOUT;
776 }
777
778 return 0;
779}
780
781int tegra_plle_enable(void)
782{
783 unsigned int cpcon = 11, p = 18, n = 150, m = 1, timeout = 1000;
784 u32 value;
785 int err;
786
787 /* disable PLLE clock */
788 value = readl(NV_PA_CLK_RST_BASE + PLLE_BASE);
789 value &= ~PLLE_BASE_ENABLE_CML;
790 value &= ~PLLE_BASE_ENABLE;
791 writel(value, NV_PA_CLK_RST_BASE + PLLE_BASE);
792
793 /* clear lock enable and setup field */
794 value = readl(NV_PA_CLK_RST_BASE + PLLE_MISC);
795 value &= ~PLLE_MISC_LOCK_ENABLE;
796 value &= ~PLLE_MISC_SETUP_BASE(0xffff);
797 value &= ~PLLE_MISC_SETUP_EXT(0x3);
798 writel(value, NV_PA_CLK_RST_BASE + PLLE_MISC);
799
800 value = readl(NV_PA_CLK_RST_BASE + PLLE_MISC);
801 if ((value & PLLE_MISC_PLL_READY) == 0) {
802 err = tegra_plle_train();
803 if (err < 0) {
Masahiro Yamada81e10422017-09-16 14:10:41 +0900804 pr_err("failed to train PLLE: %d", err);
Thierry Reding4bf98692014-12-09 22:25:06 -0700805 return err;
806 }
807 }
808
809 /* configure PLLE */
810 value = readl(NV_PA_CLK_RST_BASE + PLLE_BASE);
811
812 value &= ~PLLE_BASE_PLDIV_CML(0x0f);
813 value |= PLLE_BASE_PLDIV_CML(cpcon);
814
815 value &= ~PLLE_BASE_PLDIV(0x3f);
816 value |= PLLE_BASE_PLDIV(p);
817
818 value &= ~PLLE_BASE_NDIV(0xff);
819 value |= PLLE_BASE_NDIV(n);
820
821 value &= ~PLLE_BASE_MDIV(0xff);
822 value |= PLLE_BASE_MDIV(m);
823
824 writel(value, NV_PA_CLK_RST_BASE + PLLE_BASE);
825
826 value = readl(NV_PA_CLK_RST_BASE + PLLE_MISC);
827 value |= PLLE_MISC_SETUP_BASE(0x7);
828 value |= PLLE_MISC_LOCK_ENABLE;
829 value |= PLLE_MISC_SETUP_EXT(0);
830 writel(value, NV_PA_CLK_RST_BASE + PLLE_MISC);
831
832 value = readl(NV_PA_CLK_RST_BASE + PLLE_SS_CNTL);
833 value |= PLLE_SS_CNTL_SSCBYP | PLLE_SS_CNTL_INTERP_RESET |
834 PLLE_SS_CNTL_BYPASS_SS;
835 writel(value, NV_PA_CLK_RST_BASE + PLLE_SS_CNTL);
836
837 value = readl(NV_PA_CLK_RST_BASE + PLLE_BASE);
838 value |= PLLE_BASE_ENABLE_CML | PLLE_BASE_ENABLE;
839 writel(value, NV_PA_CLK_RST_BASE + PLLE_BASE);
840
841 do {
842 value = readl(NV_PA_CLK_RST_BASE + PLLE_MISC);
843 if (value & PLLE_MISC_LOCK)
844 break;
845
846 udelay(2);
847 } while (--timeout);
848
849 if (timeout == 0) {
Masahiro Yamada81e10422017-09-16 14:10:41 +0900850 pr_err("timeout waiting for PLLE to lock");
Thierry Reding4bf98692014-12-09 22:25:06 -0700851 return -ETIMEDOUT;
852 }
853
854 udelay(50);
855
856 value = readl(NV_PA_CLK_RST_BASE + PLLE_SS_CNTL);
857 value &= ~PLLE_SS_CNTL_SSCINCINTRV(0x3f);
858 value |= PLLE_SS_CNTL_SSCINCINTRV(0x18);
859
860 value &= ~PLLE_SS_CNTL_SSCINC(0xff);
861 value |= PLLE_SS_CNTL_SSCINC(0x01);
862
863 value &= ~PLLE_SS_CNTL_SSCBYP;
864 value &= ~PLLE_SS_CNTL_INTERP_RESET;
865 value &= ~PLLE_SS_CNTL_BYPASS_SS;
866
867 value &= ~PLLE_SS_CNTL_SSCMAX(0x1ff);
868 value |= PLLE_SS_CNTL_SSCMAX(0x24);
869 writel(value, NV_PA_CLK_RST_BASE + PLLE_SS_CNTL);
870
871 return 0;
872}
Stephen Warren1453d102016-09-13 10:45:55 -0600873
874struct periph_clk_init periph_clk_init_table[] = {
875 { PERIPH_ID_SBC1, CLOCK_ID_PERIPH },
876 { PERIPH_ID_SBC2, CLOCK_ID_PERIPH },
877 { PERIPH_ID_SBC3, CLOCK_ID_PERIPH },
878 { PERIPH_ID_SBC4, CLOCK_ID_PERIPH },
879 { PERIPH_ID_SBC5, CLOCK_ID_PERIPH },
880 { PERIPH_ID_SBC6, CLOCK_ID_PERIPH },
Svyatoslav Ryhel932ec722023-02-14 19:35:24 +0200881 { PERIPH_ID_HOST1X, CLOCK_ID_CGENERAL },
882 { PERIPH_ID_DISP1, CLOCK_ID_PERIPH },
Stephen Warren1453d102016-09-13 10:45:55 -0600883 { PERIPH_ID_NDFLASH, CLOCK_ID_PERIPH },
884 { PERIPH_ID_SDMMC1, CLOCK_ID_PERIPH },
885 { PERIPH_ID_SDMMC2, CLOCK_ID_PERIPH },
886 { PERIPH_ID_SDMMC3, CLOCK_ID_PERIPH },
887 { PERIPH_ID_SDMMC4, CLOCK_ID_PERIPH },
Svyatoslav Ryhelc226fc72023-02-14 19:35:28 +0200888 { PERIPH_ID_PWM, CLOCK_ID_PERIPH },
Stephen Warren1453d102016-09-13 10:45:55 -0600889 { PERIPH_ID_DVC_I2C, CLOCK_ID_PERIPH },
890 { PERIPH_ID_I2C1, CLOCK_ID_PERIPH },
891 { PERIPH_ID_I2C2, CLOCK_ID_PERIPH },
892 { PERIPH_ID_I2C3, CLOCK_ID_PERIPH },
893 { PERIPH_ID_I2C4, CLOCK_ID_PERIPH },
894 { -1, },
895};