firewire.h revision bf54e1462b9192fdef7ea9e2bc44fdc16a4b87bc
177c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter#ifndef _LINUX_FIREWIRE_H
277c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter#define _LINUX_FIREWIRE_H
377c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter
477c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter#include <linux/completion.h>
577c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter#include <linux/device.h>
6c76acec6d55107b652a37c90b36c00bc8b04dabbJay Fenlason#include <linux/dma-mapping.h>
777c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter#include <linux/kernel.h>
877c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter#include <linux/kref.h>
977c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter#include <linux/list.h>
1077c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter#include <linux/mutex.h>
1177c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter#include <linux/spinlock.h>
1277c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter#include <linux/sysfs.h>
1377c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter#include <linux/timer.h>
1477c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter#include <linux/types.h>
1577c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter#include <linux/workqueue.h>
1677c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter
1777c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter#include <asm/atomic.h>
1877c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter#include <asm/byteorder.h>
1977c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter
2077c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter#define fw_notify(s, args...) printk(KERN_NOTICE KBUILD_MODNAME ": " s, ## args)
2177c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter#define fw_error(s, args...) printk(KERN_ERR KBUILD_MODNAME ": " s, ## args)
2277c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter
2377c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter#define CSR_REGISTER_BASE		0xfffff0000000ULL
2477c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter
2577c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter/* register offsets are relative to CSR_REGISTER_BASE */
2677c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter#define CSR_STATE_CLEAR			0x0
2777c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter#define CSR_STATE_SET			0x4
2877c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter#define CSR_NODE_IDS			0x8
2977c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter#define CSR_RESET_START			0xc
3077c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter#define CSR_SPLIT_TIMEOUT_HI		0x18
3177c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter#define CSR_SPLIT_TIMEOUT_LO		0x1c
3277c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter#define CSR_CYCLE_TIME			0x200
3377c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter#define CSR_BUS_TIME			0x204
3477c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter#define CSR_BUSY_TIMEOUT		0x210
35a1a1132bd83d0aea51d4f19be4b4a58a064a0131Clemens Ladisch#define CSR_PRIORITY_BUDGET		0x218
3677c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter#define CSR_BUS_MANAGER_ID		0x21c
3777c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter#define CSR_BANDWIDTH_AVAILABLE		0x220
3877c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter#define CSR_CHANNELS_AVAILABLE		0x224
3977c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter#define CSR_CHANNELS_AVAILABLE_HI	0x224
4077c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter#define CSR_CHANNELS_AVAILABLE_LO	0x228
413d1f46eb60b155c705e389ecdf313f11b4b91976Clemens Ladisch#define CSR_MAINT_UTILITY		0x230
4277c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter#define CSR_BROADCAST_CHANNEL		0x234
4377c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter#define CSR_CONFIG_ROM			0x400
4477c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter#define CSR_CONFIG_ROM_END		0x800
4577c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter#define CSR_FCP_COMMAND			0xB00
4677c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter#define CSR_FCP_RESPONSE		0xD00
4777c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter#define CSR_FCP_END			0xF00
4877c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter#define CSR_TOPOLOGY_MAP		0x1000
4977c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter#define CSR_TOPOLOGY_MAP_END		0x1400
5077c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter#define CSR_SPEED_MAP			0x2000
5177c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter#define CSR_SPEED_MAP_END		0x3000
5277c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter
5377c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter#define CSR_OFFSET		0x40
5477c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter#define CSR_LEAF		0x80
5577c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter#define CSR_DIRECTORY		0xc0
5677c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter
5777c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter#define CSR_DESCRIPTOR		0x01
5877c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter#define CSR_VENDOR		0x03
5977c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter#define CSR_HARDWARE_VERSION	0x04
6077c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter#define CSR_UNIT		0x11
6177c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter#define CSR_SPECIFIER_ID	0x12
6277c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter#define CSR_VERSION		0x13
6377c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter#define CSR_DEPENDENT_INFO	0x14
6477c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter#define CSR_MODEL		0x17
6577c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter#define CSR_DIRECTORY_ID	0x20
6677c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter
6777c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richterstruct fw_csr_iterator {
6813b302d0a217580c0129b0641b0ca8b592e437b0Stefan Richter	const u32 *p;
6913b302d0a217580c0129b0641b0ca8b592e437b0Stefan Richter	const u32 *end;
7077c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter};
7177c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter
7213b302d0a217580c0129b0641b0ca8b592e437b0Stefan Richtervoid fw_csr_iterator_init(struct fw_csr_iterator *ci, const u32 *p);
7377c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richterint fw_csr_iterator_next(struct fw_csr_iterator *ci, int *key, int *value);
7413b302d0a217580c0129b0641b0ca8b592e437b0Stefan Richterint fw_csr_string(const u32 *directory, int key, char *buf, size_t size);
751f8fef7b3388b5a976e80839679b5bae581a1091Clemens Ladisch
7677c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richterextern struct bus_type fw_bus_type;
7777c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter
7877c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richterstruct fw_card_driver;
7977c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richterstruct fw_node;
8077c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter
8177c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richterstruct fw_card {
8277c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter	const struct fw_card_driver *driver;
8377c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter	struct device *device;
8477c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter	struct kref kref;
8577c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter	struct completion done;
8677c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter
8777c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter	int node_id;
8877c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter	int generation;
891e626fdcef61460dc75fe7377f38bb019722b848Stefan Richter	int current_tlabel;
901e626fdcef61460dc75fe7377f38bb019722b848Stefan Richter	u64 tlabel_mask;
9177c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter	struct list_head transaction_list;
9277c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter	unsigned long reset_jiffies;
9377c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter
948e4b50f94e8c1435a3e0ece42b7f97bc857d0145Clemens Ladisch	u32 split_timeout_hi;
958e4b50f94e8c1435a3e0ece42b7f97bc857d0145Clemens Ladisch	u32 split_timeout_lo;
968e4b50f94e8c1435a3e0ece42b7f97bc857d0145Clemens Ladisch	unsigned int split_timeout_cycles;
978e4b50f94e8c1435a3e0ece42b7f97bc857d0145Clemens Ladisch	unsigned int split_timeout_jiffies;
988e4b50f94e8c1435a3e0ece42b7f97bc857d0145Clemens Ladisch
9977c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter	unsigned long long guid;
10077c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter	unsigned max_receive;
10177c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter	int link_speed;
10277c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter	int config_rom_generation;
10377c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter
10477c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter	spinlock_t lock; /* Take this lock when handling the lists in
10577c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter			  * this struct. */
10677c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter	struct fw_node *local_node;
10777c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter	struct fw_node *root_node;
10877c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter	struct fw_node *irm_node;
10977c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter	u8 color; /* must be u8 to match the definition in struct fw_node */
11077c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter	int gap_count;
11177c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter	bool beta_repeaters_present;
11277c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter
11377c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter	int index;
11477c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter	struct list_head link;
11577c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter
116bf54e1462b9192fdef7ea9e2bc44fdc16a4b87bcStefan Richter	struct list_head phy_receiver_list;
117bf54e1462b9192fdef7ea9e2bc44fdc16a4b87bcStefan Richter
11802d37bed188c500ee7afb0a2dc6b65a80704c58eStefan Richter	struct delayed_work br_work; /* bus reset job */
11902d37bed188c500ee7afb0a2dc6b65a80704c58eStefan Richter	bool br_short;
12002d37bed188c500ee7afb0a2dc6b65a80704c58eStefan Richter
12102d37bed188c500ee7afb0a2dc6b65a80704c58eStefan Richter	struct delayed_work bm_work; /* bus manager job */
12277c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter	int bm_retries;
12377c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter	int bm_generation;
1246fdc03709433ccc2005f0f593ae9d9dd04f7b485Stefan Richter	__be32 bm_transaction_data[2];
125250b2b6dd421c9f8844a867d2ac06e0661e0ad93Stefan Richter	int bm_node_id;
126c8a94ded57e9cc2498d401b2f5c856213a3e19fbStefan Richter	bool bm_abdicate;
12777c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter
128db3c9cc105ee844f6cd7a1beb9926fb8e9a093aeStefan Richter	bool priority_budget_implemented;	/* controller feature */
129db3c9cc105ee844f6cd7a1beb9926fb8e9a093aeStefan Richter	bool broadcast_channel_auto_allocated;	/* controller feature */
130db3c9cc105ee844f6cd7a1beb9926fb8e9a093aeStefan Richter
13177c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter	bool broadcast_channel_allocated;
13277c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter	u32 broadcast_channel;
133cb7c96da3651111efbe088fa12f9bed61836ea93Stefan Richter	__be32 topology_map[(CSR_TOPOLOGY_MAP_END - CSR_TOPOLOGY_MAP) / 4];
1343d1f46eb60b155c705e389ecdf313f11b4b91976Clemens Ladisch
1353d1f46eb60b155c705e389ecdf313f11b4b91976Clemens Ladisch	__be32 maint_utility_register;
13677c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter};
13777c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter
13877c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richterstruct fw_attribute_group {
13977c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter	struct attribute_group *groups[2];
14077c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter	struct attribute_group group;
14177c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter	struct attribute *attrs[12];
14277c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter};
14377c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter
14477c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richterenum fw_device_state {
14577c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter	FW_DEVICE_INITIALIZING,
14677c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter	FW_DEVICE_RUNNING,
14777c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter	FW_DEVICE_GONE,
14877c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter	FW_DEVICE_SHUTDOWN,
14977c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter};
15077c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter
15177c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter/*
15277c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter * Note, fw_device.generation always has to be read before fw_device.node_id.
15377c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter * Use SMP memory barriers to ensure this.  Otherwise requests will be sent
15477c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter * to an outdated node_id if the generation was updated in the meantime due
15577c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter * to a bus reset.
15677c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter *
15777c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter * Likewise, fw-core will take care to update .node_id before .generation so
15877c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter * that whenever fw_device.generation is current WRT the actual bus generation,
15977c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter * fw_device.node_id is guaranteed to be current too.
16077c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter *
16177c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter * The same applies to fw_device.card->node_id vs. fw_device.generation.
16277c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter *
16377c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter * fw_device.config_rom and fw_device.config_rom_length may be accessed during
16477c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter * the lifetime of any fw_unit belonging to the fw_device, before device_del()
16577c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter * was called on the last fw_unit.  Alternatively, they may be accessed while
16677c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter * holding fw_device_rwsem.
16777c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter */
16877c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richterstruct fw_device {
16977c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter	atomic_t state;
17077c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter	struct fw_node *node;
17177c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter	int node_id;
17277c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter	int generation;
17377c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter	unsigned max_speed;
17477c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter	struct fw_card *card;
17577c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter	struct device device;
17677c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter
17777c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter	struct mutex client_list_mutex;
17877c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter	struct list_head client_list;
17977c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter
18013b302d0a217580c0129b0641b0ca8b592e437b0Stefan Richter	const u32 *config_rom;
18177c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter	size_t config_rom_length;
18277c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter	int config_rom_retries;
18377c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter	unsigned is_local:1;
184837ec787d85fda8d73193a399ebcea0288e4765bStefan Richter	unsigned max_rec:4;
18577c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter	unsigned cmc:1;
186837ec787d85fda8d73193a399ebcea0288e4765bStefan Richter	unsigned irmc:1;
18777c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter	unsigned bc_implemented:2;
18877c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter
18977c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter	struct delayed_work work;
19077c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter	struct fw_attribute_group attribute_group;
19177c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter};
19277c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter
19377c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richterstatic inline struct fw_device *fw_device(struct device *dev)
19477c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter{
19577c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter	return container_of(dev, struct fw_device, device);
19677c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter}
19777c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter
19877c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richterstatic inline int fw_device_is_shutdown(struct fw_device *device)
19977c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter{
20077c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter	return atomic_read(&device->state) == FW_DEVICE_SHUTDOWN;
20177c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter}
20277c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter
20377c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richterstatic inline struct fw_device *fw_device_get(struct fw_device *device)
20477c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter{
20577c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter	get_device(&device->device);
20677c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter
20777c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter	return device;
20877c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter}
20977c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter
21077c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richterstatic inline void fw_device_put(struct fw_device *device)
21177c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter{
21277c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter	put_device(&device->device);
21377c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter}
21477c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter
21577c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richterint fw_device_enable_phys_dma(struct fw_device *device);
21677c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter
21777c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter/*
21877c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter * fw_unit.directory must not be accessed after device_del(&fw_unit.device).
21977c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter */
22077c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richterstruct fw_unit {
22177c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter	struct device device;
22213b302d0a217580c0129b0641b0ca8b592e437b0Stefan Richter	const u32 *directory;
22377c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter	struct fw_attribute_group attribute_group;
22477c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter};
22577c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter
22677c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richterstatic inline struct fw_unit *fw_unit(struct device *dev)
22777c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter{
22877c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter	return container_of(dev, struct fw_unit, device);
22977c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter}
23077c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter
23177c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richterstatic inline struct fw_unit *fw_unit_get(struct fw_unit *unit)
23277c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter{
23377c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter	get_device(&unit->device);
23477c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter
23577c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter	return unit;
23677c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter}
23777c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter
23877c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richterstatic inline void fw_unit_put(struct fw_unit *unit)
23977c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter{
24077c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter	put_device(&unit->device);
24177c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter}
24277c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter
243e5110d011e03030926872457f05e49e3d5031737Stefan Richterstatic inline struct fw_device *fw_parent_device(struct fw_unit *unit)
244e5110d011e03030926872457f05e49e3d5031737Stefan Richter{
245e5110d011e03030926872457f05e49e3d5031737Stefan Richter	return fw_device(unit->device.parent);
246e5110d011e03030926872457f05e49e3d5031737Stefan Richter}
247e5110d011e03030926872457f05e49e3d5031737Stefan Richter
24877c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richterstruct ieee1394_device_id;
24977c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter
25077c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richterstruct fw_driver {
25177c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter	struct device_driver driver;
25277c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter	/* Called when the parent device sits through a bus reset. */
25377c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter	void (*update)(struct fw_unit *unit);
25477c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter	const struct ieee1394_device_id *id_table;
25577c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter};
25677c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter
25777c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richterstruct fw_packet;
25877c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richterstruct fw_request;
25977c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter
26077c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richtertypedef void (*fw_packet_callback_t)(struct fw_packet *packet,
26177c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter				     struct fw_card *card, int status);
26277c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richtertypedef void (*fw_transaction_callback_t)(struct fw_card *card, int rcode,
26377c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter					  void *data, size_t length,
26477c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter					  void *callback_data);
26577c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter/*
266db5d247ae811f49185a71e703b65acad845e4b18Clemens Ladisch * Important note:  Except for the FCP registers, the callback must guarantee
267db5d247ae811f49185a71e703b65acad845e4b18Clemens Ladisch * that either fw_send_response() or kfree() is called on the @request.
26877c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter */
26977c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richtertypedef void (*fw_address_callback_t)(struct fw_card *card,
27077c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter				      struct fw_request *request,
27177c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter				      int tcode, int destination, int source,
27233e553fe2b4a983ef34a57ab1440d8d33397bb12Stefan Richter				      int generation,
27377c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter				      unsigned long long offset,
27477c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter				      void *data, size_t length,
27577c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter				      void *callback_data);
27677c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter
27777c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richterstruct fw_packet {
27877c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter	int speed;
27977c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter	int generation;
28077c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter	u32 header[4];
28177c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter	size_t header_length;
28277c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter	void *payload;
28377c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter	size_t payload_length;
28477c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter	dma_addr_t payload_bus;
28519593ffdb6daa6ba691d247a2400cece12687c52Stefan Richter	bool payload_mapped;
28677c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter	u32 timestamp;
28777c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter
28877c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter	/*
28918d0cdfd1a4cc9028c0ef80f94538b31541f8fe5Stefan Richter	 * This callback is called when the packet transmission has completed.
29018d0cdfd1a4cc9028c0ef80f94538b31541f8fe5Stefan Richter	 * For successful transmission, the status code is the ack received
29118d0cdfd1a4cc9028c0ef80f94538b31541f8fe5Stefan Richter	 * from the destination.  Otherwise it is one of the juju-specific
29218d0cdfd1a4cc9028c0ef80f94538b31541f8fe5Stefan Richter	 * rcodes:  RCODE_SEND_ERROR, _CANCELLED, _BUSY, _GENERATION, _NO_ACK.
29377c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter	 * The callback can be called from tasklet context and thus
29477c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter	 * must never block.
29577c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter	 */
29677c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter	fw_packet_callback_t callback;
29777c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter	int ack;
29877c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter	struct list_head link;
29977c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter	void *driver_data;
30077c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter};
30177c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter
30277c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richterstruct fw_transaction {
30377c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter	int node_id; /* The generation is implied; it is always the current. */
30477c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter	int tlabel;
30577c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter	int timestamp;
30677c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter	struct list_head link;
3075c40cbfefa828208c671e2f58789e4dd04f79563Clemens Ladisch	struct fw_card *card;
3085c40cbfefa828208c671e2f58789e4dd04f79563Clemens Ladisch	struct timer_list split_timeout_timer;
30977c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter
31077c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter	struct fw_packet packet;
31177c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter
31277c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter	/*
31377c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter	 * The data passed to the callback is valid only during the
31477c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter	 * callback.
31577c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter	 */
31677c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter	fw_transaction_callback_t callback;
31777c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter	void *callback_data;
31877c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter};
31977c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter
32077c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richterstruct fw_address_handler {
32177c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter	u64 offset;
32277c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter	size_t length;
32377c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter	fw_address_callback_t address_callback;
32477c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter	void *callback_data;
32577c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter	struct list_head link;
32677c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter};
32777c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter
32877c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richterstruct fw_address_region {
32977c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter	u64 start;
33077c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter	u64 end;
33177c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter};
33277c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter
33377c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richterextern const struct fw_address_region fw_high_memory_region;
33477c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter
33577c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richterint fw_core_add_address_handler(struct fw_address_handler *handler,
33677c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter				const struct fw_address_region *region);
33777c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richtervoid fw_core_remove_address_handler(struct fw_address_handler *handler);
33877c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richtervoid fw_send_response(struct fw_card *card,
33977c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter		      struct fw_request *request, int rcode);
34077c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richtervoid fw_send_request(struct fw_card *card, struct fw_transaction *t,
34177c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter		     int tcode, int destination_id, int generation, int speed,
34277c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter		     unsigned long long offset, void *payload, size_t length,
34377c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter		     fw_transaction_callback_t callback, void *callback_data);
34477c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richterint fw_cancel_transaction(struct fw_card *card,
34577c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter			  struct fw_transaction *transaction);
34677c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richterint fw_run_transaction(struct fw_card *card, int tcode, int destination_id,
34777c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter		       int generation, int speed, unsigned long long offset,
34877c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter		       void *payload, size_t length);
34977c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter
350c76acec6d55107b652a37c90b36c00bc8b04dabbJay Fenlasonstatic inline int fw_stream_packet_destination_id(int tag, int channel, int sy)
351c76acec6d55107b652a37c90b36c00bc8b04dabbJay Fenlason{
352c76acec6d55107b652a37c90b36c00bc8b04dabbJay Fenlason	return tag << 14 | channel << 8 | sy;
353c76acec6d55107b652a37c90b36c00bc8b04dabbJay Fenlason}
354c76acec6d55107b652a37c90b36c00bc8b04dabbJay Fenlason
355c76acec6d55107b652a37c90b36c00bc8b04dabbJay Fenlasonstruct fw_descriptor {
356c76acec6d55107b652a37c90b36c00bc8b04dabbJay Fenlason	struct list_head link;
357c76acec6d55107b652a37c90b36c00bc8b04dabbJay Fenlason	size_t length;
358c76acec6d55107b652a37c90b36c00bc8b04dabbJay Fenlason	u32 immediate;
359c76acec6d55107b652a37c90b36c00bc8b04dabbJay Fenlason	u32 key;
360c76acec6d55107b652a37c90b36c00bc8b04dabbJay Fenlason	const u32 *data;
361c76acec6d55107b652a37c90b36c00bc8b04dabbJay Fenlason};
362c76acec6d55107b652a37c90b36c00bc8b04dabbJay Fenlason
363c76acec6d55107b652a37c90b36c00bc8b04dabbJay Fenlasonint fw_core_add_descriptor(struct fw_descriptor *desc);
364c76acec6d55107b652a37c90b36c00bc8b04dabbJay Fenlasonvoid fw_core_remove_descriptor(struct fw_descriptor *desc);
365c76acec6d55107b652a37c90b36c00bc8b04dabbJay Fenlason
366c76acec6d55107b652a37c90b36c00bc8b04dabbJay Fenlason/*
367c76acec6d55107b652a37c90b36c00bc8b04dabbJay Fenlason * The iso packet format allows for an immediate header/payload part
368c76acec6d55107b652a37c90b36c00bc8b04dabbJay Fenlason * stored in 'header' immediately after the packet info plus an
369c76acec6d55107b652a37c90b36c00bc8b04dabbJay Fenlason * indirect payload part that is pointer to by the 'payload' field.
370c76acec6d55107b652a37c90b36c00bc8b04dabbJay Fenlason * Applications can use one or the other or both to implement simple
371c76acec6d55107b652a37c90b36c00bc8b04dabbJay Fenlason * low-bandwidth streaming (e.g. audio) or more advanced
372c76acec6d55107b652a37c90b36c00bc8b04dabbJay Fenlason * scatter-gather streaming (e.g. assembling video frame automatically).
373c76acec6d55107b652a37c90b36c00bc8b04dabbJay Fenlason */
374c76acec6d55107b652a37c90b36c00bc8b04dabbJay Fenlasonstruct fw_iso_packet {
375c76acec6d55107b652a37c90b36c00bc8b04dabbJay Fenlason	u16 payload_length;	/* Length of indirect payload. */
376c76acec6d55107b652a37c90b36c00bc8b04dabbJay Fenlason	u32 interrupt:1;	/* Generate interrupt on this packet */
377c76acec6d55107b652a37c90b36c00bc8b04dabbJay Fenlason	u32 skip:1;		/* Set to not send packet at all. */
378c76acec6d55107b652a37c90b36c00bc8b04dabbJay Fenlason	u32 tag:2;
379c76acec6d55107b652a37c90b36c00bc8b04dabbJay Fenlason	u32 sy:4;
380c76acec6d55107b652a37c90b36c00bc8b04dabbJay Fenlason	u32 header_length:8;	/* Length of immediate header. */
381c76acec6d55107b652a37c90b36c00bc8b04dabbJay Fenlason	u32 header[0];
382c76acec6d55107b652a37c90b36c00bc8b04dabbJay Fenlason};
383c76acec6d55107b652a37c90b36c00bc8b04dabbJay Fenlason
384c76acec6d55107b652a37c90b36c00bc8b04dabbJay Fenlason#define FW_ISO_CONTEXT_TRANSMIT	0
385c76acec6d55107b652a37c90b36c00bc8b04dabbJay Fenlason#define FW_ISO_CONTEXT_RECEIVE	1
386c76acec6d55107b652a37c90b36c00bc8b04dabbJay Fenlason
387c76acec6d55107b652a37c90b36c00bc8b04dabbJay Fenlason#define FW_ISO_CONTEXT_MATCH_TAG0	 1
388c76acec6d55107b652a37c90b36c00bc8b04dabbJay Fenlason#define FW_ISO_CONTEXT_MATCH_TAG1	 2
389c76acec6d55107b652a37c90b36c00bc8b04dabbJay Fenlason#define FW_ISO_CONTEXT_MATCH_TAG2	 4
390c76acec6d55107b652a37c90b36c00bc8b04dabbJay Fenlason#define FW_ISO_CONTEXT_MATCH_TAG3	 8
391c76acec6d55107b652a37c90b36c00bc8b04dabbJay Fenlason#define FW_ISO_CONTEXT_MATCH_ALL_TAGS	15
392c76acec6d55107b652a37c90b36c00bc8b04dabbJay Fenlason
393c76acec6d55107b652a37c90b36c00bc8b04dabbJay Fenlason/*
394c76acec6d55107b652a37c90b36c00bc8b04dabbJay Fenlason * An iso buffer is just a set of pages mapped for DMA in the
395c76acec6d55107b652a37c90b36c00bc8b04dabbJay Fenlason * specified direction.  Since the pages are to be used for DMA, they
396c76acec6d55107b652a37c90b36c00bc8b04dabbJay Fenlason * are not mapped into the kernel virtual address space.  We store the
397c76acec6d55107b652a37c90b36c00bc8b04dabbJay Fenlason * DMA address in the page private. The helper function
398c76acec6d55107b652a37c90b36c00bc8b04dabbJay Fenlason * fw_iso_buffer_map() will map the pages into a given vma.
399c76acec6d55107b652a37c90b36c00bc8b04dabbJay Fenlason */
400c76acec6d55107b652a37c90b36c00bc8b04dabbJay Fenlasonstruct fw_iso_buffer {
401c76acec6d55107b652a37c90b36c00bc8b04dabbJay Fenlason	enum dma_data_direction direction;
402c76acec6d55107b652a37c90b36c00bc8b04dabbJay Fenlason	struct page **pages;
403c76acec6d55107b652a37c90b36c00bc8b04dabbJay Fenlason	int page_count;
404c76acec6d55107b652a37c90b36c00bc8b04dabbJay Fenlason};
405c76acec6d55107b652a37c90b36c00bc8b04dabbJay Fenlason
406c76acec6d55107b652a37c90b36c00bc8b04dabbJay Fenlasonint fw_iso_buffer_init(struct fw_iso_buffer *buffer, struct fw_card *card,
407c76acec6d55107b652a37c90b36c00bc8b04dabbJay Fenlason		       int page_count, enum dma_data_direction direction);
408c76acec6d55107b652a37c90b36c00bc8b04dabbJay Fenlasonvoid fw_iso_buffer_destroy(struct fw_iso_buffer *buffer, struct fw_card *card);
409c76acec6d55107b652a37c90b36c00bc8b04dabbJay Fenlason
410c76acec6d55107b652a37c90b36c00bc8b04dabbJay Fenlasonstruct fw_iso_context;
411c76acec6d55107b652a37c90b36c00bc8b04dabbJay Fenlasontypedef void (*fw_iso_callback_t)(struct fw_iso_context *context,
412c76acec6d55107b652a37c90b36c00bc8b04dabbJay Fenlason				  u32 cycle, size_t header_length,
413c76acec6d55107b652a37c90b36c00bc8b04dabbJay Fenlason				  void *header, void *data);
414c76acec6d55107b652a37c90b36c00bc8b04dabbJay Fenlasonstruct fw_iso_context {
415c76acec6d55107b652a37c90b36c00bc8b04dabbJay Fenlason	struct fw_card *card;
416c76acec6d55107b652a37c90b36c00bc8b04dabbJay Fenlason	int type;
417c76acec6d55107b652a37c90b36c00bc8b04dabbJay Fenlason	int channel;
418c76acec6d55107b652a37c90b36c00bc8b04dabbJay Fenlason	int speed;
419c76acec6d55107b652a37c90b36c00bc8b04dabbJay Fenlason	size_t header_size;
420c76acec6d55107b652a37c90b36c00bc8b04dabbJay Fenlason	fw_iso_callback_t callback;
421c76acec6d55107b652a37c90b36c00bc8b04dabbJay Fenlason	void *callback_data;
422c76acec6d55107b652a37c90b36c00bc8b04dabbJay Fenlason};
423c76acec6d55107b652a37c90b36c00bc8b04dabbJay Fenlason
424c76acec6d55107b652a37c90b36c00bc8b04dabbJay Fenlasonstruct fw_iso_context *fw_iso_context_create(struct fw_card *card,
425c76acec6d55107b652a37c90b36c00bc8b04dabbJay Fenlason		int type, int channel, int speed, size_t header_size,
426c76acec6d55107b652a37c90b36c00bc8b04dabbJay Fenlason		fw_iso_callback_t callback, void *callback_data);
427c76acec6d55107b652a37c90b36c00bc8b04dabbJay Fenlasonint fw_iso_context_queue(struct fw_iso_context *ctx,
428c76acec6d55107b652a37c90b36c00bc8b04dabbJay Fenlason			 struct fw_iso_packet *packet,
429c76acec6d55107b652a37c90b36c00bc8b04dabbJay Fenlason			 struct fw_iso_buffer *buffer,
430c76acec6d55107b652a37c90b36c00bc8b04dabbJay Fenlason			 unsigned long payload);
431c76acec6d55107b652a37c90b36c00bc8b04dabbJay Fenlasonint fw_iso_context_start(struct fw_iso_context *ctx,
432c76acec6d55107b652a37c90b36c00bc8b04dabbJay Fenlason			 int cycle, int sync, int tags);
433c76acec6d55107b652a37c90b36c00bc8b04dabbJay Fenlasonint fw_iso_context_stop(struct fw_iso_context *ctx);
434c76acec6d55107b652a37c90b36c00bc8b04dabbJay Fenlasonvoid fw_iso_context_destroy(struct fw_iso_context *ctx);
435c76acec6d55107b652a37c90b36c00bc8b04dabbJay Fenlason
43677c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter#endif /* _LINUX_FIREWIRE_H */
437