libertas: add support for Marvell SD8688 chip
authorBing Zhao <bzhao@marvell.com>
Mon, 6 Apr 2009 22:50:56 +0000 (15:50 -0700)
committerJohn W. Linville <linville@tuxdriver.com>
Wed, 22 Apr 2009 20:54:41 +0000 (16:54 -0400)
libertas: add support for Marvell SD8688 chip

Use RxPD->pkt_ptr to locate eth803 header in the packet
received since SD8688/v10 firmware allows a gap between
RxPD and eth803 header.

Set SDIO block size to 256 for CMD53.
The maximum block size for SD8688 WLAN function is set
to 512 in TPLFE_MAX_BLK_SIZE. But using 512 as block size
results upto 2K bytes data (4 blocks) being transferred
and causes buffer overflow in firmware.

Both changes above are backward compatible with earlier
firmware versions for SD8385/SD8686.

The SDIO_DEVICE_IDs for SD8688 chip are added in
include/linux/mmc/sdio_ids.h

Signed-off-by: Kiran Divekar <dkiran@marvell.com>
Signed-off-by: Bing Zhao <bzhao@marvell.com>
Acked-by: Dan Williams <dcbw@redhat.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
drivers/net/wireless/Kconfig
drivers/net/wireless/libertas/if_sdio.c
drivers/net/wireless/libertas/if_sdio.h
drivers/net/wireless/libertas/rx.c
include/linux/mmc/sdio_ids.h

index 8f279e7bd04957ae8e88dcc773a7bc7f1fb58b84..ad99470ae92d0849bfb71ef02df69dd1215f106c 100644 (file)
@@ -146,10 +146,10 @@ config LIBERTAS_CS
          A driver for Marvell Libertas 8385 CompactFlash devices.
 
 config LIBERTAS_SDIO
-       tristate "Marvell Libertas 8385 and 8686 SDIO 802.11b/g cards"
+       tristate "Marvell Libertas 8385/8686/8688 SDIO 802.11b/g cards"
        depends on LIBERTAS && MMC
        ---help---
-         A driver for Marvell Libertas 8385 and 8686 SDIO devices.
+         A driver for Marvell Libertas 8385/8686/8688 SDIO devices.
 
 config LIBERTAS_SPI
        tristate "Marvell Libertas 8686 SPI 802.11b/g cards"
index 76f4c653d6419782caf65902ffed19b3a5153f03..55864c10f9f1594da1508026987ecc9d345e7aa7 100644 (file)
@@ -48,8 +48,11 @@ static char *lbs_fw_name = NULL;
 module_param_named(fw_name, lbs_fw_name, charp, 0644);
 
 static const struct sdio_device_id if_sdio_ids[] = {
-       { SDIO_DEVICE(SDIO_VENDOR_ID_MARVELL, SDIO_DEVICE_ID_MARVELL_LIBERTAS) },
-       { /* end: all zeroes */                                         },
+       { SDIO_DEVICE(SDIO_VENDOR_ID_MARVELL,
+                       SDIO_DEVICE_ID_MARVELL_LIBERTAS) },
+       { SDIO_DEVICE(SDIO_VENDOR_ID_MARVELL,
+                       SDIO_DEVICE_ID_MARVELL_8688WLAN) },
+       { /* end: all zeroes */                         },
 };
 
 MODULE_DEVICE_TABLE(sdio, if_sdio_ids);
@@ -73,6 +76,12 @@ static struct if_sdio_model if_sdio_models[] = {
                .helper = "sd8686_helper.bin",
                .firmware = "sd8686.bin",
        },
+       {
+               /* 8688 */
+               .model = 0x10,
+               .helper = "sd8688_helper.bin",
+               .firmware = "sd8688.bin",
+       },
 };
 
 struct if_sdio_packet {
@@ -488,7 +497,7 @@ static int if_sdio_prog_helper(struct if_sdio_card *card)
        ret = 0;
 
 release:
-       sdio_set_block_size(card->func, 0);
+       sdio_set_block_size(card->func, IF_SDIO_BLOCK_SIZE);
        sdio_release_host(card->func);
        kfree(chunk_buffer);
 release_fw:
@@ -624,7 +633,7 @@ static int if_sdio_prog_real(struct if_sdio_card *card)
        ret = 0;
 
 release:
-       sdio_set_block_size(card->func, 0);
+       sdio_set_block_size(card->func, IF_SDIO_BLOCK_SIZE);
        sdio_release_host(card->func);
        kfree(chunk_buffer);
 release_fw:
index 533bdfbf5d2af794570e1232e6e23a3052f9d7bc..37ada2c29aa903ea84c8384b31ebaf031966c5a2 100644 (file)
@@ -42,4 +42,6 @@
 
 #define IF_SDIO_EVENT           0x80fc
 
+#define IF_SDIO_BLOCK_SIZE     256
+
 #endif
index 820c22d9220f9d0ac4137df25a29593cacf10582..bd845d09f17433611c17d3daf831ade26bc0c2d4 100644 (file)
@@ -25,7 +25,6 @@ struct rfc1042hdr {
 } __attribute__ ((packed));
 
 struct rxpackethdr {
-       struct rxpd rx_pd;
        struct eth803hdr eth803_hdr;
        struct rfc1042hdr rfc1042_hdr;
 } __attribute__ ((packed));
@@ -158,8 +157,9 @@ int lbs_process_rxed_packet(struct lbs_private *priv, struct sk_buff *skb)
        if (priv->monitormode)
                return process_rxed_802_11_packet(priv, skb);
 
-       p_rx_pkt = (struct rxpackethdr *) skb->data;
-       p_rx_pd = &p_rx_pkt->rx_pd;
+       p_rx_pd = (struct rxpd *) skb->data;
+       p_rx_pkt = (struct rxpackethdr *) ((u8 *)p_rx_pd +
+               le32_to_cpu(p_rx_pd->pkt_ptr));
        if (priv->mesh_dev) {
                if (priv->mesh_fw_ver == MESH_FW_OLD) {
                        if (p_rx_pd->rx_control & RxPD_MESH_FRAME)
@@ -181,8 +181,9 @@ int lbs_process_rxed_packet(struct lbs_private *priv, struct sk_buff *skb)
                goto done;
        }
 
-       lbs_deb_rx("rx data: skb->len-sizeof(RxPd) = %d-%zd = %zd\n",
-              skb->len, sizeof(struct rxpd), skb->len - sizeof(struct rxpd));
+       lbs_deb_rx("rx data: skb->len - pkt_ptr = %d-%zd = %zd\n",
+               skb->len, le32_to_cpu(p_rx_pd->pkt_ptr),
+               skb->len - le32_to_cpu(p_rx_pd->pkt_ptr));
 
        lbs_deb_hex(LBS_DEB_RX, "RX Data: Dest", p_rx_pkt->eth803_hdr.dest_addr,
                sizeof(p_rx_pkt->eth803_hdr.dest_addr));
@@ -216,14 +217,14 @@ int lbs_process_rxed_packet(struct lbs_private *priv, struct sk_buff *skb)
                /* Chop off the rxpd + the excess memory from the 802.2/llc/snap header
                 *   that was removed
                 */
-               hdrchop = (u8 *) p_ethhdr - (u8 *) p_rx_pkt;
+               hdrchop = (u8 *)p_ethhdr - (u8 *)p_rx_pd;
        } else {
                lbs_deb_hex(LBS_DEB_RX, "RX Data: LLC/SNAP",
                        (u8 *) & p_rx_pkt->rfc1042_hdr,
                        sizeof(p_rx_pkt->rfc1042_hdr));
 
                /* Chop off the rxpd */
-               hdrchop = (u8 *) & p_rx_pkt->eth803_hdr - (u8 *) p_rx_pkt;
+               hdrchop = (u8 *)&p_rx_pkt->eth803_hdr - (u8 *)p_rx_pd;
        }
 
        /* Chop off the leading header bytes so the skb points to the start of
index ea1bf5ba092f79b50e72b07e250362b5731194ae..c7211ab6dd4be15f61ba7cc899703f0f29b08474 100644 (file)
@@ -25,5 +25,7 @@
 
 #define SDIO_VENDOR_ID_MARVELL                 0x02df
 #define SDIO_DEVICE_ID_MARVELL_LIBERTAS                0x9103
+#define SDIO_DEVICE_ID_MARVELL_8688WLAN                0x9104
+#define SDIO_DEVICE_ID_MARVELL_8688BT          0x9105
 
 #endif