[PATCH] libertas: Fix IEEE PS mode in GSPI driver

Andrey Yurovsky andrey at cozybit.com
Thu Jun 11 19:23:45 EDT 2009


The card firmware does not set the Command Download Ready interrupt bit when
IEEE PS mode is enabled, preventing the driver from sending commands (such as
the command to exit IEEE PS mode) since there is no indication that the card is
ready to accept commands.  

This patch changes the driver to use the TX Download Ready bit, which is 
normally set along with Command Download Ready and does get set in IEEE PS 
mode.  It also moves the card event interrupt acknowledgement to the
interrupt handler and acknowledges all interrupts that we handle as well.

Signed-off-by: Andrey Yurovsky <andrey at cozybit.com>
Signed-off-by: Javier Cardona <javier at cozybit.com>
---
 drivers/net/wireless/libertas/if_spi.c |   48 ++++++++++++++++++--------------
 1 files changed, 27 insertions(+), 21 deletions(-)

diff --git a/drivers/net/wireless/libertas/if_spi.c b/drivers/net/wireless/libertas/if_spi.c
index f8c2898..c32c08d 100644
--- a/drivers/net/wireless/libertas/if_spi.c
+++ b/drivers/net/wireless/libertas/if_spi.c
@@ -820,10 +820,6 @@ static void if_spi_e2h(struct if_spi_card *card)
 	if (err)
 		goto out;
 
-	/* re-enable the card event interrupt */
-	spu_write_u16(card, IF_SPI_HOST_INT_STATUS_REG,
-			~IF_SPI_HICU_CARD_EVENT);
-
 	/* generate a card interrupt */
 	spu_write_u16(card, IF_SPI_CARD_INT_CAUSE_REG, IF_SPI_CIC_HOST_EVENT);
 
@@ -867,23 +863,23 @@ static int lbs_spi_thread(void *data)
 			goto err;
 		}
 
-		if (hiStatus & IF_SPI_HIST_CMD_UPLOAD_RDY)
+		if (hiStatus & IF_SPI_HIST_CMD_UPLOAD_RDY) {
+			spu_write_u16(card, IF_SPI_HOST_INT_STATUS_REG,
+					~(IF_SPI_HIST_CMD_UPLOAD_RDY));
 			err = if_spi_c2h_cmd(card);
 			if (err)
 				goto err;
-		if (hiStatus & IF_SPI_HIST_RX_UPLOAD_RDY)
+		}
+		if (hiStatus & IF_SPI_HIST_RX_UPLOAD_RDY) {
+			spu_write_u16(card, IF_SPI_HOST_INT_STATUS_REG,
+					~(IF_SPI_HIST_RX_UPLOAD_RDY));
 			err = if_spi_c2h_data(card);
 			if (err)
 				goto err;
-		if (hiStatus & IF_SPI_HIST_CMD_DOWNLOAD_RDY) {
-			/* This means two things. First of all,
-			 * if there was a previous command sent, the card has
-			 * successfully received it.
-			 * Secondly, it is now ready to download another
-			 * command.
-			 */
-			lbs_host_to_card_done(card->priv);
+		}
 
+		if (hiStatus & IF_SPI_HIST_TX_DOWNLOAD_RDY ||
+		    hiStatus & IF_SPI_HIST_CMD_DOWNLOAD_RDY) {
 			/* Do we have any command packets from the host to
 			 * send? */
 			packet = NULL;
@@ -895,10 +891,12 @@ static int lbs_spi_thread(void *data)
 			}
 			spin_unlock_irqrestore(&card->buffer_lock, flags);
 
-			if (packet)
-				if_spi_h2c(card, packet, MVMS_CMD);
-		}
-		if (hiStatus & IF_SPI_HIST_TX_DOWNLOAD_RDY) {
+			if (packet) {
+				spu_write_u16(card, IF_SPI_HOST_INT_STATUS_REG,
+					~(IF_SPI_HIST_CMD_DOWNLOAD_RDY));
+				if_spi_h2c(card, packet, MVMS_CMD);
+			}
+
 			/* Do we have any data packets from the host to
 			 * send? */
 			packet = NULL;
@@ -910,12 +908,20 @@ static int lbs_spi_thread(void *data)
 			}
 			spin_unlock_irqrestore(&card->buffer_lock, flags);
 
-			if (packet)
+			if (packet) {
+				spu_write_u16(card, IF_SPI_HOST_INT_STATUS_REG,
+						~(IF_SPI_HIST_TX_DOWNLOAD_RDY));
 				if_spi_h2c(card, packet, MVMS_DAT);
+			}
+
+			lbs_host_to_card_done(card->priv);
 		}
-		if (hiStatus & IF_SPI_HIST_CARD_EVENT)
-			if_spi_e2h(card);
 
+		if (hiStatus & IF_SPI_HIST_CARD_EVENT) {
+			spu_write_u16(card, IF_SPI_HOST_INT_STATUS_REG,
+					~(IF_SPI_HIST_CARD_EVENT));
+			if_spi_e2h(card);
+		}
 err:
 		if (err)
 			lbs_pr_err("%s: got error %d\n", __func__, err);
-- 
1.5.6.3




More information about the libertas-dev mailing list