Allen Martin | c037c93 | 2012-08-31 08:30:09 +0000 | [diff] [blame] | 1 | /* |
Tom Warren | 7aaa5a6 | 2015-03-04 16:36:00 -0700 | [diff] [blame] | 2 | * (C) Copyright 2010-2015 |
Allen Martin | c037c93 | 2012-08-31 08:30:09 +0000 | [diff] [blame] | 3 | * NVIDIA Corporation <www.nvidia.com> |
| 4 | * |
Wolfgang Denk | 1a45966 | 2013-07-08 09:37:19 +0200 | [diff] [blame] | 5 | * SPDX-License-Identifier: GPL-2.0+ |
Allen Martin | c037c93 | 2012-08-31 08:30:09 +0000 | [diff] [blame] | 6 | */ |
| 7 | #include <asm/types.h> |
| 8 | |
| 9 | /* Stabilization delays, in usec */ |
| 10 | #define PLL_STABILIZATION_DELAY (300) |
| 11 | #define IO_STABILIZATION_DELAY (1000) |
| 12 | |
Tom Warren | 4040ec1 | 2013-01-28 13:32:08 +0000 | [diff] [blame] | 13 | #if defined(CONFIG_TEGRA20) |
Stephen Warren | a4bcd67 | 2014-01-24 12:46:10 -0700 | [diff] [blame] | 14 | #define NVBL_PLLP_KHZ 216000 |
| 15 | #define CSITE_KHZ 144000 |
Tom Warren | 32edd2e | 2014-01-24 12:46:14 -0700 | [diff] [blame] | 16 | #elif defined(CONFIG_TEGRA30) || defined(CONFIG_TEGRA114) || \ |
Tom Warren | 7aaa5a6 | 2015-03-04 16:36:00 -0700 | [diff] [blame] | 17 | defined(CONFIG_TEGRA124) || defined(CONFIG_TEGRA210) |
Stephen Warren | a4bcd67 | 2014-01-24 12:46:10 -0700 | [diff] [blame] | 18 | #define NVBL_PLLP_KHZ 408000 |
| 19 | #define CSITE_KHZ 204000 |
Tom Warren | 4040ec1 | 2013-01-28 13:32:08 +0000 | [diff] [blame] | 20 | #else |
| 21 | #error "Unknown Tegra chip!" |
Tom Warren | 1b245fe | 2012-12-11 13:34:13 +0000 | [diff] [blame] | 22 | #endif |
Allen Martin | c037c93 | 2012-08-31 08:30:09 +0000 | [diff] [blame] | 23 | |
| 24 | #define PLLX_ENABLED (1 << 30) |
| 25 | #define CCLK_BURST_POLICY 0x20008888 |
| 26 | #define SUPER_CCLK_DIVIDER 0x80000000 |
| 27 | |
| 28 | /* Calculate clock fractional divider value from ref and target frequencies */ |
| 29 | #define CLK_DIVIDER(REF, FREQ) ((((REF) * 2) / FREQ) - 2) |
| 30 | |
| 31 | /* Calculate clock frequency value from reference and clock divider value */ |
| 32 | #define CLK_FREQUENCY(REF, REG) (((REF) * 2) / (REG + 2)) |
| 33 | |
| 34 | /* AVP/CPU ID */ |
| 35 | #define PG_UP_TAG_0_PID_CPU 0x55555555 /* CPU aka "a9" aka "mpcore" */ |
| 36 | #define PG_UP_TAG_0 0x0 |
| 37 | |
Tom Warren | 7aaa5a6 | 2015-03-04 16:36:00 -0700 | [diff] [blame] | 38 | #define CORESIGHT_UNLOCK 0xC5ACCE55 |
Allen Martin | c037c93 | 2012-08-31 08:30:09 +0000 | [diff] [blame] | 39 | |
Allen Martin | c037c93 | 2012-08-31 08:30:09 +0000 | [diff] [blame] | 40 | #define EXCEP_VECTOR_CPU_RESET_VECTOR (NV_PA_EVP_BASE + 0x100) |
| 41 | #define CSITE_CPU_DBG0_LAR (NV_PA_CSITE_BASE + 0x10FB0) |
| 42 | #define CSITE_CPU_DBG1_LAR (NV_PA_CSITE_BASE + 0x12FB0) |
Tom Warren | 1b245fe | 2012-12-11 13:34:13 +0000 | [diff] [blame] | 43 | #define CSITE_CPU_DBG2_LAR (NV_PA_CSITE_BASE + 0x14FB0) |
| 44 | #define CSITE_CPU_DBG3_LAR (NV_PA_CSITE_BASE + 0x16FB0) |
Allen Martin | c037c93 | 2012-08-31 08:30:09 +0000 | [diff] [blame] | 45 | |
| 46 | #define FLOW_CTLR_HALT_COP_EVENTS (NV_PA_FLOW_BASE + 4) |
| 47 | #define FLOW_MODE_STOP 2 |
| 48 | #define HALT_COP_EVENT_JTAG (1 << 28) |
| 49 | #define HALT_COP_EVENT_IRQ_1 (1 << 11) |
| 50 | #define HALT_COP_EVENT_FIQ_1 (1 << 9) |
| 51 | |
Tom Warren | 1b245fe | 2012-12-11 13:34:13 +0000 | [diff] [blame] | 52 | #define FLOW_MODE_NONE 0 |
| 53 | |
| 54 | #define SIMPLE_PLLX (CLOCK_ID_XCPU - CLOCK_ID_FIRST_SIMPLE) |
| 55 | |
Tom Warren | 7aaa5a6 | 2015-03-04 16:36:00 -0700 | [diff] [blame] | 56 | /* SB_AA64_RESET_LOW and _HIGH defines for CPU reset vector */ |
| 57 | #define SB_AA64_RESET_LOW 0x6000C230 |
| 58 | #define SB_AA64_RESET_HIGH 0x6000C234 |
| 59 | |
Tom Warren | 1b245fe | 2012-12-11 13:34:13 +0000 | [diff] [blame] | 60 | struct clk_pll_table { |
| 61 | u16 n; |
| 62 | u16 m; |
| 63 | u8 p; |
| 64 | u8 cpcon; |
| 65 | }; |
| 66 | |
| 67 | void clock_enable_coresight(int enable); |
| 68 | void enable_cpu_clock(int enable); |
Allen Martin | c037c93 | 2012-08-31 08:30:09 +0000 | [diff] [blame] | 69 | void halt_avp(void) __attribute__ ((noreturn)); |
Tom Warren | 1b245fe | 2012-12-11 13:34:13 +0000 | [diff] [blame] | 70 | void init_pllx(void); |
| 71 | void powerup_cpu(void); |
| 72 | void reset_A9_cpu(int reset); |
| 73 | void start_cpu(u32 reset_vector); |
Tom Warren | 49493cb | 2013-04-10 10:32:32 -0700 | [diff] [blame] | 74 | int tegra_get_chip(void); |
| 75 | int tegra_get_sku_info(void); |
| 76 | int tegra_get_chip_sku(void); |
Tom Warren | 1b245fe | 2012-12-11 13:34:13 +0000 | [diff] [blame] | 77 | void adjust_pllp_out_freqs(void); |
Tom Warren | 32edd2e | 2014-01-24 12:46:14 -0700 | [diff] [blame] | 78 | void pmic_enable_cpu_vdd(void); |