Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0 */
0002 /*
0003  * Copyright 2018-2020 Broadcom.
0004  */
0005 
0006 #ifndef BCM_VK_SG_H
0007 #define BCM_VK_SG_H
0008 
0009 #include <linux/dma-mapping.h>
0010 
0011 struct bcm_vk_dma {
0012     /* for userland buffer */
0013     struct page **pages;
0014     int nr_pages;
0015 
0016     /* common */
0017     dma_addr_t handle;
0018     /*
0019      * sglist is of the following LE format
0020      * [U32] num_sg  = number of sg addresses (N)
0021      * [U32] totalsize = totalsize of data being transferred in sglist
0022      * [U32] size[0] = size of data in address0
0023      * [U32] addr_l[0] = lower 32-bits of address0
0024      * [U32] addr_h[0] = higher 32-bits of address0
0025      * ..
0026      * [U32] size[N-1] = size of data in addressN-1
0027      * [U32] addr_l[N-1] = lower 32-bits of addressN-1
0028      * [U32] addr_h[N-1] = higher 32-bits of addressN-1
0029      */
0030     u32 *sglist;
0031 #define SGLIST_NUM_SG       0
0032 #define SGLIST_TOTALSIZE    1
0033 #define SGLIST_VKDATA_START 2
0034 
0035     int sglen; /* Length (bytes) of sglist */
0036     int direction;
0037 };
0038 
0039 struct _vk_data {
0040     u32 size;    /* data size in bytes */
0041     u64 address; /* Pointer to data     */
0042 } __packed;
0043 
0044 /*
0045  * Scatter-gather DMA buffer API.
0046  *
0047  * These functions provide a simple way to create a page list and a
0048  * scatter-gather list from userspace address and map the memory
0049  * for DMA operation.
0050  */
0051 int bcm_vk_sg_alloc(struct device *dev,
0052             struct bcm_vk_dma *dma,
0053             int dir,
0054             struct _vk_data *vkdata,
0055             int num);
0056 
0057 int bcm_vk_sg_free(struct device *dev, struct bcm_vk_dma *dma, int num,
0058            int *proc_cnt);
0059 
0060 #endif
0061