Hans Verkuil | 1c1e45d | 2008-04-28 20:24:33 -0300 | [diff] [blame] | 1 | /* |
| 2 | * cx18 mailbox functions |
| 3 | * |
| 4 | * Copyright (C) 2007 Hans Verkuil <hverkuil@xs4all.nl> |
Andy Walls | 6afdeaf | 2010-05-23 18:53:35 -0300 | [diff] [blame] | 5 | * Copyright (C) 2008 Andy Walls <awalls@md.metrocast.net> |
Hans Verkuil | 1c1e45d | 2008-04-28 20:24:33 -0300 | [diff] [blame] | 6 | * |
| 7 | * This program is free software; you can redistribute it and/or modify |
| 8 | * it under the terms of the GNU General Public License as published by |
| 9 | * the Free Software Foundation; either version 2 of the License, or |
| 10 | * (at your option) any later version. |
| 11 | * |
| 12 | * This program is distributed in the hope that it will be useful, |
| 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 15 | * GNU General Public License for more details. |
| 16 | * |
| 17 | * You should have received a copy of the GNU General Public License |
| 18 | * along with this program; if not, write to the Free Software |
| 19 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA |
| 20 | * 02111-1307 USA |
| 21 | */ |
| 22 | |
| 23 | #ifndef _CX18_MAILBOX_H_ |
| 24 | #define _CX18_MAILBOX_H_ |
| 25 | |
| 26 | /* mailbox max args */ |
| 27 | #define MAX_MB_ARGUMENTS 6 |
| 28 | /* compatibility, should be same as the define in cx2341x.h */ |
| 29 | #define CX2341X_MBOX_MAX_DATA 16 |
| 30 | |
| 31 | #define MB_RESERVED_HANDLE_0 0 |
| 32 | #define MB_RESERVED_HANDLE_1 0xFFFFFFFF |
| 33 | |
Andy Walls | 72c2d6d | 2008-11-06 01:15:41 -0300 | [diff] [blame] | 34 | #define APU 0 |
| 35 | #define CPU 1 |
| 36 | #define EPU 2 |
| 37 | #define HPU 3 |
| 38 | |
Hans Verkuil | 1c1e45d | 2008-04-28 20:24:33 -0300 | [diff] [blame] | 39 | struct cx18; |
| 40 | |
Andy Walls | ee2d64f | 2008-11-16 01:38:19 -0300 | [diff] [blame] | 41 | /* |
Andy Walls | 52fcb3e | 2009-11-08 23:45:24 -0300 | [diff] [blame] | 42 | * This structure is used by CPU to provide completed MDL & buffers information. |
| 43 | * Its structure is dictated by the layout of the SCB, required by the |
Adam Buchbinder | 6070d81 | 2009-12-04 15:47:01 -0500 | [diff] [blame] | 44 | * firmware, but its definition needs to be here, instead of in cx18-scb.h, |
Andy Walls | ee2d64f | 2008-11-16 01:38:19 -0300 | [diff] [blame] | 45 | * for mailbox work order scheduling |
| 46 | */ |
| 47 | struct cx18_mdl_ack { |
| 48 | u32 id; /* ID of a completed MDL */ |
Andy Walls | 52fcb3e | 2009-11-08 23:45:24 -0300 | [diff] [blame] | 49 | u32 data_used; /* Total data filled in the MDL with 'id' */ |
Andy Walls | ee2d64f | 2008-11-16 01:38:19 -0300 | [diff] [blame] | 50 | }; |
| 51 | |
Hans Verkuil | 1c1e45d | 2008-04-28 20:24:33 -0300 | [diff] [blame] | 52 | /* The cx18_mailbox struct is the mailbox structure which is used for passing |
| 53 | messages between processors */ |
| 54 | struct cx18_mailbox { |
| 55 | /* The sender sets a handle in 'request' after he fills the command. The |
| 56 | 'request' should be different than 'ack'. The sender, also, generates |
| 57 | an interrupt on XPU2YPU_irq where XPU is the sender and YPU is the |
| 58 | receiver. */ |
| 59 | u32 request; |
| 60 | /* The receiver detects a new command when 'req' is different than 'ack'. |
| 61 | He sets 'ack' to the same value as 'req' to clear the command. He, also, |
| 62 | generates an interrupt on YPU2XPU_irq where XPU is the sender and YPU |
| 63 | is the receiver. */ |
| 64 | u32 ack; |
| 65 | u32 reserved[6]; |
| 66 | /* 'cmd' identifies the command. The list of these commands are in |
| 67 | cx23418.h */ |
| 68 | u32 cmd; |
| 69 | /* Each command can have up to 6 arguments */ |
| 70 | u32 args[MAX_MB_ARGUMENTS]; |
| 71 | /* The return code can be one of the codes in the file cx23418.h. If the |
Joe Perches | bfb9035 | 2011-08-17 06:58:04 -0700 | [diff] [blame] | 72 | command is completed successfully, the error will be ERR_SYS_SUCCESS. |
Hans Verkuil | 1c1e45d | 2008-04-28 20:24:33 -0300 | [diff] [blame] | 73 | If it is pending, the code is ERR_SYS_PENDING. If it failed, the error |
| 74 | code would indicate the task from which the error originated and will |
| 75 | be one of the errors in cx23418.h. In that case, the following |
| 76 | applies ((error & 0xff) != 0). |
| 77 | If the command is pending, the return will be passed in a MB from the |
| 78 | receiver to the sender. 'req' will be returned in args[0] */ |
| 79 | u32 error; |
| 80 | }; |
| 81 | |
Andy Walls | 50b86ba | 2008-11-23 19:16:44 -0300 | [diff] [blame] | 82 | struct cx18_stream; |
| 83 | |
Hans Verkuil | 1c1e45d | 2008-04-28 20:24:33 -0300 | [diff] [blame] | 84 | int cx18_api(struct cx18 *cx, u32 cmd, int args, u32 data[]); |
| 85 | int cx18_vapi_result(struct cx18 *cx, u32 data[MAX_MB_ARGUMENTS], u32 cmd, |
| 86 | int args, ...); |
| 87 | int cx18_vapi(struct cx18 *cx, u32 cmd, int args, ...); |
| 88 | int cx18_api_func(void *priv, u32 cmd, int in, int out, |
| 89 | u32 data[CX2341X_MBOX_MAX_DATA]); |
Andy Walls | ee2d64f | 2008-11-16 01:38:19 -0300 | [diff] [blame] | 90 | |
| 91 | void cx18_api_epu_cmd_irq(struct cx18 *cx, int rpu); |
| 92 | |
Andy Walls | deed75e | 2009-04-13 22:22:40 -0300 | [diff] [blame] | 93 | void cx18_in_work_handler(struct work_struct *work); |
Hans Verkuil | 1c1e45d | 2008-04-28 20:24:33 -0300 | [diff] [blame] | 94 | |
| 95 | #endif |