162306a36Sopenharmony_ci/***********************license start***************
262306a36Sopenharmony_ci * Author: Cavium Networks
362306a36Sopenharmony_ci *
462306a36Sopenharmony_ci * Contact: support@caviumnetworks.com
562306a36Sopenharmony_ci * This file is part of the OCTEON SDK
662306a36Sopenharmony_ci *
762306a36Sopenharmony_ci * Copyright (c) 2003-2017 Cavium, Inc.
862306a36Sopenharmony_ci *
962306a36Sopenharmony_ci * This file is free software; you can redistribute it and/or modify
1062306a36Sopenharmony_ci * it under the terms of the GNU General Public License, Version 2, as
1162306a36Sopenharmony_ci * published by the Free Software Foundation.
1262306a36Sopenharmony_ci *
1362306a36Sopenharmony_ci * This file is distributed in the hope that it will be useful, but
1462306a36Sopenharmony_ci * AS-IS and WITHOUT ANY WARRANTY; without even the implied warranty
1562306a36Sopenharmony_ci * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE, TITLE, or
1662306a36Sopenharmony_ci * NONINFRINGEMENT.  See the GNU General Public License for more
1762306a36Sopenharmony_ci * details.
1862306a36Sopenharmony_ci *
1962306a36Sopenharmony_ci * You should have received a copy of the GNU General Public License
2062306a36Sopenharmony_ci * along with this file; if not, write to the Free Software
2162306a36Sopenharmony_ci * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
2262306a36Sopenharmony_ci * or visit http://www.gnu.org/licenses/.
2362306a36Sopenharmony_ci *
2462306a36Sopenharmony_ci * This file may also be available under a different license from Cavium.
2562306a36Sopenharmony_ci * Contact Cavium Networks for more information
2662306a36Sopenharmony_ci ***********************license end**************************************/
2762306a36Sopenharmony_ci
2862306a36Sopenharmony_ci/*
2962306a36Sopenharmony_ci * Interface to the Level 2 Cache (L2C) control, measurement, and debugging
3062306a36Sopenharmony_ci * facilities.
3162306a36Sopenharmony_ci */
3262306a36Sopenharmony_ci
3362306a36Sopenharmony_ci#ifndef __CVMX_L2C_H__
3462306a36Sopenharmony_ci#define __CVMX_L2C_H__
3562306a36Sopenharmony_ci
3662306a36Sopenharmony_ci#include <uapi/asm/bitfield.h>
3762306a36Sopenharmony_ci
3862306a36Sopenharmony_ci#define CVMX_L2_ASSOC	 cvmx_l2c_get_num_assoc()	/* Deprecated macro */
3962306a36Sopenharmony_ci#define CVMX_L2_SET_BITS cvmx_l2c_get_set_bits()	/* Deprecated macro */
4062306a36Sopenharmony_ci#define CVMX_L2_SETS	 cvmx_l2c_get_num_sets()	/* Deprecated macro */
4162306a36Sopenharmony_ci
4262306a36Sopenharmony_ci/* Based on 128 byte cache line size */
4362306a36Sopenharmony_ci#define CVMX_L2C_IDX_ADDR_SHIFT	7
4462306a36Sopenharmony_ci#define CVMX_L2C_IDX_MASK	(cvmx_l2c_get_num_sets() - 1)
4562306a36Sopenharmony_ci
4662306a36Sopenharmony_ci/* Defines for index aliasing computations */
4762306a36Sopenharmony_ci#define CVMX_L2C_TAG_ADDR_ALIAS_SHIFT (CVMX_L2C_IDX_ADDR_SHIFT +	       \
4862306a36Sopenharmony_ci		cvmx_l2c_get_set_bits())
4962306a36Sopenharmony_ci#define CVMX_L2C_ALIAS_MASK (CVMX_L2C_IDX_MASK << CVMX_L2C_TAG_ADDR_ALIAS_SHIFT)
5062306a36Sopenharmony_ci#define CVMX_L2C_MEMBANK_SELECT_SIZE 4096
5162306a36Sopenharmony_ci
5262306a36Sopenharmony_ci/* Number of L2C Tag-and-data sections (TADs) that are connected to LMC. */
5362306a36Sopenharmony_ci#define CVMX_L2C_TADS  1
5462306a36Sopenharmony_ci
5562306a36Sopenharmony_ciunion cvmx_l2c_tag {
5662306a36Sopenharmony_ci	uint64_t u64;
5762306a36Sopenharmony_ci	struct {
5862306a36Sopenharmony_ci		__BITFIELD_FIELD(uint64_t reserved:28,
5962306a36Sopenharmony_ci		__BITFIELD_FIELD(uint64_t V:1,
6062306a36Sopenharmony_ci		__BITFIELD_FIELD(uint64_t D:1,
6162306a36Sopenharmony_ci		__BITFIELD_FIELD(uint64_t L:1,
6262306a36Sopenharmony_ci		__BITFIELD_FIELD(uint64_t U:1,
6362306a36Sopenharmony_ci		__BITFIELD_FIELD(uint64_t addr:32,
6462306a36Sopenharmony_ci		;))))))
6562306a36Sopenharmony_ci	} s;
6662306a36Sopenharmony_ci};
6762306a36Sopenharmony_ci
6862306a36Sopenharmony_ci/* L2C Performance Counter events. */
6962306a36Sopenharmony_cienum cvmx_l2c_event {
7062306a36Sopenharmony_ci	CVMX_L2C_EVENT_CYCLES		=  0,
7162306a36Sopenharmony_ci	CVMX_L2C_EVENT_INSTRUCTION_MISS =  1,
7262306a36Sopenharmony_ci	CVMX_L2C_EVENT_INSTRUCTION_HIT	=  2,
7362306a36Sopenharmony_ci	CVMX_L2C_EVENT_DATA_MISS	=  3,
7462306a36Sopenharmony_ci	CVMX_L2C_EVENT_DATA_HIT		=  4,
7562306a36Sopenharmony_ci	CVMX_L2C_EVENT_MISS		=  5,
7662306a36Sopenharmony_ci	CVMX_L2C_EVENT_HIT		=  6,
7762306a36Sopenharmony_ci	CVMX_L2C_EVENT_VICTIM_HIT	=  7,
7862306a36Sopenharmony_ci	CVMX_L2C_EVENT_INDEX_CONFLICT	=  8,
7962306a36Sopenharmony_ci	CVMX_L2C_EVENT_TAG_PROBE	=  9,
8062306a36Sopenharmony_ci	CVMX_L2C_EVENT_TAG_UPDATE	= 10,
8162306a36Sopenharmony_ci	CVMX_L2C_EVENT_TAG_COMPLETE	= 11,
8262306a36Sopenharmony_ci	CVMX_L2C_EVENT_TAG_DIRTY	= 12,
8362306a36Sopenharmony_ci	CVMX_L2C_EVENT_DATA_STORE_NOP	= 13,
8462306a36Sopenharmony_ci	CVMX_L2C_EVENT_DATA_STORE_READ	= 14,
8562306a36Sopenharmony_ci	CVMX_L2C_EVENT_DATA_STORE_WRITE = 15,
8662306a36Sopenharmony_ci	CVMX_L2C_EVENT_FILL_DATA_VALID	= 16,
8762306a36Sopenharmony_ci	CVMX_L2C_EVENT_WRITE_REQUEST	= 17,
8862306a36Sopenharmony_ci	CVMX_L2C_EVENT_READ_REQUEST	= 18,
8962306a36Sopenharmony_ci	CVMX_L2C_EVENT_WRITE_DATA_VALID = 19,
9062306a36Sopenharmony_ci	CVMX_L2C_EVENT_XMC_NOP		= 20,
9162306a36Sopenharmony_ci	CVMX_L2C_EVENT_XMC_LDT		= 21,
9262306a36Sopenharmony_ci	CVMX_L2C_EVENT_XMC_LDI		= 22,
9362306a36Sopenharmony_ci	CVMX_L2C_EVENT_XMC_LDD		= 23,
9462306a36Sopenharmony_ci	CVMX_L2C_EVENT_XMC_STF		= 24,
9562306a36Sopenharmony_ci	CVMX_L2C_EVENT_XMC_STT		= 25,
9662306a36Sopenharmony_ci	CVMX_L2C_EVENT_XMC_STP		= 26,
9762306a36Sopenharmony_ci	CVMX_L2C_EVENT_XMC_STC		= 27,
9862306a36Sopenharmony_ci	CVMX_L2C_EVENT_XMC_DWB		= 28,
9962306a36Sopenharmony_ci	CVMX_L2C_EVENT_XMC_PL2		= 29,
10062306a36Sopenharmony_ci	CVMX_L2C_EVENT_XMC_PSL1		= 30,
10162306a36Sopenharmony_ci	CVMX_L2C_EVENT_XMC_IOBLD	= 31,
10262306a36Sopenharmony_ci	CVMX_L2C_EVENT_XMC_IOBST	= 32,
10362306a36Sopenharmony_ci	CVMX_L2C_EVENT_XMC_IOBDMA	= 33,
10462306a36Sopenharmony_ci	CVMX_L2C_EVENT_XMC_IOBRSP	= 34,
10562306a36Sopenharmony_ci	CVMX_L2C_EVENT_XMC_BUS_VALID	= 35,
10662306a36Sopenharmony_ci	CVMX_L2C_EVENT_XMC_MEM_DATA	= 36,
10762306a36Sopenharmony_ci	CVMX_L2C_EVENT_XMC_REFL_DATA	= 37,
10862306a36Sopenharmony_ci	CVMX_L2C_EVENT_XMC_IOBRSP_DATA	= 38,
10962306a36Sopenharmony_ci	CVMX_L2C_EVENT_RSC_NOP		= 39,
11062306a36Sopenharmony_ci	CVMX_L2C_EVENT_RSC_STDN		= 40,
11162306a36Sopenharmony_ci	CVMX_L2C_EVENT_RSC_FILL		= 41,
11262306a36Sopenharmony_ci	CVMX_L2C_EVENT_RSC_REFL		= 42,
11362306a36Sopenharmony_ci	CVMX_L2C_EVENT_RSC_STIN		= 43,
11462306a36Sopenharmony_ci	CVMX_L2C_EVENT_RSC_SCIN		= 44,
11562306a36Sopenharmony_ci	CVMX_L2C_EVENT_RSC_SCFL		= 45,
11662306a36Sopenharmony_ci	CVMX_L2C_EVENT_RSC_SCDN		= 46,
11762306a36Sopenharmony_ci	CVMX_L2C_EVENT_RSC_DATA_VALID	= 47,
11862306a36Sopenharmony_ci	CVMX_L2C_EVENT_RSC_VALID_FILL	= 48,
11962306a36Sopenharmony_ci	CVMX_L2C_EVENT_RSC_VALID_STRSP	= 49,
12062306a36Sopenharmony_ci	CVMX_L2C_EVENT_RSC_VALID_REFL	= 50,
12162306a36Sopenharmony_ci	CVMX_L2C_EVENT_LRF_REQ		= 51,
12262306a36Sopenharmony_ci	CVMX_L2C_EVENT_DT_RD_ALLOC	= 52,
12362306a36Sopenharmony_ci	CVMX_L2C_EVENT_DT_WR_INVAL	= 53,
12462306a36Sopenharmony_ci	CVMX_L2C_EVENT_MAX
12562306a36Sopenharmony_ci};
12662306a36Sopenharmony_ci
12762306a36Sopenharmony_ci/* L2C Performance Counter events for Octeon2. */
12862306a36Sopenharmony_cienum cvmx_l2c_tad_event {
12962306a36Sopenharmony_ci	CVMX_L2C_TAD_EVENT_NONE		 = 0,
13062306a36Sopenharmony_ci	CVMX_L2C_TAD_EVENT_TAG_HIT	 = 1,
13162306a36Sopenharmony_ci	CVMX_L2C_TAD_EVENT_TAG_MISS	 = 2,
13262306a36Sopenharmony_ci	CVMX_L2C_TAD_EVENT_TAG_NOALLOC	 = 3,
13362306a36Sopenharmony_ci	CVMX_L2C_TAD_EVENT_TAG_VICTIM	 = 4,
13462306a36Sopenharmony_ci	CVMX_L2C_TAD_EVENT_SC_FAIL	 = 5,
13562306a36Sopenharmony_ci	CVMX_L2C_TAD_EVENT_SC_PASS	 = 6,
13662306a36Sopenharmony_ci	CVMX_L2C_TAD_EVENT_LFB_VALID	 = 7,
13762306a36Sopenharmony_ci	CVMX_L2C_TAD_EVENT_LFB_WAIT_LFB	 = 8,
13862306a36Sopenharmony_ci	CVMX_L2C_TAD_EVENT_LFB_WAIT_VAB	 = 9,
13962306a36Sopenharmony_ci	CVMX_L2C_TAD_EVENT_QUAD0_INDEX	 = 128,
14062306a36Sopenharmony_ci	CVMX_L2C_TAD_EVENT_QUAD0_READ	 = 129,
14162306a36Sopenharmony_ci	CVMX_L2C_TAD_EVENT_QUAD0_BANK	 = 130,
14262306a36Sopenharmony_ci	CVMX_L2C_TAD_EVENT_QUAD0_WDAT	 = 131,
14362306a36Sopenharmony_ci	CVMX_L2C_TAD_EVENT_QUAD1_INDEX	 = 144,
14462306a36Sopenharmony_ci	CVMX_L2C_TAD_EVENT_QUAD1_READ	 = 145,
14562306a36Sopenharmony_ci	CVMX_L2C_TAD_EVENT_QUAD1_BANK	 = 146,
14662306a36Sopenharmony_ci	CVMX_L2C_TAD_EVENT_QUAD1_WDAT	 = 147,
14762306a36Sopenharmony_ci	CVMX_L2C_TAD_EVENT_QUAD2_INDEX	 = 160,
14862306a36Sopenharmony_ci	CVMX_L2C_TAD_EVENT_QUAD2_READ	 = 161,
14962306a36Sopenharmony_ci	CVMX_L2C_TAD_EVENT_QUAD2_BANK	 = 162,
15062306a36Sopenharmony_ci	CVMX_L2C_TAD_EVENT_QUAD2_WDAT	 = 163,
15162306a36Sopenharmony_ci	CVMX_L2C_TAD_EVENT_QUAD3_INDEX	 = 176,
15262306a36Sopenharmony_ci	CVMX_L2C_TAD_EVENT_QUAD3_READ	 = 177,
15362306a36Sopenharmony_ci	CVMX_L2C_TAD_EVENT_QUAD3_BANK	 = 178,
15462306a36Sopenharmony_ci	CVMX_L2C_TAD_EVENT_QUAD3_WDAT	 = 179,
15562306a36Sopenharmony_ci	CVMX_L2C_TAD_EVENT_MAX
15662306a36Sopenharmony_ci};
15762306a36Sopenharmony_ci
15862306a36Sopenharmony_ci/**
15962306a36Sopenharmony_ci * Configure one of the four L2 Cache performance counters to capture event
16062306a36Sopenharmony_ci * occurrences.
16162306a36Sopenharmony_ci *
16262306a36Sopenharmony_ci * @counter:	    The counter to configure. Range 0..3.
16362306a36Sopenharmony_ci * @event:	    The type of L2 Cache event occurrence to count.
16462306a36Sopenharmony_ci * @clear_on_read:  When asserted, any read of the performance counter
16562306a36Sopenharmony_ci *			 clears the counter.
16662306a36Sopenharmony_ci *
16762306a36Sopenharmony_ci * @note The routine does not clear the counter.
16862306a36Sopenharmony_ci */
16962306a36Sopenharmony_civoid cvmx_l2c_config_perf(uint32_t counter, enum cvmx_l2c_event event,
17062306a36Sopenharmony_ci			  uint32_t clear_on_read);
17162306a36Sopenharmony_ci
17262306a36Sopenharmony_ci/**
17362306a36Sopenharmony_ci * Read the given L2 Cache performance counter. The counter must be configured
17462306a36Sopenharmony_ci * before reading, but this routine does not enforce this requirement.
17562306a36Sopenharmony_ci *
17662306a36Sopenharmony_ci * @counter:  The counter to configure. Range 0..3.
17762306a36Sopenharmony_ci *
17862306a36Sopenharmony_ci * Returns The current counter value.
17962306a36Sopenharmony_ci */
18062306a36Sopenharmony_ciuint64_t cvmx_l2c_read_perf(uint32_t counter);
18162306a36Sopenharmony_ci
18262306a36Sopenharmony_ci/**
18362306a36Sopenharmony_ci * Return the L2 Cache way partitioning for a given core.
18462306a36Sopenharmony_ci *
18562306a36Sopenharmony_ci * @core:  The core processor of interest.
18662306a36Sopenharmony_ci *
18762306a36Sopenharmony_ci * Returns    The mask specifying the partitioning. 0 bits in mask indicates
18862306a36Sopenharmony_ci *		the cache 'ways' that a core can evict from.
18962306a36Sopenharmony_ci *	      -1 on error
19062306a36Sopenharmony_ci */
19162306a36Sopenharmony_ciint cvmx_l2c_get_core_way_partition(uint32_t core);
19262306a36Sopenharmony_ci
19362306a36Sopenharmony_ci/**
19462306a36Sopenharmony_ci * Partitions the L2 cache for a core
19562306a36Sopenharmony_ci *
19662306a36Sopenharmony_ci * @core: The core that the partitioning applies to.
19762306a36Sopenharmony_ci * @mask: The partitioning of the ways expressed as a binary
19862306a36Sopenharmony_ci *	       mask. A 0 bit allows the core to evict cache lines from
19962306a36Sopenharmony_ci *	       a way, while a 1 bit blocks the core from evicting any
20062306a36Sopenharmony_ci *	       lines from that way. There must be at least one allowed
20162306a36Sopenharmony_ci *	       way (0 bit) in the mask.
20262306a36Sopenharmony_ci *
20362306a36Sopenharmony_ci
20462306a36Sopenharmony_ci * @note If any ways are blocked for all cores and the HW blocks, then
20562306a36Sopenharmony_ci *	 those ways will never have any cache lines evicted from them.
20662306a36Sopenharmony_ci *	 All cores and the hardware blocks are free to read from all
20762306a36Sopenharmony_ci *	 ways regardless of the partitioning.
20862306a36Sopenharmony_ci */
20962306a36Sopenharmony_ciint cvmx_l2c_set_core_way_partition(uint32_t core, uint32_t mask);
21062306a36Sopenharmony_ci
21162306a36Sopenharmony_ci/**
21262306a36Sopenharmony_ci * Return the L2 Cache way partitioning for the hw blocks.
21362306a36Sopenharmony_ci *
21462306a36Sopenharmony_ci * Returns    The mask specifying the reserved way. 0 bits in mask indicates
21562306a36Sopenharmony_ci *		the cache 'ways' that a core can evict from.
21662306a36Sopenharmony_ci *	      -1 on error
21762306a36Sopenharmony_ci */
21862306a36Sopenharmony_ciint cvmx_l2c_get_hw_way_partition(void);
21962306a36Sopenharmony_ci
22062306a36Sopenharmony_ci/**
22162306a36Sopenharmony_ci * Partitions the L2 cache for the hardware blocks.
22262306a36Sopenharmony_ci *
22362306a36Sopenharmony_ci * @mask: The partitioning of the ways expressed as a binary
22462306a36Sopenharmony_ci *	       mask. A 0 bit allows the core to evict cache lines from
22562306a36Sopenharmony_ci *	       a way, while a 1 bit blocks the core from evicting any
22662306a36Sopenharmony_ci *	       lines from that way. There must be at least one allowed
22762306a36Sopenharmony_ci *	       way (0 bit) in the mask.
22862306a36Sopenharmony_ci *
22962306a36Sopenharmony_ci
23062306a36Sopenharmony_ci * @note If any ways are blocked for all cores and the HW blocks, then
23162306a36Sopenharmony_ci *	 those ways will never have any cache lines evicted from them.
23262306a36Sopenharmony_ci *	 All cores and the hardware blocks are free to read from all
23362306a36Sopenharmony_ci *	 ways regardless of the partitioning.
23462306a36Sopenharmony_ci */
23562306a36Sopenharmony_ciint cvmx_l2c_set_hw_way_partition(uint32_t mask);
23662306a36Sopenharmony_ci
23762306a36Sopenharmony_ci
23862306a36Sopenharmony_ci/**
23962306a36Sopenharmony_ci * Locks a line in the L2 cache at the specified physical address
24062306a36Sopenharmony_ci *
24162306a36Sopenharmony_ci * @addr:   physical address of line to lock
24262306a36Sopenharmony_ci *
24362306a36Sopenharmony_ci * Returns 0 on success,
24462306a36Sopenharmony_ci *	   1 if line not locked.
24562306a36Sopenharmony_ci */
24662306a36Sopenharmony_ciint cvmx_l2c_lock_line(uint64_t addr);
24762306a36Sopenharmony_ci
24862306a36Sopenharmony_ci/**
24962306a36Sopenharmony_ci * Locks a specified memory region in the L2 cache.
25062306a36Sopenharmony_ci *
25162306a36Sopenharmony_ci * Note that if not all lines can be locked, that means that all
25262306a36Sopenharmony_ci * but one of the ways (associations) available to the locking
25362306a36Sopenharmony_ci * core are locked.  Having only 1 association available for
25462306a36Sopenharmony_ci * normal caching may have a significant adverse affect on performance.
25562306a36Sopenharmony_ci * Care should be taken to ensure that enough of the L2 cache is left
25662306a36Sopenharmony_ci * unlocked to allow for normal caching of DRAM.
25762306a36Sopenharmony_ci *
25862306a36Sopenharmony_ci * @start:  Physical address of the start of the region to lock
25962306a36Sopenharmony_ci * @len:    Length (in bytes) of region to lock
26062306a36Sopenharmony_ci *
26162306a36Sopenharmony_ci * Returns Number of requested lines that where not locked.
26262306a36Sopenharmony_ci *	   0 on success (all locked)
26362306a36Sopenharmony_ci */
26462306a36Sopenharmony_ciint cvmx_l2c_lock_mem_region(uint64_t start, uint64_t len);
26562306a36Sopenharmony_ci
26662306a36Sopenharmony_ci/**
26762306a36Sopenharmony_ci * Unlock and flush a cache line from the L2 cache.
26862306a36Sopenharmony_ci * IMPORTANT: Must only be run by one core at a time due to use
26962306a36Sopenharmony_ci * of L2C debug features.
27062306a36Sopenharmony_ci * Note that this function will flush a matching but unlocked cache line.
27162306a36Sopenharmony_ci * (If address is not in L2, no lines are flushed.)
27262306a36Sopenharmony_ci *
27362306a36Sopenharmony_ci * @address: Physical address to unlock
27462306a36Sopenharmony_ci *
27562306a36Sopenharmony_ci * Returns 0: line not unlocked
27662306a36Sopenharmony_ci *	   1: line unlocked
27762306a36Sopenharmony_ci */
27862306a36Sopenharmony_ciint cvmx_l2c_unlock_line(uint64_t address);
27962306a36Sopenharmony_ci
28062306a36Sopenharmony_ci/**
28162306a36Sopenharmony_ci * Unlocks a region of memory that is locked in the L2 cache
28262306a36Sopenharmony_ci *
28362306a36Sopenharmony_ci * @start:  start physical address
28462306a36Sopenharmony_ci * @len:    length (in bytes) to unlock
28562306a36Sopenharmony_ci *
28662306a36Sopenharmony_ci * Returns Number of locked lines that the call unlocked
28762306a36Sopenharmony_ci */
28862306a36Sopenharmony_ciint cvmx_l2c_unlock_mem_region(uint64_t start, uint64_t len);
28962306a36Sopenharmony_ci
29062306a36Sopenharmony_ci/**
29162306a36Sopenharmony_ci * Read the L2 controller tag for a given location in L2
29262306a36Sopenharmony_ci *
29362306a36Sopenharmony_ci * @association:
29462306a36Sopenharmony_ci *		 Which association to read line from
29562306a36Sopenharmony_ci * @index:  Which way to read from.
29662306a36Sopenharmony_ci *
29762306a36Sopenharmony_ci * Returns l2c tag structure for line requested.
29862306a36Sopenharmony_ci */
29962306a36Sopenharmony_ciunion cvmx_l2c_tag cvmx_l2c_get_tag(uint32_t association, uint32_t index);
30062306a36Sopenharmony_ci
30162306a36Sopenharmony_ci/* Wrapper providing a deprecated old function name */
30262306a36Sopenharmony_cistatic inline union cvmx_l2c_tag cvmx_get_l2c_tag(uint32_t association,
30362306a36Sopenharmony_ci						  uint32_t index)
30462306a36Sopenharmony_ci						  __attribute__((deprecated));
30562306a36Sopenharmony_cistatic inline union cvmx_l2c_tag cvmx_get_l2c_tag(uint32_t association,
30662306a36Sopenharmony_ci						  uint32_t index)
30762306a36Sopenharmony_ci{
30862306a36Sopenharmony_ci	return cvmx_l2c_get_tag(association, index);
30962306a36Sopenharmony_ci}
31062306a36Sopenharmony_ci
31162306a36Sopenharmony_ci
31262306a36Sopenharmony_ci/**
31362306a36Sopenharmony_ci * Returns the cache index for a given physical address
31462306a36Sopenharmony_ci *
31562306a36Sopenharmony_ci * @addr:   physical address
31662306a36Sopenharmony_ci *
31762306a36Sopenharmony_ci * Returns L2 cache index
31862306a36Sopenharmony_ci */
31962306a36Sopenharmony_ciuint32_t cvmx_l2c_address_to_index(uint64_t addr);
32062306a36Sopenharmony_ci
32162306a36Sopenharmony_ci/**
32262306a36Sopenharmony_ci * Flushes (and unlocks) the entire L2 cache.
32362306a36Sopenharmony_ci * IMPORTANT: Must only be run by one core at a time due to use
32462306a36Sopenharmony_ci * of L2C debug features.
32562306a36Sopenharmony_ci */
32662306a36Sopenharmony_civoid cvmx_l2c_flush(void);
32762306a36Sopenharmony_ci
32862306a36Sopenharmony_ci/**
32962306a36Sopenharmony_ci *
33062306a36Sopenharmony_ci * Returns the size of the L2 cache in bytes,
33162306a36Sopenharmony_ci * -1 on error (unrecognized model)
33262306a36Sopenharmony_ci */
33362306a36Sopenharmony_ciint cvmx_l2c_get_cache_size_bytes(void);
33462306a36Sopenharmony_ci
33562306a36Sopenharmony_ci/**
33662306a36Sopenharmony_ci * Return the number of sets in the L2 Cache
33762306a36Sopenharmony_ci *
33862306a36Sopenharmony_ci * Returns
33962306a36Sopenharmony_ci */
34062306a36Sopenharmony_ciint cvmx_l2c_get_num_sets(void);
34162306a36Sopenharmony_ci
34262306a36Sopenharmony_ci/**
34362306a36Sopenharmony_ci * Return log base 2 of the number of sets in the L2 cache
34462306a36Sopenharmony_ci * Returns
34562306a36Sopenharmony_ci */
34662306a36Sopenharmony_ciint cvmx_l2c_get_set_bits(void);
34762306a36Sopenharmony_ci/**
34862306a36Sopenharmony_ci * Return the number of associations in the L2 Cache
34962306a36Sopenharmony_ci *
35062306a36Sopenharmony_ci * Returns
35162306a36Sopenharmony_ci */
35262306a36Sopenharmony_ciint cvmx_l2c_get_num_assoc(void);
35362306a36Sopenharmony_ci
35462306a36Sopenharmony_ci/**
35562306a36Sopenharmony_ci * Flush a line from the L2 cache
35662306a36Sopenharmony_ci * This should only be called from one core at a time, as this routine
35762306a36Sopenharmony_ci * sets the core to the 'debug' core in order to flush the line.
35862306a36Sopenharmony_ci *
35962306a36Sopenharmony_ci * @assoc:  Association (or way) to flush
36062306a36Sopenharmony_ci * @index:  Index to flush
36162306a36Sopenharmony_ci */
36262306a36Sopenharmony_civoid cvmx_l2c_flush_line(uint32_t assoc, uint32_t index);
36362306a36Sopenharmony_ci
36462306a36Sopenharmony_ci#endif /* __CVMX_L2C_H__ */
365