![]() |
|
|||
0001 /* SPDX-License-Identifier: GPL-2.0-only 0002 * 0003 * Copyright (C) 2020-21 Intel Corporation. 0004 */ 0005 0006 #ifndef IOSM_IPC_PROTOCOL_OPS_H 0007 #define IOSM_IPC_PROTOCOL_OPS_H 0008 0009 #define SIZE_MASK 0x00FFFFFF 0010 #define COMPLETION_STATUS 24 0011 #define RESET_BIT 7 0012 0013 /** 0014 * enum ipc_mem_td_cs - Completion status of a TD 0015 * @IPC_MEM_TD_CS_INVALID: Initial status - td not yet used. 0016 * @IPC_MEM_TD_CS_PARTIAL_TRANSFER: More data pending -> next TD used for this 0017 * @IPC_MEM_TD_CS_END_TRANSFER: IO transfer is complete. 0018 * @IPC_MEM_TD_CS_OVERFLOW: IO transfer to small for the buff to write 0019 * @IPC_MEM_TD_CS_ABORT: TD marked as abort and shall be discarded 0020 * by AP. 0021 * @IPC_MEM_TD_CS_ERROR: General error. 0022 */ 0023 enum ipc_mem_td_cs { 0024 IPC_MEM_TD_CS_INVALID, 0025 IPC_MEM_TD_CS_PARTIAL_TRANSFER, 0026 IPC_MEM_TD_CS_END_TRANSFER, 0027 IPC_MEM_TD_CS_OVERFLOW, 0028 IPC_MEM_TD_CS_ABORT, 0029 IPC_MEM_TD_CS_ERROR, 0030 }; 0031 0032 /** 0033 * enum ipc_mem_msg_cs - Completion status of IPC Message 0034 * @IPC_MEM_MSG_CS_INVALID: Initial status. 0035 * @IPC_MEM_MSG_CS_SUCCESS: IPC Message completion success. 0036 * @IPC_MEM_MSG_CS_ERROR: Message send error. 0037 */ 0038 enum ipc_mem_msg_cs { 0039 IPC_MEM_MSG_CS_INVALID, 0040 IPC_MEM_MSG_CS_SUCCESS, 0041 IPC_MEM_MSG_CS_ERROR, 0042 }; 0043 0044 /** 0045 * struct ipc_msg_prep_args_pipe - struct for pipe args for message preparation 0046 * @pipe: Pipe to open/close 0047 */ 0048 struct ipc_msg_prep_args_pipe { 0049 struct ipc_pipe *pipe; 0050 }; 0051 0052 /** 0053 * struct ipc_msg_prep_args_sleep - struct for sleep args for message 0054 * preparation 0055 * @target: 0=host, 1=device 0056 * @state: 0=enter sleep, 1=exit sleep 0057 */ 0058 struct ipc_msg_prep_args_sleep { 0059 unsigned int target; 0060 unsigned int state; 0061 }; 0062 0063 /** 0064 * struct ipc_msg_prep_feature_set - struct for feature set argument for 0065 * message preparation 0066 * @reset_enable: 0=out-of-band, 1=in-band-crash notification 0067 */ 0068 struct ipc_msg_prep_feature_set { 0069 u8 reset_enable; 0070 }; 0071 0072 /** 0073 * struct ipc_msg_prep_map - struct for map argument for message preparation 0074 * @region_id: Region to map 0075 * @addr: Pcie addr of region to map 0076 * @size: Size of the region to map 0077 */ 0078 struct ipc_msg_prep_map { 0079 unsigned int region_id; 0080 unsigned long addr; 0081 size_t size; 0082 }; 0083 0084 /** 0085 * struct ipc_msg_prep_unmap - struct for unmap argument for message preparation 0086 * @region_id: Region to unmap 0087 */ 0088 struct ipc_msg_prep_unmap { 0089 unsigned int region_id; 0090 }; 0091 0092 /** 0093 * struct ipc_msg_prep_args - Union to handle different message types 0094 * @pipe_open: Pipe open message preparation struct 0095 * @pipe_close: Pipe close message preparation struct 0096 * @sleep: Sleep message preparation struct 0097 * @feature_set: Feature set message preparation struct 0098 * @map: Memory map message preparation struct 0099 * @unmap: Memory unmap message preparation struct 0100 */ 0101 union ipc_msg_prep_args { 0102 struct ipc_msg_prep_args_pipe pipe_open; 0103 struct ipc_msg_prep_args_pipe pipe_close; 0104 struct ipc_msg_prep_args_sleep sleep; 0105 struct ipc_msg_prep_feature_set feature_set; 0106 struct ipc_msg_prep_map map; 0107 struct ipc_msg_prep_unmap unmap; 0108 }; 0109 0110 /** 0111 * enum ipc_msg_prep_type - Enum for message prepare actions 0112 * @IPC_MSG_PREP_SLEEP: Sleep message preparation type 0113 * @IPC_MSG_PREP_PIPE_OPEN: Pipe open message preparation type 0114 * @IPC_MSG_PREP_PIPE_CLOSE: Pipe close message preparation type 0115 * @IPC_MSG_PREP_FEATURE_SET: Feature set message preparation type 0116 * @IPC_MSG_PREP_MAP: Memory map message preparation type 0117 * @IPC_MSG_PREP_UNMAP: Memory unmap message preparation type 0118 */ 0119 enum ipc_msg_prep_type { 0120 IPC_MSG_PREP_SLEEP, 0121 IPC_MSG_PREP_PIPE_OPEN, 0122 IPC_MSG_PREP_PIPE_CLOSE, 0123 IPC_MSG_PREP_FEATURE_SET, 0124 IPC_MSG_PREP_MAP, 0125 IPC_MSG_PREP_UNMAP, 0126 }; 0127 0128 /** 0129 * struct ipc_rsp - Response to sent message 0130 * @completion: For waking up requestor 0131 * @status: Completion status 0132 */ 0133 struct ipc_rsp { 0134 struct completion completion; 0135 enum ipc_mem_msg_cs status; 0136 }; 0137 0138 /** 0139 * enum ipc_mem_msg - Type-definition of the messages. 0140 * @IPC_MEM_MSG_OPEN_PIPE: AP ->CP: Open a pipe 0141 * @IPC_MEM_MSG_CLOSE_PIPE: AP ->CP: Close a pipe 0142 * @IPC_MEM_MSG_ABORT_PIPE: AP ->CP: wait for completion of the 0143 * running transfer and abort all pending 0144 * IO-transfers for the pipe 0145 * @IPC_MEM_MSG_SLEEP: AP ->CP: host enter or exit sleep 0146 * @IPC_MEM_MSG_FEATURE_SET: AP ->CP: Intel feature configuration 0147 */ 0148 enum ipc_mem_msg { 0149 IPC_MEM_MSG_OPEN_PIPE = 0x01, 0150 IPC_MEM_MSG_CLOSE_PIPE = 0x02, 0151 IPC_MEM_MSG_ABORT_PIPE = 0x03, 0152 IPC_MEM_MSG_SLEEP = 0x04, 0153 IPC_MEM_MSG_FEATURE_SET = 0xF0, 0154 }; 0155 0156 /** 0157 * struct ipc_mem_msg_open_pipe - Message structure for open pipe 0158 * @tdr_addr: Tdr address 0159 * @tdr_entries: Tdr entries 0160 * @pipe_nr: Pipe number 0161 * @type_of_message: Message type 0162 * @irq_vector: MSI vector number 0163 * @accumulation_backoff: Time in usec for data accumalation 0164 * @completion_status: Message Completion Status 0165 */ 0166 struct ipc_mem_msg_open_pipe { 0167 __le64 tdr_addr; 0168 __le16 tdr_entries; 0169 u8 pipe_nr; 0170 u8 type_of_message; 0171 __le32 irq_vector; 0172 __le32 accumulation_backoff; 0173 __le32 completion_status; 0174 }; 0175 0176 /** 0177 * struct ipc_mem_msg_close_pipe - Message structure for close pipe 0178 * @reserved1: Reserved 0179 * @reserved2: Reserved 0180 * @pipe_nr: Pipe number 0181 * @type_of_message: Message type 0182 * @reserved3: Reserved 0183 * @reserved4: Reserved 0184 * @completion_status: Message Completion Status 0185 */ 0186 struct ipc_mem_msg_close_pipe { 0187 __le32 reserved1[2]; 0188 __le16 reserved2; 0189 u8 pipe_nr; 0190 u8 type_of_message; 0191 __le32 reserved3; 0192 __le32 reserved4; 0193 __le32 completion_status; 0194 }; 0195 0196 /** 0197 * struct ipc_mem_msg_abort_pipe - Message structure for abort pipe 0198 * @reserved1: Reserved 0199 * @reserved2: Reserved 0200 * @pipe_nr: Pipe number 0201 * @type_of_message: Message type 0202 * @reserved3: Reserved 0203 * @reserved4: Reserved 0204 * @completion_status: Message Completion Status 0205 */ 0206 struct ipc_mem_msg_abort_pipe { 0207 __le32 reserved1[2]; 0208 __le16 reserved2; 0209 u8 pipe_nr; 0210 u8 type_of_message; 0211 __le32 reserved3; 0212 __le32 reserved4; 0213 __le32 completion_status; 0214 }; 0215 0216 /** 0217 * struct ipc_mem_msg_host_sleep - Message structure for sleep message. 0218 * @reserved1: Reserved 0219 * @target: 0=host, 1=device, host or EP devie 0220 * is the message target 0221 * @state: 0=enter sleep, 1=exit sleep, 0222 * 2=enter sleep no protocol 0223 * @reserved2: Reserved 0224 * @type_of_message: Message type 0225 * @reserved3: Reserved 0226 * @reserved4: Reserved 0227 * @completion_status: Message Completion Status 0228 */ 0229 struct ipc_mem_msg_host_sleep { 0230 __le32 reserved1[2]; 0231 u8 target; 0232 u8 state; 0233 u8 reserved2; 0234 u8 type_of_message; 0235 __le32 reserved3; 0236 __le32 reserved4; 0237 __le32 completion_status; 0238 }; 0239 0240 /** 0241 * struct ipc_mem_msg_feature_set - Message structure for feature_set message 0242 * @reserved1: Reserved 0243 * @reserved2: Reserved 0244 * @reset_enable: 0=out-of-band, 1=in-band-crash notification 0245 * @type_of_message: Message type 0246 * @reserved3: Reserved 0247 * @reserved4: Reserved 0248 * @completion_status: Message Completion Status 0249 */ 0250 struct ipc_mem_msg_feature_set { 0251 __le32 reserved1[2]; 0252 __le16 reserved2; 0253 u8 reset_enable; 0254 u8 type_of_message; 0255 __le32 reserved3; 0256 __le32 reserved4; 0257 __le32 completion_status; 0258 }; 0259 0260 /** 0261 * struct ipc_mem_msg_common - Message structure for completion status update. 0262 * @reserved1: Reserved 0263 * @reserved2: Reserved 0264 * @type_of_message: Message type 0265 * @reserved3: Reserved 0266 * @reserved4: Reserved 0267 * @completion_status: Message Completion Status 0268 */ 0269 struct ipc_mem_msg_common { 0270 __le32 reserved1[2]; 0271 u8 reserved2[3]; 0272 u8 type_of_message; 0273 __le32 reserved3; 0274 __le32 reserved4; 0275 __le32 completion_status; 0276 }; 0277 0278 /** 0279 * union ipc_mem_msg_entry - Union with all possible messages. 0280 * @open_pipe: Open pipe message struct 0281 * @close_pipe: Close pipe message struct 0282 * @abort_pipe: Abort pipe message struct 0283 * @host_sleep: Host sleep message struct 0284 * @feature_set: Featuer set message struct 0285 * @common: Used to access msg_type and to set the completion status 0286 */ 0287 union ipc_mem_msg_entry { 0288 struct ipc_mem_msg_open_pipe open_pipe; 0289 struct ipc_mem_msg_close_pipe close_pipe; 0290 struct ipc_mem_msg_abort_pipe abort_pipe; 0291 struct ipc_mem_msg_host_sleep host_sleep; 0292 struct ipc_mem_msg_feature_set feature_set; 0293 struct ipc_mem_msg_common common; 0294 }; 0295 0296 /* Transfer descriptor definition. */ 0297 struct ipc_protocol_td { 0298 union { 0299 /* 0 : 63 - 64-bit address of a buffer in host memory. */ 0300 dma_addr_t address; 0301 struct { 0302 /* 0 : 31 - 32 bit address */ 0303 __le32 address; 0304 /* 32 : 63 - corresponding descriptor */ 0305 __le32 desc; 0306 } __packed shm; 0307 } buffer; 0308 0309 /* 0 - 2nd byte - Size of the buffer. 0310 * The host provides the size of the buffer queued. 0311 * The EP device reads this value and shall update 0312 * it for downlink transfers to indicate the 0313 * amount of data written in buffer. 0314 * 3rd byte - This field provides the completion status 0315 * of the TD. When queuing the TD, the host sets 0316 * the status to 0. The EP device updates this 0317 * field when completing the TD. 0318 */ 0319 __le32 scs; 0320 0321 /* 0th - nr of following descriptors 0322 * 1 - 3rd byte - reserved 0323 */ 0324 __le32 next; 0325 } __packed; 0326 0327 /** 0328 * ipc_protocol_msg_prep - Prepare message based upon message type 0329 * @ipc_imem: iosm_protocol instance 0330 * @msg_type: message prepare type 0331 * @args: message arguments 0332 * 0333 * Return: 0 on success and failure value on error 0334 */ 0335 int ipc_protocol_msg_prep(struct iosm_imem *ipc_imem, 0336 enum ipc_msg_prep_type msg_type, 0337 union ipc_msg_prep_args *args); 0338 0339 /** 0340 * ipc_protocol_msg_hp_update - Function for head pointer update 0341 * of message ring 0342 * @ipc_imem: iosm_protocol instance 0343 */ 0344 void ipc_protocol_msg_hp_update(struct iosm_imem *ipc_imem); 0345 0346 /** 0347 * ipc_protocol_msg_process - Function for processing responses 0348 * to IPC messages 0349 * @ipc_imem: iosm_protocol instance 0350 * @irq: IRQ vector 0351 * 0352 * Return: True on success, false if error 0353 */ 0354 bool ipc_protocol_msg_process(struct iosm_imem *ipc_imem, int irq); 0355 0356 /** 0357 * ipc_protocol_ul_td_send - Function for sending the data to CP 0358 * @ipc_protocol: iosm_protocol instance 0359 * @pipe: Pipe instance 0360 * @p_ul_list: uplink sk_buff list 0361 * 0362 * Return: true in success, false in case of error 0363 */ 0364 bool ipc_protocol_ul_td_send(struct iosm_protocol *ipc_protocol, 0365 struct ipc_pipe *pipe, 0366 struct sk_buff_head *p_ul_list); 0367 0368 /** 0369 * ipc_protocol_ul_td_process - Function for processing the sent data 0370 * @ipc_protocol: iosm_protocol instance 0371 * @pipe: Pipe instance 0372 * 0373 * Return: sk_buff instance 0374 */ 0375 struct sk_buff *ipc_protocol_ul_td_process(struct iosm_protocol *ipc_protocol, 0376 struct ipc_pipe *pipe); 0377 0378 /** 0379 * ipc_protocol_dl_td_prepare - Function for providing DL TDs to CP 0380 * @ipc_protocol: iosm_protocol instance 0381 * @pipe: Pipe instance 0382 * 0383 * Return: true in success, false in case of error 0384 */ 0385 bool ipc_protocol_dl_td_prepare(struct iosm_protocol *ipc_protocol, 0386 struct ipc_pipe *pipe); 0387 0388 /** 0389 * ipc_protocol_dl_td_process - Function for processing the DL data 0390 * @ipc_protocol: iosm_protocol instance 0391 * @pipe: Pipe instance 0392 * 0393 * Return: sk_buff instance 0394 */ 0395 struct sk_buff *ipc_protocol_dl_td_process(struct iosm_protocol *ipc_protocol, 0396 struct ipc_pipe *pipe); 0397 0398 /** 0399 * ipc_protocol_get_head_tail_index - Function for getting Head and Tail 0400 * pointer index of given pipe 0401 * @ipc_protocol: iosm_protocol instance 0402 * @pipe: Pipe Instance 0403 * @head: head pointer index of the given pipe 0404 * @tail: tail pointer index of the given pipe 0405 */ 0406 void ipc_protocol_get_head_tail_index(struct iosm_protocol *ipc_protocol, 0407 struct ipc_pipe *pipe, u32 *head, 0408 u32 *tail); 0409 /** 0410 * ipc_protocol_get_ipc_status - Function for getting the IPC Status 0411 * @ipc_protocol: iosm_protocol instance 0412 * 0413 * Return: Returns IPC State 0414 */ 0415 enum ipc_mem_device_ipc_state ipc_protocol_get_ipc_status(struct iosm_protocol 0416 *ipc_protocol); 0417 0418 /** 0419 * ipc_protocol_pipe_cleanup - Function to cleanup pipe resources 0420 * @ipc_protocol: iosm_protocol instance 0421 * @pipe: Pipe instance 0422 */ 0423 void ipc_protocol_pipe_cleanup(struct iosm_protocol *ipc_protocol, 0424 struct ipc_pipe *pipe); 0425 0426 /** 0427 * ipc_protocol_get_ap_exec_stage - Function for getting AP Exec Stage 0428 * @ipc_protocol: pointer to struct iosm protocol 0429 * 0430 * Return: returns BOOT Stages 0431 */ 0432 enum ipc_mem_exec_stage 0433 ipc_protocol_get_ap_exec_stage(struct iosm_protocol *ipc_protocol); 0434 0435 /** 0436 * ipc_protocol_pm_dev_get_sleep_notification - Function for getting Dev Sleep 0437 * notification 0438 * @ipc_protocol: iosm_protocol instance 0439 * 0440 * Return: Returns dev PM State 0441 */ 0442 u32 ipc_protocol_pm_dev_get_sleep_notification(struct iosm_protocol 0443 *ipc_protocol); 0444 #endif
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.1.0 LXR engine. The LXR team |
![]() ![]() |