Loading...
1/*
2 * nosy - Snoop mode driver for TI PCILynx 1394 controllers
3 * Copyright (C) 2002-2007 Kristian Høgsberg
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software Foundation,
17 * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 */
19
20#include <linux/device.h>
21#include <linux/errno.h>
22#include <linux/fs.h>
23#include <linux/init.h>
24#include <linux/interrupt.h>
25#include <linux/io.h>
26#include <linux/kernel.h>
27#include <linux/kref.h>
28#include <linux/miscdevice.h>
29#include <linux/module.h>
30#include <linux/mutex.h>
31#include <linux/pci.h>
32#include <linux/poll.h>
33#include <linux/sched.h> /* required for linux/wait.h */
34#include <linux/slab.h>
35#include <linux/spinlock.h>
36#include <linux/time64.h>
37#include <linux/timex.h>
38#include <linux/uaccess.h>
39#include <linux/wait.h>
40#include <linux/dma-mapping.h>
41#include <linux/atomic.h>
42#include <asm/byteorder.h>
43
44#include "nosy.h"
45#include "nosy-user.h"
46
47#define TCODE_PHY_PACKET 0x10
48#define PCI_DEVICE_ID_TI_PCILYNX 0x8000
49
50static char driver_name[] = KBUILD_MODNAME;
51
52/* this is the physical layout of a PCL, its size is 128 bytes */
53struct pcl {
54 __le32 next;
55 __le32 async_error_next;
56 u32 user_data;
57 __le32 pcl_status;
58 __le32 remaining_transfer_count;
59 __le32 next_data_buffer;
60 struct {
61 __le32 control;
62 __le32 pointer;
63 } buffer[13];
64};
65
66struct packet {
67 unsigned int length;
68 char data[0];
69};
70
71struct packet_buffer {
72 char *data;
73 size_t capacity;
74 long total_packet_count, lost_packet_count;
75 atomic_t size;
76 struct packet *head, *tail;
77 wait_queue_head_t wait;
78};
79
80struct pcilynx {
81 struct pci_dev *pci_device;
82 __iomem char *registers;
83
84 struct pcl *rcv_start_pcl, *rcv_pcl;
85 __le32 *rcv_buffer;
86
87 dma_addr_t rcv_start_pcl_bus, rcv_pcl_bus, rcv_buffer_bus;
88
89 spinlock_t client_list_lock;
90 struct list_head client_list;
91
92 struct miscdevice misc;
93 struct list_head link;
94 struct kref kref;
95};
96
97static inline struct pcilynx *
98lynx_get(struct pcilynx *lynx)
99{
100 kref_get(&lynx->kref);
101
102 return lynx;
103}
104
105static void
106lynx_release(struct kref *kref)
107{
108 kfree(container_of(kref, struct pcilynx, kref));
109}
110
111static inline void
112lynx_put(struct pcilynx *lynx)
113{
114 kref_put(&lynx->kref, lynx_release);
115}
116
117struct client {
118 struct pcilynx *lynx;
119 u32 tcode_mask;
120 struct packet_buffer buffer;
121 struct list_head link;
122};
123
124static DEFINE_MUTEX(card_mutex);
125static LIST_HEAD(card_list);
126
127static int
128packet_buffer_init(struct packet_buffer *buffer, size_t capacity)
129{
130 buffer->data = kmalloc(capacity, GFP_KERNEL);
131 if (buffer->data == NULL)
132 return -ENOMEM;
133 buffer->head = (struct packet *) buffer->data;
134 buffer->tail = (struct packet *) buffer->data;
135 buffer->capacity = capacity;
136 buffer->lost_packet_count = 0;
137 atomic_set(&buffer->size, 0);
138 init_waitqueue_head(&buffer->wait);
139
140 return 0;
141}
142
143static void
144packet_buffer_destroy(struct packet_buffer *buffer)
145{
146 kfree(buffer->data);
147}
148
149static int
150packet_buffer_get(struct client *client, char __user *data, size_t user_length)
151{
152 struct packet_buffer *buffer = &client->buffer;
153 size_t length;
154 char *end;
155
156 if (wait_event_interruptible(buffer->wait,
157 atomic_read(&buffer->size) > 0) ||
158 list_empty(&client->lynx->link))
159 return -ERESTARTSYS;
160
161 if (atomic_read(&buffer->size) == 0)
162 return -ENODEV;
163
164 /* FIXME: Check length <= user_length. */
165
166 end = buffer->data + buffer->capacity;
167 length = buffer->head->length;
168
169 if (&buffer->head->data[length] < end) {
170 if (copy_to_user(data, buffer->head->data, length))
171 return -EFAULT;
172 buffer->head = (struct packet *) &buffer->head->data[length];
173 } else {
174 size_t split = end - buffer->head->data;
175
176 if (copy_to_user(data, buffer->head->data, split))
177 return -EFAULT;
178 if (copy_to_user(data + split, buffer->data, length - split))
179 return -EFAULT;
180 buffer->head = (struct packet *) &buffer->data[length - split];
181 }
182
183 /*
184 * Decrease buffer->size as the last thing, since this is what
185 * keeps the interrupt from overwriting the packet we are
186 * retrieving from the buffer.
187 */
188 atomic_sub(sizeof(struct packet) + length, &buffer->size);
189
190 return length;
191}
192
193static void
194packet_buffer_put(struct packet_buffer *buffer, void *data, size_t length)
195{
196 char *end;
197
198 buffer->total_packet_count++;
199
200 if (buffer->capacity <
201 atomic_read(&buffer->size) + sizeof(struct packet) + length) {
202 buffer->lost_packet_count++;
203 return;
204 }
205
206 end = buffer->data + buffer->capacity;
207 buffer->tail->length = length;
208
209 if (&buffer->tail->data[length] < end) {
210 memcpy(buffer->tail->data, data, length);
211 buffer->tail = (struct packet *) &buffer->tail->data[length];
212 } else {
213 size_t split = end - buffer->tail->data;
214
215 memcpy(buffer->tail->data, data, split);
216 memcpy(buffer->data, data + split, length - split);
217 buffer->tail = (struct packet *) &buffer->data[length - split];
218 }
219
220 /* Finally, adjust buffer size and wake up userspace reader. */
221
222 atomic_add(sizeof(struct packet) + length, &buffer->size);
223 wake_up_interruptible(&buffer->wait);
224}
225
226static inline void
227reg_write(struct pcilynx *lynx, int offset, u32 data)
228{
229 writel(data, lynx->registers + offset);
230}
231
232static inline u32
233reg_read(struct pcilynx *lynx, int offset)
234{
235 return readl(lynx->registers + offset);
236}
237
238static inline void
239reg_set_bits(struct pcilynx *lynx, int offset, u32 mask)
240{
241 reg_write(lynx, offset, (reg_read(lynx, offset) | mask));
242}
243
244/*
245 * Maybe the pcl programs could be set up to just append data instead
246 * of using a whole packet.
247 */
248static inline void
249run_pcl(struct pcilynx *lynx, dma_addr_t pcl_bus,
250 int dmachan)
251{
252 reg_write(lynx, DMA0_CURRENT_PCL + dmachan * 0x20, pcl_bus);
253 reg_write(lynx, DMA0_CHAN_CTRL + dmachan * 0x20,
254 DMA_CHAN_CTRL_ENABLE | DMA_CHAN_CTRL_LINK);
255}
256
257static int
258set_phy_reg(struct pcilynx *lynx, int addr, int val)
259{
260 if (addr > 15) {
261 dev_err(&lynx->pci_device->dev,
262 "PHY register address %d out of range\n", addr);
263 return -1;
264 }
265 if (val > 0xff) {
266 dev_err(&lynx->pci_device->dev,
267 "PHY register value %d out of range\n", val);
268 return -1;
269 }
270 reg_write(lynx, LINK_PHY, LINK_PHY_WRITE |
271 LINK_PHY_ADDR(addr) | LINK_PHY_WDATA(val));
272
273 return 0;
274}
275
276static int
277nosy_open(struct inode *inode, struct file *file)
278{
279 int minor = iminor(inode);
280 struct client *client;
281 struct pcilynx *tmp, *lynx = NULL;
282
283 mutex_lock(&card_mutex);
284 list_for_each_entry(tmp, &card_list, link)
285 if (tmp->misc.minor == minor) {
286 lynx = lynx_get(tmp);
287 break;
288 }
289 mutex_unlock(&card_mutex);
290 if (lynx == NULL)
291 return -ENODEV;
292
293 client = kmalloc(sizeof *client, GFP_KERNEL);
294 if (client == NULL)
295 goto fail;
296
297 client->tcode_mask = ~0;
298 client->lynx = lynx;
299 INIT_LIST_HEAD(&client->link);
300
301 if (packet_buffer_init(&client->buffer, 128 * 1024) < 0)
302 goto fail;
303
304 file->private_data = client;
305
306 return nonseekable_open(inode, file);
307fail:
308 kfree(client);
309 lynx_put(lynx);
310
311 return -ENOMEM;
312}
313
314static int
315nosy_release(struct inode *inode, struct file *file)
316{
317 struct client *client = file->private_data;
318 struct pcilynx *lynx = client->lynx;
319
320 spin_lock_irq(&lynx->client_list_lock);
321 list_del_init(&client->link);
322 spin_unlock_irq(&lynx->client_list_lock);
323
324 packet_buffer_destroy(&client->buffer);
325 kfree(client);
326 lynx_put(lynx);
327
328 return 0;
329}
330
331static unsigned int
332nosy_poll(struct file *file, poll_table *pt)
333{
334 struct client *client = file->private_data;
335 unsigned int ret = 0;
336
337 poll_wait(file, &client->buffer.wait, pt);
338
339 if (atomic_read(&client->buffer.size) > 0)
340 ret = POLLIN | POLLRDNORM;
341
342 if (list_empty(&client->lynx->link))
343 ret |= POLLHUP;
344
345 return ret;
346}
347
348static ssize_t
349nosy_read(struct file *file, char __user *buffer, size_t count, loff_t *offset)
350{
351 struct client *client = file->private_data;
352
353 return packet_buffer_get(client, buffer, count);
354}
355
356static long
357nosy_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
358{
359 struct client *client = file->private_data;
360 spinlock_t *client_list_lock = &client->lynx->client_list_lock;
361 struct nosy_stats stats;
362
363 switch (cmd) {
364 case NOSY_IOC_GET_STATS:
365 spin_lock_irq(client_list_lock);
366 stats.total_packet_count = client->buffer.total_packet_count;
367 stats.lost_packet_count = client->buffer.lost_packet_count;
368 spin_unlock_irq(client_list_lock);
369
370 if (copy_to_user((void __user *) arg, &stats, sizeof stats))
371 return -EFAULT;
372 else
373 return 0;
374
375 case NOSY_IOC_START:
376 spin_lock_irq(client_list_lock);
377 list_add_tail(&client->link, &client->lynx->client_list);
378 spin_unlock_irq(client_list_lock);
379
380 return 0;
381
382 case NOSY_IOC_STOP:
383 spin_lock_irq(client_list_lock);
384 list_del_init(&client->link);
385 spin_unlock_irq(client_list_lock);
386
387 return 0;
388
389 case NOSY_IOC_FILTER:
390 spin_lock_irq(client_list_lock);
391 client->tcode_mask = arg;
392 spin_unlock_irq(client_list_lock);
393
394 return 0;
395
396 default:
397 return -EINVAL;
398 /* Flush buffer, configure filter. */
399 }
400}
401
402static const struct file_operations nosy_ops = {
403 .owner = THIS_MODULE,
404 .read = nosy_read,
405 .unlocked_ioctl = nosy_ioctl,
406 .poll = nosy_poll,
407 .open = nosy_open,
408 .release = nosy_release,
409};
410
411#define PHY_PACKET_SIZE 12 /* 1 payload, 1 inverse, 1 ack = 3 quadlets */
412
413static void
414packet_irq_handler(struct pcilynx *lynx)
415{
416 struct client *client;
417 u32 tcode_mask, tcode, timestamp;
418 size_t length;
419 struct timespec64 ts64;
420
421 /* FIXME: Also report rcv_speed. */
422
423 length = __le32_to_cpu(lynx->rcv_pcl->pcl_status) & 0x00001fff;
424 tcode = __le32_to_cpu(lynx->rcv_buffer[1]) >> 4 & 0xf;
425
426 ktime_get_real_ts64(&ts64);
427 timestamp = ts64.tv_nsec / NSEC_PER_USEC;
428 lynx->rcv_buffer[0] = (__force __le32)timestamp;
429
430 if (length == PHY_PACKET_SIZE)
431 tcode_mask = 1 << TCODE_PHY_PACKET;
432 else
433 tcode_mask = 1 << tcode;
434
435 spin_lock(&lynx->client_list_lock);
436
437 list_for_each_entry(client, &lynx->client_list, link)
438 if (client->tcode_mask & tcode_mask)
439 packet_buffer_put(&client->buffer,
440 lynx->rcv_buffer, length + 4);
441
442 spin_unlock(&lynx->client_list_lock);
443}
444
445static void
446bus_reset_irq_handler(struct pcilynx *lynx)
447{
448 struct client *client;
449 struct timespec64 ts64;
450 u32 timestamp;
451
452 ktime_get_real_ts64(&ts64);
453 timestamp = ts64.tv_nsec / NSEC_PER_USEC;
454
455 spin_lock(&lynx->client_list_lock);
456
457 list_for_each_entry(client, &lynx->client_list, link)
458 packet_buffer_put(&client->buffer, ×tamp, 4);
459
460 spin_unlock(&lynx->client_list_lock);
461}
462
463static irqreturn_t
464irq_handler(int irq, void *device)
465{
466 struct pcilynx *lynx = device;
467 u32 pci_int_status;
468
469 pci_int_status = reg_read(lynx, PCI_INT_STATUS);
470
471 if (pci_int_status == ~0)
472 /* Card was ejected. */
473 return IRQ_NONE;
474
475 if ((pci_int_status & PCI_INT_INT_PEND) == 0)
476 /* Not our interrupt, bail out quickly. */
477 return IRQ_NONE;
478
479 if ((pci_int_status & PCI_INT_P1394_INT) != 0) {
480 u32 link_int_status;
481
482 link_int_status = reg_read(lynx, LINK_INT_STATUS);
483 reg_write(lynx, LINK_INT_STATUS, link_int_status);
484
485 if ((link_int_status & LINK_INT_PHY_BUSRESET) > 0)
486 bus_reset_irq_handler(lynx);
487 }
488
489 /* Clear the PCI_INT_STATUS register only after clearing the
490 * LINK_INT_STATUS register; otherwise the PCI_INT_P1394 will
491 * be set again immediately. */
492
493 reg_write(lynx, PCI_INT_STATUS, pci_int_status);
494
495 if ((pci_int_status & PCI_INT_DMA0_HLT) > 0) {
496 packet_irq_handler(lynx);
497 run_pcl(lynx, lynx->rcv_start_pcl_bus, 0);
498 }
499
500 return IRQ_HANDLED;
501}
502
503static void
504remove_card(struct pci_dev *dev)
505{
506 struct pcilynx *lynx = pci_get_drvdata(dev);
507 struct client *client;
508
509 mutex_lock(&card_mutex);
510 list_del_init(&lynx->link);
511 misc_deregister(&lynx->misc);
512 mutex_unlock(&card_mutex);
513
514 reg_write(lynx, PCI_INT_ENABLE, 0);
515 free_irq(lynx->pci_device->irq, lynx);
516
517 spin_lock_irq(&lynx->client_list_lock);
518 list_for_each_entry(client, &lynx->client_list, link)
519 wake_up_interruptible(&client->buffer.wait);
520 spin_unlock_irq(&lynx->client_list_lock);
521
522 pci_free_consistent(lynx->pci_device, sizeof(struct pcl),
523 lynx->rcv_start_pcl, lynx->rcv_start_pcl_bus);
524 pci_free_consistent(lynx->pci_device, sizeof(struct pcl),
525 lynx->rcv_pcl, lynx->rcv_pcl_bus);
526 pci_free_consistent(lynx->pci_device, PAGE_SIZE,
527 lynx->rcv_buffer, lynx->rcv_buffer_bus);
528
529 iounmap(lynx->registers);
530 pci_disable_device(dev);
531 lynx_put(lynx);
532}
533
534#define RCV_BUFFER_SIZE (16 * 1024)
535
536static int
537add_card(struct pci_dev *dev, const struct pci_device_id *unused)
538{
539 struct pcilynx *lynx;
540 u32 p, end;
541 int ret, i;
542
543 if (pci_set_dma_mask(dev, DMA_BIT_MASK(32))) {
544 dev_err(&dev->dev,
545 "DMA address limits not supported for PCILynx hardware\n");
546 return -ENXIO;
547 }
548 if (pci_enable_device(dev)) {
549 dev_err(&dev->dev, "Failed to enable PCILynx hardware\n");
550 return -ENXIO;
551 }
552 pci_set_master(dev);
553
554 lynx = kzalloc(sizeof *lynx, GFP_KERNEL);
555 if (lynx == NULL) {
556 dev_err(&dev->dev, "Failed to allocate control structure\n");
557 ret = -ENOMEM;
558 goto fail_disable;
559 }
560 lynx->pci_device = dev;
561 pci_set_drvdata(dev, lynx);
562
563 spin_lock_init(&lynx->client_list_lock);
564 INIT_LIST_HEAD(&lynx->client_list);
565 kref_init(&lynx->kref);
566
567 lynx->registers = ioremap_nocache(pci_resource_start(dev, 0),
568 PCILYNX_MAX_REGISTER);
569
570 lynx->rcv_start_pcl = pci_alloc_consistent(lynx->pci_device,
571 sizeof(struct pcl), &lynx->rcv_start_pcl_bus);
572 lynx->rcv_pcl = pci_alloc_consistent(lynx->pci_device,
573 sizeof(struct pcl), &lynx->rcv_pcl_bus);
574 lynx->rcv_buffer = pci_alloc_consistent(lynx->pci_device,
575 RCV_BUFFER_SIZE, &lynx->rcv_buffer_bus);
576 if (lynx->rcv_start_pcl == NULL ||
577 lynx->rcv_pcl == NULL ||
578 lynx->rcv_buffer == NULL) {
579 dev_err(&dev->dev, "Failed to allocate receive buffer\n");
580 ret = -ENOMEM;
581 goto fail_deallocate;
582 }
583 lynx->rcv_start_pcl->next = cpu_to_le32(lynx->rcv_pcl_bus);
584 lynx->rcv_pcl->next = cpu_to_le32(PCL_NEXT_INVALID);
585 lynx->rcv_pcl->async_error_next = cpu_to_le32(PCL_NEXT_INVALID);
586
587 lynx->rcv_pcl->buffer[0].control =
588 cpu_to_le32(PCL_CMD_RCV | PCL_BIGENDIAN | 2044);
589 lynx->rcv_pcl->buffer[0].pointer =
590 cpu_to_le32(lynx->rcv_buffer_bus + 4);
591 p = lynx->rcv_buffer_bus + 2048;
592 end = lynx->rcv_buffer_bus + RCV_BUFFER_SIZE;
593 for (i = 1; p < end; i++, p += 2048) {
594 lynx->rcv_pcl->buffer[i].control =
595 cpu_to_le32(PCL_CMD_RCV | PCL_BIGENDIAN | 2048);
596 lynx->rcv_pcl->buffer[i].pointer = cpu_to_le32(p);
597 }
598 lynx->rcv_pcl->buffer[i - 1].control |= cpu_to_le32(PCL_LAST_BUFF);
599
600 reg_set_bits(lynx, MISC_CONTROL, MISC_CONTROL_SWRESET);
601 /* Fix buggy cards with autoboot pin not tied low: */
602 reg_write(lynx, DMA0_CHAN_CTRL, 0);
603 reg_write(lynx, DMA_GLOBAL_REGISTER, 0x00 << 24);
604
605#if 0
606 /* now, looking for PHY register set */
607 if ((get_phy_reg(lynx, 2) & 0xe0) == 0xe0) {
608 lynx->phyic.reg_1394a = 1;
609 PRINT(KERN_INFO, lynx->id,
610 "found 1394a conform PHY (using extended register set)");
611 lynx->phyic.vendor = get_phy_vendorid(lynx);
612 lynx->phyic.product = get_phy_productid(lynx);
613 } else {
614 lynx->phyic.reg_1394a = 0;
615 PRINT(KERN_INFO, lynx->id, "found old 1394 PHY");
616 }
617#endif
618
619 /* Setup the general receive FIFO max size. */
620 reg_write(lynx, FIFO_SIZES, 255);
621
622 reg_set_bits(lynx, PCI_INT_ENABLE, PCI_INT_DMA_ALL);
623
624 reg_write(lynx, LINK_INT_ENABLE,
625 LINK_INT_PHY_TIME_OUT | LINK_INT_PHY_REG_RCVD |
626 LINK_INT_PHY_BUSRESET | LINK_INT_IT_STUCK |
627 LINK_INT_AT_STUCK | LINK_INT_SNTRJ |
628 LINK_INT_TC_ERR | LINK_INT_GRF_OVER_FLOW |
629 LINK_INT_ITF_UNDER_FLOW | LINK_INT_ATF_UNDER_FLOW);
630
631 /* Disable the L flag in self ID packets. */
632 set_phy_reg(lynx, 4, 0);
633
634 /* Put this baby into snoop mode */
635 reg_set_bits(lynx, LINK_CONTROL, LINK_CONTROL_SNOOP_ENABLE);
636
637 run_pcl(lynx, lynx->rcv_start_pcl_bus, 0);
638
639 if (request_irq(dev->irq, irq_handler, IRQF_SHARED,
640 driver_name, lynx)) {
641 dev_err(&dev->dev,
642 "Failed to allocate shared interrupt %d\n", dev->irq);
643 ret = -EIO;
644 goto fail_deallocate;
645 }
646
647 lynx->misc.parent = &dev->dev;
648 lynx->misc.minor = MISC_DYNAMIC_MINOR;
649 lynx->misc.name = "nosy";
650 lynx->misc.fops = &nosy_ops;
651
652 mutex_lock(&card_mutex);
653 ret = misc_register(&lynx->misc);
654 if (ret) {
655 dev_err(&dev->dev, "Failed to register misc char device\n");
656 mutex_unlock(&card_mutex);
657 goto fail_free_irq;
658 }
659 list_add_tail(&lynx->link, &card_list);
660 mutex_unlock(&card_mutex);
661
662 dev_info(&dev->dev,
663 "Initialized PCILynx IEEE1394 card, irq=%d\n", dev->irq);
664
665 return 0;
666
667fail_free_irq:
668 reg_write(lynx, PCI_INT_ENABLE, 0);
669 free_irq(lynx->pci_device->irq, lynx);
670
671fail_deallocate:
672 if (lynx->rcv_start_pcl)
673 pci_free_consistent(lynx->pci_device, sizeof(struct pcl),
674 lynx->rcv_start_pcl, lynx->rcv_start_pcl_bus);
675 if (lynx->rcv_pcl)
676 pci_free_consistent(lynx->pci_device, sizeof(struct pcl),
677 lynx->rcv_pcl, lynx->rcv_pcl_bus);
678 if (lynx->rcv_buffer)
679 pci_free_consistent(lynx->pci_device, PAGE_SIZE,
680 lynx->rcv_buffer, lynx->rcv_buffer_bus);
681 iounmap(lynx->registers);
682 kfree(lynx);
683
684fail_disable:
685 pci_disable_device(dev);
686
687 return ret;
688}
689
690static struct pci_device_id pci_table[] = {
691 {
692 .vendor = PCI_VENDOR_ID_TI,
693 .device = PCI_DEVICE_ID_TI_PCILYNX,
694 .subvendor = PCI_ANY_ID,
695 .subdevice = PCI_ANY_ID,
696 },
697 { } /* Terminating entry */
698};
699
700MODULE_DEVICE_TABLE(pci, pci_table);
701
702static struct pci_driver lynx_pci_driver = {
703 .name = driver_name,
704 .id_table = pci_table,
705 .probe = add_card,
706 .remove = remove_card,
707};
708
709module_pci_driver(lynx_pci_driver);
710
711MODULE_AUTHOR("Kristian Hoegsberg");
712MODULE_DESCRIPTION("Snoop mode driver for TI pcilynx 1394 controllers");
713MODULE_LICENSE("GPL");
1// SPDX-License-Identifier: GPL-2.0-or-later
2/*
3 * nosy - Snoop mode driver for TI PCILynx 1394 controllers
4 * Copyright (C) 2002-2007 Kristian Høgsberg
5 */
6
7#include <linux/device.h>
8#include <linux/errno.h>
9#include <linux/fs.h>
10#include <linux/init.h>
11#include <linux/interrupt.h>
12#include <linux/io.h>
13#include <linux/kernel.h>
14#include <linux/kref.h>
15#include <linux/miscdevice.h>
16#include <linux/module.h>
17#include <linux/mutex.h>
18#include <linux/pci.h>
19#include <linux/poll.h>
20#include <linux/sched.h> /* required for linux/wait.h */
21#include <linux/slab.h>
22#include <linux/spinlock.h>
23#include <linux/time64.h>
24#include <linux/timex.h>
25#include <linux/uaccess.h>
26#include <linux/wait.h>
27#include <linux/dma-mapping.h>
28#include <linux/atomic.h>
29#include <asm/byteorder.h>
30
31#include "nosy.h"
32#include "nosy-user.h"
33
34#define TCODE_PHY_PACKET 0x10
35#define PCI_DEVICE_ID_TI_PCILYNX 0x8000
36
37static char driver_name[] = KBUILD_MODNAME;
38
39/* this is the physical layout of a PCL, its size is 128 bytes */
40struct pcl {
41 __le32 next;
42 __le32 async_error_next;
43 u32 user_data;
44 __le32 pcl_status;
45 __le32 remaining_transfer_count;
46 __le32 next_data_buffer;
47 struct {
48 __le32 control;
49 __le32 pointer;
50 } buffer[13];
51};
52
53struct packet {
54 unsigned int length;
55 char data[];
56};
57
58struct packet_buffer {
59 char *data;
60 size_t capacity;
61 long total_packet_count, lost_packet_count;
62 atomic_t size;
63 struct packet *head, *tail;
64 wait_queue_head_t wait;
65};
66
67struct pcilynx {
68 struct pci_dev *pci_device;
69 __iomem char *registers;
70
71 struct pcl *rcv_start_pcl, *rcv_pcl;
72 __le32 *rcv_buffer;
73
74 dma_addr_t rcv_start_pcl_bus, rcv_pcl_bus, rcv_buffer_bus;
75
76 spinlock_t client_list_lock;
77 struct list_head client_list;
78
79 struct miscdevice misc;
80 struct list_head link;
81 struct kref kref;
82};
83
84static inline struct pcilynx *
85lynx_get(struct pcilynx *lynx)
86{
87 kref_get(&lynx->kref);
88
89 return lynx;
90}
91
92static void
93lynx_release(struct kref *kref)
94{
95 kfree(container_of(kref, struct pcilynx, kref));
96}
97
98static inline void
99lynx_put(struct pcilynx *lynx)
100{
101 kref_put(&lynx->kref, lynx_release);
102}
103
104struct client {
105 struct pcilynx *lynx;
106 u32 tcode_mask;
107 struct packet_buffer buffer;
108 struct list_head link;
109};
110
111static DEFINE_MUTEX(card_mutex);
112static LIST_HEAD(card_list);
113
114static int
115packet_buffer_init(struct packet_buffer *buffer, size_t capacity)
116{
117 buffer->data = kmalloc(capacity, GFP_KERNEL);
118 if (buffer->data == NULL)
119 return -ENOMEM;
120 buffer->head = (struct packet *) buffer->data;
121 buffer->tail = (struct packet *) buffer->data;
122 buffer->capacity = capacity;
123 buffer->lost_packet_count = 0;
124 atomic_set(&buffer->size, 0);
125 init_waitqueue_head(&buffer->wait);
126
127 return 0;
128}
129
130static void
131packet_buffer_destroy(struct packet_buffer *buffer)
132{
133 kfree(buffer->data);
134}
135
136static int
137packet_buffer_get(struct client *client, char __user *data, size_t user_length)
138{
139 struct packet_buffer *buffer = &client->buffer;
140 size_t length;
141 char *end;
142
143 if (wait_event_interruptible(buffer->wait,
144 atomic_read(&buffer->size) > 0) ||
145 list_empty(&client->lynx->link))
146 return -ERESTARTSYS;
147
148 if (atomic_read(&buffer->size) == 0)
149 return -ENODEV;
150
151 length = buffer->head->length;
152
153 if (length > user_length)
154 return 0;
155
156 end = buffer->data + buffer->capacity;
157
158 if (&buffer->head->data[length] < end) {
159 if (copy_to_user(data, buffer->head->data, length))
160 return -EFAULT;
161 buffer->head = (struct packet *) &buffer->head->data[length];
162 } else {
163 size_t split = end - buffer->head->data;
164
165 if (copy_to_user(data, buffer->head->data, split))
166 return -EFAULT;
167 if (copy_to_user(data + split, buffer->data, length - split))
168 return -EFAULT;
169 buffer->head = (struct packet *) &buffer->data[length - split];
170 }
171
172 /*
173 * Decrease buffer->size as the last thing, since this is what
174 * keeps the interrupt from overwriting the packet we are
175 * retrieving from the buffer.
176 */
177 atomic_sub(sizeof(struct packet) + length, &buffer->size);
178
179 return length;
180}
181
182static void
183packet_buffer_put(struct packet_buffer *buffer, void *data, size_t length)
184{
185 char *end;
186
187 buffer->total_packet_count++;
188
189 if (buffer->capacity <
190 atomic_read(&buffer->size) + sizeof(struct packet) + length) {
191 buffer->lost_packet_count++;
192 return;
193 }
194
195 end = buffer->data + buffer->capacity;
196 buffer->tail->length = length;
197
198 if (&buffer->tail->data[length] < end) {
199 memcpy(buffer->tail->data, data, length);
200 buffer->tail = (struct packet *) &buffer->tail->data[length];
201 } else {
202 size_t split = end - buffer->tail->data;
203
204 memcpy(buffer->tail->data, data, split);
205 memcpy(buffer->data, data + split, length - split);
206 buffer->tail = (struct packet *) &buffer->data[length - split];
207 }
208
209 /* Finally, adjust buffer size and wake up userspace reader. */
210
211 atomic_add(sizeof(struct packet) + length, &buffer->size);
212 wake_up_interruptible(&buffer->wait);
213}
214
215static inline void
216reg_write(struct pcilynx *lynx, int offset, u32 data)
217{
218 writel(data, lynx->registers + offset);
219}
220
221static inline u32
222reg_read(struct pcilynx *lynx, int offset)
223{
224 return readl(lynx->registers + offset);
225}
226
227static inline void
228reg_set_bits(struct pcilynx *lynx, int offset, u32 mask)
229{
230 reg_write(lynx, offset, (reg_read(lynx, offset) | mask));
231}
232
233/*
234 * Maybe the pcl programs could be set up to just append data instead
235 * of using a whole packet.
236 */
237static inline void
238run_pcl(struct pcilynx *lynx, dma_addr_t pcl_bus,
239 int dmachan)
240{
241 reg_write(lynx, DMA0_CURRENT_PCL + dmachan * 0x20, pcl_bus);
242 reg_write(lynx, DMA0_CHAN_CTRL + dmachan * 0x20,
243 DMA_CHAN_CTRL_ENABLE | DMA_CHAN_CTRL_LINK);
244}
245
246static int
247set_phy_reg(struct pcilynx *lynx, int addr, int val)
248{
249 if (addr > 15) {
250 dev_err(&lynx->pci_device->dev,
251 "PHY register address %d out of range\n", addr);
252 return -1;
253 }
254 if (val > 0xff) {
255 dev_err(&lynx->pci_device->dev,
256 "PHY register value %d out of range\n", val);
257 return -1;
258 }
259 reg_write(lynx, LINK_PHY, LINK_PHY_WRITE |
260 LINK_PHY_ADDR(addr) | LINK_PHY_WDATA(val));
261
262 return 0;
263}
264
265static int
266nosy_open(struct inode *inode, struct file *file)
267{
268 int minor = iminor(inode);
269 struct client *client;
270 struct pcilynx *tmp, *lynx = NULL;
271
272 mutex_lock(&card_mutex);
273 list_for_each_entry(tmp, &card_list, link)
274 if (tmp->misc.minor == minor) {
275 lynx = lynx_get(tmp);
276 break;
277 }
278 mutex_unlock(&card_mutex);
279 if (lynx == NULL)
280 return -ENODEV;
281
282 client = kmalloc(sizeof *client, GFP_KERNEL);
283 if (client == NULL)
284 goto fail;
285
286 client->tcode_mask = ~0;
287 client->lynx = lynx;
288 INIT_LIST_HEAD(&client->link);
289
290 if (packet_buffer_init(&client->buffer, 128 * 1024) < 0)
291 goto fail;
292
293 file->private_data = client;
294
295 return stream_open(inode, file);
296fail:
297 kfree(client);
298 lynx_put(lynx);
299
300 return -ENOMEM;
301}
302
303static int
304nosy_release(struct inode *inode, struct file *file)
305{
306 struct client *client = file->private_data;
307 struct pcilynx *lynx = client->lynx;
308
309 spin_lock_irq(&lynx->client_list_lock);
310 list_del_init(&client->link);
311 spin_unlock_irq(&lynx->client_list_lock);
312
313 packet_buffer_destroy(&client->buffer);
314 kfree(client);
315 lynx_put(lynx);
316
317 return 0;
318}
319
320static __poll_t
321nosy_poll(struct file *file, poll_table *pt)
322{
323 struct client *client = file->private_data;
324 __poll_t ret = 0;
325
326 poll_wait(file, &client->buffer.wait, pt);
327
328 if (atomic_read(&client->buffer.size) > 0)
329 ret = EPOLLIN | EPOLLRDNORM;
330
331 if (list_empty(&client->lynx->link))
332 ret |= EPOLLHUP;
333
334 return ret;
335}
336
337static ssize_t
338nosy_read(struct file *file, char __user *buffer, size_t count, loff_t *offset)
339{
340 struct client *client = file->private_data;
341
342 return packet_buffer_get(client, buffer, count);
343}
344
345static long
346nosy_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
347{
348 struct client *client = file->private_data;
349 spinlock_t *client_list_lock = &client->lynx->client_list_lock;
350 struct nosy_stats stats;
351 int ret;
352
353 switch (cmd) {
354 case NOSY_IOC_GET_STATS:
355 spin_lock_irq(client_list_lock);
356 stats.total_packet_count = client->buffer.total_packet_count;
357 stats.lost_packet_count = client->buffer.lost_packet_count;
358 spin_unlock_irq(client_list_lock);
359
360 if (copy_to_user((void __user *) arg, &stats, sizeof stats))
361 return -EFAULT;
362 else
363 return 0;
364
365 case NOSY_IOC_START:
366 ret = -EBUSY;
367 spin_lock_irq(client_list_lock);
368 if (list_empty(&client->link)) {
369 list_add_tail(&client->link, &client->lynx->client_list);
370 ret = 0;
371 }
372 spin_unlock_irq(client_list_lock);
373
374 return ret;
375
376 case NOSY_IOC_STOP:
377 spin_lock_irq(client_list_lock);
378 list_del_init(&client->link);
379 spin_unlock_irq(client_list_lock);
380
381 return 0;
382
383 case NOSY_IOC_FILTER:
384 spin_lock_irq(client_list_lock);
385 client->tcode_mask = arg;
386 spin_unlock_irq(client_list_lock);
387
388 return 0;
389
390 default:
391 return -EINVAL;
392 /* Flush buffer, configure filter. */
393 }
394}
395
396static const struct file_operations nosy_ops = {
397 .owner = THIS_MODULE,
398 .read = nosy_read,
399 .unlocked_ioctl = nosy_ioctl,
400 .poll = nosy_poll,
401 .open = nosy_open,
402 .release = nosy_release,
403};
404
405#define PHY_PACKET_SIZE 12 /* 1 payload, 1 inverse, 1 ack = 3 quadlets */
406
407static void
408packet_irq_handler(struct pcilynx *lynx)
409{
410 struct client *client;
411 u32 tcode_mask, tcode, timestamp;
412 size_t length;
413 struct timespec64 ts64;
414
415 /* FIXME: Also report rcv_speed. */
416
417 length = __le32_to_cpu(lynx->rcv_pcl->pcl_status) & 0x00001fff;
418 tcode = __le32_to_cpu(lynx->rcv_buffer[1]) >> 4 & 0xf;
419
420 ktime_get_real_ts64(&ts64);
421 timestamp = ts64.tv_nsec / NSEC_PER_USEC;
422 lynx->rcv_buffer[0] = (__force __le32)timestamp;
423
424 if (length == PHY_PACKET_SIZE)
425 tcode_mask = 1 << TCODE_PHY_PACKET;
426 else
427 tcode_mask = 1 << tcode;
428
429 spin_lock(&lynx->client_list_lock);
430
431 list_for_each_entry(client, &lynx->client_list, link)
432 if (client->tcode_mask & tcode_mask)
433 packet_buffer_put(&client->buffer,
434 lynx->rcv_buffer, length + 4);
435
436 spin_unlock(&lynx->client_list_lock);
437}
438
439static void
440bus_reset_irq_handler(struct pcilynx *lynx)
441{
442 struct client *client;
443 struct timespec64 ts64;
444 u32 timestamp;
445
446 ktime_get_real_ts64(&ts64);
447 timestamp = ts64.tv_nsec / NSEC_PER_USEC;
448
449 spin_lock(&lynx->client_list_lock);
450
451 list_for_each_entry(client, &lynx->client_list, link)
452 packet_buffer_put(&client->buffer, ×tamp, 4);
453
454 spin_unlock(&lynx->client_list_lock);
455}
456
457static irqreturn_t
458irq_handler(int irq, void *device)
459{
460 struct pcilynx *lynx = device;
461 u32 pci_int_status;
462
463 pci_int_status = reg_read(lynx, PCI_INT_STATUS);
464
465 if (pci_int_status == ~0)
466 /* Card was ejected. */
467 return IRQ_NONE;
468
469 if ((pci_int_status & PCI_INT_INT_PEND) == 0)
470 /* Not our interrupt, bail out quickly. */
471 return IRQ_NONE;
472
473 if ((pci_int_status & PCI_INT_P1394_INT) != 0) {
474 u32 link_int_status;
475
476 link_int_status = reg_read(lynx, LINK_INT_STATUS);
477 reg_write(lynx, LINK_INT_STATUS, link_int_status);
478
479 if ((link_int_status & LINK_INT_PHY_BUSRESET) > 0)
480 bus_reset_irq_handler(lynx);
481 }
482
483 /* Clear the PCI_INT_STATUS register only after clearing the
484 * LINK_INT_STATUS register; otherwise the PCI_INT_P1394 will
485 * be set again immediately. */
486
487 reg_write(lynx, PCI_INT_STATUS, pci_int_status);
488
489 if ((pci_int_status & PCI_INT_DMA0_HLT) > 0) {
490 packet_irq_handler(lynx);
491 run_pcl(lynx, lynx->rcv_start_pcl_bus, 0);
492 }
493
494 return IRQ_HANDLED;
495}
496
497static void
498remove_card(struct pci_dev *dev)
499{
500 struct pcilynx *lynx = pci_get_drvdata(dev);
501 struct client *client;
502
503 mutex_lock(&card_mutex);
504 list_del_init(&lynx->link);
505 misc_deregister(&lynx->misc);
506 mutex_unlock(&card_mutex);
507
508 reg_write(lynx, PCI_INT_ENABLE, 0);
509 free_irq(lynx->pci_device->irq, lynx);
510
511 spin_lock_irq(&lynx->client_list_lock);
512 list_for_each_entry(client, &lynx->client_list, link)
513 wake_up_interruptible(&client->buffer.wait);
514 spin_unlock_irq(&lynx->client_list_lock);
515
516 dma_free_coherent(&lynx->pci_device->dev, sizeof(struct pcl),
517 lynx->rcv_start_pcl, lynx->rcv_start_pcl_bus);
518 dma_free_coherent(&lynx->pci_device->dev, sizeof(struct pcl),
519 lynx->rcv_pcl, lynx->rcv_pcl_bus);
520 dma_free_coherent(&lynx->pci_device->dev, PAGE_SIZE, lynx->rcv_buffer,
521 lynx->rcv_buffer_bus);
522
523 iounmap(lynx->registers);
524 pci_disable_device(dev);
525 lynx_put(lynx);
526}
527
528#define RCV_BUFFER_SIZE (16 * 1024)
529
530static int
531add_card(struct pci_dev *dev, const struct pci_device_id *unused)
532{
533 struct pcilynx *lynx;
534 u32 p, end;
535 int ret, i;
536
537 if (dma_set_mask(&dev->dev, DMA_BIT_MASK(32))) {
538 dev_err(&dev->dev,
539 "DMA address limits not supported for PCILynx hardware\n");
540 return -ENXIO;
541 }
542 if (pci_enable_device(dev)) {
543 dev_err(&dev->dev, "Failed to enable PCILynx hardware\n");
544 return -ENXIO;
545 }
546 pci_set_master(dev);
547
548 lynx = kzalloc(sizeof *lynx, GFP_KERNEL);
549 if (lynx == NULL) {
550 dev_err(&dev->dev, "Failed to allocate control structure\n");
551 ret = -ENOMEM;
552 goto fail_disable;
553 }
554 lynx->pci_device = dev;
555 pci_set_drvdata(dev, lynx);
556
557 spin_lock_init(&lynx->client_list_lock);
558 INIT_LIST_HEAD(&lynx->client_list);
559 kref_init(&lynx->kref);
560
561 lynx->registers = ioremap(pci_resource_start(dev, 0),
562 PCILYNX_MAX_REGISTER);
563 if (lynx->registers == NULL) {
564 dev_err(&dev->dev, "Failed to map registers\n");
565 ret = -ENOMEM;
566 goto fail_deallocate_lynx;
567 }
568
569 lynx->rcv_start_pcl = dma_alloc_coherent(&lynx->pci_device->dev,
570 sizeof(struct pcl),
571 &lynx->rcv_start_pcl_bus,
572 GFP_KERNEL);
573 lynx->rcv_pcl = dma_alloc_coherent(&lynx->pci_device->dev,
574 sizeof(struct pcl),
575 &lynx->rcv_pcl_bus, GFP_KERNEL);
576 lynx->rcv_buffer = dma_alloc_coherent(&lynx->pci_device->dev,
577 RCV_BUFFER_SIZE,
578 &lynx->rcv_buffer_bus, GFP_KERNEL);
579 if (lynx->rcv_start_pcl == NULL ||
580 lynx->rcv_pcl == NULL ||
581 lynx->rcv_buffer == NULL) {
582 dev_err(&dev->dev, "Failed to allocate receive buffer\n");
583 ret = -ENOMEM;
584 goto fail_deallocate_buffers;
585 }
586 lynx->rcv_start_pcl->next = cpu_to_le32(lynx->rcv_pcl_bus);
587 lynx->rcv_pcl->next = cpu_to_le32(PCL_NEXT_INVALID);
588 lynx->rcv_pcl->async_error_next = cpu_to_le32(PCL_NEXT_INVALID);
589
590 lynx->rcv_pcl->buffer[0].control =
591 cpu_to_le32(PCL_CMD_RCV | PCL_BIGENDIAN | 2044);
592 lynx->rcv_pcl->buffer[0].pointer =
593 cpu_to_le32(lynx->rcv_buffer_bus + 4);
594 p = lynx->rcv_buffer_bus + 2048;
595 end = lynx->rcv_buffer_bus + RCV_BUFFER_SIZE;
596 for (i = 1; p < end; i++, p += 2048) {
597 lynx->rcv_pcl->buffer[i].control =
598 cpu_to_le32(PCL_CMD_RCV | PCL_BIGENDIAN | 2048);
599 lynx->rcv_pcl->buffer[i].pointer = cpu_to_le32(p);
600 }
601 lynx->rcv_pcl->buffer[i - 1].control |= cpu_to_le32(PCL_LAST_BUFF);
602
603 reg_set_bits(lynx, MISC_CONTROL, MISC_CONTROL_SWRESET);
604 /* Fix buggy cards with autoboot pin not tied low: */
605 reg_write(lynx, DMA0_CHAN_CTRL, 0);
606 reg_write(lynx, DMA_GLOBAL_REGISTER, 0x00 << 24);
607
608#if 0
609 /* now, looking for PHY register set */
610 if ((get_phy_reg(lynx, 2) & 0xe0) == 0xe0) {
611 lynx->phyic.reg_1394a = 1;
612 PRINT(KERN_INFO, lynx->id,
613 "found 1394a conform PHY (using extended register set)");
614 lynx->phyic.vendor = get_phy_vendorid(lynx);
615 lynx->phyic.product = get_phy_productid(lynx);
616 } else {
617 lynx->phyic.reg_1394a = 0;
618 PRINT(KERN_INFO, lynx->id, "found old 1394 PHY");
619 }
620#endif
621
622 /* Setup the general receive FIFO max size. */
623 reg_write(lynx, FIFO_SIZES, 255);
624
625 reg_set_bits(lynx, PCI_INT_ENABLE, PCI_INT_DMA_ALL);
626
627 reg_write(lynx, LINK_INT_ENABLE,
628 LINK_INT_PHY_TIME_OUT | LINK_INT_PHY_REG_RCVD |
629 LINK_INT_PHY_BUSRESET | LINK_INT_IT_STUCK |
630 LINK_INT_AT_STUCK | LINK_INT_SNTRJ |
631 LINK_INT_TC_ERR | LINK_INT_GRF_OVER_FLOW |
632 LINK_INT_ITF_UNDER_FLOW | LINK_INT_ATF_UNDER_FLOW);
633
634 /* Disable the L flag in self ID packets. */
635 set_phy_reg(lynx, 4, 0);
636
637 /* Put this baby into snoop mode */
638 reg_set_bits(lynx, LINK_CONTROL, LINK_CONTROL_SNOOP_ENABLE);
639
640 run_pcl(lynx, lynx->rcv_start_pcl_bus, 0);
641
642 if (request_irq(dev->irq, irq_handler, IRQF_SHARED,
643 driver_name, lynx)) {
644 dev_err(&dev->dev,
645 "Failed to allocate shared interrupt %d\n", dev->irq);
646 ret = -EIO;
647 goto fail_deallocate_buffers;
648 }
649
650 lynx->misc.parent = &dev->dev;
651 lynx->misc.minor = MISC_DYNAMIC_MINOR;
652 lynx->misc.name = "nosy";
653 lynx->misc.fops = &nosy_ops;
654
655 mutex_lock(&card_mutex);
656 ret = misc_register(&lynx->misc);
657 if (ret) {
658 dev_err(&dev->dev, "Failed to register misc char device\n");
659 mutex_unlock(&card_mutex);
660 goto fail_free_irq;
661 }
662 list_add_tail(&lynx->link, &card_list);
663 mutex_unlock(&card_mutex);
664
665 dev_info(&dev->dev,
666 "Initialized PCILynx IEEE1394 card, irq=%d\n", dev->irq);
667
668 return 0;
669
670fail_free_irq:
671 reg_write(lynx, PCI_INT_ENABLE, 0);
672 free_irq(lynx->pci_device->irq, lynx);
673
674fail_deallocate_buffers:
675 if (lynx->rcv_start_pcl)
676 dma_free_coherent(&lynx->pci_device->dev, sizeof(struct pcl),
677 lynx->rcv_start_pcl,
678 lynx->rcv_start_pcl_bus);
679 if (lynx->rcv_pcl)
680 dma_free_coherent(&lynx->pci_device->dev, sizeof(struct pcl),
681 lynx->rcv_pcl, lynx->rcv_pcl_bus);
682 if (lynx->rcv_buffer)
683 dma_free_coherent(&lynx->pci_device->dev, PAGE_SIZE,
684 lynx->rcv_buffer, lynx->rcv_buffer_bus);
685 iounmap(lynx->registers);
686
687fail_deallocate_lynx:
688 kfree(lynx);
689
690fail_disable:
691 pci_disable_device(dev);
692
693 return ret;
694}
695
696static struct pci_device_id pci_table[] = {
697 {
698 .vendor = PCI_VENDOR_ID_TI,
699 .device = PCI_DEVICE_ID_TI_PCILYNX,
700 .subvendor = PCI_ANY_ID,
701 .subdevice = PCI_ANY_ID,
702 },
703 { } /* Terminating entry */
704};
705
706MODULE_DEVICE_TABLE(pci, pci_table);
707
708static struct pci_driver lynx_pci_driver = {
709 .name = driver_name,
710 .id_table = pci_table,
711 .probe = add_card,
712 .remove = remove_card,
713};
714
715module_pci_driver(lynx_pci_driver);
716
717MODULE_AUTHOR("Kristian Hoegsberg");
718MODULE_DESCRIPTION("Snoop mode driver for TI pcilynx 1394 controllers");
719MODULE_LICENSE("GPL");