Skip to contentSkip to conversation

adding bits_per_word to struct spi_board_info to mirror struct spi_device

DISCUSSION Mike Frysinger 3 participants 8 messages Apr 25, 2007 – May 8, 2007

lore
Share & tools
lore
#0 lore raw

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

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

#1 lore raw
Quoted 5 lines · Mike Frysinger

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

Quoted 4 lines

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.

- Dave

#2 lore raw
Quoted 7 lines · David Brownell
Quoted 5 lines · Mike Frysinger

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

Quoted 5 lines

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

Quoted 8 lines
Quoted 4 lines

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

#3 lore raw
Quoted 25 lines · Mike Frysinger
Quoted 7 lines · David Brownell
Quoted 5 lines · Mike Frysinger

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

Quoted 5 lines

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

Quoted 8 lines
Quoted 4 lines

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.

Quoted 7 lines

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

#6 lore raw
In reply to Mike Frysinger
Quoted 8 lines · Mike Frysinger
Quoted 7 lines · David Brownell
Quoted 4 lines · Mike Frysinger

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

Quoted 5 lines
Quoted 3 lines

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.

Quoted 4 lines

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

#4 lore raw
In reply to Bryan WU
Quoted 3 lines · Bryan WU

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

#7 lore raw
In reply to David Brownell
Quoted 8 lines · David Brownell
Quoted 7 lines · Mike Frysinger
Quoted 6 lines · David Brownell
Quoted 4 lines · Mike Frysinger

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

Quoted 8 lines
Quoted 5 lines
Quoted 3 lines

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

Quoted 10 lines
Quoted 4 lines

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

#5 lore raw
In reply to David Brownell
Quoted 11 lines · David Brownell
Quoted 3 lines · Bryan WU

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.

Quoted 7 lines

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