xref: /OK3568_Linux_fs/kernel/drivers/media/pci/cx18/cx18-mailbox.h (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1*4882a593Smuzhiyun /* SPDX-License-Identifier: GPL-2.0-or-later */
2*4882a593Smuzhiyun /*
3*4882a593Smuzhiyun  *  cx18 mailbox functions
4*4882a593Smuzhiyun  *
5*4882a593Smuzhiyun  *  Copyright (C) 2007  Hans Verkuil <hverkuil@xs4all.nl>
6*4882a593Smuzhiyun  *  Copyright (C) 2008  Andy Walls <awalls@md.metrocast.net>
7*4882a593Smuzhiyun  */
8*4882a593Smuzhiyun 
9*4882a593Smuzhiyun #ifndef _CX18_MAILBOX_H_
10*4882a593Smuzhiyun #define _CX18_MAILBOX_H_
11*4882a593Smuzhiyun 
12*4882a593Smuzhiyun /* mailbox max args */
13*4882a593Smuzhiyun #define MAX_MB_ARGUMENTS 6
14*4882a593Smuzhiyun /* compatibility, should be same as the define in cx2341x.h */
15*4882a593Smuzhiyun #define CX2341X_MBOX_MAX_DATA 16
16*4882a593Smuzhiyun 
17*4882a593Smuzhiyun #define MB_RESERVED_HANDLE_0 0
18*4882a593Smuzhiyun #define MB_RESERVED_HANDLE_1 0xFFFFFFFF
19*4882a593Smuzhiyun 
20*4882a593Smuzhiyun #define APU 0
21*4882a593Smuzhiyun #define CPU 1
22*4882a593Smuzhiyun #define EPU 2
23*4882a593Smuzhiyun #define HPU 3
24*4882a593Smuzhiyun 
25*4882a593Smuzhiyun struct cx18;
26*4882a593Smuzhiyun 
27*4882a593Smuzhiyun /*
28*4882a593Smuzhiyun  * This structure is used by CPU to provide completed MDL & buffers information.
29*4882a593Smuzhiyun  * Its structure is dictated by the layout of the SCB, required by the
30*4882a593Smuzhiyun  * firmware, but its definition needs to be here, instead of in cx18-scb.h,
31*4882a593Smuzhiyun  * for mailbox work order scheduling
32*4882a593Smuzhiyun  */
33*4882a593Smuzhiyun struct cx18_mdl_ack {
34*4882a593Smuzhiyun     u32 id;        /* ID of a completed MDL */
35*4882a593Smuzhiyun     u32 data_used; /* Total data filled in the MDL with 'id' */
36*4882a593Smuzhiyun };
37*4882a593Smuzhiyun 
38*4882a593Smuzhiyun /* The cx18_mailbox struct is the mailbox structure which is used for passing
39*4882a593Smuzhiyun    messages between processors */
40*4882a593Smuzhiyun struct cx18_mailbox {
41*4882a593Smuzhiyun     /* The sender sets a handle in 'request' after he fills the command. The
42*4882a593Smuzhiyun        'request' should be different than 'ack'. The sender, also, generates
43*4882a593Smuzhiyun        an interrupt on XPU2YPU_irq where XPU is the sender and YPU is the
44*4882a593Smuzhiyun        receiver. */
45*4882a593Smuzhiyun     u32       request;
46*4882a593Smuzhiyun     /* The receiver detects a new command when 'req' is different than 'ack'.
47*4882a593Smuzhiyun        He sets 'ack' to the same value as 'req' to clear the command. He, also,
48*4882a593Smuzhiyun        generates an interrupt on YPU2XPU_irq where XPU is the sender and YPU
49*4882a593Smuzhiyun        is the receiver. */
50*4882a593Smuzhiyun     u32       ack;
51*4882a593Smuzhiyun     u32       reserved[6];
52*4882a593Smuzhiyun     /* 'cmd' identifies the command. The list of these commands are in
53*4882a593Smuzhiyun        cx23418.h */
54*4882a593Smuzhiyun     u32       cmd;
55*4882a593Smuzhiyun     /* Each command can have up to 6 arguments */
56*4882a593Smuzhiyun     u32       args[MAX_MB_ARGUMENTS];
57*4882a593Smuzhiyun     /* The return code can be one of the codes in the file cx23418.h. If the
58*4882a593Smuzhiyun        command is completed successfully, the error will be ERR_SYS_SUCCESS.
59*4882a593Smuzhiyun        If it is pending, the code is ERR_SYS_PENDING. If it failed, the error
60*4882a593Smuzhiyun        code would indicate the task from which the error originated and will
61*4882a593Smuzhiyun        be one of the errors in cx23418.h. In that case, the following
62*4882a593Smuzhiyun        applies ((error & 0xff) != 0).
63*4882a593Smuzhiyun        If the command is pending, the return will be passed in a MB from the
64*4882a593Smuzhiyun        receiver to the sender. 'req' will be returned in args[0] */
65*4882a593Smuzhiyun     u32       error;
66*4882a593Smuzhiyun };
67*4882a593Smuzhiyun 
68*4882a593Smuzhiyun struct cx18_stream;
69*4882a593Smuzhiyun 
70*4882a593Smuzhiyun int cx18_api(struct cx18 *cx, u32 cmd, int args, u32 data[]);
71*4882a593Smuzhiyun int cx18_vapi_result(struct cx18 *cx, u32 data[MAX_MB_ARGUMENTS], u32 cmd,
72*4882a593Smuzhiyun 		int args, ...);
73*4882a593Smuzhiyun int cx18_vapi(struct cx18 *cx, u32 cmd, int args, ...);
74*4882a593Smuzhiyun int cx18_api_func(void *priv, u32 cmd, int in, int out,
75*4882a593Smuzhiyun 		u32 data[CX2341X_MBOX_MAX_DATA]);
76*4882a593Smuzhiyun 
77*4882a593Smuzhiyun void cx18_api_epu_cmd_irq(struct cx18 *cx, int rpu);
78*4882a593Smuzhiyun 
79*4882a593Smuzhiyun void cx18_in_work_handler(struct work_struct *work);
80*4882a593Smuzhiyun 
81*4882a593Smuzhiyun #endif
82