Created attachment 199531 [details] device tree Hi. We are trying to gain userland access to SPI on the raspberry PI 3 on FreeBSD 12 and FreeBSD 13.0-CURRENT. When we load the spigen.ko kernel module, it successfully loads but no spigen devices appear in /dev. There is a dtb file in the rpi boot partition, bcm2710-rpi-3-b.dtb, and we confirmed it is being loaded. SPI is enabled in config.txt with the line, "dtparam=audio=on,i2c_arm=on,spi=on". sysctl output shows dev.gpio.0.pin.11.function: alt0 dev.gpio.0.pin.10.function: alt0 dev.gpio.0.pin.9.function: alt0 alt0 is correct for SPI according to the Broadcom manual. Yet no /dev/spigen0.n appear with the spigen.ko module loaded. To confirm, we set spi=off in config.txt, for testing, and rebooted and those three pins changed to dev.gpio.0.pin.11.function: input dev.gpio.0.pin.10.function: input dev.gpio.0.pin.9.function: input I have attached the device tree with SPI enabled as output by "ofwdump -a". We also tested with the latest snapshot for FreeBSD 13 as of 11/20/2018. BTW, i2c seems to work fine except that setting the speed via sysctl does not work.
spigen now requires overlay. You need spigen-rpi3.dtso from this review: https://reviews.freebsd.org/D16088 Compile it: dtc -@ -o spigen-rpi3.dtbo spigen-rpi3.dtso and move dtbo to /boot/dtb/overlays/ Add following line to /boot/loader.conf: fdt_overlays="spigen-rpi3" After reboot spigen should be functioning.
In looking at that ofwdump output, it appears that setting "spi=on" automatically enabled 2 "spidev" devices, which are the linux equivelent of our spi(8) (aka spigen) devices. We specifically used a different compatible string, because our driver isn't compatible with linux (it has a different userland API). Now I'm wondering whether it would be better for us to go ahead and add the linux "spidev" compat string to our driver, so that people can use the off-the-shelf overlays on rpi. They would still have to cope with a slightly different userland api to use spi(8).
(In reply to Oleksandr Tymoshenko from comment #1) Thank you Oleksandr. That worked. That puts our ICE40 FPGA project back on track. Tested the SPIGENIOC_SET_CLOCK_SPEED and SPIGENIOC_TRANSFER ioctls and they worked great.
A commit references this bug: Author: gonzo Date: Wed Jan 16 01:08:35 UTC 2019 New revision: 343069 URL: https://svnweb.freebsd.org/changeset/base/343069 Log: [rpi] Reorganize spigen(4) overlays for Raspberry Pi - Remove CS=2 entry from spigen-rpi2 since it didn't work - Add spigen-rpi3 overlay for Raspberry Pi 3 - Enable rpi overlay modules for GENERIC kernel on aarch64 PR: 233489 Submitted by: bobf@mrp3.com Reviewed by: db MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D16088 Changes: head/sys/arm64/conf/GENERIC head/sys/dts/arm/overlays/spigen-rpi2.dtso head/sys/dts/arm64/overlays/spigen-rpi3.dtso head/sys/modules/dtb/rpi/Makefile
spigen-rpi3 overlay was committed to HEAD. I'm going to close this PR as fixed since the original issue is addressed now.
A commit references this bug: Author: gonzo Date: Sun Feb 3 15:34:10 UTC 2019 New revision: 343718 URL: https://svnweb.freebsd.org/changeset/base/343718 Log: MFC r343069: [rpi] Reorganize spigen(4) overlays for Raspberry Pi - Remove CS=2 entry from spigen-rpi2 since it didn't work - Add spigen-rpi3 overlay for Raspberry Pi 3 - Enable rpi overlay modules for GENERIC kernel on aarch64 PR: 233489 Submitted by: bobf@mrp3.com Reviewed by: db Differential Revision: https://reviews.freebsd.org/D16088 Changes: _U stable/12/ stable/12/sys/arm64/conf/GENERIC stable/12/sys/dts/arm/overlays/spigen-rpi2.dtso stable/12/sys/dts/arm64/overlays/spigen-rpi3.dtso stable/12/sys/modules/dtb/rpi/Makefile