2005-04-16 16:20:36 -06:00
|
|
|
/*
|
|
|
|
* linux/arch/m32r/mm/cache.c
|
|
|
|
*
|
2006-01-06 01:18:44 -07:00
|
|
|
* Copyright (C) 2002-2005 Hirokazu Takata, Hayato Fujiwara
|
2005-04-16 16:20:36 -06:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <asm/pgtable.h>
|
|
|
|
|
|
|
|
#undef MCCR
|
|
|
|
|
2006-01-06 01:18:44 -07:00
|
|
|
#if defined(CONFIG_CHIP_XNUX2) || defined(CONFIG_CHIP_M32700) \
|
|
|
|
|| defined(CONFIG_CHIP_VDEC2) || defined(CONFIG_CHIP_OPSP)
|
2005-04-16 16:20:36 -06:00
|
|
|
/* Cache Control Register */
|
|
|
|
#define MCCR ((volatile unsigned long*)0xfffffffc)
|
|
|
|
#define MCCR_CC (1UL << 7) /* Cache mode modify bit */
|
|
|
|
#define MCCR_IIV (1UL << 6) /* I-cache invalidate */
|
|
|
|
#define MCCR_DIV (1UL << 5) /* D-cache invalidate */
|
|
|
|
#define MCCR_DCB (1UL << 4) /* D-cache copy back */
|
|
|
|
#define MCCR_ICM (1UL << 1) /* I-cache mode [0:off,1:on] */
|
|
|
|
#define MCCR_DCM (1UL << 0) /* D-cache mode [0:off,1:on] */
|
|
|
|
#define MCCR_ICACHE_INV (MCCR_CC|MCCR_IIV)
|
|
|
|
#define MCCR_DCACHE_CB (MCCR_CC|MCCR_DCB)
|
|
|
|
#define MCCR_DCACHE_CBINV (MCCR_CC|MCCR_DIV|MCCR_DCB)
|
|
|
|
#define CHECK_MCCR(mccr) (mccr = *MCCR)
|
|
|
|
#elif defined(CONFIG_CHIP_M32102)
|
|
|
|
#define MCCR ((volatile unsigned char*)0xfffffffe)
|
|
|
|
#define MCCR_IIV (1UL << 0) /* I-cache invalidate */
|
|
|
|
#define MCCR_ICACHE_INV MCCR_IIV
|
2006-01-06 01:18:41 -07:00
|
|
|
#elif defined(CONFIG_CHIP_M32104)
|
2006-01-06 01:18:44 -07:00
|
|
|
#define MCCR ((volatile unsigned short*)0xfffffffe)
|
2006-01-06 01:18:41 -07:00
|
|
|
#define MCCR_IIV (1UL << 8) /* I-cache invalidate */
|
|
|
|
#define MCCR_DIV (1UL << 9) /* D-cache invalidate */
|
|
|
|
#define MCCR_DCB (1UL << 10) /* D-cache copy back */
|
|
|
|
#define MCCR_ICM (1UL << 0) /* I-cache mode [0:off,1:on] */
|
|
|
|
#define MCCR_DCM (1UL << 1) /* D-cache mode [0:off,1:on] */
|
|
|
|
#define MCCR_ICACHE_INV MCCR_IIV
|
|
|
|
#define MCCR_DCACHE_CB MCCR_DCB
|
|
|
|
#define MCCR_DCACHE_CBINV (MCCR_DIV|MCCR_DCB)
|
2006-01-06 01:18:44 -07:00
|
|
|
#endif
|
2005-04-16 16:20:36 -06:00
|
|
|
|
|
|
|
#ifndef MCCR
|
|
|
|
#error Unknown cache type.
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
/* Copy back and invalidate D-cache and invalidate I-cache all */
|
|
|
|
void _flush_cache_all(void)
|
|
|
|
{
|
|
|
|
#if defined(CONFIG_CHIP_M32102)
|
2006-01-06 01:18:44 -07:00
|
|
|
unsigned char mccr;
|
2005-04-16 16:20:36 -06:00
|
|
|
*MCCR = MCCR_ICACHE_INV;
|
2006-01-06 01:18:44 -07:00
|
|
|
#elif defined(CONFIG_CHIP_M32104)
|
|
|
|
unsigned short mccr;
|
|
|
|
|
|
|
|
/* Copyback and invalidate D-cache */
|
|
|
|
/* Invalidate I-cache */
|
|
|
|
*MCCR |= (MCCR_ICACHE_INV | MCCR_DCACHE_CBINV);
|
2005-04-16 16:20:36 -06:00
|
|
|
#else
|
|
|
|
unsigned long mccr;
|
|
|
|
|
|
|
|
/* Copyback and invalidate D-cache */
|
|
|
|
/* Invalidate I-cache */
|
|
|
|
*MCCR = MCCR_ICACHE_INV | MCCR_DCACHE_CBINV;
|
|
|
|
#endif
|
2006-01-06 01:18:44 -07:00
|
|
|
while ((mccr = *MCCR) & MCCR_IIV); /* loop while invalidating... */
|
2005-04-16 16:20:36 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Copy back D-cache and invalidate I-cache all */
|
|
|
|
void _flush_cache_copyback_all(void)
|
|
|
|
{
|
|
|
|
#if defined(CONFIG_CHIP_M32102)
|
2006-01-06 01:18:44 -07:00
|
|
|
unsigned char mccr;
|
2005-04-16 16:20:36 -06:00
|
|
|
*MCCR = MCCR_ICACHE_INV;
|
2006-01-06 01:18:44 -07:00
|
|
|
#elif defined(CONFIG_CHIP_M32104)
|
|
|
|
unsigned short mccr;
|
|
|
|
|
|
|
|
/* Copyback and invalidate D-cache */
|
|
|
|
/* Invalidate I-cache */
|
|
|
|
*MCCR |= (MCCR_ICACHE_INV | MCCR_DCACHE_CB);
|
2005-04-16 16:20:36 -06:00
|
|
|
#else
|
|
|
|
unsigned long mccr;
|
|
|
|
|
|
|
|
/* Copyback D-cache */
|
|
|
|
/* Invalidate I-cache */
|
|
|
|
*MCCR = MCCR_ICACHE_INV | MCCR_DCACHE_CB;
|
|
|
|
#endif
|
2006-01-06 01:18:44 -07:00
|
|
|
while ((mccr = *MCCR) & MCCR_IIV); /* loop while invalidating... */
|
2005-04-16 16:20:36 -06:00
|
|
|
}
|