![]() |
|
|||
0001 /* SPDX-License-Identifier: GPL-2.0-only 0002 * 0003 * Copyright (C) 2020-21 Intel Corporation. 0004 */ 0005 0006 #ifndef IOSM_IPC_PROTOCOL_H 0007 #define IOSM_IPC_PROTOCOL_H 0008 0009 #include "iosm_ipc_imem.h" 0010 #include "iosm_ipc_pm.h" 0011 #include "iosm_ipc_protocol_ops.h" 0012 0013 /* Trigger the doorbell interrupt on CP. */ 0014 #define IPC_DOORBELL_IRQ_HPDA 0 0015 #define IPC_DOORBELL_IRQ_IPC 1 0016 #define IPC_DOORBELL_IRQ_SLEEP 2 0017 0018 /* IRQ vector number. */ 0019 #define IPC_DEVICE_IRQ_VECTOR 0 0020 #define IPC_MSG_IRQ_VECTOR 0 0021 #define IPC_UL_PIPE_IRQ_VECTOR 0 0022 #define IPC_DL_PIPE_IRQ_VECTOR 0 0023 0024 #define IPC_MEM_MSG_ENTRIES 128 0025 0026 /* Default time out for sending IPC messages like open pipe, close pipe etc. 0027 * during run mode. 0028 * 0029 * If the message interface lock to CP times out, the link to CP is broken. 0030 * mode : run mode (IPC_MEM_EXEC_STAGE_RUN) 0031 * unit : milliseconds 0032 */ 0033 #define IPC_MSG_COMPLETE_RUN_DEFAULT_TIMEOUT 500 /* 0.5 seconds */ 0034 0035 /* Default time out for sending IPC messages like open pipe, close pipe etc. 0036 * during boot mode. 0037 * 0038 * If the message interface lock to CP times out, the link to CP is broken. 0039 * mode : boot mode 0040 * (IPC_MEM_EXEC_STAGE_BOOT | IPC_MEM_EXEC_STAGE_PSI | IPC_MEM_EXEC_STAGE_EBL) 0041 * unit : milliseconds 0042 */ 0043 #define IPC_MSG_COMPLETE_BOOT_DEFAULT_TIMEOUT 500 /* 0.5 seconds */ 0044 0045 /** 0046 * struct ipc_protocol_context_info - Structure of the context info 0047 * @device_info_addr: 64 bit address to device info 0048 * @head_array: 64 bit address to head pointer arr for the pipes 0049 * @tail_array: 64 bit address to tail pointer arr for the pipes 0050 * @msg_head: 64 bit address to message head pointer 0051 * @msg_tail: 64 bit address to message tail pointer 0052 * @msg_ring_addr: 64 bit pointer to the message ring buffer 0053 * @msg_ring_entries: This field provides the number of entries which 0054 * the MR can hold 0055 * @msg_irq_vector: This field provides the IRQ which shall be 0056 * generated by the EP device when generating 0057 * completion for Messages. 0058 * @device_info_irq_vector: This field provides the IRQ which shall be 0059 * generated by the EP dev after updating Dev. Info 0060 */ 0061 struct ipc_protocol_context_info { 0062 phys_addr_t device_info_addr; 0063 phys_addr_t head_array; 0064 phys_addr_t tail_array; 0065 phys_addr_t msg_head; 0066 phys_addr_t msg_tail; 0067 phys_addr_t msg_ring_addr; 0068 __le16 msg_ring_entries; 0069 u8 msg_irq_vector; 0070 u8 device_info_irq_vector; 0071 }; 0072 0073 /** 0074 * struct ipc_protocol_device_info - Structure for the device information 0075 * @execution_stage: CP execution stage 0076 * @ipc_status: IPC states 0077 * @device_sleep_notification: Requested device pm states 0078 */ 0079 struct ipc_protocol_device_info { 0080 __le32 execution_stage; 0081 __le32 ipc_status; 0082 __le32 device_sleep_notification; 0083 }; 0084 0085 /** 0086 * struct ipc_protocol_ap_shm - Protocol Shared Memory Structure 0087 * @ci: Context information struct 0088 * @device_info: Device information struct 0089 * @msg_head: Point to msg head 0090 * @head_array: Array of head pointer 0091 * @msg_tail: Point to msg tail 0092 * @tail_array: Array of tail pointer 0093 * @msg_ring: Circular buffers for the read/tail and write/head 0094 * indeces. 0095 */ 0096 struct ipc_protocol_ap_shm { 0097 struct ipc_protocol_context_info ci; 0098 struct ipc_protocol_device_info device_info; 0099 __le32 msg_head; 0100 __le32 head_array[IPC_MEM_MAX_PIPES]; 0101 __le32 msg_tail; 0102 __le32 tail_array[IPC_MEM_MAX_PIPES]; 0103 union ipc_mem_msg_entry msg_ring[IPC_MEM_MSG_ENTRIES]; 0104 }; 0105 0106 /** 0107 * struct iosm_protocol - Structure for IPC protocol. 0108 * @p_ap_shm: Pointer to Protocol Shared Memory Structure 0109 * @pm: Instance to struct iosm_pm 0110 * @pcie: Pointer to struct iosm_pcie 0111 * @imem: Pointer to struct iosm_imem 0112 * @rsp_ring: Array of OS completion objects to be triggered once CP 0113 * acknowledges a request in the message ring 0114 * @dev: Pointer to device structure 0115 * @phy_ap_shm: Physical/Mapped representation of the shared memory info 0116 * @old_msg_tail: Old msg tail ptr, until AP has handled ACK's from CP 0117 */ 0118 struct iosm_protocol { 0119 struct ipc_protocol_ap_shm *p_ap_shm; 0120 struct iosm_pm pm; 0121 struct iosm_pcie *pcie; 0122 struct iosm_imem *imem; 0123 struct ipc_rsp *rsp_ring[IPC_MEM_MSG_ENTRIES]; 0124 struct device *dev; 0125 phys_addr_t phy_ap_shm; 0126 u32 old_msg_tail; 0127 }; 0128 0129 /** 0130 * struct ipc_call_msg_send_args - Structure for message argument for 0131 * tasklet function. 0132 * @prep_args: Arguments for message preparation function 0133 * @response: Can be NULL if result can be ignored 0134 * @msg_type: Message Type 0135 */ 0136 struct ipc_call_msg_send_args { 0137 union ipc_msg_prep_args *prep_args; 0138 struct ipc_rsp *response; 0139 enum ipc_msg_prep_type msg_type; 0140 }; 0141 0142 /** 0143 * ipc_protocol_tq_msg_send - prepare the msg and send to CP 0144 * @ipc_protocol: Pointer to ipc_protocol instance 0145 * @msg_type: Message type 0146 * @prep_args: Message arguments 0147 * @response: Pointer to a response object which has a 0148 * completion object and return code. 0149 * 0150 * Returns: 0 on success and failure value on error 0151 */ 0152 int ipc_protocol_tq_msg_send(struct iosm_protocol *ipc_protocol, 0153 enum ipc_msg_prep_type msg_type, 0154 union ipc_msg_prep_args *prep_args, 0155 struct ipc_rsp *response); 0156 0157 /** 0158 * ipc_protocol_msg_send - Send ipc control message to CP and wait for response 0159 * @ipc_protocol: Pointer to ipc_protocol instance 0160 * @prep: Message type 0161 * @prep_args: Message arguments 0162 * 0163 * Returns: 0 on success and failure value on error 0164 */ 0165 int ipc_protocol_msg_send(struct iosm_protocol *ipc_protocol, 0166 enum ipc_msg_prep_type prep, 0167 union ipc_msg_prep_args *prep_args); 0168 0169 /** 0170 * ipc_protocol_suspend - Signal to CP that host wants to go to sleep (suspend). 0171 * @ipc_protocol: Pointer to ipc_protocol instance 0172 * 0173 * Returns: true if host can suspend, false if suspend must be aborted. 0174 */ 0175 bool ipc_protocol_suspend(struct iosm_protocol *ipc_protocol); 0176 0177 /** 0178 * ipc_protocol_s2idle_sleep - Call PM function to set PM variables in s2idle 0179 * sleep/active case 0180 * @ipc_protocol: Pointer to ipc_protocol instance 0181 * @sleep: True for sleep/False for active 0182 */ 0183 void ipc_protocol_s2idle_sleep(struct iosm_protocol *ipc_protocol, bool sleep); 0184 0185 /** 0186 * ipc_protocol_resume - Signal to CP that host wants to resume operation. 0187 * @ipc_protocol: Pointer to ipc_protocol instance 0188 * 0189 * Returns: true if host can resume, false if there is a problem. 0190 */ 0191 bool ipc_protocol_resume(struct iosm_protocol *ipc_protocol); 0192 0193 /** 0194 * ipc_protocol_pm_dev_sleep_handle - Handles the Device Sleep state change 0195 * notification. 0196 * @ipc_protocol: Pointer to ipc_protocol instance. 0197 * 0198 * Returns: true if sleep notification handled, false otherwise. 0199 */ 0200 bool ipc_protocol_pm_dev_sleep_handle(struct iosm_protocol *ipc_protocol); 0201 0202 /** 0203 * ipc_protocol_doorbell_trigger - Wrapper for PM function which wake up the 0204 * device if it is in low power mode 0205 * and trigger a head pointer update interrupt. 0206 * @ipc_protocol: Pointer to ipc_protocol instance. 0207 * @identifier: Specifies what component triggered hpda 0208 * update irq 0209 */ 0210 void ipc_protocol_doorbell_trigger(struct iosm_protocol *ipc_protocol, 0211 u32 identifier); 0212 0213 /** 0214 * ipc_protocol_sleep_notification_string - Returns last Sleep Notification as 0215 * string. 0216 * @ipc_protocol: Instance pointer of Protocol module. 0217 * 0218 * Returns: Pointer to string. 0219 */ 0220 const char * 0221 ipc_protocol_sleep_notification_string(struct iosm_protocol *ipc_protocol); 0222 0223 /** 0224 * ipc_protocol_init - Allocates IPC protocol instance 0225 * @ipc_imem: Pointer to iosm_imem structure 0226 * 0227 * Returns: Address of IPC protocol instance on success & NULL on failure. 0228 */ 0229 struct iosm_protocol *ipc_protocol_init(struct iosm_imem *ipc_imem); 0230 0231 /** 0232 * ipc_protocol_deinit - Deallocates IPC protocol instance 0233 * @ipc_protocol: pointer to the IPC protocol instance 0234 */ 0235 void ipc_protocol_deinit(struct iosm_protocol *ipc_protocol); 0236 0237 #endif
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.1.0 LXR engine. The LXR team |
![]() ![]() |