1 #ifndef _IEEE1394_HOSTS_H
2 #define _IEEE1394_HOSTS_H
4 #include <linux/wait.h>
5 #include <linux/list.h>
6 #include <asm/semaphore.h>
8 #include "ieee1394_types.h"
11 /* size of the array used to store config rom (in quadlets)
12 maximum is 0x100. About 0x40 is needed for the default
13 entries. So 0x80 should provide enough space for additional
15 Note: All lowlevel drivers are required to allocate at least
16 this amount of memory for the configuration rom!
18 #define CSR_CONFIG_ROM_SIZE 0x100
23 struct list_head host_list;
31 struct list_head pending_packets;
32 spinlock_t pending_pkt_lock;
33 struct hpsb_queue_struct timeout_tq;
35 /* A bitmask where a set bit means that this tlabel is in use.
36 * FIXME - should be handled per node instead of per bus. */
38 struct semaphore tlabel_count;
39 spinlock_t tlabel_lock;
42 unsigned char iso_listen_count[64];
44 int node_count; /* number of identified nodes on this bus */
45 int selfid_count; /* total number of SelfIDs received */
46 int nodes_active; /* number of nodes that are actually active */
48 nodeid_t node_id; /* node ID of this host */
49 nodeid_t irm_id; /* ID of this bus' isochronous resource manager */
50 nodeid_t busmgr_id; /* ID of this bus' bus manager */
52 /* this nodes state */
53 unsigned in_bus_reset:1;
54 unsigned is_shutdown:1;
56 /* this nodes' duties on the bus */
63 quadlet_t *topology_map;
65 struct csr_control csr;
67 struct hpsb_host_driver *driver;
75 /* Host is requested to reset its bus and cancel all outstanding async
76 * requests. If arg == 1, it shall also attempt to become root on the
77 * bus. Return void. */
80 /* Arg is void, return value is the hardware cycle counter value. */
83 /* Set the hardware cycle counter to the value in arg, return void.
84 * FIXME - setting is probably not required. */
87 /* Configure hardware for new bus ID in arg, return void. */
90 /* If arg true, start sending cycle start packets, stop if arg == 0.
94 /* Cancel all outstanding async requests without resetting the bus.
98 /* Decrease host usage count if arg == 0, increase otherwise. Return
99 * 1 for success, 0 for failure. Increase usage may fail if the driver
100 * is in the process of shutting itself down. Decrease usage can not
104 /* Start or stop receiving isochronous channel in arg. Return void.
105 * This acts as an optimization hint, hosts are not required not to
106 * listen on unrequested channels. */
112 /* 166 microsecond reset -- only type of reset available on
113 non-1394a capable IEEE 1394 controllers */
116 /* Short (arbitrated) reset -- only available on 1394a capable
117 IEEE 1394 capable controllers */
121 struct hpsb_host_driver {
124 /* This function must store a pointer to the configuration ROM into the
125 * location referenced to by pointer and return the size of the ROM. It
126 * may not fail. If any allocation is required, it must be done
129 size_t (*get_rom) (struct hpsb_host *host, quadlet_t **pointer);
131 /* This function shall implement packet transmission based on
132 * packet->type. It shall CRC both parts of the packet (unless
133 * packet->type == raw) and do byte-swapping as necessary or instruct
134 * the hardware to do so. It can return immediately after the packet
135 * was queued for sending. After sending, hpsb_sent_packet() has to be
136 * called. Return 0 for failure.
137 * NOTE: The function must be callable in interrupt context.
139 int (*transmit_packet) (struct hpsb_host *host,
140 struct hpsb_packet *packet);
142 /* This function requests miscellanous services from the driver, see
143 * above for command codes and expected actions. Return -1 for unknown
144 * command, though that should never happen.
146 int (*devctl) (struct hpsb_host *host, enum devctl_cmd command, int arg);
148 /* This function is mainly to redirect local CSR reads/locks to the iso
149 * management registers (bus manager id, bandwidth available, channels
150 * available) to the hardware registers in OHCI. reg is 0,1,2,3 for bus
151 * mgr, bwdth avail, ch avail hi, ch avail lo respectively (the same ids
152 * as OHCI uses). data and compare are the new data and expected data
153 * respectively, return value is the old value.
155 quadlet_t (*hw_csr_reg) (struct hpsb_host *host, int reg,
156 quadlet_t data, quadlet_t compare);
159 /* core internal use */
160 void register_builtin_lowlevels(void);
162 /* high level internal use */
163 struct hpsb_highlevel;
164 void hl_all_hosts(void (*function)(struct hpsb_host*));
168 * In order to prevent hosts from unloading, use hpsb_ref_host(). This prevents
169 * the host from going away (e.g. makes module unloading of the driver
170 * impossible), but still can not guarantee it (e.g. PC-Card being pulled by the
171 * user). hpsb_ref_host() returns false if host could not be locked. If it is
172 * successful, host is valid as a pointer until hpsb_unref_host() (not just
173 * until after remove_host).
175 int hpsb_ref_host(struct hpsb_host *host);
176 void hpsb_unref_host(struct hpsb_host *host);
178 struct hpsb_host *hpsb_alloc_host(struct hpsb_host_driver *drv, size_t extra);
179 void hpsb_add_host(struct hpsb_host *host);
180 void hpsb_remove_host(struct hpsb_host *h);
182 /* updates the configuration rom of a host.
183 * rom_version must be the current version,
184 * otherwise it will fail with return value -1.
185 * Return value -2 indicates that the new
186 * rom version is too big.
187 * Return value 0 indicates success
189 int hpsb_update_config_rom(struct hpsb_host *host,
190 const quadlet_t *new_rom, size_t size, unsigned char rom_version);
192 /* reads the current version of the configuration rom of a host.
193 * buffersize is the size of the buffer, rom_size
194 * returns the size of the current rom image.
195 * rom_version is the version number of the fetched rom.
196 * return value -1 indicates, that the buffer was
197 * too small, 0 indicates success.
199 int hpsb_get_config_rom(struct hpsb_host *host, quadlet_t *buffer,
200 size_t buffersize, size_t *rom_size, unsigned char *rom_version);
202 #endif /* _IEEE1394_HOSTS_H */