First of all why do you need SPI device node to be exposed to user space?
I could imagine two possibilities:
- You are creating IoT software that will use user-space driver
- You are experimenting with different devices (that apparently have no kernel space drivers yet)
In any case:
according to Mark Brown (maintainer of SPI subsystem in the kernel):
spidev should never appear directly in ACPI or DT since our ideas about the best way to control the hardware may change.
See full discussion for the details.
Nevertheless Mark applied support for special SPI node in ACPI to expose spidev which you may use
Since the firmware is hardly to be changed for existing boards on market, you need to upgrade ACPI tables in OS. Some of engineers currently are working on a mechanism how to make this stuff easier for people. For now you may try latest vanilla kernel, let's say v4.8-rc3 as for this writing, and take an excerpt to enable SPI device (this is just an example, you need to adjust it regarding to the hardware in use):
/*
* Intel Joule
*
* This adds an SPI test device to the SPI host controller available on
* Intel Joule breakout #1 header:
*
* pin name pin number
* -----------------------------
* SPI_1_MISO_LS 2
* SPI_1_MOSI_LS 4
* SPI_1_FS2_LS 8
* SPI_1_CLK_LS 10
*
* In Linux you need to set CONFIG_SPI_SPIDEV=y (or m) to be able to use
* this device.
*/
DefinitionBlock ("spidev.aml", "SSDT", 5, "INTEL", "SPIDEV", 1)
{
External (_SB_.PCI0.SPI2, DeviceObj)
Scope (\_SB.PCI0.SPI2)
{
Device (TP0) {
Name (_HID, "SPT0001")
Name (_DDN, "SPI test device connected to CS2")
Name (_CRS, ResourceTemplate () {
SpiSerialBus (
2, // Chip select
PolarityLow, // Chip select is active low
FourWireMode, // Full duplex
8, // Bits per word is 8 (byte)
ControllerInitiated, // Don't care
1000000, // 1 MHz
ClockPolarityLow, // SPI mode 0
ClockPhaseFirst, // SPI mode 0
"\_SB.PCI0.SPI2", // SPI host controller
0 // Must be 0
)
})
}
}
}
Since you didn't point to the exact specifications you might need to do an additional work. For older Atoms the vanilla Linux kernel lacks of one patch to propagate ACPI handle to the platform driver.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…