blob: 65b15b79fe9bca6499f360116e2414aa2eb61cf3 [file] [log] [blame]
Tom Rini83d290c2018-05-06 17:58:06 -04001// SPDX-License-Identifier: GPL-2.0
Tom Warren1b245fe2012-12-11 13:34:13 +00002/*
Thierry Redingf9ec2ec2019-04-15 11:32:25 +02003 * Copyright (c) 2010-2019, NVIDIA CORPORATION. All rights reserved.
Tom Warren1b245fe2012-12-11 13:34:13 +00004 */
5
6#include <common.h>
Simon Glassf7ae49f2020-05-10 11:40:05 -06007#include <log.h>
Tom Warren1b245fe2012-12-11 13:34:13 +00008#include <asm/io.h>
9#include <asm/arch/clock.h>
10#include <asm/arch/gp_padctrl.h>
11#include <asm/arch/pinmux.h>
12#include <asm/arch/tegra.h>
13#include <asm/arch-tegra/clk_rst.h>
14#include <asm/arch-tegra/pmc.h>
15#include <asm/arch-tegra/scu.h>
Simon Glassc05ed002020-05-10 11:40:11 -060016#include <linux/delay.h>
Tom Warren1b245fe2012-12-11 13:34:13 +000017#include "cpu.h"
18
Tom Warren1b245fe2012-12-11 13:34:13 +000019int get_num_cpus(void)
20{
Tom Warren4040ec12013-01-28 13:32:08 +000021 struct apb_misc_gp_ctlr *gp;
22 uint rev;
Tom Warren7aaa5a62015-03-04 16:36:00 -070023 debug("%s entry\n", __func__);
Tom Warren4040ec12013-01-28 13:32:08 +000024
25 gp = (struct apb_misc_gp_ctlr *)NV_PA_APB_MISC_GP_BASE;
26 rev = (readl(&gp->hidrev) & HIDREV_CHIPID_MASK) >> HIDREV_CHIPID_SHIFT;
27
28 switch (rev) {
29 case CHIPID_TEGRA20:
30 return 2;
31 break;
32 case CHIPID_TEGRA30:
33 case CHIPID_TEGRA114:
Tom Warren7aaa5a62015-03-04 16:36:00 -070034 case CHIPID_TEGRA124:
35 case CHIPID_TEGRA210:
Tom Warren4040ec12013-01-28 13:32:08 +000036 default:
37 return 4;
38 break;
39 }
Tom Warren1b245fe2012-12-11 13:34:13 +000040}
41
42/*
43 * Timing tables for each SOC for all four oscillator options.
44 */
45struct clk_pll_table tegra_pll_x_table[TEGRA_SOC_CNT][CLOCK_OSC_FREQ_COUNT] = {
Jimmy Zhang44de8e22013-09-23 22:07:49 +020046 /*
47 * T20: 1 GHz
48 *
49 * Register Field Bits Width
50 * ------------------------------
51 * PLLX_BASE p 22:20 3
52 * PLLX_BASE n 17: 8 10
53 * PLLX_BASE m 4: 0 5
54 * PLLX_MISC cpcon 11: 8 4
55 */
56 {
57 { .n = 1000, .m = 13, .p = 0, .cpcon = 12 }, /* OSC: 13.0 MHz */
58 { .n = 625, .m = 12, .p = 0, .cpcon = 8 }, /* OSC: 19.2 MHz */
59 { .n = 1000, .m = 12, .p = 0, .cpcon = 12 }, /* OSC: 12.0 MHz */
60 { .n = 1000, .m = 26, .p = 0, .cpcon = 12 }, /* OSC: 26.0 MHz */
Tom Warren3e8650c2015-06-22 13:03:44 -070061 { .n = 0, .m = 0, .p = 0, .cpcon = 0 }, /* OSC: 38.4 MHz (N/A) */
62 { .n = 0, .m = 0, .p = 0, .cpcon = 0 }, /* OSC: 48.0 MHz (N/A) */
Tom Warren1b245fe2012-12-11 13:34:13 +000063 },
Jimmy Zhang44de8e22013-09-23 22:07:49 +020064 /*
65 * T25: 1.2 GHz
66 *
67 * Register Field Bits Width
68 * ------------------------------
69 * PLLX_BASE p 22:20 3
70 * PLLX_BASE n 17: 8 10
71 * PLLX_BASE m 4: 0 5
72 * PLLX_MISC cpcon 11: 8 4
73 */
74 {
75 { .n = 923, .m = 10, .p = 0, .cpcon = 12 }, /* OSC: 13.0 MHz */
76 { .n = 750, .m = 12, .p = 0, .cpcon = 8 }, /* OSC: 19.2 MHz */
77 { .n = 600, .m = 6, .p = 0, .cpcon = 12 }, /* OSC: 12.0 MHz */
78 { .n = 600, .m = 13, .p = 0, .cpcon = 12 }, /* OSC: 26.0 MHz */
Tom Warren3e8650c2015-06-22 13:03:44 -070079 { .n = 0, .m = 0, .p = 0, .cpcon = 0 }, /* OSC: 38.4 MHz (N/A) */
80 { .n = 0, .m = 0, .p = 0, .cpcon = 0 }, /* OSC: 48.0 MHz (N/A) */
Tom Warren1b245fe2012-12-11 13:34:13 +000081 },
Jimmy Zhang44de8e22013-09-23 22:07:49 +020082 /*
Stephen Warren2364e152014-05-08 09:33:45 -060083 * T30: 600 MHz
Jimmy Zhang44de8e22013-09-23 22:07:49 +020084 *
85 * Register Field Bits Width
86 * ------------------------------
87 * PLLX_BASE p 22:20 3
88 * PLLX_BASE n 17: 8 10
89 * PLLX_BASE m 4: 0 5
90 * PLLX_MISC cpcon 11: 8 4
91 */
92 {
Stephen Warren2364e152014-05-08 09:33:45 -060093 { .n = 600, .m = 13, .p = 0, .cpcon = 8 }, /* OSC: 13.0 MHz */
94 { .n = 500, .m = 16, .p = 0, .cpcon = 8 }, /* OSC: 19.2 MHz */
95 { .n = 600, .m = 12, .p = 0, .cpcon = 8 }, /* OSC: 12.0 MHz */
96 { .n = 600, .m = 26, .p = 0, .cpcon = 8 }, /* OSC: 26.0 MHz */
Tom Warren3e8650c2015-06-22 13:03:44 -070097 { .n = 0, .m = 0, .p = 0, .cpcon = 0 }, /* OSC: 38.4 MHz (N/A) */
98 { .n = 0, .m = 0, .p = 0, .cpcon = 0 }, /* OSC: 48.0 MHz (N/A) */
Tom Warren1b245fe2012-12-11 13:34:13 +000099 },
Jimmy Zhang44de8e22013-09-23 22:07:49 +0200100 /*
101 * T114: 700 MHz
102 *
103 * Register Field Bits Width
104 * ------------------------------
105 * PLLX_BASE p 23:20 4
106 * PLLX_BASE n 15: 8 8
107 * PLLX_BASE m 7: 0 8
108 */
109 {
110 { .n = 108, .m = 1, .p = 1 }, /* OSC: 13.0 MHz */
111 { .n = 73, .m = 1, .p = 1 }, /* OSC: 19.2 MHz */
112 { .n = 116, .m = 1, .p = 1 }, /* OSC: 12.0 MHz */
113 { .n = 108, .m = 2, .p = 1 }, /* OSC: 26.0 MHz */
Tom Warren3e8650c2015-06-22 13:03:44 -0700114 { .n = 0, .m = 0, .p = 0 }, /* OSC: 38.4 MHz (N/A) */
115 { .n = 0, .m = 0, .p = 0 }, /* OSC: 48.0 MHz (N/A) */
Tom Warren4040ec12013-01-28 13:32:08 +0000116 },
Tom Warren32edd2e2014-01-24 12:46:14 -0700117
118 /*
119 * T124: 700 MHz
120 *
121 * Register Field Bits Width
122 * ------------------------------
123 * PLLX_BASE p 23:20 4
124 * PLLX_BASE n 15: 8 8
125 * PLLX_BASE m 7: 0 8
126 */
127 {
128 { .n = 108, .m = 1, .p = 1 }, /* OSC: 13.0 MHz */
129 { .n = 73, .m = 1, .p = 1 }, /* OSC: 19.2 MHz */
130 { .n = 116, .m = 1, .p = 1 }, /* OSC: 12.0 MHz */
131 { .n = 108, .m = 2, .p = 1 }, /* OSC: 26.0 MHz */
Tom Warren3e8650c2015-06-22 13:03:44 -0700132 { .n = 0, .m = 0, .p = 0 }, /* OSC: 38.4 MHz (N/A) */
133 { .n = 0, .m = 0, .p = 0 }, /* OSC: 48.0 MHz (N/A) */
Tom Warren32edd2e2014-01-24 12:46:14 -0700134 },
Tom Warren7aaa5a62015-03-04 16:36:00 -0700135
136 /*
137 * T210: 700 MHz
138 *
139 * Register Field Bits Width
140 * ------------------------------
141 * PLLX_BASE p 24:20 5
142 * PLLX_BASE n 15: 8 8
143 * PLLX_BASE m 7: 0 8
144 */
145 {
146 { .n = 108, .m = 1, .p = 1 }, /* OSC: 13.0 MHz = 702 MHz*/
147 { .n = 73, .m = 1, .p = 1 }, /* OSC: 19.2 MHz = 700.8 MHz*/
148 { .n = 116, .m = 1, .p = 1 }, /* OSC: 12.0 MHz = 696 MHz*/
149 { .n = 108, .m = 2, .p = 1 }, /* OSC: 26.0 MHz = 702 MHz*/
Tom Warren3e8650c2015-06-22 13:03:44 -0700150 { .n = 36, .m = 1, .p = 1 }, /* OSC: 38.4 MHz = 691.2 MHz */
151 { .n = 58, .m = 2, .p = 1 }, /* OSC: 48.0 MHz = 696 MHz */
Tom Warren7aaa5a62015-03-04 16:36:00 -0700152 },
Tom Warren1b245fe2012-12-11 13:34:13 +0000153};
154
Tom Warren32edd2e2014-01-24 12:46:14 -0700155static inline void pllx_set_iddq(void)
156{
Tom Warren7aaa5a62015-03-04 16:36:00 -0700157#if defined(CONFIG_TEGRA124) || defined(CONFIG_TEGRA210)
Tom Warren32edd2e2014-01-24 12:46:14 -0700158 struct clk_rst_ctlr *clkrst = (struct clk_rst_ctlr *)NV_PA_CLK_RST_BASE;
159 u32 reg;
Tom Warren7aaa5a62015-03-04 16:36:00 -0700160 debug("%s entry\n", __func__);
Tom Warren32edd2e2014-01-24 12:46:14 -0700161
162 /* Disable IDDQ */
163 reg = readl(&clkrst->crc_pllx_misc3);
164 reg &= ~PLLX_IDDQ_MASK;
165 writel(reg, &clkrst->crc_pllx_misc3);
166 udelay(2);
167 debug("%s: IDDQ: PLLX IDDQ = 0x%08X\n", __func__,
168 readl(&clkrst->crc_pllx_misc3));
169#endif
170}
171
Tom Warren1b245fe2012-12-11 13:34:13 +0000172int pllx_set_rate(struct clk_pll_simple *pll , u32 divn, u32 divm,
173 u32 divp, u32 cpcon)
174{
Tom Warren722e0002015-06-25 09:50:44 -0700175 struct clk_pll_info *pllinfo = &tegra_pll_info_table[CLOCK_ID_XCPU];
Thierry Reding4475c772013-10-01 17:04:45 +0200176 int chip = tegra_get_chip();
Tom Warren1b245fe2012-12-11 13:34:13 +0000177 u32 reg;
Tom Warren7aaa5a62015-03-04 16:36:00 -0700178 debug("%s entry\n", __func__);
Tom Warren1b245fe2012-12-11 13:34:13 +0000179
180 /* If PLLX is already enabled, just return */
181 if (readl(&pll->pll_base) & PLL_ENABLE_MASK) {
Tom Warren7aaa5a62015-03-04 16:36:00 -0700182 debug("%s: PLLX already enabled, returning\n", __func__);
Tom Warren1b245fe2012-12-11 13:34:13 +0000183 return 0;
184 }
185
Tom Warren32edd2e2014-01-24 12:46:14 -0700186 pllx_set_iddq();
187
Tom Warren1b245fe2012-12-11 13:34:13 +0000188 /* Set BYPASS, m, n and p to PLLX_BASE */
Tom Warren722e0002015-06-25 09:50:44 -0700189 reg = PLL_BYPASS_MASK | (divm << pllinfo->m_shift);
190 reg |= (divn << pllinfo->n_shift) | (divp << pllinfo->p_shift);
Tom Warren1b245fe2012-12-11 13:34:13 +0000191 writel(reg, &pll->pll_base);
192
193 /* Set cpcon to PLLX_MISC */
Thierry Reding4475c772013-10-01 17:04:45 +0200194 if (chip == CHIPID_TEGRA20 || chip == CHIPID_TEGRA30)
Tom Warren722e0002015-06-25 09:50:44 -0700195 reg = (cpcon << pllinfo->kcp_shift);
Thierry Reding4475c772013-10-01 17:04:45 +0200196 else
197 reg = 0;
Tom Warren1b245fe2012-12-11 13:34:13 +0000198
Tom Warren722e0002015-06-25 09:50:44 -0700199 /*
200 * TODO(twarren@nvidia.com) Check which SoCs use DCCON
201 * and add to pllinfo table if needed!
202 */
203 /* Set dccon to PLLX_MISC if freq > 600MHz */
Tom Warren1b245fe2012-12-11 13:34:13 +0000204 if (divn > 600)
205 reg |= (1 << PLL_DCCON_SHIFT);
206 writel(reg, &pll->pll_misc);
207
Tom Warren1b245fe2012-12-11 13:34:13 +0000208 /* Disable BYPASS */
Stephen Warren41447fb2014-01-24 12:46:09 -0700209 reg = readl(&pll->pll_base);
Tom Warren1b245fe2012-12-11 13:34:13 +0000210 reg &= ~PLL_BYPASS_MASK;
211 writel(reg, &pll->pll_base);
Tom Warren7aaa5a62015-03-04 16:36:00 -0700212 debug("%s: base = 0x%08X\n", __func__, reg);
Tom Warren1b245fe2012-12-11 13:34:13 +0000213
Tom Warren722e0002015-06-25 09:50:44 -0700214 /* Set lock_enable to PLLX_MISC if lock_ena is valid (i.e. 0-31) */
Tom Warren1b245fe2012-12-11 13:34:13 +0000215 reg = readl(&pll->pll_misc);
Tom Warren722e0002015-06-25 09:50:44 -0700216 if (pllinfo->lock_ena < 32)
217 reg |= (1 << pllinfo->lock_ena);
Tom Warren1b245fe2012-12-11 13:34:13 +0000218 writel(reg, &pll->pll_misc);
Tom Warren7aaa5a62015-03-04 16:36:00 -0700219 debug("%s: misc = 0x%08X\n", __func__, reg);
Stephen Warren41447fb2014-01-24 12:46:09 -0700220
221 /* Enable PLLX last, once it's all configured */
222 reg = readl(&pll->pll_base);
223 reg |= PLL_ENABLE_MASK;
224 writel(reg, &pll->pll_base);
Tom Warren7aaa5a62015-03-04 16:36:00 -0700225 debug("%s: base final = 0x%08X\n", __func__, reg);
Tom Warren1b245fe2012-12-11 13:34:13 +0000226
227 return 0;
228}
229
230void init_pllx(void)
231{
232 struct clk_rst_ctlr *clkrst = (struct clk_rst_ctlr *)NV_PA_CLK_RST_BASE;
233 struct clk_pll_simple *pll = &clkrst->crc_pll_simple[SIMPLE_PLLX];
Tom Warren49493cb2013-04-10 10:32:32 -0700234 int soc_type, sku_info, chip_sku;
Tom Warren1b245fe2012-12-11 13:34:13 +0000235 enum clock_osc_freq osc;
236 struct clk_pll_table *sel;
Tom Warren7aaa5a62015-03-04 16:36:00 -0700237 debug("%s entry\n", __func__);
Tom Warren1b245fe2012-12-11 13:34:13 +0000238
Tom Warren49493cb2013-04-10 10:32:32 -0700239 /* get SOC (chip) type */
240 soc_type = tegra_get_chip();
Tom Warren7aaa5a62015-03-04 16:36:00 -0700241 debug("%s: SoC = 0x%02X\n", __func__, soc_type);
Tom Warren49493cb2013-04-10 10:32:32 -0700242
243 /* get SKU info */
244 sku_info = tegra_get_sku_info();
Tom Warren7aaa5a62015-03-04 16:36:00 -0700245 debug("%s: SKU info byte = 0x%02X\n", __func__, sku_info);
Tom Warren49493cb2013-04-10 10:32:32 -0700246
247 /* get chip SKU, combo of the above info */
248 chip_sku = tegra_get_chip_sku();
Tom Warren7aaa5a62015-03-04 16:36:00 -0700249 debug("%s: Chip SKU = %d\n", __func__, chip_sku);
Tom Warren1b245fe2012-12-11 13:34:13 +0000250
251 /* get osc freq */
252 osc = clock_get_osc_freq();
Tom Warren7aaa5a62015-03-04 16:36:00 -0700253 debug("%s: osc = %d\n", __func__, osc);
Tom Warren1b245fe2012-12-11 13:34:13 +0000254
255 /* set pllx */
Tom Warren49493cb2013-04-10 10:32:32 -0700256 sel = &tegra_pll_x_table[chip_sku][osc];
Tom Warren1b245fe2012-12-11 13:34:13 +0000257 pllx_set_rate(pll, sel->n, sel->m, sel->p, sel->cpcon);
Tom Warren1b245fe2012-12-11 13:34:13 +0000258}
259
260void enable_cpu_clock(int enable)
261{
262 struct clk_rst_ctlr *clkrst = (struct clk_rst_ctlr *)NV_PA_CLK_RST_BASE;
263 u32 clk;
Tom Warren7aaa5a62015-03-04 16:36:00 -0700264 debug("%s entry\n", __func__);
Tom Warren1b245fe2012-12-11 13:34:13 +0000265
266 /*
267 * NOTE:
268 * Regardless of whether the request is to enable or disable the CPU
269 * clock, every processor in the CPU complex except the master (CPU 0)
270 * will have it's clock stopped because the AVP only talks to the
271 * master.
272 */
273
274 if (enable) {
275 /* Initialize PLLX */
276 init_pllx();
277
278 /* Wait until all clocks are stable */
279 udelay(PLL_STABILIZATION_DELAY);
280
281 writel(CCLK_BURST_POLICY, &clkrst->crc_cclk_brst_pol);
282 writel(SUPER_CCLK_DIVIDER, &clkrst->crc_super_cclk_div);
283 }
284
285 /*
286 * Read the register containing the individual CPU clock enables and
287 * always stop the clocks to CPUs > 0.
288 */
289 clk = readl(&clkrst->crc_clk_cpu_cmplx);
290 clk |= 1 << CPU1_CLK_STP_SHIFT;
Tom Warren4040ec12013-01-28 13:32:08 +0000291 if (get_num_cpus() == 4)
292 clk |= (1 << CPU2_CLK_STP_SHIFT) + (1 << CPU3_CLK_STP_SHIFT);
293
Tom Warren1b245fe2012-12-11 13:34:13 +0000294 /* Stop/Unstop the CPU clock */
295 clk &= ~CPU0_CLK_STP_MASK;
296 clk |= !enable << CPU0_CLK_STP_SHIFT;
297 writel(clk, &clkrst->crc_clk_cpu_cmplx);
298
299 clock_enable(PERIPH_ID_CPU);
300}
301
302static int is_cpu_powered(void)
303{
Thierry Redingf9ec2ec2019-04-15 11:32:25 +0200304 return (tegra_pmc_readl(offsetof(struct pmc_ctlr,
305 pmc_pwrgate_status)) & CPU_PWRED) ? 1 : 0;
Tom Warren1b245fe2012-12-11 13:34:13 +0000306}
307
308static void remove_cpu_io_clamps(void)
309{
Tom Warren1b245fe2012-12-11 13:34:13 +0000310 u32 reg;
Tom Warren7aaa5a62015-03-04 16:36:00 -0700311 debug("%s entry\n", __func__);
Tom Warren1b245fe2012-12-11 13:34:13 +0000312
313 /* Remove the clamps on the CPU I/O signals */
Thierry Redingf9ec2ec2019-04-15 11:32:25 +0200314 reg = tegra_pmc_readl(offsetof(struct pmc_ctlr, pmc_remove_clamping));
Tom Warren1b245fe2012-12-11 13:34:13 +0000315 reg |= CPU_CLMP;
Thierry Redingf9ec2ec2019-04-15 11:32:25 +0200316 tegra_pmc_writel(reg, offsetof(struct pmc_ctlr, pmc_remove_clamping));
Tom Warren1b245fe2012-12-11 13:34:13 +0000317
318 /* Give I/O signals time to stabilize */
319 udelay(IO_STABILIZATION_DELAY);
320}
321
322void powerup_cpu(void)
323{
Tom Warren1b245fe2012-12-11 13:34:13 +0000324 u32 reg;
325 int timeout = IO_STABILIZATION_DELAY;
Tom Warren7aaa5a62015-03-04 16:36:00 -0700326 debug("%s entry\n", __func__);
Tom Warren1b245fe2012-12-11 13:34:13 +0000327
328 if (!is_cpu_powered()) {
329 /* Toggle the CPU power state (OFF -> ON) */
Thierry Redingf9ec2ec2019-04-15 11:32:25 +0200330 reg = tegra_pmc_readl(offsetof(struct pmc_ctlr,
331 pmc_pwrgate_toggle));
Tom Warren1b245fe2012-12-11 13:34:13 +0000332 reg &= PARTID_CP;
333 reg |= START_CP;
Thierry Redingf9ec2ec2019-04-15 11:32:25 +0200334 tegra_pmc_writel(reg,
335 offsetof(struct pmc_ctlr,
336 pmc_pwrgate_toggle));
Tom Warren1b245fe2012-12-11 13:34:13 +0000337
338 /* Wait for the power to come up */
339 while (!is_cpu_powered()) {
340 if (timeout-- == 0)
341 printf("CPU failed to power up!\n");
342 else
343 udelay(10);
344 }
345
346 /*
347 * Remove the I/O clamps from CPU power partition.
348 * Recommended only on a Warm boot, if the CPU partition gets
349 * power gated. Shouldn't cause any harm when called after a
350 * cold boot according to HW, probably just redundant.
351 */
352 remove_cpu_io_clamps();
353 }
354}
355
356void reset_A9_cpu(int reset)
357{
358 /*
359 * NOTE: Regardless of whether the request is to hold the CPU in reset
360 * or take it out of reset, every processor in the CPU complex
361 * except the master (CPU 0) will be held in reset because the
362 * AVP only talks to the master. The AVP does not know that there
363 * are multiple processors in the CPU complex.
364 */
365 int mask = crc_rst_cpu | crc_rst_de | crc_rst_debug;
366 int num_cpus = get_num_cpus();
367 int cpu;
368
Tom Warren7aaa5a62015-03-04 16:36:00 -0700369 debug("%s entry\n", __func__);
Tom Warren1b245fe2012-12-11 13:34:13 +0000370 /* Hold CPUs 1 onwards in reset, and CPU 0 if asked */
371 for (cpu = 1; cpu < num_cpus; cpu++)
372 reset_cmplx_set_enable(cpu, mask, 1);
373 reset_cmplx_set_enable(0, mask, reset);
374
375 /* Enable/Disable master CPU reset */
376 reset_set_enable(PERIPH_ID_CPU, reset);
377}
378
379void clock_enable_coresight(int enable)
380{
Tom Warren4040ec12013-01-28 13:32:08 +0000381 u32 rst, src = 2;
Tom Warren1b245fe2012-12-11 13:34:13 +0000382
Tom Warren7aaa5a62015-03-04 16:36:00 -0700383 debug("%s entry\n", __func__);
Tom Warren1b245fe2012-12-11 13:34:13 +0000384 clock_set_enable(PERIPH_ID_CORESIGHT, enable);
385 reset_set_enable(PERIPH_ID_CORESIGHT, !enable);
386
387 if (enable) {
388 /*
Tom Warren49493cb2013-04-10 10:32:32 -0700389 * Put CoreSight on PLLP_OUT0 and divide it down as per
Tom Warren32edd2e2014-01-24 12:46:14 -0700390 * PLLP base frequency based on SoC type (T20/T30+).
Tom Warren49493cb2013-04-10 10:32:32 -0700391 * Clock divider request would setup CSITE clock as 144MHz
392 * for PLLP base 216MHz and 204MHz for PLLP base 408MHz
Tom Warren1b245fe2012-12-11 13:34:13 +0000393 */
Stephen Warrena4bcd672014-01-24 12:46:10 -0700394 src = CLK_DIVIDER(NVBL_PLLP_KHZ, CSITE_KHZ);
Tom Warren1b245fe2012-12-11 13:34:13 +0000395 clock_ll_set_source_divisor(PERIPH_ID_CSI, 0, src);
396
397 /* Unlock the CPU CoreSight interfaces */
398 rst = CORESIGHT_UNLOCK;
399 writel(rst, CSITE_CPU_DBG0_LAR);
400 writel(rst, CSITE_CPU_DBG1_LAR);
Tom Warren4040ec12013-01-28 13:32:08 +0000401 if (get_num_cpus() == 4) {
402 writel(rst, CSITE_CPU_DBG2_LAR);
403 writel(rst, CSITE_CPU_DBG3_LAR);
404 }
Tom Warren1b245fe2012-12-11 13:34:13 +0000405 }
406}
407
408void halt_avp(void)
409{
Tom Warren7aaa5a62015-03-04 16:36:00 -0700410 debug("%s entry\n", __func__);
411
Tom Warren1b245fe2012-12-11 13:34:13 +0000412 for (;;) {
Stephen Warren716ff5c2014-02-03 14:03:27 -0700413 writel(HALT_COP_EVENT_JTAG | (FLOW_MODE_STOP << 29),
414 FLOW_CTLR_HALT_COP_EVENTS);
Tom Warren1b245fe2012-12-11 13:34:13 +0000415 }
416}