/* SPDX-License-Identifier: GPL-2.0-only */1/*2* Copyright (c) 2016, NVIDIA CORPORATION. All rights reserved.3*/45#ifndef __TEGRA_IVC_H6#define __TEGRA_IVC_H78#include <linux/device.h>9#include <linux/dma-mapping.h>10#include <linux/iosys-map.h>11#include <linux/types.h>1213struct tegra_ivc_header;1415struct tegra_ivc {16struct device *peer;1718struct {19struct iosys_map map;20unsigned int position;21dma_addr_t phys;22} rx, tx;2324void (*notify)(struct tegra_ivc *ivc, void *data);25void *notify_data;2627unsigned int num_frames;28size_t frame_size;29};3031/**32* tegra_ivc_read_get_next_frame - Peek at the next frame to receive33* @ivc pointer of the IVC channel34*35* Peek at the next frame to be received, without removing it from36* the queue.37*38* Returns a pointer to the frame, or an error encoded pointer.39*/40int tegra_ivc_read_get_next_frame(struct tegra_ivc *ivc, struct iosys_map *map);4142/**43* tegra_ivc_read_advance - Advance the read queue44* @ivc pointer of the IVC channel45*46* Advance the read queue47*48* Returns 0, or a negative error value if failed.49*/50int tegra_ivc_read_advance(struct tegra_ivc *ivc);5152/**53* tegra_ivc_write_get_next_frame - Poke at the next frame to transmit54* @ivc pointer of the IVC channel55*56* Get access to the next frame.57*58* Returns a pointer to the frame, or an error encoded pointer.59*/60int tegra_ivc_write_get_next_frame(struct tegra_ivc *ivc, struct iosys_map *map);6162/**63* tegra_ivc_write_advance - Advance the write queue64* @ivc pointer of the IVC channel65*66* Advance the write queue67*68* Returns 0, or a negative error value if failed.69*/70int tegra_ivc_write_advance(struct tegra_ivc *ivc);7172/**73* tegra_ivc_notified - handle internal messages74* @ivc pointer of the IVC channel75*76* This function must be called following every notification.77*78* Returns 0 if the channel is ready for communication, or -EAGAIN if a channel79* reset is in progress.80*/81int tegra_ivc_notified(struct tegra_ivc *ivc);8283/**84* tegra_ivc_reset - initiates a reset of the shared memory state85* @ivc pointer of the IVC channel86*87* This function must be called after a channel is reserved before it is used88* for communication. The channel will be ready for use when a subsequent call89* to notify the remote of the channel reset.90*/91void tegra_ivc_reset(struct tegra_ivc *ivc);9293size_t tegra_ivc_align(size_t size);94unsigned tegra_ivc_total_queue_size(unsigned queue_size);95int tegra_ivc_init(struct tegra_ivc *ivc, struct device *peer, const struct iosys_map *rx,96dma_addr_t rx_phys, const struct iosys_map *tx, dma_addr_t tx_phys,97unsigned int num_frames, size_t frame_size,98void (*notify)(struct tegra_ivc *ivc, void *data),99void *data);100void tegra_ivc_cleanup(struct tegra_ivc *ivc);101102#endif /* __TEGRA_IVC_H */103104105