2019-05-30 06:57:47 +07:00
|
|
|
/* SPDX-License-Identifier: GPL-2.0-only */
|
2010-03-24 22:46:52 +07:00
|
|
|
/*
|
|
|
|
* arch/arm/include/asm/outercache.h
|
|
|
|
*
|
|
|
|
* Copyright (C) 2010 ARM Ltd.
|
|
|
|
* Written by Catalin Marinas <catalin.marinas@arm.com>
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef __ASM_OUTERCACHE_H
|
|
|
|
#define __ASM_OUTERCACHE_H
|
|
|
|
|
2011-02-15 18:41:49 +07:00
|
|
|
#include <linux/types.h>
|
|
|
|
|
2015-01-08 13:51:07 +07:00
|
|
|
struct l2x0_regs;
|
|
|
|
|
2010-03-24 22:46:52 +07:00
|
|
|
struct outer_cache_fns {
|
|
|
|
void (*inv_range)(unsigned long, unsigned long);
|
|
|
|
void (*clean_range)(unsigned long, unsigned long);
|
|
|
|
void (*flush_range)(unsigned long, unsigned long);
|
2010-07-31 22:36:06 +07:00
|
|
|
void (*flush_all)(void);
|
|
|
|
void (*disable)(void);
|
2010-03-24 22:47:53 +07:00
|
|
|
#ifdef CONFIG_OUTER_CACHE_SYNC
|
|
|
|
void (*sync)(void);
|
|
|
|
#endif
|
2011-09-30 20:43:12 +07:00
|
|
|
void (*resume)(void);
|
2014-03-17 00:38:08 +07:00
|
|
|
|
|
|
|
/* This is an ARM L2C thing */
|
|
|
|
void (*write_sec)(unsigned long, unsigned);
|
2015-01-08 13:51:07 +07:00
|
|
|
void (*configure)(const struct l2x0_regs *);
|
2010-03-24 22:46:52 +07:00
|
|
|
};
|
|
|
|
|
|
|
|
extern struct outer_cache_fns outer_cache;
|
|
|
|
|
2013-08-18 08:12:57 +07:00
|
|
|
#ifdef CONFIG_OUTER_CACHE
|
2014-03-16 17:52:55 +07:00
|
|
|
/**
|
|
|
|
* outer_inv_range - invalidate range of outer cache lines
|
|
|
|
* @start: starting physical address, inclusive
|
|
|
|
* @end: end physical address, exclusive
|
|
|
|
*/
|
2011-02-15 18:41:49 +07:00
|
|
|
static inline void outer_inv_range(phys_addr_t start, phys_addr_t end)
|
2010-03-24 22:46:52 +07:00
|
|
|
{
|
|
|
|
if (outer_cache.inv_range)
|
|
|
|
outer_cache.inv_range(start, end);
|
|
|
|
}
|
2014-03-16 17:52:55 +07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* outer_clean_range - clean dirty outer cache lines
|
|
|
|
* @start: starting physical address, inclusive
|
|
|
|
* @end: end physical address, exclusive
|
|
|
|
*/
|
2011-02-15 18:41:49 +07:00
|
|
|
static inline void outer_clean_range(phys_addr_t start, phys_addr_t end)
|
2010-03-24 22:46:52 +07:00
|
|
|
{
|
|
|
|
if (outer_cache.clean_range)
|
|
|
|
outer_cache.clean_range(start, end);
|
|
|
|
}
|
2014-03-16 17:52:55 +07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* outer_flush_range - clean and invalidate outer cache lines
|
|
|
|
* @start: starting physical address, inclusive
|
|
|
|
* @end: end physical address, exclusive
|
|
|
|
*/
|
2011-02-15 18:41:49 +07:00
|
|
|
static inline void outer_flush_range(phys_addr_t start, phys_addr_t end)
|
2010-03-24 22:46:52 +07:00
|
|
|
{
|
|
|
|
if (outer_cache.flush_range)
|
|
|
|
outer_cache.flush_range(start, end);
|
|
|
|
}
|
|
|
|
|
2014-03-16 17:52:55 +07:00
|
|
|
/**
|
|
|
|
* outer_flush_all - clean and invalidate all cache lines in the outer cache
|
|
|
|
*
|
|
|
|
* Note: depending on implementation, this may not be atomic - it must
|
|
|
|
* only be called with interrupts disabled and no other active outer
|
|
|
|
* cache masters.
|
|
|
|
*
|
|
|
|
* It is intended that this function is only used by implementations
|
|
|
|
* needing to override the outer_cache.disable() method due to security.
|
|
|
|
* (Some implementations perform this as a clean followed by an invalidate.)
|
|
|
|
*/
|
2010-07-31 22:36:06 +07:00
|
|
|
static inline void outer_flush_all(void)
|
|
|
|
{
|
|
|
|
if (outer_cache.flush_all)
|
|
|
|
outer_cache.flush_all();
|
|
|
|
}
|
|
|
|
|
2014-03-16 17:52:55 +07:00
|
|
|
/**
|
|
|
|
* outer_disable - clean, invalidate and disable the outer cache
|
|
|
|
*
|
|
|
|
* Disable the outer cache, ensuring that any data contained in the outer
|
|
|
|
* cache is pushed out to lower levels of system memory. The note and
|
|
|
|
* conditions above concerning outer_flush_all() applies here.
|
|
|
|
*/
|
2014-03-16 20:14:38 +07:00
|
|
|
extern void outer_disable(void);
|
2010-07-31 22:36:06 +07:00
|
|
|
|
2014-03-16 17:52:55 +07:00
|
|
|
/**
|
|
|
|
* outer_resume - restore the cache configuration and re-enable outer cache
|
|
|
|
*
|
|
|
|
* Restore any configuration that the cache had when previously enabled,
|
|
|
|
* and re-enable the outer cache.
|
|
|
|
*/
|
2011-09-30 20:43:12 +07:00
|
|
|
static inline void outer_resume(void)
|
|
|
|
{
|
|
|
|
if (outer_cache.resume)
|
|
|
|
outer_cache.resume();
|
|
|
|
}
|
|
|
|
|
2010-03-24 22:46:52 +07:00
|
|
|
#else
|
|
|
|
|
2011-02-15 18:41:49 +07:00
|
|
|
static inline void outer_inv_range(phys_addr_t start, phys_addr_t end)
|
2010-03-24 22:46:52 +07:00
|
|
|
{ }
|
2011-02-15 18:41:49 +07:00
|
|
|
static inline void outer_clean_range(phys_addr_t start, phys_addr_t end)
|
2010-03-24 22:46:52 +07:00
|
|
|
{ }
|
2011-02-15 18:41:49 +07:00
|
|
|
static inline void outer_flush_range(phys_addr_t start, phys_addr_t end)
|
2010-03-24 22:46:52 +07:00
|
|
|
{ }
|
2010-07-31 22:36:06 +07:00
|
|
|
static inline void outer_flush_all(void) { }
|
|
|
|
static inline void outer_disable(void) { }
|
2013-02-04 13:46:57 +07:00
|
|
|
static inline void outer_resume(void) { }
|
2010-03-24 22:46:52 +07:00
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#endif /* __ASM_OUTERCACHE_H */
|