firewire.h revision 94a87157cde95d38b9cdf1116e4f0fd93f6d25df
177c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter#ifndef _LINUX_FIREWIRE_H 277c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter#define _LINUX_FIREWIRE_H 377c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter 477c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter#include <linux/completion.h> 5f68c56b7d2351036d1ec58c7a0ac4f258cbc1fa2Paul Gortmaker#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 1760063497a95e716c9a689af3be2687d261f115b4Arun Sharma#include <linux/atomic.h> 1877c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter#include <asm/byteorder.h> 1977c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter 2077c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter#define CSR_REGISTER_BASE 0xfffff0000000ULL 2177c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter 2277c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter/* register offsets are relative to CSR_REGISTER_BASE */ 2377c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter#define CSR_STATE_CLEAR 0x0 2477c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter#define CSR_STATE_SET 0x4 2577c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter#define CSR_NODE_IDS 0x8 2677c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter#define CSR_RESET_START 0xc 2777c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter#define CSR_SPLIT_TIMEOUT_HI 0x18 2877c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter#define CSR_SPLIT_TIMEOUT_LO 0x1c 2977c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter#define CSR_CYCLE_TIME 0x200 3077c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter#define CSR_BUS_TIME 0x204 3177c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter#define CSR_BUSY_TIMEOUT 0x210 32a1a1132bd83d0aea51d4f19be4b4a58a064a0131Clemens Ladisch#define CSR_PRIORITY_BUDGET 0x218 3377c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter#define CSR_BUS_MANAGER_ID 0x21c 3477c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter#define CSR_BANDWIDTH_AVAILABLE 0x220 3577c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter#define CSR_CHANNELS_AVAILABLE 0x224 3677c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter#define CSR_CHANNELS_AVAILABLE_HI 0x224 3777c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter#define CSR_CHANNELS_AVAILABLE_LO 0x228 383d1f46eb60b155c705e389ecdf313f11b4b91976Clemens Ladisch#define CSR_MAINT_UTILITY 0x230 3977c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter#define CSR_BROADCAST_CHANNEL 0x234 4077c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter#define CSR_CONFIG_ROM 0x400 4177c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter#define CSR_CONFIG_ROM_END 0x800 4231ef9134eb52636d383a7d0626cbbd345cb94f2fClemens Ladisch#define CSR_OMPR 0x900 4331ef9134eb52636d383a7d0626cbbd345cb94f2fClemens Ladisch#define CSR_OPCR(i) (0x904 + (i) * 4) 4431ef9134eb52636d383a7d0626cbbd345cb94f2fClemens Ladisch#define CSR_IMPR 0x980 4531ef9134eb52636d383a7d0626cbbd345cb94f2fClemens Ladisch#define CSR_IPCR(i) (0x984 + (i) * 4) 4677c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter#define CSR_FCP_COMMAND 0xB00 4777c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter#define CSR_FCP_RESPONSE 0xD00 4877c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter#define CSR_FCP_END 0xF00 4977c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter#define CSR_TOPOLOGY_MAP 0x1000 5077c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter#define CSR_TOPOLOGY_MAP_END 0x1400 5177c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter#define CSR_SPEED_MAP 0x2000 5277c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter#define CSR_SPEED_MAP_END 0x3000 5377c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter 5477c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter#define CSR_OFFSET 0x40 5577c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter#define CSR_LEAF 0x80 5677c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter#define CSR_DIRECTORY 0xc0 5777c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter 5877c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter#define CSR_DESCRIPTOR 0x01 5977c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter#define CSR_VENDOR 0x03 6077c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter#define CSR_HARDWARE_VERSION 0x04 6177c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter#define CSR_UNIT 0x11 6277c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter#define CSR_SPECIFIER_ID 0x12 6377c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter#define CSR_VERSION 0x13 6477c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter#define CSR_DEPENDENT_INFO 0x14 6577c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter#define CSR_MODEL 0x17 6677c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter#define CSR_DIRECTORY_ID 0x20 6777c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter 6877c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richterstruct fw_csr_iterator { 6913b302d0a217580c0129b0641b0ca8b592e437b0Stefan Richter const u32 *p; 7013b302d0a217580c0129b0641b0ca8b592e437b0Stefan Richter const u32 *end; 7177c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter}; 7277c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter 7313b302d0a217580c0129b0641b0ca8b592e437b0Stefan Richtervoid fw_csr_iterator_init(struct fw_csr_iterator *ci, const u32 *p); 7477c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richterint fw_csr_iterator_next(struct fw_csr_iterator *ci, int *key, int *value); 7513b302d0a217580c0129b0641b0ca8b592e437b0Stefan Richterint fw_csr_string(const u32 *directory, int key, char *buf, size_t size); 761f8fef7b3388b5a976e80839679b5bae581a1091Clemens Ladisch 7777c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richterextern struct bus_type fw_bus_type; 7877c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter 7977c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richterstruct fw_card_driver; 8077c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richterstruct fw_node; 8177c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter 8277c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richterstruct fw_card { 8377c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter const struct fw_card_driver *driver; 8477c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter struct device *device; 8577c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter struct kref kref; 8677c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter struct completion done; 8777c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter 8877c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter int node_id; 8977c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter int generation; 901e626fdcef61460dc75fe7377f38bb019722b848Stefan Richter int current_tlabel; 911e626fdcef61460dc75fe7377f38bb019722b848Stefan Richter u64 tlabel_mask; 9277c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter struct list_head transaction_list; 93e71084af58cf15e6043338500eeaf6281d0a62afClemens Ladisch u64 reset_jiffies; 9477c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter 958e4b50f94e8c1435a3e0ece42b7f97bc857d0145Clemens Ladisch u32 split_timeout_hi; 968e4b50f94e8c1435a3e0ece42b7f97bc857d0145Clemens Ladisch u32 split_timeout_lo; 978e4b50f94e8c1435a3e0ece42b7f97bc857d0145Clemens Ladisch unsigned int split_timeout_cycles; 988e4b50f94e8c1435a3e0ece42b7f97bc857d0145Clemens Ladisch unsigned int split_timeout_jiffies; 998e4b50f94e8c1435a3e0ece42b7f97bc857d0145Clemens Ladisch 10077c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter unsigned long long guid; 10177c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter unsigned max_receive; 10277c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter int link_speed; 10377c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter int config_rom_generation; 10477c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter 10577c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter spinlock_t lock; /* Take this lock when handling the lists in 10677c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter * this struct. */ 10777c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter struct fw_node *local_node; 10877c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter struct fw_node *root_node; 10977c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter struct fw_node *irm_node; 11077c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter u8 color; /* must be u8 to match the definition in struct fw_node */ 11177c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter int gap_count; 11277c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter bool beta_repeaters_present; 11377c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter 11477c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter int index; 11577c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter struct list_head link; 11677c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter 117bf54e1462b9192fdef7ea9e2bc44fdc16a4b87bcStefan Richter struct list_head phy_receiver_list; 118bf54e1462b9192fdef7ea9e2bc44fdc16a4b87bcStefan Richter 11902d37bed188c500ee7afb0a2dc6b65a80704c58eStefan Richter struct delayed_work br_work; /* bus reset job */ 12002d37bed188c500ee7afb0a2dc6b65a80704c58eStefan Richter bool br_short; 12102d37bed188c500ee7afb0a2dc6b65a80704c58eStefan Richter 12202d37bed188c500ee7afb0a2dc6b65a80704c58eStefan Richter struct delayed_work bm_work; /* bus manager job */ 12377c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter int bm_retries; 12477c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter int bm_generation; 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 138fc5f80b152896c1ffded2a91d11dcb08ffcffebbChris Bootstatic inline struct fw_card *fw_card_get(struct fw_card *card) 139fc5f80b152896c1ffded2a91d11dcb08ffcffebbChris Boot{ 140fc5f80b152896c1ffded2a91d11dcb08ffcffebbChris Boot kref_get(&card->kref); 141fc5f80b152896c1ffded2a91d11dcb08ffcffebbChris Boot 142fc5f80b152896c1ffded2a91d11dcb08ffcffebbChris Boot return card; 143fc5f80b152896c1ffded2a91d11dcb08ffcffebbChris Boot} 144fc5f80b152896c1ffded2a91d11dcb08ffcffebbChris Boot 145fc5f80b152896c1ffded2a91d11dcb08ffcffebbChris Bootvoid fw_card_release(struct kref *kref); 146fc5f80b152896c1ffded2a91d11dcb08ffcffebbChris Boot 147fc5f80b152896c1ffded2a91d11dcb08ffcffebbChris Bootstatic inline void fw_card_put(struct fw_card *card) 148fc5f80b152896c1ffded2a91d11dcb08ffcffebbChris Boot{ 149fc5f80b152896c1ffded2a91d11dcb08ffcffebbChris Boot kref_put(&card->kref, fw_card_release); 150fc5f80b152896c1ffded2a91d11dcb08ffcffebbChris Boot} 151fc5f80b152896c1ffded2a91d11dcb08ffcffebbChris Boot 15277c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richterstruct fw_attribute_group { 15377c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter struct attribute_group *groups[2]; 15477c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter struct attribute_group group; 155baedee177e6c553af455865718971d9a9c75e537Clemens Ladisch struct attribute *attrs[13]; 15677c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter}; 15777c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter 15877c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richterenum fw_device_state { 15977c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter FW_DEVICE_INITIALIZING, 16077c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter FW_DEVICE_RUNNING, 16177c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter FW_DEVICE_GONE, 16277c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter FW_DEVICE_SHUTDOWN, 16377c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter}; 16477c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter 16577c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter/* 16677c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter * Note, fw_device.generation always has to be read before fw_device.node_id. 16777c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter * Use SMP memory barriers to ensure this. Otherwise requests will be sent 16877c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter * to an outdated node_id if the generation was updated in the meantime due 16977c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter * to a bus reset. 17077c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter * 17177c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter * Likewise, fw-core will take care to update .node_id before .generation so 17277c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter * that whenever fw_device.generation is current WRT the actual bus generation, 17377c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter * fw_device.node_id is guaranteed to be current too. 17477c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter * 17577c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter * The same applies to fw_device.card->node_id vs. fw_device.generation. 17677c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter * 17777c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter * fw_device.config_rom and fw_device.config_rom_length may be accessed during 17877c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter * the lifetime of any fw_unit belonging to the fw_device, before device_del() 17977c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter * was called on the last fw_unit. Alternatively, they may be accessed while 18077c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter * holding fw_device_rwsem. 18177c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter */ 18277c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richterstruct fw_device { 18377c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter atomic_t state; 18477c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter struct fw_node *node; 18577c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter int node_id; 18677c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter int generation; 18777c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter unsigned max_speed; 18877c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter struct fw_card *card; 18977c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter struct device device; 19077c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter 19177c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter struct mutex client_list_mutex; 19277c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter struct list_head client_list; 19377c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter 19413b302d0a217580c0129b0641b0ca8b592e437b0Stefan Richter const u32 *config_rom; 19577c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter size_t config_rom_length; 19677c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter int config_rom_retries; 19777c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter unsigned is_local:1; 198837ec787d85fda8d73193a399ebcea0288e4765bStefan Richter unsigned max_rec:4; 19977c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter unsigned cmc:1; 200837ec787d85fda8d73193a399ebcea0288e4765bStefan Richter unsigned irmc:1; 20177c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter unsigned bc_implemented:2; 20277c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter 20377c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter struct delayed_work work; 20477c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter struct fw_attribute_group attribute_group; 20577c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter}; 20677c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter 20777c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richterstatic inline struct fw_device *fw_device(struct device *dev) 20877c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter{ 20977c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter return container_of(dev, struct fw_device, device); 21077c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter} 21177c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter 21277c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richterstatic inline int fw_device_is_shutdown(struct fw_device *device) 21377c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter{ 21477c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter return atomic_read(&device->state) == FW_DEVICE_SHUTDOWN; 21577c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter} 21677c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter 21777c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richterint fw_device_enable_phys_dma(struct fw_device *device); 21877c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter 21977c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter/* 22077c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter * fw_unit.directory must not be accessed after device_del(&fw_unit.device). 22177c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter */ 22277c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richterstruct fw_unit { 22377c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter struct device device; 22413b302d0a217580c0129b0641b0ca8b592e437b0Stefan Richter const u32 *directory; 22577c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter struct fw_attribute_group attribute_group; 22677c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter}; 22777c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter 22877c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richterstatic inline struct fw_unit *fw_unit(struct device *dev) 22977c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter{ 23077c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter return container_of(dev, struct fw_unit, device); 23177c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter} 23277c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter 23377c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richterstatic inline struct fw_unit *fw_unit_get(struct fw_unit *unit) 23477c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter{ 23577c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter get_device(&unit->device); 23677c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter 23777c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter return unit; 23877c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter} 23977c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter 24077c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richterstatic inline void fw_unit_put(struct fw_unit *unit) 24177c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter{ 24277c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter put_device(&unit->device); 24377c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter} 24477c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter 245e5110d011e03030926872457f05e49e3d5031737Stefan Richterstatic inline struct fw_device *fw_parent_device(struct fw_unit *unit) 246e5110d011e03030926872457f05e49e3d5031737Stefan Richter{ 247e5110d011e03030926872457f05e49e3d5031737Stefan Richter return fw_device(unit->device.parent); 248e5110d011e03030926872457f05e49e3d5031737Stefan Richter} 249e5110d011e03030926872457f05e49e3d5031737Stefan Richter 25077c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richterstruct ieee1394_device_id; 25177c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter 25277c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richterstruct fw_driver { 25377c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter struct device_driver driver; 25494a87157cde95d38b9cdf1116e4f0fd93f6d25dfStefan Richter int (*probe)(struct fw_unit *unit, const struct ieee1394_device_id *id); 25577c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter /* Called when the parent device sits through a bus reset. */ 25677c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter void (*update)(struct fw_unit *unit); 25794a87157cde95d38b9cdf1116e4f0fd93f6d25dfStefan Richter void (*remove)(struct fw_unit *unit); 25877c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter const struct ieee1394_device_id *id_table; 25977c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter}; 26077c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter 26177c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richterstruct fw_packet; 26277c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richterstruct fw_request; 26377c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter 26477c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richtertypedef void (*fw_packet_callback_t)(struct fw_packet *packet, 26577c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter struct fw_card *card, int status); 26677c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richtertypedef void (*fw_transaction_callback_t)(struct fw_card *card, int rcode, 26777c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter void *data, size_t length, 26877c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter void *callback_data); 26977c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter/* 2704d50c44381c981c9caa74e82ab894d4938dac9caStefan Richter * This callback handles an inbound request subaction. It is called in 2714d50c44381c981c9caa74e82ab894d4938dac9caStefan Richter * RCU read-side context, therefore must not sleep. 2724d50c44381c981c9caa74e82ab894d4938dac9caStefan Richter * 2734d50c44381c981c9caa74e82ab894d4938dac9caStefan Richter * The callback should not initiate outbound request subactions directly. 2744d50c44381c981c9caa74e82ab894d4938dac9caStefan Richter * Otherwise there is a danger of recursion of inbound and outbound 2754d50c44381c981c9caa74e82ab894d4938dac9caStefan Richter * transactions from and to the local node. 2764d50c44381c981c9caa74e82ab894d4938dac9caStefan Richter * 2774d50c44381c981c9caa74e82ab894d4938dac9caStefan Richter * The callback is responsible that either fw_send_response() or kfree() 2784d50c44381c981c9caa74e82ab894d4938dac9caStefan Richter * is called on the @request, except for FCP registers for which the core 2794d50c44381c981c9caa74e82ab894d4938dac9caStefan Richter * takes care of that. 28077c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter */ 28177c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richtertypedef void (*fw_address_callback_t)(struct fw_card *card, 28277c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter struct fw_request *request, 28377c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter int tcode, int destination, int source, 28433e553fe2b4a983ef34a57ab1440d8d33397bb12Stefan Richter int generation, 28577c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter unsigned long long offset, 28677c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter void *data, size_t length, 28777c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter void *callback_data); 28877c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter 28977c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richterstruct fw_packet { 29077c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter int speed; 29177c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter int generation; 29277c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter u32 header[4]; 29377c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter size_t header_length; 29477c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter void *payload; 29577c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter size_t payload_length; 29677c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter dma_addr_t payload_bus; 29719593ffdb6daa6ba691d247a2400cece12687c52Stefan Richter bool payload_mapped; 29877c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter u32 timestamp; 29977c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter 30077c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter /* 30118d0cdfd1a4cc9028c0ef80f94538b31541f8fe5Stefan Richter * This callback is called when the packet transmission has completed. 30218d0cdfd1a4cc9028c0ef80f94538b31541f8fe5Stefan Richter * For successful transmission, the status code is the ack received 30318d0cdfd1a4cc9028c0ef80f94538b31541f8fe5Stefan Richter * from the destination. Otherwise it is one of the juju-specific 30418d0cdfd1a4cc9028c0ef80f94538b31541f8fe5Stefan Richter * rcodes: RCODE_SEND_ERROR, _CANCELLED, _BUSY, _GENERATION, _NO_ACK. 30577c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter * The callback can be called from tasklet context and thus 30677c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter * must never block. 30777c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter */ 30877c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter fw_packet_callback_t callback; 30977c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter int ack; 31077c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter struct list_head link; 31177c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter void *driver_data; 31277c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter}; 31377c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter 31477c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richterstruct fw_transaction { 31577c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter int node_id; /* The generation is implied; it is always the current. */ 31677c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter int tlabel; 31777c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter struct list_head link; 3185c40cbfefa828208c671e2f58789e4dd04f79563Clemens Ladisch struct fw_card *card; 319410cf2bd3dc6ec1ed9e1b36b25b9d7aa927ed14eClemens Ladisch bool is_split_transaction; 3205c40cbfefa828208c671e2f58789e4dd04f79563Clemens Ladisch struct timer_list split_timeout_timer; 32177c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter 32277c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter struct fw_packet packet; 32377c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter 32477c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter /* 32577c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter * The data passed to the callback is valid only during the 32677c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter * callback. 32777c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter */ 32877c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter fw_transaction_callback_t callback; 32977c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter void *callback_data; 33077c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter}; 33177c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter 33277c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richterstruct fw_address_handler { 33377c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter u64 offset; 334188726ecb66f022e92ec110ca85c62a937184636Clemens Ladisch u64 length; 33577c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter fw_address_callback_t address_callback; 33677c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter void *callback_data; 33777c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter struct list_head link; 33877c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter}; 33977c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter 34077c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richterstruct fw_address_region { 34177c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter u64 start; 34277c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter u64 end; 34377c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter}; 34477c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter 34577c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richterextern const struct fw_address_region fw_high_memory_region; 34677c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter 34777c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richterint fw_core_add_address_handler(struct fw_address_handler *handler, 34877c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter const struct fw_address_region *region); 34977c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richtervoid fw_core_remove_address_handler(struct fw_address_handler *handler); 35077c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richtervoid fw_send_response(struct fw_card *card, 35177c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter struct fw_request *request, int rcode); 352253d92371ca29a470b2bbf91fb9824a9fef05657Chris Bootint fw_get_request_speed(struct fw_request *request); 35377c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richtervoid fw_send_request(struct fw_card *card, struct fw_transaction *t, 35477c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter int tcode, int destination_id, int generation, int speed, 35577c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter unsigned long long offset, void *payload, size_t length, 35677c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter fw_transaction_callback_t callback, void *callback_data); 35777c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richterint fw_cancel_transaction(struct fw_card *card, 35877c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter struct fw_transaction *transaction); 35977c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richterint fw_run_transaction(struct fw_card *card, int tcode, int destination_id, 36077c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter int generation, int speed, unsigned long long offset, 36177c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter void *payload, size_t length); 3627bdbff6762a573b911e4ee5715779d8ee6a62631Clemens Ladischconst char *fw_rcode_string(int rcode); 36377c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter 364c76acec6d55107b652a37c90b36c00bc8b04dabbJay Fenlasonstatic inline int fw_stream_packet_destination_id(int tag, int channel, int sy) 365c76acec6d55107b652a37c90b36c00bc8b04dabbJay Fenlason{ 366c76acec6d55107b652a37c90b36c00bc8b04dabbJay Fenlason return tag << 14 | channel << 8 | sy; 367c76acec6d55107b652a37c90b36c00bc8b04dabbJay Fenlason} 368c76acec6d55107b652a37c90b36c00bc8b04dabbJay Fenlason 369c76acec6d55107b652a37c90b36c00bc8b04dabbJay Fenlasonstruct fw_descriptor { 370c76acec6d55107b652a37c90b36c00bc8b04dabbJay Fenlason struct list_head link; 371c76acec6d55107b652a37c90b36c00bc8b04dabbJay Fenlason size_t length; 372c76acec6d55107b652a37c90b36c00bc8b04dabbJay Fenlason u32 immediate; 373c76acec6d55107b652a37c90b36c00bc8b04dabbJay Fenlason u32 key; 374c76acec6d55107b652a37c90b36c00bc8b04dabbJay Fenlason const u32 *data; 375c76acec6d55107b652a37c90b36c00bc8b04dabbJay Fenlason}; 376c76acec6d55107b652a37c90b36c00bc8b04dabbJay Fenlason 377c76acec6d55107b652a37c90b36c00bc8b04dabbJay Fenlasonint fw_core_add_descriptor(struct fw_descriptor *desc); 378c76acec6d55107b652a37c90b36c00bc8b04dabbJay Fenlasonvoid fw_core_remove_descriptor(struct fw_descriptor *desc); 379c76acec6d55107b652a37c90b36c00bc8b04dabbJay Fenlason 380c76acec6d55107b652a37c90b36c00bc8b04dabbJay Fenlason/* 381c76acec6d55107b652a37c90b36c00bc8b04dabbJay Fenlason * The iso packet format allows for an immediate header/payload part 382c76acec6d55107b652a37c90b36c00bc8b04dabbJay Fenlason * stored in 'header' immediately after the packet info plus an 383c76acec6d55107b652a37c90b36c00bc8b04dabbJay Fenlason * indirect payload part that is pointer to by the 'payload' field. 384c76acec6d55107b652a37c90b36c00bc8b04dabbJay Fenlason * Applications can use one or the other or both to implement simple 385c76acec6d55107b652a37c90b36c00bc8b04dabbJay Fenlason * low-bandwidth streaming (e.g. audio) or more advanced 386c76acec6d55107b652a37c90b36c00bc8b04dabbJay Fenlason * scatter-gather streaming (e.g. assembling video frame automatically). 387c76acec6d55107b652a37c90b36c00bc8b04dabbJay Fenlason */ 388c76acec6d55107b652a37c90b36c00bc8b04dabbJay Fenlasonstruct fw_iso_packet { 389872e330e38806d835bd6c311c93ab998e2fb9058Stefan Richter u16 payload_length; /* Length of indirect payload */ 390872e330e38806d835bd6c311c93ab998e2fb9058Stefan Richter u32 interrupt:1; /* Generate interrupt on this packet */ 391872e330e38806d835bd6c311c93ab998e2fb9058Stefan Richter u32 skip:1; /* tx: Set to not send packet at all */ 392872e330e38806d835bd6c311c93ab998e2fb9058Stefan Richter /* rx: Sync bit, wait for matching sy */ 393872e330e38806d835bd6c311c93ab998e2fb9058Stefan Richter u32 tag:2; /* tx: Tag in packet header */ 394872e330e38806d835bd6c311c93ab998e2fb9058Stefan Richter u32 sy:4; /* tx: Sy in packet header */ 395872e330e38806d835bd6c311c93ab998e2fb9058Stefan Richter u32 header_length:8; /* Length of immediate header */ 396872e330e38806d835bd6c311c93ab998e2fb9058Stefan Richter u32 header[0]; /* tx: Top of 1394 isoch. data_block */ 397c76acec6d55107b652a37c90b36c00bc8b04dabbJay Fenlason}; 398c76acec6d55107b652a37c90b36c00bc8b04dabbJay Fenlason 399872e330e38806d835bd6c311c93ab998e2fb9058Stefan Richter#define FW_ISO_CONTEXT_TRANSMIT 0 400872e330e38806d835bd6c311c93ab998e2fb9058Stefan Richter#define FW_ISO_CONTEXT_RECEIVE 1 401872e330e38806d835bd6c311c93ab998e2fb9058Stefan Richter#define FW_ISO_CONTEXT_RECEIVE_MULTICHANNEL 2 402c76acec6d55107b652a37c90b36c00bc8b04dabbJay Fenlason 403c76acec6d55107b652a37c90b36c00bc8b04dabbJay Fenlason#define FW_ISO_CONTEXT_MATCH_TAG0 1 404c76acec6d55107b652a37c90b36c00bc8b04dabbJay Fenlason#define FW_ISO_CONTEXT_MATCH_TAG1 2 405c76acec6d55107b652a37c90b36c00bc8b04dabbJay Fenlason#define FW_ISO_CONTEXT_MATCH_TAG2 4 406c76acec6d55107b652a37c90b36c00bc8b04dabbJay Fenlason#define FW_ISO_CONTEXT_MATCH_TAG3 8 407c76acec6d55107b652a37c90b36c00bc8b04dabbJay Fenlason#define FW_ISO_CONTEXT_MATCH_ALL_TAGS 15 408c76acec6d55107b652a37c90b36c00bc8b04dabbJay Fenlason 409c76acec6d55107b652a37c90b36c00bc8b04dabbJay Fenlason/* 410c76acec6d55107b652a37c90b36c00bc8b04dabbJay Fenlason * An iso buffer is just a set of pages mapped for DMA in the 411c76acec6d55107b652a37c90b36c00bc8b04dabbJay Fenlason * specified direction. Since the pages are to be used for DMA, they 412c76acec6d55107b652a37c90b36c00bc8b04dabbJay Fenlason * are not mapped into the kernel virtual address space. We store the 413c76acec6d55107b652a37c90b36c00bc8b04dabbJay Fenlason * DMA address in the page private. The helper function 414c76acec6d55107b652a37c90b36c00bc8b04dabbJay Fenlason * fw_iso_buffer_map() will map the pages into a given vma. 415c76acec6d55107b652a37c90b36c00bc8b04dabbJay Fenlason */ 416c76acec6d55107b652a37c90b36c00bc8b04dabbJay Fenlasonstruct fw_iso_buffer { 417c76acec6d55107b652a37c90b36c00bc8b04dabbJay Fenlason enum dma_data_direction direction; 418c76acec6d55107b652a37c90b36c00bc8b04dabbJay Fenlason struct page **pages; 419c76acec6d55107b652a37c90b36c00bc8b04dabbJay Fenlason int page_count; 4200b6c4857f7684f6d3f59e0506f62953575346978Stefan Richter int page_count_mapped; 421c76acec6d55107b652a37c90b36c00bc8b04dabbJay Fenlason}; 422c76acec6d55107b652a37c90b36c00bc8b04dabbJay Fenlason 423c76acec6d55107b652a37c90b36c00bc8b04dabbJay Fenlasonint fw_iso_buffer_init(struct fw_iso_buffer *buffer, struct fw_card *card, 424c76acec6d55107b652a37c90b36c00bc8b04dabbJay Fenlason int page_count, enum dma_data_direction direction); 425c76acec6d55107b652a37c90b36c00bc8b04dabbJay Fenlasonvoid fw_iso_buffer_destroy(struct fw_iso_buffer *buffer, struct fw_card *card); 426872e330e38806d835bd6c311c93ab998e2fb9058Stefan Richtersize_t fw_iso_buffer_lookup(struct fw_iso_buffer *buffer, dma_addr_t completed); 427c76acec6d55107b652a37c90b36c00bc8b04dabbJay Fenlason 428c76acec6d55107b652a37c90b36c00bc8b04dabbJay Fenlasonstruct fw_iso_context; 429c76acec6d55107b652a37c90b36c00bc8b04dabbJay Fenlasontypedef void (*fw_iso_callback_t)(struct fw_iso_context *context, 430c76acec6d55107b652a37c90b36c00bc8b04dabbJay Fenlason u32 cycle, size_t header_length, 431c76acec6d55107b652a37c90b36c00bc8b04dabbJay Fenlason void *header, void *data); 432872e330e38806d835bd6c311c93ab998e2fb9058Stefan Richtertypedef void (*fw_iso_mc_callback_t)(struct fw_iso_context *context, 433872e330e38806d835bd6c311c93ab998e2fb9058Stefan Richter dma_addr_t completed, void *data); 434c76acec6d55107b652a37c90b36c00bc8b04dabbJay Fenlasonstruct fw_iso_context { 435c76acec6d55107b652a37c90b36c00bc8b04dabbJay Fenlason struct fw_card *card; 436c76acec6d55107b652a37c90b36c00bc8b04dabbJay Fenlason int type; 437c76acec6d55107b652a37c90b36c00bc8b04dabbJay Fenlason int channel; 438c76acec6d55107b652a37c90b36c00bc8b04dabbJay Fenlason int speed; 439c76acec6d55107b652a37c90b36c00bc8b04dabbJay Fenlason size_t header_size; 440872e330e38806d835bd6c311c93ab998e2fb9058Stefan Richter union { 441872e330e38806d835bd6c311c93ab998e2fb9058Stefan Richter fw_iso_callback_t sc; 442872e330e38806d835bd6c311c93ab998e2fb9058Stefan Richter fw_iso_mc_callback_t mc; 443872e330e38806d835bd6c311c93ab998e2fb9058Stefan Richter } callback; 444c76acec6d55107b652a37c90b36c00bc8b04dabbJay Fenlason void *callback_data; 445c76acec6d55107b652a37c90b36c00bc8b04dabbJay Fenlason}; 446c76acec6d55107b652a37c90b36c00bc8b04dabbJay Fenlason 447c76acec6d55107b652a37c90b36c00bc8b04dabbJay Fenlasonstruct fw_iso_context *fw_iso_context_create(struct fw_card *card, 448c76acec6d55107b652a37c90b36c00bc8b04dabbJay Fenlason int type, int channel, int speed, size_t header_size, 449c76acec6d55107b652a37c90b36c00bc8b04dabbJay Fenlason fw_iso_callback_t callback, void *callback_data); 450872e330e38806d835bd6c311c93ab998e2fb9058Stefan Richterint fw_iso_context_set_channels(struct fw_iso_context *ctx, u64 *channels); 451c76acec6d55107b652a37c90b36c00bc8b04dabbJay Fenlasonint fw_iso_context_queue(struct fw_iso_context *ctx, 452c76acec6d55107b652a37c90b36c00bc8b04dabbJay Fenlason struct fw_iso_packet *packet, 453c76acec6d55107b652a37c90b36c00bc8b04dabbJay Fenlason struct fw_iso_buffer *buffer, 454c76acec6d55107b652a37c90b36c00bc8b04dabbJay Fenlason unsigned long payload); 45513882a82ee1646336c3996c93b4a560a55d2a419Clemens Ladischvoid fw_iso_context_queue_flush(struct fw_iso_context *ctx); 456d1bbd20972936b9b178fda3eb1ec417cb27fdc01Clemens Ladischint fw_iso_context_flush_completions(struct fw_iso_context *ctx); 457c76acec6d55107b652a37c90b36c00bc8b04dabbJay Fenlasonint fw_iso_context_start(struct fw_iso_context *ctx, 458c76acec6d55107b652a37c90b36c00bc8b04dabbJay Fenlason int cycle, int sync, int tags); 459c76acec6d55107b652a37c90b36c00bc8b04dabbJay Fenlasonint fw_iso_context_stop(struct fw_iso_context *ctx); 460c76acec6d55107b652a37c90b36c00bc8b04dabbJay Fenlasonvoid fw_iso_context_destroy(struct fw_iso_context *ctx); 46131ef9134eb52636d383a7d0626cbbd345cb94f2fClemens Ladischvoid fw_iso_resource_manage(struct fw_card *card, int generation, 46231ef9134eb52636d383a7d0626cbbd345cb94f2fClemens Ladisch u64 channels_mask, int *channel, int *bandwidth, 463f30e6d3e419bfb5540fa82ba7eca01d578556e6bStefan Richter bool allocate); 464c76acec6d55107b652a37c90b36c00bc8b04dabbJay Fenlason 465105e53f863c04e1d9e5bb34bf753c9fdbce6a60cStefan Richterextern struct workqueue_struct *fw_workqueue; 466105e53f863c04e1d9e5bb34bf753c9fdbce6a60cStefan Richter 46777c9a5daa9c4d9b37812c9c69c7bcbb3f9399c3cStefan Richter#endif /* _LINUX_FIREWIRE_H */ 468