Jolly Shah | b07fd0c | 2019-01-08 11:25:28 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2018, Xilinx, Inc. All rights reserved. |
Devanshi Chauhan Alpeshbhai | b3d4c9f | 2025-03-26 02:08:58 -0700 | [diff] [blame^] | 3 | * Copyright (c) 2022-2025, Advanced Micro Devices, Inc. All rights reserved. |
Jolly Shah | b07fd0c | 2019-01-08 11:25:28 -0800 | [diff] [blame] | 4 | * |
| 5 | * SPDX-License-Identifier: BSD-3-Clause |
| 6 | */ |
| 7 | |
| 8 | /* Xilinx IPI management configuration data and macros */ |
| 9 | |
| 10 | #ifndef IPI_H |
| 11 | #define IPI_H |
| 12 | |
| 13 | #include <stdint.h> |
| 14 | |
| 15 | /********************************************************************* |
Jolly Shah | c2583ab | 2019-01-08 11:31:49 -0800 | [diff] [blame] | 16 | * IPI mailbox status macros |
| 17 | ********************************************************************/ |
HariBabu Gattem | 9f9db61 | 2022-09-15 22:35:11 -0700 | [diff] [blame] | 18 | #define IPI_MB_STATUS_IDLE (0U) |
| 19 | #define IPI_MB_STATUS_SEND_PENDING (1U) |
| 20 | #define IPI_MB_STATUS_RECV_PENDING (2U) |
Jolly Shah | c2583ab | 2019-01-08 11:31:49 -0800 | [diff] [blame] | 21 | |
| 22 | /********************************************************************* |
| 23 | * IPI mailbox call is secure or not macros |
| 24 | ********************************************************************/ |
HariBabu Gattem | 9f9db61 | 2022-09-15 22:35:11 -0700 | [diff] [blame] | 25 | #define IPI_MB_CALL_NOTSECURE (0U) |
| 26 | #define IPI_MB_CALL_SECURE (1U) |
Jolly Shah | c2583ab | 2019-01-08 11:31:49 -0800 | [diff] [blame] | 27 | |
| 28 | /********************************************************************* |
| 29 | * IPI secure check |
| 30 | ********************************************************************/ |
HariBabu Gattem | 9f9db61 | 2022-09-15 22:35:11 -0700 | [diff] [blame] | 31 | #define IPI_SECURE_MASK (0x1U) |
Jolly Shah | c2583ab | 2019-01-08 11:31:49 -0800 | [diff] [blame] | 32 | #define IPI_IS_SECURE(I) ((ipi_table[(I)].secure_only & \ |
Maheedhar Bollapalli | 9c3fc0b | 2024-04-24 12:53:28 +0530 | [diff] [blame] | 33 | IPI_SECURE_MASK) ? true : false) |
Jolly Shah | c2583ab | 2019-01-08 11:31:49 -0800 | [diff] [blame] | 34 | |
| 35 | /********************************************************************* |
Jolly Shah | b07fd0c | 2019-01-08 11:25:28 -0800 | [diff] [blame] | 36 | * Struct definitions |
| 37 | ********************************************************************/ |
| 38 | |
| 39 | /* structure to maintain IPI configuration information */ |
| 40 | struct ipi_config { |
| 41 | unsigned int ipi_bit_mask; |
| 42 | unsigned int ipi_reg_base; |
| 43 | unsigned char secure_only; |
| 44 | }; |
| 45 | |
Jolly Shah | c2583ab | 2019-01-08 11:31:49 -0800 | [diff] [blame] | 46 | /********************************************************************* |
| 47 | * IPI APIs declarations |
| 48 | ********************************************************************/ |
| 49 | |
| 50 | /* Initialize IPI configuration table */ |
Venkatesh Yadav Abbarapu | c70726f | 2022-05-16 17:44:33 +0530 | [diff] [blame] | 51 | void ipi_config_table_init(const struct ipi_config *ipi_config_table, |
Jolly Shah | c2583ab | 2019-01-08 11:31:49 -0800 | [diff] [blame] | 52 | uint32_t total_ipi); |
| 53 | |
| 54 | /* Validate IPI mailbox access */ |
| 55 | int ipi_mb_validate(uint32_t local, uint32_t remote, unsigned int is_secure); |
| 56 | |
| 57 | /* Open the IPI mailbox */ |
| 58 | void ipi_mb_open(uint32_t local, uint32_t remote); |
| 59 | |
| 60 | /* Release the IPI mailbox */ |
| 61 | void ipi_mb_release(uint32_t local, uint32_t remote); |
| 62 | |
| 63 | /* Enquire IPI mailbox status */ |
Devanshi Chauhan Alpeshbhai | b3d4c9f | 2025-03-26 02:08:58 -0700 | [diff] [blame^] | 64 | uint32_t ipi_mb_enquire_status(uint32_t local, uint32_t remote); |
Jolly Shah | c2583ab | 2019-01-08 11:31:49 -0800 | [diff] [blame] | 65 | |
| 66 | /* Trigger notification on the IPI mailbox */ |
Venkatesh Yadav Abbarapu | efa1d32 | 2021-08-04 21:33:15 -0600 | [diff] [blame] | 67 | void ipi_mb_notify(uint32_t local, uint32_t remote, uint32_t is_blocking); |
Jolly Shah | c2583ab | 2019-01-08 11:31:49 -0800 | [diff] [blame] | 68 | |
| 69 | /* Ack IPI mailbox notification */ |
| 70 | void ipi_mb_ack(uint32_t local, uint32_t remote); |
| 71 | |
| 72 | /* Disable IPI mailbox notification interrupt */ |
| 73 | void ipi_mb_disable_irq(uint32_t local, uint32_t remote); |
| 74 | |
| 75 | /* Enable IPI mailbox notification interrupt */ |
| 76 | void ipi_mb_enable_irq(uint32_t local, uint32_t remote); |
| 77 | |
Jolly Shah | b07fd0c | 2019-01-08 11:25:28 -0800 | [diff] [blame] | 78 | #endif /* IPI_H */ |