summaryrefslogtreecommitdiff
path: root/drivers/misc/hwmem/cache_handler.h
blob: 792105196fa758d0c00177058d253bff78238782 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
/*
 * Copyright (C) ST-Ericsson SA 2010
 *
 * Cache handler
 *
 * Author: Johan Mossberg <johan.xx.mossberg@stericsson.com>
 * for ST-Ericsson.
 *
 * License terms: GNU General Public License (GPL), version 2.
 */

/*
 * Cache handler can not handle simultaneous execution! The caller has to
 * ensure such a situation does not occur.
 */

#ifndef _CACHE_HANDLER_H_
#define _CACHE_HANDLER_H_

#include <linux/types.h>
#include <linux/hwmem.h>

/*
 * To not have to double all datatypes we've used hwmem datatypes. If someone
 * want's to use cache handler but not hwmem then we'll have to define our own
 * datatypes.
 */

struct cach_range {
	u32 start; /* Inclusive */
	u32 end; /* Exclusive */
};

/*
 * Internal, do not touch!
 */
struct cach_buf {
	void *vstart;
	u32 pstart;
	u32 size;

	/* Remaining hints are active */
	enum hwmem_alloc_flags cache_settings;

	bool in_cpu_write_buf;
	struct cach_range range_in_cpu_cache;
	struct cach_range range_dirty_in_cpu_cache;
	struct cach_range range_invalid_in_cpu_cache;
};

void cach_init_buf(struct cach_buf *buf,
			enum hwmem_alloc_flags cache_settings, u32 size);

void cach_set_buf_addrs(struct cach_buf *buf, void* vaddr, u32 paddr);

void cach_set_pgprot_cache_options(struct cach_buf *buf, pgprot_t *pgprot);

void cach_set_domain(struct cach_buf *buf, enum hwmem_access access,
			enum hwmem_domain domain, struct hwmem_region *region);

#endif /* _CACHE_HANDLER_H_ */