BeaglePlay no /dev/spidev

I can’t get /dev/spidev* to appear, either with no-GUI Debian, nor my custom kernel.

Here is uname -a from the no-GUI Debian:

Linux BeagleBone 6.6.32-ti-arm64-r10 #1 SMP PREEMPT_DYNAMIC Mon Jul 15 21:33:03 UTC 2024 aarch64 GNU/Linux

After sudo modprobe spidev the /dev/spidev device nodes(s) should appear.

The spi0 SPI master device does exist:

debian@BeagleBone:~$ ls -ld /sys/class/spi_master/spi0/*
lrwxrwxrwx 1 root root    0 Aug  7  2024 /sys/class/spi_master/spi0/device -> ../../../20120000.spi
lrwxrwxrwx 1 root root    0 Feb 25 04:10 /sys/class/spi_master/spi0/of_node -> ../../../../../../firmware/devicetree/base/bus@f0000/spi@20120000
drwxr-xr-x 2 root root    0 Feb 25 04:10 /sys/class/spi_master/spi0/power
drwxr-xr-x 2 root root    0 Feb 25 04:10 /sys/class/spi_master/spi0/statistics
lrwxrwxrwx 1 root root    0 Aug  7  2024 /sys/class/spi_master/spi0/subsystem -> ../../../../../../class/spi_master
-rw-r--r-- 1 root root 4096 Aug  7  2024 /sys/class/spi_master/spi0/uevent

The spi0 base address 0x20120000 corresponds to MCSPI2 and the schematic shows that SPI2_CS0 is routed to the mikroBUS socket SCK pin.

I can run a program to toggle GPIO3_12 (RST) successfully. Running the same program to toggle GPIO3_13 (CS) runs successfully but the nothing shows on my oscilloscope.

The only anomaly I have been able to find in the source code is that in the device tree source file k3-am625-beagleplay.dts the SPI output pins are marked as inputs:

	mikrobus_spi_pins_default: mikrobus-spi-default-pins {
		pinctrl-single,pins = <
			AM62X_IOPAD(0x01b0, PIN_INPUT, 1) /* (A20) MCASP0_ACLKR.SPI2_CLK */
			AM62X_IOPAD(0x01ac, PIN_INPUT, 1) /* (E19) MCASP0_AFSR.SPI2_CS0 */
			AM62X_IOPAD(0x0194, PIN_INPUT, 1) /* (B19) MCASP0_AXR3.SPI2_D0 */
			AM62X_IOPAD(0x0198, PIN_INPUT, 1) /* (A19) MCASP0_AXR2.SPI2_D1 */
		>;
	};

Wrong. You’re most likely missing one of the spi overlays for that to work.
The spi hardware is enabled separately from a spidev device.

Take a look here for an example:
src/arm/overlays/BB-SPIDEV0-00A0.dtso · v6.6.x-Beagle · BeagleBoard.org / BeagleBoard-DeviceTrees · GitLab

The channel@0 node is what makes the actual spidev

Don’t get hung up on the GPIO Pin direction; it only applies to the GPIO part of the pin.
Once you switch the PINMUX, whatever underlying device is selected,
it is now in direct control of any directional capabilities of said pin and will override it.

I eventually remembered having to deal with this exact same issue in my custom kernel for the Orange Pi Zero 2W. I enabled the creation of /dev/spidev0.0 by my custom kernel by patching two kernel source files:

k3-am625-beagleplay.dts.orig:

 	pinctrl-names = "default";
 	pinctrl-0 = <&mikrobus_spi_pins_default>;
 	status = "okay";
+
+	spidev@0 {
+		compatible = "beagleplay,spi-dev";
+		status = "okay";
+		reg = <0>;
+	};
 };

spidev.c:

 }
 
 static const struct of_device_id spidev_dt_ids[] = {
+	{ .compatible = "beagleplay,spi-dev", .data = &spidev_of_check },
 	{ .compatible = "cisco,spi-petra", .data = &spidev_of_check },
 	{ .compatible = "dh,dhcom-board", .data = &spidev_of_check },
 	{ .compatible = "elgin,jg10309-01", .data = &spidev_of_check },

Apparently nobody has ever used SPI on the BeaglePlay until now.

compatible = "rohm,dh2228fv";

Supports back to forever (3.8), then you didn’t need to rebuild the spidev driver, and the overlay works on everything.

Jason had a spidev click manifest

Regards,