Raspberry Pi SPI device example?

Luiz Otavio O Souza lists.br at gmail.com
Wed Mar 4 17:11:31 UTC 2015


On 3 March 2015 at 17:50, Milan Obuch wrote:
> On Mon, 2 Mar 2015 20:14:29 -0300
> Luiz Otavio O Souza wrote:
>
> [ snip ]
>
>> Edit the DTS source file (bcm2835.dtsi and/or rpi.dts in
>> sys/boot/fdt/dts/arm/) and then the DTB will be built as part of the
>> next kernel build (you can also build it manually in
>> sys/modules/dtb/rpi).
>>
>> Here is a patch I'm using to attach a mx25l compatible flash on my RPi
>> (old patch...):
>>
>> http://loos.com.br/mx25l-fdt-intr.diff
>>
>> And the DTS changes:
>>
>> Index: sys/boot/fdt/dts/rpi.dts
>> ===================================================================
>> --- sys/boot/fdt/dts/rpi.dts    (revision 253747)
>> +++ sys/boot/fdt/dts/rpi.dts    (working copy)
>> @@ -281,6 +281,14 @@
>>                                 broadcom,function = "ALT3";
>>                         };
>>                 };
>> +
>> +               spi0 {
>> +                       flash0 {
>> +                               compatible = "flash,mx25l";
>> +                               spi-chipselect = <0>;
>> +                       };
>> +               };
>> +
>>                 usb {
>>                         hub {
>>                                 compatible = "usb,hub", "usb,device";
>>
>>
>> HTH,
>> Luiz
>
> Hi,
>
> no success yet. I wrote simple skeleton containing only basic
> functions, attached, but nothing shows any call to them. In my dts, I
> put
>
>                 spi0 {
>                         tsc0 {
>                                 compatible = "st,stmpe_tc";
>                                 spi-chipselect = <0>;
>                         };
>                 };
>
> I tried some variations, too, but no change. There are just two lines
> in dmesg mentioning spi:
>
> spi0: <BCM2708/2835 SPI controller> mem 0x204000-0x20401f irq 62 on simplebus0
> spibus0: <OFW SPI bus> on spi0
>
> I think I am just missing something simple and obvious, but I can't see
> it. Anybody knows what is missing here?
>
> Regards,
> Milan

It (kinda) works for me:

spi0: <BCM2708/2835 SPI controller> mem 0x204000-0x20401f irq 62 on simplebus0
spibus0: <OFW SPI bus> on spi0
tsc0: probe
tsc0: probe
tsc0: <Touchscreen Controller> at cs 0 on spibus0
tsc0: attach

In case you have the DTS entry but not a driver for the device, you
will see something like:

spi0: <BCM2708/2835 SPI controller> mem 0x204000-0x20401f irq 62 on simplebus0
spibus0: <OFW SPI bus> on spi0
spibus0: <unknown card> at cs 0

Check if your dtb has the necessary nodes:

# ofwdump -a
[...]
    Node 0x1704: bsc1
    Node 0x17a0: spi0
      Node 0x1818: tsc0
    Node 0x1854: dma
    Node 0x1914: mbox
[...]

And the node contents:

# ofwdump -p /axi/spi0/tsc0
Node 0x1818: tsc0
  compatible:
    73 74 2c 73 74 6d 70 65 5f 74 63 00
    'st,stmpe_tc'
  spi-chipselect:
    00 00 00 00

Luiz


More information about the freebsd-arm mailing list