Holger Schurig | 27590d0 | 2007-10-03 17:25:41 -0700 | [diff] [blame] | 1 | /* |
| 2 | |
| 3 | Driver for the Marvell 8385 based compact flash WLAN cards. |
| 4 | |
| 5 | (C) 2007 by Holger Schurig <hs4233@mail.mn-solutions.de> |
| 6 | |
| 7 | This program is free software; you can redistribute it and/or modify |
| 8 | it under the terms of the GNU General Public License as published by |
| 9 | the Free Software Foundation; either version 2 of the License, or |
| 10 | (at your option) any later version. |
| 11 | |
| 12 | This program is distributed in the hope that it will be useful, |
| 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 15 | GNU General Public License for more details. |
| 16 | |
| 17 | You should have received a copy of the GNU General Public License |
| 18 | along with this program; see the file COPYING. If not, write to |
| 19 | the Free Software Foundation, Inc., 51 Franklin Steet, Fifth Floor, |
| 20 | Boston, MA 02110-1301, USA. |
| 21 | |
| 22 | */ |
| 23 | |
| 24 | #include <linux/module.h> |
| 25 | #include <linux/delay.h> |
| 26 | #include <linux/moduleparam.h> |
| 27 | #include <linux/firmware.h> |
| 28 | #include <linux/netdevice.h> |
| 29 | |
| 30 | #include <pcmcia/cs_types.h> |
| 31 | #include <pcmcia/cs.h> |
| 32 | #include <pcmcia/cistpl.h> |
| 33 | #include <pcmcia/ds.h> |
| 34 | |
| 35 | #include <linux/io.h> |
| 36 | |
| 37 | #define DRV_NAME "libertas_cs" |
| 38 | |
| 39 | #include "decl.h" |
| 40 | #include "defs.h" |
| 41 | #include "dev.h" |
| 42 | |
| 43 | |
| 44 | /********************************************************************/ |
| 45 | /* Module stuff */ |
| 46 | /********************************************************************/ |
| 47 | |
| 48 | MODULE_AUTHOR("Holger Schurig <hs4233@mail.mn-solutions.de>"); |
| 49 | MODULE_DESCRIPTION("Driver for Marvell 83xx compact flash WLAN cards"); |
| 50 | MODULE_LICENSE("GPL"); |
| 51 | |
| 52 | |
| 53 | |
| 54 | /********************************************************************/ |
| 55 | /* Data structures */ |
| 56 | /********************************************************************/ |
| 57 | |
| 58 | struct if_cs_card { |
| 59 | struct pcmcia_device *p_dev; |
Holger Schurig | 69f9032 | 2007-11-23 15:43:44 +0100 | [diff] [blame] | 60 | struct lbs_private *priv; |
Holger Schurig | 27590d0 | 2007-10-03 17:25:41 -0700 | [diff] [blame] | 61 | void __iomem *iobase; |
Marek Vasut | 9d45368 | 2009-08-21 04:08:16 +0200 | [diff] [blame] | 62 | bool align_regs; |
Holger Schurig | 27590d0 | 2007-10-03 17:25:41 -0700 | [diff] [blame] | 63 | }; |
| 64 | |
| 65 | |
| 66 | |
| 67 | /********************************************************************/ |
| 68 | /* Hardware access */ |
| 69 | /********************************************************************/ |
| 70 | |
| 71 | /* This define enables wrapper functions which allow you |
| 72 | to dump all register accesses. You normally won't this, |
| 73 | except for development */ |
| 74 | /* #define DEBUG_IO */ |
| 75 | |
| 76 | #ifdef DEBUG_IO |
| 77 | static int debug_output = 0; |
| 78 | #else |
| 79 | /* This way the compiler optimizes the printk's away */ |
| 80 | #define debug_output 0 |
| 81 | #endif |
| 82 | |
| 83 | static inline unsigned int if_cs_read8(struct if_cs_card *card, uint reg) |
| 84 | { |
| 85 | unsigned int val = ioread8(card->iobase + reg); |
| 86 | if (debug_output) |
Holger Schurig | 7919b89 | 2008-04-01 14:50:43 +0200 | [diff] [blame] | 87 | printk(KERN_INFO "inb %08x<%02x\n", reg, val); |
Holger Schurig | 27590d0 | 2007-10-03 17:25:41 -0700 | [diff] [blame] | 88 | return val; |
| 89 | } |
| 90 | static inline unsigned int if_cs_read16(struct if_cs_card *card, uint reg) |
| 91 | { |
| 92 | unsigned int val = ioread16(card->iobase + reg); |
| 93 | if (debug_output) |
Holger Schurig | 7919b89 | 2008-04-01 14:50:43 +0200 | [diff] [blame] | 94 | printk(KERN_INFO "inw %08x<%04x\n", reg, val); |
Holger Schurig | 27590d0 | 2007-10-03 17:25:41 -0700 | [diff] [blame] | 95 | return val; |
| 96 | } |
| 97 | static inline void if_cs_read16_rep( |
| 98 | struct if_cs_card *card, |
| 99 | uint reg, |
| 100 | void *buf, |
| 101 | unsigned long count) |
| 102 | { |
| 103 | if (debug_output) |
Holger Schurig | 7919b89 | 2008-04-01 14:50:43 +0200 | [diff] [blame] | 104 | printk(KERN_INFO "insw %08x<(0x%lx words)\n", |
Holger Schurig | 27590d0 | 2007-10-03 17:25:41 -0700 | [diff] [blame] | 105 | reg, count); |
| 106 | ioread16_rep(card->iobase + reg, buf, count); |
| 107 | } |
| 108 | |
| 109 | static inline void if_cs_write8(struct if_cs_card *card, uint reg, u8 val) |
| 110 | { |
| 111 | if (debug_output) |
Holger Schurig | 7919b89 | 2008-04-01 14:50:43 +0200 | [diff] [blame] | 112 | printk(KERN_INFO "outb %08x>%02x\n", reg, val); |
Holger Schurig | 27590d0 | 2007-10-03 17:25:41 -0700 | [diff] [blame] | 113 | iowrite8(val, card->iobase + reg); |
| 114 | } |
| 115 | |
| 116 | static inline void if_cs_write16(struct if_cs_card *card, uint reg, u16 val) |
| 117 | { |
| 118 | if (debug_output) |
Holger Schurig | 7919b89 | 2008-04-01 14:50:43 +0200 | [diff] [blame] | 119 | printk(KERN_INFO "outw %08x>%04x\n", reg, val); |
Holger Schurig | 27590d0 | 2007-10-03 17:25:41 -0700 | [diff] [blame] | 120 | iowrite16(val, card->iobase + reg); |
| 121 | } |
| 122 | |
| 123 | static inline void if_cs_write16_rep( |
| 124 | struct if_cs_card *card, |
| 125 | uint reg, |
David Woodhouse | 6dfff89 | 2008-05-23 18:37:51 +0100 | [diff] [blame] | 126 | const void *buf, |
Holger Schurig | 27590d0 | 2007-10-03 17:25:41 -0700 | [diff] [blame] | 127 | unsigned long count) |
| 128 | { |
| 129 | if (debug_output) |
Holger Schurig | 7919b89 | 2008-04-01 14:50:43 +0200 | [diff] [blame] | 130 | printk(KERN_INFO "outsw %08x>(0x%lx words)\n", |
Holger Schurig | 27590d0 | 2007-10-03 17:25:41 -0700 | [diff] [blame] | 131 | reg, count); |
| 132 | iowrite16_rep(card->iobase + reg, buf, count); |
| 133 | } |
| 134 | |
| 135 | |
| 136 | /* |
| 137 | * I know that polling/delaying is frowned upon. However, this procedure |
| 138 | * with polling is needed while downloading the firmware. At this stage, |
| 139 | * the hardware does unfortunately not create any interrupts. |
| 140 | * |
| 141 | * Fortunately, this function is never used once the firmware is in |
| 142 | * the card. :-) |
| 143 | * |
| 144 | * As a reference, see the "Firmware Specification v5.1", page 18 |
| 145 | * and 19. I did not follow their suggested timing to the word, |
| 146 | * but this works nice & fast anyway. |
| 147 | */ |
| 148 | static int if_cs_poll_while_fw_download(struct if_cs_card *card, uint addr, u8 reg) |
| 149 | { |
| 150 | int i; |
| 151 | |
Holger Schurig | 93416c8 | 2008-05-23 10:18:26 +0200 | [diff] [blame] | 152 | for (i = 0; i < 100000; i++) { |
Holger Schurig | 27590d0 | 2007-10-03 17:25:41 -0700 | [diff] [blame] | 153 | u8 val = if_cs_read8(card, addr); |
| 154 | if (val == reg) |
Dan Williams | 1fac36e | 2009-01-23 11:55:33 -0500 | [diff] [blame] | 155 | return 0; |
Holger Schurig | 93416c8 | 2008-05-23 10:18:26 +0200 | [diff] [blame] | 156 | udelay(5); |
Holger Schurig | 27590d0 | 2007-10-03 17:25:41 -0700 | [diff] [blame] | 157 | } |
| 158 | return -ETIME; |
| 159 | } |
| 160 | |
| 161 | |
| 162 | |
Holger Schurig | 5314325 | 2008-06-05 13:07:04 +0200 | [diff] [blame] | 163 | /* |
| 164 | * First the bitmasks for the host/card interrupt/status registers: |
| 165 | */ |
Holger Schurig | 78cf074 | 2008-06-02 09:25:05 +0200 | [diff] [blame] | 166 | #define IF_CS_BIT_TX 0x0001 |
| 167 | #define IF_CS_BIT_RX 0x0002 |
| 168 | #define IF_CS_BIT_COMMAND 0x0004 |
| 169 | #define IF_CS_BIT_RESP 0x0008 |
| 170 | #define IF_CS_BIT_EVENT 0x0010 |
| 171 | #define IF_CS_BIT_MASK 0x001f |
Holger Schurig | 27590d0 | 2007-10-03 17:25:41 -0700 | [diff] [blame] | 172 | |
Holger Schurig | 5314325 | 2008-06-05 13:07:04 +0200 | [diff] [blame] | 173 | |
| 174 | |
| 175 | /* |
| 176 | * It's not really clear to me what the host status register is for. It |
| 177 | * needs to be set almost in union with "host int cause". The following |
| 178 | * bits from above are used: |
| 179 | * |
| 180 | * IF_CS_BIT_TX driver downloaded a data packet |
| 181 | * IF_CS_BIT_RX driver got a data packet |
| 182 | * IF_CS_BIT_COMMAND driver downloaded a command |
| 183 | * IF_CS_BIT_RESP not used (has some meaning with powerdown) |
| 184 | * IF_CS_BIT_EVENT driver read a host event |
| 185 | */ |
Holger Schurig | 78cf074 | 2008-06-02 09:25:05 +0200 | [diff] [blame] | 186 | #define IF_CS_HOST_STATUS 0x00000000 |
Holger Schurig | 27590d0 | 2007-10-03 17:25:41 -0700 | [diff] [blame] | 187 | |
Holger Schurig | 5314325 | 2008-06-05 13:07:04 +0200 | [diff] [blame] | 188 | /* |
| 189 | * With the host int cause register can the host (that is, Linux) cause |
| 190 | * an interrupt in the firmware, to tell the firmware about those events: |
| 191 | * |
| 192 | * IF_CS_BIT_TX a data packet has been downloaded |
| 193 | * IF_CS_BIT_RX a received data packet has retrieved |
| 194 | * IF_CS_BIT_COMMAND a firmware block or a command has been downloaded |
| 195 | * IF_CS_BIT_RESP not used (has some meaning with powerdown) |
| 196 | * IF_CS_BIT_EVENT a host event (link lost etc) has been retrieved |
| 197 | */ |
Holger Schurig | 78cf074 | 2008-06-02 09:25:05 +0200 | [diff] [blame] | 198 | #define IF_CS_HOST_INT_CAUSE 0x00000002 |
Holger Schurig | 27590d0 | 2007-10-03 17:25:41 -0700 | [diff] [blame] | 199 | |
Holger Schurig | 5314325 | 2008-06-05 13:07:04 +0200 | [diff] [blame] | 200 | /* |
| 201 | * The host int mask register is used to enable/disable interrupt. However, |
| 202 | * I have the suspicion that disabled interrupts are lost. |
| 203 | */ |
Holger Schurig | 78cf074 | 2008-06-02 09:25:05 +0200 | [diff] [blame] | 204 | #define IF_CS_HOST_INT_MASK 0x00000004 |
Holger Schurig | 27590d0 | 2007-10-03 17:25:41 -0700 | [diff] [blame] | 205 | |
Holger Schurig | 5314325 | 2008-06-05 13:07:04 +0200 | [diff] [blame] | 206 | /* |
| 207 | * Used to send or receive data packets: |
| 208 | */ |
Holger Schurig | a78a832 | 2008-06-05 13:09:50 +0200 | [diff] [blame] | 209 | #define IF_CS_WRITE 0x00000016 |
| 210 | #define IF_CS_WRITE_LEN 0x00000014 |
Holger Schurig | 78cf074 | 2008-06-02 09:25:05 +0200 | [diff] [blame] | 211 | #define IF_CS_READ 0x00000010 |
| 212 | #define IF_CS_READ_LEN 0x00000024 |
Holger Schurig | 27590d0 | 2007-10-03 17:25:41 -0700 | [diff] [blame] | 213 | |
Holger Schurig | 5314325 | 2008-06-05 13:07:04 +0200 | [diff] [blame] | 214 | /* |
| 215 | * Used to send commands (and to send firmware block) and to |
| 216 | * receive command responses: |
| 217 | */ |
Holger Schurig | a78a832 | 2008-06-05 13:09:50 +0200 | [diff] [blame] | 218 | #define IF_CS_CMD 0x0000001A |
| 219 | #define IF_CS_CMD_LEN 0x00000018 |
| 220 | #define IF_CS_RESP 0x00000012 |
| 221 | #define IF_CS_RESP_LEN 0x00000030 |
Holger Schurig | 27590d0 | 2007-10-03 17:25:41 -0700 | [diff] [blame] | 222 | |
Holger Schurig | 5314325 | 2008-06-05 13:07:04 +0200 | [diff] [blame] | 223 | /* |
| 224 | * The card status registers shows what the card/firmware actually |
| 225 | * accepts: |
| 226 | * |
| 227 | * IF_CS_BIT_TX you may send a data packet |
| 228 | * IF_CS_BIT_RX you may retrieve a data packet |
| 229 | * IF_CS_BIT_COMMAND you may send a command |
| 230 | * IF_CS_BIT_RESP you may retrieve a command response |
| 231 | * IF_CS_BIT_EVENT the card has a event for use (link lost, snr low etc) |
| 232 | * |
| 233 | * When reading this register several times, you will get back the same |
| 234 | * results --- with one exception: the IF_CS_BIT_EVENT clear itself |
| 235 | * automatically. |
| 236 | * |
| 237 | * Not that we don't rely on BIT_RX,_BIT_RESP or BIT_EVENT because |
| 238 | * we handle this via the card int cause register. |
| 239 | */ |
Holger Schurig | 78cf074 | 2008-06-02 09:25:05 +0200 | [diff] [blame] | 240 | #define IF_CS_CARD_STATUS 0x00000020 |
| 241 | #define IF_CS_CARD_STATUS_MASK 0x7f00 |
Holger Schurig | 27590d0 | 2007-10-03 17:25:41 -0700 | [diff] [blame] | 242 | |
Holger Schurig | 5314325 | 2008-06-05 13:07:04 +0200 | [diff] [blame] | 243 | /* |
| 244 | * The card int cause register is used by the card/firmware to notify us |
| 245 | * about the following events: |
| 246 | * |
| 247 | * IF_CS_BIT_TX a data packet has successfully been sentx |
| 248 | * IF_CS_BIT_RX a data packet has been received and can be retrieved |
| 249 | * IF_CS_BIT_COMMAND not used |
| 250 | * IF_CS_BIT_RESP the firmware has a command response for us |
| 251 | * IF_CS_BIT_EVENT the card has a event for use (link lost, snr low etc) |
| 252 | */ |
Holger Schurig | 78cf074 | 2008-06-02 09:25:05 +0200 | [diff] [blame] | 253 | #define IF_CS_CARD_INT_CAUSE 0x00000022 |
Holger Schurig | 27590d0 | 2007-10-03 17:25:41 -0700 | [diff] [blame] | 254 | |
Holger Schurig | 5314325 | 2008-06-05 13:07:04 +0200 | [diff] [blame] | 255 | /* |
| 256 | * This is used to for handshaking with the card's bootloader/helper image |
| 257 | * to synchronize downloading of firmware blocks. |
| 258 | */ |
Holger Schurig | a78a832 | 2008-06-05 13:09:50 +0200 | [diff] [blame] | 259 | #define IF_CS_SQ_READ_LOW 0x00000028 |
| 260 | #define IF_CS_SQ_HELPER_OK 0x10 |
Holger Schurig | 27590d0 | 2007-10-03 17:25:41 -0700 | [diff] [blame] | 261 | |
Holger Schurig | 5314325 | 2008-06-05 13:07:04 +0200 | [diff] [blame] | 262 | /* |
| 263 | * The scratch register tells us ... |
| 264 | * |
| 265 | * IF_CS_SCRATCH_BOOT_OK the bootloader runs |
| 266 | * IF_CS_SCRATCH_HELPER_OK the helper firmware already runs |
| 267 | */ |
Holger Schurig | 27590d0 | 2007-10-03 17:25:41 -0700 | [diff] [blame] | 268 | #define IF_CS_SCRATCH 0x0000003F |
Holger Schurig | 5314325 | 2008-06-05 13:07:04 +0200 | [diff] [blame] | 269 | #define IF_CS_SCRATCH_BOOT_OK 0x00 |
| 270 | #define IF_CS_SCRATCH_HELPER_OK 0x5a |
Holger Schurig | 27590d0 | 2007-10-03 17:25:41 -0700 | [diff] [blame] | 271 | |
Holger Schurig | 4c55523 | 2008-06-05 13:08:35 +0200 | [diff] [blame] | 272 | /* |
| 273 | * Used to detect ancient chips: |
| 274 | */ |
| 275 | #define IF_CS_PRODUCT_ID 0x0000001C |
| 276 | #define IF_CS_CF8385_B1_REV 0x12 |
Marek Vasut | dc7d243 | 2009-03-24 21:33:43 +0100 | [diff] [blame] | 277 | #define IF_CS_CF8381_B3_REV 0x04 |
Marek Vasut | 9d45368 | 2009-08-21 04:08:16 +0200 | [diff] [blame] | 278 | #define IF_CS_CF8305_B1_REV 0x03 |
Holger Schurig | 4c55523 | 2008-06-05 13:08:35 +0200 | [diff] [blame] | 279 | |
Marek Vasut | dc7d243 | 2009-03-24 21:33:43 +0100 | [diff] [blame] | 280 | /* |
| 281 | * Used to detect other cards than CF8385 since their revisions of silicon |
| 282 | * doesn't match those from CF8385, eg. CF8381 B3 works with this driver. |
| 283 | */ |
Marek Vasut | 9d45368 | 2009-08-21 04:08:16 +0200 | [diff] [blame] | 284 | #define CF8305_MANFID 0x02db |
| 285 | #define CF8305_CARDID 0x8103 |
Marek Vasut | dc7d243 | 2009-03-24 21:33:43 +0100 | [diff] [blame] | 286 | #define CF8381_MANFID 0x02db |
| 287 | #define CF8381_CARDID 0x6064 |
| 288 | #define CF8385_MANFID 0x02df |
| 289 | #define CF8385_CARDID 0x8103 |
| 290 | |
Marek Vasut | 9d45368 | 2009-08-21 04:08:16 +0200 | [diff] [blame] | 291 | static inline int if_cs_hw_is_cf8305(struct pcmcia_device *p_dev) |
| 292 | { |
| 293 | return (p_dev->manf_id == CF8305_MANFID && |
| 294 | p_dev->card_id == CF8305_CARDID); |
| 295 | } |
| 296 | |
Marek Vasut | dc7d243 | 2009-03-24 21:33:43 +0100 | [diff] [blame] | 297 | static inline int if_cs_hw_is_cf8381(struct pcmcia_device *p_dev) |
| 298 | { |
| 299 | return (p_dev->manf_id == CF8381_MANFID && |
| 300 | p_dev->card_id == CF8381_CARDID); |
| 301 | } |
| 302 | |
| 303 | static inline int if_cs_hw_is_cf8385(struct pcmcia_device *p_dev) |
| 304 | { |
| 305 | return (p_dev->manf_id == CF8385_MANFID && |
| 306 | p_dev->card_id == CF8385_CARDID); |
| 307 | } |
Holger Schurig | 27590d0 | 2007-10-03 17:25:41 -0700 | [diff] [blame] | 308 | |
| 309 | /********************************************************************/ |
Holger Schurig | 43d01c5 | 2008-05-26 12:50:23 +0200 | [diff] [blame] | 310 | /* I/O and interrupt handling */ |
Holger Schurig | 27590d0 | 2007-10-03 17:25:41 -0700 | [diff] [blame] | 311 | /********************************************************************/ |
| 312 | |
Holger Schurig | 43d01c5 | 2008-05-26 12:50:23 +0200 | [diff] [blame] | 313 | static inline void if_cs_enable_ints(struct if_cs_card *card) |
| 314 | { |
| 315 | lbs_deb_enter(LBS_DEB_CS); |
Holger Schurig | 78cf074 | 2008-06-02 09:25:05 +0200 | [diff] [blame] | 316 | if_cs_write16(card, IF_CS_HOST_INT_MASK, 0); |
Holger Schurig | 43d01c5 | 2008-05-26 12:50:23 +0200 | [diff] [blame] | 317 | } |
| 318 | |
| 319 | static inline void if_cs_disable_ints(struct if_cs_card *card) |
| 320 | { |
| 321 | lbs_deb_enter(LBS_DEB_CS); |
Holger Schurig | 78cf074 | 2008-06-02 09:25:05 +0200 | [diff] [blame] | 322 | if_cs_write16(card, IF_CS_HOST_INT_MASK, IF_CS_BIT_MASK); |
Holger Schurig | 43d01c5 | 2008-05-26 12:50:23 +0200 | [diff] [blame] | 323 | } |
| 324 | |
Holger Schurig | 27590d0 | 2007-10-03 17:25:41 -0700 | [diff] [blame] | 325 | /* |
| 326 | * Called from if_cs_host_to_card to send a command to the hardware |
| 327 | */ |
Holger Schurig | 69f9032 | 2007-11-23 15:43:44 +0100 | [diff] [blame] | 328 | static int if_cs_send_cmd(struct lbs_private *priv, u8 *buf, u16 nb) |
Holger Schurig | 27590d0 | 2007-10-03 17:25:41 -0700 | [diff] [blame] | 329 | { |
| 330 | struct if_cs_card *card = (struct if_cs_card *)priv->card; |
| 331 | int ret = -1; |
| 332 | int loops = 0; |
| 333 | |
| 334 | lbs_deb_enter(LBS_DEB_CS); |
Holger Schurig | 43d01c5 | 2008-05-26 12:50:23 +0200 | [diff] [blame] | 335 | if_cs_disable_ints(card); |
Holger Schurig | 27590d0 | 2007-10-03 17:25:41 -0700 | [diff] [blame] | 336 | |
| 337 | /* Is hardware ready? */ |
| 338 | while (1) { |
Holger Schurig | a78a832 | 2008-06-05 13:09:50 +0200 | [diff] [blame] | 339 | u16 status = if_cs_read16(card, IF_CS_CARD_STATUS); |
| 340 | if (status & IF_CS_BIT_COMMAND) |
Holger Schurig | 27590d0 | 2007-10-03 17:25:41 -0700 | [diff] [blame] | 341 | break; |
| 342 | if (++loops > 100) { |
| 343 | lbs_pr_err("card not ready for commands\n"); |
| 344 | goto done; |
| 345 | } |
| 346 | mdelay(1); |
| 347 | } |
| 348 | |
Holger Schurig | a78a832 | 2008-06-05 13:09:50 +0200 | [diff] [blame] | 349 | if_cs_write16(card, IF_CS_CMD_LEN, nb); |
Holger Schurig | 27590d0 | 2007-10-03 17:25:41 -0700 | [diff] [blame] | 350 | |
Holger Schurig | a78a832 | 2008-06-05 13:09:50 +0200 | [diff] [blame] | 351 | if_cs_write16_rep(card, IF_CS_CMD, buf, nb / 2); |
Holger Schurig | 27590d0 | 2007-10-03 17:25:41 -0700 | [diff] [blame] | 352 | /* Are we supposed to transfer an odd amount of bytes? */ |
| 353 | if (nb & 1) |
Holger Schurig | a78a832 | 2008-06-05 13:09:50 +0200 | [diff] [blame] | 354 | if_cs_write8(card, IF_CS_CMD, buf[nb-1]); |
Holger Schurig | 27590d0 | 2007-10-03 17:25:41 -0700 | [diff] [blame] | 355 | |
| 356 | /* "Assert the download over interrupt command in the Host |
| 357 | * status register" */ |
Holger Schurig | 78cf074 | 2008-06-02 09:25:05 +0200 | [diff] [blame] | 358 | if_cs_write16(card, IF_CS_HOST_STATUS, IF_CS_BIT_COMMAND); |
Holger Schurig | 27590d0 | 2007-10-03 17:25:41 -0700 | [diff] [blame] | 359 | |
| 360 | /* "Assert the download over interrupt command in the Card |
| 361 | * interrupt case register" */ |
Holger Schurig | 78cf074 | 2008-06-02 09:25:05 +0200 | [diff] [blame] | 362 | if_cs_write16(card, IF_CS_HOST_INT_CAUSE, IF_CS_BIT_COMMAND); |
Holger Schurig | 27590d0 | 2007-10-03 17:25:41 -0700 | [diff] [blame] | 363 | ret = 0; |
| 364 | |
| 365 | done: |
Holger Schurig | 43d01c5 | 2008-05-26 12:50:23 +0200 | [diff] [blame] | 366 | if_cs_enable_ints(card); |
Holger Schurig | 27590d0 | 2007-10-03 17:25:41 -0700 | [diff] [blame] | 367 | lbs_deb_leave_args(LBS_DEB_CS, "ret %d", ret); |
| 368 | return ret; |
| 369 | } |
| 370 | |
Holger Schurig | 27590d0 | 2007-10-03 17:25:41 -0700 | [diff] [blame] | 371 | /* |
| 372 | * Called from if_cs_host_to_card to send a data to the hardware |
| 373 | */ |
Holger Schurig | 69f9032 | 2007-11-23 15:43:44 +0100 | [diff] [blame] | 374 | static void if_cs_send_data(struct lbs_private *priv, u8 *buf, u16 nb) |
Holger Schurig | 27590d0 | 2007-10-03 17:25:41 -0700 | [diff] [blame] | 375 | { |
| 376 | struct if_cs_card *card = (struct if_cs_card *)priv->card; |
Holger Schurig | 43d01c5 | 2008-05-26 12:50:23 +0200 | [diff] [blame] | 377 | u16 status; |
Holger Schurig | 27590d0 | 2007-10-03 17:25:41 -0700 | [diff] [blame] | 378 | |
| 379 | lbs_deb_enter(LBS_DEB_CS); |
Holger Schurig | 43d01c5 | 2008-05-26 12:50:23 +0200 | [diff] [blame] | 380 | if_cs_disable_ints(card); |
| 381 | |
Holger Schurig | 78cf074 | 2008-06-02 09:25:05 +0200 | [diff] [blame] | 382 | status = if_cs_read16(card, IF_CS_CARD_STATUS); |
| 383 | BUG_ON((status & IF_CS_BIT_TX) == 0); |
Holger Schurig | 27590d0 | 2007-10-03 17:25:41 -0700 | [diff] [blame] | 384 | |
Holger Schurig | a78a832 | 2008-06-05 13:09:50 +0200 | [diff] [blame] | 385 | if_cs_write16(card, IF_CS_WRITE_LEN, nb); |
Holger Schurig | 27590d0 | 2007-10-03 17:25:41 -0700 | [diff] [blame] | 386 | |
| 387 | /* write even number of bytes, then odd byte if necessary */ |
Holger Schurig | a78a832 | 2008-06-05 13:09:50 +0200 | [diff] [blame] | 388 | if_cs_write16_rep(card, IF_CS_WRITE, buf, nb / 2); |
Holger Schurig | 27590d0 | 2007-10-03 17:25:41 -0700 | [diff] [blame] | 389 | if (nb & 1) |
Holger Schurig | a78a832 | 2008-06-05 13:09:50 +0200 | [diff] [blame] | 390 | if_cs_write8(card, IF_CS_WRITE, buf[nb-1]); |
Holger Schurig | 27590d0 | 2007-10-03 17:25:41 -0700 | [diff] [blame] | 391 | |
Holger Schurig | 78cf074 | 2008-06-02 09:25:05 +0200 | [diff] [blame] | 392 | if_cs_write16(card, IF_CS_HOST_STATUS, IF_CS_BIT_TX); |
| 393 | if_cs_write16(card, IF_CS_HOST_INT_CAUSE, IF_CS_BIT_TX); |
Holger Schurig | 43d01c5 | 2008-05-26 12:50:23 +0200 | [diff] [blame] | 394 | if_cs_enable_ints(card); |
Holger Schurig | 27590d0 | 2007-10-03 17:25:41 -0700 | [diff] [blame] | 395 | |
| 396 | lbs_deb_leave(LBS_DEB_CS); |
| 397 | } |
| 398 | |
Holger Schurig | 27590d0 | 2007-10-03 17:25:41 -0700 | [diff] [blame] | 399 | /* |
| 400 | * Get the command result out of the card. |
| 401 | */ |
Holger Schurig | 69f9032 | 2007-11-23 15:43:44 +0100 | [diff] [blame] | 402 | static int if_cs_receive_cmdres(struct lbs_private *priv, u8 *data, u32 *len) |
Holger Schurig | 27590d0 | 2007-10-03 17:25:41 -0700 | [diff] [blame] | 403 | { |
Holger Schurig | 7919b89 | 2008-04-01 14:50:43 +0200 | [diff] [blame] | 404 | unsigned long flags; |
Holger Schurig | 27590d0 | 2007-10-03 17:25:41 -0700 | [diff] [blame] | 405 | int ret = -1; |
Holger Schurig | 78cf074 | 2008-06-02 09:25:05 +0200 | [diff] [blame] | 406 | u16 status; |
Holger Schurig | 27590d0 | 2007-10-03 17:25:41 -0700 | [diff] [blame] | 407 | |
| 408 | lbs_deb_enter(LBS_DEB_CS); |
| 409 | |
| 410 | /* is hardware ready? */ |
Holger Schurig | 78cf074 | 2008-06-02 09:25:05 +0200 | [diff] [blame] | 411 | status = if_cs_read16(priv->card, IF_CS_CARD_STATUS); |
| 412 | if ((status & IF_CS_BIT_RESP) == 0) { |
| 413 | lbs_pr_err("no cmd response in card\n"); |
| 414 | *len = 0; |
Holger Schurig | 27590d0 | 2007-10-03 17:25:41 -0700 | [diff] [blame] | 415 | goto out; |
| 416 | } |
| 417 | |
Holger Schurig | a78a832 | 2008-06-05 13:09:50 +0200 | [diff] [blame] | 418 | *len = if_cs_read16(priv->card, IF_CS_RESP_LEN); |
Dan Williams | ddac452 | 2007-12-11 13:49:39 -0500 | [diff] [blame] | 419 | if ((*len == 0) || (*len > LBS_CMD_BUFFER_SIZE)) { |
Holger Schurig | 27590d0 | 2007-10-03 17:25:41 -0700 | [diff] [blame] | 420 | lbs_pr_err("card cmd buffer has invalid # of bytes (%d)\n", *len); |
| 421 | goto out; |
| 422 | } |
| 423 | |
| 424 | /* read even number of bytes, then odd byte if necessary */ |
Holger Schurig | a78a832 | 2008-06-05 13:09:50 +0200 | [diff] [blame] | 425 | if_cs_read16_rep(priv->card, IF_CS_RESP, data, *len/sizeof(u16)); |
Holger Schurig | 27590d0 | 2007-10-03 17:25:41 -0700 | [diff] [blame] | 426 | if (*len & 1) |
Holger Schurig | a78a832 | 2008-06-05 13:09:50 +0200 | [diff] [blame] | 427 | data[*len-1] = if_cs_read8(priv->card, IF_CS_RESP); |
Holger Schurig | 27590d0 | 2007-10-03 17:25:41 -0700 | [diff] [blame] | 428 | |
Holger Schurig | 09d4fad | 2007-12-06 13:50:30 +0100 | [diff] [blame] | 429 | /* This is a workaround for a firmware that reports too much |
| 430 | * bytes */ |
| 431 | *len -= 8; |
Holger Schurig | 27590d0 | 2007-10-03 17:25:41 -0700 | [diff] [blame] | 432 | ret = 0; |
Holger Schurig | 7919b89 | 2008-04-01 14:50:43 +0200 | [diff] [blame] | 433 | |
| 434 | /* Clear this flag again */ |
| 435 | spin_lock_irqsave(&priv->driver_lock, flags); |
| 436 | priv->dnld_sent = DNLD_RES_RECEIVED; |
| 437 | spin_unlock_irqrestore(&priv->driver_lock, flags); |
| 438 | |
Holger Schurig | 27590d0 | 2007-10-03 17:25:41 -0700 | [diff] [blame] | 439 | out: |
| 440 | lbs_deb_leave_args(LBS_DEB_CS, "ret %d, len %d", ret, *len); |
| 441 | return ret; |
| 442 | } |
| 443 | |
Holger Schurig | 69f9032 | 2007-11-23 15:43:44 +0100 | [diff] [blame] | 444 | static struct sk_buff *if_cs_receive_data(struct lbs_private *priv) |
Holger Schurig | 27590d0 | 2007-10-03 17:25:41 -0700 | [diff] [blame] | 445 | { |
| 446 | struct sk_buff *skb = NULL; |
| 447 | u16 len; |
| 448 | u8 *data; |
| 449 | |
| 450 | lbs_deb_enter(LBS_DEB_CS); |
| 451 | |
Holger Schurig | 78cf074 | 2008-06-02 09:25:05 +0200 | [diff] [blame] | 452 | len = if_cs_read16(priv->card, IF_CS_READ_LEN); |
Holger Schurig | 27590d0 | 2007-10-03 17:25:41 -0700 | [diff] [blame] | 453 | if (len == 0 || len > MRVDRV_ETH_RX_PACKET_BUFFER_SIZE) { |
| 454 | lbs_pr_err("card data buffer has invalid # of bytes (%d)\n", len); |
Stephen Hemminger | bbfc6b7 | 2009-03-20 19:36:36 +0000 | [diff] [blame] | 455 | priv->dev->stats.rx_dropped++; |
Holger Schurig | 27590d0 | 2007-10-03 17:25:41 -0700 | [diff] [blame] | 456 | goto dat_err; |
| 457 | } |
| 458 | |
Vladimir Davydov | f31ce76 | 2007-09-06 21:41:02 -0400 | [diff] [blame] | 459 | skb = dev_alloc_skb(MRVDRV_ETH_RX_PACKET_BUFFER_SIZE + 2); |
Holger Schurig | 27590d0 | 2007-10-03 17:25:41 -0700 | [diff] [blame] | 460 | if (!skb) |
| 461 | goto out; |
Vladimir Davydov | f31ce76 | 2007-09-06 21:41:02 -0400 | [diff] [blame] | 462 | skb_put(skb, len); |
| 463 | skb_reserve(skb, 2);/* 16 byte align */ |
| 464 | data = skb->data; |
Holger Schurig | 27590d0 | 2007-10-03 17:25:41 -0700 | [diff] [blame] | 465 | |
| 466 | /* read even number of bytes, then odd byte if necessary */ |
Holger Schurig | 78cf074 | 2008-06-02 09:25:05 +0200 | [diff] [blame] | 467 | if_cs_read16_rep(priv->card, IF_CS_READ, data, len/sizeof(u16)); |
Holger Schurig | 27590d0 | 2007-10-03 17:25:41 -0700 | [diff] [blame] | 468 | if (len & 1) |
Holger Schurig | 78cf074 | 2008-06-02 09:25:05 +0200 | [diff] [blame] | 469 | data[len-1] = if_cs_read8(priv->card, IF_CS_READ); |
Holger Schurig | 27590d0 | 2007-10-03 17:25:41 -0700 | [diff] [blame] | 470 | |
| 471 | dat_err: |
Holger Schurig | 78cf074 | 2008-06-02 09:25:05 +0200 | [diff] [blame] | 472 | if_cs_write16(priv->card, IF_CS_HOST_STATUS, IF_CS_BIT_RX); |
| 473 | if_cs_write16(priv->card, IF_CS_HOST_INT_CAUSE, IF_CS_BIT_RX); |
Holger Schurig | 27590d0 | 2007-10-03 17:25:41 -0700 | [diff] [blame] | 474 | |
| 475 | out: |
| 476 | lbs_deb_leave_args(LBS_DEB_CS, "ret %p", skb); |
| 477 | return skb; |
| 478 | } |
| 479 | |
Holger Schurig | 7919b89 | 2008-04-01 14:50:43 +0200 | [diff] [blame] | 480 | static irqreturn_t if_cs_interrupt(int irq, void *data) |
| 481 | { |
| 482 | struct if_cs_card *card = data; |
| 483 | struct lbs_private *priv = card->priv; |
| 484 | u16 cause; |
| 485 | |
| 486 | lbs_deb_enter(LBS_DEB_CS); |
| 487 | |
Holger Schurig | 43d01c5 | 2008-05-26 12:50:23 +0200 | [diff] [blame] | 488 | /* Ask card interrupt cause register if there is something for us */ |
Holger Schurig | 78cf074 | 2008-06-02 09:25:05 +0200 | [diff] [blame] | 489 | cause = if_cs_read16(card, IF_CS_CARD_INT_CAUSE); |
Holger Schurig | 3073556 | 2008-06-05 13:06:15 +0200 | [diff] [blame] | 490 | lbs_deb_cs("cause 0x%04x\n", cause); |
| 491 | |
Holger Schurig | 7919b89 | 2008-04-01 14:50:43 +0200 | [diff] [blame] | 492 | if (cause == 0) { |
| 493 | /* Not for us */ |
| 494 | return IRQ_NONE; |
| 495 | } |
| 496 | |
| 497 | if (cause == 0xffff) { |
| 498 | /* Read in junk, the card has probably been removed */ |
| 499 | card->priv->surpriseremoved = 1; |
| 500 | return IRQ_HANDLED; |
| 501 | } |
| 502 | |
Holger Schurig | 78cf074 | 2008-06-02 09:25:05 +0200 | [diff] [blame] | 503 | if (cause & IF_CS_BIT_RX) { |
Holger Schurig | 7919b89 | 2008-04-01 14:50:43 +0200 | [diff] [blame] | 504 | struct sk_buff *skb; |
| 505 | lbs_deb_cs("rx packet\n"); |
| 506 | skb = if_cs_receive_data(priv); |
| 507 | if (skb) |
| 508 | lbs_process_rxed_packet(priv, skb); |
| 509 | } |
| 510 | |
Holger Schurig | 78cf074 | 2008-06-02 09:25:05 +0200 | [diff] [blame] | 511 | if (cause & IF_CS_BIT_TX) { |
Holger Schurig | 43d01c5 | 2008-05-26 12:50:23 +0200 | [diff] [blame] | 512 | lbs_deb_cs("tx done\n"); |
Holger Schurig | 7919b89 | 2008-04-01 14:50:43 +0200 | [diff] [blame] | 513 | lbs_host_to_card_done(priv); |
| 514 | } |
| 515 | |
Holger Schurig | 78cf074 | 2008-06-02 09:25:05 +0200 | [diff] [blame] | 516 | if (cause & IF_CS_BIT_RESP) { |
Holger Schurig | 7919b89 | 2008-04-01 14:50:43 +0200 | [diff] [blame] | 517 | unsigned long flags; |
| 518 | u8 i; |
| 519 | |
Holger Schurig | 43d01c5 | 2008-05-26 12:50:23 +0200 | [diff] [blame] | 520 | lbs_deb_cs("cmd resp\n"); |
Holger Schurig | 7919b89 | 2008-04-01 14:50:43 +0200 | [diff] [blame] | 521 | spin_lock_irqsave(&priv->driver_lock, flags); |
| 522 | i = (priv->resp_idx == 0) ? 1 : 0; |
| 523 | spin_unlock_irqrestore(&priv->driver_lock, flags); |
| 524 | |
| 525 | BUG_ON(priv->resp_len[i]); |
| 526 | if_cs_receive_cmdres(priv, priv->resp_buf[i], |
| 527 | &priv->resp_len[i]); |
| 528 | |
| 529 | spin_lock_irqsave(&priv->driver_lock, flags); |
| 530 | lbs_notify_command_response(priv, i); |
| 531 | spin_unlock_irqrestore(&priv->driver_lock, flags); |
| 532 | } |
| 533 | |
Holger Schurig | 78cf074 | 2008-06-02 09:25:05 +0200 | [diff] [blame] | 534 | if (cause & IF_CS_BIT_EVENT) { |
Holger Schurig | a78a832 | 2008-06-05 13:09:50 +0200 | [diff] [blame] | 535 | u16 status = if_cs_read16(priv->card, IF_CS_CARD_STATUS); |
Holger Schurig | 78cf074 | 2008-06-02 09:25:05 +0200 | [diff] [blame] | 536 | if_cs_write16(priv->card, IF_CS_HOST_INT_CAUSE, |
| 537 | IF_CS_BIT_EVENT); |
Holger Schurig | a78a832 | 2008-06-05 13:09:50 +0200 | [diff] [blame] | 538 | lbs_queue_event(priv, (status & IF_CS_CARD_STATUS_MASK) >> 8); |
Holger Schurig | 7919b89 | 2008-04-01 14:50:43 +0200 | [diff] [blame] | 539 | } |
| 540 | |
Holger Schurig | 3073556 | 2008-06-05 13:06:15 +0200 | [diff] [blame] | 541 | /* Clear interrupt cause */ |
| 542 | if_cs_write16(card, IF_CS_CARD_INT_CAUSE, cause & IF_CS_BIT_MASK); |
| 543 | |
Holger Schurig | 43d01c5 | 2008-05-26 12:50:23 +0200 | [diff] [blame] | 544 | lbs_deb_leave(LBS_DEB_CS); |
Holger Schurig | 7919b89 | 2008-04-01 14:50:43 +0200 | [diff] [blame] | 545 | return IRQ_HANDLED; |
| 546 | } |
| 547 | |
| 548 | |
| 549 | |
| 550 | |
| 551 | /********************************************************************/ |
Holger Schurig | 27590d0 | 2007-10-03 17:25:41 -0700 | [diff] [blame] | 552 | /* Firmware */ |
| 553 | /********************************************************************/ |
| 554 | |
| 555 | /* |
| 556 | * Tries to program the helper firmware. |
| 557 | * |
| 558 | * Return 0 on success |
| 559 | */ |
| 560 | static int if_cs_prog_helper(struct if_cs_card *card) |
| 561 | { |
| 562 | int ret = 0; |
| 563 | int sent = 0; |
| 564 | u8 scratch; |
| 565 | const struct firmware *fw; |
| 566 | |
| 567 | lbs_deb_enter(LBS_DEB_CS); |
| 568 | |
Marek Vasut | 9d45368 | 2009-08-21 04:08:16 +0200 | [diff] [blame] | 569 | /* |
| 570 | * This is the only place where an unaligned register access happens on |
| 571 | * the CF8305 card, therefore for the sake of speed of the driver, we do |
| 572 | * the alignment correction here. |
| 573 | */ |
| 574 | if (card->align_regs) |
| 575 | scratch = if_cs_read16(card, IF_CS_SCRATCH) >> 8; |
| 576 | else |
| 577 | scratch = if_cs_read8(card, IF_CS_SCRATCH); |
Holger Schurig | 27590d0 | 2007-10-03 17:25:41 -0700 | [diff] [blame] | 578 | |
| 579 | /* "If the value is 0x5a, the firmware is already |
| 580 | * downloaded successfully" |
| 581 | */ |
Holger Schurig | 5314325 | 2008-06-05 13:07:04 +0200 | [diff] [blame] | 582 | if (scratch == IF_CS_SCRATCH_HELPER_OK) |
Holger Schurig | 27590d0 | 2007-10-03 17:25:41 -0700 | [diff] [blame] | 583 | goto done; |
| 584 | |
| 585 | /* "If the value is != 00, it is invalid value of register */ |
Holger Schurig | 5314325 | 2008-06-05 13:07:04 +0200 | [diff] [blame] | 586 | if (scratch != IF_CS_SCRATCH_BOOT_OK) { |
Holger Schurig | 27590d0 | 2007-10-03 17:25:41 -0700 | [diff] [blame] | 587 | ret = -ENODEV; |
| 588 | goto done; |
| 589 | } |
| 590 | |
| 591 | /* TODO: make firmware file configurable */ |
| 592 | ret = request_firmware(&fw, "libertas_cs_helper.fw", |
| 593 | &handle_to_dev(card->p_dev)); |
| 594 | if (ret) { |
| 595 | lbs_pr_err("can't load helper firmware\n"); |
| 596 | ret = -ENODEV; |
| 597 | goto done; |
| 598 | } |
Andrew Morton | 4ecd41b | 2007-08-21 02:15:45 -0700 | [diff] [blame] | 599 | lbs_deb_cs("helper size %td\n", fw->size); |
Holger Schurig | 27590d0 | 2007-10-03 17:25:41 -0700 | [diff] [blame] | 600 | |
| 601 | /* "Set the 5 bytes of the helper image to 0" */ |
| 602 | /* Not needed, this contains an ARM branch instruction */ |
| 603 | |
| 604 | for (;;) { |
| 605 | /* "the number of bytes to send is 256" */ |
| 606 | int count = 256; |
| 607 | int remain = fw->size - sent; |
| 608 | |
| 609 | if (remain < count) |
| 610 | count = remain; |
Holger Schurig | 27590d0 | 2007-10-03 17:25:41 -0700 | [diff] [blame] | 611 | |
| 612 | /* "write the number of bytes to be sent to the I/O Command |
| 613 | * write length register" */ |
Holger Schurig | a78a832 | 2008-06-05 13:09:50 +0200 | [diff] [blame] | 614 | if_cs_write16(card, IF_CS_CMD_LEN, count); |
Holger Schurig | 27590d0 | 2007-10-03 17:25:41 -0700 | [diff] [blame] | 615 | |
| 616 | /* "write this to I/O Command port register as 16 bit writes */ |
| 617 | if (count) |
Holger Schurig | a78a832 | 2008-06-05 13:09:50 +0200 | [diff] [blame] | 618 | if_cs_write16_rep(card, IF_CS_CMD, |
Holger Schurig | 27590d0 | 2007-10-03 17:25:41 -0700 | [diff] [blame] | 619 | &fw->data[sent], |
| 620 | count >> 1); |
| 621 | |
| 622 | /* "Assert the download over interrupt command in the Host |
| 623 | * status register" */ |
Holger Schurig | 78cf074 | 2008-06-02 09:25:05 +0200 | [diff] [blame] | 624 | if_cs_write8(card, IF_CS_HOST_STATUS, IF_CS_BIT_COMMAND); |
Holger Schurig | 27590d0 | 2007-10-03 17:25:41 -0700 | [diff] [blame] | 625 | |
| 626 | /* "Assert the download over interrupt command in the Card |
| 627 | * interrupt case register" */ |
Holger Schurig | 78cf074 | 2008-06-02 09:25:05 +0200 | [diff] [blame] | 628 | if_cs_write16(card, IF_CS_HOST_INT_CAUSE, IF_CS_BIT_COMMAND); |
Holger Schurig | 27590d0 | 2007-10-03 17:25:41 -0700 | [diff] [blame] | 629 | |
| 630 | /* "The host polls the Card Status register ... for 50 ms before |
| 631 | declaring a failure */ |
Holger Schurig | 78cf074 | 2008-06-02 09:25:05 +0200 | [diff] [blame] | 632 | ret = if_cs_poll_while_fw_download(card, IF_CS_CARD_STATUS, |
| 633 | IF_CS_BIT_COMMAND); |
Holger Schurig | 27590d0 | 2007-10-03 17:25:41 -0700 | [diff] [blame] | 634 | if (ret < 0) { |
| 635 | lbs_pr_err("can't download helper at 0x%x, ret %d\n", |
| 636 | sent, ret); |
Adrian Bunk | 9a52028 | 2008-08-28 01:05:08 +0300 | [diff] [blame] | 637 | goto err_release; |
Holger Schurig | 27590d0 | 2007-10-03 17:25:41 -0700 | [diff] [blame] | 638 | } |
| 639 | |
| 640 | if (count == 0) |
| 641 | break; |
| 642 | |
| 643 | sent += count; |
| 644 | } |
| 645 | |
Adrian Bunk | 9a52028 | 2008-08-28 01:05:08 +0300 | [diff] [blame] | 646 | err_release: |
Holger Schurig | 27590d0 | 2007-10-03 17:25:41 -0700 | [diff] [blame] | 647 | release_firmware(fw); |
Holger Schurig | 27590d0 | 2007-10-03 17:25:41 -0700 | [diff] [blame] | 648 | done: |
| 649 | lbs_deb_leave_args(LBS_DEB_CS, "ret %d", ret); |
| 650 | return ret; |
| 651 | } |
| 652 | |
| 653 | |
| 654 | static int if_cs_prog_real(struct if_cs_card *card) |
| 655 | { |
| 656 | const struct firmware *fw; |
| 657 | int ret = 0; |
| 658 | int retry = 0; |
| 659 | int len = 0; |
| 660 | int sent; |
| 661 | |
| 662 | lbs_deb_enter(LBS_DEB_CS); |
| 663 | |
| 664 | /* TODO: make firmware file configurable */ |
| 665 | ret = request_firmware(&fw, "libertas_cs.fw", |
| 666 | &handle_to_dev(card->p_dev)); |
| 667 | if (ret) { |
| 668 | lbs_pr_err("can't load firmware\n"); |
| 669 | ret = -ENODEV; |
| 670 | goto done; |
| 671 | } |
Andrew Morton | 4ecd41b | 2007-08-21 02:15:45 -0700 | [diff] [blame] | 672 | lbs_deb_cs("fw size %td\n", fw->size); |
Holger Schurig | 27590d0 | 2007-10-03 17:25:41 -0700 | [diff] [blame] | 673 | |
Holger Schurig | a78a832 | 2008-06-05 13:09:50 +0200 | [diff] [blame] | 674 | ret = if_cs_poll_while_fw_download(card, IF_CS_SQ_READ_LOW, |
| 675 | IF_CS_SQ_HELPER_OK); |
Holger Schurig | 27590d0 | 2007-10-03 17:25:41 -0700 | [diff] [blame] | 676 | if (ret < 0) { |
Holger Schurig | 27590d0 | 2007-10-03 17:25:41 -0700 | [diff] [blame] | 677 | lbs_pr_err("helper firmware doesn't answer\n"); |
Holger Schurig | 27590d0 | 2007-10-03 17:25:41 -0700 | [diff] [blame] | 678 | goto err_release; |
| 679 | } |
| 680 | |
| 681 | for (sent = 0; sent < fw->size; sent += len) { |
Holger Schurig | a78a832 | 2008-06-05 13:09:50 +0200 | [diff] [blame] | 682 | len = if_cs_read16(card, IF_CS_SQ_READ_LOW); |
Holger Schurig | 27590d0 | 2007-10-03 17:25:41 -0700 | [diff] [blame] | 683 | if (len & 1) { |
| 684 | retry++; |
| 685 | lbs_pr_info("odd, need to retry this firmware block\n"); |
| 686 | } else { |
| 687 | retry = 0; |
| 688 | } |
| 689 | |
| 690 | if (retry > 20) { |
| 691 | lbs_pr_err("could not download firmware\n"); |
| 692 | ret = -ENODEV; |
| 693 | goto err_release; |
| 694 | } |
| 695 | if (retry) { |
| 696 | sent -= len; |
| 697 | } |
| 698 | |
| 699 | |
Holger Schurig | a78a832 | 2008-06-05 13:09:50 +0200 | [diff] [blame] | 700 | if_cs_write16(card, IF_CS_CMD_LEN, len); |
Holger Schurig | 27590d0 | 2007-10-03 17:25:41 -0700 | [diff] [blame] | 701 | |
Holger Schurig | a78a832 | 2008-06-05 13:09:50 +0200 | [diff] [blame] | 702 | if_cs_write16_rep(card, IF_CS_CMD, |
Holger Schurig | 27590d0 | 2007-10-03 17:25:41 -0700 | [diff] [blame] | 703 | &fw->data[sent], |
| 704 | (len+1) >> 1); |
Holger Schurig | 78cf074 | 2008-06-02 09:25:05 +0200 | [diff] [blame] | 705 | if_cs_write8(card, IF_CS_HOST_STATUS, IF_CS_BIT_COMMAND); |
| 706 | if_cs_write16(card, IF_CS_HOST_INT_CAUSE, IF_CS_BIT_COMMAND); |
Holger Schurig | 27590d0 | 2007-10-03 17:25:41 -0700 | [diff] [blame] | 707 | |
Holger Schurig | 78cf074 | 2008-06-02 09:25:05 +0200 | [diff] [blame] | 708 | ret = if_cs_poll_while_fw_download(card, IF_CS_CARD_STATUS, |
| 709 | IF_CS_BIT_COMMAND); |
Holger Schurig | 27590d0 | 2007-10-03 17:25:41 -0700 | [diff] [blame] | 710 | if (ret < 0) { |
| 711 | lbs_pr_err("can't download firmware at 0x%x\n", sent); |
| 712 | goto err_release; |
| 713 | } |
| 714 | } |
| 715 | |
| 716 | ret = if_cs_poll_while_fw_download(card, IF_CS_SCRATCH, 0x5a); |
Adrian Bunk | 9a52028 | 2008-08-28 01:05:08 +0300 | [diff] [blame] | 717 | if (ret < 0) |
Holger Schurig | 27590d0 | 2007-10-03 17:25:41 -0700 | [diff] [blame] | 718 | lbs_pr_err("firmware download failed\n"); |
Holger Schurig | 27590d0 | 2007-10-03 17:25:41 -0700 | [diff] [blame] | 719 | |
| 720 | err_release: |
| 721 | release_firmware(fw); |
| 722 | |
| 723 | done: |
| 724 | lbs_deb_leave_args(LBS_DEB_CS, "ret %d", ret); |
| 725 | return ret; |
| 726 | } |
| 727 | |
| 728 | |
| 729 | |
| 730 | /********************************************************************/ |
| 731 | /* Callback functions for libertas.ko */ |
| 732 | /********************************************************************/ |
| 733 | |
Holger Schurig | 27590d0 | 2007-10-03 17:25:41 -0700 | [diff] [blame] | 734 | /* Send commands or data packets to the card */ |
Holger Schurig | 69f9032 | 2007-11-23 15:43:44 +0100 | [diff] [blame] | 735 | static int if_cs_host_to_card(struct lbs_private *priv, |
| 736 | u8 type, |
| 737 | u8 *buf, |
| 738 | u16 nb) |
Holger Schurig | 27590d0 | 2007-10-03 17:25:41 -0700 | [diff] [blame] | 739 | { |
| 740 | int ret = -1; |
| 741 | |
| 742 | lbs_deb_enter_args(LBS_DEB_CS, "type %d, bytes %d", type, nb); |
| 743 | |
| 744 | switch (type) { |
| 745 | case MVMS_DAT: |
Ryan Mallon | 6f05cbe | 2007-09-06 21:30:32 -0400 | [diff] [blame] | 746 | priv->dnld_sent = DNLD_DATA_SENT; |
Holger Schurig | 27590d0 | 2007-10-03 17:25:41 -0700 | [diff] [blame] | 747 | if_cs_send_data(priv, buf, nb); |
| 748 | ret = 0; |
| 749 | break; |
| 750 | case MVMS_CMD: |
Ryan Mallon | 6f05cbe | 2007-09-06 21:30:32 -0400 | [diff] [blame] | 751 | priv->dnld_sent = DNLD_CMD_SENT; |
Holger Schurig | 27590d0 | 2007-10-03 17:25:41 -0700 | [diff] [blame] | 752 | ret = if_cs_send_cmd(priv, buf, nb); |
| 753 | break; |
| 754 | default: |
Harvey Harrison | c94c93d | 2008-07-28 23:01:34 -0700 | [diff] [blame] | 755 | lbs_pr_err("%s: unsupported type %d\n", __func__, type); |
Holger Schurig | 27590d0 | 2007-10-03 17:25:41 -0700 | [diff] [blame] | 756 | } |
| 757 | |
| 758 | lbs_deb_leave_args(LBS_DEB_CS, "ret %d", ret); |
| 759 | return ret; |
| 760 | } |
| 761 | |
| 762 | |
Holger Schurig | 27590d0 | 2007-10-03 17:25:41 -0700 | [diff] [blame] | 763 | /********************************************************************/ |
| 764 | /* Card Services */ |
| 765 | /********************************************************************/ |
| 766 | |
| 767 | /* |
| 768 | * After a card is removed, if_cs_release() will unregister the |
| 769 | * device, and release the PCMCIA configuration. If the device is |
| 770 | * still open, this will be postponed until it is closed. |
| 771 | */ |
| 772 | static void if_cs_release(struct pcmcia_device *p_dev) |
| 773 | { |
| 774 | struct if_cs_card *card = p_dev->priv; |
| 775 | |
| 776 | lbs_deb_enter(LBS_DEB_CS); |
| 777 | |
Holger Schurig | 27590d0 | 2007-10-03 17:25:41 -0700 | [diff] [blame] | 778 | free_irq(p_dev->irq.AssignedIRQ, card); |
Holger Schurig | fdfb92e | 2008-01-25 14:15:48 +0100 | [diff] [blame] | 779 | pcmcia_disable_device(p_dev); |
Holger Schurig | 27590d0 | 2007-10-03 17:25:41 -0700 | [diff] [blame] | 780 | if (card->iobase) |
| 781 | ioport_unmap(card->iobase); |
| 782 | |
| 783 | lbs_deb_leave(LBS_DEB_CS); |
| 784 | } |
| 785 | |
| 786 | |
| 787 | /* |
| 788 | * This creates an "instance" of the driver, allocating local data |
| 789 | * structures for one device. The device is registered with Card |
| 790 | * Services. |
| 791 | * |
| 792 | * The dev_link structure is initialized, but we don't actually |
| 793 | * configure the card at this point -- we wait until we receive a card |
| 794 | * insertion event. |
| 795 | */ |
| 796 | static int if_cs_probe(struct pcmcia_device *p_dev) |
| 797 | { |
| 798 | int ret = -ENOMEM; |
Marek Vasut | dc7d243 | 2009-03-24 21:33:43 +0100 | [diff] [blame] | 799 | unsigned int prod_id; |
Holger Schurig | 69f9032 | 2007-11-23 15:43:44 +0100 | [diff] [blame] | 800 | struct lbs_private *priv; |
Holger Schurig | 27590d0 | 2007-10-03 17:25:41 -0700 | [diff] [blame] | 801 | struct if_cs_card *card; |
| 802 | /* CIS parsing */ |
| 803 | tuple_t tuple; |
| 804 | cisparse_t parse; |
| 805 | cistpl_cftable_entry_t *cfg = &parse.cftable_entry; |
| 806 | cistpl_io_t *io = &cfg->io; |
| 807 | u_char buf[64]; |
| 808 | |
| 809 | lbs_deb_enter(LBS_DEB_CS); |
| 810 | |
| 811 | card = kzalloc(sizeof(struct if_cs_card), GFP_KERNEL); |
| 812 | if (!card) { |
| 813 | lbs_pr_err("error in kzalloc\n"); |
| 814 | goto out; |
| 815 | } |
| 816 | card->p_dev = p_dev; |
| 817 | p_dev->priv = card; |
| 818 | |
| 819 | p_dev->irq.Attributes = IRQ_TYPE_DYNAMIC_SHARING; |
| 820 | p_dev->irq.Handler = NULL; |
| 821 | p_dev->irq.IRQInfo1 = IRQ_INFO2_VALID | IRQ_LEVEL_ID; |
| 822 | |
| 823 | p_dev->conf.Attributes = 0; |
| 824 | p_dev->conf.IntType = INT_MEMORY_AND_IO; |
| 825 | |
| 826 | tuple.Attributes = 0; |
| 827 | tuple.TupleData = buf; |
| 828 | tuple.TupleDataMax = sizeof(buf); |
| 829 | tuple.TupleOffset = 0; |
| 830 | |
| 831 | tuple.DesiredTuple = CISTPL_CFTABLE_ENTRY; |
| 832 | if ((ret = pcmcia_get_first_tuple(p_dev, &tuple)) != 0 || |
| 833 | (ret = pcmcia_get_tuple_data(p_dev, &tuple)) != 0 || |
Dominik Brodowski | 2f3061e | 2008-08-31 15:50:33 +0200 | [diff] [blame] | 834 | (ret = pcmcia_parse_tuple(&tuple, &parse)) != 0) |
Holger Schurig | 27590d0 | 2007-10-03 17:25:41 -0700 | [diff] [blame] | 835 | { |
| 836 | lbs_pr_err("error in pcmcia_get_first_tuple etc\n"); |
| 837 | goto out1; |
| 838 | } |
| 839 | |
| 840 | p_dev->conf.ConfigIndex = cfg->index; |
| 841 | |
| 842 | /* Do we need to allocate an interrupt? */ |
| 843 | if (cfg->irq.IRQInfo1) { |
| 844 | p_dev->conf.Attributes |= CONF_ENABLE_IRQ; |
| 845 | } |
| 846 | |
| 847 | /* IO window settings */ |
| 848 | if (cfg->io.nwin != 1) { |
| 849 | lbs_pr_err("wrong CIS (check number of IO windows)\n"); |
| 850 | ret = -ENODEV; |
| 851 | goto out1; |
| 852 | } |
| 853 | p_dev->io.Attributes1 = IO_DATA_PATH_WIDTH_AUTO; |
| 854 | p_dev->io.BasePort1 = io->win[0].base; |
| 855 | p_dev->io.NumPorts1 = io->win[0].len; |
| 856 | |
| 857 | /* This reserves IO space but doesn't actually enable it */ |
| 858 | ret = pcmcia_request_io(p_dev, &p_dev->io); |
| 859 | if (ret) { |
| 860 | lbs_pr_err("error in pcmcia_request_io\n"); |
| 861 | goto out1; |
| 862 | } |
| 863 | |
| 864 | /* |
| 865 | * Allocate an interrupt line. Note that this does not assign |
| 866 | * a handler to the interrupt, unless the 'Handler' member of |
| 867 | * the irq structure is initialized. |
| 868 | */ |
| 869 | if (p_dev->conf.Attributes & CONF_ENABLE_IRQ) { |
| 870 | ret = pcmcia_request_irq(p_dev, &p_dev->irq); |
| 871 | if (ret) { |
| 872 | lbs_pr_err("error in pcmcia_request_irq\n"); |
| 873 | goto out1; |
| 874 | } |
| 875 | } |
| 876 | |
| 877 | /* Initialize io access */ |
| 878 | card->iobase = ioport_map(p_dev->io.BasePort1, p_dev->io.NumPorts1); |
| 879 | if (!card->iobase) { |
| 880 | lbs_pr_err("error in ioport_map\n"); |
| 881 | ret = -EIO; |
| 882 | goto out1; |
| 883 | } |
| 884 | |
| 885 | /* |
| 886 | * This actually configures the PCMCIA socket -- setting up |
| 887 | * the I/O windows and the interrupt mapping, and putting the |
| 888 | * card and host interface into "Memory and IO" mode. |
| 889 | */ |
| 890 | ret = pcmcia_request_configuration(p_dev, &p_dev->conf); |
| 891 | if (ret) { |
| 892 | lbs_pr_err("error in pcmcia_request_configuration\n"); |
| 893 | goto out2; |
| 894 | } |
| 895 | |
| 896 | /* Finally, report what we've done */ |
| 897 | lbs_deb_cs("irq %d, io 0x%04x-0x%04x\n", |
| 898 | p_dev->irq.AssignedIRQ, p_dev->io.BasePort1, |
| 899 | p_dev->io.BasePort1 + p_dev->io.NumPorts1 - 1); |
| 900 | |
Marek Vasut | 9d45368 | 2009-08-21 04:08:16 +0200 | [diff] [blame] | 901 | /* |
| 902 | * Most of the libertas cards can do unaligned register access, but some |
| 903 | * weird ones can not. That's especially true for the CF8305 card. |
| 904 | */ |
| 905 | card->align_regs = 0; |
| 906 | |
Holger Schurig | 4c55523 | 2008-06-05 13:08:35 +0200 | [diff] [blame] | 907 | /* Check if we have a current silicon */ |
Marek Vasut | dc7d243 | 2009-03-24 21:33:43 +0100 | [diff] [blame] | 908 | prod_id = if_cs_read8(card, IF_CS_PRODUCT_ID); |
Marek Vasut | 9d45368 | 2009-08-21 04:08:16 +0200 | [diff] [blame] | 909 | if (if_cs_hw_is_cf8305(p_dev)) { |
| 910 | card->align_regs = 1; |
| 911 | if (prod_id < IF_CS_CF8305_B1_REV) { |
| 912 | lbs_pr_err("old chips like 8305 rev B3 " |
| 913 | "aren't supported\n"); |
| 914 | ret = -ENODEV; |
| 915 | goto out2; |
| 916 | } |
| 917 | } |
| 918 | |
Marek Vasut | dc7d243 | 2009-03-24 21:33:43 +0100 | [diff] [blame] | 919 | if (if_cs_hw_is_cf8381(p_dev) && prod_id < IF_CS_CF8381_B3_REV) { |
| 920 | lbs_pr_err("old chips like 8381 rev B3 aren't supported\n"); |
| 921 | ret = -ENODEV; |
| 922 | goto out2; |
| 923 | } |
| 924 | |
| 925 | if (if_cs_hw_is_cf8385(p_dev) && prod_id < IF_CS_CF8385_B1_REV) { |
Holger Schurig | 4c55523 | 2008-06-05 13:08:35 +0200 | [diff] [blame] | 926 | lbs_pr_err("old chips like 8385 rev B1 aren't supported\n"); |
| 927 | ret = -ENODEV; |
| 928 | goto out2; |
| 929 | } |
Holger Schurig | 27590d0 | 2007-10-03 17:25:41 -0700 | [diff] [blame] | 930 | |
| 931 | /* Load the firmware early, before calling into libertas.ko */ |
| 932 | ret = if_cs_prog_helper(card); |
Marek Vasut | 9d45368 | 2009-08-21 04:08:16 +0200 | [diff] [blame] | 933 | if (ret == 0 && !if_cs_hw_is_cf8305(p_dev)) |
Holger Schurig | 27590d0 | 2007-10-03 17:25:41 -0700 | [diff] [blame] | 934 | ret = if_cs_prog_real(card); |
| 935 | if (ret) |
| 936 | goto out2; |
| 937 | |
| 938 | /* Make this card known to the libertas driver */ |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 939 | priv = lbs_add_card(card, &p_dev->dev); |
Holger Schurig | 27590d0 | 2007-10-03 17:25:41 -0700 | [diff] [blame] | 940 | if (!priv) { |
| 941 | ret = -ENOMEM; |
| 942 | goto out2; |
| 943 | } |
| 944 | |
Holger Schurig | 7919b89 | 2008-04-01 14:50:43 +0200 | [diff] [blame] | 945 | /* Finish setting up fields in lbs_private */ |
Dan Williams | 954ee16 | 2007-08-20 11:43:25 -0400 | [diff] [blame] | 946 | card->priv = priv; |
Holger Schurig | 27590d0 | 2007-10-03 17:25:41 -0700 | [diff] [blame] | 947 | priv->card = card; |
Holger Schurig | 7919b89 | 2008-04-01 14:50:43 +0200 | [diff] [blame] | 948 | priv->hw_host_to_card = if_cs_host_to_card; |
David Woodhouse | aa21c00 | 2007-12-08 20:04:36 +0000 | [diff] [blame] | 949 | priv->fw_ready = 1; |
Dan Williams | 954ee16 | 2007-08-20 11:43:25 -0400 | [diff] [blame] | 950 | |
Holger Schurig | 27590d0 | 2007-10-03 17:25:41 -0700 | [diff] [blame] | 951 | /* Now actually get the IRQ */ |
| 952 | ret = request_irq(p_dev->irq.AssignedIRQ, if_cs_interrupt, |
| 953 | IRQF_SHARED, DRV_NAME, card); |
| 954 | if (ret) { |
| 955 | lbs_pr_err("error in request_irq\n"); |
| 956 | goto out3; |
| 957 | } |
| 958 | |
Holger Schurig | 4ef3170 | 2007-10-09 10:41:57 +0200 | [diff] [blame] | 959 | /* Clear any interrupt cause that happend while sending |
| 960 | * firmware/initializing card */ |
Holger Schurig | 78cf074 | 2008-06-02 09:25:05 +0200 | [diff] [blame] | 961 | if_cs_write16(card, IF_CS_CARD_INT_CAUSE, IF_CS_BIT_MASK); |
Ryan Mallon | 28de0b3 | 2007-09-06 21:32:42 -0400 | [diff] [blame] | 962 | if_cs_enable_ints(card); |
| 963 | |
Holger Schurig | 27590d0 | 2007-10-03 17:25:41 -0700 | [diff] [blame] | 964 | /* And finally bring the card up */ |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 965 | if (lbs_start_card(priv) != 0) { |
Holger Schurig | 27590d0 | 2007-10-03 17:25:41 -0700 | [diff] [blame] | 966 | lbs_pr_err("could not activate card\n"); |
| 967 | goto out3; |
| 968 | } |
| 969 | |
| 970 | ret = 0; |
| 971 | goto out; |
| 972 | |
| 973 | out3: |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 974 | lbs_remove_card(priv); |
Holger Schurig | 27590d0 | 2007-10-03 17:25:41 -0700 | [diff] [blame] | 975 | out2: |
| 976 | ioport_unmap(card->iobase); |
| 977 | out1: |
| 978 | pcmcia_disable_device(p_dev); |
| 979 | out: |
| 980 | lbs_deb_leave_args(LBS_DEB_CS, "ret %d", ret); |
| 981 | return ret; |
| 982 | } |
| 983 | |
| 984 | |
| 985 | /* |
| 986 | * This deletes a driver "instance". The device is de-registered with |
| 987 | * Card Services. If it has been released, all local data structures |
| 988 | * are freed. Otherwise, the structures will be freed when the device |
| 989 | * is released. |
| 990 | */ |
| 991 | static void if_cs_detach(struct pcmcia_device *p_dev) |
| 992 | { |
| 993 | struct if_cs_card *card = p_dev->priv; |
| 994 | |
| 995 | lbs_deb_enter(LBS_DEB_CS); |
| 996 | |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 997 | lbs_stop_card(card->priv); |
| 998 | lbs_remove_card(card->priv); |
Ryan Mallon | 28de0b3 | 2007-09-06 21:32:42 -0400 | [diff] [blame] | 999 | if_cs_disable_ints(card); |
Holger Schurig | 27590d0 | 2007-10-03 17:25:41 -0700 | [diff] [blame] | 1000 | if_cs_release(p_dev); |
| 1001 | kfree(card); |
| 1002 | |
| 1003 | lbs_deb_leave(LBS_DEB_CS); |
| 1004 | } |
| 1005 | |
| 1006 | |
| 1007 | |
| 1008 | /********************************************************************/ |
| 1009 | /* Module initialization */ |
| 1010 | /********************************************************************/ |
| 1011 | |
| 1012 | static struct pcmcia_device_id if_cs_ids[] = { |
Marek Vasut | 9d45368 | 2009-08-21 04:08:16 +0200 | [diff] [blame] | 1013 | PCMCIA_DEVICE_MANF_CARD(CF8305_MANFID, CF8305_CARDID), |
Marek Vasut | dc7d243 | 2009-03-24 21:33:43 +0100 | [diff] [blame] | 1014 | PCMCIA_DEVICE_MANF_CARD(CF8381_MANFID, CF8381_CARDID), |
| 1015 | PCMCIA_DEVICE_MANF_CARD(CF8385_MANFID, CF8385_CARDID), |
Holger Schurig | 27590d0 | 2007-10-03 17:25:41 -0700 | [diff] [blame] | 1016 | PCMCIA_DEVICE_NULL, |
| 1017 | }; |
| 1018 | MODULE_DEVICE_TABLE(pcmcia, if_cs_ids); |
| 1019 | |
| 1020 | |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 1021 | static struct pcmcia_driver lbs_driver = { |
Holger Schurig | 27590d0 | 2007-10-03 17:25:41 -0700 | [diff] [blame] | 1022 | .owner = THIS_MODULE, |
| 1023 | .drv = { |
| 1024 | .name = DRV_NAME, |
| 1025 | }, |
| 1026 | .probe = if_cs_probe, |
| 1027 | .remove = if_cs_detach, |
| 1028 | .id_table = if_cs_ids, |
| 1029 | }; |
| 1030 | |
| 1031 | |
| 1032 | static int __init if_cs_init(void) |
| 1033 | { |
| 1034 | int ret; |
| 1035 | |
| 1036 | lbs_deb_enter(LBS_DEB_CS); |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 1037 | ret = pcmcia_register_driver(&lbs_driver); |
Holger Schurig | 27590d0 | 2007-10-03 17:25:41 -0700 | [diff] [blame] | 1038 | lbs_deb_leave(LBS_DEB_CS); |
| 1039 | return ret; |
| 1040 | } |
| 1041 | |
| 1042 | |
| 1043 | static void __exit if_cs_exit(void) |
| 1044 | { |
| 1045 | lbs_deb_enter(LBS_DEB_CS); |
Holger Schurig | 1007832 | 2007-11-15 18:05:47 -0500 | [diff] [blame] | 1046 | pcmcia_unregister_driver(&lbs_driver); |
Holger Schurig | 27590d0 | 2007-10-03 17:25:41 -0700 | [diff] [blame] | 1047 | lbs_deb_leave(LBS_DEB_CS); |
| 1048 | } |
| 1049 | |
| 1050 | |
| 1051 | module_init(if_cs_init); |
| 1052 | module_exit(if_cs_exit); |