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 10 #ifndef __HMM_H__ 11 #define __HMM_H__ 12 13 #include <linux/kernel.h> 14 #include <linux/types.h> 15 #include <linux/slab.h> 16 #include <linux/mm.h> 17 18 #include "hmm_common.h" 19 #include "hmm/hmm_bo.h" 20 #include "ia_css_types.h" 21 22 #define mmgr_NULL ((ia_css_ptr)0) 23 #define mmgr_EXCEPTION ((ia_css_ptr) - 1) 24 25 int hmm_init(void); 26 void hmm_cleanup(void); 27 28 ia_css_ptr hmm_alloc(size_t bytes); 29 ia_css_ptr hmm_create_from_vmalloc_buf(size_t bytes, void *vmalloc_addr); 30 31 void hmm_free(ia_css_ptr ptr); 32 int hmm_load(ia_css_ptr virt, void *data, unsigned int bytes); 33 int hmm_store(ia_css_ptr virt, const void *data, unsigned int bytes); 34 int hmm_set(ia_css_ptr virt, int c, unsigned int bytes); 35 int hmm_flush(ia_css_ptr virt, unsigned int bytes); 36 37 /* 38 * get kernel memory physical address from ISP virtual address. 39 */ 40 phys_addr_t hmm_virt_to_phys(ia_css_ptr virt); 41 42 /* 43 * map ISP memory starts with virt to kernel virtual address 44 * by using vmap. return NULL if failed. 45 * 46 * virt must be the start address of ISP memory (return by hmm_alloc), 47 * do not pass any other address. 48 */ 49 void *hmm_vmap(ia_css_ptr virt, bool cached); 50 void hmm_vunmap(ia_css_ptr virt); 51 52 /* 53 * flush the cache for the vmapped buffer. 54 * if the buffer has not been vmapped, return directly. 55 */ 56 void hmm_flush_vmap(ia_css_ptr virt); 57 58 /* 59 * map ISP memory starts with virt to specific vma. 60 * 61 * used for mmap operation. 62 * 63 * virt must be the start address of ISP memory (return by hmm_alloc), 64 * do not pass any other address. 65 */ 66 int hmm_mmap(struct vm_area_struct *vma, ia_css_ptr virt); 67 68 extern struct hmm_bo_device bo_device; 69 70 #endif 71