aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/firewire/fw-transaction.h
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/firewire/fw-transaction.h')
-rw-r--r--drivers/firewire/fw-transaction.h138
1 files changed, 51 insertions, 87 deletions
diff --git a/drivers/firewire/fw-transaction.h b/drivers/firewire/fw-transaction.h
index 1d78e9cc5940..dfa799068f89 100644
--- a/drivers/firewire/fw-transaction.h
+++ b/drivers/firewire/fw-transaction.h
@@ -82,14 +82,14 @@
82#define CSR_SPEED_MAP 0x2000 82#define CSR_SPEED_MAP 0x2000
83#define CSR_SPEED_MAP_END 0x3000 83#define CSR_SPEED_MAP_END 0x3000
84 84
85#define BANDWIDTH_AVAILABLE_INITIAL 4915
85#define BROADCAST_CHANNEL_INITIAL (1 << 31 | 31) 86#define BROADCAST_CHANNEL_INITIAL (1 << 31 | 31)
86#define BROADCAST_CHANNEL_VALID (1 << 30) 87#define BROADCAST_CHANNEL_VALID (1 << 30)
87 88
88#define fw_notify(s, args...) printk(KERN_NOTICE KBUILD_MODNAME ": " s, ## args) 89#define fw_notify(s, args...) printk(KERN_NOTICE KBUILD_MODNAME ": " s, ## args)
89#define fw_error(s, args...) printk(KERN_ERR KBUILD_MODNAME ": " s, ## args) 90#define fw_error(s, args...) printk(KERN_ERR KBUILD_MODNAME ": " s, ## args)
90 91
91static inline void 92static inline void fw_memcpy_from_be32(void *_dst, void *_src, size_t size)
92fw_memcpy_from_be32(void *_dst, void *_src, size_t size)
93{ 93{
94 u32 *dst = _dst; 94 u32 *dst = _dst;
95 __be32 *src = _src; 95 __be32 *src = _src;
@@ -99,8 +99,7 @@ fw_memcpy_from_be32(void *_dst, void *_src, size_t size)
99 dst[i] = be32_to_cpu(src[i]); 99 dst[i] = be32_to_cpu(src[i]);
100} 100}
101 101
102static inline void 102static inline void fw_memcpy_to_be32(void *_dst, void *_src, size_t size)
103fw_memcpy_to_be32(void *_dst, void *_src, size_t size)
104{ 103{
105 fw_memcpy_from_be32(_dst, _src, size); 104 fw_memcpy_from_be32(_dst, _src, size);
106} 105}
@@ -125,8 +124,7 @@ typedef void (*fw_packet_callback_t)(struct fw_packet *packet,
125 struct fw_card *card, int status); 124 struct fw_card *card, int status);
126 125
127typedef void (*fw_transaction_callback_t)(struct fw_card *card, int rcode, 126typedef void (*fw_transaction_callback_t)(struct fw_card *card, int rcode,
128 void *data, 127 void *data, size_t length,
129 size_t length,
130 void *callback_data); 128 void *callback_data);
131 129
132/* 130/*
@@ -141,12 +139,6 @@ typedef void (*fw_address_callback_t)(struct fw_card *card,
141 void *data, size_t length, 139 void *data, size_t length,
142 void *callback_data); 140 void *callback_data);
143 141
144typedef void (*fw_bus_reset_callback_t)(struct fw_card *handle,
145 int node_id, int generation,
146 u32 *self_ids,
147 int self_id_count,
148 void *callback_data);
149
150struct fw_packet { 142struct fw_packet {
151 int speed; 143 int speed;
152 int generation; 144 int generation;
@@ -187,12 +179,6 @@ struct fw_transaction {
187 void *callback_data; 179 void *callback_data;
188}; 180};
189 181
190static inline struct fw_packet *
191fw_packet(struct list_head *l)
192{
193 return list_entry(l, struct fw_packet, link);
194}
195
196struct fw_address_handler { 182struct fw_address_handler {
197 u64 offset; 183 u64 offset;
198 size_t length; 184 size_t length;
@@ -201,7 +187,6 @@ struct fw_address_handler {
201 struct list_head link; 187 struct list_head link;
202}; 188};
203 189
204
205struct fw_address_region { 190struct fw_address_region {
206 u64 start; 191 u64 start;
207 u64 end; 192 u64 end;
@@ -255,6 +240,7 @@ struct fw_card {
255 int bm_retries; 240 int bm_retries;
256 int bm_generation; 241 int bm_generation;
257 242
243 bool broadcast_channel_allocated;
258 u32 broadcast_channel; 244 u32 broadcast_channel;
259 u32 topology_map[(CSR_TOPOLOGY_MAP_END - CSR_TOPOLOGY_MAP) / 4]; 245 u32 topology_map[(CSR_TOPOLOGY_MAP_END - CSR_TOPOLOGY_MAP) / 4];
260}; 246};
@@ -315,10 +301,8 @@ struct fw_iso_packet {
315struct fw_iso_context; 301struct fw_iso_context;
316 302
317typedef void (*fw_iso_callback_t)(struct fw_iso_context *context, 303typedef void (*fw_iso_callback_t)(struct fw_iso_context *context,
318 u32 cycle, 304 u32 cycle, size_t header_length,
319 size_t header_length, 305 void *header, void *data);
320 void *header,
321 void *data);
322 306
323/* 307/*
324 * An iso buffer is just a set of pages mapped for DMA in the 308 * An iso buffer is just a set of pages mapped for DMA in the
@@ -344,36 +328,25 @@ struct fw_iso_context {
344 void *callback_data; 328 void *callback_data;
345}; 329};
346 330
347int 331int fw_iso_buffer_init(struct fw_iso_buffer *buffer, struct fw_card *card,
348fw_iso_buffer_init(struct fw_iso_buffer *buffer, 332 int page_count, enum dma_data_direction direction);
349 struct fw_card *card, 333int fw_iso_buffer_map(struct fw_iso_buffer *buffer, struct vm_area_struct *vma);
350 int page_count, 334void fw_iso_buffer_destroy(struct fw_iso_buffer *buffer, struct fw_card *card);
351 enum dma_data_direction direction); 335
352int 336struct fw_iso_context *fw_iso_context_create(struct fw_card *card,
353fw_iso_buffer_map(struct fw_iso_buffer *buffer, struct vm_area_struct *vma); 337 int type, int channel, int speed, size_t header_size,
354void 338 fw_iso_callback_t callback, void *callback_data);
355fw_iso_buffer_destroy(struct fw_iso_buffer *buffer, struct fw_card *card); 339int fw_iso_context_queue(struct fw_iso_context *ctx,
356 340 struct fw_iso_packet *packet,
357struct fw_iso_context * 341 struct fw_iso_buffer *buffer,
358fw_iso_context_create(struct fw_card *card, int type, 342 unsigned long payload);
359 int channel, int speed, size_t header_size, 343int fw_iso_context_start(struct fw_iso_context *ctx,
360 fw_iso_callback_t callback, void *callback_data); 344 int cycle, int sync, int tags);
361 345int fw_iso_context_stop(struct fw_iso_context *ctx);
362void 346void fw_iso_context_destroy(struct fw_iso_context *ctx);
363fw_iso_context_destroy(struct fw_iso_context *ctx); 347
364 348void fw_iso_resource_manage(struct fw_card *card, int generation,
365int 349 u64 channels_mask, int *channel, int *bandwidth, bool allocate);
366fw_iso_context_queue(struct fw_iso_context *ctx,
367 struct fw_iso_packet *packet,
368 struct fw_iso_buffer *buffer,
369 unsigned long payload);
370
371int
372fw_iso_context_start(struct fw_iso_context *ctx,
373 int cycle, int sync, int tags);
374
375int
376fw_iso_context_stop(struct fw_iso_context *ctx);
377 350
378struct fw_card_driver { 351struct fw_card_driver {
379 /* 352 /*
@@ -415,7 +388,7 @@ struct fw_card_driver {
415 388
416 struct fw_iso_context * 389 struct fw_iso_context *
417 (*allocate_iso_context)(struct fw_card *card, 390 (*allocate_iso_context)(struct fw_card *card,
418 int type, size_t header_size); 391 int type, int channel, size_t header_size);
419 void (*free_iso_context)(struct fw_iso_context *ctx); 392 void (*free_iso_context)(struct fw_iso_context *ctx);
420 393
421 int (*start_iso)(struct fw_iso_context *ctx, 394 int (*start_iso)(struct fw_iso_context *ctx,
@@ -429,54 +402,45 @@ struct fw_card_driver {
429 int (*stop_iso)(struct fw_iso_context *ctx); 402 int (*stop_iso)(struct fw_iso_context *ctx);
430}; 403};
431 404
432int 405int fw_core_initiate_bus_reset(struct fw_card *card, int short_reset);
433fw_core_initiate_bus_reset(struct fw_card *card, int short_reset);
434 406
435void 407void fw_send_request(struct fw_card *card, struct fw_transaction *t,
436fw_send_request(struct fw_card *card, struct fw_transaction *t,
437 int tcode, int destination_id, int generation, int speed, 408 int tcode, int destination_id, int generation, int speed,
438 unsigned long long offset, void *data, size_t length, 409 unsigned long long offset, void *payload, size_t length,
439 fw_transaction_callback_t callback, void *callback_data); 410 fw_transaction_callback_t callback, void *callback_data);
440
441int fw_run_transaction(struct fw_card *card, int tcode, int destination_id,
442 int generation, int speed, unsigned long long offset,
443 void *data, size_t length);
444
445int fw_cancel_transaction(struct fw_card *card, 411int fw_cancel_transaction(struct fw_card *card,
446 struct fw_transaction *transaction); 412 struct fw_transaction *transaction);
447
448void fw_flush_transactions(struct fw_card *card); 413void fw_flush_transactions(struct fw_card *card);
449 414int fw_run_transaction(struct fw_card *card, int tcode, int destination_id,
415 int generation, int speed, unsigned long long offset,
416 void *payload, size_t length);
450void fw_send_phy_config(struct fw_card *card, 417void fw_send_phy_config(struct fw_card *card,
451 int node_id, int generation, int gap_count); 418 int node_id, int generation, int gap_count);
452 419
420static inline int fw_stream_packet_destination_id(int tag, int channel, int sy)
421{
422 return tag << 14 | channel << 8 | sy;
423}
424
453/* 425/*
454 * Called by the topology code to inform the device code of node 426 * Called by the topology code to inform the device code of node
455 * activity; found, lost, or updated nodes. 427 * activity; found, lost, or updated nodes.
456 */ 428 */
457void 429void fw_node_event(struct fw_card *card, struct fw_node *node, int event);
458fw_node_event(struct fw_card *card, struct fw_node *node, int event);
459 430
460/* API used by card level drivers */ 431/* API used by card level drivers */
461 432
462void 433void fw_card_initialize(struct fw_card *card,
463fw_card_initialize(struct fw_card *card, const struct fw_card_driver *driver, 434 const struct fw_card_driver *driver, struct device *device);
464 struct device *device); 435int fw_card_add(struct fw_card *card,
465int 436 u32 max_receive, u32 link_speed, u64 guid);
466fw_card_add(struct fw_card *card, 437void fw_core_remove_card(struct fw_card *card);
467 u32 max_receive, u32 link_speed, u64 guid); 438void fw_core_handle_bus_reset(struct fw_card *card, int node_id,
468 439 int generation, int self_id_count, u32 *self_ids);
469void 440void fw_core_handle_request(struct fw_card *card, struct fw_packet *request);
470fw_core_remove_card(struct fw_card *card); 441void fw_core_handle_response(struct fw_card *card, struct fw_packet *packet);
471 442
472void 443extern int fw_irm_set_broadcast_channel_register(struct device *dev,
473fw_core_handle_bus_reset(struct fw_card *card, 444 void *data);
474 int node_id, int generation,
475 int self_id_count, u32 *self_ids);
476void
477fw_core_handle_request(struct fw_card *card, struct fw_packet *request);
478
479void
480fw_core_handle_response(struct fw_card *card, struct fw_packet *packet);
481 445
482#endif /* __fw_transaction_h */ 446#endif /* __fw_transaction_h */