162306a36Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-only */
262306a36Sopenharmony_ci/*
362306a36Sopenharmony_ci * Copyright (C) 2004, 2007-2010, 2011-2012 Synopsys, Inc. (www.synopsys.com)
462306a36Sopenharmony_ci */
562306a36Sopenharmony_ci
662306a36Sopenharmony_ci#ifndef __ARC_ASM_CACHE_H
762306a36Sopenharmony_ci#define __ARC_ASM_CACHE_H
862306a36Sopenharmony_ci
962306a36Sopenharmony_ci/* In case $$ not config, setup a dummy number for rest of kernel */
1062306a36Sopenharmony_ci#ifndef CONFIG_ARC_CACHE_LINE_SHIFT
1162306a36Sopenharmony_ci#define L1_CACHE_SHIFT		6
1262306a36Sopenharmony_ci#else
1362306a36Sopenharmony_ci#define L1_CACHE_SHIFT		CONFIG_ARC_CACHE_LINE_SHIFT
1462306a36Sopenharmony_ci#endif
1562306a36Sopenharmony_ci
1662306a36Sopenharmony_ci#define L1_CACHE_BYTES		(1 << L1_CACHE_SHIFT)
1762306a36Sopenharmony_ci#define CACHE_LINE_MASK		(~(L1_CACHE_BYTES - 1))
1862306a36Sopenharmony_ci
1962306a36Sopenharmony_ci/*
2062306a36Sopenharmony_ci * ARC700 doesn't cache any access in top 1G (0xc000_0000 to 0xFFFF_FFFF)
2162306a36Sopenharmony_ci * Ideal for wiring memory mapped peripherals as we don't need to do
2262306a36Sopenharmony_ci * explicit uncached accesses (LD.di/ST.di) hence more portable drivers
2362306a36Sopenharmony_ci */
2462306a36Sopenharmony_ci#define ARC_UNCACHED_ADDR_SPACE	0xc0000000
2562306a36Sopenharmony_ci
2662306a36Sopenharmony_ci#ifndef __ASSEMBLY__
2762306a36Sopenharmony_ci
2862306a36Sopenharmony_ci#include <linux/build_bug.h>
2962306a36Sopenharmony_ci
3062306a36Sopenharmony_ci/* Uncached access macros */
3162306a36Sopenharmony_ci#define arc_read_uncached_32(ptr)	\
3262306a36Sopenharmony_ci({					\
3362306a36Sopenharmony_ci	unsigned int __ret;		\
3462306a36Sopenharmony_ci	__asm__ __volatile__(		\
3562306a36Sopenharmony_ci	"	ld.di %0, [%1]	\n"	\
3662306a36Sopenharmony_ci	: "=r"(__ret)			\
3762306a36Sopenharmony_ci	: "r"(ptr));			\
3862306a36Sopenharmony_ci	__ret;				\
3962306a36Sopenharmony_ci})
4062306a36Sopenharmony_ci
4162306a36Sopenharmony_ci#define arc_write_uncached_32(ptr, data)\
4262306a36Sopenharmony_ci({					\
4362306a36Sopenharmony_ci	__asm__ __volatile__(		\
4462306a36Sopenharmony_ci	"	st.di %0, [%1]	\n"	\
4562306a36Sopenharmony_ci	:				\
4662306a36Sopenharmony_ci	: "r"(data), "r"(ptr));		\
4762306a36Sopenharmony_ci})
4862306a36Sopenharmony_ci
4962306a36Sopenharmony_ci/* Largest line length for either L1 or L2 is 128 bytes */
5062306a36Sopenharmony_ci#define SMP_CACHE_BYTES		128
5162306a36Sopenharmony_ci#define cache_line_size()	SMP_CACHE_BYTES
5262306a36Sopenharmony_ci#define ARCH_DMA_MINALIGN	SMP_CACHE_BYTES
5362306a36Sopenharmony_ci
5462306a36Sopenharmony_ci/*
5562306a36Sopenharmony_ci * Make sure slab-allocated buffers are 64-bit aligned when atomic64_t uses
5662306a36Sopenharmony_ci * ARCv2 64-bit atomics (LLOCKD/SCONDD). This guarantess runtime 64-bit
5762306a36Sopenharmony_ci * alignment for any atomic64_t embedded in buffer.
5862306a36Sopenharmony_ci * Default ARCH_SLAB_MINALIGN is __alignof__(long long) which has a relaxed
5962306a36Sopenharmony_ci * value of 4 (and not 8) in ARC ABI.
6062306a36Sopenharmony_ci */
6162306a36Sopenharmony_ci#if defined(CONFIG_ARC_HAS_LL64) && defined(CONFIG_ARC_HAS_LLSC)
6262306a36Sopenharmony_ci#define ARCH_SLAB_MINALIGN	8
6362306a36Sopenharmony_ci#endif
6462306a36Sopenharmony_ci
6562306a36Sopenharmony_ciextern int ioc_enable;
6662306a36Sopenharmony_ciextern unsigned long perip_base, perip_end;
6762306a36Sopenharmony_ci
6862306a36Sopenharmony_ci#endif	/* !__ASSEMBLY__ */
6962306a36Sopenharmony_ci
7062306a36Sopenharmony_ci/* Instruction cache related Auxiliary registers */
7162306a36Sopenharmony_ci#define ARC_REG_IC_BCR		0x77	/* Build Config reg */
7262306a36Sopenharmony_ci#define ARC_REG_IC_IVIC		0x10
7362306a36Sopenharmony_ci#define ARC_REG_IC_CTRL		0x11
7462306a36Sopenharmony_ci#define ARC_REG_IC_IVIR		0x16
7562306a36Sopenharmony_ci#define ARC_REG_IC_ENDR		0x17
7662306a36Sopenharmony_ci#define ARC_REG_IC_IVIL		0x19
7762306a36Sopenharmony_ci#define ARC_REG_IC_PTAG		0x1E
7862306a36Sopenharmony_ci#define ARC_REG_IC_PTAG_HI	0x1F
7962306a36Sopenharmony_ci
8062306a36Sopenharmony_ci/* Bit val in IC_CTRL */
8162306a36Sopenharmony_ci#define IC_CTRL_DIS		0x1
8262306a36Sopenharmony_ci
8362306a36Sopenharmony_ci/* Data cache related Auxiliary registers */
8462306a36Sopenharmony_ci#define ARC_REG_DC_BCR		0x72	/* Build Config reg */
8562306a36Sopenharmony_ci#define ARC_REG_DC_IVDC		0x47
8662306a36Sopenharmony_ci#define ARC_REG_DC_CTRL		0x48
8762306a36Sopenharmony_ci#define ARC_REG_DC_IVDL		0x4A
8862306a36Sopenharmony_ci#define ARC_REG_DC_FLSH		0x4B
8962306a36Sopenharmony_ci#define ARC_REG_DC_FLDL		0x4C
9062306a36Sopenharmony_ci#define ARC_REG_DC_STARTR	0x4D
9162306a36Sopenharmony_ci#define ARC_REG_DC_ENDR		0x4E
9262306a36Sopenharmony_ci#define ARC_REG_DC_PTAG		0x5C
9362306a36Sopenharmony_ci#define ARC_REG_DC_PTAG_HI	0x5F
9462306a36Sopenharmony_ci
9562306a36Sopenharmony_ci/* Bit val in DC_CTRL */
9662306a36Sopenharmony_ci#define DC_CTRL_DIS		0x001
9762306a36Sopenharmony_ci#define DC_CTRL_INV_MODE_FLUSH	0x040
9862306a36Sopenharmony_ci#define DC_CTRL_FLUSH_STATUS	0x100
9962306a36Sopenharmony_ci#define DC_CTRL_RGN_OP_INV	0x200
10062306a36Sopenharmony_ci#define DC_CTRL_RGN_OP_MSK	0x200
10162306a36Sopenharmony_ci
10262306a36Sopenharmony_ci/*System-level cache (L2 cache) related Auxiliary registers */
10362306a36Sopenharmony_ci#define ARC_REG_SLC_CFG		0x901
10462306a36Sopenharmony_ci#define ARC_REG_SLC_CTRL	0x903
10562306a36Sopenharmony_ci#define ARC_REG_SLC_FLUSH	0x904
10662306a36Sopenharmony_ci#define ARC_REG_SLC_INVALIDATE	0x905
10762306a36Sopenharmony_ci#define ARC_AUX_SLC_IVDL	0x910
10862306a36Sopenharmony_ci#define ARC_AUX_SLC_FLDL	0x912
10962306a36Sopenharmony_ci#define ARC_REG_SLC_RGN_START	0x914
11062306a36Sopenharmony_ci#define ARC_REG_SLC_RGN_START1	0x915
11162306a36Sopenharmony_ci#define ARC_REG_SLC_RGN_END	0x916
11262306a36Sopenharmony_ci#define ARC_REG_SLC_RGN_END1	0x917
11362306a36Sopenharmony_ci
11462306a36Sopenharmony_ci/* Bit val in SLC_CONTROL */
11562306a36Sopenharmony_ci#define SLC_CTRL_DIS		0x001
11662306a36Sopenharmony_ci#define SLC_CTRL_IM		0x040
11762306a36Sopenharmony_ci#define SLC_CTRL_BUSY		0x100
11862306a36Sopenharmony_ci#define SLC_CTRL_RGN_OP_INV	0x200
11962306a36Sopenharmony_ci
12062306a36Sopenharmony_ci/* IO coherency related Auxiliary registers */
12162306a36Sopenharmony_ci#define ARC_REG_IO_COH_ENABLE	0x500
12262306a36Sopenharmony_ci#define ARC_IO_COH_ENABLE_BIT	BIT(0)
12362306a36Sopenharmony_ci#define ARC_REG_IO_COH_PARTIAL	0x501
12462306a36Sopenharmony_ci#define ARC_IO_COH_PARTIAL_BIT	BIT(0)
12562306a36Sopenharmony_ci#define ARC_REG_IO_COH_AP0_BASE	0x508
12662306a36Sopenharmony_ci#define ARC_REG_IO_COH_AP0_SIZE	0x509
12762306a36Sopenharmony_ci
12862306a36Sopenharmony_ci#endif /* _ASM_CACHE_H */
129