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