Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0-only */
0002 /*
0003  * Copyright (c) 2016, NVIDIA CORPORATION.  All rights reserved.
0004  */
0005 
0006 #ifndef __TEGRA_IVC_H
0007 
0008 #include <linux/device.h>
0009 #include <linux/dma-mapping.h>
0010 #include <linux/types.h>
0011 
0012 struct tegra_ivc_header;
0013 
0014 struct tegra_ivc {
0015     struct device *peer;
0016 
0017     struct {
0018         struct tegra_ivc_header *channel;
0019         unsigned int position;
0020         dma_addr_t phys;
0021     } rx, tx;
0022 
0023     void (*notify)(struct tegra_ivc *ivc, void *data);
0024     void *notify_data;
0025 
0026     unsigned int num_frames;
0027     size_t frame_size;
0028 };
0029 
0030 /**
0031  * tegra_ivc_read_get_next_frame - Peek at the next frame to receive
0032  * @ivc     pointer of the IVC channel
0033  *
0034  * Peek at the next frame to be received, without removing it from
0035  * the queue.
0036  *
0037  * Returns a pointer to the frame, or an error encoded pointer.
0038  */
0039 void *tegra_ivc_read_get_next_frame(struct tegra_ivc *ivc);
0040 
0041 /**
0042  * tegra_ivc_read_advance - Advance the read queue
0043  * @ivc     pointer of the IVC channel
0044  *
0045  * Advance the read queue
0046  *
0047  * Returns 0, or a negative error value if failed.
0048  */
0049 int tegra_ivc_read_advance(struct tegra_ivc *ivc);
0050 
0051 /**
0052  * tegra_ivc_write_get_next_frame - Poke at the next frame to transmit
0053  * @ivc     pointer of the IVC channel
0054  *
0055  * Get access to the next frame.
0056  *
0057  * Returns a pointer to the frame, or an error encoded pointer.
0058  */
0059 void *tegra_ivc_write_get_next_frame(struct tegra_ivc *ivc);
0060 
0061 /**
0062  * tegra_ivc_write_advance - Advance the write queue
0063  * @ivc     pointer of the IVC channel
0064  *
0065  * Advance the write queue
0066  *
0067  * Returns 0, or a negative error value if failed.
0068  */
0069 int tegra_ivc_write_advance(struct tegra_ivc *ivc);
0070 
0071 /**
0072  * tegra_ivc_notified - handle internal messages
0073  * @ivc     pointer of the IVC channel
0074  *
0075  * This function must be called following every notification.
0076  *
0077  * Returns 0 if the channel is ready for communication, or -EAGAIN if a channel
0078  * reset is in progress.
0079  */
0080 int tegra_ivc_notified(struct tegra_ivc *ivc);
0081 
0082 /**
0083  * tegra_ivc_reset - initiates a reset of the shared memory state
0084  * @ivc     pointer of the IVC channel
0085  *
0086  * This function must be called after a channel is reserved before it is used
0087  * for communication. The channel will be ready for use when a subsequent call
0088  * to notify the remote of the channel reset.
0089  */
0090 void tegra_ivc_reset(struct tegra_ivc *ivc);
0091 
0092 size_t tegra_ivc_align(size_t size);
0093 unsigned tegra_ivc_total_queue_size(unsigned queue_size);
0094 int tegra_ivc_init(struct tegra_ivc *ivc, struct device *peer, void *rx,
0095            dma_addr_t rx_phys, void *tx, dma_addr_t tx_phys,
0096            unsigned int num_frames, size_t frame_size,
0097            void (*notify)(struct tegra_ivc *ivc, void *data),
0098            void *data);
0099 void tegra_ivc_cleanup(struct tegra_ivc *ivc);
0100 
0101 #endif /* __TEGRA_IVC_H */