* How to define an I2C-to-SPI bridge device ?
@ 2010-09-03 8:36 André Schwarz
2010-09-03 12:08 ` Anton Vorontsov
2010-09-09 17:06 ` Grant Likely
0 siblings, 2 replies; 13+ messages in thread
From: André Schwarz @ 2010-09-03 8:36 UTC (permalink / raw)
To: DevTreeDiscuss, LinuxPPC List
Hi,
we're about to get new MPC8377 based hardware with various peripherals.
There are two I2C-to-SPI bridge devices (NXP SC18IS602) and I'm not sure
how to define a proper dts...
Of course it's an easy thing creating 2 child nodes on the CPU's I2C
device - but how can I represent the created SPI bus ?
Is the (possibly) required driver (of_sc18is60x_spi ?) supposed to be an
I2C slave or an SPI host driver ?
Any help is welcome.
--
Mit freundlichen Grüßen / Best regards
André Schwarz
___________________________________________
MATRIX VISION GmbH
- Entwicklung / Development -
Talstraße 16
D-71570 Oppenweiler
Fon: ++49-07191-9432-420
Fax: ++49-07191-9432-288
eMail: andre.schwarz@matrix-vision.de
web: www.matrix-vision.de
MATRIX VISION GmbH, Talstrasse 16, DE-71570 Oppenweiler
Registergericht: Amtsgericht Stuttgart, HRB 271090
Geschaeftsfuehrer: Gerhard Thullner, Werner Armingeon, Uwe Furtner, Hans-Joachim Reich
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: How to define an I2C-to-SPI bridge device ?
2010-09-03 8:36 How to define an I2C-to-SPI bridge device ? André Schwarz
@ 2010-09-03 12:08 ` Anton Vorontsov
2010-09-06 11:40 ` Andre Schwarz
2010-09-09 17:06 ` Grant Likely
1 sibling, 1 reply; 13+ messages in thread
From: Anton Vorontsov @ 2010-09-03 12:08 UTC (permalink / raw)
To: André Schwarz; +Cc: LinuxPPC List, DevTreeDiscuss
On Fri, Sep 03, 2010 at 10:36:19AM +0200, André Schwarz wrote:
> Hi,
>
> we're about to get new MPC8377 based hardware with various peripherals.
> There are two I2C-to-SPI bridge devices (NXP SC18IS602) and I'm not sure
> how to define a proper dts...
>
> Of course it's an easy thing creating 2 child nodes on the CPU's I2C
> device - but how can I represent the created SPI bus ?
Um.. the same as the other SPI buses? I.e.
i2c-controller { /* SOC I2C controller */
spi-controller { /* The I2C-to-SPI bridge */
spi-device@0 {
};
spi-device@1 {
};
};
};
> Is the (possibly) required driver (of_sc18is60x_spi ?) supposed to be an
> I2C slave or an SPI host driver ?
It should be an I2C driver that registers an SPI master (i.e.
calls spi_alloc_master() and spi_register_master()).
Thanks,
--
Anton Vorontsov
email: cbouatmailru@gmail.com
irc://irc.freenode.net/bd2
_______________________________________________
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev
^ permalink raw reply [flat|nested] 13+ messages in thread* Re: How to define an I2C-to-SPI bridge device ?
2010-09-03 12:08 ` Anton Vorontsov
@ 2010-09-06 11:40 ` Andre Schwarz
[not found] ` <4C84D334.6060008-P0pTl12WyEgpBod+wgzj8A@public.gmane.org>
2010-09-09 18:23 ` Grant Likely
0 siblings, 2 replies; 13+ messages in thread
From: Andre Schwarz @ 2010-09-06 11:40 UTC (permalink / raw)
To: Anton Vorontsov; +Cc: LinuxPPC List, DevTreeDiscuss
Anton,
> we're about to get new MPC8377 based hardware with various peripherals.
>> There are two I2C-to-SPI bridge devices (NXP SC18IS602) and I'm not sure
>> how to define a proper dts...
>>
>> Of course it's an easy thing creating 2 child nodes on the CPU's I2C
>> device - but how can I represent the created SPI bus ?
> Um.. the same as the other SPI buses? I.e.
>
> i2c-controller { /* SOC I2C controller */
> spi-controller { /* The I2C-to-SPI bridge */
> spi-device@0 {
> };
> spi-device@1 {
> };
> };
> };
>
ok , thanks - looks straight forward.
Is this any more than plain definition, i.e. will this trigger any I2C
or SPI device registration/linking ?
>> Is the (possibly) required driver (of_sc18is60x_spi ?) supposed to be an
>> I2C slave or an SPI host driver ?
> It should be an I2C driver that registers an SPI master (i.e.
> calls spi_alloc_master() and spi_register_master()).
hmm - ok. Will have to do it manually then ...
I still wonder how to make the driver arch-generic *and* of-capable.
Do we need a generic I2C slave driver that can be probed along with an
"of glue driver" or should the of-binding be part of a single device
driver ?
Sorry for the dumb questions - looks like I expected a little too much
functionality already existing.
Regards,
André
MATRIX VISION GmbH, Talstrasse 16, DE-71570 Oppenweiler
Registergericht: Amtsgericht Stuttgart, HRB 271090
Geschaeftsfuehrer: Gerhard Thullner, Werner Armingeon, Uwe Furtner, Hans-Joachim Reich
_______________________________________________
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev
^ permalink raw reply [flat|nested] 13+ messages in thread[parent not found: <4C84D334.6060008-P0pTl12WyEgpBod+wgzj8A@public.gmane.org>]
* Re: How to define an I2C-to-SPI bridge device ?
[not found] ` <4C84D334.6060008-P0pTl12WyEgpBod+wgzj8A@public.gmane.org>
@ 2010-09-06 14:37 ` André Schwarz
0 siblings, 0 replies; 13+ messages in thread
From: André Schwarz @ 2010-09-06 14:37 UTC (permalink / raw)
To: Anton Vorontsov; +Cc: LinuxPPC List, DevTreeDiscuss
Anton,
looks like I should have looked at include/spi/spi.h earlier :
/*
* INTERFACES between SPI master-side drivers and SPI infrastructure.
* (There's no SPI slave support for Linux yet...)
*/
...this is what I've been looking for.
thanks for your help and sorry for the noise.
Regards,
André
On Mon, 2010-09-06 at 13:40 +0200, Andre Schwarz wrote:
> Anton,
>
> > we're about to get new MPC8377 based hardware with various peripherals.
> >> There are two I2C-to-SPI bridge devices (NXP SC18IS602) and I'm not sure
> >> how to define a proper dts...
> >>
> >> Of course it's an easy thing creating 2 child nodes on the CPU's I2C
> >> device - but how can I represent the created SPI bus ?
> > Um.. the same as the other SPI buses? I.e.
> >
> > i2c-controller { /* SOC I2C controller */
> > spi-controller { /* The I2C-to-SPI bridge */
> > spi-device@0 {
> > };
> > spi-device@1 {
> > };
> > };
> > };
> >
> ok , thanks - looks straight forward.
> Is this any more than plain definition, i.e. will this trigger any I2C
> or SPI device registration/linking ?
> >> Is the (possibly) required driver (of_sc18is60x_spi ?) supposed to be an
> >> I2C slave or an SPI host driver ?
> > It should be an I2C driver that registers an SPI master (i.e.
> > calls spi_alloc_master() and spi_register_master()).
> hmm - ok. Will have to do it manually then ...
>
> I still wonder how to make the driver arch-generic *and* of-capable.
> Do we need a generic I2C slave driver that can be probed along with an
> "of glue driver" or should the of-binding be part of a single device
> driver ?
>
> Sorry for the dumb questions - looks like I expected a little too much
> functionality already existing.
>
>
> Regards,
> André
>
MATRIX VISION GmbH, Talstrasse 16, DE-71570 Oppenweiler
Registergericht: Amtsgericht Stuttgart, HRB 271090
Geschaeftsfuehrer: Gerhard Thullner, Werner Armingeon, Uwe Furtner, Hans-Joachim Reich
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: How to define an I2C-to-SPI bridge device ?
2010-09-06 11:40 ` Andre Schwarz
[not found] ` <4C84D334.6060008-P0pTl12WyEgpBod+wgzj8A@public.gmane.org>
@ 2010-09-09 18:23 ` Grant Likely
2010-09-10 8:11 ` André Schwarz
1 sibling, 1 reply; 13+ messages in thread
From: Grant Likely @ 2010-09-09 18:23 UTC (permalink / raw)
To: Andre Schwarz, Anton Vorontsov; +Cc: LinuxPPC List, DevTreeDiscuss
"Andre Schwarz" <andre.schwarz@matrix-vision.de> wrote:
> Anton,
>
>> we're about to get new MPC8377 based hardware with various peripherals.
>>> There are two I2C-to-SPI bridge devices (NXP SC18IS602) and I'm not sure
>>> how to define a proper dts...
>>>
>>> Of course it's an easy thing creating 2 child nodes on the CPU's I2C
>>> device - but how can I represent the created SPI bus ?
>> Um.. the same as the other SPI buses? I.e.
>>
>> i2c-controller { /* SOC I2C controller */
>> spi-controller { /* The I2C-to-SPI bridge */
>> spi-device@0 {
>> };
>> spi-device@1 {
>> };
>> };
>> };
>>
>ok , thanks - looks straight forward.
>Is this any more than plain definition, i.e. will this trigger any I2C
>or SPI device registration/linking ?
>>> Is the (possibly) required driver (of_sc18is60x_spi ?) supposed to be an
>>> I2C slave or an SPI host driver ?
>> It should be an I2C driver that registers an SPI master (i.e.
>> calls spi_alloc_master() and spi_register_master()).
>hmm - ok. Will have to do it manually then ...
Yes, but this is the case for non-of drivers too. The i2c to spi device driver must always create (and trigger population of) the spi bus instance.
>
>I still wonder how to make the driver arch-generic *and* of-capable.
>Do we need a generic I2C slave driver that can be probed along with an
>"of glue driver" or should the of-binding be part of a single device
>driver ?
There is no longer any need for separate of and non-of drivers for the same hardware. Any device may have the of_node pointer in struct device set, and drivers can use the pointer as an alternative to platform_data to get information about the hardware configuration.
Just read the data out of the node in the driver's probe hook.
For i2c and (soon) spi, the core code will even register child devices for you.
g.
>
>Sorry for the dumb questions - looks like I expected a little too much
>functionality already existing.
>
>
>Regards,
>André
>
>
>MATRIX VISION GmbH, Talstrasse 16, DE-71570 Oppenweiler
>Registergericht: Amtsgericht Stuttgart, HRB 271090
>Geschaeftsfuehrer: Gerhard Thullner, Werner Armingeon, Uwe Furtner, Hans-Joachim Reich
>_______________________________________________
>Linuxppc-dev mailing list
>Linuxppc-dev@lists.ozlabs.org
>https://lists.ozlabs.org/listinfo/linuxppc-dev
--
Sent from my Android phone with K-9 Mail. Please excuse my brevity.
_______________________________________________
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev
^ permalink raw reply [flat|nested] 13+ messages in thread* Re: How to define an I2C-to-SPI bridge device ?
2010-09-09 18:23 ` Grant Likely
@ 2010-09-10 8:11 ` André Schwarz
2010-09-10 17:37 ` Grant Likely
0 siblings, 1 reply; 13+ messages in thread
From: André Schwarz @ 2010-09-10 8:11 UTC (permalink / raw)
To: Grant Likely; +Cc: LinuxPPC List, DevTreeDiscuss
Grant, Anton,
>
> There is no longer any need for separate of and non-of drivers for the same hardware. Any device may have the of_node pointer in struct device set, and drivers can use the pointer as an alternative to platform_data to get information about the hardware configuration.
> Just read the data out of the node in the driver's probe hook.
ok - will do it that way.
>
> For i2c and (soon) spi, the core code will even register child devices for you.
excellent.
Thinking about this device raises even more questions. Since there are
several possible solutions I'd like to hear your opinions :
1.
The SC18IS602 is capable of generating interrupts which is *extremely*
useful triggering on the end of the actual SPI transaction and not the
end of I2C chip access. Since we need an IRQ_ACK over I2C (which takes
loooong with IRQ being still asserted) I'm thinking about using an edge
triggered interrupt.
Since all transactions are in-order there's no risk of missing multiple
edges ... what do you think about this ? Any known issues with edge
triggered IRQs ?
2.
chips select generations is a little tricky.
The device has up to four cs# lines with their assertion being encoded
as subaddr representing a bitfield, i.e. Subaddr 0x01 generates cs0,
0x04 asserts cs3 and 0x07 asserts cs0-2.
At first I thought about registering 4 SPI busses representing the 4 cs#
lines and hide the cs# generation from the user. This would make
multiple cs# assertions for a single write impossible which is a very
useful feature.
Exposing the desired cs# setting for the next transaction via sysfs or
libGPIO requires the user to serialize cs# config and actual SPI
read/write. I also wouldn't know how to properly present the cs# lines
from multiple chips to the user in a clear and unambiguous way.
Any suggestions ?
Regards,
André
MATRIX VISION GmbH, Talstrasse 16, DE-71570 Oppenweiler
Registergericht: Amtsgericht Stuttgart, HRB 271090
Geschaeftsfuehrer: Gerhard Thullner, Werner Armingeon, Uwe Furtner
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: How to define an I2C-to-SPI bridge device ?
2010-09-10 8:11 ` André Schwarz
@ 2010-09-10 17:37 ` Grant Likely
[not found] ` <20100910173706.GD11284-MrY2KI0G/OVr83L8+7iqerDks+cytr/Z@public.gmane.org>
0 siblings, 1 reply; 13+ messages in thread
From: Grant Likely @ 2010-09-10 17:37 UTC (permalink / raw)
To: André Schwarz; +Cc: LinuxPPC List, DevTreeDiscuss, Anton Vorontsov
On Fri, Sep 10, 2010 at 10:11:33AM +0200, André Schwarz wrote:
> Grant, Anton,
>
>
> >
> > There is no longer any need for separate of and non-of drivers for the same hardware. Any device may have the of_node pointer in struct device set, and drivers can use the pointer as an alternative to platform_data to get information about the hardware configuration.
>
> > Just read the data out of the node in the driver's probe hook.
>
> ok - will do it that way.
>
> >
> > For i2c and (soon) spi, the core code will even register child devices for you.
>
> excellent.
>
>
>
> Thinking about this device raises even more questions. Since there are
> several possible solutions I'd like to hear your opinions :
>
> 1.
> The SC18IS602 is capable of generating interrupts which is *extremely*
> useful triggering on the end of the actual SPI transaction and not the
> end of I2C chip access. Since we need an IRQ_ACK over I2C (which takes
> loooong with IRQ being still asserted) I'm thinking about using an edge
> triggered interrupt.
> Since all transactions are in-order there's no risk of missing multiple
> edges ... what do you think about this ? Any known issues with edge
> triggered IRQs ?
Does the device actually generate edge interrupts? Or is it a level
irq device? If it is a level irq device, then the correct way to
handle this is to disable the irq line so that the event can be
handled at non-irq context, and then reenable it when finished.
> 2.
> chips select generations is a little tricky.
> The device has up to four cs# lines with their assertion being encoded
> as subaddr representing a bitfield, i.e. Subaddr 0x01 generates cs0,
> 0x04 asserts cs3 and 0x07 asserts cs0-2.
I'm really not sure what is tricky about this. The spi layer handles
multiple CS lines on a single bus just fine.
To start, how the CS lines are manipulated is only a hardware
implementation detail. The driver can and should do the work of
translate Linux CS line numbers into the format/bitfield expected by
the hardware. Other drivers do the same thing.
> At first I thought about registering 4 SPI busses representing the 4 cs#
> lines and hide the cs# generation from the user. This would make
> multiple cs# assertions for a single write impossible which is a very
> useful feature.
The SPI subsystem doesn't directly support this use-case. If you want
to do this, then assign another chip select number for the purpose of
enabling multiple CS lines at once... and be careful which drivers you
allow to be bound to the oddball CS number. The in-kernel drivers
certainly don't support this use-case, and care must be taken to
ensure only one device is writing to the input line at a time.
What specific hardware do you need this feature for?
> Exposing the desired cs# setting for the next transaction via sysfs or
> libGPIO requires the user to serialize cs# config and actual SPI
> read/write. I also wouldn't know how to properly present the cs# lines
> from multiple chips to the user in a clear and unambiguous way.
Exposing via sysfs or discrete GPIO manipulations is completely the
wrong thing to do.
g.
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: How to define an I2C-to-SPI bridge device ?
2010-09-03 8:36 How to define an I2C-to-SPI bridge device ? André Schwarz
2010-09-03 12:08 ` Anton Vorontsov
@ 2010-09-09 17:06 ` Grant Likely
1 sibling, 0 replies; 13+ messages in thread
From: Grant Likely @ 2010-09-09 17:06 UTC (permalink / raw)
To: André Schwarz; +Cc: LinuxPPC List, DevTreeDiscuss
On Fri, Sep 03, 2010 at 10:36:19AM +0200, André Schwarz wrote:
> Hi,
>
> we're about to get new MPC8377 based hardware with various peripherals.
> There are two I2C-to-SPI bridge devices (NXP SC18IS602) and I'm not sure
> how to define a proper dts...
>
> Of course it's an easy thing creating 2 child nodes on the CPU's I2C
> device - but how can I represent the created SPI bus ?
>
> Is the (possibly) required driver (of_sc18is60x_spi ?) supposed to be an
> I2C slave or an SPI host driver ?
Both! The driver would get probed from the i2c bus, and it would
create and register an spi master. If the spi bus registration
includes a pointer to the device tree node, then the child nodes will
automatically be registered as spi_devices.
The dts is also fairly straight forward:
i2c-bus: i2c@80001000 {
compatible = <blah>;
#address-cells = <1>;
#size-cells = <0>;
spi-bus: spi@28{
compatible = "nxp,sc18is602";
#address-cells = <1>;
#size-cells = <0x28>;
reg = <0>;
spi-device@0 {
compatible = <blah>;
reg = <0>;
};
spi-device@1 {
compatible = <blah>;
reg = <1>;
};
spi-device@2 {
compatible = <blah>;
reg = <2>;
};
};
};
Cheers,
g.
>
>
> Any help is welcome.
>
>
> --
> Mit freundlichen Grüßen / Best regards
>
> André Schwarz
>
> ___________________________________________
>
> MATRIX VISION GmbH
> - Entwicklung / Development -
> Talstraße 16
> D-71570 Oppenweiler
>
> Fon: ++49-07191-9432-420
> Fax: ++49-07191-9432-288
> eMail: andre.schwarz-P0pTl12WyEgpBod+wgzj8A@public.gmane.org
> web: www.matrix-vision.de
>
>
> MATRIX VISION GmbH, Talstrasse 16, DE-71570 Oppenweiler
> Registergericht: Amtsgericht Stuttgart, HRB 271090
> Geschaeftsfuehrer: Gerhard Thullner, Werner Armingeon, Uwe Furtner, Hans-Joachim Reich
> _______________________________________________
> Linuxppc-dev mailing list
> Linuxppc-dev-uLR06cmDAlY/bJ5BZ2RsiQ@public.gmane.org
> https://lists.ozlabs.org/listinfo/linuxppc-dev
^ permalink raw reply [flat|nested] 13+ messages in thread
end of thread, other threads:[~2010-09-13 4:39 UTC | newest]
Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-09-03 8:36 How to define an I2C-to-SPI bridge device ? André Schwarz
2010-09-03 12:08 ` Anton Vorontsov
2010-09-06 11:40 ` Andre Schwarz
[not found] ` <4C84D334.6060008-P0pTl12WyEgpBod+wgzj8A@public.gmane.org>
2010-09-06 14:37 ` André Schwarz
2010-09-09 18:23 ` Grant Likely
2010-09-10 8:11 ` André Schwarz
2010-09-10 17:37 ` Grant Likely
[not found] ` <20100910173706.GD11284-MrY2KI0G/OVr83L8+7iqerDks+cytr/Z@public.gmane.org>
2010-09-10 18:14 ` André Schwarz
2010-09-10 18:27 ` Anton Vorontsov
2010-09-10 18:28 ` Grant Likely
[not found] ` <20100910182815.GH11284-MrY2KI0G/OVr83L8+7iqerDks+cytr/Z@public.gmane.org>
2010-09-12 15:10 ` André Schwarz
2010-09-13 4:39 ` Grant Likely
2010-09-09 17:06 ` Grant Likely
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox