xref: /utopia/UTPA2-700.0.x/projects/tools/lint/mips-linux-gnu_include/linux/firewire-cdev.h (revision 53ee8cc121a030b8d368113ac3e966b4705770ef)
1*53ee8cc1Swenshuai.xi /*
2*53ee8cc1Swenshuai.xi  * Char device interface.
3*53ee8cc1Swenshuai.xi  *
4*53ee8cc1Swenshuai.xi  * Copyright (C) 2005-2006  Kristian Hoegsberg <krh@bitplanet.net>
5*53ee8cc1Swenshuai.xi  *
6*53ee8cc1Swenshuai.xi  * This program is free software; you can redistribute it and/or modify
7*53ee8cc1Swenshuai.xi  * it under the terms of the GNU General Public License as published by
8*53ee8cc1Swenshuai.xi  * the Free Software Foundation; either version 2 of the License, or
9*53ee8cc1Swenshuai.xi  * (at your option) any later version.
10*53ee8cc1Swenshuai.xi  *
11*53ee8cc1Swenshuai.xi  * This program is distributed in the hope that it will be useful,
12*53ee8cc1Swenshuai.xi  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13*53ee8cc1Swenshuai.xi  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14*53ee8cc1Swenshuai.xi  * GNU General Public License for more details.
15*53ee8cc1Swenshuai.xi  *
16*53ee8cc1Swenshuai.xi  * You should have received a copy of the GNU General Public License
17*53ee8cc1Swenshuai.xi  * along with this program; if not, write to the Free Software Foundation,
18*53ee8cc1Swenshuai.xi  * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19*53ee8cc1Swenshuai.xi  */
20*53ee8cc1Swenshuai.xi 
21*53ee8cc1Swenshuai.xi #ifndef _LINUX_FIREWIRE_CDEV_H
22*53ee8cc1Swenshuai.xi #define _LINUX_FIREWIRE_CDEV_H
23*53ee8cc1Swenshuai.xi 
24*53ee8cc1Swenshuai.xi #include <linux/ioctl.h>
25*53ee8cc1Swenshuai.xi #include <linux/types.h>
26*53ee8cc1Swenshuai.xi #include <linux/firewire-constants.h>
27*53ee8cc1Swenshuai.xi 
28*53ee8cc1Swenshuai.xi #define FW_CDEV_EVENT_BUS_RESET		0x00
29*53ee8cc1Swenshuai.xi #define FW_CDEV_EVENT_RESPONSE		0x01
30*53ee8cc1Swenshuai.xi #define FW_CDEV_EVENT_REQUEST		0x02
31*53ee8cc1Swenshuai.xi #define FW_CDEV_EVENT_ISO_INTERRUPT	0x03
32*53ee8cc1Swenshuai.xi 
33*53ee8cc1Swenshuai.xi /**
34*53ee8cc1Swenshuai.xi  * struct fw_cdev_event_common - Common part of all fw_cdev_event_ types
35*53ee8cc1Swenshuai.xi  * @closure:	For arbitrary use by userspace
36*53ee8cc1Swenshuai.xi  * @type:	Discriminates the fw_cdev_event_ types
37*53ee8cc1Swenshuai.xi  *
38*53ee8cc1Swenshuai.xi  * This struct may be used to access generic members of all fw_cdev_event_
39*53ee8cc1Swenshuai.xi  * types regardless of the specific type.
40*53ee8cc1Swenshuai.xi  *
41*53ee8cc1Swenshuai.xi  * Data passed in the @closure field for a request will be returned in the
42*53ee8cc1Swenshuai.xi  * corresponding event.  It is big enough to hold a pointer on all platforms.
43*53ee8cc1Swenshuai.xi  * The ioctl used to set @closure depends on the @type of event.
44*53ee8cc1Swenshuai.xi  */
45*53ee8cc1Swenshuai.xi struct fw_cdev_event_common {
46*53ee8cc1Swenshuai.xi 	__u64 closure;
47*53ee8cc1Swenshuai.xi 	__u32 type;
48*53ee8cc1Swenshuai.xi };
49*53ee8cc1Swenshuai.xi 
50*53ee8cc1Swenshuai.xi /**
51*53ee8cc1Swenshuai.xi  * struct fw_cdev_event_bus_reset - Sent when a bus reset occurred
52*53ee8cc1Swenshuai.xi  * @closure:	See &fw_cdev_event_common; set by %FW_CDEV_IOC_GET_INFO ioctl
53*53ee8cc1Swenshuai.xi  * @type:	See &fw_cdev_event_common; always %FW_CDEV_EVENT_BUS_RESET
54*53ee8cc1Swenshuai.xi  * @node_id:       New node ID of this node
55*53ee8cc1Swenshuai.xi  * @local_node_id: Node ID of the local node, i.e. of the controller
56*53ee8cc1Swenshuai.xi  * @bm_node_id:    Node ID of the bus manager
57*53ee8cc1Swenshuai.xi  * @irm_node_id:   Node ID of the iso resource manager
58*53ee8cc1Swenshuai.xi  * @root_node_id:  Node ID of the root node
59*53ee8cc1Swenshuai.xi  * @generation:    New bus generation
60*53ee8cc1Swenshuai.xi  *
61*53ee8cc1Swenshuai.xi  * This event is sent when the bus the device belongs to goes through a bus
62*53ee8cc1Swenshuai.xi  * reset.  It provides information about the new bus configuration, such as
63*53ee8cc1Swenshuai.xi  * new node ID for this device, new root ID, and others.
64*53ee8cc1Swenshuai.xi  */
65*53ee8cc1Swenshuai.xi struct fw_cdev_event_bus_reset {
66*53ee8cc1Swenshuai.xi 	__u64 closure;
67*53ee8cc1Swenshuai.xi 	__u32 type;
68*53ee8cc1Swenshuai.xi 	__u32 node_id;
69*53ee8cc1Swenshuai.xi 	__u32 local_node_id;
70*53ee8cc1Swenshuai.xi 	__u32 bm_node_id;
71*53ee8cc1Swenshuai.xi 	__u32 irm_node_id;
72*53ee8cc1Swenshuai.xi 	__u32 root_node_id;
73*53ee8cc1Swenshuai.xi 	__u32 generation;
74*53ee8cc1Swenshuai.xi };
75*53ee8cc1Swenshuai.xi 
76*53ee8cc1Swenshuai.xi /**
77*53ee8cc1Swenshuai.xi  * struct fw_cdev_event_response - Sent when a response packet was received
78*53ee8cc1Swenshuai.xi  * @closure:	See &fw_cdev_event_common;
79*53ee8cc1Swenshuai.xi  *		set by %FW_CDEV_IOC_SEND_REQUEST ioctl
80*53ee8cc1Swenshuai.xi  * @type:	See &fw_cdev_event_common; always %FW_CDEV_EVENT_RESPONSE
81*53ee8cc1Swenshuai.xi  * @rcode:	Response code returned by the remote node
82*53ee8cc1Swenshuai.xi  * @length:	Data length, i.e. the response's payload size in bytes
83*53ee8cc1Swenshuai.xi  * @data:	Payload data, if any
84*53ee8cc1Swenshuai.xi  *
85*53ee8cc1Swenshuai.xi  * This event is sent when the stack receives a response to an outgoing request
86*53ee8cc1Swenshuai.xi  * sent by %FW_CDEV_IOC_SEND_REQUEST ioctl.  The payload data for responses
87*53ee8cc1Swenshuai.xi  * carrying data (read and lock responses) follows immediately and can be
88*53ee8cc1Swenshuai.xi  * accessed through the @data field.
89*53ee8cc1Swenshuai.xi  */
90*53ee8cc1Swenshuai.xi struct fw_cdev_event_response {
91*53ee8cc1Swenshuai.xi 	__u64 closure;
92*53ee8cc1Swenshuai.xi 	__u32 type;
93*53ee8cc1Swenshuai.xi 	__u32 rcode;
94*53ee8cc1Swenshuai.xi 	__u32 length;
95*53ee8cc1Swenshuai.xi 	__u32 data[0];
96*53ee8cc1Swenshuai.xi };
97*53ee8cc1Swenshuai.xi 
98*53ee8cc1Swenshuai.xi /**
99*53ee8cc1Swenshuai.xi  * struct fw_cdev_event_request - Sent on incoming request to an address region
100*53ee8cc1Swenshuai.xi  * @closure:	See &fw_cdev_event_common; set by %FW_CDEV_IOC_ALLOCATE ioctl
101*53ee8cc1Swenshuai.xi  * @type:	See &fw_cdev_event_common; always %FW_CDEV_EVENT_REQUEST
102*53ee8cc1Swenshuai.xi  * @tcode:	Transaction code of the incoming request
103*53ee8cc1Swenshuai.xi  * @offset:	The offset into the 48-bit per-node address space
104*53ee8cc1Swenshuai.xi  * @handle:	Reference to the kernel-side pending request
105*53ee8cc1Swenshuai.xi  * @length:	Data length, i.e. the request's payload size in bytes
106*53ee8cc1Swenshuai.xi  * @data:	Incoming data, if any
107*53ee8cc1Swenshuai.xi  *
108*53ee8cc1Swenshuai.xi  * This event is sent when the stack receives an incoming request to an address
109*53ee8cc1Swenshuai.xi  * region registered using the %FW_CDEV_IOC_ALLOCATE ioctl.  The request is
110*53ee8cc1Swenshuai.xi  * guaranteed to be completely contained in the specified region.  Userspace is
111*53ee8cc1Swenshuai.xi  * responsible for sending the response by %FW_CDEV_IOC_SEND_RESPONSE ioctl,
112*53ee8cc1Swenshuai.xi  * using the same @handle.
113*53ee8cc1Swenshuai.xi  *
114*53ee8cc1Swenshuai.xi  * The payload data for requests carrying data (write and lock requests)
115*53ee8cc1Swenshuai.xi  * follows immediately and can be accessed through the @data field.
116*53ee8cc1Swenshuai.xi  */
117*53ee8cc1Swenshuai.xi struct fw_cdev_event_request {
118*53ee8cc1Swenshuai.xi 	__u64 closure;
119*53ee8cc1Swenshuai.xi 	__u32 type;
120*53ee8cc1Swenshuai.xi 	__u32 tcode;
121*53ee8cc1Swenshuai.xi 	__u64 offset;
122*53ee8cc1Swenshuai.xi 	__u32 handle;
123*53ee8cc1Swenshuai.xi 	__u32 length;
124*53ee8cc1Swenshuai.xi 	__u32 data[0];
125*53ee8cc1Swenshuai.xi };
126*53ee8cc1Swenshuai.xi 
127*53ee8cc1Swenshuai.xi /**
128*53ee8cc1Swenshuai.xi  * struct fw_cdev_event_iso_interrupt - Sent when an iso packet was completed
129*53ee8cc1Swenshuai.xi  * @closure:	See &fw_cdev_event_common;
130*53ee8cc1Swenshuai.xi  *		set by %FW_CDEV_CREATE_ISO_CONTEXT ioctl
131*53ee8cc1Swenshuai.xi  * @type:	See &fw_cdev_event_common; always %FW_CDEV_EVENT_ISO_INTERRUPT
132*53ee8cc1Swenshuai.xi  * @cycle:	Cycle counter of the interrupt packet
133*53ee8cc1Swenshuai.xi  * @header_length: Total length of following headers, in bytes
134*53ee8cc1Swenshuai.xi  * @header:	Stripped headers, if any
135*53ee8cc1Swenshuai.xi  *
136*53ee8cc1Swenshuai.xi  * This event is sent when the controller has completed an &fw_cdev_iso_packet
137*53ee8cc1Swenshuai.xi  * with the %FW_CDEV_ISO_INTERRUPT bit set.  In the receive case, the headers
138*53ee8cc1Swenshuai.xi  * stripped of all packets up until and including the interrupt packet are
139*53ee8cc1Swenshuai.xi  * returned in the @header field.
140*53ee8cc1Swenshuai.xi  */
141*53ee8cc1Swenshuai.xi struct fw_cdev_event_iso_interrupt {
142*53ee8cc1Swenshuai.xi 	__u64 closure;
143*53ee8cc1Swenshuai.xi 	__u32 type;
144*53ee8cc1Swenshuai.xi 	__u32 cycle;
145*53ee8cc1Swenshuai.xi 	__u32 header_length;
146*53ee8cc1Swenshuai.xi 	__u32 header[0];
147*53ee8cc1Swenshuai.xi };
148*53ee8cc1Swenshuai.xi 
149*53ee8cc1Swenshuai.xi /**
150*53ee8cc1Swenshuai.xi  * union fw_cdev_event - Convenience union of fw_cdev_event_ types
151*53ee8cc1Swenshuai.xi  * @common:        Valid for all types
152*53ee8cc1Swenshuai.xi  * @bus_reset:     Valid if @common.type == %FW_CDEV_EVENT_BUS_RESET
153*53ee8cc1Swenshuai.xi  * @response:      Valid if @common.type == %FW_CDEV_EVENT_RESPONSE
154*53ee8cc1Swenshuai.xi  * @request:       Valid if @common.type == %FW_CDEV_EVENT_REQUEST
155*53ee8cc1Swenshuai.xi  * @iso_interrupt: Valid if @common.type == %FW_CDEV_EVENT_ISO_INTERRUPT
156*53ee8cc1Swenshuai.xi  *
157*53ee8cc1Swenshuai.xi  * Convenience union for userspace use.  Events could be read(2) into a char
158*53ee8cc1Swenshuai.xi  * buffer and then cast to this union for further processing.
159*53ee8cc1Swenshuai.xi  */
160*53ee8cc1Swenshuai.xi union fw_cdev_event {
161*53ee8cc1Swenshuai.xi 	struct fw_cdev_event_common common;
162*53ee8cc1Swenshuai.xi 	struct fw_cdev_event_bus_reset bus_reset;
163*53ee8cc1Swenshuai.xi 	struct fw_cdev_event_response response;
164*53ee8cc1Swenshuai.xi 	struct fw_cdev_event_request request;
165*53ee8cc1Swenshuai.xi 	struct fw_cdev_event_iso_interrupt iso_interrupt;
166*53ee8cc1Swenshuai.xi };
167*53ee8cc1Swenshuai.xi 
168*53ee8cc1Swenshuai.xi #define FW_CDEV_IOC_GET_INFO		_IOWR('#', 0x00, struct fw_cdev_get_info)
169*53ee8cc1Swenshuai.xi #define FW_CDEV_IOC_SEND_REQUEST	_IOW('#', 0x01, struct fw_cdev_send_request)
170*53ee8cc1Swenshuai.xi #define FW_CDEV_IOC_ALLOCATE		_IOWR('#', 0x02, struct fw_cdev_allocate)
171*53ee8cc1Swenshuai.xi #define FW_CDEV_IOC_DEALLOCATE		_IOW('#', 0x03, struct fw_cdev_deallocate)
172*53ee8cc1Swenshuai.xi #define FW_CDEV_IOC_SEND_RESPONSE	_IOW('#', 0x04, struct fw_cdev_send_response)
173*53ee8cc1Swenshuai.xi #define FW_CDEV_IOC_INITIATE_BUS_RESET	_IOW('#', 0x05, struct fw_cdev_initiate_bus_reset)
174*53ee8cc1Swenshuai.xi #define FW_CDEV_IOC_ADD_DESCRIPTOR	_IOWR('#', 0x06, struct fw_cdev_add_descriptor)
175*53ee8cc1Swenshuai.xi #define FW_CDEV_IOC_REMOVE_DESCRIPTOR	_IOW('#', 0x07, struct fw_cdev_remove_descriptor)
176*53ee8cc1Swenshuai.xi 
177*53ee8cc1Swenshuai.xi #define FW_CDEV_IOC_CREATE_ISO_CONTEXT	_IOWR('#', 0x08, struct fw_cdev_create_iso_context)
178*53ee8cc1Swenshuai.xi #define FW_CDEV_IOC_QUEUE_ISO		_IOWR('#', 0x09, struct fw_cdev_queue_iso)
179*53ee8cc1Swenshuai.xi #define FW_CDEV_IOC_START_ISO		_IOW('#', 0x0a, struct fw_cdev_start_iso)
180*53ee8cc1Swenshuai.xi #define FW_CDEV_IOC_STOP_ISO		_IOW('#', 0x0b, struct fw_cdev_stop_iso)
181*53ee8cc1Swenshuai.xi #define FW_CDEV_IOC_GET_CYCLE_TIMER	_IOR('#', 0x0c, struct fw_cdev_get_cycle_timer)
182*53ee8cc1Swenshuai.xi 
183*53ee8cc1Swenshuai.xi /* FW_CDEV_VERSION History
184*53ee8cc1Swenshuai.xi  *
185*53ee8cc1Swenshuai.xi  * 1	Feb 18, 2007:  Initial version.
186*53ee8cc1Swenshuai.xi  */
187*53ee8cc1Swenshuai.xi #define FW_CDEV_VERSION		1
188*53ee8cc1Swenshuai.xi 
189*53ee8cc1Swenshuai.xi /**
190*53ee8cc1Swenshuai.xi  * struct fw_cdev_get_info - General purpose information ioctl
191*53ee8cc1Swenshuai.xi  * @version:	The version field is just a running serial number.
192*53ee8cc1Swenshuai.xi  *		We never break backwards compatibility, but may add more
193*53ee8cc1Swenshuai.xi  *		structs and ioctls in later revisions.
194*53ee8cc1Swenshuai.xi  * @rom_length:	If @rom is non-zero, at most rom_length bytes of configuration
195*53ee8cc1Swenshuai.xi  *		ROM will be copied into that user space address.  In either
196*53ee8cc1Swenshuai.xi  *		case, @rom_length is updated with the actual length of the
197*53ee8cc1Swenshuai.xi  *		configuration ROM.
198*53ee8cc1Swenshuai.xi  * @rom:	If non-zero, address of a buffer to be filled by a copy of the
199*53ee8cc1Swenshuai.xi  *		local node's configuration ROM
200*53ee8cc1Swenshuai.xi  * @bus_reset:	If non-zero, address of a buffer to be filled by a
201*53ee8cc1Swenshuai.xi  *		&struct fw_cdev_event_bus_reset with the current state
202*53ee8cc1Swenshuai.xi  *		of the bus.  This does not cause a bus reset to happen.
203*53ee8cc1Swenshuai.xi  * @bus_reset_closure: Value of &closure in this and subsequent bus reset events
204*53ee8cc1Swenshuai.xi  * @card:	The index of the card this device belongs to
205*53ee8cc1Swenshuai.xi  */
206*53ee8cc1Swenshuai.xi struct fw_cdev_get_info {
207*53ee8cc1Swenshuai.xi 	__u32 version;
208*53ee8cc1Swenshuai.xi 	__u32 rom_length;
209*53ee8cc1Swenshuai.xi 	__u64 rom;
210*53ee8cc1Swenshuai.xi 	__u64 bus_reset;
211*53ee8cc1Swenshuai.xi 	__u64 bus_reset_closure;
212*53ee8cc1Swenshuai.xi 	__u32 card;
213*53ee8cc1Swenshuai.xi };
214*53ee8cc1Swenshuai.xi 
215*53ee8cc1Swenshuai.xi /**
216*53ee8cc1Swenshuai.xi  * struct fw_cdev_send_request - Send an asynchronous request packet
217*53ee8cc1Swenshuai.xi  * @tcode:	Transaction code of the request
218*53ee8cc1Swenshuai.xi  * @length:	Length of outgoing payload, in bytes
219*53ee8cc1Swenshuai.xi  * @offset:	48-bit offset at destination node
220*53ee8cc1Swenshuai.xi  * @closure:	Passed back to userspace in the response event
221*53ee8cc1Swenshuai.xi  * @data:	Userspace pointer to payload
222*53ee8cc1Swenshuai.xi  * @generation:	The bus generation where packet is valid
223*53ee8cc1Swenshuai.xi  *
224*53ee8cc1Swenshuai.xi  * Send a request to the device.  This ioctl implements all outgoing requests.
225*53ee8cc1Swenshuai.xi  * Both quadlet and block request specify the payload as a pointer to the data
226*53ee8cc1Swenshuai.xi  * in the @data field.  Once the transaction completes, the kernel writes an
227*53ee8cc1Swenshuai.xi  * &fw_cdev_event_request event back.  The @closure field is passed back to
228*53ee8cc1Swenshuai.xi  * user space in the response event.
229*53ee8cc1Swenshuai.xi  */
230*53ee8cc1Swenshuai.xi struct fw_cdev_send_request {
231*53ee8cc1Swenshuai.xi 	__u32 tcode;
232*53ee8cc1Swenshuai.xi 	__u32 length;
233*53ee8cc1Swenshuai.xi 	__u64 offset;
234*53ee8cc1Swenshuai.xi 	__u64 closure;
235*53ee8cc1Swenshuai.xi 	__u64 data;
236*53ee8cc1Swenshuai.xi 	__u32 generation;
237*53ee8cc1Swenshuai.xi };
238*53ee8cc1Swenshuai.xi 
239*53ee8cc1Swenshuai.xi /**
240*53ee8cc1Swenshuai.xi  * struct fw_cdev_send_response - Send an asynchronous response packet
241*53ee8cc1Swenshuai.xi  * @rcode:	Response code as determined by the userspace handler
242*53ee8cc1Swenshuai.xi  * @length:	Length of outgoing payload, in bytes
243*53ee8cc1Swenshuai.xi  * @data:	Userspace pointer to payload
244*53ee8cc1Swenshuai.xi  * @handle:	The handle from the &fw_cdev_event_request
245*53ee8cc1Swenshuai.xi  *
246*53ee8cc1Swenshuai.xi  * Send a response to an incoming request.  By setting up an address range using
247*53ee8cc1Swenshuai.xi  * the %FW_CDEV_IOC_ALLOCATE ioctl, userspace can listen for incoming requests.  An
248*53ee8cc1Swenshuai.xi  * incoming request will generate an %FW_CDEV_EVENT_REQUEST, and userspace must
249*53ee8cc1Swenshuai.xi  * send a reply using this ioctl.  The event has a handle to the kernel-side
250*53ee8cc1Swenshuai.xi  * pending transaction, which should be used with this ioctl.
251*53ee8cc1Swenshuai.xi  */
252*53ee8cc1Swenshuai.xi struct fw_cdev_send_response {
253*53ee8cc1Swenshuai.xi 	__u32 rcode;
254*53ee8cc1Swenshuai.xi 	__u32 length;
255*53ee8cc1Swenshuai.xi 	__u64 data;
256*53ee8cc1Swenshuai.xi 	__u32 handle;
257*53ee8cc1Swenshuai.xi };
258*53ee8cc1Swenshuai.xi 
259*53ee8cc1Swenshuai.xi /**
260*53ee8cc1Swenshuai.xi  * struct fw_cdev_allocate - Allocate a CSR address range
261*53ee8cc1Swenshuai.xi  * @offset:	Start offset of the address range
262*53ee8cc1Swenshuai.xi  * @closure:	To be passed back to userspace in request events
263*53ee8cc1Swenshuai.xi  * @length:	Length of the address range, in bytes
264*53ee8cc1Swenshuai.xi  * @handle:	Handle to the allocation, written by the kernel
265*53ee8cc1Swenshuai.xi  *
266*53ee8cc1Swenshuai.xi  * Allocate an address range in the 48-bit address space on the local node
267*53ee8cc1Swenshuai.xi  * (the controller).  This allows userspace to listen for requests with an
268*53ee8cc1Swenshuai.xi  * offset within that address range.  When the kernel receives a request
269*53ee8cc1Swenshuai.xi  * within the range, an &fw_cdev_event_request event will be written back.
270*53ee8cc1Swenshuai.xi  * The @closure field is passed back to userspace in the response event.
271*53ee8cc1Swenshuai.xi  * The @handle field is an out parameter, returning a handle to the allocated
272*53ee8cc1Swenshuai.xi  * range to be used for later deallocation of the range.
273*53ee8cc1Swenshuai.xi  */
274*53ee8cc1Swenshuai.xi struct fw_cdev_allocate {
275*53ee8cc1Swenshuai.xi 	__u64 offset;
276*53ee8cc1Swenshuai.xi 	__u64 closure;
277*53ee8cc1Swenshuai.xi 	__u32 length;
278*53ee8cc1Swenshuai.xi 	__u32 handle;
279*53ee8cc1Swenshuai.xi };
280*53ee8cc1Swenshuai.xi 
281*53ee8cc1Swenshuai.xi /**
282*53ee8cc1Swenshuai.xi  * struct fw_cdev_deallocate - Free an address range allocation
283*53ee8cc1Swenshuai.xi  * @handle:	Handle to the address range, as returned by the kernel when the
284*53ee8cc1Swenshuai.xi  *		range was allocated
285*53ee8cc1Swenshuai.xi  */
286*53ee8cc1Swenshuai.xi struct fw_cdev_deallocate {
287*53ee8cc1Swenshuai.xi 	__u32 handle;
288*53ee8cc1Swenshuai.xi };
289*53ee8cc1Swenshuai.xi 
290*53ee8cc1Swenshuai.xi #define FW_CDEV_LONG_RESET	0
291*53ee8cc1Swenshuai.xi #define FW_CDEV_SHORT_RESET	1
292*53ee8cc1Swenshuai.xi 
293*53ee8cc1Swenshuai.xi /**
294*53ee8cc1Swenshuai.xi  * struct fw_cdev_initiate_bus_reset - Initiate a bus reset
295*53ee8cc1Swenshuai.xi  * @type:	%FW_CDEV_SHORT_RESET or %FW_CDEV_LONG_RESET
296*53ee8cc1Swenshuai.xi  *
297*53ee8cc1Swenshuai.xi  * Initiate a bus reset for the bus this device is on.  The bus reset can be
298*53ee8cc1Swenshuai.xi  * either the original (long) bus reset or the arbitrated (short) bus reset
299*53ee8cc1Swenshuai.xi  * introduced in 1394a-2000.
300*53ee8cc1Swenshuai.xi  */
301*53ee8cc1Swenshuai.xi struct fw_cdev_initiate_bus_reset {
302*53ee8cc1Swenshuai.xi 	__u32 type;	/* FW_CDEV_SHORT_RESET or FW_CDEV_LONG_RESET */
303*53ee8cc1Swenshuai.xi };
304*53ee8cc1Swenshuai.xi 
305*53ee8cc1Swenshuai.xi /**
306*53ee8cc1Swenshuai.xi  * struct fw_cdev_add_descriptor - Add contents to the local node's config ROM
307*53ee8cc1Swenshuai.xi  * @immediate:	If non-zero, immediate key to insert before pointer
308*53ee8cc1Swenshuai.xi  * @key:	Upper 8 bits of root directory pointer
309*53ee8cc1Swenshuai.xi  * @data:	Userspace pointer to contents of descriptor block
310*53ee8cc1Swenshuai.xi  * @length:	Length of descriptor block data, in bytes
311*53ee8cc1Swenshuai.xi  * @handle:	Handle to the descriptor, written by the kernel
312*53ee8cc1Swenshuai.xi  *
313*53ee8cc1Swenshuai.xi  * Add a descriptor block and optionally a preceding immediate key to the local
314*53ee8cc1Swenshuai.xi  * node's configuration ROM.
315*53ee8cc1Swenshuai.xi  *
316*53ee8cc1Swenshuai.xi  * The @key field specifies the upper 8 bits of the descriptor root directory
317*53ee8cc1Swenshuai.xi  * pointer and the @data and @length fields specify the contents. The @key
318*53ee8cc1Swenshuai.xi  * should be of the form 0xXX000000. The offset part of the root directory entry
319*53ee8cc1Swenshuai.xi  * will be filled in by the kernel.
320*53ee8cc1Swenshuai.xi  *
321*53ee8cc1Swenshuai.xi  * If not 0, the @immediate field specifies an immediate key which will be
322*53ee8cc1Swenshuai.xi  * inserted before the root directory pointer.
323*53ee8cc1Swenshuai.xi  *
324*53ee8cc1Swenshuai.xi  * If successful, the kernel adds the descriptor and writes back a handle to the
325*53ee8cc1Swenshuai.xi  * kernel-side object to be used for later removal of the descriptor block and
326*53ee8cc1Swenshuai.xi  * immediate key.
327*53ee8cc1Swenshuai.xi  */
328*53ee8cc1Swenshuai.xi struct fw_cdev_add_descriptor {
329*53ee8cc1Swenshuai.xi 	__u32 immediate;
330*53ee8cc1Swenshuai.xi 	__u32 key;
331*53ee8cc1Swenshuai.xi 	__u64 data;
332*53ee8cc1Swenshuai.xi 	__u32 length;
333*53ee8cc1Swenshuai.xi 	__u32 handle;
334*53ee8cc1Swenshuai.xi };
335*53ee8cc1Swenshuai.xi 
336*53ee8cc1Swenshuai.xi /**
337*53ee8cc1Swenshuai.xi  * struct fw_cdev_remove_descriptor - Remove contents from the configuration ROM
338*53ee8cc1Swenshuai.xi  * @handle:	Handle to the descriptor, as returned by the kernel when the
339*53ee8cc1Swenshuai.xi  *		descriptor was added
340*53ee8cc1Swenshuai.xi  *
341*53ee8cc1Swenshuai.xi  * Remove a descriptor block and accompanying immediate key from the local
342*53ee8cc1Swenshuai.xi  * node's configuration ROM.
343*53ee8cc1Swenshuai.xi  */
344*53ee8cc1Swenshuai.xi struct fw_cdev_remove_descriptor {
345*53ee8cc1Swenshuai.xi 	__u32 handle;
346*53ee8cc1Swenshuai.xi };
347*53ee8cc1Swenshuai.xi 
348*53ee8cc1Swenshuai.xi #define FW_CDEV_ISO_CONTEXT_TRANSMIT	0
349*53ee8cc1Swenshuai.xi #define FW_CDEV_ISO_CONTEXT_RECEIVE	1
350*53ee8cc1Swenshuai.xi 
351*53ee8cc1Swenshuai.xi /**
352*53ee8cc1Swenshuai.xi  * struct fw_cdev_create_iso_context - Create a context for isochronous IO
353*53ee8cc1Swenshuai.xi  * @type:	%FW_CDEV_ISO_CONTEXT_TRANSMIT or %FW_CDEV_ISO_CONTEXT_RECEIVE
354*53ee8cc1Swenshuai.xi  * @header_size: Header size to strip for receive contexts
355*53ee8cc1Swenshuai.xi  * @channel:	Channel to bind to
356*53ee8cc1Swenshuai.xi  * @speed:	Speed to transmit at
357*53ee8cc1Swenshuai.xi  * @closure:	To be returned in &fw_cdev_event_iso_interrupt
358*53ee8cc1Swenshuai.xi  * @handle:	Handle to context, written back by kernel
359*53ee8cc1Swenshuai.xi  *
360*53ee8cc1Swenshuai.xi  * Prior to sending or receiving isochronous I/O, a context must be created.
361*53ee8cc1Swenshuai.xi  * The context records information about the transmit or receive configuration
362*53ee8cc1Swenshuai.xi  * and typically maps to an underlying hardware resource.  A context is set up
363*53ee8cc1Swenshuai.xi  * for either sending or receiving.  It is bound to a specific isochronous
364*53ee8cc1Swenshuai.xi  * channel.
365*53ee8cc1Swenshuai.xi  *
366*53ee8cc1Swenshuai.xi  * If a context was successfully created, the kernel writes back a handle to the
367*53ee8cc1Swenshuai.xi  * context, which must be passed in for subsequent operations on that context.
368*53ee8cc1Swenshuai.xi  */
369*53ee8cc1Swenshuai.xi struct fw_cdev_create_iso_context {
370*53ee8cc1Swenshuai.xi 	__u32 type;
371*53ee8cc1Swenshuai.xi 	__u32 header_size;
372*53ee8cc1Swenshuai.xi 	__u32 channel;
373*53ee8cc1Swenshuai.xi 	__u32 speed;
374*53ee8cc1Swenshuai.xi 	__u64 closure;
375*53ee8cc1Swenshuai.xi 	__u32 handle;
376*53ee8cc1Swenshuai.xi };
377*53ee8cc1Swenshuai.xi 
378*53ee8cc1Swenshuai.xi #define FW_CDEV_ISO_PAYLOAD_LENGTH(v)	(v)
379*53ee8cc1Swenshuai.xi #define FW_CDEV_ISO_INTERRUPT		(1 << 16)
380*53ee8cc1Swenshuai.xi #define FW_CDEV_ISO_SKIP		(1 << 17)
381*53ee8cc1Swenshuai.xi #define FW_CDEV_ISO_SYNC		(1 << 17)
382*53ee8cc1Swenshuai.xi #define FW_CDEV_ISO_TAG(v)		((v) << 18)
383*53ee8cc1Swenshuai.xi #define FW_CDEV_ISO_SY(v)		((v) << 20)
384*53ee8cc1Swenshuai.xi #define FW_CDEV_ISO_HEADER_LENGTH(v)	((v) << 24)
385*53ee8cc1Swenshuai.xi 
386*53ee8cc1Swenshuai.xi /**
387*53ee8cc1Swenshuai.xi  * struct fw_cdev_iso_packet - Isochronous packet
388*53ee8cc1Swenshuai.xi  * @control:	Contains the header length (8 uppermost bits), the sy field
389*53ee8cc1Swenshuai.xi  *		(4 bits), the tag field (2 bits), a sync flag (1 bit),
390*53ee8cc1Swenshuai.xi  *		a skip flag (1 bit), an interrupt flag (1 bit), and the
391*53ee8cc1Swenshuai.xi  *		payload length (16 lowermost bits)
392*53ee8cc1Swenshuai.xi  * @header:	Header and payload
393*53ee8cc1Swenshuai.xi  *
394*53ee8cc1Swenshuai.xi  * &struct fw_cdev_iso_packet is used to describe isochronous packet queues.
395*53ee8cc1Swenshuai.xi  *
396*53ee8cc1Swenshuai.xi  * Use the FW_CDEV_ISO_ macros to fill in @control.  The sy and tag fields are
397*53ee8cc1Swenshuai.xi  * specified by IEEE 1394a and IEC 61883.
398*53ee8cc1Swenshuai.xi  *
399*53ee8cc1Swenshuai.xi  * FIXME - finish this documentation
400*53ee8cc1Swenshuai.xi  */
401*53ee8cc1Swenshuai.xi struct fw_cdev_iso_packet {
402*53ee8cc1Swenshuai.xi 	__u32 control;
403*53ee8cc1Swenshuai.xi 	__u32 header[0];
404*53ee8cc1Swenshuai.xi };
405*53ee8cc1Swenshuai.xi 
406*53ee8cc1Swenshuai.xi /**
407*53ee8cc1Swenshuai.xi  * struct fw_cdev_queue_iso - Queue isochronous packets for I/O
408*53ee8cc1Swenshuai.xi  * @packets:	Userspace pointer to packet data
409*53ee8cc1Swenshuai.xi  * @data:	Pointer into mmap()'ed payload buffer
410*53ee8cc1Swenshuai.xi  * @size:	Size of packet data in bytes
411*53ee8cc1Swenshuai.xi  * @handle:	Isochronous context handle
412*53ee8cc1Swenshuai.xi  *
413*53ee8cc1Swenshuai.xi  * Queue a number of isochronous packets for reception or transmission.
414*53ee8cc1Swenshuai.xi  * This ioctl takes a pointer to an array of &fw_cdev_iso_packet structs,
415*53ee8cc1Swenshuai.xi  * which describe how to transmit from or receive into a contiguous region
416*53ee8cc1Swenshuai.xi  * of a mmap()'ed payload buffer.  As part of the packet descriptors,
417*53ee8cc1Swenshuai.xi  * a series of headers can be supplied, which will be prepended to the
418*53ee8cc1Swenshuai.xi  * payload during DMA.
419*53ee8cc1Swenshuai.xi  *
420*53ee8cc1Swenshuai.xi  * The kernel may or may not queue all packets, but will write back updated
421*53ee8cc1Swenshuai.xi  * values of the @packets, @data and @size fields, so the ioctl can be
422*53ee8cc1Swenshuai.xi  * resubmitted easily.
423*53ee8cc1Swenshuai.xi  */
424*53ee8cc1Swenshuai.xi struct fw_cdev_queue_iso {
425*53ee8cc1Swenshuai.xi 	__u64 packets;
426*53ee8cc1Swenshuai.xi 	__u64 data;
427*53ee8cc1Swenshuai.xi 	__u32 size;
428*53ee8cc1Swenshuai.xi 	__u32 handle;
429*53ee8cc1Swenshuai.xi };
430*53ee8cc1Swenshuai.xi 
431*53ee8cc1Swenshuai.xi #define FW_CDEV_ISO_CONTEXT_MATCH_TAG0		 1
432*53ee8cc1Swenshuai.xi #define FW_CDEV_ISO_CONTEXT_MATCH_TAG1		 2
433*53ee8cc1Swenshuai.xi #define FW_CDEV_ISO_CONTEXT_MATCH_TAG2		 4
434*53ee8cc1Swenshuai.xi #define FW_CDEV_ISO_CONTEXT_MATCH_TAG3		 8
435*53ee8cc1Swenshuai.xi #define FW_CDEV_ISO_CONTEXT_MATCH_ALL_TAGS	15
436*53ee8cc1Swenshuai.xi 
437*53ee8cc1Swenshuai.xi /**
438*53ee8cc1Swenshuai.xi  * struct fw_cdev_start_iso - Start an isochronous transmission or reception
439*53ee8cc1Swenshuai.xi  * @cycle:	Cycle in which to start I/O.  If @cycle is greater than or
440*53ee8cc1Swenshuai.xi  *		equal to 0, the I/O will start on that cycle.
441*53ee8cc1Swenshuai.xi  * @sync:	Determines the value to wait for for receive packets that have
442*53ee8cc1Swenshuai.xi  *		the %FW_CDEV_ISO_SYNC bit set
443*53ee8cc1Swenshuai.xi  * @tags:	Tag filter bit mask.  Only valid for isochronous reception.
444*53ee8cc1Swenshuai.xi  *		Determines the tag values for which packets will be accepted.
445*53ee8cc1Swenshuai.xi  *		Use FW_CDEV_ISO_CONTEXT_MATCH_ macros to set @tags.
446*53ee8cc1Swenshuai.xi  * @handle:	Isochronous context handle within which to transmit or receive
447*53ee8cc1Swenshuai.xi  */
448*53ee8cc1Swenshuai.xi struct fw_cdev_start_iso {
449*53ee8cc1Swenshuai.xi 	__s32 cycle;
450*53ee8cc1Swenshuai.xi 	__u32 sync;
451*53ee8cc1Swenshuai.xi 	__u32 tags;
452*53ee8cc1Swenshuai.xi 	__u32 handle;
453*53ee8cc1Swenshuai.xi };
454*53ee8cc1Swenshuai.xi 
455*53ee8cc1Swenshuai.xi /**
456*53ee8cc1Swenshuai.xi  * struct fw_cdev_stop_iso - Stop an isochronous transmission or reception
457*53ee8cc1Swenshuai.xi  * @handle:	Handle of isochronous context to stop
458*53ee8cc1Swenshuai.xi  */
459*53ee8cc1Swenshuai.xi struct fw_cdev_stop_iso {
460*53ee8cc1Swenshuai.xi 	__u32 handle;
461*53ee8cc1Swenshuai.xi };
462*53ee8cc1Swenshuai.xi 
463*53ee8cc1Swenshuai.xi /**
464*53ee8cc1Swenshuai.xi  * struct fw_cdev_get_cycle_timer - read cycle timer register
465*53ee8cc1Swenshuai.xi  * @local_time:   system time, in microseconds since the Epoch
466*53ee8cc1Swenshuai.xi  * @cycle_timer:  isochronous cycle timer, as per OHCI 1.1 clause 5.13
467*53ee8cc1Swenshuai.xi  *
468*53ee8cc1Swenshuai.xi  * The %FW_CDEV_IOC_GET_CYCLE_TIMER ioctl reads the isochronous cycle timer
469*53ee8cc1Swenshuai.xi  * and also the system clock.  This allows to express the receive time of an
470*53ee8cc1Swenshuai.xi  * isochronous packet as a system time with microsecond accuracy.
471*53ee8cc1Swenshuai.xi  */
472*53ee8cc1Swenshuai.xi struct fw_cdev_get_cycle_timer {
473*53ee8cc1Swenshuai.xi 	__u64 local_time;
474*53ee8cc1Swenshuai.xi 	__u32 cycle_timer;
475*53ee8cc1Swenshuai.xi };
476*53ee8cc1Swenshuai.xi 
477*53ee8cc1Swenshuai.xi #endif /* _LINUX_FIREWIRE_CDEV_H */
478