Commit | Line | Data |
---|---|---|
1da177e4 LT |
1 | #ifndef _IEEE1394_HOSTS_H |
2 | #define _IEEE1394_HOSTS_H | |
3 | ||
4 | #include <linux/device.h> | |
1da177e4 | 5 | #include <linux/list.h> |
de4394f1 SR |
6 | #include <linux/timer.h> |
7 | #include <linux/types.h> | |
8 | #include <linux/workqueue.h> | |
9 | #include <asm/atomic.h> | |
1da177e4 | 10 | |
de4394f1 SR |
11 | struct pci_dev; |
12 | struct module; | |
1da177e4 LT |
13 | |
14 | #include "ieee1394_types.h" | |
15 | #include "csr.h" | |
16 | ||
1da177e4 LT |
17 | struct hpsb_packet; |
18 | struct hpsb_iso; | |
19 | ||
20 | struct hpsb_host { | |
741854e4 | 21 | struct list_head host_list; |
1da177e4 | 22 | |
741854e4 | 23 | void *hostdata; |
1da177e4 | 24 | |
741854e4 | 25 | atomic_t generation; |
1da177e4 | 26 | |
7542e0e6 | 27 | struct list_head pending_packets; |
1da177e4 LT |
28 | struct timer_list timeout; |
29 | unsigned long timeout_interval; | |
30 | ||
eaf88450 BC |
31 | int node_count; /* number of identified nodes on this bus */ |
32 | int selfid_count; /* total number of SelfIDs received */ | |
33 | int nodes_active; /* number of nodes with active link layer */ | |
1da177e4 | 34 | |
eaf88450 BC |
35 | nodeid_t node_id; /* node ID of this host */ |
36 | nodeid_t irm_id; /* ID of this bus' isochronous resource manager */ | |
37 | nodeid_t busmgr_id; /* ID of this bus' bus manager */ | |
1da177e4 | 38 | |
741854e4 SR |
39 | /* this nodes state */ |
40 | unsigned in_bus_reset:1; | |
41 | unsigned is_shutdown:1; | |
14c0fa24 | 42 | unsigned resume_packet_sent:1; |
1da177e4 | 43 | |
741854e4 SR |
44 | /* this nodes' duties on the bus */ |
45 | unsigned is_root:1; | |
46 | unsigned is_cycmst:1; | |
47 | unsigned is_irm:1; | |
48 | unsigned is_busmgr:1; | |
1da177e4 | 49 | |
741854e4 SR |
50 | int reset_retries; |
51 | quadlet_t *topology_map; | |
52 | u8 *speed_map; | |
1da177e4 | 53 | |
9951903e | 54 | int id; |
741854e4 | 55 | struct hpsb_host_driver *driver; |
1da177e4 | 56 | struct pci_dev *pdev; |
1da177e4 | 57 | struct device device; |
dd7f2928 | 58 | struct device host_dev; |
1da177e4 | 59 | |
c4028958 | 60 | struct delayed_work delayed_reset; |
d06170a9 SR |
61 | unsigned config_roms:31; |
62 | unsigned update_config_rom:1; | |
1da177e4 LT |
63 | |
64 | struct list_head addr_space; | |
8aef63ff BC |
65 | u64 low_addr_space; /* upper bound of physical DMA area */ |
66 | u64 middle_addr_space; /* upper bound of posted write area */ | |
1da177e4 | 67 | |
9951903e | 68 | u8 speed[ALL_NODES]; /* speed between each node and local node */ |
1da177e4 | 69 | |
9951903e SR |
70 | /* per node tlabel allocation */ |
71 | u8 next_tl[ALL_NODES]; | |
72 | struct { DECLARE_BITMAP(map, 64); } tl_pool[ALL_NODES]; | |
73 | ||
74 | struct csr_control csr; | |
75 | }; | |
1da177e4 LT |
76 | |
77 | enum devctl_cmd { | |
741854e4 SR |
78 | /* Host is requested to reset its bus and cancel all outstanding async |
79 | * requests. If arg == 1, it shall also attempt to become root on the | |
80 | * bus. Return void. */ | |
81 | RESET_BUS, | |
82 | ||
83 | /* Arg is void, return value is the hardware cycle counter value. */ | |
84 | GET_CYCLE_COUNTER, | |
85 | ||
86 | /* Set the hardware cycle counter to the value in arg, return void. | |
87 | * FIXME - setting is probably not required. */ | |
88 | SET_CYCLE_COUNTER, | |
89 | ||
90 | /* Configure hardware for new bus ID in arg, return void. */ | |
91 | SET_BUS_ID, | |
92 | ||
93 | /* If arg true, start sending cycle start packets, stop if arg == 0. | |
94 | * Return void. */ | |
95 | ACT_CYCLE_MASTER, | |
96 | ||
97 | /* Cancel all outstanding async requests without resetting the bus. | |
98 | * Return void. */ | |
99 | CANCEL_REQUESTS, | |
1da177e4 LT |
100 | }; |
101 | ||
102 | enum isoctl_cmd { | |
103 | /* rawiso API - see iso.h for the meanings of these commands | |
e1d118f1 | 104 | * (they correspond exactly to the hpsb_iso_* API functions) |
1da177e4 LT |
105 | * INIT = allocate resources |
106 | * START = begin transmission/reception | |
107 | * STOP = halt transmission/reception | |
108 | * QUEUE/RELEASE = produce/consume packets | |
109 | * SHUTDOWN = deallocate resources | |
110 | */ | |
111 | ||
112 | XMIT_INIT, | |
113 | XMIT_START, | |
114 | XMIT_STOP, | |
115 | XMIT_QUEUE, | |
116 | XMIT_SHUTDOWN, | |
117 | ||
118 | RECV_INIT, | |
119 | RECV_LISTEN_CHANNEL, /* multi-channel only */ | |
120 | RECV_UNLISTEN_CHANNEL, /* multi-channel only */ | |
121 | RECV_SET_CHANNEL_MASK, /* multi-channel only; arg is a *u64 */ | |
122 | RECV_START, | |
123 | RECV_STOP, | |
124 | RECV_RELEASE, | |
125 | RECV_SHUTDOWN, | |
126 | RECV_FLUSH | |
127 | }; | |
128 | ||
129 | enum reset_types { | |
741854e4 SR |
130 | /* 166 microsecond reset -- only type of reset available on |
131 | non-1394a capable controllers */ | |
132 | LONG_RESET, | |
1da177e4 | 133 | |
741854e4 SR |
134 | /* Short (arbitrated) reset -- only available on 1394a capable |
135 | controllers */ | |
136 | SHORT_RESET, | |
1da177e4 | 137 | |
3256cc13 | 138 | /* Variants that set force_root before issueing the bus reset */ |
1da177e4 LT |
139 | LONG_RESET_FORCE_ROOT, SHORT_RESET_FORCE_ROOT, |
140 | ||
3256cc13 | 141 | /* Variants that clear force_root before issueing the bus reset */ |
1da177e4 LT |
142 | LONG_RESET_NO_FORCE_ROOT, SHORT_RESET_NO_FORCE_ROOT |
143 | }; | |
144 | ||
145 | struct hpsb_host_driver { | |
146 | struct module *owner; | |
147 | const char *name; | |
148 | ||
149 | /* The hardware driver may optionally support a function that is used | |
150 | * to set the hardware ConfigROM if the hardware supports handling | |
151 | * reads to the ConfigROM on its own. */ | |
e1d118f1 SR |
152 | void (*set_hw_config_rom)(struct hpsb_host *host, |
153 | quadlet_t *config_rom); | |
1da177e4 | 154 | |
741854e4 SR |
155 | /* This function shall implement packet transmission based on |
156 | * packet->type. It shall CRC both parts of the packet (unless | |
157 | * packet->type == raw) and do byte-swapping as necessary or instruct | |
158 | * the hardware to do so. It can return immediately after the packet | |
159 | * was queued for sending. After sending, hpsb_sent_packet() has to be | |
160 | * called. Return 0 on success, negative errno on failure. | |
161 | * NOTE: The function must be callable in interrupt context. | |
162 | */ | |
e1d118f1 SR |
163 | int (*transmit_packet)(struct hpsb_host *host, |
164 | struct hpsb_packet *packet); | |
741854e4 SR |
165 | |
166 | /* This function requests miscellanous services from the driver, see | |
167 | * above for command codes and expected actions. Return -1 for unknown | |
168 | * command, though that should never happen. | |
169 | */ | |
e1d118f1 | 170 | int (*devctl)(struct hpsb_host *host, enum devctl_cmd command, int arg); |
1da177e4 LT |
171 | |
172 | /* ISO transmission/reception functions. Return 0 on success, -1 | |
173 | * (or -EXXX errno code) on failure. If the low-level driver does not | |
174 | * support the new ISO API, set isoctl to NULL. | |
175 | */ | |
e1d118f1 SR |
176 | int (*isoctl)(struct hpsb_iso *iso, enum isoctl_cmd command, |
177 | unsigned long arg); | |
1da177e4 | 178 | |
741854e4 SR |
179 | /* This function is mainly to redirect local CSR reads/locks to the iso |
180 | * management registers (bus manager id, bandwidth available, channels | |
181 | * available) to the hardware registers in OHCI. reg is 0,1,2,3 for bus | |
182 | * mgr, bwdth avail, ch avail hi, ch avail lo respectively (the same ids | |
183 | * as OHCI uses). data and compare are the new data and expected data | |
184 | * respectively, return value is the old value. | |
185 | */ | |
186 | quadlet_t (*hw_csr_reg) (struct hpsb_host *host, int reg, | |
187 | quadlet_t data, quadlet_t compare); | |
1da177e4 LT |
188 | }; |
189 | ||
1da177e4 LT |
190 | struct hpsb_host *hpsb_alloc_host(struct hpsb_host_driver *drv, size_t extra, |
191 | struct device *dev); | |
192 | int hpsb_add_host(struct hpsb_host *host); | |
3360177c SR |
193 | void hpsb_resume_host(struct hpsb_host *host); |
194 | void hpsb_remove_host(struct hpsb_host *host); | |
1da177e4 LT |
195 | int hpsb_update_config_rom_image(struct hpsb_host *host); |
196 | ||
197 | #endif /* _IEEE1394_HOSTS_H */ |