1 #ifndef _IEEE1394_HOSTS_H
2 #define _IEEE1394_HOSTS_H
4 #include <linux/wait.h>
5 #include <linux/list.h>
6 #include <linux/timer.h>
7 #include <asm/semaphore.h>
9 #include "ieee1394_types.h"
12 /* size of the array used to store config rom (in quadlets)
13 maximum is 0x100. About 0x40 is needed for the default
14 entries. So 0x80 should provide enough space for additional
16 Note: All lowlevel drivers are required to allocate at least
17 this amount of memory for the configuration rom!
19 #define CSR_CONFIG_ROM_SIZE 0x100
25 struct list_head host_list;
33 struct list_head pending_packets;
34 spinlock_t pending_pkt_lock;
35 struct timer_list timeout;
36 unsigned long timeout_interval;
38 unsigned char iso_listen_count[64];
40 int node_count; /* number of identified nodes on this bus */
41 int selfid_count; /* total number of SelfIDs received */
42 int nodes_active; /* number of nodes that are actually active */
44 nodeid_t node_id; /* node ID of this host */
45 nodeid_t irm_id; /* ID of this bus' isochronous resource manager */
46 nodeid_t busmgr_id; /* ID of this bus' bus manager */
48 /* this nodes state */
49 unsigned in_bus_reset:1;
50 unsigned is_shutdown:1;
52 /* this nodes' duties on the bus */
59 quadlet_t *topology_map;
61 struct csr_control csr;
63 /* Per node tlabel pool allocation */
64 struct hpsb_tlabel_pool tpool[64];
66 struct hpsb_host_driver *driver;
76 /* Host is requested to reset its bus and cancel all outstanding async
77 * requests. If arg == 1, it shall also attempt to become root on the
78 * bus. Return void. */
81 /* Arg is void, return value is the hardware cycle counter value. */
84 /* Set the hardware cycle counter to the value in arg, return void.
85 * FIXME - setting is probably not required. */
88 /* Configure hardware for new bus ID in arg, return void. */
91 /* If arg true, start sending cycle start packets, stop if arg == 0.
95 /* Cancel all outstanding async requests without resetting the bus.
99 /* Decrease host usage count if arg == 0, increase otherwise. Return
100 * 1 for success, 0 for failure. Increase usage may fail if the driver
101 * is in the process of shutting itself down. Decrease usage can not
105 /* Start or stop receiving isochronous channel in arg. Return void.
106 * This acts as an optimization hint, hosts are not required not to
107 * listen on unrequested channels. */
113 /* rawiso API - see iso.h for the meanings of these commands
114 (they correspond exactly to the hpsb_iso_* API functions)
115 * INIT = allocate resources
116 * START = begin transmission/reception
117 * STOP = halt transmission/reception
118 * QUEUE/RELEASE = produce/consume packets
119 * SHUTDOWN = deallocate resources
129 RECV_LISTEN_CHANNEL, /* multi-channel only */
130 RECV_UNLISTEN_CHANNEL, /* multi-channel only */
131 RECV_SET_CHANNEL_MASK, /* multi-channel only; arg is a *u64 */
140 /* 166 microsecond reset -- only type of reset available on
141 non-1394a capable IEEE 1394 controllers */
144 /* Short (arbitrated) reset -- only available on 1394a capable
145 IEEE 1394 capable controllers */
148 /* Variants, that set force_root before issueing the bus reset */
149 LONG_RESET_FORCE_ROOT, SHORT_RESET_FORCE_ROOT,
151 /* Variants, that clear force_root before issueing the bus reset */
152 LONG_RESET_NO_FORCE_ROOT, SHORT_RESET_NO_FORCE_ROOT
155 struct hpsb_host_driver {
158 /* This function must store a pointer to the configuration ROM into the
159 * location referenced to by pointer and return the size of the ROM. It
160 * may not fail. If any allocation is required, it must be done
163 size_t (*get_rom) (struct hpsb_host *host, quadlet_t **pointer);
165 /* This function shall implement packet transmission based on
166 * packet->type. It shall CRC both parts of the packet (unless
167 * packet->type == raw) and do byte-swapping as necessary or instruct
168 * the hardware to do so. It can return immediately after the packet
169 * was queued for sending. After sending, hpsb_sent_packet() has to be
170 * called. Return 0 for failure.
171 * NOTE: The function must be callable in interrupt context.
173 int (*transmit_packet) (struct hpsb_host *host,
174 struct hpsb_packet *packet);
176 /* This function requests miscellanous services from the driver, see
177 * above for command codes and expected actions. Return -1 for unknown
178 * command, though that should never happen.
180 int (*devctl) (struct hpsb_host *host, enum devctl_cmd command, int arg);
182 /* ISO transmission/reception functions. Return 0 on success, -1
183 * (or -EXXX errno code) on failure. If the low-level driver does not
184 * support the new ISO API, set isoctl to NULL.
186 int (*isoctl) (struct hpsb_iso *iso, enum isoctl_cmd command, unsigned long arg);
188 /* This function is mainly to redirect local CSR reads/locks to the iso
189 * management registers (bus manager id, bandwidth available, channels
190 * available) to the hardware registers in OHCI. reg is 0,1,2,3 for bus
191 * mgr, bwdth avail, ch avail hi, ch avail lo respectively (the same ids
192 * as OHCI uses). data and compare are the new data and expected data
193 * respectively, return value is the old value.
195 quadlet_t (*hw_csr_reg) (struct hpsb_host *host, int reg,
196 quadlet_t data, quadlet_t compare);
200 extern struct list_head hpsb_hosts;
201 extern struct semaphore hpsb_hosts_lock;
205 * In order to prevent hosts from unloading, use hpsb_ref_host(). This prevents
206 * the host from going away (e.g. makes module unloading of the driver
207 * impossible), but still can not guarantee it (e.g. PC-Card being pulled by the
208 * user). hpsb_ref_host() returns false if host could not be locked. If it is
209 * successful, host is valid as a pointer until hpsb_unref_host() (not just
210 * until after remove_host).
212 int hpsb_ref_host(struct hpsb_host *host);
213 void hpsb_unref_host(struct hpsb_host *host);
215 struct hpsb_host *hpsb_alloc_host(struct hpsb_host_driver *drv, size_t extra);
216 void hpsb_add_host(struct hpsb_host *host);
217 void hpsb_remove_host(struct hpsb_host *h);
219 /* updates the configuration rom of a host.
220 * rom_version must be the current version,
221 * otherwise it will fail with return value -1.
222 * Return value -2 indicates that the new
223 * rom version is too big.
224 * Return value 0 indicates success
226 int hpsb_update_config_rom(struct hpsb_host *host,
227 const quadlet_t *new_rom, size_t size, unsigned char rom_version);
229 /* reads the current version of the configuration rom of a host.
230 * buffersize is the size of the buffer, rom_size
231 * returns the size of the current rom image.
232 * rom_version is the version number of the fetched rom.
233 * return value -1 indicates, that the buffer was
234 * too small, 0 indicates success.
236 int hpsb_get_config_rom(struct hpsb_host *host, quadlet_t *buffer,
237 size_t buffersize, size_t *rom_size, unsigned char *rom_version);
239 #endif /* _IEEE1394_HOSTS_H */