162306a36Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */
262306a36Sopenharmony_ci/****************************************************************************/
362306a36Sopenharmony_ci
462306a36Sopenharmony_ci/*
562306a36Sopenharmony_ci * m52xxacr.h -- ColdFire version 2 core cache support
662306a36Sopenharmony_ci *
762306a36Sopenharmony_ci * (C) Copyright 2010, Greg Ungerer <gerg@snapgear.com>
862306a36Sopenharmony_ci */
962306a36Sopenharmony_ci
1062306a36Sopenharmony_ci/****************************************************************************/
1162306a36Sopenharmony_ci#ifndef m52xxacr_h
1262306a36Sopenharmony_ci#define m52xxacr_h
1362306a36Sopenharmony_ci/****************************************************************************/
1462306a36Sopenharmony_ci
1562306a36Sopenharmony_ci/*
1662306a36Sopenharmony_ci * All varients of the ColdFire using version 2 cores have a similar
1762306a36Sopenharmony_ci * cache setup. Although not absolutely identical the cache register
1862306a36Sopenharmony_ci * definitions are compatible for all of them. Mostly they support a
1962306a36Sopenharmony_ci * configurable cache memory that can be instruction only, data only,
2062306a36Sopenharmony_ci * or split instruction and data. The exception is the very old version 2
2162306a36Sopenharmony_ci * core based parts, like the 5206(e), 5249 and 5272, which are instruction
2262306a36Sopenharmony_ci * cache only. Cache size varies from 2k up to 16k.
2362306a36Sopenharmony_ci */
2462306a36Sopenharmony_ci
2562306a36Sopenharmony_ci/*
2662306a36Sopenharmony_ci * Define the Cache Control register flags.
2762306a36Sopenharmony_ci */
2862306a36Sopenharmony_ci#define CACR_CENB	0x80000000	/* Enable cache */
2962306a36Sopenharmony_ci#define CACR_CDPI	0x10000000	/* Disable invalidation by CPUSHL */
3062306a36Sopenharmony_ci#define CACR_CFRZ	0x08000000	/* Cache freeze mode */
3162306a36Sopenharmony_ci#define CACR_CINV	0x01000000	/* Invalidate cache */
3262306a36Sopenharmony_ci#define CACR_DISI	0x00800000	/* Disable instruction cache */
3362306a36Sopenharmony_ci#define CACR_DISD	0x00400000	/* Disable data cache */
3462306a36Sopenharmony_ci#define CACR_INVI	0x00200000	/* Invalidate instruction cache */
3562306a36Sopenharmony_ci#define CACR_INVD	0x00100000	/* Invalidate data cache */
3662306a36Sopenharmony_ci#define CACR_CEIB	0x00000400	/* Non-cachable instruction burst */
3762306a36Sopenharmony_ci#define CACR_DCM	0x00000200	/* Default cache mode */
3862306a36Sopenharmony_ci#define CACR_DBWE	0x00000100	/* Buffered write enable */
3962306a36Sopenharmony_ci#define CACR_DWP	0x00000020	/* Write protection */
4062306a36Sopenharmony_ci#define CACR_EUSP	0x00000010	/* Enable separate user a7 */
4162306a36Sopenharmony_ci
4262306a36Sopenharmony_ci/*
4362306a36Sopenharmony_ci * Define the Access Control register flags.
4462306a36Sopenharmony_ci */
4562306a36Sopenharmony_ci#define ACR_BASE_POS	24		/* Address Base (upper 8 bits) */
4662306a36Sopenharmony_ci#define ACR_MASK_POS	16		/* Address Mask (next 8 bits) */
4762306a36Sopenharmony_ci#define ACR_ENABLE	0x00008000	/* Enable this ACR */
4862306a36Sopenharmony_ci#define ACR_USER	0x00000000	/* Allow only user accesses */
4962306a36Sopenharmony_ci#define ACR_SUPER	0x00002000	/* Allow supervisor access only */
5062306a36Sopenharmony_ci#define ACR_ANY		0x00004000	/* Allow any access type */
5162306a36Sopenharmony_ci#define ACR_CENB	0x00000000	/* Caching of region enabled */
5262306a36Sopenharmony_ci#define ACR_CDIS	0x00000040	/* Caching of region disabled */
5362306a36Sopenharmony_ci#define ACR_BWE		0x00000020	/* Write buffer enabled */
5462306a36Sopenharmony_ci#define ACR_WPROTECT	0x00000004	/* Write protect region */
5562306a36Sopenharmony_ci
5662306a36Sopenharmony_ci/*
5762306a36Sopenharmony_ci * Set the cache controller settings we will use. On the cores that support
5862306a36Sopenharmony_ci * a split cache configuration we allow all the combinations at Kconfig
5962306a36Sopenharmony_ci * time. For those cores that only have an instruction cache we just set
6062306a36Sopenharmony_ci * that as on.
6162306a36Sopenharmony_ci */
6262306a36Sopenharmony_ci#if defined(CONFIG_CACHE_I)
6362306a36Sopenharmony_ci#define CACHE_TYPE	(CACR_DISD + CACR_EUSP)
6462306a36Sopenharmony_ci#define CACHE_INVTYPEI	0
6562306a36Sopenharmony_ci#elif defined(CONFIG_CACHE_D)
6662306a36Sopenharmony_ci#define CACHE_TYPE	(CACR_DISI + CACR_EUSP)
6762306a36Sopenharmony_ci#define CACHE_INVTYPED	0
6862306a36Sopenharmony_ci#elif defined(CONFIG_CACHE_BOTH)
6962306a36Sopenharmony_ci#define CACHE_TYPE	CACR_EUSP
7062306a36Sopenharmony_ci#define CACHE_INVTYPEI	CACR_INVI
7162306a36Sopenharmony_ci#define CACHE_INVTYPED	CACR_INVD
7262306a36Sopenharmony_ci#else
7362306a36Sopenharmony_ci/* This is the instruction cache only devices (no split cache, no eusp) */
7462306a36Sopenharmony_ci#define CACHE_TYPE	0
7562306a36Sopenharmony_ci#define CACHE_INVTYPEI	0
7662306a36Sopenharmony_ci#endif
7762306a36Sopenharmony_ci
7862306a36Sopenharmony_ci#define CACHE_INIT	(CACR_CINV + CACHE_TYPE)
7962306a36Sopenharmony_ci#define CACHE_MODE	(CACR_CENB + CACHE_TYPE + CACR_DCM)
8062306a36Sopenharmony_ci
8162306a36Sopenharmony_ci#define CACHE_INVALIDATE  (CACHE_MODE + CACR_CINV)
8262306a36Sopenharmony_ci#if defined(CACHE_INVTYPEI)
8362306a36Sopenharmony_ci#define CACHE_INVALIDATEI (CACHE_MODE + CACR_CINV + CACHE_INVTYPEI)
8462306a36Sopenharmony_ci#endif
8562306a36Sopenharmony_ci#if defined(CACHE_INVTYPED)
8662306a36Sopenharmony_ci#define CACHE_INVALIDATED (CACHE_MODE + CACR_CINV + CACHE_INVTYPED)
8762306a36Sopenharmony_ci#endif
8862306a36Sopenharmony_ci
8962306a36Sopenharmony_ci#define ACR0_MODE	((CONFIG_RAMBASE & 0xff000000) + \
9062306a36Sopenharmony_ci			 (0x000f0000) + \
9162306a36Sopenharmony_ci			 (ACR_ENABLE + ACR_ANY + ACR_CENB + ACR_BWE))
9262306a36Sopenharmony_ci#define ACR1_MODE	0
9362306a36Sopenharmony_ci
9462306a36Sopenharmony_ci/****************************************************************************/
9562306a36Sopenharmony_ci#endif  /* m52xxsim_h */
96