public inbox for linux-arm-kernel@lists.infradead.org
 help / color / mirror / Atom feed
From: stephanolbrich@gmx.de (Stephan Olbrich)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 4/4] spi: bcm2835aux: fix CPOL/CPHA setting
Date: Wed, 10 Feb 2016 21:45:27 +0100	[thread overview]
Message-ID: <7621387.PU4Z2tGlUh@chaos-desktop> (raw)
In-Reply-To: <87a8n94e3x.fsf@eliezer.anholt.net>

Am Tuesday 09 February 2016, 16:13:06 schrieb Eric Anholt:
> stephanolbrich at gmx.de writes:
> > From: Stephan Olbrich <stephanolbrich@gmx.de>
> > 
> > The auxiliary spi supports only CPHA=0 modes as the first bit is
> > always output to the pin before the first clock cycle. In CPHA=1
> > modes the first clock edge outputs the second bit hence the slave
> > can never read the first bit.
> > 
> > Also the CPHA registers switch between clocking data in/out on
> > rising/falling edge hence depend on the CPOL setting.
> > 
> > Signed-off-by: Stephan Olbrich <stephanolbrich@gmx.de>
> > ---
> > 
> >  drivers/spi/spi-bcm2835aux.c | 10 +++++-----
> >  1 file changed, 5 insertions(+), 5 deletions(-)
> > 
> > diff --git a/drivers/spi/spi-bcm2835aux.c b/drivers/spi/spi-bcm2835aux.c
> > index b90aa34..169f521 100644
> > --- a/drivers/spi/spi-bcm2835aux.c
> > +++ b/drivers/spi/spi-bcm2835aux.c
> > @@ -386,12 +386,12 @@ static int bcm2835aux_spi_prepare_message(struct
> > spi_master *master,> 
> >  	bs->cntl[1] = BCM2835_AUX_SPI_CNTL1_MSBF_IN;
> >  	
> >  	/* handle all the modes */
> > 
> > -	if (spi->mode & SPI_CPOL)
> > +	if (spi->mode & SPI_CPOL) {
> > 
> >  		bs->cntl[0] |= BCM2835_AUX_SPI_CNTL0_CPOL;
> > 
> > -	if (spi->mode & SPI_CPHA)
> > -		bs->cntl[0] |= BCM2835_AUX_SPI_CNTL0_CPHA_OUT |
> > -			       BCM2835_AUX_SPI_CNTL0_CPHA_IN;
> > -
> > +		bs->cntl[0] |= BCM2835_AUX_SPI_CNTL0_CPHA_OUT;
> > +	} else {
> > +		bs->cntl[0] |= BCM2835_AUX_SPI_CNTL0_CPHA_IN;
> > +	}
> > 
> >  	bcm2835aux_wr(bs, BCM2835_AUX_SPI_CNTL1, bs->cntl[1]);
> >  	bcm2835aux_wr(bs, BCM2835_AUX_SPI_CNTL0, bs->cntl[0]);
> 
> (Note for other readers: A better name for CNTL0_CPHA_* would be
> CNTL0_*_RISING).

Should I rename them? 

> I think you're right about not actually supporting CPHA.  I don't see
> wany way to keep bit 1 out lasting through the first full clock cycle.
> I think Stefan's right that we should drop CPHA from MODE_BITS
> (actually, MODE_BITS would be nicer if we just merged it into its one
> user, I think).

You are right. I'll fix that.

  reply	other threads:[~2016-02-10 20:45 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-02-09 18:10 [PATCH 0/4] spi: bcm2835aux: auxiliary spi improvements stephanolbrich at gmx.de
2016-02-09 18:10 ` [PATCH 1/4] spi: bcm2835aux: fix bitmask defines stephanolbrich at gmx.de
2016-02-09 19:54   ` Stefan Wahren
2016-02-10 20:08     ` Stephan Olbrich
2016-02-09 23:44   ` Eric Anholt
2016-02-09 18:10 ` [PATCH 2/4] spi: bcm2835aux: disable tx fifo empty irq stephanolbrich at gmx.de
2016-02-09 23:45   ` Eric Anholt
2016-02-09 18:10 ` [PATCH 3/4] spi: bcm2835aux: set up spi-mode before asserting cs-gpio stephanolbrich at gmx.de
2016-02-09 23:49   ` Eric Anholt
2016-02-10  8:01     ` Mark Brown
2016-02-10 18:59       ` Eric Anholt
2016-02-10 19:02         ` Mark Brown
2016-02-10 20:26           ` Stephan Olbrich
2016-02-10 23:19             ` Martin Sperl
2016-02-11 12:27             ` Mark Brown
2016-02-11 18:06   ` Martin Sperl
2016-02-09 18:10 ` [PATCH 4/4] spi: bcm2835aux: fix CPOL/CPHA setting stephanolbrich at gmx.de
2016-02-09 20:21   ` Stefan Wahren
2016-02-10  0:13   ` Eric Anholt
2016-02-10 20:45     ` Stephan Olbrich [this message]
2016-02-10 21:24       ` Eric Anholt
2016-02-11 15:25     ` Martin Sperl
2016-02-11 16:05       ` Stephan Olbrich
2016-02-11 16:19         ` Martin Sperl
2016-02-11 18:44           ` Martin Sperl

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=7621387.PU4Z2tGlUh@chaos-desktop \
    --to=stephanolbrich@gmx.de \
    --cc=linux-arm-kernel@lists.infradead.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