blob: d541825441a3caab39ae2592e6f7b5aef75cc89c [file] [log] [blame]
Tom Rini83d290c2018-05-06 17:58:06 -04001/* SPDX-License-Identifier: GPL-2.0+ */
Allen Martinc037c932012-08-31 08:30:09 +00002/*
Tom Warren7aaa5a62015-03-04 16:36:00 -07003 * (C) Copyright 2010-2015
Allen Martinc037c932012-08-31 08:30:09 +00004 * NVIDIA Corporation <www.nvidia.com>
Allen Martinc037c932012-08-31 08:30:09 +00005 */
6#include <asm/types.h>
7
8/* Stabilization delays, in usec */
9#define PLL_STABILIZATION_DELAY (300)
10#define IO_STABILIZATION_DELAY (1000)
11
Tom Warren4040ec12013-01-28 13:32:08 +000012#if defined(CONFIG_TEGRA20)
Stephen Warrena4bcd672014-01-24 12:46:10 -070013#define NVBL_PLLP_KHZ 216000
14#define CSITE_KHZ 144000
Tom Warren32edd2e2014-01-24 12:46:14 -070015#elif defined(CONFIG_TEGRA30) || defined(CONFIG_TEGRA114) || \
Tom Warren7aaa5a62015-03-04 16:36:00 -070016 defined(CONFIG_TEGRA124) || defined(CONFIG_TEGRA210)
Stephen Warrena4bcd672014-01-24 12:46:10 -070017#define NVBL_PLLP_KHZ 408000
Bryan Wu027638d2016-08-11 16:28:27 -060018#define CSITE_KHZ 136000
Tom Warren4040ec12013-01-28 13:32:08 +000019#else
20#error "Unknown Tegra chip!"
Tom Warren1b245fe2012-12-11 13:34:13 +000021#endif
Allen Martinc037c932012-08-31 08:30:09 +000022
23#define PLLX_ENABLED (1 << 30)
24#define CCLK_BURST_POLICY 0x20008888
25#define SUPER_CCLK_DIVIDER 0x80000000
26
27/* Calculate clock fractional divider value from ref and target frequencies */
28#define CLK_DIVIDER(REF, FREQ) ((((REF) * 2) / FREQ) - 2)
29
30/* Calculate clock frequency value from reference and clock divider value */
31#define CLK_FREQUENCY(REF, REG) (((REF) * 2) / (REG + 2))
32
33/* AVP/CPU ID */
34#define PG_UP_TAG_0_PID_CPU 0x55555555 /* CPU aka "a9" aka "mpcore" */
35#define PG_UP_TAG_0 0x0
36
Tom Warren7aaa5a62015-03-04 16:36:00 -070037#define CORESIGHT_UNLOCK 0xC5ACCE55
Allen Martinc037c932012-08-31 08:30:09 +000038
Allen Martinc037c932012-08-31 08:30:09 +000039#define EXCEP_VECTOR_CPU_RESET_VECTOR (NV_PA_EVP_BASE + 0x100)
40#define CSITE_CPU_DBG0_LAR (NV_PA_CSITE_BASE + 0x10FB0)
41#define CSITE_CPU_DBG1_LAR (NV_PA_CSITE_BASE + 0x12FB0)
Tom Warren1b245fe2012-12-11 13:34:13 +000042#define CSITE_CPU_DBG2_LAR (NV_PA_CSITE_BASE + 0x14FB0)
43#define CSITE_CPU_DBG3_LAR (NV_PA_CSITE_BASE + 0x16FB0)
Allen Martinc037c932012-08-31 08:30:09 +000044
45#define FLOW_CTLR_HALT_COP_EVENTS (NV_PA_FLOW_BASE + 4)
46#define FLOW_MODE_STOP 2
47#define HALT_COP_EVENT_JTAG (1 << 28)
48#define HALT_COP_EVENT_IRQ_1 (1 << 11)
49#define HALT_COP_EVENT_FIQ_1 (1 << 9)
50
Tom Warren1b245fe2012-12-11 13:34:13 +000051#define FLOW_MODE_NONE 0
52
53#define SIMPLE_PLLX (CLOCK_ID_XCPU - CLOCK_ID_FIRST_SIMPLE)
54
Tom Warren7aaa5a62015-03-04 16:36:00 -070055/* SB_AA64_RESET_LOW and _HIGH defines for CPU reset vector */
56#define SB_AA64_RESET_LOW 0x6000C230
57#define SB_AA64_RESET_HIGH 0x6000C234
58
Tom Warren1b245fe2012-12-11 13:34:13 +000059struct clk_pll_table {
60 u16 n;
61 u16 m;
62 u8 p;
63 u8 cpcon;
64};
65
66void clock_enable_coresight(int enable);
67void enable_cpu_clock(int enable);
Allen Martinc037c932012-08-31 08:30:09 +000068void halt_avp(void) __attribute__ ((noreturn));
Tom Warren1b245fe2012-12-11 13:34:13 +000069void init_pllx(void);
70void powerup_cpu(void);
71void reset_A9_cpu(int reset);
72void start_cpu(u32 reset_vector);
Tom Warren49493cb2013-04-10 10:32:32 -070073int tegra_get_chip(void);
74int tegra_get_sku_info(void);
75int tegra_get_chip_sku(void);
Tom Warren1b245fe2012-12-11 13:34:13 +000076void adjust_pllp_out_freqs(void);
Tom Warren32edd2e2014-01-24 12:46:14 -070077void pmic_enable_cpu_vdd(void);