[PATCH] Added gpios property for SPI slaves

Grant Likely grant.likely at secretlab.ca
Sat Oct 25 08:29:00 EST 2008


On Fri, Oct 24, 2008 at 3:10 PM, Anton Vorontsov
<avorontsov at ru.mvista.com> wrote:
> On Fri, Oct 24, 2008 at 10:08:59PM +0200, Wolfgang Ocker wrote:
>> SPI slave devices require the specification of a chip select address.
>> This patch allows that specification using the gpios property. The reg
>> property remains supported.
>>
>> Signed-off-by: Wolfgang Ocker <weo at reccoware.de>
>> ---
>>
>> --- linux-2.6.27.3/drivers/of/of_spi.c.of_spi_gpio    2008-10-22 23:38:01.000000000 +0200
>> +++ linux-2.6.27.3/drivers/of/of_spi.c.of_spi_cshigh  2008-10-24 21:36:39.000000000 +0200
> [...]
>> --- linux-2.6.27.3/Documentation/powerpc/booting-without-of.txt.of_spi_gpio   2008-10-22 23:38:01.000000000 +0200
>> +++ linux-2.6.27.3/Documentation/powerpc/booting-without-of.txt.of_spi_cshigh 2008-10-24 21:57:16.000000000 +0200
>> @@ -1936,7 +1938,7 @@ platforms are moved over to use the flat
>>                       codec at 1 {
>>                               compatible = "ti,tlv320aic26";
>>                               spi-max-frequency = <100000>;
>> -                             reg = <1>;
>> +                             gpios = <&GPIO1 3>;
>>                       };
>>               };
>
> Close, but no cigar. Sorry. ;-) The bindings are fine as is, you don't
> need to change them.
>
> The scheme should look like this:
>
> spi-controller {
>        #address-cells = <1>;
>        #size-cells = <0>;
>
>        /* two GPIOs, representing two chip selects: 0 and 1 */
>        gpios = <&pio 5 0 &pio 16 0>;
>
>        mmc-slot at 0 {
>                reg = <0>;
>        };
>
>        touchscreen at 1 {
>                reg = <1>;
>        };
> }
>
> Notice that "gpios" is spi-controller's property, not spi devices'.
> It is truly as hardware works, SPI controllers consists of two units:
> I/O, and chip-select machine. Most spi controllers don't have
> dedicated chip-select machines, so they use GPIOs.

FWIW, I 100% agree.

g.

-- 
Grant Likely, B.Sc., P.Eng.
Secret Lab Technologies Ltd.



More information about the Linuxppc-dev mailing list