1 |
1275 |
phoenix |
|
2 |
|
|
#ifndef _IEEE1394_CORE_H
|
3 |
|
|
#define _IEEE1394_CORE_H
|
4 |
|
|
|
5 |
|
|
#include <linux/slab.h>
|
6 |
|
|
#include <linux/devfs_fs_kernel.h>
|
7 |
|
|
#include <linux/proc_fs.h>
|
8 |
|
|
#include <asm/semaphore.h>
|
9 |
|
|
#include "hosts.h"
|
10 |
|
|
|
11 |
|
|
|
12 |
|
|
struct hpsb_packet {
|
13 |
|
|
/* This struct is basically read-only for hosts with the exception of
|
14 |
|
|
* the data buffer contents and xnext - see below. */
|
15 |
|
|
struct list_head list;
|
16 |
|
|
|
17 |
|
|
/* This can be used for host driver internal linking. */
|
18 |
|
|
struct list_head driver_list;
|
19 |
|
|
|
20 |
|
|
nodeid_t node_id;
|
21 |
|
|
|
22 |
|
|
/* Async and Iso types should be clear, raw means send-as-is, do not
|
23 |
|
|
* CRC! Byte swapping shall still be done in this case. */
|
24 |
|
|
enum { hpsb_async, hpsb_iso, hpsb_raw } __attribute__((packed)) type;
|
25 |
|
|
|
26 |
|
|
/* Okay, this is core internal and a no care for hosts.
|
27 |
|
|
* queued = queued for sending
|
28 |
|
|
* pending = sent, waiting for response
|
29 |
|
|
* complete = processing completed, successful or not
|
30 |
|
|
* incoming = incoming packet
|
31 |
|
|
*/
|
32 |
|
|
enum {
|
33 |
|
|
hpsb_unused, hpsb_queued, hpsb_pending, hpsb_complete, hpsb_incoming
|
34 |
|
|
} __attribute__((packed)) state;
|
35 |
|
|
|
36 |
|
|
/* These are core internal. */
|
37 |
|
|
signed char tlabel;
|
38 |
|
|
char ack_code;
|
39 |
|
|
char tcode;
|
40 |
|
|
|
41 |
|
|
unsigned expect_response:1;
|
42 |
|
|
unsigned no_waiter:1;
|
43 |
|
|
|
44 |
|
|
/* Data big endianness flag - may vary from request to request. The
|
45 |
|
|
* header is always in machine byte order.
|
46 |
|
|
* Not really used currently. */
|
47 |
|
|
unsigned data_be:1;
|
48 |
|
|
|
49 |
|
|
/* Speed to transmit with: 0 = 100Mbps, 1 = 200Mbps, 2 = 400Mbps */
|
50 |
|
|
unsigned speed_code:2;
|
51 |
|
|
|
52 |
|
|
/*
|
53 |
|
|
* *header and *data are guaranteed to be 32-bit DMAable and may be
|
54 |
|
|
* overwritten to allow in-place byte swapping. Neither of these is
|
55 |
|
|
* CRCed (the sizes also don't include CRC), but contain space for at
|
56 |
|
|
* least one additional quadlet to allow in-place CRCing. The memory is
|
57 |
|
|
* also guaranteed to be DMA mappable.
|
58 |
|
|
*/
|
59 |
|
|
quadlet_t *header;
|
60 |
|
|
quadlet_t *data;
|
61 |
|
|
size_t header_size;
|
62 |
|
|
size_t data_size;
|
63 |
|
|
|
64 |
|
|
|
65 |
|
|
struct hpsb_host *host;
|
66 |
|
|
unsigned int generation;
|
67 |
|
|
|
68 |
|
|
/* Very core internal, don't care. */
|
69 |
|
|
struct semaphore state_change;
|
70 |
|
|
|
71 |
|
|
/* Function (and possible data to pass to it) to call when this
|
72 |
|
|
* packet is completed. */
|
73 |
|
|
void (*complete_routine)(void *);
|
74 |
|
|
void *complete_data;
|
75 |
|
|
|
76 |
|
|
/* Store jiffies for implementing bus timeouts. */
|
77 |
|
|
unsigned long sendtime;
|
78 |
|
|
|
79 |
|
|
quadlet_t embedded_header[5];
|
80 |
|
|
};
|
81 |
|
|
|
82 |
|
|
/* Set a task for when a packet completes */
|
83 |
|
|
void hpsb_set_packet_complete_task(struct hpsb_packet *packet,
|
84 |
|
|
void (*routine)(void *), void *data);
|
85 |
|
|
|
86 |
|
|
static inline struct hpsb_packet *driver_packet(struct list_head *l)
|
87 |
|
|
{
|
88 |
|
|
return list_entry(l, struct hpsb_packet, driver_list);
|
89 |
|
|
}
|
90 |
|
|
|
91 |
|
|
void abort_timedouts(unsigned long __opaque);
|
92 |
|
|
void abort_requests(struct hpsb_host *host);
|
93 |
|
|
|
94 |
|
|
struct hpsb_packet *alloc_hpsb_packet(size_t data_size);
|
95 |
|
|
void free_hpsb_packet(struct hpsb_packet *packet);
|
96 |
|
|
|
97 |
|
|
|
98 |
|
|
/*
|
99 |
|
|
* Generation counter for the complete 1394 subsystem. Generation gets
|
100 |
|
|
* incremented on every change in the subsystem (e.g. bus reset).
|
101 |
|
|
*
|
102 |
|
|
* Use the functions, not the variable.
|
103 |
|
|
*/
|
104 |
|
|
#include <asm/atomic.h>
|
105 |
|
|
|
106 |
|
|
static inline unsigned int get_hpsb_generation(struct hpsb_host *host)
|
107 |
|
|
{
|
108 |
|
|
return atomic_read(&host->generation);
|
109 |
|
|
}
|
110 |
|
|
|
111 |
|
|
/*
|
112 |
|
|
* Send a PHY configuration packet.
|
113 |
|
|
*/
|
114 |
|
|
int hpsb_send_phy_config(struct hpsb_host *host, int rootid, int gapcnt);
|
115 |
|
|
|
116 |
|
|
/*
|
117 |
|
|
* Queue packet for transmitting, return 0 for failure.
|
118 |
|
|
*/
|
119 |
|
|
int hpsb_send_packet(struct hpsb_packet *packet);
|
120 |
|
|
|
121 |
|
|
/* Initiate bus reset on the given host. Returns 1 if bus reset already in
|
122 |
|
|
* progress, 0 otherwise. */
|
123 |
|
|
int hpsb_reset_bus(struct hpsb_host *host, int type);
|
124 |
|
|
|
125 |
|
|
/*
|
126 |
|
|
* The following functions are exported for host driver module usage. All of
|
127 |
|
|
* them are safe to use in interrupt contexts, although some are quite
|
128 |
|
|
* complicated so you may want to run them in bottom halves instead of calling
|
129 |
|
|
* them directly.
|
130 |
|
|
*/
|
131 |
|
|
|
132 |
|
|
/* Notify a bus reset to the core. Returns 1 if bus reset already in progress,
|
133 |
|
|
* 0 otherwise. */
|
134 |
|
|
int hpsb_bus_reset(struct hpsb_host *host);
|
135 |
|
|
|
136 |
|
|
/*
|
137 |
|
|
* Hand over received selfid packet to the core. Complement check (second
|
138 |
|
|
* quadlet is complement of first) is expected to be done and succesful.
|
139 |
|
|
*/
|
140 |
|
|
void hpsb_selfid_received(struct hpsb_host *host, quadlet_t sid);
|
141 |
|
|
|
142 |
|
|
/*
|
143 |
|
|
* Notify completion of SelfID stage to the core and report new physical ID
|
144 |
|
|
* and whether host is root now.
|
145 |
|
|
*/
|
146 |
|
|
void hpsb_selfid_complete(struct hpsb_host *host, int phyid, int isroot);
|
147 |
|
|
|
148 |
|
|
/*
|
149 |
|
|
* Notify core of sending a packet. Ackcode is the ack code returned for async
|
150 |
|
|
* transmits or ACKX_SEND_ERROR if the transmission failed completely; ACKX_NONE
|
151 |
|
|
* for other cases (internal errors that don't justify a panic). Safe to call
|
152 |
|
|
* from within a transmit packet routine.
|
153 |
|
|
*/
|
154 |
|
|
void hpsb_packet_sent(struct hpsb_host *host, struct hpsb_packet *packet,
|
155 |
|
|
int ackcode);
|
156 |
|
|
|
157 |
|
|
/*
|
158 |
|
|
* Hand over received packet to the core. The contents of data are expected to
|
159 |
|
|
* be the full packet but with the CRCs left out (data block follows header
|
160 |
|
|
* immediately), with the header (i.e. the first four quadlets) in machine byte
|
161 |
|
|
* order and the data block in big endian. *data can be safely overwritten
|
162 |
|
|
* after this call.
|
163 |
|
|
*
|
164 |
|
|
* If the packet is a write request, write_acked is to be set to true if it was
|
165 |
|
|
* ack_complete'd already, false otherwise. This arg is ignored for any other
|
166 |
|
|
* packet type.
|
167 |
|
|
*/
|
168 |
|
|
void hpsb_packet_received(struct hpsb_host *host, quadlet_t *data, size_t size,
|
169 |
|
|
int write_acked);
|
170 |
|
|
|
171 |
|
|
|
172 |
|
|
/*
|
173 |
|
|
* CHARACTER DEVICE DISPATCHING
|
174 |
|
|
*
|
175 |
|
|
* All ieee1394 character device drivers share the same major number
|
176 |
|
|
* (major 171). The 256 minor numbers are allocated to the various
|
177 |
|
|
* task-specific interfaces (raw1394, video1394, dv1394, etc) in
|
178 |
|
|
* blocks of 16.
|
179 |
|
|
*
|
180 |
|
|
* The core ieee1394.o modules handles the initial open() for all
|
181 |
|
|
* character devices on major 171; it then dispatches to the
|
182 |
|
|
* appropriate task-specific driver.
|
183 |
|
|
*
|
184 |
|
|
* Minor device number block allocations:
|
185 |
|
|
*
|
186 |
|
|
* Block 0 ( 0- 15) raw1394
|
187 |
|
|
* Block 1 ( 16- 31) video1394
|
188 |
|
|
* Block 2 ( 32- 47) dv1394
|
189 |
|
|
*
|
190 |
|
|
* Blocks 3-14 free for future allocation
|
191 |
|
|
*
|
192 |
|
|
* Block 15 (240-255) reserved for drivers under development, etc.
|
193 |
|
|
*/
|
194 |
|
|
|
195 |
|
|
#define IEEE1394_MAJOR 171
|
196 |
|
|
|
197 |
|
|
#define IEEE1394_MINOR_BLOCK_RAW1394 0
|
198 |
|
|
#define IEEE1394_MINOR_BLOCK_VIDEO1394 1
|
199 |
|
|
#define IEEE1394_MINOR_BLOCK_DV1394 2
|
200 |
|
|
#define IEEE1394_MINOR_BLOCK_AMDTP 3
|
201 |
|
|
#define IEEE1394_MINOR_BLOCK_EXPERIMENTAL 15
|
202 |
|
|
|
203 |
|
|
/* return the index (within a minor number block) of a file */
|
204 |
|
|
static inline unsigned char ieee1394_file_to_instance(struct file *file)
|
205 |
|
|
{
|
206 |
|
|
unsigned char minor = MINOR(file->f_dentry->d_inode->i_rdev);
|
207 |
|
|
|
208 |
|
|
/* return lower 4 bits */
|
209 |
|
|
return minor & 0xF;
|
210 |
|
|
}
|
211 |
|
|
|
212 |
|
|
/*
|
213 |
|
|
* Task-specific drivers should call ieee1394_register_chardev() to
|
214 |
|
|
* request a block of 16 minor numbers.
|
215 |
|
|
*
|
216 |
|
|
* Returns 0 if the request was successful, -EBUSY if the block was
|
217 |
|
|
* already taken.
|
218 |
|
|
*/
|
219 |
|
|
|
220 |
|
|
int ieee1394_register_chardev(int blocknum, /* 0-15 */
|
221 |
|
|
struct module *module, /* THIS_MODULE */
|
222 |
|
|
struct file_operations *file_ops);
|
223 |
|
|
|
224 |
|
|
/* release a block of minor numbers */
|
225 |
|
|
void ieee1394_unregister_chardev(int blocknum);
|
226 |
|
|
|
227 |
|
|
/* the devfs handle for /dev/ieee1394; NULL if devfs is not in use */
|
228 |
|
|
extern devfs_handle_t ieee1394_devfs_handle;
|
229 |
|
|
|
230 |
|
|
/* the proc_fs entry for /proc/ieee1394 */
|
231 |
|
|
extern struct proc_dir_entry *ieee1394_procfs_entry;
|
232 |
|
|
|
233 |
|
|
#endif /* _IEEE1394_CORE_H */
|