blob: 9ddc6628e71024381162f7db6135eb7a0a9e48c0 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001#ifndef _IEEE1394_HOSTS_H
2#define _IEEE1394_HOSTS_H
3
4#include <linux/device.h>
5#include <linux/wait.h>
6#include <linux/list.h>
7#include <linux/timer.h>
8#include <linux/skbuff.h>
9
10#include <asm/semaphore.h>
11
12#include "ieee1394_types.h"
13#include "csr.h"
14
15
16struct hpsb_packet;
17struct hpsb_iso;
18
19struct hpsb_host {
Stefan Richter741854e2005-12-01 18:52:03 -050020 struct list_head host_list;
Linus Torvalds1da177e2005-04-16 15:20:36 -070021
Stefan Richter741854e2005-12-01 18:52:03 -050022 void *hostdata;
Linus Torvalds1da177e2005-04-16 15:20:36 -070023
Stefan Richter741854e2005-12-01 18:52:03 -050024 atomic_t generation;
Linus Torvalds1da177e2005-04-16 15:20:36 -070025
26 struct sk_buff_head pending_packet_queue;
27
28 struct timer_list timeout;
29 unsigned long timeout_interval;
30
Stefan Richter741854e2005-12-01 18:52:03 -050031 unsigned char iso_listen_count[64];
Linus Torvalds1da177e2005-04-16 15:20:36 -070032
Ben Collinseaf88452006-06-12 18:12:49 -040033 int node_count; /* number of identified nodes on this bus */
34 int selfid_count; /* total number of SelfIDs received */
35 int nodes_active; /* number of nodes with active link layer */
36 u8 speed[ALL_NODES]; /* speed between each node and local node */
Linus Torvalds1da177e2005-04-16 15:20:36 -070037
Ben Collinseaf88452006-06-12 18:12:49 -040038 nodeid_t node_id; /* node ID of this host */
39 nodeid_t irm_id; /* ID of this bus' isochronous resource manager */
40 nodeid_t busmgr_id; /* ID of this bus' bus manager */
Linus Torvalds1da177e2005-04-16 15:20:36 -070041
Stefan Richter741854e2005-12-01 18:52:03 -050042 /* this nodes state */
43 unsigned in_bus_reset:1;
44 unsigned is_shutdown:1;
Stefan Richter14c0fa22005-12-01 18:51:52 -050045 unsigned resume_packet_sent:1;
Linus Torvalds1da177e2005-04-16 15:20:36 -070046
Stefan Richter741854e2005-12-01 18:52:03 -050047 /* this nodes' duties on the bus */
48 unsigned is_root:1;
49 unsigned is_cycmst:1;
50 unsigned is_irm:1;
51 unsigned is_busmgr:1;
Linus Torvalds1da177e2005-04-16 15:20:36 -070052
Stefan Richter741854e2005-12-01 18:52:03 -050053 int reset_retries;
54 quadlet_t *topology_map;
55 u8 *speed_map;
56 struct csr_control csr;
Linus Torvalds1da177e2005-04-16 15:20:36 -070057
58 /* Per node tlabel pool allocation */
Ben Collinseaf88452006-06-12 18:12:49 -040059 struct hpsb_tlabel_pool tpool[ALL_NODES];
Linus Torvalds1da177e2005-04-16 15:20:36 -070060
Stefan Richter741854e2005-12-01 18:52:03 -050061 struct hpsb_host_driver *driver;
Linus Torvalds1da177e2005-04-16 15:20:36 -070062
63 struct pci_dev *pdev;
64
65 int id;
66
67 struct device device;
68 struct class_device class_dev;
69
70 int update_config_rom;
71 struct work_struct delayed_reset;
72
73 unsigned int config_roms;
74
75 struct list_head addr_space;
76};
77
78
79
80enum devctl_cmd {
Stefan Richter741854e2005-12-01 18:52:03 -050081 /* Host is requested to reset its bus and cancel all outstanding async
82 * requests. If arg == 1, it shall also attempt to become root on the
83 * bus. Return void. */
84 RESET_BUS,
Linus Torvalds1da177e2005-04-16 15:20:36 -070085
Stefan Richter741854e2005-12-01 18:52:03 -050086 /* Arg is void, return value is the hardware cycle counter value. */
87 GET_CYCLE_COUNTER,
Linus Torvalds1da177e2005-04-16 15:20:36 -070088
Stefan Richter741854e2005-12-01 18:52:03 -050089 /* Set the hardware cycle counter to the value in arg, return void.
90 * FIXME - setting is probably not required. */
91 SET_CYCLE_COUNTER,
Linus Torvalds1da177e2005-04-16 15:20:36 -070092
Stefan Richter741854e2005-12-01 18:52:03 -050093 /* Configure hardware for new bus ID in arg, return void. */
94 SET_BUS_ID,
Linus Torvalds1da177e2005-04-16 15:20:36 -070095
Stefan Richter741854e2005-12-01 18:52:03 -050096 /* If arg true, start sending cycle start packets, stop if arg == 0.
97 * Return void. */
98 ACT_CYCLE_MASTER,
Linus Torvalds1da177e2005-04-16 15:20:36 -070099
Stefan Richter741854e2005-12-01 18:52:03 -0500100 /* Cancel all outstanding async requests without resetting the bus.
101 * Return void. */
102 CANCEL_REQUESTS,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700103
Stefan Richter741854e2005-12-01 18:52:03 -0500104 /* 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. */
107 ISO_LISTEN_CHANNEL,
108 ISO_UNLISTEN_CHANNEL
Linus Torvalds1da177e2005-04-16 15:20:36 -0700109};
110
111enum isoctl_cmd {
112 /* rawiso API - see iso.h for the meanings of these commands
113 (they correspond exactly to the hpsb_iso_* API functions)
114 * INIT = allocate resources
115 * START = begin transmission/reception
116 * STOP = halt transmission/reception
117 * QUEUE/RELEASE = produce/consume packets
118 * SHUTDOWN = deallocate resources
119 */
120
121 XMIT_INIT,
122 XMIT_START,
123 XMIT_STOP,
124 XMIT_QUEUE,
125 XMIT_SHUTDOWN,
126
127 RECV_INIT,
128 RECV_LISTEN_CHANNEL, /* multi-channel only */
129 RECV_UNLISTEN_CHANNEL, /* multi-channel only */
130 RECV_SET_CHANNEL_MASK, /* multi-channel only; arg is a *u64 */
131 RECV_START,
132 RECV_STOP,
133 RECV_RELEASE,
134 RECV_SHUTDOWN,
135 RECV_FLUSH
136};
137
138enum reset_types {
Stefan Richter741854e2005-12-01 18:52:03 -0500139 /* 166 microsecond reset -- only type of reset available on
140 non-1394a capable controllers */
141 LONG_RESET,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700142
Stefan Richter741854e2005-12-01 18:52:03 -0500143 /* Short (arbitrated) reset -- only available on 1394a capable
144 controllers */
145 SHORT_RESET,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700146
Jody McIntyre3256cc12005-09-30 11:59:16 -0700147 /* Variants that set force_root before issueing the bus reset */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700148 LONG_RESET_FORCE_ROOT, SHORT_RESET_FORCE_ROOT,
149
Jody McIntyre3256cc12005-09-30 11:59:16 -0700150 /* Variants that clear force_root before issueing the bus reset */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700151 LONG_RESET_NO_FORCE_ROOT, SHORT_RESET_NO_FORCE_ROOT
152};
153
154struct hpsb_host_driver {
155 struct module *owner;
156 const char *name;
157
158 /* The hardware driver may optionally support a function that is used
159 * to set the hardware ConfigROM if the hardware supports handling
160 * reads to the ConfigROM on its own. */
161 void (*set_hw_config_rom) (struct hpsb_host *host, quadlet_t *config_rom);
162
Stefan Richter741854e2005-12-01 18:52:03 -0500163 /* This function shall implement packet transmission based on
164 * packet->type. It shall CRC both parts of the packet (unless
165 * packet->type == raw) and do byte-swapping as necessary or instruct
166 * the hardware to do so. It can return immediately after the packet
167 * was queued for sending. After sending, hpsb_sent_packet() has to be
168 * called. Return 0 on success, negative errno on failure.
169 * NOTE: The function must be callable in interrupt context.
170 */
171 int (*transmit_packet) (struct hpsb_host *host,
172 struct hpsb_packet *packet);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700173
Stefan Richter741854e2005-12-01 18:52:03 -0500174 /* This function requests miscellanous services from the driver, see
175 * above for command codes and expected actions. Return -1 for unknown
176 * command, though that should never happen.
177 */
178 int (*devctl) (struct hpsb_host *host, enum devctl_cmd command, int arg);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700179
180 /* ISO transmission/reception functions. Return 0 on success, -1
181 * (or -EXXX errno code) on failure. If the low-level driver does not
182 * support the new ISO API, set isoctl to NULL.
183 */
184 int (*isoctl) (struct hpsb_iso *iso, enum isoctl_cmd command, unsigned long arg);
185
Stefan Richter741854e2005-12-01 18:52:03 -0500186 /* This function is mainly to redirect local CSR reads/locks to the iso
187 * management registers (bus manager id, bandwidth available, channels
188 * available) to the hardware registers in OHCI. reg is 0,1,2,3 for bus
189 * mgr, bwdth avail, ch avail hi, ch avail lo respectively (the same ids
190 * as OHCI uses). data and compare are the new data and expected data
191 * respectively, return value is the old value.
192 */
193 quadlet_t (*hw_csr_reg) (struct hpsb_host *host, int reg,
194 quadlet_t data, quadlet_t compare);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700195};
196
197
198struct hpsb_host *hpsb_alloc_host(struct hpsb_host_driver *drv, size_t extra,
199 struct device *dev);
200int hpsb_add_host(struct hpsb_host *host);
201void hpsb_remove_host(struct hpsb_host *h);
202
203/* The following 2 functions are deprecated and will be removed when the
204 * raw1394/libraw1394 update is complete. */
205int hpsb_update_config_rom(struct hpsb_host *host,
206 const quadlet_t *new_rom, size_t size, unsigned char rom_version);
207int hpsb_get_config_rom(struct hpsb_host *host, quadlet_t *buffer,
208 size_t buffersize, size_t *rom_size, unsigned char *rom_version);
209
210/* Updates the configuration rom image of a host. rom_version must be the
211 * current version, otherwise it will fail with return value -1. If this
212 * host does not support config-rom-update, it will return -EINVAL.
213 * Return value 0 indicates success.
214 */
215int hpsb_update_config_rom_image(struct hpsb_host *host);
216
217#endif /* _IEEE1394_HOSTS_H */