hostap_cs.c 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800
  1. #define PRISM2_PCCARD
  2. #include <linux/module.h>
  3. #include <linux/init.h>
  4. #include <linux/if.h>
  5. #include <linux/slab.h>
  6. #include <linux/wait.h>
  7. #include <linux/timer.h>
  8. #include <linux/skbuff.h>
  9. #include <linux/netdevice.h>
  10. #include <linux/workqueue.h>
  11. #include <linux/wireless.h>
  12. #include <net/iw_handler.h>
  13. #include <pcmcia/cistpl.h>
  14. #include <pcmcia/cisreg.h>
  15. #include <pcmcia/ds.h>
  16. #include <asm/io.h>
  17. #include "hostap_wlan.h"
  18. static char *dev_info = "hostap_cs";
  19. MODULE_AUTHOR("Jouni Malinen");
  20. MODULE_DESCRIPTION("Support for Intersil Prism2-based 802.11 wireless LAN "
  21. "cards (PC Card).");
  22. MODULE_SUPPORTED_DEVICE("Intersil Prism2-based WLAN cards (PC Card)");
  23. MODULE_LICENSE("GPL");
  24. static int ignore_cis_vcc;
  25. module_param(ignore_cis_vcc, int, 0444);
  26. MODULE_PARM_DESC(ignore_cis_vcc, "Ignore broken CIS VCC entry");
  27. /* struct local_info::hw_priv */
  28. struct hostap_cs_priv {
  29. struct pcmcia_device *link;
  30. int sandisk_connectplus;
  31. };
  32. #ifdef PRISM2_IO_DEBUG
  33. static inline void hfa384x_outb_debug(struct net_device *dev, int a, u8 v)
  34. {
  35. struct hostap_interface *iface;
  36. local_info_t *local;
  37. unsigned long flags;
  38. iface = netdev_priv(dev);
  39. local = iface->local;
  40. spin_lock_irqsave(&local->lock, flags);
  41. prism2_io_debug_add(dev, PRISM2_IO_DEBUG_CMD_OUTB, a, v);
  42. outb(v, dev->base_addr + a);
  43. spin_unlock_irqrestore(&local->lock, flags);
  44. }
  45. static inline u8 hfa384x_inb_debug(struct net_device *dev, int a)
  46. {
  47. struct hostap_interface *iface;
  48. local_info_t *local;
  49. unsigned long flags;
  50. u8 v;
  51. iface = netdev_priv(dev);
  52. local = iface->local;
  53. spin_lock_irqsave(&local->lock, flags);
  54. v = inb(dev->base_addr + a);
  55. prism2_io_debug_add(dev, PRISM2_IO_DEBUG_CMD_INB, a, v);
  56. spin_unlock_irqrestore(&local->lock, flags);
  57. return v;
  58. }
  59. static inline void hfa384x_outw_debug(struct net_device *dev, int a, u16 v)
  60. {
  61. struct hostap_interface *iface;
  62. local_info_t *local;
  63. unsigned long flags;
  64. iface = netdev_priv(dev);
  65. local = iface->local;
  66. spin_lock_irqsave(&local->lock, flags);
  67. prism2_io_debug_add(dev, PRISM2_IO_DEBUG_CMD_OUTW, a, v);
  68. outw(v, dev->base_addr + a);
  69. spin_unlock_irqrestore(&local->lock, flags);
  70. }
  71. static inline u16 hfa384x_inw_debug(struct net_device *dev, int a)
  72. {
  73. struct hostap_interface *iface;
  74. local_info_t *local;
  75. unsigned long flags;
  76. u16 v;
  77. iface = netdev_priv(dev);
  78. local = iface->local;
  79. spin_lock_irqsave(&local->lock, flags);
  80. v = inw(dev->base_addr + a);
  81. prism2_io_debug_add(dev, PRISM2_IO_DEBUG_CMD_INW, a, v);
  82. spin_unlock_irqrestore(&local->lock, flags);
  83. return v;
  84. }
  85. static inline void hfa384x_outsw_debug(struct net_device *dev, int a,
  86. u8 *buf, int wc)
  87. {
  88. struct hostap_interface *iface;
  89. local_info_t *local;
  90. unsigned long flags;
  91. iface = netdev_priv(dev);
  92. local = iface->local;
  93. spin_lock_irqsave(&local->lock, flags);
  94. prism2_io_debug_add(dev, PRISM2_IO_DEBUG_CMD_OUTSW, a, wc);
  95. outsw(dev->base_addr + a, buf, wc);
  96. spin_unlock_irqrestore(&local->lock, flags);
  97. }
  98. static inline void hfa384x_insw_debug(struct net_device *dev, int a,
  99. u8 *buf, int wc)
  100. {
  101. struct hostap_interface *iface;
  102. local_info_t *local;
  103. unsigned long flags;
  104. iface = netdev_priv(dev);
  105. local = iface->local;
  106. spin_lock_irqsave(&local->lock, flags);
  107. prism2_io_debug_add(dev, PRISM2_IO_DEBUG_CMD_INSW, a, wc);
  108. insw(dev->base_addr + a, buf, wc);
  109. spin_unlock_irqrestore(&local->lock, flags);
  110. }
  111. #define HFA384X_OUTB(v,a) hfa384x_outb_debug(dev, (a), (v))
  112. #define HFA384X_INB(a) hfa384x_inb_debug(dev, (a))
  113. #define HFA384X_OUTW(v,a) hfa384x_outw_debug(dev, (a), (v))
  114. #define HFA384X_INW(a) hfa384x_inw_debug(dev, (a))
  115. #define HFA384X_OUTSW(a, buf, wc) hfa384x_outsw_debug(dev, (a), (buf), (wc))
  116. #define HFA384X_INSW(a, buf, wc) hfa384x_insw_debug(dev, (a), (buf), (wc))
  117. #else /* PRISM2_IO_DEBUG */
  118. #define HFA384X_OUTB(v,a) outb((v), dev->base_addr + (a))
  119. #define HFA384X_INB(a) inb(dev->base_addr + (a))
  120. #define HFA384X_OUTW(v,a) outw((v), dev->base_addr + (a))
  121. #define HFA384X_INW(a) inw(dev->base_addr + (a))
  122. #define HFA384X_INSW(a, buf, wc) insw(dev->base_addr + (a), buf, wc)
  123. #define HFA384X_OUTSW(a, buf, wc) outsw(dev->base_addr + (a), buf, wc)
  124. #endif /* PRISM2_IO_DEBUG */
  125. static int hfa384x_from_bap(struct net_device *dev, u16 bap, void *buf,
  126. int len)
  127. {
  128. u16 d_off;
  129. u16 *pos;
  130. d_off = (bap == 1) ? HFA384X_DATA1_OFF : HFA384X_DATA0_OFF;
  131. pos = (u16 *) buf;
  132. if (len / 2)
  133. HFA384X_INSW(d_off, buf, len / 2);
  134. pos += len / 2;
  135. if (len & 1)
  136. *((char *) pos) = HFA384X_INB(d_off);
  137. return 0;
  138. }
  139. static int hfa384x_to_bap(struct net_device *dev, u16 bap, void *buf, int len)
  140. {
  141. u16 d_off;
  142. u16 *pos;
  143. d_off = (bap == 1) ? HFA384X_DATA1_OFF : HFA384X_DATA0_OFF;
  144. pos = (u16 *) buf;
  145. if (len / 2)
  146. HFA384X_OUTSW(d_off, buf, len / 2);
  147. pos += len / 2;
  148. if (len & 1)
  149. HFA384X_OUTB(*((char *) pos), d_off);
  150. return 0;
  151. }
  152. /* FIX: This might change at some point.. */
  153. #include "hostap_hw.c"
  154. static void prism2_detach(struct pcmcia_device *p_dev);
  155. static void prism2_release(u_long arg);
  156. static int prism2_config(struct pcmcia_device *link);
  157. static int prism2_pccard_card_present(local_info_t *local)
  158. {
  159. struct hostap_cs_priv *hw_priv = local->hw_priv;
  160. if (hw_priv != NULL && hw_priv->link != NULL && pcmcia_dev_present(hw_priv->link))
  161. return 1;
  162. return 0;
  163. }
  164. /*
  165. * SanDisk CompactFlash WLAN Flashcard - Product Manual v1.0
  166. * Document No. 20-10-00058, January 2004
  167. * http://www.sandisk.com/pdf/industrial/ProdManualCFWLANv1.0.pdf
  168. */
  169. #define SANDISK_WLAN_ACTIVATION_OFF 0x40
  170. #define SANDISK_HCR_OFF 0x42
  171. static void sandisk_set_iobase(local_info_t *local)
  172. {
  173. int res;
  174. struct hostap_cs_priv *hw_priv = local->hw_priv;
  175. res = pcmcia_write_config_byte(hw_priv->link, 0x10,
  176. hw_priv->link->resource[0]->start & 0x00ff);
  177. if (res != 0) {
  178. printk(KERN_DEBUG "Prism3 SanDisk - failed to set I/O base 0 -"
  179. " res=%d\n", res);
  180. }
  181. udelay(10);
  182. res = pcmcia_write_config_byte(hw_priv->link, 0x12,
  183. (hw_priv->link->resource[0]->start >> 8) & 0x00ff);
  184. if (res != 0) {
  185. printk(KERN_DEBUG "Prism3 SanDisk - failed to set I/O base 1 -"
  186. " res=%d\n", res);
  187. }
  188. }
  189. static void sandisk_write_hcr(local_info_t *local, int hcr)
  190. {
  191. struct net_device *dev = local->dev;
  192. int i;
  193. HFA384X_OUTB(0x80, SANDISK_WLAN_ACTIVATION_OFF);
  194. udelay(50);
  195. for (i = 0; i < 10; i++) {
  196. HFA384X_OUTB(hcr, SANDISK_HCR_OFF);
  197. }
  198. udelay(55);
  199. HFA384X_OUTB(0x45, SANDISK_WLAN_ACTIVATION_OFF);
  200. }
  201. static int sandisk_enable_wireless(struct net_device *dev)
  202. {
  203. int res, ret = 0;
  204. struct hostap_interface *iface = netdev_priv(dev);
  205. local_info_t *local = iface->local;
  206. struct hostap_cs_priv *hw_priv = local->hw_priv;
  207. if (resource_size(hw_priv->link->resource[0]) < 0x42) {
  208. /* Not enough ports to be SanDisk multi-function card */
  209. ret = -ENODEV;
  210. goto done;
  211. }
  212. if (hw_priv->link->manf_id != 0xd601 || hw_priv->link->card_id != 0x0101) {
  213. /* No SanDisk manfid found */
  214. ret = -ENODEV;
  215. goto done;
  216. }
  217. if (hw_priv->link->socket->functions < 2) {
  218. /* No multi-function links found */
  219. ret = -ENODEV;
  220. goto done;
  221. }
  222. printk(KERN_DEBUG "%s: Multi-function SanDisk ConnectPlus detected"
  223. " - using vendor-specific initialization\n", dev->name);
  224. hw_priv->sandisk_connectplus = 1;
  225. res = pcmcia_write_config_byte(hw_priv->link, CISREG_COR,
  226. COR_SOFT_RESET);
  227. if (res != 0) {
  228. printk(KERN_DEBUG "%s: SanDisk - COR sreset failed (%d)\n",
  229. dev->name, res);
  230. goto done;
  231. }
  232. mdelay(5);
  233. /*
  234. * Do not enable interrupts here to avoid some bogus events. Interrupts
  235. * will be enabled during the first cor_sreset call.
  236. */
  237. res = pcmcia_write_config_byte(hw_priv->link, CISREG_COR,
  238. (COR_LEVEL_REQ | 0x8 | COR_ADDR_DECODE |
  239. COR_FUNC_ENA));
  240. if (res != 0) {
  241. printk(KERN_DEBUG "%s: SanDisk - COR sreset failed (%d)\n",
  242. dev->name, res);
  243. goto done;
  244. }
  245. mdelay(5);
  246. sandisk_set_iobase(local);
  247. HFA384X_OUTB(0xc5, SANDISK_WLAN_ACTIVATION_OFF);
  248. udelay(10);
  249. HFA384X_OUTB(0x4b, SANDISK_WLAN_ACTIVATION_OFF);
  250. udelay(10);
  251. done:
  252. return ret;
  253. }
  254. static void prism2_pccard_cor_sreset(local_info_t *local)
  255. {
  256. int res;
  257. u8 val;
  258. struct hostap_cs_priv *hw_priv = local->hw_priv;
  259. if (!prism2_pccard_card_present(local))
  260. return;
  261. res = pcmcia_read_config_byte(hw_priv->link, CISREG_COR, &val);
  262. if (res != 0) {
  263. printk(KERN_DEBUG "prism2_pccard_cor_sreset failed 1 (%d)\n",
  264. res);
  265. return;
  266. }
  267. printk(KERN_DEBUG "prism2_pccard_cor_sreset: original COR %02x\n",
  268. val);
  269. val |= COR_SOFT_RESET;
  270. res = pcmcia_write_config_byte(hw_priv->link, CISREG_COR, val);
  271. if (res != 0) {
  272. printk(KERN_DEBUG "prism2_pccard_cor_sreset failed 2 (%d)\n",
  273. res);
  274. return;
  275. }
  276. mdelay(hw_priv->sandisk_connectplus ? 5 : 2);
  277. val &= ~COR_SOFT_RESET;
  278. if (hw_priv->sandisk_connectplus)
  279. val |= COR_IREQ_ENA;
  280. res = pcmcia_write_config_byte(hw_priv->link, CISREG_COR, val);
  281. if (res != 0) {
  282. printk(KERN_DEBUG "prism2_pccard_cor_sreset failed 3 (%d)\n",
  283. res);
  284. return;
  285. }
  286. mdelay(hw_priv->sandisk_connectplus ? 5 : 2);
  287. if (hw_priv->sandisk_connectplus)
  288. sandisk_set_iobase(local);
  289. }
  290. static void prism2_pccard_genesis_reset(local_info_t *local, int hcr)
  291. {
  292. int res;
  293. u8 old_cor;
  294. struct hostap_cs_priv *hw_priv = local->hw_priv;
  295. if (!prism2_pccard_card_present(local))
  296. return;
  297. if (hw_priv->sandisk_connectplus) {
  298. sandisk_write_hcr(local, hcr);
  299. return;
  300. }
  301. res = pcmcia_read_config_byte(hw_priv->link, CISREG_COR, &old_cor);
  302. if (res != 0) {
  303. printk(KERN_DEBUG "prism2_pccard_genesis_sreset failed 1 "
  304. "(%d)\n", res);
  305. return;
  306. }
  307. printk(KERN_DEBUG "prism2_pccard_genesis_sreset: original COR %02x\n",
  308. old_cor);
  309. res = pcmcia_write_config_byte(hw_priv->link, CISREG_COR,
  310. old_cor | COR_SOFT_RESET);
  311. if (res != 0) {
  312. printk(KERN_DEBUG "prism2_pccard_genesis_sreset failed 2 "
  313. "(%d)\n", res);
  314. return;
  315. }
  316. mdelay(10);
  317. /* Setup Genesis mode */
  318. res = pcmcia_write_config_byte(hw_priv->link, CISREG_CCSR, hcr);
  319. if (res != 0) {
  320. printk(KERN_DEBUG "prism2_pccard_genesis_sreset failed 3 "
  321. "(%d)\n", res);
  322. return;
  323. }
  324. mdelay(10);
  325. res = pcmcia_write_config_byte(hw_priv->link, CISREG_COR,
  326. old_cor & ~COR_SOFT_RESET);
  327. if (res != 0) {
  328. printk(KERN_DEBUG "prism2_pccard_genesis_sreset failed 4 "
  329. "(%d)\n", res);
  330. return;
  331. }
  332. mdelay(10);
  333. }
  334. static struct prism2_helper_functions prism2_pccard_funcs =
  335. {
  336. .card_present = prism2_pccard_card_present,
  337. .cor_sreset = prism2_pccard_cor_sreset,
  338. .genesis_reset = prism2_pccard_genesis_reset,
  339. .hw_type = HOSTAP_HW_PCCARD,
  340. };
  341. /* allocate local data and register with CardServices
  342. * initialize dev_link structure, but do not configure the card yet */
  343. static int hostap_cs_probe(struct pcmcia_device *p_dev)
  344. {
  345. int ret;
  346. PDEBUG(DEBUG_HW, "%s: setting Vcc=33 (constant)\n", dev_info);
  347. ret = prism2_config(p_dev);
  348. if (ret) {
  349. PDEBUG(DEBUG_EXTRA, "prism2_config() failed\n");
  350. }
  351. return ret;
  352. }
  353. static void prism2_detach(struct pcmcia_device *link)
  354. {
  355. PDEBUG(DEBUG_FLOW, "prism2_detach\n");
  356. prism2_release((u_long)link);
  357. /* release net devices */
  358. if (link->priv) {
  359. struct hostap_cs_priv *hw_priv;
  360. struct net_device *dev;
  361. struct hostap_interface *iface;
  362. dev = link->priv;
  363. iface = netdev_priv(dev);
  364. hw_priv = iface->local->hw_priv;
  365. prism2_free_local_data(dev);
  366. kfree(hw_priv);
  367. }
  368. }
  369. /* run after a CARD_INSERTION event is received to configure the PCMCIA
  370. * socket and make the device available to the system */
  371. static int prism2_config_check(struct pcmcia_device *p_dev,
  372. cistpl_cftable_entry_t *cfg,
  373. cistpl_cftable_entry_t *dflt,
  374. unsigned int vcc,
  375. void *priv_data)
  376. {
  377. if (cfg->index == 0)
  378. return -ENODEV;
  379. PDEBUG(DEBUG_EXTRA, "Checking CFTABLE_ENTRY 0x%02X "
  380. "(default 0x%02X)\n", cfg->index, dflt->index);
  381. /* Does this card need audio output? */
  382. if (cfg->flags & CISTPL_CFTABLE_AUDIO)
  383. p_dev->config_flags |= CONF_ENABLE_SPKR;
  384. /* Use power settings for Vcc and Vpp if present */
  385. /* Note that the CIS values need to be rescaled */
  386. if (cfg->vcc.present & (1 << CISTPL_POWER_VNOM)) {
  387. if (vcc != cfg->vcc.param[CISTPL_POWER_VNOM] /
  388. 10000 && !ignore_cis_vcc) {
  389. PDEBUG(DEBUG_EXTRA, " Vcc mismatch - skipping"
  390. " this entry\n");
  391. return -ENODEV;
  392. }
  393. } else if (dflt->vcc.present & (1 << CISTPL_POWER_VNOM)) {
  394. if (vcc != dflt->vcc.param[CISTPL_POWER_VNOM] /
  395. 10000 && !ignore_cis_vcc) {
  396. PDEBUG(DEBUG_EXTRA, " Vcc (default) mismatch "
  397. "- skipping this entry\n");
  398. return -ENODEV;
  399. }
  400. }
  401. if (cfg->vpp1.present & (1 << CISTPL_POWER_VNOM))
  402. p_dev->vpp = cfg->vpp1.param[CISTPL_POWER_VNOM] / 10000;
  403. else if (dflt->vpp1.present & (1 << CISTPL_POWER_VNOM))
  404. p_dev->vpp = dflt->vpp1.param[CISTPL_POWER_VNOM] / 10000;
  405. /* Do we need to allocate an interrupt? */
  406. p_dev->config_flags |= CONF_ENABLE_IRQ;
  407. /* IO window settings */
  408. PDEBUG(DEBUG_EXTRA, "IO window settings: cfg->io.nwin=%d "
  409. "dflt->io.nwin=%d\n",
  410. cfg->io.nwin, dflt->io.nwin);
  411. p_dev->resource[0]->end = p_dev->resource[1]->end = 0;
  412. if ((cfg->io.nwin > 0) || (dflt->io.nwin > 0)) {
  413. cistpl_io_t *io = (cfg->io.nwin) ? &cfg->io : &dflt->io;
  414. p_dev->resource[0]->flags &= ~IO_DATA_PATH_WIDTH;
  415. p_dev->resource[0]->flags |=
  416. pcmcia_io_cfg_data_width(io->flags);
  417. p_dev->io_lines = io->flags & CISTPL_IO_LINES_MASK;
  418. p_dev->resource[0]->start = io->win[0].base;
  419. p_dev->resource[0]->end = io->win[0].len;
  420. if (io->nwin > 1) {
  421. p_dev->resource[1]->flags = p_dev->resource[0]->flags;
  422. p_dev->resource[1]->start = io->win[1].base;
  423. p_dev->resource[1]->end = io->win[1].len;
  424. }
  425. }
  426. /* This reserves IO space but doesn't actually enable it */
  427. return pcmcia_request_io(p_dev);
  428. }
  429. static int prism2_config(struct pcmcia_device *link)
  430. {
  431. struct net_device *dev;
  432. struct hostap_interface *iface;
  433. local_info_t *local;
  434. int ret = 1;
  435. struct hostap_cs_priv *hw_priv;
  436. unsigned long flags;
  437. PDEBUG(DEBUG_FLOW, "prism2_config()\n");
  438. hw_priv = kzalloc(sizeof(*hw_priv), GFP_KERNEL);
  439. if (hw_priv == NULL) {
  440. ret = -ENOMEM;
  441. goto failed;
  442. }
  443. /* Look for an appropriate configuration table entry in the CIS */
  444. ret = pcmcia_loop_config(link, prism2_config_check, NULL);
  445. if (ret) {
  446. if (!ignore_cis_vcc)
  447. printk(KERN_ERR "GetNextTuple(): No matching "
  448. "CIS configuration. Maybe you need the "
  449. "ignore_cis_vcc=1 parameter.\n");
  450. goto failed;
  451. }
  452. /* Need to allocate net_device before requesting IRQ handler */
  453. dev = prism2_init_local_data(&prism2_pccard_funcs, 0,
  454. &link->dev);
  455. if (dev == NULL)
  456. goto failed;
  457. link->priv = dev;
  458. iface = netdev_priv(dev);
  459. local = iface->local;
  460. local->hw_priv = hw_priv;
  461. hw_priv->link = link;
  462. /*
  463. * Make sure the IRQ handler cannot proceed until at least
  464. * dev->base_addr is initialized.
  465. */
  466. spin_lock_irqsave(&local->irq_init_lock, flags);
  467. ret = pcmcia_request_irq(link, prism2_interrupt);
  468. if (ret)
  469. goto failed_unlock;
  470. /*
  471. * This actually configures the PCMCIA socket -- setting up
  472. * the I/O windows and the interrupt mapping, and putting the
  473. * card and host interface into "Memory and IO" mode.
  474. */
  475. ret = pcmcia_enable_device(link);
  476. if (ret)
  477. goto failed_unlock;
  478. dev->irq = link->irq;
  479. dev->base_addr = link->resource[0]->start;
  480. spin_unlock_irqrestore(&local->irq_init_lock, flags);
  481. /* Finally, report what we've done */
  482. printk(KERN_INFO "%s: index 0x%02x: ",
  483. dev_info, link->config_index);
  484. if (link->vpp)
  485. printk(", Vpp %d.%d", link->vpp / 10,
  486. link->vpp % 10);
  487. printk(", irq %d", link->irq);
  488. if (link->resource[0])
  489. printk(" & %pR", link->resource[0]);
  490. if (link->resource[1])
  491. printk(" & %pR", link->resource[1]);
  492. printk("\n");
  493. local->shutdown = 0;
  494. sandisk_enable_wireless(dev);
  495. ret = prism2_hw_config(dev, 1);
  496. if (!ret)
  497. ret = hostap_hw_ready(dev);
  498. return ret;
  499. failed_unlock:
  500. spin_unlock_irqrestore(&local->irq_init_lock, flags);
  501. failed:
  502. kfree(hw_priv);
  503. prism2_release((u_long)link);
  504. return ret;
  505. }
  506. static void prism2_release(u_long arg)
  507. {
  508. struct pcmcia_device *link = (struct pcmcia_device *)arg;
  509. PDEBUG(DEBUG_FLOW, "prism2_release\n");
  510. if (link->priv) {
  511. struct net_device *dev = link->priv;
  512. struct hostap_interface *iface;
  513. iface = netdev_priv(dev);
  514. prism2_hw_shutdown(dev, 0);
  515. iface->local->shutdown = 1;
  516. }
  517. pcmcia_disable_device(link);
  518. PDEBUG(DEBUG_FLOW, "release - done\n");
  519. }
  520. static int hostap_cs_suspend(struct pcmcia_device *link)
  521. {
  522. struct net_device *dev = (struct net_device *) link->priv;
  523. int dev_open = 0;
  524. struct hostap_interface *iface = NULL;
  525. if (!dev)
  526. return -ENODEV;
  527. iface = netdev_priv(dev);
  528. PDEBUG(DEBUG_EXTRA, "%s: CS_EVENT_PM_SUSPEND\n", dev_info);
  529. if (iface && iface->local)
  530. dev_open = iface->local->num_dev_open > 0;
  531. if (dev_open) {
  532. netif_stop_queue(dev);
  533. netif_device_detach(dev);
  534. }
  535. prism2_suspend(dev);
  536. return 0;
  537. }
  538. static int hostap_cs_resume(struct pcmcia_device *link)
  539. {
  540. struct net_device *dev = (struct net_device *) link->priv;
  541. int dev_open = 0;
  542. struct hostap_interface *iface = NULL;
  543. if (!dev)
  544. return -ENODEV;
  545. iface = netdev_priv(dev);
  546. PDEBUG(DEBUG_EXTRA, "%s: CS_EVENT_PM_RESUME\n", dev_info);
  547. if (iface && iface->local)
  548. dev_open = iface->local->num_dev_open > 0;
  549. prism2_hw_shutdown(dev, 1);
  550. prism2_hw_config(dev, dev_open ? 0 : 1);
  551. if (dev_open) {
  552. netif_device_attach(dev);
  553. netif_start_queue(dev);
  554. }
  555. return 0;
  556. }
  557. static struct pcmcia_device_id hostap_cs_ids[] = {
  558. PCMCIA_DEVICE_MANF_CARD(0x000b, 0x7100),
  559. PCMCIA_DEVICE_MANF_CARD(0x000b, 0x7300),
  560. PCMCIA_DEVICE_MANF_CARD(0x0101, 0x0777),
  561. PCMCIA_DEVICE_MANF_CARD(0x0126, 0x8000),
  562. PCMCIA_DEVICE_MANF_CARD(0x0138, 0x0002),
  563. PCMCIA_DEVICE_MANF_CARD(0x01bf, 0x3301),
  564. PCMCIA_DEVICE_MANF_CARD(0x0250, 0x0002),
  565. PCMCIA_DEVICE_MANF_CARD(0x026f, 0x030b),
  566. PCMCIA_DEVICE_MANF_CARD(0x0274, 0x1612),
  567. PCMCIA_DEVICE_MANF_CARD(0x0274, 0x1613),
  568. PCMCIA_DEVICE_MANF_CARD(0x028a, 0x0002),
  569. PCMCIA_DEVICE_MANF_CARD(0x02aa, 0x0002),
  570. PCMCIA_DEVICE_MANF_CARD(0x02d2, 0x0001),
  571. PCMCIA_DEVICE_MANF_CARD(0x50c2, 0x0001),
  572. PCMCIA_DEVICE_MANF_CARD(0x50c2, 0x7300),
  573. /* PCMCIA_DEVICE_MANF_CARD(0xc00f, 0x0000), conflict with pcnet_cs */
  574. PCMCIA_DEVICE_MANF_CARD(0xc250, 0x0002),
  575. PCMCIA_DEVICE_MANF_CARD(0xd601, 0x0002),
  576. PCMCIA_DEVICE_MANF_CARD(0xd601, 0x0005),
  577. PCMCIA_DEVICE_MANF_CARD(0xd601, 0x0010),
  578. PCMCIA_DEVICE_MANF_CARD(0x0126, 0x0002),
  579. PCMCIA_DEVICE_MANF_CARD_PROD_ID1(0xd601, 0x0005, "ADLINK 345 CF",
  580. 0x2d858104),
  581. PCMCIA_DEVICE_MANF_CARD_PROD_ID1(0x0156, 0x0002, "INTERSIL",
  582. 0x74c5e40d),
  583. PCMCIA_DEVICE_MANF_CARD_PROD_ID1(0x0156, 0x0002, "Intersil",
  584. 0x4b801a17),
  585. PCMCIA_MFC_DEVICE_PROD_ID12(0, "SanDisk", "ConnectPlus",
  586. 0x7a954bd9, 0x74be00c6),
  587. PCMCIA_DEVICE_PROD_ID123(
  588. "Addtron", "AWP-100 Wireless PCMCIA", "Version 01.02",
  589. 0xe6ec52ce, 0x08649af2, 0x4b74baa0),
  590. PCMCIA_DEVICE_PROD_ID123(
  591. "D", "Link DWL-650 11Mbps WLAN Card", "Version 01.02",
  592. 0x71b18589, 0xb6f1b0ab, 0x4b74baa0),
  593. PCMCIA_DEVICE_PROD_ID123(
  594. "Instant Wireless ", " Network PC CARD", "Version 01.02",
  595. 0x11d901af, 0x6e9bd926, 0x4b74baa0),
  596. PCMCIA_DEVICE_PROD_ID123(
  597. "SMC", "SMC2632W", "Version 01.02",
  598. 0xc4f8b18b, 0x474a1f2a, 0x4b74baa0),
  599. PCMCIA_DEVICE_PROD_ID12("BUFFALO", "WLI-CF-S11G",
  600. 0x2decece3, 0x82067c18),
  601. PCMCIA_DEVICE_PROD_ID12("Compaq", "WL200_11Mbps_Wireless_PCI_Card",
  602. 0x54f7c49c, 0x15a75e5b),
  603. PCMCIA_DEVICE_PROD_ID12("INTERSIL", "HFA384x/IEEE",
  604. 0x74c5e40d, 0xdb472a18),
  605. PCMCIA_DEVICE_PROD_ID12("Linksys", "Wireless CompactFlash Card",
  606. 0x0733cc81, 0x0c52f395),
  607. PCMCIA_DEVICE_PROD_ID12(
  608. "ZoomAir 11Mbps High", "Rate wireless Networking",
  609. 0x273fe3db, 0x32a1eaee),
  610. PCMCIA_DEVICE_PROD_ID123(
  611. "Pretec", "CompactWLAN Card 802.11b", "2.5",
  612. 0x1cadd3e5, 0xe697636c, 0x7a5bfcf1),
  613. PCMCIA_DEVICE_PROD_ID123(
  614. "U.S. Robotics", "IEEE 802.11b PC-CARD", "Version 01.02",
  615. 0xc7b8df9d, 0x1700d087, 0x4b74baa0),
  616. PCMCIA_DEVICE_PROD_ID123(
  617. "Allied Telesyn", "AT-WCL452 Wireless PCMCIA Radio",
  618. "Ver. 1.00",
  619. 0x5cd01705, 0x4271660f, 0x9d08ee12),
  620. PCMCIA_DEVICE_PROD_ID123(
  621. "Wireless LAN" , "11Mbps PC Card", "Version 01.02",
  622. 0x4b8870ff, 0x70e946d1, 0x4b74baa0),
  623. PCMCIA_DEVICE_PROD_ID3("HFA3863", 0x355cb092),
  624. PCMCIA_DEVICE_PROD_ID3("ISL37100P", 0x630d52b2),
  625. PCMCIA_DEVICE_PROD_ID3("ISL37101P-10", 0xdd97a26b),
  626. PCMCIA_DEVICE_PROD_ID3("ISL37300P", 0xc9049a39),
  627. PCMCIA_DEVICE_NULL
  628. };
  629. MODULE_DEVICE_TABLE(pcmcia, hostap_cs_ids);
  630. static struct pcmcia_driver hostap_driver = {
  631. .drv = {
  632. .name = "hostap_cs",
  633. },
  634. .probe = hostap_cs_probe,
  635. .remove = prism2_detach,
  636. .owner = THIS_MODULE,
  637. .id_table = hostap_cs_ids,
  638. .suspend = hostap_cs_suspend,
  639. .resume = hostap_cs_resume,
  640. };
  641. static int __init init_prism2_pccard(void)
  642. {
  643. return pcmcia_register_driver(&hostap_driver);
  644. }
  645. static void __exit exit_prism2_pccard(void)
  646. {
  647. pcmcia_unregister_driver(&hostap_driver);
  648. }
  649. module_init(init_prism2_pccard);
  650. module_exit(exit_prism2_pccard);