public inbox for linux-wireless@vger.kernel.org
 help / color / mirror / Atom feed
From: Dan Williams <dcbw@redhat.com>
To: Bing Zhao <bzhao@marvell.com>
Cc: "linux-wireless@vger.kernel.org" <linux-wireless@vger.kernel.org>,
	"libertas-dev@lists.infradead.org"
	<libertas-dev@lists.infradead.org>
Subject: RE: [PATCH 4/4] libertas: read SD8688 firmware status from new register
Date: Thu, 21 May 2009 10:40:52 -0400	[thread overview]
Message-ID: <1242916852.14369.3.camel@localhost.localdomain> (raw)
In-Reply-To: <477F20668A386D41ADCC57781B1F704301E8616CA2@SC-VEXCH1.marvell.com>

On Wed, 2009-05-20 at 16:50 -0700, Bing Zhao wrote:
> Hi Dan,
> 
> > -----Original Message-----
> > From: Dan Williams [mailto:dcbw@redhat.com]
> > Sent: Wednesday, May 20, 2009 3:46 PM
> > To: Bing Zhao
> > Cc: libertas-dev@lists.infradead.org; linux-wireless@vger.kernel.org
> > Subject: Re: [PATCH 4/4] libertas: read SD8688 firmware status from new register
> > 
> > On Tue, 2009-05-19 at 19:48 -0700, Bing Zhao wrote:
> > > The scratch pad register is used to store firmware status after
> > > firmware is downloaded and initialized. After firmware status is
> > > verified OK, the same register is used to store RX packet length.
> > > Hence the firmware status code is no longer valid afterwards.
> > >
> > > SD8688 firmware introduces a new register for firmware status
> > > which will never be overwritten.
> > 
> > This could become confusing :)  read_rx_len() already has a switch
> > statement, but since read_rx_len() can also call into read_scratch() for
> > the 8385 and 8686, that *also* has a switch selector.  I can't think of
> > a great way to break it up though without copying a chunk of code around
> > or making useless wrapper functions.
> > 
> 
> Do you think this change makes things better?

Yeah, that's better.  Also saves some processing time because the
scratch reg doesn't have to be set each time a frame comes in.

Want to resubmit with the Signed-off-by and description just for fun? :)

Dan

> diff --git a/drivers/net/wireless/libertas/if_sdio.c b/drivers/net/wireless/libertas/if_sdio.c
> index 18132d4..a7e3fc1 100644
> --- a/drivers/net/wireless/libertas/if_sdio.c
> +++ b/drivers/net/wireless/libertas/if_sdio.c
> @@ -100,6 +100,7 @@ struct if_sdio_card {
>  
>  	int			model;
>  	unsigned long		ioport;
> +	unsigned int		scratch_reg;
>  
>  	const char		*helper;
>  	const char		*firmware;
> @@ -127,25 +128,13 @@ struct if_sdio_card {
>   */
>  static u16 if_sdio_read_scratch(struct if_sdio_card *card, int *err)
>  {
> -	int ret, reg;
> +	int ret;
>  	u16 scratch;
>  
> -	switch (card->model) {
> -	case IF_SDIO_MODEL_8385:
> -		reg = IF_SDIO_SCRATCH_OLD;
> -		break;
> -	case IF_SDIO_MODEL_8686:
> -		reg = IF_SDIO_SCRATCH;
> -		break;
> -	case IF_SDIO_MODEL_8688:
> -	default: /* for newer chipsets */
> -		reg = IF_SDIO_FW_STATUS;
> -		break;
> -	}
> -
> -	scratch = sdio_readb(card->func, reg, &ret);
> +	scratch = sdio_readb(card->func, card->scratch_reg, &ret);
>  	if (!ret)
> -		scratch |= sdio_readb(card->func, reg + 1, &ret) << 8;
> +		scratch |= sdio_readb(card->func, card->scratch_reg + 1,
> +					&ret) << 8;
>  
>  	if (err)
>  		*err = ret;
> @@ -909,6 +898,20 @@ static int if_sdio_probe(struct sdio_func *func,
>  
>  	card->func = func;
>  	card->model = model;
> +
> +	switch (card->model) {
> +	case IF_SDIO_MODEL_8385:
> +		card->scratch_reg = IF_SDIO_SCRATCH_OLD;
> +		break;
> +	case IF_SDIO_MODEL_8686:
> +		card->scratch_reg = IF_SDIO_SCRATCH;
> +		break;
> +	case IF_SDIO_MODEL_8688:
> +	default: /* for newer chipsets */
> +		card->scratch_reg = IF_SDIO_FW_STATUS;
> +		break;
> +	}
> +
>  	spin_lock_init(&card->lock);
>  	card->workqueue = create_workqueue("libertas_sdio");
>  	INIT_WORK(&card->packet_worker, if_sdio_host_to_card_worker);
> 
> 
> 
> Thanks,
> 
> Bing
> 
> 
> > Acked-by: Dan Williams <dcbw@redhat.com>
> > 
> > Dan
> > 
> > > Signed-off-by: Bing Zhao <bzhao@marvell.com>
> > > ---
> > >  drivers/net/wireless/libertas/if_sdio.c |   20 ++++++++++++++++++--
> > >  drivers/net/wireless/libertas/if_sdio.h |    1 +
> > >  2 files changed, 19 insertions(+), 2 deletions(-)
> > >
> > > diff --git a/drivers/net/wireless/libertas/if_sdio.c b/drivers/net/wireless/libertas/if_sdio.c
> > > index 478d766..18132d4 100644
> > > --- a/drivers/net/wireless/libertas/if_sdio.c
> > > +++ b/drivers/net/wireless/libertas/if_sdio.c
> > > @@ -119,15 +119,29 @@ struct if_sdio_card {
> > >  /* I/O                                                              */
> > >  /********************************************************************/
> > >
> > > +/*
> > > + *  For SD8385/SD8686, this function reads firmware status after
> > > + *  the image is downloaded, or reads RX packet length when
> > > + *  interrupt (with IF_SDIO_H_INT_UPLD bit set) is received.
> > > + *  For SD8688, this function reads firmware status only.
> > > + */
> > >  static u16 if_sdio_read_scratch(struct if_sdio_card *card, int *err)
> > >  {
> > >  	int ret, reg;
> > >  	u16 scratch;
> > >
> > > -	if (card->model == IF_SDIO_MODEL_8385)
> > > +	switch (card->model) {
> > > +	case IF_SDIO_MODEL_8385:
> > >  		reg = IF_SDIO_SCRATCH_OLD;
> > > -	else
> > > +		break;
> > > +	case IF_SDIO_MODEL_8686:
> > >  		reg = IF_SDIO_SCRATCH;
> > > +		break;
> > > +	case IF_SDIO_MODEL_8688:
> > > +	default: /* for newer chipsets */
> > > +		reg = IF_SDIO_FW_STATUS;
> > > +		break;
> > > +	}
> > >
> > >  	scratch = sdio_readb(card->func, reg, &ret);
> > >  	if (!ret)
> > > @@ -706,6 +720,8 @@ static int if_sdio_prog_firmware(struct if_sdio_card *card)
> > >  	if (ret)
> > >  		goto out;
> > >
> > > +	lbs_deb_sdio("firmware status = %#x\n", scratch);
> > > +
> > >  	if (scratch == IF_SDIO_FIRMWARE_OK) {
> > >  		lbs_deb_sdio("firmware already loaded\n");
> > >  		goto success;
> > > diff --git a/drivers/net/wireless/libertas/if_sdio.h b/drivers/net/wireless/libertas/if_sdio.h
> > > index d3a4fbe..60c9b2f 100644
> > > --- a/drivers/net/wireless/libertas/if_sdio.h
> > > +++ b/drivers/net/wireless/libertas/if_sdio.h
> > > @@ -42,6 +42,7 @@
> > >
> > >  #define IF_SDIO_SCRATCH		0x34
> > >  #define IF_SDIO_SCRATCH_OLD	0x80fe
> > > +#define IF_SDIO_FW_STATUS	0x40
> > >  #define   IF_SDIO_FIRMWARE_OK	0xfedc
> > >
> > >  #define IF_SDIO_RX_LEN		0x42
> 
> 
> _______________________________________________
> libertas-dev mailing list
> libertas-dev@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/libertas-dev


  reply	other threads:[~2009-05-21 14:41 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
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 [this message]
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=1242916852.14369.3.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