p54pci.c 15.8 KB
Newer Older
1 2 3 4 5

/*
 * Linux device driver for PCI based Prism54
 *
 * Copyright (c) 2006, Michael Wu <flamingice@sourmilk.net>
6
 * Copyright (c) 2008, Christian Lamparter <chunkeey@web.de>
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
 *
 * Based on the islsm (softmac prism54) driver, which is:
 * Copyright 2004-2006 Jean-Baptiste Note <jean-baptiste.note@m4x.org>, et al.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 as
 * published by the Free Software Foundation.
 */

#include <linux/init.h>
#include <linux/pci.h>
#include <linux/firmware.h>
#include <linux/etherdevice.h>
#include <linux/delay.h>
#include <linux/completion.h>
#include <net/mac80211.h>

#include "p54.h"
25
#include "lmac.h"
26 27 28 29 30 31
#include "p54pci.h"

MODULE_AUTHOR("Michael Wu <flamingice@sourmilk.net>");
MODULE_DESCRIPTION("Prism54 PCI wireless driver");
MODULE_LICENSE("GPL");
MODULE_ALIAS("prism54pci");
32
MODULE_FIRMWARE("isl3886pci");
33 34 35 36 37 38 39 40 41 42

static struct pci_device_id p54p_table[] __devinitdata = {
	/* Intersil PRISM Duette/Prism GT Wireless LAN adapter */
	{ PCI_DEVICE(0x1260, 0x3890) },
	/* 3COM 3CRWE154G72 Wireless LAN adapter */
	{ PCI_DEVICE(0x10b7, 0x6001) },
	/* Intersil PRISM Indigo Wireless LAN adapter */
	{ PCI_DEVICE(0x1260, 0x3877) },
	/* Intersil PRISM Javelin/Xbow Wireless LAN adapter */
	{ PCI_DEVICE(0x1260, 0x3886) },
A
Andrew Morton 已提交
43
	{ },
44 45 46 47 48 49 50 51 52
};

MODULE_DEVICE_TABLE(pci, p54p_table);

static int p54p_upload_firmware(struct ieee80211_hw *dev)
{
	struct p54p_priv *priv = dev->priv;
	__le32 reg;
	int err;
53
	__le32 *data;
54 55
	u32 remains, left, device_addr;

56
	P54P_WRITE(int_enable, cpu_to_le32(0));
57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75
	P54P_READ(int_enable);
	udelay(10);

	reg = P54P_READ(ctrl_stat);
	reg &= cpu_to_le32(~ISL38XX_CTRL_STAT_RESET);
	reg &= cpu_to_le32(~ISL38XX_CTRL_STAT_RAMBOOT);
	P54P_WRITE(ctrl_stat, reg);
	P54P_READ(ctrl_stat);
	udelay(10);

	reg |= cpu_to_le32(ISL38XX_CTRL_STAT_RESET);
	P54P_WRITE(ctrl_stat, reg);
	wmb();
	udelay(10);

	reg &= cpu_to_le32(~ISL38XX_CTRL_STAT_RESET);
	P54P_WRITE(ctrl_stat, reg);
	wmb();

76 77
	/* wait for the firmware to reset properly */
	mdelay(10);
78

79 80
	err = p54_parse_firmware(dev, priv->firmware);
	if (err)
81
		return err;
82

83 84 85 86 87 88
	if (priv->common.fw_interface != FW_LM86) {
		dev_err(&priv->pdev->dev, "wrong firmware, "
			"please get a LM86(PCI) firmware a try again.\n");
		return -EINVAL;
	}

89 90
	data = (__le32 *) priv->firmware->data;
	remains = priv->firmware->size;
91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125
	device_addr = ISL38XX_DEV_FIRMWARE_ADDR;
	while (remains) {
		u32 i = 0;
		left = min((u32)0x1000, remains);
		P54P_WRITE(direct_mem_base, cpu_to_le32(device_addr));
		P54P_READ(int_enable);

		device_addr += 0x1000;
		while (i < left) {
			P54P_WRITE(direct_mem_win[i], *data++);
			i += sizeof(u32);
		}

		remains -= left;
		P54P_READ(int_enable);
	}

	reg = P54P_READ(ctrl_stat);
	reg &= cpu_to_le32(~ISL38XX_CTRL_STAT_CLKRUN);
	reg &= cpu_to_le32(~ISL38XX_CTRL_STAT_RESET);
	reg |= cpu_to_le32(ISL38XX_CTRL_STAT_RAMBOOT);
	P54P_WRITE(ctrl_stat, reg);
	P54P_READ(ctrl_stat);
	udelay(10);

	reg |= cpu_to_le32(ISL38XX_CTRL_STAT_RESET);
	P54P_WRITE(ctrl_stat, reg);
	wmb();
	udelay(10);

	reg &= cpu_to_le32(~ISL38XX_CTRL_STAT_RESET);
	P54P_WRITE(ctrl_stat, reg);
	wmb();
	udelay(10);

126
	/* wait for the firmware to boot properly */
127 128
	mdelay(100);

129
	return 0;
130 131
}

132 133 134
static void p54p_refill_rx_ring(struct ieee80211_hw *dev,
	int ring_index, struct p54p_desc *ring, u32 ring_limit,
	struct sk_buff **rx_buf)
135 136
{
	struct p54p_priv *priv = dev->priv;
137
	struct p54p_ring_control *ring_control = priv->ring_control;
138
	u32 limit, idx, i;
139

140 141 142 143
	idx = le32_to_cpu(ring_control->host_idx[ring_index]);
	limit = idx;
	limit -= le32_to_cpu(ring_control->device_idx[ring_index]);
	limit = ring_limit - limit;
144

145
	i = idx % ring_limit;
146
	while (limit-- > 1) {
147
		struct p54p_desc *desc = &ring[i];
148 149 150 151

		if (!desc->host_addr) {
			struct sk_buff *skb;
			dma_addr_t mapping;
152
			skb = dev_alloc_skb(priv->common.rx_mtu + 32);
153 154 155 156 157
			if (!skb)
				break;

			mapping = pci_map_single(priv->pdev,
						 skb_tail_pointer(skb),
158
						 priv->common.rx_mtu + 32,
159 160 161
						 PCI_DMA_FROMDEVICE);
			desc->host_addr = cpu_to_le32(mapping);
			desc->device_addr = 0;	// FIXME: necessary?
162
			desc->len = cpu_to_le16(priv->common.rx_mtu + 32);
163
			desc->flags = 0;
164
			rx_buf[i] = skb;
165 166
		}

167
		i++;
168
		idx++;
169
		i %= ring_limit;
170 171 172
	}

	wmb();
173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194
	ring_control->host_idx[ring_index] = cpu_to_le32(idx);
}

static void p54p_check_rx_ring(struct ieee80211_hw *dev, u32 *index,
	int ring_index, struct p54p_desc *ring, u32 ring_limit,
	struct sk_buff **rx_buf)
{
	struct p54p_priv *priv = dev->priv;
	struct p54p_ring_control *ring_control = priv->ring_control;
	struct p54p_desc *desc;
	u32 idx, i;

	i = (*index) % ring_limit;
	(*index) = idx = le32_to_cpu(ring_control->device_idx[ring_index]);
	idx %= ring_limit;
	while (i != idx) {
		u16 len;
		struct sk_buff *skb;
		desc = &ring[i];
		len = le16_to_cpu(desc->len);
		skb = rx_buf[i];

195 196 197
		if (!skb) {
			i++;
			i %= ring_limit;
198
			continue;
199
		}
200 201 202 203 204
		skb_put(skb, len);

		if (p54_rx(dev, skb)) {
			pci_unmap_single(priv->pdev,
					 le32_to_cpu(desc->host_addr),
205 206
					 priv->common.rx_mtu + 32,
					 PCI_DMA_FROMDEVICE);
207 208 209 210
			rx_buf[i] = NULL;
			desc->host_addr = 0;
		} else {
			skb_trim(skb, 0);
211
			desc->len = cpu_to_le16(priv->common.rx_mtu + 32);
212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236
		}

		i++;
		i %= ring_limit;
	}

	p54p_refill_rx_ring(dev, ring_index, ring, ring_limit, rx_buf);
}

/* caller must hold priv->lock */
static void p54p_check_tx_ring(struct ieee80211_hw *dev, u32 *index,
	int ring_index, struct p54p_desc *ring, u32 ring_limit,
	void **tx_buf)
{
	struct p54p_priv *priv = dev->priv;
	struct p54p_ring_control *ring_control = priv->ring_control;
	struct p54p_desc *desc;
	u32 idx, i;

	i = (*index) % ring_limit;
	(*index) = idx = le32_to_cpu(ring_control->device_idx[1]);
	idx %= ring_limit;

	while (i != idx) {
		desc = &ring[i];
237 238 239
		if (tx_buf[i])
			if (FREE_AFTER_TX((struct sk_buff *) tx_buf[i]))
				p54_free_skb(dev, tx_buf[i]);
240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268
		tx_buf[i] = NULL;

		pci_unmap_single(priv->pdev, le32_to_cpu(desc->host_addr),
				 le16_to_cpu(desc->len), PCI_DMA_TODEVICE);

		desc->host_addr = 0;
		desc->device_addr = 0;
		desc->len = 0;
		desc->flags = 0;

		i++;
		i %= ring_limit;
	}
}

static void p54p_rx_tasklet(unsigned long dev_id)
{
	struct ieee80211_hw *dev = (struct ieee80211_hw *)dev_id;
	struct p54p_priv *priv = dev->priv;
	struct p54p_ring_control *ring_control = priv->ring_control;

	p54p_check_rx_ring(dev, &priv->rx_idx_mgmt, 2, ring_control->rx_mgmt,
		ARRAY_SIZE(ring_control->rx_mgmt), priv->rx_buf_mgmt);

	p54p_check_rx_ring(dev, &priv->rx_idx_data, 0, ring_control->rx_data,
		ARRAY_SIZE(ring_control->rx_data), priv->rx_buf_data);

	wmb();
	P54P_WRITE(dev_int, cpu_to_le32(ISL38XX_DEV_INT_UPDATE));
269 270 271 272 273 274
}

static irqreturn_t p54p_interrupt(int irq, void *dev_id)
{
	struct ieee80211_hw *dev = dev_id;
	struct p54p_priv *priv = dev->priv;
275
	struct p54p_ring_control *ring_control = priv->ring_control;
276 277 278 279
	__le32 reg;

	spin_lock(&priv->lock);
	reg = P54P_READ(int_ident);
280
	if (unlikely(reg == cpu_to_le32(0xFFFFFFFF))) {
281 282 283 284 285 286 287 288 289
		spin_unlock(&priv->lock);
		return IRQ_HANDLED;
	}

	P54P_WRITE(int_ack, reg);

	reg &= P54P_READ(int_enable);

	if (reg & cpu_to_le32(ISL38XX_INT_IDENT_UPDATE)) {
290 291 292 293
		p54p_check_tx_ring(dev, &priv->tx_idx_mgmt,
				   3, ring_control->tx_mgmt,
				   ARRAY_SIZE(ring_control->tx_mgmt),
				   priv->tx_buf_mgmt);
294

295 296 297 298
		p54p_check_tx_ring(dev, &priv->tx_idx_data,
				   1, ring_control->tx_data,
				   ARRAY_SIZE(ring_control->tx_data),
				   priv->tx_buf_data);
299

300
		tasklet_schedule(&priv->rx_tasklet);
301 302 303 304 305 306 307 308 309

	} else if (reg & cpu_to_le32(ISL38XX_INT_IDENT_INIT))
		complete(&priv->boot_comp);

	spin_unlock(&priv->lock);

	return reg ? IRQ_HANDLED : IRQ_NONE;
}

310
static void p54p_tx(struct ieee80211_hw *dev, struct sk_buff *skb)
311 312
{
	struct p54p_priv *priv = dev->priv;
313
	struct p54p_ring_control *ring_control = priv->ring_control;
314 315 316 317 318 319 320
	unsigned long flags;
	struct p54p_desc *desc;
	dma_addr_t mapping;
	u32 device_idx, idx, i;

	spin_lock_irqsave(&priv->lock, flags);

321 322 323
	device_idx = le32_to_cpu(ring_control->device_idx[1]);
	idx = le32_to_cpu(ring_control->host_idx[1]);
	i = idx % ARRAY_SIZE(ring_control->tx_data);
324

325
	priv->tx_buf_data[i] = skb;
C
Christian Lamparter 已提交
326 327
	mapping = pci_map_single(priv->pdev, skb->data, skb->len,
				 PCI_DMA_TODEVICE);
328
	desc = &ring_control->tx_data[i];
329
	desc->host_addr = cpu_to_le32(mapping);
330
	desc->device_addr = ((struct p54_hdr *)skb->data)->req_id;
C
Christian Lamparter 已提交
331
	desc->len = cpu_to_le16(skb->len);
332 333 334
	desc->flags = 0;

	wmb();
335
	ring_control->host_idx[1] = cpu_to_le32(idx + 1);
336 337 338 339 340 341 342 343 344
	spin_unlock_irqrestore(&priv->lock, flags);

	P54P_WRITE(dev_int, cpu_to_le32(ISL38XX_DEV_INT_UPDATE));
	P54P_READ(dev_int);
}

static void p54p_stop(struct ieee80211_hw *dev)
{
	struct p54p_priv *priv = dev->priv;
345
	struct p54p_ring_control *ring_control = priv->ring_control;
346 347 348
	unsigned int i;
	struct p54p_desc *desc;

349 350
	tasklet_kill(&priv->rx_tasklet);

351
	P54P_WRITE(int_enable, cpu_to_le32(0));
352 353 354 355 356 357 358
	P54P_READ(int_enable);
	udelay(10);

	free_irq(priv->pdev->irq, dev);

	P54P_WRITE(dev_int, cpu_to_le32(ISL38XX_DEV_INT_RESET));

359
	for (i = 0; i < ARRAY_SIZE(priv->rx_buf_data); i++) {
360
		desc = &ring_control->rx_data[i];
361
		if (desc->host_addr)
362 363
			pci_unmap_single(priv->pdev,
					 le32_to_cpu(desc->host_addr),
364 365
					 priv->common.rx_mtu + 32,
					 PCI_DMA_FROMDEVICE);
366 367
		kfree_skb(priv->rx_buf_data[i]);
		priv->rx_buf_data[i] = NULL;
368 369
	}

370 371 372 373 374
	for (i = 0; i < ARRAY_SIZE(priv->rx_buf_mgmt); i++) {
		desc = &ring_control->rx_mgmt[i];
		if (desc->host_addr)
			pci_unmap_single(priv->pdev,
					 le32_to_cpu(desc->host_addr),
375 376
					 priv->common.rx_mtu + 32,
					 PCI_DMA_FROMDEVICE);
377 378 379 380 381
		kfree_skb(priv->rx_buf_mgmt[i]);
		priv->rx_buf_mgmt[i] = NULL;
	}

	for (i = 0; i < ARRAY_SIZE(priv->tx_buf_data); i++) {
382
		desc = &ring_control->tx_data[i];
383
		if (desc->host_addr)
384 385 386 387 388
			pci_unmap_single(priv->pdev,
					 le32_to_cpu(desc->host_addr),
					 le16_to_cpu(desc->len),
					 PCI_DMA_TODEVICE);

C
Christian Lamparter 已提交
389
		p54_free_skb(dev, priv->tx_buf_data[i]);
390 391 392 393 394 395 396 397 398 399
		priv->tx_buf_data[i] = NULL;
	}

	for (i = 0; i < ARRAY_SIZE(priv->tx_buf_mgmt); i++) {
		desc = &ring_control->tx_mgmt[i];
		if (desc->host_addr)
			pci_unmap_single(priv->pdev,
					 le32_to_cpu(desc->host_addr),
					 le16_to_cpu(desc->len),
					 PCI_DMA_TODEVICE);
400

C
Christian Lamparter 已提交
401
		p54_free_skb(dev, priv->tx_buf_mgmt[i]);
402
		priv->tx_buf_mgmt[i] = NULL;
403 404
	}

405
	memset(ring_control, 0, sizeof(*ring_control));
406 407
}

408 409 410 411 412 413 414 415 416
static int p54p_open(struct ieee80211_hw *dev)
{
	struct p54p_priv *priv = dev->priv;
	int err;

	init_completion(&priv->boot_comp);
	err = request_irq(priv->pdev->irq, &p54p_interrupt,
			  IRQF_SHARED, "p54pci", dev);
	if (err) {
417
		dev_err(&priv->pdev->dev, "failed to register IRQ handler\n");
418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468
		return err;
	}

	memset(priv->ring_control, 0, sizeof(*priv->ring_control));
	err = p54p_upload_firmware(dev);
	if (err) {
		free_irq(priv->pdev->irq, dev);
		return err;
	}
	priv->rx_idx_data = priv->tx_idx_data = 0;
	priv->rx_idx_mgmt = priv->tx_idx_mgmt = 0;

	p54p_refill_rx_ring(dev, 0, priv->ring_control->rx_data,
		ARRAY_SIZE(priv->ring_control->rx_data), priv->rx_buf_data);

	p54p_refill_rx_ring(dev, 2, priv->ring_control->rx_mgmt,
		ARRAY_SIZE(priv->ring_control->rx_mgmt), priv->rx_buf_mgmt);

	P54P_WRITE(ring_control_base, cpu_to_le32(priv->ring_control_dma));
	P54P_READ(ring_control_base);
	wmb();
	udelay(10);

	P54P_WRITE(int_enable, cpu_to_le32(ISL38XX_INT_IDENT_INIT));
	P54P_READ(int_enable);
	wmb();
	udelay(10);

	P54P_WRITE(dev_int, cpu_to_le32(ISL38XX_DEV_INT_RESET));
	P54P_READ(dev_int);

	if (!wait_for_completion_interruptible_timeout(&priv->boot_comp, HZ)) {
		printk(KERN_ERR "%s: Cannot boot firmware!\n",
		       wiphy_name(dev->wiphy));
		p54p_stop(dev);
		return -ETIMEDOUT;
	}

	P54P_WRITE(int_enable, cpu_to_le32(ISL38XX_INT_IDENT_UPDATE));
	P54P_READ(int_enable);
	wmb();
	udelay(10);

	P54P_WRITE(dev_int, cpu_to_le32(ISL38XX_DEV_INT_UPDATE));
	P54P_READ(dev_int);
	wmb();
	udelay(10);

	return 0;
}

469 470 471 472 473 474 475 476 477 478
static int __devinit p54p_probe(struct pci_dev *pdev,
				const struct pci_device_id *id)
{
	struct p54p_priv *priv;
	struct ieee80211_hw *dev;
	unsigned long mem_addr, mem_len;
	int err;

	err = pci_enable_device(pdev);
	if (err) {
479
		dev_err(&pdev->dev, "Cannot enable new PCI device\n");
480 481 482 483 484 485
		return err;
	}

	mem_addr = pci_resource_start(pdev, 0);
	mem_len = pci_resource_len(pdev, 0);
	if (mem_len < sizeof(struct p54p_csr)) {
486
		dev_err(&pdev->dev, "Too short PCI resources\n");
487
		goto err_disable_dev;
488 489
	}

490
	err = pci_request_regions(pdev, "p54pci");
491
	if (err) {
492
		dev_err(&pdev->dev, "Cannot obtain PCI resources\n");
493
		goto err_disable_dev;
494 495
	}

496 497
	if (pci_set_dma_mask(pdev, DMA_BIT_MASK(32)) ||
	    pci_set_consistent_dma_mask(pdev, DMA_BIT_MASK(32))) {
498
		dev_err(&pdev->dev, "No suitable DMA available\n");
499 500 501 502 503 504 505 506 507 508 509
		goto err_free_reg;
	}

	pci_set_master(pdev);
	pci_try_set_mwi(pdev);

	pci_write_config_byte(pdev, 0x40, 0);
	pci_write_config_byte(pdev, 0x41, 0);

	dev = p54_init_common(sizeof(*priv));
	if (!dev) {
510
		dev_err(&pdev->dev, "ieee80211 alloc failed\n");
511 512 513 514 515 516 517 518 519 520 521 522
		err = -ENOMEM;
		goto err_free_reg;
	}

	priv = dev->priv;
	priv->pdev = pdev;

	SET_IEEE80211_DEV(dev, &pdev->dev);
	pci_set_drvdata(pdev, dev);

	priv->map = ioremap(mem_addr, mem_len);
	if (!priv->map) {
523 524
		dev_err(&pdev->dev, "Cannot map device memory\n");
		err = -ENOMEM;
525 526 527 528 529 530
		goto err_free_dev;
	}

	priv->ring_control = pci_alloc_consistent(pdev, sizeof(*priv->ring_control),
						  &priv->ring_control_dma);
	if (!priv->ring_control) {
531
		dev_err(&pdev->dev, "Cannot allocate rings\n");
532 533 534 535 536 537 538 539
		err = -ENOMEM;
		goto err_iounmap;
	}
	priv->common.open = p54p_open;
	priv->common.stop = p54p_stop;
	priv->common.tx = p54p_tx;

	spin_lock_init(&priv->lock);
540
	tasklet_init(&priv->rx_tasklet, p54p_rx_tasklet, (unsigned long)dev);
541

542 543 544
	err = request_firmware(&priv->firmware, "isl3886pci",
			       &priv->pdev->dev);
	if (err) {
545
		dev_err(&pdev->dev, "Cannot find firmware (isl3886pci)\n");
546 547 548 549 550 551
		err = request_firmware(&priv->firmware, "isl3886",
				       &priv->pdev->dev);
		if (err)
			goto err_free_common;
	}

552 553 554
	err = p54p_open(dev);
	if (err)
		goto err_free_common;
555 556 557
	err = p54_read_eeprom(dev);
	p54p_stop(dev);
	if (err)
558
		goto err_free_common;
559

560 561
	err = p54_register_common(dev, &pdev->dev);
	if (err)
562 563 564 565 566
		goto err_free_common;

	return 0;

 err_free_common:
567
	release_firmware(priv->firmware);
568 569 570 571 572 573 574 575
	pci_free_consistent(pdev, sizeof(*priv->ring_control),
			    priv->ring_control, priv->ring_control_dma);

 err_iounmap:
	iounmap(priv->map);

 err_free_dev:
	pci_set_drvdata(pdev, NULL);
576
	p54_free_common(dev);
577 578 579

 err_free_reg:
	pci_release_regions(pdev);
580
 err_disable_dev:
581 582 583 584 585 586 587 588 589 590 591 592
	pci_disable_device(pdev);
	return err;
}

static void __devexit p54p_remove(struct pci_dev *pdev)
{
	struct ieee80211_hw *dev = pci_get_drvdata(pdev);
	struct p54p_priv *priv;

	if (!dev)
		return;

593
	p54_unregister_common(dev);
594
	priv = dev->priv;
595
	release_firmware(priv->firmware);
596 597 598 599 600
	pci_free_consistent(pdev, sizeof(*priv->ring_control),
			    priv->ring_control, priv->ring_control_dma);
	iounmap(priv->map);
	pci_release_regions(pdev);
	pci_disable_device(pdev);
601
	p54_free_common(dev);
602 603 604 605 606 607 608 609
}

#ifdef CONFIG_PM
static int p54p_suspend(struct pci_dev *pdev, pm_message_t state)
{
	struct ieee80211_hw *dev = pci_get_drvdata(pdev);
	struct p54p_priv *priv = dev->priv;

610
	if (priv->common.mode != NL80211_IFTYPE_UNSPECIFIED) {
611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627
		ieee80211_stop_queues(dev);
		p54p_stop(dev);
	}

	pci_save_state(pdev);
	pci_set_power_state(pdev, pci_choose_state(pdev, state));
	return 0;
}

static int p54p_resume(struct pci_dev *pdev)
{
	struct ieee80211_hw *dev = pci_get_drvdata(pdev);
	struct p54p_priv *priv = dev->priv;

	pci_set_power_state(pdev, PCI_D0);
	pci_restore_state(pdev);

628
	if (priv->common.mode != NL80211_IFTYPE_UNSPECIFIED) {
629
		p54p_open(dev);
630
		ieee80211_wake_queues(dev);
631 632 633 634 635 636 637
	}

	return 0;
}
#endif /* CONFIG_PM */

static struct pci_driver p54p_driver = {
638
	.name		= "p54pci",
639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659
	.id_table	= p54p_table,
	.probe		= p54p_probe,
	.remove		= __devexit_p(p54p_remove),
#ifdef CONFIG_PM
	.suspend	= p54p_suspend,
	.resume		= p54p_resume,
#endif /* CONFIG_PM */
};

static int __init p54p_init(void)
{
	return pci_register_driver(&p54p_driver);
}

static void __exit p54p_exit(void)
{
	pci_unregister_driver(&p54p_driver);
}

module_init(p54p_init);
module_exit(p54p_exit);