19d4fa1a1SMauro Carvalho Chehab /* 29d4fa1a1SMauro Carvalho Chehab * Support for Medifield PNW Camera Imaging ISP subsystem. 39d4fa1a1SMauro Carvalho Chehab * 49d4fa1a1SMauro Carvalho Chehab * Copyright (c) 2010 Intel Corporation. All Rights Reserved. 59d4fa1a1SMauro Carvalho Chehab * 69d4fa1a1SMauro Carvalho Chehab * Copyright (c) 2010 Silicon Hive www.siliconhive.com. 79d4fa1a1SMauro Carvalho Chehab * 89d4fa1a1SMauro Carvalho Chehab * This program is free software; you can redistribute it and/or 99d4fa1a1SMauro Carvalho Chehab * modify it under the terms of the GNU General Public License version 109d4fa1a1SMauro Carvalho Chehab * 2 as published by the Free Software Foundation. 119d4fa1a1SMauro Carvalho Chehab * 129d4fa1a1SMauro Carvalho Chehab * This program is distributed in the hope that it will be useful, 139d4fa1a1SMauro Carvalho Chehab * but WITHOUT ANY WARRANTY; without even the implied warranty of 149d4fa1a1SMauro Carvalho Chehab * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 159d4fa1a1SMauro Carvalho Chehab * GNU General Public License for more details. 169d4fa1a1SMauro Carvalho Chehab * 179d4fa1a1SMauro Carvalho Chehab * 189d4fa1a1SMauro Carvalho Chehab */ 199d4fa1a1SMauro Carvalho Chehab 209d4fa1a1SMauro Carvalho Chehab #ifndef __HMM_H__ 219d4fa1a1SMauro Carvalho Chehab #define __HMM_H__ 229d4fa1a1SMauro Carvalho Chehab 239d4fa1a1SMauro Carvalho Chehab #include <linux/kernel.h> 249d4fa1a1SMauro Carvalho Chehab #include <linux/types.h> 259d4fa1a1SMauro Carvalho Chehab #include <linux/slab.h> 269d4fa1a1SMauro Carvalho Chehab #include <linux/mm.h> 279d4fa1a1SMauro Carvalho Chehab 289d4fa1a1SMauro Carvalho Chehab #include "hmm/hmm_pool.h" 299d4fa1a1SMauro Carvalho Chehab #include "ia_css_types.h" 309d4fa1a1SMauro Carvalho Chehab 319d4fa1a1SMauro Carvalho Chehab int hmm_pool_register(unsigned int pool_size, enum hmm_pool_type pool_type); 329d4fa1a1SMauro Carvalho Chehab void hmm_pool_unregister(enum hmm_pool_type pool_type); 339d4fa1a1SMauro Carvalho Chehab 349d4fa1a1SMauro Carvalho Chehab int hmm_init(void); 359d4fa1a1SMauro Carvalho Chehab void hmm_cleanup(void); 369d4fa1a1SMauro Carvalho Chehab 379d4fa1a1SMauro Carvalho Chehab ia_css_ptr hmm_alloc(size_t bytes, enum hmm_bo_type type, 38b92d99aeSMauro Carvalho Chehab int from_highmem, const void __user *userptr, 39b92d99aeSMauro Carvalho Chehab const uint16_t attrs); 409d4fa1a1SMauro Carvalho Chehab void hmm_free(ia_css_ptr ptr); 419d4fa1a1SMauro Carvalho Chehab int hmm_load(ia_css_ptr virt, void *data, unsigned int bytes); 429d4fa1a1SMauro Carvalho Chehab int hmm_store(ia_css_ptr virt, const void *data, unsigned int bytes); 439d4fa1a1SMauro Carvalho Chehab int hmm_set(ia_css_ptr virt, int c, unsigned int bytes); 449d4fa1a1SMauro Carvalho Chehab int hmm_flush(ia_css_ptr virt, unsigned int bytes); 459d4fa1a1SMauro Carvalho Chehab 469d4fa1a1SMauro Carvalho Chehab /* 479d4fa1a1SMauro Carvalho Chehab * get kernel memory physical address from ISP virtual address. 489d4fa1a1SMauro Carvalho Chehab */ 499d4fa1a1SMauro Carvalho Chehab phys_addr_t hmm_virt_to_phys(ia_css_ptr virt); 509d4fa1a1SMauro Carvalho Chehab 519d4fa1a1SMauro Carvalho Chehab /* 529d4fa1a1SMauro Carvalho Chehab * map ISP memory starts with virt to kernel virtual address 539d4fa1a1SMauro Carvalho Chehab * by using vmap. return NULL if failed. 549d4fa1a1SMauro Carvalho Chehab * 559d4fa1a1SMauro Carvalho Chehab * virt must be the start address of ISP memory (return by hmm_alloc), 569d4fa1a1SMauro Carvalho Chehab * do not pass any other address. 579d4fa1a1SMauro Carvalho Chehab */ 589d4fa1a1SMauro Carvalho Chehab void *hmm_vmap(ia_css_ptr virt, bool cached); 599d4fa1a1SMauro Carvalho Chehab void hmm_vunmap(ia_css_ptr virt); 609d4fa1a1SMauro Carvalho Chehab 619d4fa1a1SMauro Carvalho Chehab /* 629d4fa1a1SMauro Carvalho Chehab * flush the cache for the vmapped buffer. 639d4fa1a1SMauro Carvalho Chehab * if the buffer has not been vmapped, return directly. 649d4fa1a1SMauro Carvalho Chehab */ 659d4fa1a1SMauro Carvalho Chehab void hmm_flush_vmap(ia_css_ptr virt); 669d4fa1a1SMauro Carvalho Chehab 679d4fa1a1SMauro Carvalho Chehab /* 689d4fa1a1SMauro Carvalho Chehab * Address translation from ISP shared memory address to kernel virtual address 699d4fa1a1SMauro Carvalho Chehab * if the memory is not vmmaped, then do it. 709d4fa1a1SMauro Carvalho Chehab */ 719d4fa1a1SMauro Carvalho Chehab void *hmm_isp_vaddr_to_host_vaddr(ia_css_ptr ptr, bool cached); 729d4fa1a1SMauro Carvalho Chehab 739d4fa1a1SMauro Carvalho Chehab /* 749d4fa1a1SMauro Carvalho Chehab * Address translation from kernel virtual address to ISP shared memory address 759d4fa1a1SMauro Carvalho Chehab */ 769d4fa1a1SMauro Carvalho Chehab ia_css_ptr hmm_host_vaddr_to_hrt_vaddr(const void *ptr); 779d4fa1a1SMauro Carvalho Chehab 789d4fa1a1SMauro Carvalho Chehab /* 799d4fa1a1SMauro Carvalho Chehab * map ISP memory starts with virt to specific vma. 809d4fa1a1SMauro Carvalho Chehab * 819d4fa1a1SMauro Carvalho Chehab * used for mmap operation. 829d4fa1a1SMauro Carvalho Chehab * 839d4fa1a1SMauro Carvalho Chehab * virt must be the start address of ISP memory (return by hmm_alloc), 849d4fa1a1SMauro Carvalho Chehab * do not pass any other address. 859d4fa1a1SMauro Carvalho Chehab */ 869d4fa1a1SMauro Carvalho Chehab int hmm_mmap(struct vm_area_struct *vma, ia_css_ptr virt); 879d4fa1a1SMauro Carvalho Chehab 889d4fa1a1SMauro Carvalho Chehab /* show memory statistic 899d4fa1a1SMauro Carvalho Chehab */ 909d4fa1a1SMauro Carvalho Chehab void hmm_show_mem_stat(const char *func, const int line); 919d4fa1a1SMauro Carvalho Chehab 929d4fa1a1SMauro Carvalho Chehab /* init memory statistic 939d4fa1a1SMauro Carvalho Chehab */ 949d4fa1a1SMauro Carvalho Chehab void hmm_init_mem_stat(int res_pgnr, int dyc_en, int dyc_pgnr); 959d4fa1a1SMauro Carvalho Chehab 969d4fa1a1SMauro Carvalho Chehab extern bool dypool_enable; 979d4fa1a1SMauro Carvalho Chehab extern unsigned int dypool_pgnr; 989d4fa1a1SMauro Carvalho Chehab extern struct hmm_bo_device bo_device; 999d4fa1a1SMauro Carvalho Chehab 1009d4fa1a1SMauro Carvalho Chehab #endif 101