nosy.c 16.2 KB
Newer Older
S
Stefan Richter 已提交
1 2 3
/*
 * nosy - Snoop mode driver for TI PCILynx 1394 controllers
 * Copyright (C) 2002-2007 Kristian Høgsberg
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software Foundation,
 * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 */

#include <linux/errno.h>
S
Stefan Richter 已提交
21
#include <linux/fs.h>
22
#include <linux/init.h>
S
Stefan Richter 已提交
23 24 25 26 27
#include <linux/interrupt.h>
#include <linux/io.h>
#include <linux/kernel.h>
#include <linux/miscdevice.h>
#include <linux/module.h>
28 29
#include <linux/pci.h>
#include <linux/poll.h>
S
Stefan Richter 已提交
30 31 32 33 34 35 36
#include <linux/sched.h> /* required for linux/wait.h */
#include <linux/slab.h>
#include <linux/spinlock.h>
#include <linux/timex.h>
#include <linux/uaccess.h>
#include <linux/wait.h>

37
#include <asm/atomic.h>
S
Stefan Richter 已提交
38
#include <asm/byteorder.h>
39 40 41 42 43 44 45 46 47 48 49

#include "nosy.h"
#include "nosy-user.h"

#define TCODE_PHY_PACKET		0x10
#define PCI_DEVICE_ID_TI_PCILYNX	0x8000

#define notify(s, args...) printk(KERN_NOTICE s, ## args)
#define error(s, args...) printk(KERN_ERR s, ## args)
#define debug(s, args...) printk(KERN_DEBUG s, ## args)

S
Stefan Richter 已提交
50
static char driver_name[] = KBUILD_MODNAME;
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80

struct pcl_status {
	unsigned int transfer_count : 13;
	unsigned int reserved0 : 1;
	unsigned int ack_type : 1;
	unsigned int ack : 4;
	unsigned int rcv_speed : 2;
	unsigned int rcv_dma_channel : 6;
	unsigned int packet_complete : 1;
	unsigned int packet_error : 1;
	unsigned int master_error : 1;
	unsigned int iso_mode : 1;
	unsigned int self_id : 1;
};

/* this is the physical layout of a PCL, its size is 128 bytes */
struct pcl {
        u32 next;
        u32 async_error_next;
        u32 user_data;
        struct pcl_status pcl_status;
        u32 remaining_transfer_count;
        u32 next_data_buffer;
        struct {
                u32 control;
                u32 pointer;
        } buffer[13] __attribute__ ((packed));
} __attribute__ ((packed));

struct packet {
S
Stefan Richter 已提交
81
	unsigned int length;
82 83 84 85 86 87 88 89
	char data[0];
};

struct packet_buffer {
	char *data;
	size_t capacity;
	long total_packet_count, lost_packet_count;
	atomic_t size;
S
Stefan Richter 已提交
90 91
	struct packet *head, *tail;
	wait_queue_head_t wait;
92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110
};

struct pcilynx {
	struct pci_dev *pci_device;
	unsigned char *registers;

	struct pcl *rcv_start_pcl, *rcv_pcl;
	u32 *rcv_buffer;

	dma_addr_t rcv_start_pcl_bus, rcv_pcl_bus, rcv_buffer_bus;

	spinlock_t client_list_lock;
	struct list_head client_list;

	struct miscdevice misc;
};

struct client {
	struct pcilynx *lynx;
111
	u32 tcode_mask;
112 113 114 115 116
	struct packet_buffer buffer;
	struct list_head link;
};

#define MAX_MINORS 64
S
Stefan Richter 已提交
117
static struct pcilynx *minors[MAX_MINORS];
118 119 120 121 122 123 124 125 126 127 128 129

static int
packet_buffer_init(struct packet_buffer *buffer, size_t capacity)
{
	buffer->data = kmalloc(capacity, GFP_KERNEL);
	if (buffer->data == NULL)
		return -ENOMEM;
	buffer->head = (struct packet *) buffer->data;
	buffer->tail = (struct packet *) buffer->data;
	buffer->capacity = capacity;
	buffer->lost_packet_count = 0;
	atomic_set(&buffer->size, 0);
S
Stefan Richter 已提交
130
	init_waitqueue_head(&buffer->wait);
131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159

	return 0;
}

static void
packet_buffer_destroy(struct packet_buffer *buffer)
{
	kfree(buffer->data);
}

static int
packet_buffer_get(struct packet_buffer *buffer, void *data, size_t user_length)
{
	size_t length;
	char *end;

	if (wait_event_interruptible(buffer->wait,
				     atomic_read(&buffer->size) > 0))
		return -ERESTARTSYS;

	/* FIXME: Check length <= user_length. */

	end = buffer->data + buffer->capacity;
	length = buffer->head->length;

	if (&buffer->head->data[length] < end) {
		if (copy_to_user(data, buffer->head->data, length))
			return -EFAULT;
		buffer->head = (struct packet *) &buffer->head->data[length];
S
Stefan Richter 已提交
160
	} else {
161 162 163 164 165 166 167 168 169
		size_t split = end - buffer->head->data;

		if (copy_to_user(data, buffer->head->data, split))
			return -EFAULT;
		if (copy_to_user(data + split, buffer->data, length - split))
			return -EFAULT;
		buffer->head = (struct packet *) &buffer->data[length - split];
	}

S
Stefan Richter 已提交
170 171
	/*
	 * Decrease buffer->size as the last thing, since this is what
172
	 * keeps the interrupt from overwriting the packet we are
S
Stefan Richter 已提交
173 174 175
	 * retrieving from the buffer.
	 */
	atomic_sub(sizeof(struct packet) + length, &buffer->size);
176 177 178 179 180 181 182 183 184 185 186

	return length;
}

static void
packet_buffer_put(struct packet_buffer *buffer, void *data, size_t length)
{
	char *end;

	buffer->total_packet_count++;

S
Stefan Richter 已提交
187 188
	if (buffer->capacity <
	    atomic_read(&buffer->size) + sizeof(struct packet) + length) {
189 190 191 192 193 194 195 196 197 198
		buffer->lost_packet_count++;
		return;
	}

	end = buffer->data + buffer->capacity;
	buffer->tail->length = length;

	if (&buffer->tail->data[length] < end) {
		memcpy(buffer->tail->data, data, length);
		buffer->tail = (struct packet *) &buffer->tail->data[length];
S
Stefan Richter 已提交
199
	} else {
200 201 202 203 204 205
		size_t split = end - buffer->tail->data;

		memcpy(buffer->tail->data, data, split);
		memcpy(buffer->data, data + split, length - split);
		buffer->tail = (struct packet *) &buffer->data[length - split];
	}
S
Stefan Richter 已提交
206

207 208
	/* Finally, adjust buffer size and wake up userspace reader. */

S
Stefan Richter 已提交
209
	atomic_add(sizeof(struct packet) + length, &buffer->size);
210 211 212 213 214 215
	wake_up_interruptible(&buffer->wait);
}

static inline void
reg_write(struct pcilynx *lynx, int offset, u32 data)
{
S
Stefan Richter 已提交
216
	writel(data, lynx->registers + offset);
217 218 219 220 221
}

static inline u32
reg_read(struct pcilynx *lynx, int offset)
{
S
Stefan Richter 已提交
222
	return readl(lynx->registers + offset);
223 224 225 226 227
}

static inline void
reg_set_bits(struct pcilynx *lynx, int offset, u32 mask)
{
S
Stefan Richter 已提交
228
	reg_write(lynx, offset, (reg_read(lynx, offset) | mask));
229 230
}

S
Stefan Richter 已提交
231 232 233 234 235 236 237
/*
 * Maybe the pcl programs could be set up to just append data instead
 * of using a whole packet.
 */
static inline void
run_pcl(struct pcilynx *lynx, dma_addr_t pcl_bus,
			   int dmachan)
238
{
S
Stefan Richter 已提交
239 240 241
	reg_write(lynx, DMA0_CURRENT_PCL + dmachan * 0x20, pcl_bus);
	reg_write(lynx, DMA0_CHAN_CTRL + dmachan * 0x20,
		  DMA_CHAN_CTRL_ENABLE | DMA_CHAN_CTRL_LINK);
242 243 244 245 246
}

static int
set_phy_reg(struct pcilynx *lynx, int addr, int val)
{
S
Stefan Richter 已提交
247 248 249 250 251 252 253 254 255 256 257
	if (addr > 15) {
		debug("PHY register address %d out of range\n", addr);
		return -1;
	}

	if (val > 0xff) {
		debug("PHY register value %d out of range\n", val);
		return -1;
	}

	reg_write(lynx, LINK_PHY, LINK_PHY_WRITE |
258 259
		  LINK_PHY_ADDR(addr) | LINK_PHY_WDATA(val));

S
Stefan Richter 已提交
260
	return 0;
261 262
}

263 264
static int
nosy_open(struct inode *inode, struct file *file)
265
{
266
	int minor = iminor(inode);
267 268
	struct client *client;

269 270 271
	if (minor > MAX_MINORS || minors[minor] == NULL)
		return -ENODEV;

272
	client = kmalloc(sizeof *client, GFP_KERNEL);
273 274 275
	if (client == NULL)
		return -ENOMEM;

276
	client->tcode_mask = ~0;
277
	client->lynx = minors[minor];
278 279 280 281
	INIT_LIST_HEAD(&client->link);

	if (packet_buffer_init(&client->buffer, 128 * 1024) < 0) {
		kfree(client);
282
		return -ENOMEM;
283 284
	}

285
	file->private_data = client;
286

287
	return 0;
288 289 290
}

static int
291
nosy_release(struct inode *inode, struct file *file)
292
{
293
	struct client *client = file->private_data;
294

295 296 297
	spin_lock_irq(&client->lynx->client_list_lock);
	list_del_init(&client->link);
	spin_unlock_irq(&client->lynx->client_list_lock);
298

299 300
	packet_buffer_destroy(&client->buffer);
	kfree(client);
301

S
Stefan Richter 已提交
302
	return 0;
303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325
}

static unsigned int
nosy_poll(struct file *file, poll_table *pt)
{
	struct client *client = file->private_data;

	poll_wait(file, &client->buffer.wait, pt);

	if (atomic_read(&client->buffer.size) > 0)
		return POLLIN | POLLRDNORM;
	else
		return 0;
}

static ssize_t
nosy_read(struct file *file, char *buffer, size_t count, loff_t *offset)
{
	struct client *client = file->private_data;

	return packet_buffer_get(&client->buffer, buffer, count);
}

326 327
static long
nosy_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
328 329
{
	struct client *client = file->private_data;
330
	spinlock_t *client_list_lock = &client->lynx->client_list_lock;
S
Stefan Richter 已提交
331
	struct nosy_stats stats;
332 333

	switch (cmd) {
S
Stefan Richter 已提交
334
	case NOSY_IOC_GET_STATS:
335
		spin_lock_irq(client_list_lock);
336
		stats.total_packet_count = client->buffer.total_packet_count;
337 338 339
		stats.lost_packet_count  = client->buffer.lost_packet_count;
		spin_unlock_irq(client_list_lock);

340 341 342 343
		if (copy_to_user((void *) arg, &stats, sizeof stats))
			return -EFAULT;
		else
			return 0;
S
Stefan Richter 已提交
344

345
	case NOSY_IOC_START:
346 347 348 349
		spin_lock_irq(client_list_lock);
		list_add_tail(&client->link, &client->lynx->client_list);
		spin_unlock_irq(client_list_lock);

350 351 352
		return 0;

	case NOSY_IOC_STOP:
353 354 355 356
		spin_lock_irq(client_list_lock);
		list_del_init(&client->link);
		spin_unlock_irq(client_list_lock);

357 358 359
		return 0;

	case NOSY_IOC_FILTER:
360
		spin_lock_irq(client_list_lock);
361
		client->tcode_mask = arg;
362
		spin_unlock_irq(client_list_lock);
363

364 365 366 367 368 369 370 371
		return 0;

	default:
		return -EINVAL;
		/* Flush buffer, configure filter. */
	}
}

S
Stefan Richter 已提交
372
static const struct file_operations nosy_ops = {
373 374 375 376 377 378
	.owner =		THIS_MODULE,
	.read =			nosy_read,
	.unlocked_ioctl =	nosy_ioctl,
	.poll =			nosy_poll,
	.open =			nosy_open,
	.release =		nosy_release,
379 380 381 382 383 384 385 386 387 388 389 390 391
};

#define PHY_PACKET_SIZE 12 /* 1 payload, 1 inverse, 1 ack = 3 quadlets */

struct link_packet {
	unsigned int priority : 4;
	unsigned int tcode : 4;
	unsigned int rt : 2;
	unsigned int tlabel : 6;
	unsigned int destination : 16;
};

static void
392
packet_irq_handler(struct pcilynx *lynx)
393 394
{
	struct client *client;
395
	u32 tcode_mask;
396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412
	size_t length;
	struct link_packet *packet;
	struct timeval tv;

	/* FIXME: Also report rcv_speed. */

	length = lynx->rcv_pcl->pcl_status.transfer_count;
	packet = (struct link_packet *) &lynx->rcv_buffer[1];

	do_gettimeofday(&tv);
	lynx->rcv_buffer[0] = tv.tv_usec;

	if (length == PHY_PACKET_SIZE)
		tcode_mask = 1 << TCODE_PHY_PACKET;
	else
		tcode_mask = 1 << packet->tcode;

413
	spin_lock(&lynx->client_list_lock);
414

S
Stefan Richter 已提交
415
	list_for_each_entry(client, &lynx->client_list, link)
416
		if (client->tcode_mask & tcode_mask)
S
Stefan Richter 已提交
417
			packet_buffer_put(&client->buffer,
418 419
					  lynx->rcv_buffer, length + 4);

420
	spin_unlock(&lynx->client_list_lock);
421 422 423
}

static void
424
bus_reset_irq_handler(struct pcilynx *lynx)
425 426 427 428 429 430
{
	struct client *client;
	struct timeval tv;

	do_gettimeofday(&tv);

431
	spin_lock(&lynx->client_list_lock);
432

S
Stefan Richter 已提交
433
	list_for_each_entry(client, &lynx->client_list, link)
434 435
		packet_buffer_put(&client->buffer, &tv.tv_usec, 4);

436
	spin_unlock(&lynx->client_list_lock);
437 438 439 440 441
}

static irqreturn_t
irq_handler(int irq, void *device)
{
S
Stefan Richter 已提交
442
	struct pcilynx *lynx = device;
443
	u32 pci_int_status;
S
Stefan Richter 已提交
444 445

	pci_int_status = reg_read(lynx, PCI_INT_STATUS);
446

447 448 449 450
	if (pci_int_status == ~0)
		/* Card was ejected. */
		return IRQ_NONE;

451 452 453 454 455 456 457 458 459 460 461
	if ((pci_int_status & PCI_INT_INT_PEND) == 0)
		/* Not our interrupt, bail out quickly. */
		return IRQ_NONE;

	if ((pci_int_status & PCI_INT_P1394_INT) != 0) {
		u32 link_int_status;

		link_int_status = reg_read(lynx, LINK_INT_STATUS);
		reg_write(lynx, LINK_INT_STATUS, link_int_status);

		if ((link_int_status & LINK_INT_PHY_BUSRESET) > 0)
462
			bus_reset_irq_handler(lynx);
463 464 465 466 467 468 469 470 471
	}

	/* Clear the PCI_INT_STATUS register only after clearing the
	 * LINK_INT_STATUS register; otherwise the PCI_INT_P1394 will
	 * be set again immediately. */

	reg_write(lynx, PCI_INT_STATUS, pci_int_status);

	if ((pci_int_status & PCI_INT_DMA0_HLT) > 0) {
472
		packet_irq_handler(lynx);
473 474 475 476 477 478 479 480 481
		run_pcl(lynx, lynx->rcv_start_pcl_bus, 0);
	}

	return IRQ_HANDLED;
}

static void
remove_card(struct pci_dev *dev)
{
S
Stefan Richter 已提交
482
	struct pcilynx *lynx;
483

S
Stefan Richter 已提交
484 485
	lynx = pci_get_drvdata(dev);
	if (!lynx)
486
		return;
S
Stefan Richter 已提交
487
	pci_set_drvdata(dev, NULL);
488 489 490 491

	reg_write(lynx, PCI_INT_ENABLE, 0);
	free_irq(lynx->pci_device->irq, lynx);

S
Stefan Richter 已提交
492
	pci_free_consistent(lynx->pci_device, sizeof(struct pcl),
493
			    lynx->rcv_start_pcl, lynx->rcv_start_pcl_bus);
S
Stefan Richter 已提交
494
	pci_free_consistent(lynx->pci_device, sizeof(struct pcl),
495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511
			    lynx->rcv_pcl, lynx->rcv_pcl_bus);
	pci_free_consistent(lynx->pci_device, PAGE_SIZE,
			    lynx->rcv_buffer, lynx->rcv_buffer_bus);

	iounmap(lynx->registers);

	minors[lynx->misc.minor] = NULL;
	misc_deregister(&lynx->misc);

	kfree(lynx);
}

#define RCV_BUFFER_SIZE (16 * 1024)

static int __devinit
add_card(struct pci_dev *dev, const struct pci_device_id *unused)
{
S
Stefan Richter 已提交
512
	struct pcilynx *lynx;
513
	u32 p, end;
S
Stefan Richter 已提交
514
	int i;
515

S
Stefan Richter 已提交
516 517 518 519 520 521 522 523 524 525
	if (pci_set_dma_mask(dev, 0xffffffff)) {
		error("DMA address limits not supported "
		      "for PCILynx hardware\n");
		return -ENXIO;
	}
	if (pci_enable_device(dev)) {
		error("Failed to enable PCILynx hardware\n");
		return -ENXIO;
	}
	pci_set_master(dev);
526 527

	lynx = kzalloc(sizeof *lynx, GFP_KERNEL);
S
Stefan Richter 已提交
528 529 530 531 532 533
	if (lynx == NULL) {
		error("Failed to allocate control structure memory\n");
		return -ENOMEM;
	}
	lynx->pci_device = dev;
	pci_set_drvdata(dev, lynx);
534 535 536 537

	spin_lock_init(&lynx->client_list_lock);
	INIT_LIST_HEAD(&lynx->client_list);

S
Stefan Richter 已提交
538 539 540 541 542 543 544 545 546 547
	lynx->registers = ioremap_nocache(pci_resource_start(dev, 0),
					  PCILYNX_MAX_REGISTER);

	lynx->rcv_start_pcl = pci_alloc_consistent(lynx->pci_device,
				sizeof(struct pcl), &lynx->rcv_start_pcl_bus);
	lynx->rcv_pcl = pci_alloc_consistent(lynx->pci_device,
				sizeof(struct pcl), &lynx->rcv_pcl_bus);
	lynx->rcv_buffer = pci_alloc_consistent(lynx->pci_device,
				RCV_BUFFER_SIZE, &lynx->rcv_buffer_bus);
	if (lynx->rcv_start_pcl == NULL ||
548
	    lynx->rcv_pcl == NULL ||
S
Stefan Richter 已提交
549
	    lynx->rcv_buffer == NULL) {
550
		/* FIXME: do proper error handling. */
S
Stefan Richter 已提交
551 552 553
		error("Failed to allocate receive buffer\n");
		return -ENOMEM;
	}
554
	lynx->rcv_start_pcl->next = lynx->rcv_pcl_bus;
S
Stefan Richter 已提交
555 556
	lynx->rcv_pcl->next = PCL_NEXT_INVALID;
	lynx->rcv_pcl->async_error_next = PCL_NEXT_INVALID;
557

S
Stefan Richter 已提交
558
	lynx->rcv_pcl->buffer[0].control =
559
		PCL_CMD_RCV | PCL_BIGENDIAN | 2044;
S
Stefan Richter 已提交
560
	lynx->rcv_pcl->buffer[0].pointer = lynx->rcv_buffer_bus + 4;
561 562 563 564 565 566 567 568 569
	p = lynx->rcv_buffer_bus + 2048;
	end = lynx->rcv_buffer_bus + RCV_BUFFER_SIZE;
	for (i = 1; p < end; i++, p += 2048) {
		lynx->rcv_pcl->buffer[i].control =
			PCL_CMD_RCV | PCL_BIGENDIAN | 2048;
		lynx->rcv_pcl->buffer[i].pointer = p;
	}
	lynx->rcv_pcl->buffer[i - 1].control |= PCL_LAST_BUFF;

S
Stefan Richter 已提交
570 571 572 573
	reg_set_bits(lynx, MISC_CONTROL, MISC_CONTROL_SWRESET);
	/* Fix buggy cards with autoboot pin not tied low: */
	reg_write(lynx, DMA0_CHAN_CTRL, 0);
	reg_write(lynx, DMA_GLOBAL_REGISTER, 0x00 << 24);
574 575

#if 0
S
Stefan Richter 已提交
576 577 578 579 580 581 582 583 584 585 586
	/* now, looking for PHY register set */
	if ((get_phy_reg(lynx, 2) & 0xe0) == 0xe0) {
		lynx->phyic.reg_1394a = 1;
		PRINT(KERN_INFO, lynx->id,
		      "found 1394a conform PHY (using extended register set)");
		lynx->phyic.vendor = get_phy_vendorid(lynx);
		lynx->phyic.product = get_phy_productid(lynx);
	} else {
		lynx->phyic.reg_1394a = 0;
		PRINT(KERN_INFO, lynx->id, "found old 1394 PHY");
	}
587 588 589 590 591
#endif

	/* Setup the general receive FIFO max size. */
	reg_write(lynx, FIFO_SIZES, 255);

S
Stefan Richter 已提交
592
	reg_set_bits(lynx, PCI_INT_ENABLE, PCI_INT_DMA_ALL);
593

S
Stefan Richter 已提交
594
	reg_write(lynx, LINK_INT_ENABLE,
595 596 597 598 599 600 601 602 603 604 605 606 607 608
		  LINK_INT_PHY_TIME_OUT | LINK_INT_PHY_REG_RCVD |
		  LINK_INT_PHY_BUSRESET | LINK_INT_IT_STUCK |
		  LINK_INT_AT_STUCK | LINK_INT_SNTRJ |
		  LINK_INT_TC_ERR | LINK_INT_GRF_OVER_FLOW |
		  LINK_INT_ITF_UNDER_FLOW | LINK_INT_ATF_UNDER_FLOW);

	/* Disable the L flag in self ID packets. */
	set_phy_reg(lynx, 4, 0);

	/* Put this baby into snoop mode */
	reg_set_bits(lynx, LINK_CONTROL, LINK_CONTROL_SNOOP_ENABLE);

	run_pcl(lynx, lynx->rcv_start_pcl_bus, 0);

S
Stefan Richter 已提交
609 610 611 612 613
	if (request_irq(dev->irq, irq_handler, IRQF_SHARED,
			driver_name, lynx)) {
		error("Failed to allocate shared interrupt %d\n", dev->irq);
		return -EIO;
	}
614 615 616 617 618

	lynx->misc.parent = &dev->dev;
	lynx->misc.minor = MISC_DYNAMIC_MINOR;
	lynx->misc.name = "nosy";
	lynx->misc.fops = &nosy_ops;
S
Stefan Richter 已提交
619 620 621 622
	if (misc_register(&lynx->misc)) {
		error("Failed to register misc char device\n");
		return -ENOMEM;
	}
623 624 625 626
	minors[lynx->misc.minor] = lynx;

	notify("Initialized PCILynx IEEE1394 card, irq=%d\n", dev->irq);

S
Stefan Richter 已提交
627
	return 0;
628 629 630 631
}

static struct pci_device_id pci_table[] __devinitdata = {
	{
S
Stefan Richter 已提交
632 633 634 635
		.vendor =    PCI_VENDOR_ID_TI,
		.device =    PCI_DEVICE_ID_TI_PCILYNX,
		.subvendor = PCI_ANY_ID,
		.subdevice = PCI_ANY_ID,
636 637 638 639 640
	},
	{ }	/* Terminating entry */
};

static struct pci_driver lynx_pci_driver = {
S
Stefan Richter 已提交
641
	.name =		driver_name,
642 643
	.id_table =	pci_table,
	.probe =	add_card,
S
Stefan Richter 已提交
644
	.remove =	remove_card,
645 646
};

S
Stefan Richter 已提交
647
MODULE_AUTHOR("Kristian Hoegsberg");
648 649 650 651 652 653
MODULE_DESCRIPTION("Snoop mode driver for TI pcilynx 1394 controllers");
MODULE_LICENSE("GPL");
MODULE_DEVICE_TABLE(pci, pci_table);

static int __init nosy_init(void)
{
S
Stefan Richter 已提交
654
	return pci_register_driver(&lynx_pci_driver);
655 656 657 658
}

static void __exit nosy_cleanup(void)
{
S
Stefan Richter 已提交
659
	pci_unregister_driver(&lynx_pci_driver);
660 661 662 663 664 665

	notify("Unloaded %s.\n", driver_name);
}

module_init(nosy_init);
module_exit(nosy_cleanup);