Varun Wadekar | b374103 | 2017-09-25 13:27:45 -0700 | [diff] [blame] | 1 | /* |
Varun Wadekar | d11345a | 2018-05-25 14:34:53 -0700 | [diff] [blame] | 2 | * Copyright (c) 2017-2020, NVIDIA Corporation. All rights reserved. |
Varun Wadekar | b374103 | 2017-09-25 13:27:45 -0700 | [diff] [blame] | 3 | * |
| 4 | * SPDX-License-Identifier: BSD-3-Clause |
| 5 | */ |
| 6 | |
Varun Wadekar | d11345a | 2018-05-25 14:34:53 -0700 | [diff] [blame] | 7 | #ifndef BPMP_IVC_H |
| 8 | #define BPMP_IVC_H |
Varun Wadekar | b374103 | 2017-09-25 13:27:45 -0700 | [diff] [blame] | 9 | |
Ambroise Vincent | ffbf32a | 2019-03-28 09:01:18 +0000 | [diff] [blame] | 10 | #include <lib/utils_def.h> |
Varun Wadekar | b374103 | 2017-09-25 13:27:45 -0700 | [diff] [blame] | 11 | #include <stdint.h> |
| 12 | #include <stddef.h> |
Varun Wadekar | b374103 | 2017-09-25 13:27:45 -0700 | [diff] [blame] | 13 | |
| 14 | #define IVC_ALIGN U(64) |
| 15 | #define IVC_CHHDR_TX_FIELDS U(16) |
| 16 | #define IVC_CHHDR_RX_FIELDS U(16) |
| 17 | |
Varun Wadekar | b374103 | 2017-09-25 13:27:45 -0700 | [diff] [blame] | 18 | struct ivc_channel_header; |
| 19 | |
Varun Wadekar | b374103 | 2017-09-25 13:27:45 -0700 | [diff] [blame] | 20 | struct 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 Wadekar | d11345a | 2018-05-25 14:34:53 -0700 | [diff] [blame] | 25 | void (*notify)(const struct ivc *); |
Varun Wadekar | b374103 | 2017-09-25 13:27:45 -0700 | [diff] [blame] | 26 | uint32_t nframes; |
| 27 | uint32_t frame_size; |
| 28 | }; |
| 29 | |
Varun Wadekar | d11345a | 2018-05-25 14:34:53 -0700 | [diff] [blame] | 30 | /* callback handler for notify on receiving a response */ |
| 31 | typedef void (* ivc_notify_function)(const struct ivc *); |
| 32 | |
Varun Wadekar | b374103 | 2017-09-25 13:27:45 -0700 | [diff] [blame] | 33 | int32_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); |
| 36 | size_t tegra_ivc_total_queue_size(size_t queue_size); |
| 37 | size_t tegra_ivc_align(size_t size); |
| 38 | int32_t tegra_ivc_channel_notified(struct ivc *ivc); |
| 39 | void tegra_ivc_channel_reset(const struct ivc *ivc); |
| 40 | int32_t tegra_ivc_write_advance(struct ivc *ivc); |
| 41 | void *tegra_ivc_write_get_next_frame(const struct ivc *ivc); |
| 42 | int32_t tegra_ivc_write(struct ivc *ivc, const void *buf, size_t size); |
| 43 | int32_t tegra_ivc_read_advance(struct ivc *ivc); |
| 44 | void *tegra_ivc_read_get_next_frame(const struct ivc *ivc); |
| 45 | int32_t tegra_ivc_read(struct ivc *ivc, void *buf, size_t max_read); |
| 46 | bool tegra_ivc_tx_empty(const struct ivc *ivc); |
| 47 | bool tegra_ivc_can_write(const struct ivc *ivc); |
| 48 | bool tegra_ivc_can_read(const struct ivc *ivc); |
| 49 | |
Varun Wadekar | d11345a | 2018-05-25 14:34:53 -0700 | [diff] [blame] | 50 | #endif /* BPMP_IVC_H */ |