Tom Rini | 10e4779 | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0+ */ |
Allen Martin | e60ab6e | 2012-08-31 08:30:09 +0000 | [diff] [blame] | 2 | /* |
Tom Warren | ab0cc6b | 2015-03-04 16:36:00 -0700 | [diff] [blame] | 3 | * (C) Copyright 2010-2015 |
Allen Martin | e60ab6e | 2012-08-31 08:30:09 +0000 | [diff] [blame] | 4 | * NVIDIA Corporation <www.nvidia.com> |
Allen Martin | e60ab6e | 2012-08-31 08:30:09 +0000 | [diff] [blame] | 5 | */ |
| 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 Warren | d034d1b | 2013-01-28 13:32:08 +0000 | [diff] [blame] | 12 | #if defined(CONFIG_TEGRA20) |
Stephen Warren | 62dd54f | 2014-01-24 12:46:10 -0700 | [diff] [blame] | 13 | #define NVBL_PLLP_KHZ 216000 |
| 14 | #define CSITE_KHZ 144000 |
Tom Warren | 9588ab7 | 2014-01-24 12:46:14 -0700 | [diff] [blame] | 15 | #elif defined(CONFIG_TEGRA30) || defined(CONFIG_TEGRA114) || \ |
Tom Warren | ab0cc6b | 2015-03-04 16:36:00 -0700 | [diff] [blame] | 16 | defined(CONFIG_TEGRA124) || defined(CONFIG_TEGRA210) |
Stephen Warren | 62dd54f | 2014-01-24 12:46:10 -0700 | [diff] [blame] | 17 | #define NVBL_PLLP_KHZ 408000 |
Bryan Wu | f082993 | 2016-08-11 16:28:27 -0600 | [diff] [blame] | 18 | #define CSITE_KHZ 136000 |
Tom Warren | d034d1b | 2013-01-28 13:32:08 +0000 | [diff] [blame] | 19 | #else |
| 20 | #error "Unknown Tegra chip!" |
Tom Warren | 9c79abe | 2012-12-11 13:34:13 +0000 | [diff] [blame] | 21 | #endif |
Allen Martin | e60ab6e | 2012-08-31 08:30:09 +0000 | [diff] [blame] | 22 | |
| 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 Warren | ab0cc6b | 2015-03-04 16:36:00 -0700 | [diff] [blame] | 37 | #define CORESIGHT_UNLOCK 0xC5ACCE55 |
Allen Martin | e60ab6e | 2012-08-31 08:30:09 +0000 | [diff] [blame] | 38 | |
Allen Martin | e60ab6e | 2012-08-31 08:30:09 +0000 | [diff] [blame] | 39 | #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 Warren | 9c79abe | 2012-12-11 13:34:13 +0000 | [diff] [blame] | 42 | #define CSITE_CPU_DBG2_LAR (NV_PA_CSITE_BASE + 0x14FB0) |
| 43 | #define CSITE_CPU_DBG3_LAR (NV_PA_CSITE_BASE + 0x16FB0) |
Allen Martin | e60ab6e | 2012-08-31 08:30:09 +0000 | [diff] [blame] | 44 | |
| 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 Warren | 9c79abe | 2012-12-11 13:34:13 +0000 | [diff] [blame] | 51 | #define FLOW_MODE_NONE 0 |
| 52 | |
| 53 | #define SIMPLE_PLLX (CLOCK_ID_XCPU - CLOCK_ID_FIRST_SIMPLE) |
| 54 | |
Tom Warren | ab0cc6b | 2015-03-04 16:36:00 -0700 | [diff] [blame] | 55 | /* 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 Warren | 9c79abe | 2012-12-11 13:34:13 +0000 | [diff] [blame] | 59 | struct clk_pll_table { |
| 60 | u16 n; |
| 61 | u16 m; |
| 62 | u8 p; |
| 63 | u8 cpcon; |
| 64 | }; |
| 65 | |
| 66 | void clock_enable_coresight(int enable); |
| 67 | void enable_cpu_clock(int enable); |
Allen Martin | e60ab6e | 2012-08-31 08:30:09 +0000 | [diff] [blame] | 68 | void halt_avp(void) __attribute__ ((noreturn)); |
Tom Warren | 9c79abe | 2012-12-11 13:34:13 +0000 | [diff] [blame] | 69 | void init_pllx(void); |
| 70 | void powerup_cpu(void); |
| 71 | void reset_A9_cpu(int reset); |
| 72 | void start_cpu(u32 reset_vector); |
Tom Warren | 8b81711 | 2013-04-10 10:32:32 -0700 | [diff] [blame] | 73 | int tegra_get_chip(void); |
| 74 | int tegra_get_sku_info(void); |
| 75 | int tegra_get_chip_sku(void); |
Tom Warren | 9c79abe | 2012-12-11 13:34:13 +0000 | [diff] [blame] | 76 | void adjust_pllp_out_freqs(void); |