libertas: Fix IEEE PS mode in GSPI driver
PATCH 1/1 libertas: Fix IEEE PS mode in GSPI driver
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.
--- drivers/net/wireless/libertas/if_spi.c | 48 ++++++++++++++++++-------------- 1 files changed, 27 insertions(+), 21 deletions(-)
drivers/net/wireless/libertas/if_spi.c +27 -21
@@ -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);
Signature · 1 line
1.5.6.3
PATCH v2 1/1 libertas: fix IEEE PS mode in GSPI driver
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 works around the problem by using the the TX Download Ready bit in place of the Command Download Ready Bit while in IEEE PS mode. TX Download Ready is set in IEEE PS mode.
--- drivers/net/wireless/libertas/if_spi.c | 7 ++++++- 1 files changed, 6 insertions(+), 1 deletions(-)
drivers/net/wireless/libertas/if_spi.c +6 -1
@@ -875,7 +875,12 @@ static int lbs_spi_thread(void *data) err =if_spi_c2h_data (card);if (err) goto err; -if (hiStatus &IF_SPI_HIST_CMD_DOWNLOAD_RDY ) { + +/* workaround: in PS mode, the card does not set the Command +* Download Ready bit, but it sets TX Download Ready. */ +if (hiStatus &IF_SPI_HIST_CMD_DOWNLOAD_RDY || + (card->priv->psstate !=PS_STATE_FULL_POWER && + (hiStatus &IF_SPI_HIST_TX_DOWNLOAD_RDY ))) {/* This means two things. First of all, * if there was a previous command sent, the card has * successfully received it.
Signature · 1 line
1.5.6.3
Re: [PATCH v2] libertas: fix IEEE PS mode in GSPI driver
Quoted 11 lines · Andrey Yurovsky
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 works around the problem by using the the TX Download Ready bit in place of the Command Download Ready Bit while in IEEE PS mode. TX Download Ready is set in IEEE PS mode.
Signed-off-by Andrey Yurovsky <[email protected]>Signed-off-by Javier Cardona <[email protected]>
Quoted 22 lines
--- drivers/net/wireless/libertas/if_spi.c | 7 ++++++- 1 files changed, 6 insertions(+), 1 deletions(-)drivers/net/wireless/libertas/if_spi.c +6
-1@@ -875,7 +875,12 @@ static int lbs_spi_thread(void *data) err =if_spi_c2h_data (card);if (err) goto err; -if (hiStatus &IF_SPI_HIST_CMD_DOWNLOAD_RDY ) { + +/* workaround: in PS mode, the card does not set the Command +* Download Ready bit, but it sets TX Download Ready. */ +if (hiStatus &IF_SPI_HIST_CMD_DOWNLOAD_RDY || + (card->priv->psstate !=PS_STATE_FULL_POWER && + (hiStatus &IF_SPI_HIST_TX_DOWNLOAD_RDY ))) {/* This means two things. First of all, * if there was a previous command sent, the card has * successfully received it.