18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */
28c2ecf20Sopenharmony_ci/****************************************************************************/
38c2ecf20Sopenharmony_ci
48c2ecf20Sopenharmony_ci/*
58c2ecf20Sopenharmony_ci * m52xxacr.h -- ColdFire version 2 core cache support
68c2ecf20Sopenharmony_ci *
78c2ecf20Sopenharmony_ci * (C) Copyright 2010, Greg Ungerer <gerg@snapgear.com>
88c2ecf20Sopenharmony_ci */
98c2ecf20Sopenharmony_ci
108c2ecf20Sopenharmony_ci/****************************************************************************/
118c2ecf20Sopenharmony_ci#ifndef m52xxacr_h
128c2ecf20Sopenharmony_ci#define m52xxacr_h
138c2ecf20Sopenharmony_ci/****************************************************************************/
148c2ecf20Sopenharmony_ci
158c2ecf20Sopenharmony_ci/*
168c2ecf20Sopenharmony_ci * All varients of the ColdFire using version 2 cores have a similar
178c2ecf20Sopenharmony_ci * cache setup. Although not absolutely identical the cache register
188c2ecf20Sopenharmony_ci * definitions are compatible for all of them. Mostly they support a
198c2ecf20Sopenharmony_ci * configurable cache memory that can be instruction only, data only,
208c2ecf20Sopenharmony_ci * or split instruction and data. The exception is the very old version 2
218c2ecf20Sopenharmony_ci * core based parts, like the 5206(e), 5249 and 5272, which are instruction
228c2ecf20Sopenharmony_ci * cache only. Cache size varies from 2k up to 16k.
238c2ecf20Sopenharmony_ci */
248c2ecf20Sopenharmony_ci
258c2ecf20Sopenharmony_ci/*
268c2ecf20Sopenharmony_ci * Define the Cache Control register flags.
278c2ecf20Sopenharmony_ci */
288c2ecf20Sopenharmony_ci#define CACR_CENB	0x80000000	/* Enable cache */
298c2ecf20Sopenharmony_ci#define CACR_CDPI	0x10000000	/* Disable invalidation by CPUSHL */
308c2ecf20Sopenharmony_ci#define CACR_CFRZ	0x08000000	/* Cache freeze mode */
318c2ecf20Sopenharmony_ci#define CACR_CINV	0x01000000	/* Invalidate cache */
328c2ecf20Sopenharmony_ci#define CACR_DISI	0x00800000	/* Disable instruction cache */
338c2ecf20Sopenharmony_ci#define CACR_DISD	0x00400000	/* Disable data cache */
348c2ecf20Sopenharmony_ci#define CACR_INVI	0x00200000	/* Invalidate instruction cache */
358c2ecf20Sopenharmony_ci#define CACR_INVD	0x00100000	/* Invalidate data cache */
368c2ecf20Sopenharmony_ci#define CACR_CEIB	0x00000400	/* Non-cachable instruction burst */
378c2ecf20Sopenharmony_ci#define CACR_DCM	0x00000200	/* Default cache mode */
388c2ecf20Sopenharmony_ci#define CACR_DBWE	0x00000100	/* Buffered write enable */
398c2ecf20Sopenharmony_ci#define CACR_DWP	0x00000020	/* Write protection */
408c2ecf20Sopenharmony_ci#define CACR_EUSP	0x00000010	/* Enable separate user a7 */
418c2ecf20Sopenharmony_ci
428c2ecf20Sopenharmony_ci/*
438c2ecf20Sopenharmony_ci * Define the Access Control register flags.
448c2ecf20Sopenharmony_ci */
458c2ecf20Sopenharmony_ci#define ACR_BASE_POS	24		/* Address Base (upper 8 bits) */
468c2ecf20Sopenharmony_ci#define ACR_MASK_POS	16		/* Address Mask (next 8 bits) */
478c2ecf20Sopenharmony_ci#define ACR_ENABLE	0x00008000	/* Enable this ACR */
488c2ecf20Sopenharmony_ci#define ACR_USER	0x00000000	/* Allow only user accesses */
498c2ecf20Sopenharmony_ci#define ACR_SUPER	0x00002000	/* Allow supervisor access only */
508c2ecf20Sopenharmony_ci#define ACR_ANY		0x00004000	/* Allow any access type */
518c2ecf20Sopenharmony_ci#define ACR_CENB	0x00000000	/* Caching of region enabled */
528c2ecf20Sopenharmony_ci#define ACR_CDIS	0x00000040	/* Caching of region disabled */
538c2ecf20Sopenharmony_ci#define ACR_BWE		0x00000020	/* Write buffer enabled */
548c2ecf20Sopenharmony_ci#define ACR_WPROTECT	0x00000004	/* Write protect region */
558c2ecf20Sopenharmony_ci
568c2ecf20Sopenharmony_ci/*
578c2ecf20Sopenharmony_ci * Set the cache controller settings we will use. On the cores that support
588c2ecf20Sopenharmony_ci * a split cache configuration we allow all the combinations at Kconfig
598c2ecf20Sopenharmony_ci * time. For those cores that only have an instruction cache we just set
608c2ecf20Sopenharmony_ci * that as on.
618c2ecf20Sopenharmony_ci */
628c2ecf20Sopenharmony_ci#if defined(CONFIG_CACHE_I)
638c2ecf20Sopenharmony_ci#define CACHE_TYPE	(CACR_DISD + CACR_EUSP)
648c2ecf20Sopenharmony_ci#define CACHE_INVTYPEI	0
658c2ecf20Sopenharmony_ci#elif defined(CONFIG_CACHE_D)
668c2ecf20Sopenharmony_ci#define CACHE_TYPE	(CACR_DISI + CACR_EUSP)
678c2ecf20Sopenharmony_ci#define CACHE_INVTYPED	0
688c2ecf20Sopenharmony_ci#elif defined(CONFIG_CACHE_BOTH)
698c2ecf20Sopenharmony_ci#define CACHE_TYPE	CACR_EUSP
708c2ecf20Sopenharmony_ci#define CACHE_INVTYPEI	CACR_INVI
718c2ecf20Sopenharmony_ci#define CACHE_INVTYPED	CACR_INVD
728c2ecf20Sopenharmony_ci#else
738c2ecf20Sopenharmony_ci/* This is the instruction cache only devices (no split cache, no eusp) */
748c2ecf20Sopenharmony_ci#define CACHE_TYPE	0
758c2ecf20Sopenharmony_ci#define CACHE_INVTYPEI	0
768c2ecf20Sopenharmony_ci#endif
778c2ecf20Sopenharmony_ci
788c2ecf20Sopenharmony_ci#define CACHE_INIT	(CACR_CINV + CACHE_TYPE)
798c2ecf20Sopenharmony_ci#define CACHE_MODE	(CACR_CENB + CACHE_TYPE + CACR_DCM)
808c2ecf20Sopenharmony_ci
818c2ecf20Sopenharmony_ci#define CACHE_INVALIDATE  (CACHE_MODE + CACR_CINV)
828c2ecf20Sopenharmony_ci#if defined(CACHE_INVTYPEI)
838c2ecf20Sopenharmony_ci#define CACHE_INVALIDATEI (CACHE_MODE + CACR_CINV + CACHE_INVTYPEI)
848c2ecf20Sopenharmony_ci#endif
858c2ecf20Sopenharmony_ci#if defined(CACHE_INVTYPED)
868c2ecf20Sopenharmony_ci#define CACHE_INVALIDATED (CACHE_MODE + CACR_CINV + CACHE_INVTYPED)
878c2ecf20Sopenharmony_ci#endif
888c2ecf20Sopenharmony_ci
898c2ecf20Sopenharmony_ci#define ACR0_MODE	((CONFIG_RAMBASE & 0xff000000) + \
908c2ecf20Sopenharmony_ci			 (0x000f0000) + \
918c2ecf20Sopenharmony_ci			 (ACR_ENABLE + ACR_ANY + ACR_CENB + ACR_BWE))
928c2ecf20Sopenharmony_ci#define ACR1_MODE	0
938c2ecf20Sopenharmony_ci
948c2ecf20Sopenharmony_ci/****************************************************************************/
958c2ecf20Sopenharmony_ci#endif  /* m52xxsim_h */
96