Linux 5.6.13
[linux/fpc-iii.git] / include / soc / tegra / ivc.h
blob4aeb77cc22c543834771d2e7f82461bbb14beab5
1 /* SPDX-License-Identifier: GPL-2.0-only */
2 /*
3 * Copyright (c) 2016, NVIDIA CORPORATION. All rights reserved.
4 */
6 #ifndef __TEGRA_IVC_H
8 #include <linux/device.h>
9 #include <linux/dma-mapping.h>
10 #include <linux/types.h>
12 struct tegra_ivc_header;
14 struct tegra_ivc {
15 struct device *peer;
17 struct {
18 struct tegra_ivc_header *channel;
19 unsigned int position;
20 dma_addr_t phys;
21 } rx, tx;
23 void (*notify)(struct tegra_ivc *ivc, void *data);
24 void *notify_data;
26 unsigned int num_frames;
27 size_t frame_size;
30 /**
31 * tegra_ivc_read_get_next_frame - Peek at the next frame to receive
32 * @ivc pointer of the IVC channel
34 * Peek at the next frame to be received, without removing it from
35 * the queue.
37 * Returns a pointer to the frame, or an error encoded pointer.
39 void *tegra_ivc_read_get_next_frame(struct tegra_ivc *ivc);
41 /**
42 * tegra_ivc_read_advance - Advance the read queue
43 * @ivc pointer of the IVC channel
45 * Advance the read queue
47 * Returns 0, or a negative error value if failed.
49 int tegra_ivc_read_advance(struct tegra_ivc *ivc);
51 /**
52 * tegra_ivc_write_get_next_frame - Poke at the next frame to transmit
53 * @ivc pointer of the IVC channel
55 * Get access to the next frame.
57 * Returns a pointer to the frame, or an error encoded pointer.
59 void *tegra_ivc_write_get_next_frame(struct tegra_ivc *ivc);
61 /**
62 * tegra_ivc_write_advance - Advance the write queue
63 * @ivc pointer of the IVC channel
65 * Advance the write queue
67 * Returns 0, or a negative error value if failed.
69 int tegra_ivc_write_advance(struct tegra_ivc *ivc);
71 /**
72 * tegra_ivc_notified - handle internal messages
73 * @ivc pointer of the IVC channel
75 * This function must be called following every notification.
77 * Returns 0 if the channel is ready for communication, or -EAGAIN if a channel
78 * reset is in progress.
80 int tegra_ivc_notified(struct tegra_ivc *ivc);
82 /**
83 * tegra_ivc_reset - initiates a reset of the shared memory state
84 * @ivc pointer of the IVC channel
86 * This function must be called after a channel is reserved before it is used
87 * for communication. The channel will be ready for use when a subsequent call
88 * to notify the remote of the channel reset.
90 void tegra_ivc_reset(struct tegra_ivc *ivc);
92 size_t tegra_ivc_align(size_t size);
93 unsigned tegra_ivc_total_queue_size(unsigned queue_size);
94 int tegra_ivc_init(struct tegra_ivc *ivc, struct device *peer, void *rx,
95 dma_addr_t rx_phys, void *tx, dma_addr_t tx_phys,
96 unsigned int num_frames, size_t frame_size,
97 void (*notify)(struct tegra_ivc *ivc, void *data),
98 void *data);
99 void tegra_ivc_cleanup(struct tegra_ivc *ivc);
101 #endif /* __TEGRA_IVC_H */