lkml.org 
[lkml]   [2009]   [May]   [18]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH] [drivers] [SPI] SPI_GPIO: add support for controllers with missing MISO pin
On Mon, May 18, 2009 at 10:30:55AM +0200, Marek Szyprowski wrote:
> Hello,
>
> On Thursday, May 07, 2009 2:32 PM Ben Dooks wrote:
>
> > On Thu, May 07, 2009 at 02:24:11PM +0200, Marek Szyprowski wrote:
> > > There are some boards that do not strictly follow SPI standard and
> > use only 3 wires (SCLK, MOSI, SS) for connecting some simple auxiliary
> > chips and controls them with GPIO based 'spi controller'. In this
> > configuration the MISO line is missing (it is not required if the chip
> > does not transfer any data back to host). The example of such board is
> > a NCP ARM S3C64XX based machine. This patch adds support for such non-
> > standard configuration in GPIO-based SPI controller.
> > [...]
> > > diff --git a/drivers/spi/spi_gpio.c b/drivers/spi/spi_gpio.c
> > > index 26bd03e..5b75601 100644
> > > --- a/drivers/spi/spi_gpio.c
> > > +++ b/drivers/spi/spi_gpio.c
> > > @@ -114,7 +114,10 @@ static inline void setmosi(const struct
> > spi_device *spi, int is_on)
> > >
> > > static inline int getmiso(const struct spi_device *spi)
> > > {
> > > - return !!gpio_get_value(SPI_MISO_GPIO);
> > > + if (SPI_MISO_GPIO)
> > > + return !!gpio_get_value(SPI_MISO_GPIO);
> > > + else
> > > + return 0;
> > > }
> >
> > Is zero a good approximation for 'no gpio' ?
>
> Now I found that zero might be a valid gpio pin number on some architectures
> (it just means GPIO0 pin). This is imho a bit strange behavior of gpiolib as
> there should be also a special values for INVALID or NOGPIO cases. Does
> anyone have any ideas how such cases should be handled properly?

I belive there is a gpio_is_valid() function to tell you precisely if the
given GPIO is valid.

--
Ben

Q: What's a light-year?
A: One-third less calories than a regular year.



\
 
 \ /
  Last update: 2009-05-18 10:37    [W:0.145 / U:1.092 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site