blob: b911e2af99a3d7757e2ab51fef290feb04f1e134 [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>
Linus Torvalds1da177e2005-04-16 15:20:36 -07005#include <linux/list.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -07006#include <linux/skbuff.h>
Stefan Richterde4394f2006-07-03 12:02:29 -04007#include <linux/timer.h>
8#include <linux/types.h>
9#include <linux/workqueue.h>
10#include <asm/atomic.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070011
Stefan Richterde4394f2006-07-03 12:02:29 -040012struct pci_dev;
13struct module;
Linus Torvalds1da177e2005-04-16 15:20:36 -070014
15#include "ieee1394_types.h"
16#include "csr.h"
17
Linus Torvalds1da177e2005-04-16 15:20:36 -070018struct hpsb_packet;
19struct hpsb_iso;
20
21struct hpsb_host {
Stefan Richter741854e2005-12-01 18:52:03 -050022 struct list_head host_list;
Linus Torvalds1da177e2005-04-16 15:20:36 -070023
Stefan Richter741854e2005-12-01 18:52:03 -050024 void *hostdata;
Linus Torvalds1da177e2005-04-16 15:20:36 -070025
Stefan Richter741854e2005-12-01 18:52:03 -050026 atomic_t generation;
Linus Torvalds1da177e2005-04-16 15:20:36 -070027
28 struct sk_buff_head pending_packet_queue;
29
30 struct timer_list timeout;
31 unsigned long timeout_interval;
32
Stefan Richter741854e2005-12-01 18:52:03 -050033 unsigned char iso_listen_count[64];
Linus Torvalds1da177e2005-04-16 15:20:36 -070034
Ben Collinseaf88452006-06-12 18:12:49 -040035 int node_count; /* number of identified nodes on this bus */
36 int selfid_count; /* total number of SelfIDs received */
37 int nodes_active; /* number of nodes with active link layer */
38 u8 speed[ALL_NODES]; /* speed between each node and local node */
Linus Torvalds1da177e2005-04-16 15:20:36 -070039
Ben Collinseaf88452006-06-12 18:12:49 -040040 nodeid_t node_id; /* node ID of this host */
41 nodeid_t irm_id; /* ID of this bus' isochronous resource manager */
42 nodeid_t busmgr_id; /* ID of this bus' bus manager */
Linus Torvalds1da177e2005-04-16 15:20:36 -070043
Stefan Richter741854e2005-12-01 18:52:03 -050044 /* this nodes state */
45 unsigned in_bus_reset:1;
46 unsigned is_shutdown:1;
Stefan Richter14c0fa22005-12-01 18:51:52 -050047 unsigned resume_packet_sent:1;
Linus Torvalds1da177e2005-04-16 15:20:36 -070048
Stefan Richter741854e2005-12-01 18:52:03 -050049 /* this nodes' duties on the bus */
50 unsigned is_root:1;
51 unsigned is_cycmst:1;
52 unsigned is_irm:1;
53 unsigned is_busmgr:1;
Linus Torvalds1da177e2005-04-16 15:20:36 -070054
Stefan Richter741854e2005-12-01 18:52:03 -050055 int reset_retries;
56 quadlet_t *topology_map;
57 u8 *speed_map;
58 struct csr_control csr;
Linus Torvalds1da177e2005-04-16 15:20:36 -070059
60 /* Per node tlabel pool allocation */
Ben Collinseaf88452006-06-12 18:12:49 -040061 struct hpsb_tlabel_pool tpool[ALL_NODES];
Linus Torvalds1da177e2005-04-16 15:20:36 -070062
Stefan Richter741854e2005-12-01 18:52:03 -050063 struct hpsb_host_driver *driver;
Linus Torvalds1da177e2005-04-16 15:20:36 -070064
65 struct pci_dev *pdev;
66
67 int id;
68
69 struct device device;
70 struct class_device class_dev;
71
72 int update_config_rom;
73 struct work_struct delayed_reset;
74
75 unsigned int config_roms;
76
77 struct list_head addr_space;
Ben Collins8aef63f2006-06-12 18:13:21 -040078 u64 low_addr_space; /* upper bound of physical DMA area */
79 u64 middle_addr_space; /* upper bound of posted write area */
Linus Torvalds1da177e2005-04-16 15:20:36 -070080};
81
82
83
84enum devctl_cmd {
Stefan Richter741854e2005-12-01 18:52:03 -050085 /* Host is requested to reset its bus and cancel all outstanding async
86 * requests. If arg == 1, it shall also attempt to become root on the
87 * bus. Return void. */
88 RESET_BUS,
Linus Torvalds1da177e2005-04-16 15:20:36 -070089
Stefan Richter741854e2005-12-01 18:52:03 -050090 /* Arg is void, return value is the hardware cycle counter value. */
91 GET_CYCLE_COUNTER,
Linus Torvalds1da177e2005-04-16 15:20:36 -070092
Stefan Richter741854e2005-12-01 18:52:03 -050093 /* Set the hardware cycle counter to the value in arg, return void.
94 * FIXME - setting is probably not required. */
95 SET_CYCLE_COUNTER,
Linus Torvalds1da177e2005-04-16 15:20:36 -070096
Stefan Richter741854e2005-12-01 18:52:03 -050097 /* Configure hardware for new bus ID in arg, return void. */
98 SET_BUS_ID,
Linus Torvalds1da177e2005-04-16 15:20:36 -070099
Stefan Richter741854e2005-12-01 18:52:03 -0500100 /* If arg true, start sending cycle start packets, stop if arg == 0.
101 * Return void. */
102 ACT_CYCLE_MASTER,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700103
Stefan Richter741854e2005-12-01 18:52:03 -0500104 /* Cancel all outstanding async requests without resetting the bus.
105 * Return void. */
106 CANCEL_REQUESTS,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700107
Stefan Richter741854e2005-12-01 18:52:03 -0500108 /* Start or stop receiving isochronous channel in arg. Return void.
109 * This acts as an optimization hint, hosts are not required not to
110 * listen on unrequested channels. */
111 ISO_LISTEN_CHANNEL,
112 ISO_UNLISTEN_CHANNEL
Linus Torvalds1da177e2005-04-16 15:20:36 -0700113};
114
115enum isoctl_cmd {
116 /* rawiso API - see iso.h for the meanings of these commands
Stefan Richtere1d118f2006-07-03 12:02:28 -0400117 * (they correspond exactly to the hpsb_iso_* API functions)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700118 * INIT = allocate resources
119 * START = begin transmission/reception
120 * STOP = halt transmission/reception
121 * QUEUE/RELEASE = produce/consume packets
122 * SHUTDOWN = deallocate resources
123 */
124
125 XMIT_INIT,
126 XMIT_START,
127 XMIT_STOP,
128 XMIT_QUEUE,
129 XMIT_SHUTDOWN,
130
131 RECV_INIT,
132 RECV_LISTEN_CHANNEL, /* multi-channel only */
133 RECV_UNLISTEN_CHANNEL, /* multi-channel only */
134 RECV_SET_CHANNEL_MASK, /* multi-channel only; arg is a *u64 */
135 RECV_START,
136 RECV_STOP,
137 RECV_RELEASE,
138 RECV_SHUTDOWN,
139 RECV_FLUSH
140};
141
142enum reset_types {
Stefan Richter741854e2005-12-01 18:52:03 -0500143 /* 166 microsecond reset -- only type of reset available on
144 non-1394a capable controllers */
145 LONG_RESET,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700146
Stefan Richter741854e2005-12-01 18:52:03 -0500147 /* Short (arbitrated) reset -- only available on 1394a capable
148 controllers */
149 SHORT_RESET,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700150
Jody McIntyre3256cc12005-09-30 11:59:16 -0700151 /* Variants that set force_root before issueing the bus reset */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700152 LONG_RESET_FORCE_ROOT, SHORT_RESET_FORCE_ROOT,
153
Jody McIntyre3256cc12005-09-30 11:59:16 -0700154 /* Variants that clear force_root before issueing the bus reset */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700155 LONG_RESET_NO_FORCE_ROOT, SHORT_RESET_NO_FORCE_ROOT
156};
157
158struct hpsb_host_driver {
159 struct module *owner;
160 const char *name;
161
162 /* The hardware driver may optionally support a function that is used
163 * to set the hardware ConfigROM if the hardware supports handling
164 * reads to the ConfigROM on its own. */
Stefan Richtere1d118f2006-07-03 12:02:28 -0400165 void (*set_hw_config_rom)(struct hpsb_host *host,
166 quadlet_t *config_rom);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700167
Stefan Richter741854e2005-12-01 18:52:03 -0500168 /* This function shall implement packet transmission based on
169 * packet->type. It shall CRC both parts of the packet (unless
170 * packet->type == raw) and do byte-swapping as necessary or instruct
171 * the hardware to do so. It can return immediately after the packet
172 * was queued for sending. After sending, hpsb_sent_packet() has to be
173 * called. Return 0 on success, negative errno on failure.
174 * NOTE: The function must be callable in interrupt context.
175 */
Stefan Richtere1d118f2006-07-03 12:02:28 -0400176 int (*transmit_packet)(struct hpsb_host *host,
177 struct hpsb_packet *packet);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700178
Stefan Richter741854e2005-12-01 18:52:03 -0500179 /* This function requests miscellanous services from the driver, see
180 * above for command codes and expected actions. Return -1 for unknown
181 * command, though that should never happen.
182 */
Stefan Richtere1d118f2006-07-03 12:02:28 -0400183 int (*devctl)(struct hpsb_host *host, enum devctl_cmd command, int arg);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700184
185 /* ISO transmission/reception functions. Return 0 on success, -1
186 * (or -EXXX errno code) on failure. If the low-level driver does not
187 * support the new ISO API, set isoctl to NULL.
188 */
Stefan Richtere1d118f2006-07-03 12:02:28 -0400189 int (*isoctl)(struct hpsb_iso *iso, enum isoctl_cmd command,
190 unsigned long arg);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700191
Stefan Richter741854e2005-12-01 18:52:03 -0500192 /* This function is mainly to redirect local CSR reads/locks to the iso
193 * management registers (bus manager id, bandwidth available, channels
194 * available) to the hardware registers in OHCI. reg is 0,1,2,3 for bus
195 * mgr, bwdth avail, ch avail hi, ch avail lo respectively (the same ids
196 * as OHCI uses). data and compare are the new data and expected data
197 * respectively, return value is the old value.
198 */
199 quadlet_t (*hw_csr_reg) (struct hpsb_host *host, int reg,
200 quadlet_t data, quadlet_t compare);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700201};
202
Linus Torvalds1da177e2005-04-16 15:20:36 -0700203struct hpsb_host *hpsb_alloc_host(struct hpsb_host_driver *drv, size_t extra,
204 struct device *dev);
205int hpsb_add_host(struct hpsb_host *host);
206void hpsb_remove_host(struct hpsb_host *h);
207
208/* The following 2 functions are deprecated and will be removed when the
209 * raw1394/libraw1394 update is complete. */
210int hpsb_update_config_rom(struct hpsb_host *host,
211 const quadlet_t *new_rom, size_t size, unsigned char rom_version);
212int hpsb_get_config_rom(struct hpsb_host *host, quadlet_t *buffer,
213 size_t buffersize, size_t *rom_size, unsigned char *rom_version);
214
215/* Updates the configuration rom image of a host. rom_version must be the
216 * current version, otherwise it will fail with return value -1. If this
217 * host does not support config-rom-update, it will return -EINVAL.
218 * Return value 0 indicates success.
219 */
220int hpsb_update_config_rom_image(struct hpsb_host *host);
221
222#endif /* _IEEE1394_HOSTS_H */