we are using TX2 spi@3210000 on our custom board to communicate with another spi slave, but the spi speed cannot exceed 25MHz by using the spi_setup() function.
I changed the max_speed_hz to 50000000, but the spi still works in 25MHZ, what else should i do to get the 50000000MHz speed?
static void tegra_spi_parse_dt(struct tegra_spi_data *tspi)
{
const unsigned int *prop;
struct device_node *np = tspi->dev->of_node;
struct device_node *nc = NULL;
struct device_node *found_nc = NULL;
int len;
int ret;
if (of_find_property(np, "nvidia,clock-always-on", NULL))
tspi->clock_always_on = true;
if (of_find_property(np, "nvidia,polling-mode", NULL))
tspi->polling_mode = true;
if (of_property_read_u32(np, "spi-max-frequency",
&tspi->master->max_speed_hz))
tspi->master->max_speed_hz = 50000000; /* 25MHz */
if (of_property_read_u32(np, "nvidia,maximum-dma-buffer-size",
&tspi->dma_buf_size))
tspi->dma_buf_size = DEFAULT_SPI_DMA_BUF_LEN;
/*
* Last child node or first node which has property as default-cs will
* become the default. When no client is defined, default chipselect
* is zero.
*/
tspi->def_chip_select = 0;
Could you also share the full flash log so that I can get the exact bpmp dtb used in your case?
[ 4.697720] ------------[ cut here ]------------
[ 4.702357] WARNING: CPU: 4 PID: 3818 at ../drivers/spi/spidev.c:767 spidev_probe+0x118/0x218 [spidev]
[ 4.702364] Modules linked in: spidev(+) nvgpu ip_tables x_tables
[ 4.702369] CPU: 4 PID: 3818 Comm: systemd-udevd Not tainted 4.9.253 #946.2
[ 4.702371] Hardware name: lanai-3636 (DT)
[ 4.702372] task: ffffffc0e8b8b700 task.stack: ffffffc0e9820000
[ 4.702377] PC is at spidev_probe+0x118/0x218 [spidev]
[ 4.702381] LR is at spidev_probe+0x118/0x218 [spidev]
[ 4.702383] pc : [<ffffff80011522a8>] lr : [<ffffff80011522a8>] pstate: 40000045
[ 4.702384] sp : ffffffc0e9823a50
I see above error in your dmesg, is it caused from that you used compatible = "cztek,Z1576";? Is this your custom SPI driver?
What SPI device you are connecting on spi@3210000?
The warning occurs because i didn’t load my deviceDriver.ko at boot up, if i load the ko file at boot there won’t be such warning. My SPI device is a slave FPGA chip.
From the flash log you shared, bpmp-dtb used in your case should be tegra186-bpmp-p3636-0001-a00-00.dtb.
Please also help to dump the clock frequency and the parent clock info for spi1.
It should be found through the path like /sys/kernel/debug/bpmp/debug/clk/spi1/*
I tried to set spi-max-frequency = 50000000 in my device tree, but the maxmimum speed is still 25MHz. Do you known if any one has ever succeed generating 50000000MHz spi on TX2?
I found this description in the TRM. It says TX2 spi supports x2 Mode, and the maximun data rate is 65Mbps. Does this mean i can only achieve 32.5Mbps in bidirectional mode or single data wire transfer mode?
If the spi clock rate cannot achieve 50MHz, we will need to change our board design, can you help confirm this?
On TX2, the SPI1 clock is limited by BPMP firmware (DVFS/clock tables), so even with spi-max-frequency = 50000000 the controller input is only ~45.3 MHz and the actual SCK ends up around 25 MHz after divider. There is no supported method to change BPMP’s clock tables to achieve a true 50 MHz SPI clock on TX2, so for production we can only recommend designing the SPI interface for ≤ 25 MHz on this platform.
Could you please configure spi-max-frequency = <52000000>; in the Device Tree and verify the SPI frequency from scope, and also the rate, max_rate, and parent clock via sysfs?