Jouni Malinen | ff1d276 | 2005-05-12 22:54:16 -0400 | [diff] [blame] | 1 | #define PRISM2_PCI |
| 2 | |
| 3 | /* Host AP driver's support for Intersil Prism2.5 PCI cards is based on |
| 4 | * driver patches from Reyk Floeter <reyk@vantronix.net> and |
| 5 | * Andy Warner <andyw@pobox.com> */ |
| 6 | |
| 7 | #include <linux/config.h> |
Jouni Malinen | ff1d276 | 2005-05-12 22:54:16 -0400 | [diff] [blame] | 8 | #include <linux/module.h> |
| 9 | #include <linux/init.h> |
| 10 | #include <linux/if.h> |
| 11 | #include <linux/skbuff.h> |
| 12 | #include <linux/netdevice.h> |
| 13 | #include <linux/workqueue.h> |
| 14 | #include <linux/wireless.h> |
| 15 | #include <net/iw_handler.h> |
| 16 | |
| 17 | #include <linux/ioport.h> |
| 18 | #include <linux/pci.h> |
| 19 | #include <asm/io.h> |
| 20 | |
| 21 | #include "hostap_wlan.h" |
| 22 | |
| 23 | |
| 24 | static char *version = PRISM2_VERSION " (Jouni Malinen <jkmaline@cc.hut.fi>)"; |
| 25 | static char *dev_info = "hostap_pci"; |
| 26 | |
| 27 | |
| 28 | MODULE_AUTHOR("Jouni Malinen"); |
| 29 | MODULE_DESCRIPTION("Support for Intersil Prism2.5-based 802.11 wireless LAN " |
| 30 | "PCI cards."); |
| 31 | MODULE_SUPPORTED_DEVICE("Intersil Prism2.5-based WLAN PCI cards"); |
| 32 | MODULE_LICENSE("GPL"); |
Jouni Malinen | f06ac31 | 2005-07-30 12:50:00 -0700 | [diff] [blame] | 33 | MODULE_VERSION(PRISM2_VERSION); |
Jouni Malinen | ff1d276 | 2005-05-12 22:54:16 -0400 | [diff] [blame] | 34 | |
| 35 | |
Jouni Malinen | 67e0e47 | 2005-08-14 19:08:41 -0700 | [diff] [blame] | 36 | /* struct local_info::hw_priv */ |
| 37 | struct hostap_pci_priv { |
| 38 | void __iomem *mem_start; |
| 39 | }; |
| 40 | |
| 41 | |
Jouni Malinen | ff1d276 | 2005-05-12 22:54:16 -0400 | [diff] [blame] | 42 | /* FIX: do we need mb/wmb/rmb with memory operations? */ |
| 43 | |
| 44 | |
| 45 | static struct pci_device_id prism2_pci_id_table[] __devinitdata = { |
| 46 | /* Intersil Prism3 ISL3872 11Mb/s WLAN Controller */ |
| 47 | { 0x1260, 0x3872, PCI_ANY_ID, PCI_ANY_ID }, |
| 48 | /* Intersil Prism2.5 ISL3874 11Mb/s WLAN Controller */ |
| 49 | { 0x1260, 0x3873, PCI_ANY_ID, PCI_ANY_ID }, |
| 50 | /* Samsung MagicLAN SWL-2210P */ |
| 51 | { 0x167d, 0xa000, PCI_ANY_ID, PCI_ANY_ID }, |
| 52 | { 0 } |
| 53 | }; |
| 54 | |
| 55 | |
| 56 | #ifdef PRISM2_IO_DEBUG |
| 57 | |
| 58 | static inline void hfa384x_outb_debug(struct net_device *dev, int a, u8 v) |
| 59 | { |
| 60 | struct hostap_interface *iface; |
Jouni Malinen | f7a7444 | 2005-10-02 17:18:59 -0700 | [diff] [blame] | 61 | struct hostap_pci_priv *hw_priv; |
Jouni Malinen | ff1d276 | 2005-05-12 22:54:16 -0400 | [diff] [blame] | 62 | local_info_t *local; |
| 63 | unsigned long flags; |
| 64 | |
| 65 | iface = netdev_priv(dev); |
| 66 | local = iface->local; |
Jouni Malinen | f7a7444 | 2005-10-02 17:18:59 -0700 | [diff] [blame] | 67 | hw_priv = local->hw_priv; |
Jouni Malinen | ff1d276 | 2005-05-12 22:54:16 -0400 | [diff] [blame] | 68 | |
| 69 | spin_lock_irqsave(&local->lock, flags); |
| 70 | prism2_io_debug_add(dev, PRISM2_IO_DEBUG_CMD_OUTB, a, v); |
Jouni Malinen | 67e0e47 | 2005-08-14 19:08:41 -0700 | [diff] [blame] | 71 | writeb(v, hw_priv->mem_start + a); |
Jouni Malinen | ff1d276 | 2005-05-12 22:54:16 -0400 | [diff] [blame] | 72 | spin_unlock_irqrestore(&local->lock, flags); |
| 73 | } |
| 74 | |
| 75 | static inline u8 hfa384x_inb_debug(struct net_device *dev, int a) |
| 76 | { |
| 77 | struct hostap_interface *iface; |
Jouni Malinen | f7a7444 | 2005-10-02 17:18:59 -0700 | [diff] [blame] | 78 | struct hostap_pci_priv *hw_priv; |
Jouni Malinen | ff1d276 | 2005-05-12 22:54:16 -0400 | [diff] [blame] | 79 | local_info_t *local; |
| 80 | unsigned long flags; |
| 81 | u8 v; |
| 82 | |
| 83 | iface = netdev_priv(dev); |
| 84 | local = iface->local; |
Jouni Malinen | f7a7444 | 2005-10-02 17:18:59 -0700 | [diff] [blame] | 85 | hw_priv = local->hw_priv; |
Jouni Malinen | ff1d276 | 2005-05-12 22:54:16 -0400 | [diff] [blame] | 86 | |
| 87 | spin_lock_irqsave(&local->lock, flags); |
Jouni Malinen | 67e0e47 | 2005-08-14 19:08:41 -0700 | [diff] [blame] | 88 | v = readb(hw_priv->mem_start + a); |
Jouni Malinen | ff1d276 | 2005-05-12 22:54:16 -0400 | [diff] [blame] | 89 | prism2_io_debug_add(dev, PRISM2_IO_DEBUG_CMD_INB, a, v); |
| 90 | spin_unlock_irqrestore(&local->lock, flags); |
| 91 | return v; |
| 92 | } |
| 93 | |
| 94 | static inline void hfa384x_outw_debug(struct net_device *dev, int a, u16 v) |
| 95 | { |
| 96 | struct hostap_interface *iface; |
Jouni Malinen | f7a7444 | 2005-10-02 17:18:59 -0700 | [diff] [blame] | 97 | struct hostap_pci_priv *hw_priv; |
Jouni Malinen | ff1d276 | 2005-05-12 22:54:16 -0400 | [diff] [blame] | 98 | local_info_t *local; |
| 99 | unsigned long flags; |
| 100 | |
| 101 | iface = netdev_priv(dev); |
| 102 | local = iface->local; |
Jouni Malinen | f7a7444 | 2005-10-02 17:18:59 -0700 | [diff] [blame] | 103 | hw_priv = local->hw_priv; |
Jouni Malinen | ff1d276 | 2005-05-12 22:54:16 -0400 | [diff] [blame] | 104 | |
| 105 | spin_lock_irqsave(&local->lock, flags); |
| 106 | prism2_io_debug_add(dev, PRISM2_IO_DEBUG_CMD_OUTW, a, v); |
Jouni Malinen | 67e0e47 | 2005-08-14 19:08:41 -0700 | [diff] [blame] | 107 | writew(v, hw_priv->mem_start + a); |
Jouni Malinen | ff1d276 | 2005-05-12 22:54:16 -0400 | [diff] [blame] | 108 | spin_unlock_irqrestore(&local->lock, flags); |
| 109 | } |
| 110 | |
| 111 | static inline u16 hfa384x_inw_debug(struct net_device *dev, int a) |
| 112 | { |
| 113 | struct hostap_interface *iface; |
Jouni Malinen | f7a7444 | 2005-10-02 17:18:59 -0700 | [diff] [blame] | 114 | struct hostap_pci_priv *hw_priv; |
Jouni Malinen | ff1d276 | 2005-05-12 22:54:16 -0400 | [diff] [blame] | 115 | local_info_t *local; |
| 116 | unsigned long flags; |
| 117 | u16 v; |
| 118 | |
| 119 | iface = netdev_priv(dev); |
| 120 | local = iface->local; |
Jouni Malinen | f7a7444 | 2005-10-02 17:18:59 -0700 | [diff] [blame] | 121 | hw_priv = local->hw_priv; |
Jouni Malinen | ff1d276 | 2005-05-12 22:54:16 -0400 | [diff] [blame] | 122 | |
| 123 | spin_lock_irqsave(&local->lock, flags); |
Jouni Malinen | 67e0e47 | 2005-08-14 19:08:41 -0700 | [diff] [blame] | 124 | v = readw(hw_priv->mem_start + a); |
Jouni Malinen | ff1d276 | 2005-05-12 22:54:16 -0400 | [diff] [blame] | 125 | prism2_io_debug_add(dev, PRISM2_IO_DEBUG_CMD_INW, a, v); |
| 126 | spin_unlock_irqrestore(&local->lock, flags); |
| 127 | return v; |
| 128 | } |
| 129 | |
| 130 | #define HFA384X_OUTB(v,a) hfa384x_outb_debug(dev, (a), (v)) |
| 131 | #define HFA384X_INB(a) hfa384x_inb_debug(dev, (a)) |
| 132 | #define HFA384X_OUTW(v,a) hfa384x_outw_debug(dev, (a), (v)) |
| 133 | #define HFA384X_INW(a) hfa384x_inw_debug(dev, (a)) |
| 134 | #define HFA384X_OUTW_DATA(v,a) hfa384x_outw_debug(dev, (a), cpu_to_le16((v))) |
| 135 | #define HFA384X_INW_DATA(a) (u16) le16_to_cpu(hfa384x_inw_debug(dev, (a))) |
| 136 | |
| 137 | #else /* PRISM2_IO_DEBUG */ |
| 138 | |
| 139 | static inline void hfa384x_outb(struct net_device *dev, int a, u8 v) |
| 140 | { |
| 141 | struct hostap_interface *iface; |
Jouni Malinen | 67e0e47 | 2005-08-14 19:08:41 -0700 | [diff] [blame] | 142 | struct hostap_pci_priv *hw_priv; |
Jouni Malinen | ff1d276 | 2005-05-12 22:54:16 -0400 | [diff] [blame] | 143 | iface = netdev_priv(dev); |
Jouni Malinen | 67e0e47 | 2005-08-14 19:08:41 -0700 | [diff] [blame] | 144 | hw_priv = iface->local->hw_priv; |
| 145 | writeb(v, hw_priv->mem_start + a); |
Jouni Malinen | ff1d276 | 2005-05-12 22:54:16 -0400 | [diff] [blame] | 146 | } |
| 147 | |
| 148 | static inline u8 hfa384x_inb(struct net_device *dev, int a) |
| 149 | { |
| 150 | struct hostap_interface *iface; |
Jouni Malinen | 67e0e47 | 2005-08-14 19:08:41 -0700 | [diff] [blame] | 151 | struct hostap_pci_priv *hw_priv; |
Jouni Malinen | ff1d276 | 2005-05-12 22:54:16 -0400 | [diff] [blame] | 152 | iface = netdev_priv(dev); |
Jouni Malinen | 67e0e47 | 2005-08-14 19:08:41 -0700 | [diff] [blame] | 153 | hw_priv = iface->local->hw_priv; |
| 154 | return readb(hw_priv->mem_start + a); |
Jouni Malinen | ff1d276 | 2005-05-12 22:54:16 -0400 | [diff] [blame] | 155 | } |
| 156 | |
| 157 | static inline void hfa384x_outw(struct net_device *dev, int a, u16 v) |
| 158 | { |
| 159 | struct hostap_interface *iface; |
Jouni Malinen | 67e0e47 | 2005-08-14 19:08:41 -0700 | [diff] [blame] | 160 | struct hostap_pci_priv *hw_priv; |
Jouni Malinen | ff1d276 | 2005-05-12 22:54:16 -0400 | [diff] [blame] | 161 | iface = netdev_priv(dev); |
Jouni Malinen | 67e0e47 | 2005-08-14 19:08:41 -0700 | [diff] [blame] | 162 | hw_priv = iface->local->hw_priv; |
| 163 | writew(v, hw_priv->mem_start + a); |
Jouni Malinen | ff1d276 | 2005-05-12 22:54:16 -0400 | [diff] [blame] | 164 | } |
| 165 | |
| 166 | static inline u16 hfa384x_inw(struct net_device *dev, int a) |
| 167 | { |
| 168 | struct hostap_interface *iface; |
Jouni Malinen | 67e0e47 | 2005-08-14 19:08:41 -0700 | [diff] [blame] | 169 | struct hostap_pci_priv *hw_priv; |
Jouni Malinen | ff1d276 | 2005-05-12 22:54:16 -0400 | [diff] [blame] | 170 | iface = netdev_priv(dev); |
Jouni Malinen | 67e0e47 | 2005-08-14 19:08:41 -0700 | [diff] [blame] | 171 | hw_priv = iface->local->hw_priv; |
| 172 | return readw(hw_priv->mem_start + a); |
Jouni Malinen | ff1d276 | 2005-05-12 22:54:16 -0400 | [diff] [blame] | 173 | } |
| 174 | |
| 175 | #define HFA384X_OUTB(v,a) hfa384x_outb(dev, (a), (v)) |
| 176 | #define HFA384X_INB(a) hfa384x_inb(dev, (a)) |
| 177 | #define HFA384X_OUTW(v,a) hfa384x_outw(dev, (a), (v)) |
| 178 | #define HFA384X_INW(a) hfa384x_inw(dev, (a)) |
| 179 | #define HFA384X_OUTW_DATA(v,a) hfa384x_outw(dev, (a), cpu_to_le16((v))) |
| 180 | #define HFA384X_INW_DATA(a) (u16) le16_to_cpu(hfa384x_inw(dev, (a))) |
| 181 | |
| 182 | #endif /* PRISM2_IO_DEBUG */ |
| 183 | |
| 184 | |
| 185 | static int hfa384x_from_bap(struct net_device *dev, u16 bap, void *buf, |
| 186 | int len) |
| 187 | { |
| 188 | u16 d_off; |
| 189 | u16 *pos; |
| 190 | |
| 191 | d_off = (bap == 1) ? HFA384X_DATA1_OFF : HFA384X_DATA0_OFF; |
| 192 | pos = (u16 *) buf; |
| 193 | |
| 194 | for ( ; len > 1; len -= 2) |
| 195 | *pos++ = HFA384X_INW_DATA(d_off); |
| 196 | |
| 197 | if (len & 1) |
| 198 | *((char *) pos) = HFA384X_INB(d_off); |
| 199 | |
| 200 | return 0; |
| 201 | } |
| 202 | |
| 203 | |
| 204 | static int hfa384x_to_bap(struct net_device *dev, u16 bap, void *buf, int len) |
| 205 | { |
| 206 | u16 d_off; |
| 207 | u16 *pos; |
| 208 | |
| 209 | d_off = (bap == 1) ? HFA384X_DATA1_OFF : HFA384X_DATA0_OFF; |
| 210 | pos = (u16 *) buf; |
| 211 | |
| 212 | for ( ; len > 1; len -= 2) |
| 213 | HFA384X_OUTW_DATA(*pos++, d_off); |
| 214 | |
| 215 | if (len & 1) |
| 216 | HFA384X_OUTB(*((char *) pos), d_off); |
| 217 | |
| 218 | return 0; |
| 219 | } |
| 220 | |
| 221 | |
| 222 | /* FIX: This might change at some point.. */ |
| 223 | #include "hostap_hw.c" |
| 224 | |
| 225 | static void prism2_pci_cor_sreset(local_info_t *local) |
| 226 | { |
| 227 | struct net_device *dev = local->dev; |
| 228 | u16 reg; |
| 229 | |
| 230 | reg = HFA384X_INB(HFA384X_PCICOR_OFF); |
| 231 | printk(KERN_DEBUG "%s: Original COR value: 0x%0x\n", dev->name, reg); |
| 232 | |
| 233 | /* linux-wlan-ng uses extremely long hold and settle times for |
| 234 | * COR sreset. A comment in the driver code mentions that the long |
| 235 | * delays appear to be necessary. However, at least IBM 22P6901 seems |
| 236 | * to work fine with shorter delays. |
| 237 | * |
| 238 | * Longer delays can be configured by uncommenting following line: */ |
| 239 | /* #define PRISM2_PCI_USE_LONG_DELAYS */ |
| 240 | |
| 241 | #ifdef PRISM2_PCI_USE_LONG_DELAYS |
| 242 | int i; |
| 243 | |
| 244 | HFA384X_OUTW(reg | 0x0080, HFA384X_PCICOR_OFF); |
| 245 | mdelay(250); |
| 246 | |
| 247 | HFA384X_OUTW(reg & ~0x0080, HFA384X_PCICOR_OFF); |
| 248 | mdelay(500); |
| 249 | |
| 250 | /* Wait for f/w to complete initialization (CMD:BUSY == 0) */ |
| 251 | i = 2000000 / 10; |
| 252 | while ((HFA384X_INW(HFA384X_CMD_OFF) & HFA384X_CMD_BUSY) && --i) |
| 253 | udelay(10); |
| 254 | |
| 255 | #else /* PRISM2_PCI_USE_LONG_DELAYS */ |
| 256 | |
| 257 | HFA384X_OUTW(reg | 0x0080, HFA384X_PCICOR_OFF); |
| 258 | mdelay(2); |
| 259 | HFA384X_OUTW(reg & ~0x0080, HFA384X_PCICOR_OFF); |
| 260 | mdelay(2); |
| 261 | |
| 262 | #endif /* PRISM2_PCI_USE_LONG_DELAYS */ |
| 263 | |
| 264 | if (HFA384X_INW(HFA384X_CMD_OFF) & HFA384X_CMD_BUSY) { |
| 265 | printk(KERN_DEBUG "%s: COR sreset timeout\n", dev->name); |
| 266 | } |
| 267 | } |
| 268 | |
| 269 | |
| 270 | static void prism2_pci_genesis_reset(local_info_t *local, int hcr) |
| 271 | { |
| 272 | struct net_device *dev = local->dev; |
| 273 | |
| 274 | HFA384X_OUTW(0x00C5, HFA384X_PCICOR_OFF); |
| 275 | mdelay(10); |
| 276 | HFA384X_OUTW(hcr, HFA384X_PCIHCR_OFF); |
| 277 | mdelay(10); |
| 278 | HFA384X_OUTW(0x0045, HFA384X_PCICOR_OFF); |
| 279 | mdelay(10); |
| 280 | } |
| 281 | |
| 282 | |
| 283 | static struct prism2_helper_functions prism2_pci_funcs = |
| 284 | { |
| 285 | .card_present = NULL, |
| 286 | .cor_sreset = prism2_pci_cor_sreset, |
Jouni Malinen | ff1d276 | 2005-05-12 22:54:16 -0400 | [diff] [blame] | 287 | .genesis_reset = prism2_pci_genesis_reset, |
| 288 | .hw_type = HOSTAP_HW_PCI, |
| 289 | }; |
| 290 | |
| 291 | |
| 292 | static int prism2_pci_probe(struct pci_dev *pdev, |
| 293 | const struct pci_device_id *id) |
| 294 | { |
| 295 | unsigned long phymem; |
| 296 | void __iomem *mem = NULL; |
| 297 | local_info_t *local = NULL; |
| 298 | struct net_device *dev = NULL; |
| 299 | static int cards_found /* = 0 */; |
| 300 | int irq_registered = 0; |
| 301 | struct hostap_interface *iface; |
Jouni Malinen | 67e0e47 | 2005-08-14 19:08:41 -0700 | [diff] [blame] | 302 | struct hostap_pci_priv *hw_priv; |
| 303 | |
| 304 | hw_priv = kmalloc(sizeof(*hw_priv), GFP_KERNEL); |
| 305 | if (hw_priv == NULL) |
| 306 | return -ENOMEM; |
| 307 | memset(hw_priv, 0, sizeof(*hw_priv)); |
Jouni Malinen | ff1d276 | 2005-05-12 22:54:16 -0400 | [diff] [blame] | 308 | |
| 309 | if (pci_enable_device(pdev)) |
Jouni Malinen | 9320199 | 2006-03-19 19:21:49 -0800 | [diff] [blame^] | 310 | goto err_out_free; |
Jouni Malinen | ff1d276 | 2005-05-12 22:54:16 -0400 | [diff] [blame] | 311 | |
| 312 | phymem = pci_resource_start(pdev, 0); |
| 313 | |
| 314 | if (!request_mem_region(phymem, pci_resource_len(pdev, 0), "Prism2")) { |
| 315 | printk(KERN_ERR "prism2: Cannot reserve PCI memory region\n"); |
| 316 | goto err_out_disable; |
| 317 | } |
| 318 | |
| 319 | mem = ioremap(phymem, pci_resource_len(pdev, 0)); |
| 320 | if (mem == NULL) { |
| 321 | printk(KERN_ERR "prism2: Cannot remap PCI memory region\n") ; |
| 322 | goto fail; |
| 323 | } |
| 324 | |
Dave Hansen | 0cd545d | 2005-07-30 12:49:58 -0700 | [diff] [blame] | 325 | dev = prism2_init_local_data(&prism2_pci_funcs, cards_found, |
| 326 | &pdev->dev); |
Jouni Malinen | ff1d276 | 2005-05-12 22:54:16 -0400 | [diff] [blame] | 327 | if (dev == NULL) |
| 328 | goto fail; |
| 329 | iface = netdev_priv(dev); |
| 330 | local = iface->local; |
Jouni Malinen | 67e0e47 | 2005-08-14 19:08:41 -0700 | [diff] [blame] | 331 | local->hw_priv = hw_priv; |
Jouni Malinen | ff1d276 | 2005-05-12 22:54:16 -0400 | [diff] [blame] | 332 | cards_found++; |
| 333 | |
| 334 | dev->irq = pdev->irq; |
Jouni Malinen | 67e0e47 | 2005-08-14 19:08:41 -0700 | [diff] [blame] | 335 | hw_priv->mem_start = mem; |
Jouni Malinen | ff1d276 | 2005-05-12 22:54:16 -0400 | [diff] [blame] | 336 | |
| 337 | prism2_pci_cor_sreset(local); |
| 338 | |
| 339 | pci_set_drvdata(pdev, dev); |
| 340 | |
| 341 | if (request_irq(dev->irq, prism2_interrupt, SA_SHIRQ, dev->name, |
| 342 | dev)) { |
| 343 | printk(KERN_WARNING "%s: request_irq failed\n", dev->name); |
| 344 | goto fail; |
| 345 | } else |
| 346 | irq_registered = 1; |
| 347 | |
| 348 | if (!local->pri_only && prism2_hw_config(dev, 1)) { |
| 349 | printk(KERN_DEBUG "%s: hardware initialization failed\n", |
| 350 | dev_info); |
| 351 | goto fail; |
| 352 | } |
| 353 | |
| 354 | printk(KERN_INFO "%s: Intersil Prism2.5 PCI: " |
| 355 | "mem=0x%lx, irq=%d\n", dev->name, phymem, dev->irq); |
| 356 | |
| 357 | return hostap_hw_ready(dev); |
| 358 | |
| 359 | fail: |
| 360 | if (irq_registered && dev) |
| 361 | free_irq(dev->irq, dev); |
| 362 | |
| 363 | if (mem) |
| 364 | iounmap(mem); |
| 365 | |
| 366 | release_mem_region(phymem, pci_resource_len(pdev, 0)); |
| 367 | |
| 368 | err_out_disable: |
| 369 | pci_disable_device(pdev); |
| 370 | prism2_free_local_data(dev); |
Jouni Malinen | 9320199 | 2006-03-19 19:21:49 -0800 | [diff] [blame^] | 371 | |
| 372 | err_out_free: |
Jouni Malinen | c355184 | 2005-10-02 17:19:00 -0700 | [diff] [blame] | 373 | kfree(hw_priv); |
Jouni Malinen | ff1d276 | 2005-05-12 22:54:16 -0400 | [diff] [blame] | 374 | |
| 375 | return -ENODEV; |
| 376 | } |
| 377 | |
| 378 | |
| 379 | static void prism2_pci_remove(struct pci_dev *pdev) |
| 380 | { |
| 381 | struct net_device *dev; |
| 382 | struct hostap_interface *iface; |
| 383 | void __iomem *mem_start; |
Jouni Malinen | 67e0e47 | 2005-08-14 19:08:41 -0700 | [diff] [blame] | 384 | struct hostap_pci_priv *hw_priv; |
Jouni Malinen | ff1d276 | 2005-05-12 22:54:16 -0400 | [diff] [blame] | 385 | |
| 386 | dev = pci_get_drvdata(pdev); |
| 387 | iface = netdev_priv(dev); |
Jouni Malinen | 67e0e47 | 2005-08-14 19:08:41 -0700 | [diff] [blame] | 388 | hw_priv = iface->local->hw_priv; |
Jouni Malinen | ff1d276 | 2005-05-12 22:54:16 -0400 | [diff] [blame] | 389 | |
| 390 | /* Reset the hardware, and ensure interrupts are disabled. */ |
| 391 | prism2_pci_cor_sreset(iface->local); |
| 392 | hfa384x_disable_interrupts(dev); |
| 393 | |
| 394 | if (dev->irq) |
| 395 | free_irq(dev->irq, dev); |
| 396 | |
Jouni Malinen | 67e0e47 | 2005-08-14 19:08:41 -0700 | [diff] [blame] | 397 | mem_start = hw_priv->mem_start; |
Jouni Malinen | ff1d276 | 2005-05-12 22:54:16 -0400 | [diff] [blame] | 398 | prism2_free_local_data(dev); |
Jouni Malinen | c355184 | 2005-10-02 17:19:00 -0700 | [diff] [blame] | 399 | kfree(hw_priv); |
Jouni Malinen | ff1d276 | 2005-05-12 22:54:16 -0400 | [diff] [blame] | 400 | |
| 401 | iounmap(mem_start); |
| 402 | |
| 403 | release_mem_region(pci_resource_start(pdev, 0), |
| 404 | pci_resource_len(pdev, 0)); |
| 405 | pci_disable_device(pdev); |
| 406 | } |
| 407 | |
| 408 | |
| 409 | #ifdef CONFIG_PM |
Andrew Morton | b2dabd5 | 2005-07-13 00:33:46 -0700 | [diff] [blame] | 410 | static int prism2_pci_suspend(struct pci_dev *pdev, pm_message_t state) |
Jouni Malinen | ff1d276 | 2005-05-12 22:54:16 -0400 | [diff] [blame] | 411 | { |
| 412 | struct net_device *dev = pci_get_drvdata(pdev); |
| 413 | |
| 414 | if (netif_running(dev)) { |
| 415 | netif_stop_queue(dev); |
| 416 | netif_device_detach(dev); |
| 417 | } |
| 418 | prism2_suspend(dev); |
| 419 | pci_save_state(pdev); |
| 420 | pci_disable_device(pdev); |
Pavel Machek | 583a4e8 | 2005-09-03 15:56:58 -0700 | [diff] [blame] | 421 | pci_set_power_state(pdev, PCI_D3hot); |
Jouni Malinen | ff1d276 | 2005-05-12 22:54:16 -0400 | [diff] [blame] | 422 | |
| 423 | return 0; |
| 424 | } |
| 425 | |
| 426 | static int prism2_pci_resume(struct pci_dev *pdev) |
| 427 | { |
| 428 | struct net_device *dev = pci_get_drvdata(pdev); |
| 429 | |
| 430 | pci_enable_device(pdev); |
| 431 | pci_restore_state(pdev); |
| 432 | prism2_hw_config(dev, 0); |
| 433 | if (netif_running(dev)) { |
| 434 | netif_device_attach(dev); |
| 435 | netif_start_queue(dev); |
| 436 | } |
| 437 | |
| 438 | return 0; |
| 439 | } |
| 440 | #endif /* CONFIG_PM */ |
| 441 | |
| 442 | |
| 443 | MODULE_DEVICE_TABLE(pci, prism2_pci_id_table); |
| 444 | |
| 445 | static struct pci_driver prism2_pci_drv_id = { |
Pavel Roskin | 7a71653 | 2005-09-23 21:58:58 -0700 | [diff] [blame] | 446 | .name = "hostap_pci", |
Jouni Malinen | ff1d276 | 2005-05-12 22:54:16 -0400 | [diff] [blame] | 447 | .id_table = prism2_pci_id_table, |
| 448 | .probe = prism2_pci_probe, |
| 449 | .remove = prism2_pci_remove, |
| 450 | #ifdef CONFIG_PM |
| 451 | .suspend = prism2_pci_suspend, |
| 452 | .resume = prism2_pci_resume, |
| 453 | #endif /* CONFIG_PM */ |
| 454 | /* Linux 2.4.6 added save_state and enable_wake that are not used here |
| 455 | */ |
| 456 | }; |
| 457 | |
| 458 | |
| 459 | static int __init init_prism2_pci(void) |
| 460 | { |
| 461 | printk(KERN_INFO "%s: %s\n", dev_info, version); |
| 462 | |
| 463 | return pci_register_driver(&prism2_pci_drv_id); |
| 464 | } |
| 465 | |
| 466 | |
| 467 | static void __exit exit_prism2_pci(void) |
| 468 | { |
| 469 | pci_unregister_driver(&prism2_pci_drv_id); |
| 470 | printk(KERN_INFO "%s: Driver unloaded\n", dev_info); |
| 471 | } |
| 472 | |
| 473 | |
| 474 | module_init(init_prism2_pci); |
| 475 | module_exit(exit_prism2_pci); |