GNU Linux-libre 4.14.251-gnu1
[releases.git] / drivers / staging / media / atomisp / pci / atomisp2 / include / hmm / hmm_vm.h
1 /*
2  * Support for Medifield PNW Camera Imaging ISP subsystem.
3  *
4  * Copyright (c) 2010 Intel Corporation. All Rights Reserved.
5  *
6  * Copyright (c) 2010 Silicon Hive www.siliconhive.com.
7  *
8  * This program is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU General Public License version
10  * 2 as published by the Free Software Foundation.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program; if not, write to the Free Software
19  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
20  * 02110-1301, USA.
21  *
22  */
23
24 #ifndef __HMM_VM_H__
25 #define __HMM_VM_H__
26
27 #include <linux/kernel.h>
28 #include <linux/types.h>
29 #include <linux/mutex.h>
30 #include <linux/list.h>
31
32 struct hmm_vm {
33         unsigned int start;
34         unsigned int pgnr;
35         unsigned int size;
36         struct list_head vm_node_list;
37         spinlock_t lock;
38         struct kmem_cache *cache;
39 };
40
41 struct hmm_vm_node {
42         struct list_head list;
43         unsigned int start;
44         unsigned int pgnr;
45         unsigned int size;
46         struct hmm_vm *vm;
47 };
48 #define ISP_VM_START    0x0
49 #define ISP_VM_SIZE     (0x7FFFFFFF)    /* 2G address space */
50 #define ISP_PTR_NULL    NULL
51
52 int hmm_vm_init(struct hmm_vm *vm, unsigned int start,
53                 unsigned int size);
54
55 void hmm_vm_clean(struct hmm_vm *vm);
56
57 struct hmm_vm_node *hmm_vm_alloc_node(struct hmm_vm *vm,
58                 unsigned int pgnr);
59
60 void hmm_vm_free_node(struct hmm_vm_node *node);
61
62 struct hmm_vm_node *hmm_vm_find_node_start(struct hmm_vm *vm,
63                 unsigned int addr);
64
65 struct hmm_vm_node *hmm_vm_find_node_in_range(struct hmm_vm *vm,
66                 unsigned int addr);
67
68 #endif