62 lines · c
1/* SPDX-License-Identifier: GPL-2.0 */2/*3 * Copyright 2018-2020 Broadcom.4 */5 6#ifndef BCM_VK_SG_H7#define BCM_VK_SG_H8 9#include <linux/dma-mapping.h>10 11struct bcm_vk_dma {12 /* for userland buffer */13 struct page **pages;14 int nr_pages;15 16 /* common */17 dma_addr_t handle;18 /*19 * sglist is of the following LE format20 * [U32] num_sg = number of sg addresses (N)21 * [U32] totalsize = totalsize of data being transferred in sglist22 * [U32] size[0] = size of data in address023 * [U32] addr_l[0] = lower 32-bits of address024 * [U32] addr_h[0] = higher 32-bits of address025 * ..26 * [U32] size[N-1] = size of data in addressN-127 * [U32] addr_l[N-1] = lower 32-bits of addressN-128 * [U32] addr_h[N-1] = higher 32-bits of addressN-129 */30 u32 *sglist;31#define SGLIST_NUM_SG 032#define SGLIST_TOTALSIZE 133#define SGLIST_VKDATA_START 234 35 int sglen; /* Length (bytes) of sglist */36 int direction;37};38 39struct _vk_data {40 u32 size; /* data size in bytes */41 u64 address; /* Pointer to data */42} __packed;43 44/*45 * Scatter-gather DMA buffer API.46 *47 * These functions provide a simple way to create a page list and a48 * scatter-gather list from userspace address and map the memory49 * for DMA operation.50 */51int bcm_vk_sg_alloc(struct device *dev,52 struct bcm_vk_dma *dma,53 int dir,54 struct _vk_data *vkdata,55 int num);56 57int bcm_vk_sg_free(struct device *dev, struct bcm_vk_dma *dma, int num,58 int *proc_cnt);59 60#endif61 62