linux-spi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH RFC] spi/gpio: start with CS non-active
@ 2012-02-09 21:21 Uwe Kleine-König
       [not found] ` <1328822505-7039-1-git-send-email-u.kleine-koenig-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
  0 siblings, 1 reply; 4+ messages in thread
From: Uwe Kleine-König @ 2012-02-09 21:21 UTC (permalink / raw)
  To: Grant Likely, spi-devel-general-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f
  Cc: kernel-bIcnvbaLZ9MEGnE8C9+IrQ

The chip select line was configured as output with the initial value
being active explicitly. It was later deasserted during
spi_bitbang_setup() without any clock activity in between. So it makes
no sense to activate the device at all and the chip select line can
better start non-active.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
---
Hello,

I'm not sure if an active chip select line without any clock activity can
confuse a device. If so, this patch might qualify as fix. But with my
limited knowledge about spi it's also possible that I just miss why the
active chip select is important. For the devices I have it doesn't seem
to make a difference.

Best regards
Uwe

 drivers/spi/spi-gpio.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/drivers/spi/spi-gpio.c b/drivers/spi/spi-gpio.c
index 0094c64..0b56cfc 100644
--- a/drivers/spi/spi-gpio.c
+++ b/drivers/spi/spi-gpio.c
@@ -235,7 +235,8 @@ static int spi_gpio_setup(struct spi_device *spi)
 			status = gpio_request(cs, dev_name(&spi->dev));
 			if (status)
 				return status;
-			status = gpio_direction_output(cs, spi->mode & SPI_CS_HIGH);
+			status = gpio_direction_output(cs,
+					!(spi->mode & SPI_CS_HIGH));
 		}
 	}
 	if (!status)
-- 
1.7.9


------------------------------------------------------------------------------
Virtualization & Cloud Management Using Capacity Planning
Cloud computing makes use of virtualization - but cloud computing 
also focuses on allowing computing to be delivered as a service.
http://www.accelacomm.com/jaw/sfnl/114/51521223/
_______________________________________________
spi-devel-general mailing list
spi-devel-general@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/spi-devel-general

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH RFC] spi/gpio: start with CS non-active
       [not found] ` <1328822505-7039-1-git-send-email-u.kleine-koenig-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
@ 2012-07-05  7:45   ` Uwe Kleine-König
       [not found]     ` <20120705074540.GF5398-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
  0 siblings, 1 reply; 4+ messages in thread
From: Uwe Kleine-König @ 2012-07-05  7:45 UTC (permalink / raw)
  To: Grant Likely, spi-devel-general-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f
  Cc: kernel-bIcnvbaLZ9MEGnE8C9+IrQ

On Thu, Feb 09, 2012 at 10:21:45PM +0100, Uwe Kleine-König wrote:
> The chip select line was configured as output with the initial value
> being active explicitly. It was later deasserted during
> spi_bitbang_setup() without any clock activity in between. So it makes
> no sense to activate the device at all and the chip select line can
> better start non-active.
> 
> Signed-off-by: Uwe Kleine-König <u.kleine-koenig-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
> ---
> Hello,
> 
> I'm not sure if an active chip select line without any clock activity can
> confuse a device. If so, this patch might qualify as fix. But with my
> limited knowledge about spi it's also possible that I just miss why the
> active chip select is important. For the devices I have it doesn't seem
> to make a difference.
ping

> 
> Best regards
> Uwe
> 
>  drivers/spi/spi-gpio.c |    3 ++-
>  1 files changed, 2 insertions(+), 1 deletions(-)
> 
> diff --git a/drivers/spi/spi-gpio.c b/drivers/spi/spi-gpio.c
> index 0094c64..0b56cfc 100644
> --- a/drivers/spi/spi-gpio.c
> +++ b/drivers/spi/spi-gpio.c
> @@ -235,7 +235,8 @@ static int spi_gpio_setup(struct spi_device *spi)
>  			status = gpio_request(cs, dev_name(&spi->dev));
>  			if (status)
>  				return status;
> -			status = gpio_direction_output(cs, spi->mode & SPI_CS_HIGH);
> +			status = gpio_direction_output(cs,
> +					!(spi->mode & SPI_CS_HIGH));
>  		}
>  	}
>  	if (!status)
> -- 
> 1.7.9
> 
> 

-- 
Pengutronix e.K.                           | Uwe Kleine-König            |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |

------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH RFC] spi/gpio: start with CS non-active
       [not found]     ` <20120705074540.GF5398-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
@ 2012-07-09 12:08       ` Mark Brown
       [not found]         ` <20120709120806.GB28306-GFdadSzt00ze9xe1eoZjHA@public.gmane.org>
  0 siblings, 1 reply; 4+ messages in thread
From: Mark Brown @ 2012-07-09 12:08 UTC (permalink / raw)
  To: Uwe Kleine-K?nig
  Cc: spi-devel-general-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f,
	Linus Walleij, kernel-bIcnvbaLZ9MEGnE8C9+IrQ

On Thu, Jul 05, 2012 at 09:45:40AM +0200, Uwe Kleine-K?nig wrote:
> On Thu, Feb 09, 2012 at 10:21:45PM +0100, Uwe Kleine-K?nig wrote:
> > The chip select line was configured as output with the initial value
> > being active explicitly. It was later deasserted during
> > spi_bitbang_setup() without any clock activity in between. So it makes
> > no sense to activate the device at all and the chip select line can
> > better start non-active.
> > 
> > Signed-off-by: Uwe Kleine-K?nig <u.kleine-koenig-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
> > ---
> > Hello,
> > 
> > I'm not sure if an active chip select line without any clock activity can
> > confuse a device. If so, this patch might qualify as fix. But with my
> > limited knowledge about spi it's also possible that I just miss why the
> > active chip select is important. For the devices I have it doesn't seem
> > to make a difference.
> ping

You probably want to resend this with Linus W in the CCs.

> 
> > 
> > Best regards
> > Uwe
> > 
> >  drivers/spi/spi-gpio.c |    3 ++-
> >  1 files changed, 2 insertions(+), 1 deletions(-)
> > 
> > diff --git a/drivers/spi/spi-gpio.c b/drivers/spi/spi-gpio.c
> > index 0094c64..0b56cfc 100644
> > --- a/drivers/spi/spi-gpio.c
> > +++ b/drivers/spi/spi-gpio.c
> > @@ -235,7 +235,8 @@ static int spi_gpio_setup(struct spi_device *spi)
> >  			status = gpio_request(cs, dev_name(&spi->dev));
> >  			if (status)
> >  				return status;
> > -			status = gpio_direction_output(cs, spi->mode & SPI_CS_HIGH);
> > +			status = gpio_direction_output(cs,
> > +					!(spi->mode & SPI_CS_HIGH));
> >  		}
> >  	}
> >  	if (!status)
> > -- 
> > 1.7.9
> > 
> > 
> 
> -- 
> Pengutronix e.K.                           | Uwe Kleine-K?nig            |
> Industrial Linux Solutions                 | http://www.pengutronix.de/  |
> 
> ------------------------------------------------------------------------------
> Live Security Virtual Conference
> Exclusive live event will cover all the ways today's security and 
> threat landscape has changed and how IT managers can respond. Discussions 
> will include endpoint security, mobile security and the latest in malware 
> threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
> _______________________________________________
> spi-devel-general mailing list
> spi-devel-general-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org
> https://lists.sourceforge.net/lists/listinfo/spi-devel-general
> 

-- 
"You grabbed my hand and we fell into it, like a daydream - or a fever."

------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH RFC] spi/gpio: start with CS non-active
       [not found]         ` <20120709120806.GB28306-GFdadSzt00ze9xe1eoZjHA@public.gmane.org>
@ 2012-07-09 20:18           ` Linus Walleij
  0 siblings, 0 replies; 4+ messages in thread
From: Linus Walleij @ 2012-07-09 20:18 UTC (permalink / raw)
  To: Mark Brown
  Cc: spi-devel-general-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f,
	kernel-bIcnvbaLZ9MEGnE8C9+IrQ, Uwe Kleine-K?nig

On Mon, Jul 9, 2012 at 2:08 PM, Mark Brown <broonie-GFdadSzt00ze9xe1eoZjHA@public.gmane.org> wrote:
> On Thu, Jul 05, 2012 at 09:45:40AM +0200, Uwe Kleine-K?nig wrote:
>> On Thu, Feb 09, 2012 at 10:21:45PM +0100, Uwe Kleine-K?nig wrote:
>> > The chip select line was configured as output with the initial value
>> > being active explicitly. It was later deasserted during
>> > spi_bitbang_setup() without any clock activity in between. So it makes
>> > no sense to activate the device at all and the chip select line can
>> > better start non-active.
>> >
>> > Signed-off-by: Uwe Kleine-K?nig <u.kleine-koenig-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
>> > ---
>> > Hello,
>> >
>> > I'm not sure if an active chip select line without any clock activity can
>> > confuse a device. If so, this patch might qualify as fix. But with my
>> > limited knowledge about spi it's also possible that I just miss why the
>> > active chip select is important. For the devices I have it doesn't seem
>> > to make a difference.
>> ping
>
> You probably want to resend this with Linus W in the CCs.

It all makes sense to me so:
Acked-by: Linus Walleij <linus.walleij-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>

Now the SPI maintainer needs to pick it up though, if your proposal
to pick it up goes through this patch is all yours now.

Yours,
Linus Walleij

------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2012-07-09 20:18 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-02-09 21:21 [PATCH RFC] spi/gpio: start with CS non-active Uwe Kleine-König
     [not found] ` <1328822505-7039-1-git-send-email-u.kleine-koenig-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
2012-07-05  7:45   ` Uwe Kleine-König
     [not found]     ` <20120705074540.GF5398-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
2012-07-09 12:08       ` Mark Brown
     [not found]         ` <20120709120806.GB28306-GFdadSzt00ze9xe1eoZjHA@public.gmane.org>
2012-07-09 20:18           ` Linus Walleij

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).