// SPDX-License-Identifier: GPL-2.0 /* * Copyright(c) 2016-2018 Intel Corporation. All rights reserved. */ #include <linux/dma-mapping.h> #include <linux/mei.h> #include "mei_dev.h" /** * mei_dmam_dscr_alloc() - allocate a managed coherent buffer * for the dma descriptor * @dev: mei_device * @dscr: dma descriptor * * Return: * * 0 - on success or zero allocation request * * -EINVAL - if size is not power of 2 * * -ENOMEM - of allocation has failed */ static int mei_dmam_dscr_alloc(struct mei_device *dev, struct mei_dma_dscr *dscr) { … } /** * mei_dmam_dscr_free() - free a managed coherent buffer * from the dma descriptor * @dev: mei_device * @dscr: dma descriptor */ static void mei_dmam_dscr_free(struct mei_device *dev, struct mei_dma_dscr *dscr) { … } /** * mei_dmam_ring_free() - free dma ring buffers * @dev: mei device */ void mei_dmam_ring_free(struct mei_device *dev) { … } /** * mei_dmam_ring_alloc() - allocate dma ring buffers * @dev: mei device * * Return: -ENOMEM on allocation failure 0 otherwise */ int mei_dmam_ring_alloc(struct mei_device *dev) { … } /** * mei_dma_ring_is_allocated() - check if dma ring is allocated * @dev: mei device * * Return: true if dma ring is allocated */ bool mei_dma_ring_is_allocated(struct mei_device *dev) { … } static inline struct hbm_dma_ring_ctrl *mei_dma_ring_ctrl(struct mei_device *dev) { … } /** * mei_dma_ring_reset() - reset the dma control block * @dev: mei device */ void mei_dma_ring_reset(struct mei_device *dev) { … } /** * mei_dma_copy_from() - copy from dma ring into buffer * @dev: mei device * @buf: data buffer * @offset: offset in slots. * @n: number of slots to copy. * * Return: number of bytes copied */ static size_t mei_dma_copy_from(struct mei_device *dev, unsigned char *buf, u32 offset, u32 n) { … } /** * mei_dma_copy_to() - copy to a buffer to the dma ring * @dev: mei device * @buf: data buffer * @offset: offset in slots. * @n: number of slots to copy. * * Return: number of bytes copied */ static size_t mei_dma_copy_to(struct mei_device *dev, unsigned char *buf, u32 offset, u32 n) { … } /** * mei_dma_ring_read() - read data from the ring * @dev: mei device * @buf: buffer to read into: may be NULL in case of dropping the data. * @len: length to read. */ void mei_dma_ring_read(struct mei_device *dev, unsigned char *buf, u32 len) { … } static inline u32 mei_dma_ring_hbuf_depth(struct mei_device *dev) { … } /** * mei_dma_ring_empty_slots() - calaculate number of empty slots in dma ring * @dev: mei_device * * Return: number of empty slots */ u32 mei_dma_ring_empty_slots(struct mei_device *dev) { … } /** * mei_dma_ring_write - write data to dma ring host buffer * * @dev: mei_device * @buf: data will be written * @len: data length */ void mei_dma_ring_write(struct mei_device *dev, unsigned char *buf, u32 len) { … }