| 1 | /* SPDX-License-Identifier: GPL-2.0-only */ | 
|---|
| 2 | /* | 
|---|
| 3 | * PCC (Platform Communications Channel) methods | 
|---|
| 4 | */ | 
|---|
| 5 |  | 
|---|
| 6 | #ifndef _PCC_H | 
|---|
| 7 | #define _PCC_H | 
|---|
| 8 |  | 
|---|
| 9 | #include <linux/mailbox_controller.h> | 
|---|
| 10 | #include <linux/mailbox_client.h> | 
|---|
| 11 |  | 
|---|
| 12 | struct pcc_mbox_chan { | 
|---|
| 13 | struct mbox_chan *mchan; | 
|---|
| 14 | u64 shmem_base_addr; | 
|---|
| 15 | void __iomem *shmem; | 
|---|
| 16 | u64 shmem_size; | 
|---|
| 17 | u32 latency; | 
|---|
| 18 | u32 max_access_rate; | 
|---|
| 19 | u16 min_turnaround_time; | 
|---|
| 20 |  | 
|---|
| 21 | /* Set to true to indicate that the mailbox should manage | 
|---|
| 22 | * writing the dat to the shared buffer. This differs from | 
|---|
| 23 | * the case where the drivesr are writing to the buffer and | 
|---|
| 24 | * using send_data only to  ring the doorbell.  If this flag | 
|---|
| 25 | * is set, then the void * data parameter of send_data must | 
|---|
| 26 | * point to a kernel-memory buffer formatted in accordance with | 
|---|
| 27 | * the PCC specification. | 
|---|
| 28 | * | 
|---|
| 29 | * The active buffer management will include reading the | 
|---|
| 30 | * notify_on_completion flag, and will then | 
|---|
| 31 | * call mbox_chan_txdone when the acknowledgment interrupt is | 
|---|
| 32 | * received. | 
|---|
| 33 | */ | 
|---|
| 34 | bool manage_writes; | 
|---|
| 35 |  | 
|---|
| 36 | /* Optional callback that allows the driver | 
|---|
| 37 | * to allocate the memory used for receiving | 
|---|
| 38 | * messages.  The return value is the location | 
|---|
| 39 | * inside the buffer where the mailbox should write the data. | 
|---|
| 40 | */ | 
|---|
| 41 | void *(*rx_alloc)(struct mbox_client *cl,  int size); | 
|---|
| 42 | }; | 
|---|
| 43 |  | 
|---|
| 44 | struct  { | 
|---|
| 45 | u32 ; | 
|---|
| 46 | u32 ; | 
|---|
| 47 | u32 ; | 
|---|
| 48 | u32 command; | 
|---|
| 49 | }; | 
|---|
| 50 |  | 
|---|
| 51 | /* Generic Communications Channel Shared Memory Region */ | 
|---|
| 52 | #define PCC_SIGNATURE			0x50434300 | 
|---|
| 53 | /* Generic Communications Channel Command Field */ | 
|---|
| 54 | #define PCC_CMD_GENERATE_DB_INTR	BIT(15) | 
|---|
| 55 | /* Generic Communications Channel Status Field */ | 
|---|
| 56 | #define PCC_STATUS_CMD_COMPLETE		BIT(0) | 
|---|
| 57 | #define PCC_STATUS_SCI_DOORBELL		BIT(1) | 
|---|
| 58 | #define PCC_STATUS_ERROR		BIT(2) | 
|---|
| 59 | #define PCC_STATUS_PLATFORM_NOTIFY	BIT(3) | 
|---|
| 60 | /* Initiator Responder Communications Channel Flags */ | 
|---|
| 61 | #define PCC_CMD_COMPLETION_NOTIFY	BIT(0) | 
|---|
| 62 |  | 
|---|
| 63 | #define MAX_PCC_SUBSPACES	256 | 
|---|
| 64 |  | 
|---|
| 65 | #ifdef CONFIG_PCC | 
|---|
| 66 | extern struct pcc_mbox_chan * | 
|---|
| 67 | pcc_mbox_request_channel(struct mbox_client *cl, int subspace_id); | 
|---|
| 68 | extern void pcc_mbox_free_channel(struct pcc_mbox_chan *chan); | 
|---|
| 69 | #else | 
|---|
| 70 | static inline struct pcc_mbox_chan * | 
|---|
| 71 | pcc_mbox_request_channel(struct mbox_client *cl, int subspace_id) | 
|---|
| 72 | { | 
|---|
| 73 | return ERR_PTR(-ENODEV); | 
|---|
| 74 | } | 
|---|
| 75 | static inline void pcc_mbox_free_channel(struct pcc_mbox_chan *chan) { } | 
|---|
| 76 | #endif | 
|---|
| 77 |  | 
|---|
| 78 | #endif /* _PCC_H */ | 
|---|
| 79 |  | 
|---|