aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/ieee1394/ohci1394.h
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@ppc970.osdl.org>2005-04-16 18:20:36 -0400
committerLinus Torvalds <torvalds@ppc970.osdl.org>2005-04-16 18:20:36 -0400
commit1da177e4c3f41524e886b7f1b8a0c1fc7321cac2 (patch)
tree0bba044c4ce775e45a88a51686b5d9f90697ea9d /drivers/ieee1394/ohci1394.h
Linux-2.6.12-rc2v2.6.12-rc2
Initial git repository build. I'm not bothering with the full history, even though we have it. We can create a separate "historical" git archive of that later if we want to, and in the meantime it's about 3.2GB when imported into git - space that would just make the early git days unnecessarily complicated, when we don't have a lot of good infrastructure for it. Let it rip!
Diffstat (limited to 'drivers/ieee1394/ohci1394.h')
-rw-r--r--drivers/ieee1394/ohci1394.h456
1 files changed, 456 insertions, 0 deletions
diff --git a/drivers/ieee1394/ohci1394.h b/drivers/ieee1394/ohci1394.h
new file mode 100644
index 000000000000..d1758d409610
--- /dev/null
+++ b/drivers/ieee1394/ohci1394.h
@@ -0,0 +1,456 @@
1/*
2 * ohci1394.h - driver for OHCI 1394 boards
3 * Copyright (C)1999,2000 Sebastien Rougeaux <sebastien.rougeaux@anu.edu.au>
4 * Gord Peters <GordPeters@smarttech.com>
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software Foundation,
18 * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19 */
20
21#ifndef _OHCI1394_H
22#define _OHCI1394_H
23
24#include "ieee1394_types.h"
25#include <asm/io.h>
26
27#define OHCI1394_DRIVER_NAME "ohci1394"
28
29#define OHCI1394_MAX_AT_REQ_RETRIES 0x2
30#define OHCI1394_MAX_AT_RESP_RETRIES 0x2
31#define OHCI1394_MAX_PHYS_RESP_RETRIES 0x8
32#define OHCI1394_MAX_SELF_ID_ERRORS 16
33
34#define AR_REQ_NUM_DESC 4 /* number of AR req descriptors */
35#define AR_REQ_BUF_SIZE PAGE_SIZE /* size of AR req buffers */
36#define AR_REQ_SPLIT_BUF_SIZE PAGE_SIZE /* split packet buffer */
37
38#define AR_RESP_NUM_DESC 4 /* number of AR resp descriptors */
39#define AR_RESP_BUF_SIZE PAGE_SIZE /* size of AR resp buffers */
40#define AR_RESP_SPLIT_BUF_SIZE PAGE_SIZE /* split packet buffer */
41
42#define IR_NUM_DESC 16 /* number of IR descriptors */
43#define IR_BUF_SIZE PAGE_SIZE /* 4096 bytes/buffer */
44#define IR_SPLIT_BUF_SIZE PAGE_SIZE /* split packet buffer */
45
46#define IT_NUM_DESC 16 /* number of IT descriptors */
47
48#define AT_REQ_NUM_DESC 32 /* number of AT req descriptors */
49#define AT_RESP_NUM_DESC 32 /* number of AT resp descriptors */
50
51#define OHCI_LOOP_COUNT 100 /* Number of loops for reg read waits */
52
53#define OHCI_CONFIG_ROM_LEN 1024 /* Length of the mapped configrom space */
54
55#define OHCI1394_SI_DMA_BUF_SIZE 8192 /* length of the selfid buffer */
56
57/* PCI configuration space addresses */
58#define OHCI1394_PCI_HCI_Control 0x40
59
60struct dma_cmd {
61 u32 control;
62 u32 address;
63 u32 branchAddress;
64 u32 status;
65};
66
67/*
68 * FIXME:
69 * It is important that a single at_dma_prg does not cross a page boundary
70 * The proper way to do it would be to do the check dynamically as the
71 * programs are inserted into the AT fifo.
72 */
73struct at_dma_prg {
74 struct dma_cmd begin;
75 quadlet_t data[4];
76 struct dma_cmd end;
77 quadlet_t pad[4]; /* FIXME: quick hack for memory alignment */
78};
79
80/* identify whether a DMA context is asynchronous or isochronous */
81enum context_type { DMA_CTX_ASYNC_REQ, DMA_CTX_ASYNC_RESP, DMA_CTX_ISO };
82
83/* DMA receive context */
84struct dma_rcv_ctx {
85 struct ti_ohci *ohci;
86 enum context_type type;
87 int ctx;
88 unsigned int num_desc;
89
90 unsigned int buf_size;
91 unsigned int split_buf_size;
92
93 /* dma block descriptors */
94 struct dma_cmd **prg_cpu;
95 dma_addr_t *prg_bus;
96 struct pci_pool *prg_pool;
97
98 /* dma buffers */
99 quadlet_t **buf_cpu;
100 dma_addr_t *buf_bus;
101
102 unsigned int buf_ind;
103 unsigned int buf_offset;
104 quadlet_t *spb;
105 spinlock_t lock;
106 struct tasklet_struct task;
107 int ctrlClear;
108 int ctrlSet;
109 int cmdPtr;
110 int ctxtMatch;
111};
112
113/* DMA transmit context */
114struct dma_trm_ctx {
115 struct ti_ohci *ohci;
116 enum context_type type;
117 int ctx;
118 unsigned int num_desc;
119
120 /* dma block descriptors */
121 struct at_dma_prg **prg_cpu;
122 dma_addr_t *prg_bus;
123 struct pci_pool *prg_pool;
124
125 unsigned int prg_ind;
126 unsigned int sent_ind;
127 int free_prgs;
128 quadlet_t *branchAddrPtr;
129
130 /* list of packets inserted in the AT FIFO */
131 struct list_head fifo_list;
132
133 /* list of pending packets to be inserted in the AT FIFO */
134 struct list_head pending_list;
135
136 spinlock_t lock;
137 struct tasklet_struct task;
138 int ctrlClear;
139 int ctrlSet;
140 int cmdPtr;
141};
142
143struct ohci1394_iso_tasklet {
144 struct tasklet_struct tasklet;
145 struct list_head link;
146 int context;
147 enum { OHCI_ISO_TRANSMIT, OHCI_ISO_RECEIVE,
148 OHCI_ISO_MULTICHANNEL_RECEIVE } type;
149};
150
151struct ti_ohci {
152 struct pci_dev *dev;
153
154 enum {
155 OHCI_INIT_ALLOC_HOST,
156 OHCI_INIT_HAVE_MEM_REGION,
157 OHCI_INIT_HAVE_IOMAPPING,
158 OHCI_INIT_HAVE_CONFIG_ROM_BUFFER,
159 OHCI_INIT_HAVE_SELFID_BUFFER,
160 OHCI_INIT_HAVE_TXRX_BUFFERS__MAYBE,
161 OHCI_INIT_HAVE_IRQ,
162 OHCI_INIT_DONE,
163 } init_state;
164
165 /* remapped memory spaces */
166 void __iomem *registers;
167
168 /* dma buffer for self-id packets */
169 quadlet_t *selfid_buf_cpu;
170 dma_addr_t selfid_buf_bus;
171
172 /* buffer for csr config rom */
173 quadlet_t *csr_config_rom_cpu;
174 dma_addr_t csr_config_rom_bus;
175 int csr_config_rom_length;
176
177 unsigned int max_packet_size;
178
179 /* async receive */
180 struct dma_rcv_ctx ar_resp_context;
181 struct dma_rcv_ctx ar_req_context;
182
183 /* async transmit */
184 struct dma_trm_ctx at_resp_context;
185 struct dma_trm_ctx at_req_context;
186
187 /* iso receive */
188 int nb_iso_rcv_ctx;
189 unsigned long ir_ctx_usage; /* use test_and_set_bit() for atomicity */
190 unsigned long ir_multichannel_used; /* ditto */
191 spinlock_t IR_channel_lock;
192
193 /* iso receive (legacy API) */
194 u64 ir_legacy_channels; /* note: this differs from ISO_channel_usage;
195 it only accounts for channels listened to
196 by the legacy API, so that we can know when
197 it is safe to free the legacy API context */
198
199 struct dma_rcv_ctx ir_legacy_context;
200 struct ohci1394_iso_tasklet ir_legacy_tasklet;
201
202 /* iso transmit */
203 int nb_iso_xmit_ctx;
204 unsigned long it_ctx_usage; /* use test_and_set_bit() for atomicity */
205
206 /* iso transmit (legacy API) */
207 struct dma_trm_ctx it_legacy_context;
208 struct ohci1394_iso_tasklet it_legacy_tasklet;
209
210 u64 ISO_channel_usage;
211
212 /* IEEE-1394 part follows */
213 struct hpsb_host *host;
214
215 int phyid, isroot;
216
217 spinlock_t phy_reg_lock;
218 spinlock_t event_lock;
219
220 int self_id_errors;
221
222 /* Tasklets for iso receive and transmit, used by video1394,
223 * amdtp and dv1394 */
224
225 struct list_head iso_tasklet_list;
226 spinlock_t iso_tasklet_list_lock;
227
228 /* Swap the selfid buffer? */
229 unsigned int selfid_swap:1;
230 /* Some Apple chipset seem to swap incoming headers for us */
231 unsigned int no_swap_incoming:1;
232
233 /* Force extra paranoia checking on bus-reset handling */
234 unsigned int check_busreset:1;
235};
236
237static inline int cross_bound(unsigned long addr, unsigned int size)
238{
239 if (size > PAGE_SIZE)
240 return 1;
241
242 if (addr >> PAGE_SHIFT != (addr + size - 1) >> PAGE_SHIFT)
243 return 1;
244
245 return 0;
246}
247
248/*
249 * Register read and write helper functions.
250 */
251static inline void reg_write(const struct ti_ohci *ohci, int offset, u32 data)
252{
253 writel(data, ohci->registers + offset);
254}
255
256static inline u32 reg_read(const struct ti_ohci *ohci, int offset)
257{
258 return readl(ohci->registers + offset);
259}
260
261
262/* 2 KiloBytes of register space */
263#define OHCI1394_REGISTER_SIZE 0x800
264
265/* Offsets relative to context bases defined below */
266
267#define OHCI1394_ContextControlSet 0x000
268#define OHCI1394_ContextControlClear 0x004
269#define OHCI1394_ContextCommandPtr 0x00C
270
271/* register map */
272#define OHCI1394_Version 0x000
273#define OHCI1394_GUID_ROM 0x004
274#define OHCI1394_ATRetries 0x008
275#define OHCI1394_CSRData 0x00C
276#define OHCI1394_CSRCompareData 0x010
277#define OHCI1394_CSRControl 0x014
278#define OHCI1394_ConfigROMhdr 0x018
279#define OHCI1394_BusID 0x01C
280#define OHCI1394_BusOptions 0x020
281#define OHCI1394_GUIDHi 0x024
282#define OHCI1394_GUIDLo 0x028
283#define OHCI1394_ConfigROMmap 0x034
284#define OHCI1394_PostedWriteAddressLo 0x038
285#define OHCI1394_PostedWriteAddressHi 0x03C
286#define OHCI1394_VendorID 0x040
287#define OHCI1394_HCControlSet 0x050
288#define OHCI1394_HCControlClear 0x054
289#define OHCI1394_HCControl_noByteSwap 0x40000000
290#define OHCI1394_HCControl_programPhyEnable 0x00800000
291#define OHCI1394_HCControl_aPhyEnhanceEnable 0x00400000
292#define OHCI1394_HCControl_LPS 0x00080000
293#define OHCI1394_HCControl_postedWriteEnable 0x00040000
294#define OHCI1394_HCControl_linkEnable 0x00020000
295#define OHCI1394_HCControl_softReset 0x00010000
296#define OHCI1394_SelfIDBuffer 0x064
297#define OHCI1394_SelfIDCount 0x068
298#define OHCI1394_IRMultiChanMaskHiSet 0x070
299#define OHCI1394_IRMultiChanMaskHiClear 0x074
300#define OHCI1394_IRMultiChanMaskLoSet 0x078
301#define OHCI1394_IRMultiChanMaskLoClear 0x07C
302#define OHCI1394_IntEventSet 0x080
303#define OHCI1394_IntEventClear 0x084
304#define OHCI1394_IntMaskSet 0x088
305#define OHCI1394_IntMaskClear 0x08C
306#define OHCI1394_IsoXmitIntEventSet 0x090
307#define OHCI1394_IsoXmitIntEventClear 0x094
308#define OHCI1394_IsoXmitIntMaskSet 0x098
309#define OHCI1394_IsoXmitIntMaskClear 0x09C
310#define OHCI1394_IsoRecvIntEventSet 0x0A0
311#define OHCI1394_IsoRecvIntEventClear 0x0A4
312#define OHCI1394_IsoRecvIntMaskSet 0x0A8
313#define OHCI1394_IsoRecvIntMaskClear 0x0AC
314#define OHCI1394_InitialBandwidthAvailable 0x0B0
315#define OHCI1394_InitialChannelsAvailableHi 0x0B4
316#define OHCI1394_InitialChannelsAvailableLo 0x0B8
317#define OHCI1394_FairnessControl 0x0DC
318#define OHCI1394_LinkControlSet 0x0E0
319#define OHCI1394_LinkControlClear 0x0E4
320#define OHCI1394_LinkControl_RcvSelfID 0x00000200
321#define OHCI1394_LinkControl_RcvPhyPkt 0x00000400
322#define OHCI1394_LinkControl_CycleTimerEnable 0x00100000
323#define OHCI1394_LinkControl_CycleMaster 0x00200000
324#define OHCI1394_LinkControl_CycleSource 0x00400000
325#define OHCI1394_NodeID 0x0E8
326#define OHCI1394_PhyControl 0x0EC
327#define OHCI1394_IsochronousCycleTimer 0x0F0
328#define OHCI1394_AsReqFilterHiSet 0x100
329#define OHCI1394_AsReqFilterHiClear 0x104
330#define OHCI1394_AsReqFilterLoSet 0x108
331#define OHCI1394_AsReqFilterLoClear 0x10C
332#define OHCI1394_PhyReqFilterHiSet 0x110
333#define OHCI1394_PhyReqFilterHiClear 0x114
334#define OHCI1394_PhyReqFilterLoSet 0x118
335#define OHCI1394_PhyReqFilterLoClear 0x11C
336#define OHCI1394_PhyUpperBound 0x120
337
338#define OHCI1394_AsReqTrContextBase 0x180
339#define OHCI1394_AsReqTrContextControlSet 0x180
340#define OHCI1394_AsReqTrContextControlClear 0x184
341#define OHCI1394_AsReqTrCommandPtr 0x18C
342
343#define OHCI1394_AsRspTrContextBase 0x1A0
344#define OHCI1394_AsRspTrContextControlSet 0x1A0
345#define OHCI1394_AsRspTrContextControlClear 0x1A4
346#define OHCI1394_AsRspTrCommandPtr 0x1AC
347
348#define OHCI1394_AsReqRcvContextBase 0x1C0
349#define OHCI1394_AsReqRcvContextControlSet 0x1C0
350#define OHCI1394_AsReqRcvContextControlClear 0x1C4
351#define OHCI1394_AsReqRcvCommandPtr 0x1CC
352
353#define OHCI1394_AsRspRcvContextBase 0x1E0
354#define OHCI1394_AsRspRcvContextControlSet 0x1E0
355#define OHCI1394_AsRspRcvContextControlClear 0x1E4
356#define OHCI1394_AsRspRcvCommandPtr 0x1EC
357
358/* Isochronous transmit registers */
359/* Add (16 * n) for context n */
360#define OHCI1394_IsoXmitContextBase 0x200
361#define OHCI1394_IsoXmitContextControlSet 0x200
362#define OHCI1394_IsoXmitContextControlClear 0x204
363#define OHCI1394_IsoXmitCommandPtr 0x20C
364
365/* Isochronous receive registers */
366/* Add (32 * n) for context n */
367#define OHCI1394_IsoRcvContextBase 0x400
368#define OHCI1394_IsoRcvContextControlSet 0x400
369#define OHCI1394_IsoRcvContextControlClear 0x404
370#define OHCI1394_IsoRcvCommandPtr 0x40C
371#define OHCI1394_IsoRcvContextMatch 0x410
372
373/* Interrupts Mask/Events */
374
375#define OHCI1394_reqTxComplete 0x00000001
376#define OHCI1394_respTxComplete 0x00000002
377#define OHCI1394_ARRQ 0x00000004
378#define OHCI1394_ARRS 0x00000008
379#define OHCI1394_RQPkt 0x00000010
380#define OHCI1394_RSPkt 0x00000020
381#define OHCI1394_isochTx 0x00000040
382#define OHCI1394_isochRx 0x00000080
383#define OHCI1394_postedWriteErr 0x00000100
384#define OHCI1394_lockRespErr 0x00000200
385#define OHCI1394_selfIDComplete 0x00010000
386#define OHCI1394_busReset 0x00020000
387#define OHCI1394_phy 0x00080000
388#define OHCI1394_cycleSynch 0x00100000
389#define OHCI1394_cycle64Seconds 0x00200000
390#define OHCI1394_cycleLost 0x00400000
391#define OHCI1394_cycleInconsistent 0x00800000
392#define OHCI1394_unrecoverableError 0x01000000
393#define OHCI1394_cycleTooLong 0x02000000
394#define OHCI1394_phyRegRcvd 0x04000000
395#define OHCI1394_masterIntEnable 0x80000000
396
397/* DMA Control flags */
398#define DMA_CTL_OUTPUT_MORE 0x00000000
399#define DMA_CTL_OUTPUT_LAST 0x10000000
400#define DMA_CTL_INPUT_MORE 0x20000000
401#define DMA_CTL_INPUT_LAST 0x30000000
402#define DMA_CTL_UPDATE 0x08000000
403#define DMA_CTL_IMMEDIATE 0x02000000
404#define DMA_CTL_IRQ 0x00300000
405#define DMA_CTL_BRANCH 0x000c0000
406#define DMA_CTL_WAIT 0x00030000
407
408/* OHCI evt_* error types, table 3-2 of the OHCI 1.1 spec. */
409#define EVT_NO_STATUS 0x0 /* No event status */
410#define EVT_RESERVED_A 0x1 /* Reserved, not used !!! */
411#define EVT_LONG_PACKET 0x2 /* The revc data was longer than the buf */
412#define EVT_MISSING_ACK 0x3 /* A subaction gap was detected before an ack
413 arrived, or recv'd ack had a parity error */
414#define EVT_UNDERRUN 0x4 /* Underrun on corresponding FIFO, packet
415 truncated */
416#define EVT_OVERRUN 0x5 /* A recv FIFO overflowed on reception of ISO
417 packet */
418#define EVT_DESCRIPTOR_READ 0x6 /* An unrecoverable error occurred while host was
419 reading a descriptor block */
420#define EVT_DATA_READ 0x7 /* An error occurred while host controller was
421 attempting to read from host memory in the data
422 stage of descriptor processing */
423#define EVT_DATA_WRITE 0x8 /* An error occurred while host controller was
424 attempting to write either during the data stage
425 of descriptor processing, or when processing a single
426 16-bit host memory write */
427#define EVT_BUS_RESET 0x9 /* Identifies a PHY packet in the recv buffer as
428 being a synthesized bus reset packet */
429#define EVT_TIMEOUT 0xa /* Indicates that the asynchronous transmit response
430 packet expired and was not transmitted, or that an
431 IT DMA context experienced a skip processing overflow */
432#define EVT_TCODE_ERR 0xb /* A bad tCode is associated with this packet.
433 The packet was flushed */
434#define EVT_RESERVED_B 0xc /* Reserved, not used !!! */
435#define EVT_RESERVED_C 0xd /* Reserved, not used !!! */
436#define EVT_UNKNOWN 0xe /* An error condition has occurred that cannot be
437 represented by any other event codes defined herein. */
438#define EVT_FLUSHED 0xf /* Send by the link side of output FIFO when asynchronous
439 packets are being flushed due to a bus reset. */
440
441#define OHCI1394_TCODE_PHY 0xE
442
443void ohci1394_init_iso_tasklet(struct ohci1394_iso_tasklet *tasklet,
444 int type,
445 void (*func)(unsigned long),
446 unsigned long data);
447int ohci1394_register_iso_tasklet(struct ti_ohci *ohci,
448 struct ohci1394_iso_tasklet *tasklet);
449void ohci1394_unregister_iso_tasklet(struct ti_ohci *ohci,
450 struct ohci1394_iso_tasklet *tasklet);
451
452/* returns zero if successful, one if DMA context is locked up */
453int ohci1394_stop_context (struct ti_ohci *ohci, int reg, char *msg);
454struct ti_ohci *ohci1394_get_struct(int card_num);
455
456#endif