Cannot Use SPI frequency above 500 kHz
Posted: Wed Jun 05, 2019 11:10 pm
I am running Arch Linux ARM on a Raspberry Pi 2 Model B, and I am attempting to communicate with a TFT display. I am writing a kernel module to interface with the display using SPI, and it works, but I cannot get the SPI frequency to go above 500 kHz. I have successfully used higher frequencies in the user space when using the BCM2835 library, so I know it is possible.
Using the following command to parse the device tree,
I can see that which is hexadecimal for 150 MHz.
gives me hexadecimal for the same number (just with the byte order reversed). In my kernel module, I do the following.
which prints out as expected (error checking code was removed above for brevity). To write to the slave, I use the following command
(I have also tried using and setting the speed there as well, to no avail). This command successfully writes the data, but at a speed of 500 kHz.
Does anyone know why I am being limited to this frequency?
Using the following command to parse the device tree,
Code: Select all
dtc -I fs /sys/firmware/devicetree/base | grep max-frequencyCode: Select all
spi-max-frequency = <0x7735940>Code: Select all
hexdump /sys/class/spi_master/spi0/of_node/spi-max-frequencyCode: Select all
7307 4059Code: Select all
struct spi_board_info spiBoardInfo = {
.modalias = "spi",
.max_speed_hz = 32000000,
.bus_num = 0,
.chip_select = 0,
.mode = 0
};
master = spi_busnum_to_master(spiBoardInfo.bus_num);
spiDevice = spi_new_device(master, &spiBoardInfo);
spiDevice->bits_per_word = 8;
ret = spi_setup(spiDevice);
printk(KERN_INFO "TFT: device max speed %ld\n", spiDevice->max_speed_hz);Code: Select all
32000000Code: Select all
spi_write(spiDevice, &data, sizeof(data));Code: Select all
spi_sync_transfer()Does anyone know why I am being limited to this frequency?