linux-wireless.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Dan Williams <dcbw@redhat.com>
To: Bing Zhao <bzhao@marvell.com>
Cc: libertas-dev@lists.infradead.org, linux-wireless@vger.kernel.org
Subject: Re: [PATCH 2/4] libertas: get SD8688 rx length with one CMD52
Date: Wed, 20 May 2009 18:26:23 -0400	[thread overview]
Message-ID: <1242858383.7048.27.camel@localhost.localdomain> (raw)
In-Reply-To: <1242787701-10685-2-git-send-email-bzhao@marvell.com>

On Tue, 2009-05-19 at 19:48 -0700, Bing Zhao wrote:
> Usually, the 16-bit rx length is read from scratch pad registers
> with two CMD52 transactions:
> SD8385: 	IF_SDIO_SCRATCH_OLD (0x80fe/0x80ff)
> SD8686/SD8688:	IF_SDIO_SCRATCH     (0x34/0x35)
> 
> Alternatively, SD8688 firmware offers an enhanced method for driver
> to read an 8-bit rx length (in units) with a single CMD52:
> IF_SDIO_RX_UNIT 0x43 is read one time after firmware is ready.
> IF_SDIO_RX_LEN  0x42 is read every time when rx interrupt is received.
> 
> Signed-off-by: Bing Zhao <bzhao@marvell.com>

Acked-by: Dan Williams <dcbw@redhat.com>

> ---
>  drivers/net/wireless/libertas/if_sdio.c |   57 +++++++++++++++++++++++++++++-
>  drivers/net/wireless/libertas/if_sdio.h |    3 ++
>  2 files changed, 58 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/net/wireless/libertas/if_sdio.c b/drivers/net/wireless/libertas/if_sdio.c
> index 69d7fd3..e998c12 100644
> --- a/drivers/net/wireless/libertas/if_sdio.c
> +++ b/drivers/net/wireless/libertas/if_sdio.c
> @@ -107,6 +107,8 @@ struct if_sdio_card {
>  
>  	struct workqueue_struct	*workqueue;
>  	struct work_struct	packet_worker;
> +
> +	u8			rx_unit;
>  };
>  
>  /********************************************************************/
> @@ -136,6 +138,46 @@ static u16 if_sdio_read_scratch(struct if_sdio_card *card, int *err)
>  	return scratch;
>  }
>  
> +static u8 if_sdio_read_rx_unit(struct if_sdio_card *card)
> +{
> +	int ret;
> +	u8 rx_unit;
> +
> +	rx_unit = sdio_readb(card->func, IF_SDIO_RX_UNIT, &ret);
> +
> +	if (ret)
> +		rx_unit = 0;
> +
> +	return rx_unit;
> +}
> +
> +static u16 if_sdio_read_rx_len(struct if_sdio_card *card, int *err)
> +{
> +	int ret;
> +	u16 rx_len;
> +
> +	switch (card->model) {
> +	case IF_SDIO_MODEL_8385:
> +	case IF_SDIO_MODEL_8686:
> +		rx_len = if_sdio_read_scratch(card, &ret);
> +		break;
> +	case IF_SDIO_MODEL_8688:
> +	default: /* for newer chipsets */
> +		rx_len = sdio_readb(card->func, IF_SDIO_RX_LEN, &ret);
> +		if (!ret)
> +			rx_len <<= card->rx_unit;
> +		else
> +			rx_len = 0xffff;	/* invalid length */
> +
> +		break;
> +	}
> +
> +	if (err)
> +		*err = ret;
> +
> +	return rx_len;
> +}
> +
>  static int if_sdio_handle_cmd(struct if_sdio_card *card,
>  		u8 *buffer, unsigned size)
>  {
> @@ -254,7 +296,7 @@ static int if_sdio_card_to_host(struct if_sdio_card *card)
>  
>  	lbs_deb_enter(LBS_DEB_SDIO);
>  
> -	size = if_sdio_read_scratch(card, &ret);
> +	size = if_sdio_read_rx_len(card, &ret);
>  	if (ret)
>  		goto out;
>  
> @@ -923,10 +965,21 @@ static int if_sdio_probe(struct sdio_func *func,
>  
>  	priv->fw_ready = 1;
>  
> +	sdio_claim_host(func);
> +
> +	/*
> +	 * Get rx_unit if the chip is SD8688 or newer.
> +	 * SD8385 & SD8686 do not have rx_unit.
> +	 */
> +	if ((card->model != IF_SDIO_MODEL_8385)
> +			&& (card->model != IF_SDIO_MODEL_8686))
> +		card->rx_unit = if_sdio_read_rx_unit(card);
> +	else
> +		card->rx_unit = 0;
> +
>  	/*
>  	 * Enable interrupts now that everything is set up
>  	 */
> -	sdio_claim_host(func);
>  	sdio_writeb(func, 0x0f, IF_SDIO_H_INT_MASK, &ret);
>  	sdio_release_host(func);
>  	if (ret)
> diff --git a/drivers/net/wireless/libertas/if_sdio.h b/drivers/net/wireless/libertas/if_sdio.h
> index cea343f..d3a4fbe 100644
> --- a/drivers/net/wireless/libertas/if_sdio.h
> +++ b/drivers/net/wireless/libertas/if_sdio.h
> @@ -44,6 +44,9 @@
>  #define IF_SDIO_SCRATCH_OLD	0x80fe
>  #define   IF_SDIO_FIRMWARE_OK	0xfedc
>  
> +#define IF_SDIO_RX_LEN		0x42
> +#define IF_SDIO_RX_UNIT		0x43
> +
>  #define IF_SDIO_EVENT           0x80fc
>  
>  #define IF_SDIO_BLOCK_SIZE	256


  reply	other threads:[~2009-05-20 22:26 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-05-20  2:48 [PATCH 1/4] libertas: define macros for SDIO model numbers Bing Zhao
2009-05-20  2:48 ` [PATCH 2/4] libertas: get SD8688 rx length with one CMD52 Bing Zhao
2009-05-20 22:26   ` Dan Williams [this message]
2009-05-20  2:48 ` [PATCH 3/4] libertas: implement function init/shutdown commands for SD8688 Bing Zhao
2009-05-26 20:27   ` Dan Williams
2009-05-27 18:38     ` Bing Zhao
2009-05-20  2:48 ` [PATCH 4/4] libertas: read SD8688 firmware status from new register Bing Zhao
2009-05-20 22:46   ` Dan Williams
2009-05-20 23:50     ` Bing Zhao
2009-05-21 14:40       ` Dan Williams
2009-05-20 22:20 ` [PATCH 1/4] libertas: define macros for SDIO model numbers Dan Williams

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1242858383.7048.27.camel@localhost.localdomain \
    --to=dcbw@redhat.com \
    --cc=bzhao@marvell.com \
    --cc=libertas-dev@lists.infradead.org \
    --cc=linux-wireless@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).