]> err.no Git - linux-2.6/blobdiff - drivers/net/wireless/libertas/if_cs.c
libertas: implement new scanning logic
[linux-2.6] / drivers / net / wireless / libertas / if_cs.c
index 0360cad363a8dacd314be2fb57272daed142c1af..8508260a286b67fb2c9274c433accfe3d22ed736 100644 (file)
@@ -57,7 +57,7 @@ MODULE_LICENSE("GPL");
 
 struct if_cs_card {
        struct pcmcia_device *p_dev;
-       wlan_private *priv;
+       struct lbs_private *priv;
        void __iomem *iobase;
 };
 
@@ -148,11 +148,11 @@ static int if_cs_poll_while_fw_download(struct if_cs_card *card, uint addr, u8 r
 {
        int i;
 
-       for (i = 0; i < 500; i++) {
+       for (i = 0; i < 1000; i++) {
                u8 val = if_cs_read8(card, addr);
                if (val == reg)
                        return i;
-               udelay(100);
+               udelay(500);
        }
        return -ETIME;
 }
@@ -170,7 +170,8 @@ static int if_cs_poll_while_fw_download(struct if_cs_card *card, uint addr, u8 r
 #define IF_CS_H_IC_TX_OVER             0x0001
 #define IF_CS_H_IC_RX_OVER             0x0002
 #define IF_CS_H_IC_DNLD_OVER           0x0004
-#define IF_CS_H_IC_HOST_EVENT          0x0008
+#define IF_CS_H_IC_POWER_DOWN          0x0008
+#define IF_CS_H_IC_HOST_EVENT          0x0010
 #define IF_CS_H_IC_MASK                        0x001f
 
 #define IF_CS_H_INT_MASK               0x00000004
@@ -242,7 +243,7 @@ static inline void if_cs_disable_ints(struct if_cs_card *card)
 
 static irqreturn_t if_cs_interrupt(int irq, void *data)
 {
-       struct if_cs_card *card = (struct if_cs_card *)data;
+       struct if_cs_card *card = data;
        u16 int_cause;
 
        lbs_deb_enter(LBS_DEB_CS);
@@ -252,25 +253,19 @@ static irqreturn_t if_cs_interrupt(int irq, void *data)
                /* Not for us */
                return IRQ_NONE;
 
-       } else if(int_cause == 0xffff) {
+       } else if (int_cause == 0xffff) {
                /* Read in junk, the card has probably been removed */
                card->priv->adapter->surpriseremoved = 1;
 
        } else {
-               if(int_cause & IF_CS_H_IC_TX_OVER) {
-                       card->priv->dnld_sent = DNLD_RES_RECEIVED;
-                       if (!card->priv->adapter->cur_cmd)
-                               wake_up_interruptible(&card->priv->waitq);
-
-                       if (card->priv->adapter->connect_status == LIBERTAS_CONNECTED)
-                               netif_wake_queue(card->priv->dev);
-               }
+               if (int_cause & IF_CS_H_IC_TX_OVER)
+                       lbs_host_to_card_done(card->priv);
 
                /* clear interrupt */
                if_cs_write16(card, IF_CS_C_INT_CAUSE, int_cause & IF_CS_C_IC_MASK);
        }
 
-       libertas_interrupt(card->priv->dev);
+       lbs_interrupt(card->priv->dev);
 
        return IRQ_HANDLED;
 }
@@ -285,7 +280,7 @@ static irqreturn_t if_cs_interrupt(int irq, void *data)
 /*
  * Called from if_cs_host_to_card to send a command to the hardware
  */
-static int if_cs_send_cmd(wlan_private *priv, u8 *buf, u16 nb)
+static int if_cs_send_cmd(struct lbs_private *priv, u8 *buf, u16 nb)
 {
        struct if_cs_card *card = (struct if_cs_card *)priv->card;
        int ret = -1;
@@ -330,7 +325,7 @@ done:
 /*
  * Called from if_cs_host_to_card to send a data to the hardware
  */
-static void if_cs_send_data(wlan_private *priv, u8 *buf, u16 nb)
+static void if_cs_send_data(struct lbs_private *priv, u8 *buf, u16 nb)
 {
        struct if_cs_card *card = (struct if_cs_card *)priv->card;
 
@@ -353,7 +348,7 @@ static void if_cs_send_data(wlan_private *priv, u8 *buf, u16 nb)
 /*
  * Get the command result out of the card.
  */
-static int if_cs_receive_cmdres(wlan_private *priv, u8* data, u32 *len)
+static int if_cs_receive_cmdres(struct lbs_private *priv, u8 *data, u32 *len)
 {
        int ret = -1;
        u16 val;
@@ -378,6 +373,9 @@ static int if_cs_receive_cmdres(wlan_private *priv, u8* data, u32 *len)
        if (*len & 1)
                data[*len-1] = if_cs_read8(priv->card, IF_CS_C_CMD);
 
+       /* This is a workaround for a firmware that reports too much
+        * bytes */
+       *len -= 8;
        ret = 0;
 out:
        lbs_deb_leave_args(LBS_DEB_CS, "ret %d, len %d", ret, *len);
@@ -385,7 +383,7 @@ out:
 }
 
 
-static struct sk_buff *if_cs_receive_data(wlan_private *priv)
+static struct sk_buff *if_cs_receive_data(struct lbs_private *priv)
 {
        struct sk_buff *skb = NULL;
        u16 len;
@@ -615,7 +613,10 @@ done:
 /********************************************************************/
 
 /* Send commands or data packets to the card */
-static int if_cs_host_to_card(wlan_private *priv, u8 type, u8 *buf, u16 nb)
+static int if_cs_host_to_card(struct lbs_private *priv,
+       u8 type,
+       u8 *buf,
+       u16 nb)
 {
        int ret = -1;
 
@@ -640,10 +641,10 @@ static int if_cs_host_to_card(wlan_private *priv, u8 type, u8 *buf, u16 nb)
 }
 
 
-static int if_cs_get_int_status(wlan_private *priv, u8 *ireg)
+static int if_cs_get_int_status(struct lbs_private *priv, u8 *ireg)
 {
        struct if_cs_card *card = (struct if_cs_card *)priv->card;
-       //wlan_adapter *adapter = priv->adapter;
+       /* struct lbs_adapter *adapter = priv->adapter; */
        int ret = 0;
        u16 int_cause;
        u8 *cmdbuf;
@@ -667,7 +668,7 @@ sbi_get_int_status_exit:
        /* is there a data packet for us? */
        if (*ireg & IF_CS_C_S_RX_UPLD_RDY) {
                struct sk_buff *skb = if_cs_receive_data(priv);
-               libertas_process_rxed_packet(priv, skb);
+               lbs_process_rxed_packet(priv, skb);
                *ireg &= ~IF_CS_C_S_RX_UPLD_RDY;
        }
 
@@ -697,7 +698,7 @@ out:
 }
 
 
-static int if_cs_read_event_cause(wlan_private *priv)
+static int if_cs_read_event_cause(struct lbs_private *priv)
 {
        lbs_deb_enter(LBS_DEB_CS);
 
@@ -745,7 +746,7 @@ static void if_cs_release(struct pcmcia_device *p_dev)
 static int if_cs_probe(struct pcmcia_device *p_dev)
 {
        int ret = -ENOMEM;
-       wlan_private *priv;
+       struct lbs_private *priv;
        struct if_cs_card *card;
        /* CIS parsing */
        tuple_t tuple;
@@ -855,7 +856,7 @@ static int if_cs_probe(struct pcmcia_device *p_dev)
                goto out2;
 
        /* Make this card known to the libertas driver */
-       priv = libertas_add_card(card, &p_dev->dev);
+       priv = lbs_add_card(card, &p_dev->dev);
        if (!priv) {
                ret = -ENOMEM;
                goto out2;
@@ -878,10 +879,13 @@ static int if_cs_probe(struct pcmcia_device *p_dev)
                goto out3;
        }
 
+       /* Clear any interrupt cause that happend while sending
+        * firmware/initializing card */
+       if_cs_write16(card, IF_CS_C_INT_CAUSE, IF_CS_C_IC_MASK);
        if_cs_enable_ints(card);
 
        /* And finally bring the card up */
-       if (libertas_start_card(priv) != 0) {
+       if (lbs_start_card(priv) != 0) {
                lbs_pr_err("could not activate card\n");
                goto out3;
        }
@@ -890,7 +894,7 @@ static int if_cs_probe(struct pcmcia_device *p_dev)
        goto out;
 
 out3:
-       libertas_remove_card(priv);
+       lbs_remove_card(priv);
 out2:
        ioport_unmap(card->iobase);
 out1:
@@ -913,8 +917,8 @@ static void if_cs_detach(struct pcmcia_device *p_dev)
 
        lbs_deb_enter(LBS_DEB_CS);
 
-       libertas_stop_card(card->priv);
-       libertas_remove_card(card->priv);
+       lbs_stop_card(card->priv);
+       lbs_remove_card(card->priv);
        if_cs_disable_ints(card);
        if_cs_release(p_dev);
        kfree(card);
@@ -935,7 +939,7 @@ static struct pcmcia_device_id if_cs_ids[] = {
 MODULE_DEVICE_TABLE(pcmcia, if_cs_ids);
 
 
-static struct pcmcia_driver libertas_driver = {
+static struct pcmcia_driver lbs_driver = {
        .owner          = THIS_MODULE,
        .drv            = {
                .name   = DRV_NAME,
@@ -951,7 +955,7 @@ static int __init if_cs_init(void)
        int ret;
 
        lbs_deb_enter(LBS_DEB_CS);
-       ret = pcmcia_register_driver(&libertas_driver);
+       ret = pcmcia_register_driver(&lbs_driver);
        lbs_deb_leave(LBS_DEB_CS);
        return ret;
 }
@@ -960,7 +964,7 @@ static int __init if_cs_init(void)
 static void __exit if_cs_exit(void)
 {
        lbs_deb_enter(LBS_DEB_CS);
-       pcmcia_unregister_driver(&libertas_driver);
+       pcmcia_unregister_driver(&lbs_driver);
        lbs_deb_leave(LBS_DEB_CS);
 }