^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) /* SPDX-License-Identifier: GPL-2.0 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) * Copyright (C) Rockchip Electronics Co.Ltd
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) * Author: Felix Zeng <felix.zeng@rock-chips.com>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) #ifndef __LINUX_RKNPU_MEM_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) #define __LINUX_RKNPU_MEM_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) #include <linux/mm_types.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) #include <linux/version.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) * rknpu DMA buffer structure.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) * @flags: indicate memory type to allocated buffer and cache attribute.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) * @size: size requested from user, in bytes and this size is aligned
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) * in page unit.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) * @kv_addr: kernel virtual address to allocated memory region.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) * @dma_addr: bus address(accessed by dma) to allocated memory region.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) * - this address could be physical address without IOMMU and
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) * device address with IOMMU.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) * @pages: Array of backing pages.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) * @sgt: Imported sg_table.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) * @dmabuf: buffer for this attachment.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) * @owner: Is this memory internally allocated.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) struct rknpu_mem_object {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) unsigned long flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) unsigned long size;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) void __iomem *kv_addr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) dma_addr_t dma_addr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) struct page **pages;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) struct sg_table *sgt;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) struct dma_buf *dmabuf;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) unsigned int owner;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) int rknpu_mem_create_ioctl(struct rknpu_device *rknpu_dev, unsigned long data);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) int rknpu_mem_destroy_ioctl(struct rknpu_device *rknpu_dev, unsigned long data);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) int rknpu_mem_sync_ioctl(struct rknpu_device *rknpu_dev, unsigned long data);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) #endif