1 /* SPDX-License-Identifier: GPL-2.0 */
2 /*
3  * Support for Medifield PNW Camera Imaging ISP subsystem.
4  *
5  * Copyright (c) 2010 Intel Corporation. All Rights Reserved.
6  *
7  * Copyright (c) 2010 Silicon Hive www.siliconhive.com.
8  *
9  * This program is free software; you can redistribute it and/or
10  * modify it under the terms of the GNU General Public License version
11  * 2 as published by the Free Software Foundation.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16  * GNU General Public License for more details.
17  *
18  *
19  */
20 
21 #ifndef	__HMM_H__
22 #define	__HMM_H__
23 
24 #include <linux/kernel.h>
25 #include <linux/types.h>
26 #include <linux/slab.h>
27 #include <linux/mm.h>
28 
29 #include "hmm_common.h"
30 #include "hmm/hmm_bo.h"
31 #include "ia_css_types.h"
32 
33 #define mmgr_NULL              ((ia_css_ptr)0)
34 #define mmgr_EXCEPTION         ((ia_css_ptr) - 1)
35 
36 int hmm_init(void);
37 void hmm_cleanup(void);
38 
39 ia_css_ptr hmm_alloc(size_t bytes);
40 ia_css_ptr hmm_create_from_vmalloc_buf(size_t bytes, void *vmalloc_addr);
41 
42 void hmm_free(ia_css_ptr ptr);
43 int hmm_load(ia_css_ptr virt, void *data, unsigned int bytes);
44 int hmm_store(ia_css_ptr virt, const void *data, unsigned int bytes);
45 int hmm_set(ia_css_ptr virt, int c, unsigned int bytes);
46 int hmm_flush(ia_css_ptr virt, unsigned int bytes);
47 
48 /*
49  * get kernel memory physical address from ISP virtual address.
50  */
51 phys_addr_t hmm_virt_to_phys(ia_css_ptr virt);
52 
53 /*
54  * map ISP memory starts with virt to kernel virtual address
55  * by using vmap. return NULL if failed.
56  *
57  * virt must be the start address of ISP memory (return by hmm_alloc),
58  * do not pass any other address.
59  */
60 void *hmm_vmap(ia_css_ptr virt, bool cached);
61 void hmm_vunmap(ia_css_ptr virt);
62 
63 /*
64  * flush the cache for the vmapped buffer.
65  * if the buffer has not been vmapped, return directly.
66  */
67 void hmm_flush_vmap(ia_css_ptr virt);
68 
69 /*
70  * map ISP memory starts with virt to specific vma.
71  *
72  * used for mmap operation.
73  *
74  * virt must be the start address of ISP memory (return by hmm_alloc),
75  * do not pass any other address.
76  */
77 int hmm_mmap(struct vm_area_struct *vma, ia_css_ptr virt);
78 
79 extern struct hmm_bo_device bo_device;
80 
81 #endif
82