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