2007-05-07 23:47:51

by Mike Frysinger

[permalink] [raw]
Subject: Re: [spi-devel-general] adding bits_per_word to struct spi_board_info to mirror struct spi_device

On 4/25/07, David Brownell <[email protected]> wrote:
> On Wednesday 25 April 2007, Mike Frysinger wrote:
> > the spi_device structure has a bits_per_word so that you can change
> > the value on a per-device setting, yet the spi_board_info structure
> > does not ... this means that the bus-specific structure has to have a
> > bits_per_word member which the spi bus driver will copy into the spi
> > device bits_per_word member
>
> Actually that's more likely a driver-specific characteristic than
> something related to board wiring/configuration ... a characteristic
> of the particular protocol requests being made. That's why for
> example bits_per_word has a per-transfer override, and drivers are
> able to call spi_setup(spi).

hmm, true ...

> > is there something obvious i'm missing ? seems to me that if the
> > generic spi framework respects bits_per_word on a per-spi device
> > basis, then it should be exposed in the generic info structure so that
> > the setting can be tracked in the boards file ...
>
> The initial driver set didn't need it, that's all. ISTR someone
> else pointed out this quirk, but never provided a patch to resolve
> the issue.

so which direction should it be ? or should it be both ? :)

Blackfin at the moment is doing DMA/bits_per_word setup in the boards
... we could move these to the drivers and have each one just call
spi_setup() at init, or i could post a patch for the common framework
if you think that's an OK direction to [also] go ...
-mike


2007-05-08 03:47:49

by Bryan Wu

[permalink] [raw]
Subject: Re: [spi-devel-general] adding bits_per_word to struct spi_board_info to mirror struct spi_device

On Mon, 2007-05-07 at 19:47 -0400, Mike Frysinger wrote:
> On 4/25/07, David Brownell <[email protected]> wrote:
> > On Wednesday 25 April 2007, Mike Frysinger wrote:
> > > the spi_device structure has a bits_per_word so that you can change
> > > the value on a per-device setting, yet the spi_board_info structure
> > > does not ... this means that the bus-specific structure has to have a
> > > bits_per_word member which the spi bus driver will copy into the spi
> > > device bits_per_word member
> >
> > Actually that's more likely a driver-specific characteristic than
> > something related to board wiring/configuration ... a characteristic
> > of the particular protocol requests being made. That's why for
> > example bits_per_word has a per-transfer override, and drivers are
> > able to call spi_setup(spi).
>
> hmm, true ...
>
> > > is there something obvious i'm missing ? seems to me that if the
> > > generic spi framework respects bits_per_word on a per-spi device
> > > basis, then it should be exposed in the generic info structure so that
> > > the setting can be tracked in the boards file ...
> >
> > The initial driver set didn't need it, that's all. ISTR someone
> > else pointed out this quirk, but never provided a patch to resolve
> > the issue.
>
> so which direction should it be ? or should it be both ? :)
>
> Blackfin at the moment is doing DMA/bits_per_word setup in the boards
> ... we could move these to the drivers and have each one just call
> spi_setup() at init, or i could post a patch for the common framework
> if you think that's an OK direction to [also] go ...
> -mike

Yes, it is very common for spi_framework. DMA setting as well as
bits_per_word setup should be imported to spi_board_info struct. And
currently, there are some duplicated data members in spi_device struct
spi_board_info struct. This two structs are confused driver writers and
boards driver users.

Thanks
-Bryan Wu

2007-05-08 05:00:31

by David Brownell

[permalink] [raw]
Subject: Re: [spi-devel-general] adding bits_per_word to struct spi_board_info to mirror struct spi_device

On Monday 07 May 2007, Mike Frysinger wrote:
> On 4/25/07, David Brownell <[email protected]> wrote:
> > On Wednesday 25 April 2007, Mike Frysinger wrote:
>
> > > is there something obvious i'm missing ? seems to me that if the
> > > generic spi framework respects bits_per_word on a per-spi device
> > > basis, then it should be exposed in the generic info structure so that
> > > the setting can be tracked in the boards file ...
> >
> > The initial driver set didn't need it, that's all. ISTR someone
> > else pointed out this quirk, but never provided a patch to resolve
> > the issue.
>
> so which direction should it be ? or should it be both ? :)

Add bits_per_word to spi_board_info, and have the device creation
logic copy it into spi_device as it's created.


> Blackfin at the moment is doing DMA/bits_per_word setup in the boards
> ... we could move these to the drivers and have each one just call
> spi_setup() at init, or i could post a patch for the common framework
> if you think that's an OK direction to [also] go ...

I don't see what you're getting at here. The SPI core doesn't
do anything with DMA, beyond passing DMA addresses through when
necessary. (Needed to handle messages derived from scatterlists,
since I don't want lower layers to know scatterlists, but otherwise
uncommon.)

And when each spi_device is created, the core calls spi_setup()
with the data. That seems like the natural place to set up
things like DMA and so forth...

The pxa2xx_spi driver uses spi_board_info.controller_data to pass
dma setup/tuning data from board init logic.

- Dave

2007-05-08 05:00:42

by David Brownell

[permalink] [raw]
Subject: Re: [spi-devel-general] adding bits_per_word to struct spi_board_info to mirror struct spi_device

On Monday 07 May 2007, Bryan WU wrote:

> currently, there are some duplicated data members in spi_device struct
> spi_board_info struct. This two structs are confused driver writers and
> boards driver users.

How would that confusion arise? Only arch/.../board-xxx.c writers
normally even see spi_board_info; the exception is that someone who
writes an add-on board -- maybe a USB-to-SPI adapter -- would call the
rarely used spi_new_device() routine.

Developers writing a SPI drivers -- controller drivers touching some
SOC's serial controller hardware, or "struct spi_driver" protocol code
talking to a chip through such a controller -- never see board info.
They only see "struct spi_device". So I don't see why they would have
a reason to be confused.

- Dave

2007-05-08 05:24:18

by Mike Frysinger

[permalink] [raw]
Subject: Re: [spi-devel-general] adding bits_per_word to struct spi_board_info to mirror struct spi_device

On 5/8/07, David Brownell <[email protected]> wrote:
> On Monday 07 May 2007, Mike Frysinger wrote:
> > On 4/25/07, David Brownell <[email protected]> wrote:
> > > On Wednesday 25 April 2007, Mike Frysinger wrote:
> > > > is there something obvious i'm missing ? seems to me that if the
> > > > generic spi framework respects bits_per_word on a per-spi device
> > > > basis, then it should be exposed in the generic info structure so that
> > > > the setting can be tracked in the boards file ...
> > >
> > > The initial driver set didn't need it, that's all. ISTR someone
> > > else pointed out this quirk, but never provided a patch to resolve
> > > the issue.
> >
> > so which direction should it be ? or should it be both ? :)
>
> Add bits_per_word to spi_board_info, and have the device creation
> logic copy it into spi_device as it's created.

OK

> > Blackfin at the moment is doing DMA/bits_per_word setup in the boards
> > ... we could move these to the drivers and have each one just call
> > spi_setup() at init, or i could post a patch for the common framework
> > if you think that's an OK direction to [also] go ...
>
> I don't see what you're getting at here. The SPI core doesn't
> do anything with DMA, beyond passing DMA addresses through when
> necessary. (Needed to handle messages derived from scatterlists,
> since I don't want lower layers to know scatterlists, but otherwise
> uncommon.)

sorry, i didnt mean to confuse things ... i was referring to the only
things that we are configuring at the moment on a per-spi device basis
in Blackfin is bits_per_word and DMA status ... when i said posting a
patch for common framework, i was referring to just bits_per_word
-mike

2007-05-08 07:30:51

by Bryan Wu

[permalink] [raw]
Subject: Re: [spi-devel-general] adding bits_per_word to struct spi_board_info to mirror struct spi_device

On Mon, 2007-05-07 at 22:00 -0700, David Brownell wrote:
> On Monday 07 May 2007, Bryan WU wrote:
>
> > currently, there are some duplicated data members in spi_device struct
> > spi_board_info struct. This two structs are confused driver writers and
> > boards driver users.
>
> How would that confusion arise? Only arch/.../board-xxx.c writers
> normally even see spi_board_info; the exception is that someone who
> writes an add-on board -- maybe a USB-to-SPI adapter -- would call the
> rarely used spi_new_device() routine.
>
> Developers writing a SPI drivers -- controller drivers touching some
> SOC's serial controller hardware, or "struct spi_driver" protocol code
> talking to a chip through such a controller -- never see board info.
> They only see "struct spi_device". So I don't see why they would have
> a reason to be confused.
>
> - Dave

Yes, I agree with you.
spi_board_info ---> board writers.
spi_device ---> spi device driver writers.

It is very clear for me, a spi_master driver developer.

But how does a board writer know the capabilities which the target
spi_device driver supports? For example, a board writer use 16
bits_per_word in a spi_board_info, while the spi_device does not support
this. And maybe other special function spi_device driver can provide but
board writer doesn't know or doesn't know how to use this in
spi_board_info.

So can we just use one struct for both board writers and spi device
driver developers?

Thanks
-Bryan Wu