summaryrefstree
path: root/kernel/include/misc/exynos_ima.h
blob: 00679fc8e3c9e26942ea24abeceb1e353cb84a87 (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
62
63
64
65
66
67
68
69
70
71
72
73
/*
 * Copyright (c) 2012 Samsung Electronics Co., Ltd.
 *		http://www.samsung.com
 *
 * Header file for Exynos Scaler driver
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 as
 * published by the Free Software Foundation.
*/

#ifndef __EXYNOS_IMA_H_
#define __EXYNOS_IMA_H_

#include <linux/delay.h>
#include <linux/genalloc.h>
#include <linux/sched.h>
#include <linux/spinlock.h>
#include <linux/types.h>

struct ima_client;

typedef int (*ima_reclaim_callback_t)(struct ima_client *,
					struct device *, void *);

struct ima_client {
	struct list_head node;
	struct device *dev;
	struct ima_dev *ima_dev;
	ima_reclaim_callback_t reclaim_callback;
	struct list_head buffer_list;
	spinlock_t lock;
	void *priv;
	atomic_t refcount;
};

struct ima_buffer {
	struct list_head node;
	void *addr;
	unsigned long size;
	struct ima_client *client;
};

enum ima_state {
	IMA_STATE_IDLE = 0,
	IMA_STATE_HOST,
	IMA_STATE_CLIENT,
	IMA_STATE_RECLAIMING,
};

struct ima_dev {
	struct list_head client_list;
	enum ima_state state;
	struct device *dev;
	struct gen_pool *pool;
	spinlock_t lock;
	spinlock_t statelock;
	struct clk *clock;
	atomic_t refcount;
	void __iomem *sysreg_base;
	void __iomem *pre_base;
};

struct ima_client *ima_create_client(struct device *dev,
		ima_reclaim_callback_t reclaim_callback, void *priv);
void ima_destroy_client(struct ima_client *client);
void *ima_alloc(struct ima_client *client, unsigned long size,
						unsigned long flags);
void ima_free(struct ima_client *client, void *vaddr);
phys_addr_t ima_get_dma_addr(struct ima_client *client, void *vaddr);
void ima_host_begin(void);
void ima_host_end(void);
#endif /* __EXYNOS_IMA_H_ */