hostap_cs.c 18.5 KB
Newer Older
J
Jouni Malinen 已提交
1 2 3 4 5
#define PRISM2_PCCARD

#include <linux/module.h>
#include <linux/init.h>
#include <linux/if.h>
6
#include <linux/slab.h>
J
Jouni Malinen 已提交
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
#include <linux/wait.h>
#include <linux/timer.h>
#include <linux/skbuff.h>
#include <linux/netdevice.h>
#include <linux/workqueue.h>
#include <linux/wireless.h>
#include <net/iw_handler.h>

#include <pcmcia/cistpl.h>
#include <pcmcia/cisreg.h>
#include <pcmcia/ds.h>

#include <asm/io.h>

#include "hostap_wlan.h"


D
Dominik Brodowski 已提交
24
static char *dev_info = "hostap_cs";
J
Jouni Malinen 已提交
25 26 27 28 29 30 31 32 33 34 35 36 37

MODULE_AUTHOR("Jouni Malinen");
MODULE_DESCRIPTION("Support for Intersil Prism2-based 802.11 wireless LAN "
		   "cards (PC Card).");
MODULE_SUPPORTED_DEVICE("Intersil Prism2-based WLAN cards (PC Card)");
MODULE_LICENSE("GPL");


static int ignore_cis_vcc;
module_param(ignore_cis_vcc, int, 0444);
MODULE_PARM_DESC(ignore_cis_vcc, "Ignore broken CIS VCC entry");


38 39
/* struct local_info::hw_priv */
struct hostap_cs_priv {
40
	struct pcmcia_device *link;
41 42 43 44
	int sandisk_connectplus;
};


J
Jouni Malinen 已提交
45 46 47 48 49 50 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 81 82 83 84 85 86 87 88 89 90 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 126 127 128 129 130 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 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199
#ifdef PRISM2_IO_DEBUG

static inline void hfa384x_outb_debug(struct net_device *dev, int a, u8 v)
{
	struct hostap_interface *iface;
	local_info_t *local;
	unsigned long flags;

	iface = netdev_priv(dev);
	local = iface->local;
	spin_lock_irqsave(&local->lock, flags);
	prism2_io_debug_add(dev, PRISM2_IO_DEBUG_CMD_OUTB, a, v);
	outb(v, dev->base_addr + a);
	spin_unlock_irqrestore(&local->lock, flags);
}

static inline u8 hfa384x_inb_debug(struct net_device *dev, int a)
{
	struct hostap_interface *iface;
	local_info_t *local;
	unsigned long flags;
	u8 v;

	iface = netdev_priv(dev);
	local = iface->local;
	spin_lock_irqsave(&local->lock, flags);
	v = inb(dev->base_addr + a);
	prism2_io_debug_add(dev, PRISM2_IO_DEBUG_CMD_INB, a, v);
	spin_unlock_irqrestore(&local->lock, flags);
	return v;
}

static inline void hfa384x_outw_debug(struct net_device *dev, int a, u16 v)
{
	struct hostap_interface *iface;
	local_info_t *local;
	unsigned long flags;

	iface = netdev_priv(dev);
	local = iface->local;
	spin_lock_irqsave(&local->lock, flags);
	prism2_io_debug_add(dev, PRISM2_IO_DEBUG_CMD_OUTW, a, v);
	outw(v, dev->base_addr + a);
	spin_unlock_irqrestore(&local->lock, flags);
}

static inline u16 hfa384x_inw_debug(struct net_device *dev, int a)
{
	struct hostap_interface *iface;
	local_info_t *local;
	unsigned long flags;
	u16 v;

	iface = netdev_priv(dev);
	local = iface->local;
	spin_lock_irqsave(&local->lock, flags);
	v = inw(dev->base_addr + a);
	prism2_io_debug_add(dev, PRISM2_IO_DEBUG_CMD_INW, a, v);
	spin_unlock_irqrestore(&local->lock, flags);
	return v;
}

static inline void hfa384x_outsw_debug(struct net_device *dev, int a,
				       u8 *buf, int wc)
{
	struct hostap_interface *iface;
	local_info_t *local;
	unsigned long flags;

	iface = netdev_priv(dev);
	local = iface->local;
	spin_lock_irqsave(&local->lock, flags);
	prism2_io_debug_add(dev, PRISM2_IO_DEBUG_CMD_OUTSW, a, wc);
	outsw(dev->base_addr + a, buf, wc);
	spin_unlock_irqrestore(&local->lock, flags);
}

static inline void hfa384x_insw_debug(struct net_device *dev, int a,
				      u8 *buf, int wc)
{
	struct hostap_interface *iface;
	local_info_t *local;
	unsigned long flags;

	iface = netdev_priv(dev);
	local = iface->local;
	spin_lock_irqsave(&local->lock, flags);
	prism2_io_debug_add(dev, PRISM2_IO_DEBUG_CMD_INSW, a, wc);
	insw(dev->base_addr + a, buf, wc);
	spin_unlock_irqrestore(&local->lock, flags);
}

#define HFA384X_OUTB(v,a) hfa384x_outb_debug(dev, (a), (v))
#define HFA384X_INB(a) hfa384x_inb_debug(dev, (a))
#define HFA384X_OUTW(v,a) hfa384x_outw_debug(dev, (a), (v))
#define HFA384X_INW(a) hfa384x_inw_debug(dev, (a))
#define HFA384X_OUTSW(a, buf, wc) hfa384x_outsw_debug(dev, (a), (buf), (wc))
#define HFA384X_INSW(a, buf, wc) hfa384x_insw_debug(dev, (a), (buf), (wc))

#else /* PRISM2_IO_DEBUG */

#define HFA384X_OUTB(v,a) outb((v), dev->base_addr + (a))
#define HFA384X_INB(a) inb(dev->base_addr + (a))
#define HFA384X_OUTW(v,a) outw((v), dev->base_addr + (a))
#define HFA384X_INW(a) inw(dev->base_addr + (a))
#define HFA384X_INSW(a, buf, wc) insw(dev->base_addr + (a), buf, wc)
#define HFA384X_OUTSW(a, buf, wc) outsw(dev->base_addr + (a), buf, wc)

#endif /* PRISM2_IO_DEBUG */


static int hfa384x_from_bap(struct net_device *dev, u16 bap, void *buf,
			    int len)
{
	u16 d_off;
	u16 *pos;

	d_off = (bap == 1) ? HFA384X_DATA1_OFF : HFA384X_DATA0_OFF;
	pos = (u16 *) buf;

	if (len / 2)
		HFA384X_INSW(d_off, buf, len / 2);
	pos += len / 2;

	if (len & 1)
		*((char *) pos) = HFA384X_INB(d_off);

	return 0;
}


static int hfa384x_to_bap(struct net_device *dev, u16 bap, void *buf, int len)
{
	u16 d_off;
	u16 *pos;

	d_off = (bap == 1) ? HFA384X_DATA1_OFF : HFA384X_DATA0_OFF;
	pos = (u16 *) buf;

	if (len / 2)
		HFA384X_OUTSW(d_off, buf, len / 2);
	pos += len / 2;

	if (len & 1)
		HFA384X_OUTB(*((char *) pos), d_off);

	return 0;
}


/* FIX: This might change at some point.. */
#include "hostap_hw.c"



200
static void prism2_detach(struct pcmcia_device *p_dev);
J
Jouni Malinen 已提交
201
static void prism2_release(u_long arg);
202
static int prism2_config(struct pcmcia_device *link);
J
Jouni Malinen 已提交
203 204 205 206


static int prism2_pccard_card_present(local_info_t *local)
{
207
	struct hostap_cs_priv *hw_priv = local->hw_priv;
208
	if (hw_priv != NULL && hw_priv->link != NULL && pcmcia_dev_present(hw_priv->link))
J
Jouni Malinen 已提交
209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225
		return 1;
	return 0;
}


/*
 * SanDisk CompactFlash WLAN Flashcard - Product Manual v1.0
 * Document No. 20-10-00058, January 2004
 * http://www.sandisk.com/pdf/industrial/ProdManualCFWLANv1.0.pdf
 */
#define SANDISK_WLAN_ACTIVATION_OFF 0x40
#define SANDISK_HCR_OFF 0x42


static void sandisk_set_iobase(local_info_t *local)
{
	int res;
226
	struct hostap_cs_priv *hw_priv = local->hw_priv;
J
Jouni Malinen 已提交
227

228
	res = pcmcia_write_config_byte(hw_priv->link, 0x10,
229
				hw_priv->link->resource[0]->start & 0x00ff);
D
Dominik Brodowski 已提交
230
	if (res != 0) {
J
Jouni Malinen 已提交
231 232 233 234 235
		printk(KERN_DEBUG "Prism3 SanDisk - failed to set I/O base 0 -"
		       " res=%d\n", res);
	}
	udelay(10);

236
	res = pcmcia_write_config_byte(hw_priv->link, 0x12,
237
				(hw_priv->link->resource[0]->start >> 8) & 0x00ff);
D
Dominik Brodowski 已提交
238
	if (res != 0) {
J
Jouni Malinen 已提交
239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262
		printk(KERN_DEBUG "Prism3 SanDisk - failed to set I/O base 1 -"
		       " res=%d\n", res);
	}
}


static void sandisk_write_hcr(local_info_t *local, int hcr)
{
	struct net_device *dev = local->dev;
	int i;

	HFA384X_OUTB(0x80, SANDISK_WLAN_ACTIVATION_OFF);
	udelay(50);
	for (i = 0; i < 10; i++) {
		HFA384X_OUTB(hcr, SANDISK_HCR_OFF);
	}
	udelay(55);
	HFA384X_OUTB(0x45, SANDISK_WLAN_ACTIVATION_OFF);
}


static int sandisk_enable_wireless(struct net_device *dev)
{
	int res, ret = 0;
263
	struct hostap_interface *iface = netdev_priv(dev);
J
Jouni Malinen 已提交
264
	local_info_t *local = iface->local;
265
	struct hostap_cs_priv *hw_priv = local->hw_priv;
J
Jouni Malinen 已提交
266

267
	if (resource_size(hw_priv->link->resource[0]) < 0x42) {
J
Jouni Malinen 已提交
268 269 270 271 272
		/* Not enough ports to be SanDisk multi-function card */
		ret = -ENODEV;
		goto done;
	}

273
	if (hw_priv->link->manf_id != 0xd601 || hw_priv->link->card_id != 0x0101) {
J
Jouni Malinen 已提交
274 275 276 277 278
		/* No SanDisk manfid found */
		ret = -ENODEV;
		goto done;
	}

279
	if (hw_priv->link->socket->functions < 2) {
J
Jouni Malinen 已提交
280 281 282 283 284 285 286
		/* No multi-function links found */
		ret = -ENODEV;
		goto done;
	}

	printk(KERN_DEBUG "%s: Multi-function SanDisk ConnectPlus detected"
	       " - using vendor-specific initialization\n", dev->name);
287
	hw_priv->sandisk_connectplus = 1;
J
Jouni Malinen 已提交
288

289 290
	res = pcmcia_write_config_byte(hw_priv->link, CISREG_COR,
				COR_SOFT_RESET);
D
Dominik Brodowski 已提交
291
	if (res != 0) {
J
Jouni Malinen 已提交
292 293 294 295 296 297 298 299 300 301
		printk(KERN_DEBUG "%s: SanDisk - COR sreset failed (%d)\n",
		       dev->name, res);
		goto done;
	}
	mdelay(5);

	/*
	 * Do not enable interrupts here to avoid some bogus events. Interrupts
	 * will be enabled during the first cor_sreset call.
	 */
302 303 304
	res = pcmcia_write_config_byte(hw_priv->link, CISREG_COR,
				(COR_LEVEL_REQ | 0x8 | COR_ADDR_DECODE |
					COR_FUNC_ENA));
D
Dominik Brodowski 已提交
305
	if (res != 0) {
J
Jouni Malinen 已提交
306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326
		printk(KERN_DEBUG "%s: SanDisk - COR sreset failed (%d)\n",
		       dev->name, res);
		goto done;
	}
	mdelay(5);

	sandisk_set_iobase(local);

	HFA384X_OUTB(0xc5, SANDISK_WLAN_ACTIVATION_OFF);
	udelay(10);
	HFA384X_OUTB(0x4b, SANDISK_WLAN_ACTIVATION_OFF);
	udelay(10);

done:
	return ret;
}


static void prism2_pccard_cor_sreset(local_info_t *local)
{
	int res;
327
	u8 val;
328
	struct hostap_cs_priv *hw_priv = local->hw_priv;
J
Jouni Malinen 已提交
329 330 331 332

	if (!prism2_pccard_card_present(local))
	       return;

333
	res = pcmcia_read_config_byte(hw_priv->link, CISREG_COR, &val);
D
Dominik Brodowski 已提交
334
	if (res != 0) {
J
Jouni Malinen 已提交
335 336 337 338 339
		printk(KERN_DEBUG "prism2_pccard_cor_sreset failed 1 (%d)\n",
		       res);
		return;
	}
	printk(KERN_DEBUG "prism2_pccard_cor_sreset: original COR %02x\n",
340
		val);
J
Jouni Malinen 已提交
341

342 343
	val |= COR_SOFT_RESET;
	res = pcmcia_write_config_byte(hw_priv->link, CISREG_COR, val);
D
Dominik Brodowski 已提交
344
	if (res != 0) {
J
Jouni Malinen 已提交
345 346 347 348 349
		printk(KERN_DEBUG "prism2_pccard_cor_sreset failed 2 (%d)\n",
		       res);
		return;
	}

350
	mdelay(hw_priv->sandisk_connectplus ? 5 : 2);
J
Jouni Malinen 已提交
351

352
	val &= ~COR_SOFT_RESET;
353
	if (hw_priv->sandisk_connectplus)
354 355
		val |= COR_IREQ_ENA;
	res = pcmcia_write_config_byte(hw_priv->link, CISREG_COR, val);
D
Dominik Brodowski 已提交
356
	if (res != 0) {
J
Jouni Malinen 已提交
357 358 359 360 361
		printk(KERN_DEBUG "prism2_pccard_cor_sreset failed 3 (%d)\n",
		       res);
		return;
	}

362
	mdelay(hw_priv->sandisk_connectplus ? 5 : 2);
J
Jouni Malinen 已提交
363

364
	if (hw_priv->sandisk_connectplus)
J
Jouni Malinen 已提交
365 366 367 368 369 370 371
		sandisk_set_iobase(local);
}


static void prism2_pccard_genesis_reset(local_info_t *local, int hcr)
{
	int res;
372
	u8 old_cor;
373
	struct hostap_cs_priv *hw_priv = local->hw_priv;
J
Jouni Malinen 已提交
374 375 376 377

	if (!prism2_pccard_card_present(local))
	       return;

378
	if (hw_priv->sandisk_connectplus) {
J
Jouni Malinen 已提交
379 380 381 382
		sandisk_write_hcr(local, hcr);
		return;
	}

383
	res = pcmcia_read_config_byte(hw_priv->link, CISREG_COR, &old_cor);
D
Dominik Brodowski 已提交
384
	if (res != 0) {
J
Jouni Malinen 已提交
385 386 387 388 389
		printk(KERN_DEBUG "prism2_pccard_genesis_sreset failed 1 "
		       "(%d)\n", res);
		return;
	}
	printk(KERN_DEBUG "prism2_pccard_genesis_sreset: original COR %02x\n",
390
		old_cor);
J
Jouni Malinen 已提交
391

392 393
	res = pcmcia_write_config_byte(hw_priv->link, CISREG_COR,
				old_cor | COR_SOFT_RESET);
D
Dominik Brodowski 已提交
394
	if (res != 0) {
J
Jouni Malinen 已提交
395 396 397 398 399 400 401 402
		printk(KERN_DEBUG "prism2_pccard_genesis_sreset failed 2 "
		       "(%d)\n", res);
		return;
	}

	mdelay(10);

	/* Setup Genesis mode */
403
	res = pcmcia_write_config_byte(hw_priv->link, CISREG_CCSR, hcr);
D
Dominik Brodowski 已提交
404
	if (res != 0) {
J
Jouni Malinen 已提交
405 406 407 408 409 410
		printk(KERN_DEBUG "prism2_pccard_genesis_sreset failed 3 "
		       "(%d)\n", res);
		return;
	}
	mdelay(10);

411 412
	res = pcmcia_write_config_byte(hw_priv->link, CISREG_COR,
				old_cor & ~COR_SOFT_RESET);
D
Dominik Brodowski 已提交
413
	if (res != 0) {
J
Jouni Malinen 已提交
414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433
		printk(KERN_DEBUG "prism2_pccard_genesis_sreset failed 4 "
		       "(%d)\n", res);
		return;
	}

	mdelay(10);
}


static struct prism2_helper_functions prism2_pccard_funcs =
{
	.card_present	= prism2_pccard_card_present,
	.cor_sreset	= prism2_pccard_cor_sreset,
	.genesis_reset	= prism2_pccard_genesis_reset,
	.hw_type	= HOSTAP_HW_PCCARD,
};


/* allocate local data and register with CardServices
 * initialize dev_link structure, but do not configure the card yet */
434
static int hostap_cs_probe(struct pcmcia_device *p_dev)
J
Jouni Malinen 已提交
435
{
436 437
	int ret;

J
Jouni Malinen 已提交
438
	PDEBUG(DEBUG_HW, "%s: setting Vcc=33 (constant)\n", dev_info);
439

440 441
	ret = prism2_config(p_dev);
	if (ret) {
442
		PDEBUG(DEBUG_EXTRA, "prism2_config() failed\n");
443
	}
444

445
	return ret;
J
Jouni Malinen 已提交
446 447 448
}


449
static void prism2_detach(struct pcmcia_device *link)
J
Jouni Malinen 已提交
450 451 452
{
	PDEBUG(DEBUG_FLOW, "prism2_detach\n");

453
	prism2_release((u_long)link);
J
Jouni Malinen 已提交
454 455 456

	/* release net devices */
	if (link->priv) {
457
		struct hostap_cs_priv *hw_priv;
458 459 460 461
		struct net_device *dev;
		struct hostap_interface *iface;
		dev = link->priv;
		iface = netdev_priv(dev);
462
		hw_priv = iface->local->hw_priv;
463
		prism2_free_local_data(dev);
464
		kfree(hw_priv);
J
Jouni Malinen 已提交
465 466 467 468 469 470
	}
}


/* run after a CARD_INSERTION event is received to configure the PCMCIA
 * socket and make the device available to the system */
471

472
static int prism2_config_check(struct pcmcia_device *p_dev, void *priv_data)
473
{
474 475
	if (p_dev->config_index == 0)
		return -EINVAL;
476

477
	return pcmcia_request_io(p_dev);
478 479
}

480
static int prism2_config(struct pcmcia_device *link)
J
Jouni Malinen 已提交
481 482 483 484 485
{
	struct net_device *dev;
	struct hostap_interface *iface;
	local_info_t *local;
	int ret = 1;
486
	struct hostap_cs_priv *hw_priv;
487
	unsigned long flags;
J
Jouni Malinen 已提交
488 489 490

	PDEBUG(DEBUG_FLOW, "prism2_config()\n");

491
	hw_priv = kzalloc(sizeof(*hw_priv), GFP_KERNEL);
492
	if (hw_priv == NULL) {
J
Jouni Malinen 已提交
493 494 495 496 497
		ret = -ENOMEM;
		goto failed;
	}

	/* Look for an appropriate configuration table entry in the CIS */
498
	link->config_flags |= CONF_AUTO_SET_VPP | CONF_AUTO_AUDIO |
499
		CONF_AUTO_CHECK_VCC | CONF_AUTO_SET_IO | CONF_ENABLE_IRQ;
500 501
	if (ignore_cis_vcc)
		link->config_flags &= ~CONF_AUTO_CHECK_VCC;
502 503
	ret = pcmcia_loop_config(link, prism2_config_check, NULL);
	if (ret) {
504 505 506 507 508
		if (!ignore_cis_vcc)
			printk(KERN_ERR "GetNextTuple(): No matching "
			       "CIS configuration.  Maybe you need the "
			       "ignore_cis_vcc=1 parameter.\n");
		goto failed;
J
Jouni Malinen 已提交
509 510 511
	}

	/* Need to allocate net_device before requesting IRQ handler */
D
Dave Hansen 已提交
512
	dev = prism2_init_local_data(&prism2_pccard_funcs, 0,
513
				     &link->dev);
J
Jouni Malinen 已提交
514 515 516 517
	if (dev == NULL)
		goto failed;
	link->priv = dev;

518 519 520 521 522
	iface = netdev_priv(dev);
	local = iface->local;
	local->hw_priv = hw_priv;
	hw_priv->link = link;

523 524 525 526 527 528
	/*
	 * Make sure the IRQ handler cannot proceed until at least
	 * dev->base_addr is initialized.
	 */
	spin_lock_irqsave(&local->irq_init_lock, flags);

529 530
	ret = pcmcia_request_irq(link, prism2_interrupt);
	if (ret)
531
		goto failed_unlock;
J
Jouni Malinen 已提交
532 533 534 535 536 537

	/*
	 * This actually configures the PCMCIA socket -- setting up
	 * the I/O windows and the interrupt mapping, and putting the
	 * card and host interface into "Memory and IO" mode.
	 */
538
	ret = pcmcia_enable_device(link);
539
	if (ret)
540
		goto failed_unlock;
J
Jouni Malinen 已提交
541

542
	dev->irq = link->irq;
543
	dev->base_addr = link->resource[0]->start;
J
Jouni Malinen 已提交
544

545 546
	spin_unlock_irqrestore(&local->irq_init_lock, flags);

J
Jouni Malinen 已提交
547
	/* Finally, report what we've done */
548
	printk(KERN_INFO "%s: index 0x%02x: ",
549
	       dev_info, link->config_index);
550 551 552
	if (link->vpp)
		printk(", Vpp %d.%d", link->vpp / 10,
		       link->vpp % 10);
553
	printk(", irq %d", link->irq);
554 555 556 557
	if (link->resource[0])
		printk(" & %pR", link->resource[0]);
	if (link->resource[1])
		printk(" & %pR", link->resource[1]);
J
Jouni Malinen 已提交
558 559 560 561 562 563 564
	printk("\n");

	local->shutdown = 0;

	sandisk_enable_wireless(dev);

	ret = prism2_hw_config(dev, 1);
565
	if (!ret)
J
Jouni Malinen 已提交
566
		ret = hostap_hw_ready(dev);
567

J
Jouni Malinen 已提交
568 569
	return ret;

570 571
 failed_unlock:
	 spin_unlock_irqrestore(&local->irq_init_lock, flags);
J
Jouni Malinen 已提交
572
 failed:
573
	kfree(hw_priv);
J
Jouni Malinen 已提交
574 575 576 577 578 579 580
	prism2_release((u_long)link);
	return ret;
}


static void prism2_release(u_long arg)
{
581
	struct pcmcia_device *link = (struct pcmcia_device *)arg;
J
Jouni Malinen 已提交
582 583 584 585 586 587 588 589

	PDEBUG(DEBUG_FLOW, "prism2_release\n");

	if (link->priv) {
		struct net_device *dev = link->priv;
		struct hostap_interface *iface;

		iface = netdev_priv(dev);
590
		prism2_hw_shutdown(dev, 0);
J
Jouni Malinen 已提交
591 592 593
		iface->local->shutdown = 1;
	}

594
	pcmcia_disable_device(link);
J
Jouni Malinen 已提交
595 596 597
	PDEBUG(DEBUG_FLOW, "release - done\n");
}

598
static int hostap_cs_suspend(struct pcmcia_device *link)
599 600 601
{
	struct net_device *dev = (struct net_device *) link->priv;
	int dev_open = 0;
602
	struct hostap_interface *iface = NULL;
J
Jouni Malinen 已提交
603

604 605 606 607
	if (!dev)
		return -ENODEV;

	iface = netdev_priv(dev);
608

609 610 611 612 613 614
	PDEBUG(DEBUG_EXTRA, "%s: CS_EVENT_PM_SUSPEND\n", dev_info);
	if (iface && iface->local)
		dev_open = iface->local->num_dev_open > 0;
	if (dev_open) {
		netif_stop_queue(dev);
		netif_device_detach(dev);
615
	}
616
	prism2_suspend(dev);
617 618 619 620

	return 0;
}

621
static int hostap_cs_resume(struct pcmcia_device *link)
J
Jouni Malinen 已提交
622 623
{
	struct net_device *dev = (struct net_device *) link->priv;
624
	int dev_open = 0;
625 626
	struct hostap_interface *iface = NULL;

627 628 629 630
	if (!dev)
		return -ENODEV;

	iface = netdev_priv(dev);
631

632 633
	PDEBUG(DEBUG_EXTRA, "%s: CS_EVENT_PM_RESUME\n", dev_info);

634 635
	if (iface && iface->local)
		dev_open = iface->local->num_dev_open > 0;
636

637 638 639 640 641
	prism2_hw_shutdown(dev, 1);
	prism2_hw_config(dev, dev_open ? 0 : 1);
	if (dev_open) {
		netif_device_attach(dev);
		netif_start_queue(dev);
642
	}
J
Jouni Malinen 已提交
643

644 645 646
	return 0;
}

H
Henrik Brix Andersen 已提交
647 648 649 650 651 652
static struct pcmcia_device_id hostap_cs_ids[] = {
	PCMCIA_DEVICE_MANF_CARD(0x000b, 0x7100),
	PCMCIA_DEVICE_MANF_CARD(0x000b, 0x7300),
	PCMCIA_DEVICE_MANF_CARD(0x0101, 0x0777),
	PCMCIA_DEVICE_MANF_CARD(0x0126, 0x8000),
	PCMCIA_DEVICE_MANF_CARD(0x0138, 0x0002),
653
	PCMCIA_DEVICE_MANF_CARD(0x01bf, 0x3301),
H
Henrik Brix Andersen 已提交
654
	PCMCIA_DEVICE_MANF_CARD(0x0250, 0x0002),
R
Richard Purdie 已提交
655
	PCMCIA_DEVICE_MANF_CARD(0x026f, 0x030b),
H
Henrik Brix Andersen 已提交
656 657 658 659 660 661 662
	PCMCIA_DEVICE_MANF_CARD(0x0274, 0x1612),
	PCMCIA_DEVICE_MANF_CARD(0x0274, 0x1613),
	PCMCIA_DEVICE_MANF_CARD(0x028a, 0x0002),
	PCMCIA_DEVICE_MANF_CARD(0x02aa, 0x0002),
	PCMCIA_DEVICE_MANF_CARD(0x02d2, 0x0001),
	PCMCIA_DEVICE_MANF_CARD(0x50c2, 0x0001),
	PCMCIA_DEVICE_MANF_CARD(0x50c2, 0x7300),
663
/*	PCMCIA_DEVICE_MANF_CARD(0xc00f, 0x0000),    conflict with pcnet_cs */
664
	PCMCIA_DEVICE_MANF_CARD(0xc250, 0x0002),
H
Henrik Brix Andersen 已提交
665 666 667
	PCMCIA_DEVICE_MANF_CARD(0xd601, 0x0002),
	PCMCIA_DEVICE_MANF_CARD(0xd601, 0x0005),
	PCMCIA_DEVICE_MANF_CARD(0xd601, 0x0010),
668
	PCMCIA_DEVICE_MANF_CARD(0x0126, 0x0002),
669 670
	PCMCIA_DEVICE_MANF_CARD_PROD_ID1(0xd601, 0x0005, "ADLINK 345 CF",
					 0x2d858104),
671 672 673 674
	PCMCIA_DEVICE_MANF_CARD_PROD_ID1(0x0156, 0x0002, "INTERSIL",
					 0x74c5e40d),
	PCMCIA_DEVICE_MANF_CARD_PROD_ID1(0x0156, 0x0002, "Intersil",
					 0x4b801a17),
H
Henrik Brix Andersen 已提交
675 676 677 678 679 680 681 682 683 684 685 686 687 688
	PCMCIA_MFC_DEVICE_PROD_ID12(0, "SanDisk", "ConnectPlus",
				    0x7a954bd9, 0x74be00c6),
	PCMCIA_DEVICE_PROD_ID123(
		"Addtron", "AWP-100 Wireless PCMCIA", "Version 01.02",
		0xe6ec52ce, 0x08649af2, 0x4b74baa0),
	PCMCIA_DEVICE_PROD_ID123(
		"D", "Link DWL-650 11Mbps WLAN Card", "Version 01.02",
		0x71b18589, 0xb6f1b0ab, 0x4b74baa0),
	PCMCIA_DEVICE_PROD_ID123(
		"Instant Wireless ", " Network PC CARD", "Version 01.02",
		0x11d901af, 0x6e9bd926, 0x4b74baa0),
	PCMCIA_DEVICE_PROD_ID123(
		"SMC", "SMC2632W", "Version 01.02",
		0xc4f8b18b, 0x474a1f2a, 0x4b74baa0),
R
Richard Purdie 已提交
689
	PCMCIA_DEVICE_PROD_ID12("BUFFALO", "WLI-CF-S11G", 
690
				0x2decece3, 0x82067c18),
H
Henrik Brix Andersen 已提交
691 692 693 694 695 696 697 698 699
	PCMCIA_DEVICE_PROD_ID12("Compaq", "WL200_11Mbps_Wireless_PCI_Card",
				0x54f7c49c, 0x15a75e5b),
	PCMCIA_DEVICE_PROD_ID12("INTERSIL", "HFA384x/IEEE",
				0x74c5e40d, 0xdb472a18),
	PCMCIA_DEVICE_PROD_ID12("Linksys", "Wireless CompactFlash Card",
				0x0733cc81, 0x0c52f395),
	PCMCIA_DEVICE_PROD_ID12(
		"ZoomAir 11Mbps High", "Rate wireless Networking",
		0x273fe3db, 0x32a1eaee),
700 701 702 703 704 705
	PCMCIA_DEVICE_PROD_ID123(
		"Pretec", "CompactWLAN Card 802.11b", "2.5",
		0x1cadd3e5, 0xe697636c, 0x7a5bfcf1),
	PCMCIA_DEVICE_PROD_ID123(
		"U.S. Robotics", "IEEE 802.11b PC-CARD", "Version 01.02",
		0xc7b8df9d, 0x1700d087, 0x4b74baa0),
706 707 708 709
	PCMCIA_DEVICE_PROD_ID123(
		"Allied Telesyn", "AT-WCL452 Wireless PCMCIA Radio",
		"Ver. 1.00",
		0x5cd01705, 0x4271660f, 0x9d08ee12),
710 711 712
	PCMCIA_DEVICE_PROD_ID123(
		"Wireless LAN" , "11Mbps PC Card", "Version 01.02",
		0x4b8870ff, 0x70e946d1, 0x4b74baa0),
P
Pavel Roskin 已提交
713 714 715 716
	PCMCIA_DEVICE_PROD_ID3("HFA3863", 0x355cb092),
	PCMCIA_DEVICE_PROD_ID3("ISL37100P", 0x630d52b2),
	PCMCIA_DEVICE_PROD_ID3("ISL37101P-10", 0xdd97a26b),
	PCMCIA_DEVICE_PROD_ID3("ISL37300P", 0xc9049a39),
H
Henrik Brix Andersen 已提交
717 718 719 720 721
	PCMCIA_DEVICE_NULL
};
MODULE_DEVICE_TABLE(pcmcia, hostap_cs_ids);


J
Jouni Malinen 已提交
722 723 724 725
static struct pcmcia_driver hostap_driver = {
	.drv		= {
		.name	= "hostap_cs",
	},
726
	.probe		= hostap_cs_probe,
727
	.remove		= prism2_detach,
J
Jouni Malinen 已提交
728
	.owner		= THIS_MODULE,
H
Henrik Brix Andersen 已提交
729
	.id_table	= hostap_cs_ids,
730 731
	.suspend	= hostap_cs_suspend,
	.resume		= hostap_cs_resume,
J
Jouni Malinen 已提交
732 733 734 735 736 737 738 739 740 741 742 743 744 745 746
};

static int __init init_prism2_pccard(void)
{
	return pcmcia_register_driver(&hostap_driver);
}

static void __exit exit_prism2_pccard(void)
{
	pcmcia_unregister_driver(&hostap_driver);
}


module_init(init_prism2_pccard);
module_exit(exit_prism2_pccard);