blob: 1b318213b9262461454c59c5ee833da0046ac47b [file] [log] [blame]
Varun Wadekarb3741032017-09-25 13:27:45 -07001/*
Varun Wadekard11345a2018-05-25 14:34:53 -07002 * Copyright (c) 2017-2020, NVIDIA Corporation. All rights reserved.
Varun Wadekarb3741032017-09-25 13:27:45 -07003 *
4 * SPDX-License-Identifier: BSD-3-Clause
5 */
6
Varun Wadekard11345a2018-05-25 14:34:53 -07007#ifndef BPMP_IVC_H
8#define BPMP_IVC_H
Varun Wadekarb3741032017-09-25 13:27:45 -07009
Ambroise Vincentffbf32a2019-03-28 09:01:18 +000010#include <lib/utils_def.h>
Varun Wadekarb3741032017-09-25 13:27:45 -070011#include <stdint.h>
12#include <stddef.h>
Varun Wadekarb3741032017-09-25 13:27:45 -070013
14#define IVC_ALIGN U(64)
15#define IVC_CHHDR_TX_FIELDS U(16)
16#define IVC_CHHDR_RX_FIELDS U(16)
17
Varun Wadekarb3741032017-09-25 13:27:45 -070018struct ivc_channel_header;
19
Varun Wadekarb3741032017-09-25 13:27:45 -070020struct ivc {
21 struct ivc_channel_header *rx_channel;
22 struct ivc_channel_header *tx_channel;
23 uint32_t w_pos;
24 uint32_t r_pos;
Varun Wadekard11345a2018-05-25 14:34:53 -070025 void (*notify)(const struct ivc *);
Varun Wadekarb3741032017-09-25 13:27:45 -070026 uint32_t nframes;
27 uint32_t frame_size;
28};
29
Varun Wadekard11345a2018-05-25 14:34:53 -070030/* callback handler for notify on receiving a response */
31typedef void (* ivc_notify_function)(const struct ivc *);
32
Varun Wadekarb3741032017-09-25 13:27:45 -070033int32_t tegra_ivc_init(struct ivc *ivc, uintptr_t rx_base, uintptr_t tx_base,
34 uint32_t nframes, uint32_t frame_size,
35 ivc_notify_function notify);
36size_t tegra_ivc_total_queue_size(size_t queue_size);
37size_t tegra_ivc_align(size_t size);
38int32_t tegra_ivc_channel_notified(struct ivc *ivc);
39void tegra_ivc_channel_reset(const struct ivc *ivc);
40int32_t tegra_ivc_write_advance(struct ivc *ivc);
41void *tegra_ivc_write_get_next_frame(const struct ivc *ivc);
42int32_t tegra_ivc_write(struct ivc *ivc, const void *buf, size_t size);
43int32_t tegra_ivc_read_advance(struct ivc *ivc);
44void *tegra_ivc_read_get_next_frame(const struct ivc *ivc);
45int32_t tegra_ivc_read(struct ivc *ivc, void *buf, size_t max_read);
46bool tegra_ivc_tx_empty(const struct ivc *ivc);
47bool tegra_ivc_can_write(const struct ivc *ivc);
48bool tegra_ivc_can_read(const struct ivc *ivc);
49
Varun Wadekard11345a2018-05-25 14:34:53 -070050#endif /* BPMP_IVC_H */