blob: 49c359022c5459bb8d79b787f6faf291d62291d4 [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>
Stefan Richterde4394f2006-07-03 12:02:29 -04006#include <linux/timer.h>
7#include <linux/types.h>
8#include <linux/workqueue.h>
9#include <asm/atomic.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070010
Stefan Richterde4394f2006-07-03 12:02:29 -040011struct pci_dev;
12struct module;
Linus Torvalds1da177e2005-04-16 15:20:36 -070013
14#include "ieee1394_types.h"
15#include "csr.h"
Stefan Richtere47c1fe2008-11-26 01:34:25 +010016#include "highlevel.h"
Linus Torvalds1da177e2005-04-16 15:20:36 -070017
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
Stefan Richter7542e0e2007-03-25 22:22:40 +020028 struct list_head pending_packets;
Linus Torvalds1da177e2005-04-16 15:20:36 -070029 struct timer_list timeout;
30 unsigned long timeout_interval;
31
Ben Collinseaf88452006-06-12 18:12:49 -040032 int node_count; /* number of identified nodes on this bus */
33 int selfid_count; /* total number of SelfIDs received */
34 int nodes_active; /* number of nodes with active link layer */
Linus Torvalds1da177e2005-04-16 15:20:36 -070035
Ben Collinseaf88452006-06-12 18:12:49 -040036 nodeid_t node_id; /* node ID of this host */
37 nodeid_t irm_id; /* ID of this bus' isochronous resource manager */
38 nodeid_t busmgr_id; /* ID of this bus' bus manager */
Linus Torvalds1da177e2005-04-16 15:20:36 -070039
Stefan Richter741854e2005-12-01 18:52:03 -050040 /* this nodes state */
41 unsigned in_bus_reset:1;
42 unsigned is_shutdown:1;
Stefan Richter14c0fa22005-12-01 18:51:52 -050043 unsigned resume_packet_sent:1;
Linus Torvalds1da177e2005-04-16 15:20:36 -070044
Stefan Richter741854e2005-12-01 18:52:03 -050045 /* this nodes' duties on the bus */
46 unsigned is_root:1;
47 unsigned is_cycmst:1;
48 unsigned is_irm:1;
49 unsigned is_busmgr:1;
Linus Torvalds1da177e2005-04-16 15:20:36 -070050
Stefan Richter741854e2005-12-01 18:52:03 -050051 int reset_retries;
52 quadlet_t *topology_map;
53 u8 *speed_map;
Linus Torvalds1da177e2005-04-16 15:20:36 -070054
55 int id;
Stefan Richter99519032006-07-02 14:17:00 +020056 struct hpsb_host_driver *driver;
57 struct pci_dev *pdev;
Linus Torvalds1da177e2005-04-16 15:20:36 -070058 struct device device;
Kay Sieversdd7f2922007-05-25 11:50:53 +020059 struct device host_dev;
Linus Torvalds1da177e2005-04-16 15:20:36 -070060
David Howellsc4028952006-11-22 14:57:56 +000061 struct delayed_work delayed_reset;
Stefan Richterd06170a2007-01-07 21:51:48 +010062 unsigned config_roms:31;
63 unsigned update_config_rom:1;
Linus Torvalds1da177e2005-04-16 15:20:36 -070064
65 struct list_head addr_space;
Ben Collins8aef63f2006-06-12 18:13:21 -040066 u64 low_addr_space; /* upper bound of physical DMA area */
67 u64 middle_addr_space; /* upper bound of posted write area */
Stefan Richter99519032006-07-02 14:17:00 +020068
69 u8 speed[ALL_NODES]; /* speed between each node and local node */
70
71 /* per node tlabel allocation */
72 u8 next_tl[ALL_NODES];
73 struct { DECLARE_BITMAP(map, 64); } tl_pool[ALL_NODES];
74
75 struct csr_control csr;
Stefan Richtere47c1fe2008-11-26 01:34:25 +010076
77 struct hpsb_address_serve dummy_zero_addr;
78 struct hpsb_address_serve dummy_max_addr;
Linus Torvalds1da177e2005-04-16 15:20:36 -070079};
80
Linus Torvalds1da177e2005-04-16 15:20:36 -070081enum devctl_cmd {
Stefan Richter741854e2005-12-01 18:52:03 -050082 /* Host is requested to reset its bus and cancel all outstanding async
83 * requests. If arg == 1, it shall also attempt to become root on the
84 * bus. Return void. */
85 RESET_BUS,
Linus Torvalds1da177e2005-04-16 15:20:36 -070086
Stefan Richter741854e2005-12-01 18:52:03 -050087 /* Arg is void, return value is the hardware cycle counter value. */
88 GET_CYCLE_COUNTER,
Linus Torvalds1da177e2005-04-16 15:20:36 -070089
Stefan Richter741854e2005-12-01 18:52:03 -050090 /* Set the hardware cycle counter to the value in arg, return void.
91 * FIXME - setting is probably not required. */
92 SET_CYCLE_COUNTER,
Linus Torvalds1da177e2005-04-16 15:20:36 -070093
Stefan Richter741854e2005-12-01 18:52:03 -050094 /* Configure hardware for new bus ID in arg, return void. */
95 SET_BUS_ID,
Linus Torvalds1da177e2005-04-16 15:20:36 -070096
Stefan Richter741854e2005-12-01 18:52:03 -050097 /* If arg true, start sending cycle start packets, stop if arg == 0.
98 * Return void. */
99 ACT_CYCLE_MASTER,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700100
Stefan Richter741854e2005-12-01 18:52:03 -0500101 /* Cancel all outstanding async requests without resetting the bus.
102 * Return void. */
103 CANCEL_REQUESTS,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700104};
105
106enum isoctl_cmd {
107 /* rawiso API - see iso.h for the meanings of these commands
Stefan Richtere1d118f2006-07-03 12:02:28 -0400108 * (they correspond exactly to the hpsb_iso_* API functions)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700109 * INIT = allocate resources
110 * START = begin transmission/reception
111 * STOP = halt transmission/reception
112 * QUEUE/RELEASE = produce/consume packets
113 * SHUTDOWN = deallocate resources
114 */
115
116 XMIT_INIT,
117 XMIT_START,
118 XMIT_STOP,
119 XMIT_QUEUE,
120 XMIT_SHUTDOWN,
121
122 RECV_INIT,
123 RECV_LISTEN_CHANNEL, /* multi-channel only */
124 RECV_UNLISTEN_CHANNEL, /* multi-channel only */
125 RECV_SET_CHANNEL_MASK, /* multi-channel only; arg is a *u64 */
126 RECV_START,
127 RECV_STOP,
128 RECV_RELEASE,
129 RECV_SHUTDOWN,
130 RECV_FLUSH
131};
132
133enum reset_types {
Stefan Richter741854e2005-12-01 18:52:03 -0500134 /* 166 microsecond reset -- only type of reset available on
135 non-1394a capable controllers */
136 LONG_RESET,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700137
Stefan Richter741854e2005-12-01 18:52:03 -0500138 /* Short (arbitrated) reset -- only available on 1394a capable
139 controllers */
140 SHORT_RESET,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700141
Jody McIntyre3256cc12005-09-30 11:59:16 -0700142 /* Variants that set force_root before issueing the bus reset */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700143 LONG_RESET_FORCE_ROOT, SHORT_RESET_FORCE_ROOT,
144
Jody McIntyre3256cc12005-09-30 11:59:16 -0700145 /* Variants that clear force_root before issueing the bus reset */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700146 LONG_RESET_NO_FORCE_ROOT, SHORT_RESET_NO_FORCE_ROOT
147};
148
149struct hpsb_host_driver {
150 struct module *owner;
151 const char *name;
152
153 /* The hardware driver may optionally support a function that is used
154 * to set the hardware ConfigROM if the hardware supports handling
155 * reads to the ConfigROM on its own. */
Stefan Richtere1d118f2006-07-03 12:02:28 -0400156 void (*set_hw_config_rom)(struct hpsb_host *host,
Harvey Harrisondebb4802008-12-13 15:02:34 -0800157 __be32 *config_rom);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700158
Stefan Richter741854e2005-12-01 18:52:03 -0500159 /* This function shall implement packet transmission based on
160 * packet->type. It shall CRC both parts of the packet (unless
161 * packet->type == raw) and do byte-swapping as necessary or instruct
162 * the hardware to do so. It can return immediately after the packet
163 * was queued for sending. After sending, hpsb_sent_packet() has to be
164 * called. Return 0 on success, negative errno on failure.
165 * NOTE: The function must be callable in interrupt context.
166 */
Stefan Richtere1d118f2006-07-03 12:02:28 -0400167 int (*transmit_packet)(struct hpsb_host *host,
168 struct hpsb_packet *packet);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700169
Stefan Richter741854e2005-12-01 18:52:03 -0500170 /* This function requests miscellanous services from the driver, see
171 * above for command codes and expected actions. Return -1 for unknown
172 * command, though that should never happen.
173 */
Stefan Richtere1d118f2006-07-03 12:02:28 -0400174 int (*devctl)(struct hpsb_host *host, enum devctl_cmd command, int arg);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700175
176 /* ISO transmission/reception functions. Return 0 on success, -1
177 * (or -EXXX errno code) on failure. If the low-level driver does not
178 * support the new ISO API, set isoctl to NULL.
179 */
Stefan Richtere1d118f2006-07-03 12:02:28 -0400180 int (*isoctl)(struct hpsb_iso *iso, enum isoctl_cmd command,
181 unsigned long arg);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700182
Stefan Richter741854e2005-12-01 18:52:03 -0500183 /* This function is mainly to redirect local CSR reads/locks to the iso
184 * management registers (bus manager id, bandwidth available, channels
185 * available) to the hardware registers in OHCI. reg is 0,1,2,3 for bus
186 * mgr, bwdth avail, ch avail hi, ch avail lo respectively (the same ids
187 * as OHCI uses). data and compare are the new data and expected data
188 * respectively, return value is the old value.
189 */
190 quadlet_t (*hw_csr_reg) (struct hpsb_host *host, int reg,
191 quadlet_t data, quadlet_t compare);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700192};
193
Linus Torvalds1da177e2005-04-16 15:20:36 -0700194struct hpsb_host *hpsb_alloc_host(struct hpsb_host_driver *drv, size_t extra,
195 struct device *dev);
196int hpsb_add_host(struct hpsb_host *host);
Stefan Richter33601772007-01-07 21:49:27 +0100197void hpsb_resume_host(struct hpsb_host *host);
198void hpsb_remove_host(struct hpsb_host *host);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700199int hpsb_update_config_rom_image(struct hpsb_host *host);
200
201#endif /* _IEEE1394_HOSTS_H */