Merge tag 'trace-printf-v6.13' of git://git.kernel.org/pub/scm/linux/kernel/git/trace...
[drm/drm-misc.git] / drivers / misc / bcm-vk / bcm_vk_sg.h
blob81b3d0976ddb5cbe6afa9c45af95e13a10fe45b0
1 /* SPDX-License-Identifier: GPL-2.0 */
2 /*
3 * Copyright 2018-2020 Broadcom.
4 */
6 #ifndef BCM_VK_SG_H
7 #define BCM_VK_SG_H
9 #include <linux/dma-mapping.h>
11 struct bcm_vk_dma {
12 /* for userland buffer */
13 struct page **pages;
14 int nr_pages;
16 /* common */
17 dma_addr_t handle;
19 * sglist is of the following LE format
20 * [U32] num_sg = number of sg addresses (N)
21 * [U32] totalsize = totalsize of data being transferred in sglist
22 * [U32] size[0] = size of data in address0
23 * [U32] addr_l[0] = lower 32-bits of address0
24 * [U32] addr_h[0] = higher 32-bits of address0
25 * ..
26 * [U32] size[N-1] = size of data in addressN-1
27 * [U32] addr_l[N-1] = lower 32-bits of addressN-1
28 * [U32] addr_h[N-1] = higher 32-bits of addressN-1
30 u32 *sglist;
31 #define SGLIST_NUM_SG 0
32 #define SGLIST_TOTALSIZE 1
33 #define SGLIST_VKDATA_START 2
35 int sglen; /* Length (bytes) of sglist */
36 int direction;
39 struct _vk_data {
40 u32 size; /* data size in bytes */
41 u64 address; /* Pointer to data */
42 } __packed;
45 * Scatter-gather DMA buffer API.
47 * These functions provide a simple way to create a page list and a
48 * scatter-gather list from userspace address and map the memory
49 * for DMA operation.
51 int bcm_vk_sg_alloc(struct device *dev,
52 struct bcm_vk_dma *dma,
53 int dir,
54 struct _vk_data *vkdata,
55 int num);
57 int bcm_vk_sg_free(struct device *dev, struct bcm_vk_dma *dma, int num,
58 int *proc_cnt);
60 #endif