1 /* 2 * Copyright (C) 2021 HiSilicon (Shanghai) Technologies CO., LIMITED. 3 * 4 * This program is free software; you can redistribute it and/or 5 * modify it under the terms of the GNU General Public License 6 * as published by the Free Software Foundation; either version 2 7 * of the License, or (at your option) any later version. 8 * 9 * This program is distributed in the hope that it will be useful, 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 * GNU General Public License for more details. 13 * 14 * You should have received a copy of the GNU General Public License 15 * along with this program; if not, write to the Free Software 16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 17 */ 18 19 #ifndef __ALLOCATOR_H__ 20 #define __ALLOCATOR_H__ 21 22 #include <linux/device.h> 23 #include "osal_mmz.h" 24 25 #define NAME_LEN_MAX 64 26 27 struct mmz_allocator { 28 int (*init)(char *args); 29 hil_mmb_t *(*mmb_alloc)(const char *name, 30 unsigned long size, 31 unsigned long align, 32 unsigned long gfp, 33 const char *mmz_name, 34 hil_mmz_t *_user_mmz); 35 hil_mmb_t *(*mmb_alloc_v2)(const char *name, 36 unsigned long size, 37 unsigned long align, 38 unsigned long gfp, 39 const char *mmz_name, 40 hil_mmz_t *_user_mmz, 41 unsigned int order); 42 void *(*mmb_map2kern)(hil_mmb_t *mmb, int cached); 43 int (*mmb_unmap)(hil_mmb_t *mmb); 44 void (*mmb_free)(hil_mmb_t *mmb); 45 void *(*mmf_map)(phys_addr_t phys, int len, int cache); 46 void (*mmf_unmap)(void *virt); 47 }; 48 49 int cma_allocator_setopt(struct mmz_allocator *allocator); 50 int hisi_allocator_setopt(struct mmz_allocator *allocator); 51 52 #endif /* __ALLOCATOR_H__ */ 53