18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-or-later */ 28c2ecf20Sopenharmony_ci/* 38c2ecf20Sopenharmony_ci * cx18 mailbox functions 48c2ecf20Sopenharmony_ci * 58c2ecf20Sopenharmony_ci * Copyright (C) 2007 Hans Verkuil <hverkuil@xs4all.nl> 68c2ecf20Sopenharmony_ci * Copyright (C) 2008 Andy Walls <awalls@md.metrocast.net> 78c2ecf20Sopenharmony_ci */ 88c2ecf20Sopenharmony_ci 98c2ecf20Sopenharmony_ci#ifndef _CX18_MAILBOX_H_ 108c2ecf20Sopenharmony_ci#define _CX18_MAILBOX_H_ 118c2ecf20Sopenharmony_ci 128c2ecf20Sopenharmony_ci/* mailbox max args */ 138c2ecf20Sopenharmony_ci#define MAX_MB_ARGUMENTS 6 148c2ecf20Sopenharmony_ci/* compatibility, should be same as the define in cx2341x.h */ 158c2ecf20Sopenharmony_ci#define CX2341X_MBOX_MAX_DATA 16 168c2ecf20Sopenharmony_ci 178c2ecf20Sopenharmony_ci#define MB_RESERVED_HANDLE_0 0 188c2ecf20Sopenharmony_ci#define MB_RESERVED_HANDLE_1 0xFFFFFFFF 198c2ecf20Sopenharmony_ci 208c2ecf20Sopenharmony_ci#define APU 0 218c2ecf20Sopenharmony_ci#define CPU 1 228c2ecf20Sopenharmony_ci#define EPU 2 238c2ecf20Sopenharmony_ci#define HPU 3 248c2ecf20Sopenharmony_ci 258c2ecf20Sopenharmony_cistruct cx18; 268c2ecf20Sopenharmony_ci 278c2ecf20Sopenharmony_ci/* 288c2ecf20Sopenharmony_ci * This structure is used by CPU to provide completed MDL & buffers information. 298c2ecf20Sopenharmony_ci * Its structure is dictated by the layout of the SCB, required by the 308c2ecf20Sopenharmony_ci * firmware, but its definition needs to be here, instead of in cx18-scb.h, 318c2ecf20Sopenharmony_ci * for mailbox work order scheduling 328c2ecf20Sopenharmony_ci */ 338c2ecf20Sopenharmony_cistruct cx18_mdl_ack { 348c2ecf20Sopenharmony_ci u32 id; /* ID of a completed MDL */ 358c2ecf20Sopenharmony_ci u32 data_used; /* Total data filled in the MDL with 'id' */ 368c2ecf20Sopenharmony_ci}; 378c2ecf20Sopenharmony_ci 388c2ecf20Sopenharmony_ci/* The cx18_mailbox struct is the mailbox structure which is used for passing 398c2ecf20Sopenharmony_ci messages between processors */ 408c2ecf20Sopenharmony_cistruct cx18_mailbox { 418c2ecf20Sopenharmony_ci /* The sender sets a handle in 'request' after he fills the command. The 428c2ecf20Sopenharmony_ci 'request' should be different than 'ack'. The sender, also, generates 438c2ecf20Sopenharmony_ci an interrupt on XPU2YPU_irq where XPU is the sender and YPU is the 448c2ecf20Sopenharmony_ci receiver. */ 458c2ecf20Sopenharmony_ci u32 request; 468c2ecf20Sopenharmony_ci /* The receiver detects a new command when 'req' is different than 'ack'. 478c2ecf20Sopenharmony_ci He sets 'ack' to the same value as 'req' to clear the command. He, also, 488c2ecf20Sopenharmony_ci generates an interrupt on YPU2XPU_irq where XPU is the sender and YPU 498c2ecf20Sopenharmony_ci is the receiver. */ 508c2ecf20Sopenharmony_ci u32 ack; 518c2ecf20Sopenharmony_ci u32 reserved[6]; 528c2ecf20Sopenharmony_ci /* 'cmd' identifies the command. The list of these commands are in 538c2ecf20Sopenharmony_ci cx23418.h */ 548c2ecf20Sopenharmony_ci u32 cmd; 558c2ecf20Sopenharmony_ci /* Each command can have up to 6 arguments */ 568c2ecf20Sopenharmony_ci u32 args[MAX_MB_ARGUMENTS]; 578c2ecf20Sopenharmony_ci /* The return code can be one of the codes in the file cx23418.h. If the 588c2ecf20Sopenharmony_ci command is completed successfully, the error will be ERR_SYS_SUCCESS. 598c2ecf20Sopenharmony_ci If it is pending, the code is ERR_SYS_PENDING. If it failed, the error 608c2ecf20Sopenharmony_ci code would indicate the task from which the error originated and will 618c2ecf20Sopenharmony_ci be one of the errors in cx23418.h. In that case, the following 628c2ecf20Sopenharmony_ci applies ((error & 0xff) != 0). 638c2ecf20Sopenharmony_ci If the command is pending, the return will be passed in a MB from the 648c2ecf20Sopenharmony_ci receiver to the sender. 'req' will be returned in args[0] */ 658c2ecf20Sopenharmony_ci u32 error; 668c2ecf20Sopenharmony_ci}; 678c2ecf20Sopenharmony_ci 688c2ecf20Sopenharmony_cistruct cx18_stream; 698c2ecf20Sopenharmony_ci 708c2ecf20Sopenharmony_ciint cx18_api(struct cx18 *cx, u32 cmd, int args, u32 data[]); 718c2ecf20Sopenharmony_ciint cx18_vapi_result(struct cx18 *cx, u32 data[MAX_MB_ARGUMENTS], u32 cmd, 728c2ecf20Sopenharmony_ci int args, ...); 738c2ecf20Sopenharmony_ciint cx18_vapi(struct cx18 *cx, u32 cmd, int args, ...); 748c2ecf20Sopenharmony_ciint cx18_api_func(void *priv, u32 cmd, int in, int out, 758c2ecf20Sopenharmony_ci u32 data[CX2341X_MBOX_MAX_DATA]); 768c2ecf20Sopenharmony_ci 778c2ecf20Sopenharmony_civoid cx18_api_epu_cmd_irq(struct cx18 *cx, int rpu); 788c2ecf20Sopenharmony_ci 798c2ecf20Sopenharmony_civoid cx18_in_work_handler(struct work_struct *work); 808c2ecf20Sopenharmony_ci 818c2ecf20Sopenharmony_ci#endif 82