aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/firewire/fw-device.h
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/firewire/fw-device.h')
-rw-r--r--drivers/firewire/fw-device.h190
1 files changed, 0 insertions, 190 deletions
diff --git a/drivers/firewire/fw-device.h b/drivers/firewire/fw-device.h
deleted file mode 100644
index e973c4361f48..000000000000
--- a/drivers/firewire/fw-device.h
+++ /dev/null
@@ -1,190 +0,0 @@
1/*
2 * Copyright (C) 2005-2006 Kristian Hoegsberg <krh@bitplanet.net>
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software Foundation,
16 * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17 */
18
19#ifndef __fw_device_h
20#define __fw_device_h
21
22#include <linux/device.h>
23#include <linux/fs.h>
24#include <linux/idr.h>
25#include <linux/kernel.h>
26#include <linux/list.h>
27#include <linux/mod_devicetable.h>
28#include <linux/mutex.h>
29#include <linux/rwsem.h>
30#include <linux/sysfs.h>
31#include <linux/types.h>
32#include <linux/workqueue.h>
33
34#include <asm/atomic.h>
35
36enum fw_device_state {
37 FW_DEVICE_INITIALIZING,
38 FW_DEVICE_RUNNING,
39 FW_DEVICE_GONE,
40 FW_DEVICE_SHUTDOWN,
41};
42
43struct fw_attribute_group {
44 struct attribute_group *groups[2];
45 struct attribute_group group;
46 struct attribute *attrs[12];
47};
48
49struct fw_node;
50struct fw_card;
51
52/*
53 * Note, fw_device.generation always has to be read before fw_device.node_id.
54 * Use SMP memory barriers to ensure this. Otherwise requests will be sent
55 * to an outdated node_id if the generation was updated in the meantime due
56 * to a bus reset.
57 *
58 * Likewise, fw-core will take care to update .node_id before .generation so
59 * that whenever fw_device.generation is current WRT the actual bus generation,
60 * fw_device.node_id is guaranteed to be current too.
61 *
62 * The same applies to fw_device.card->node_id vs. fw_device.generation.
63 *
64 * fw_device.config_rom and fw_device.config_rom_length may be accessed during
65 * the lifetime of any fw_unit belonging to the fw_device, before device_del()
66 * was called on the last fw_unit. Alternatively, they may be accessed while
67 * holding fw_device_rwsem.
68 */
69struct fw_device {
70 atomic_t state;
71 struct fw_node *node;
72 int node_id;
73 int generation;
74 unsigned max_speed;
75 struct fw_card *card;
76 struct device device;
77
78 struct mutex client_list_mutex;
79 struct list_head client_list;
80
81 u32 *config_rom;
82 size_t config_rom_length;
83 int config_rom_retries;
84 unsigned is_local:1;
85 unsigned cmc:1;
86 unsigned bc_implemented:2;
87
88 struct delayed_work work;
89 struct fw_attribute_group attribute_group;
90};
91
92static inline struct fw_device *fw_device(struct device *dev)
93{
94 return container_of(dev, struct fw_device, device);
95}
96
97static inline int fw_device_is_shutdown(struct fw_device *device)
98{
99 return atomic_read(&device->state) == FW_DEVICE_SHUTDOWN;
100}
101
102static inline struct fw_device *fw_device_get(struct fw_device *device)
103{
104 get_device(&device->device);
105
106 return device;
107}
108
109static inline void fw_device_put(struct fw_device *device)
110{
111 put_device(&device->device);
112}
113
114struct fw_device *fw_device_get_by_devt(dev_t devt);
115int fw_device_enable_phys_dma(struct fw_device *device);
116void fw_device_set_broadcast_channel(struct fw_device *device, int generation);
117
118void fw_device_cdev_update(struct fw_device *device);
119void fw_device_cdev_remove(struct fw_device *device);
120
121extern struct rw_semaphore fw_device_rwsem;
122extern struct idr fw_device_idr;
123extern int fw_cdev_major;
124
125/*
126 * fw_unit.directory must not be accessed after device_del(&fw_unit.device).
127 */
128struct fw_unit {
129 struct device device;
130 u32 *directory;
131 struct fw_attribute_group attribute_group;
132};
133
134static inline struct fw_unit *fw_unit(struct device *dev)
135{
136 return container_of(dev, struct fw_unit, device);
137}
138
139static inline struct fw_unit *fw_unit_get(struct fw_unit *unit)
140{
141 get_device(&unit->device);
142
143 return unit;
144}
145
146static inline void fw_unit_put(struct fw_unit *unit)
147{
148 put_device(&unit->device);
149}
150
151#define CSR_OFFSET 0x40
152#define CSR_LEAF 0x80
153#define CSR_DIRECTORY 0xc0
154
155#define CSR_DESCRIPTOR 0x01
156#define CSR_VENDOR 0x03
157#define CSR_HARDWARE_VERSION 0x04
158#define CSR_NODE_CAPABILITIES 0x0c
159#define CSR_UNIT 0x11
160#define CSR_SPECIFIER_ID 0x12
161#define CSR_VERSION 0x13
162#define CSR_DEPENDENT_INFO 0x14
163#define CSR_MODEL 0x17
164#define CSR_INSTANCE 0x18
165#define CSR_DIRECTORY_ID 0x20
166
167struct fw_csr_iterator {
168 u32 *p;
169 u32 *end;
170};
171
172void fw_csr_iterator_init(struct fw_csr_iterator *ci, u32 *p);
173int fw_csr_iterator_next(struct fw_csr_iterator *ci,
174 int *key, int *value);
175
176struct fw_driver {
177 struct device_driver driver;
178 /* Called when the parent device sits through a bus reset. */
179 void (*update)(struct fw_unit *unit);
180 const struct ieee1394_device_id *id_table;
181};
182
183static inline struct fw_driver *fw_driver(struct device_driver *drv)
184{
185 return container_of(drv, struct fw_driver, driver);
186}
187
188extern const struct file_operations fw_device_ops;
189
190#endif /* __fw_device_h */