Hi,
My problem is basically the same as in https://community.nxp.com/t5/i-MX-Processors/Enabling-ecspi1-on-imx8mm-isn-t-working/m-p/1218229 , but that solution doesn't seem to work for me. So I hope somebody has a hint.
I'm using a Congatec imx8mm smarc module and I want to use its ECSPI1 interface. I'm using the 5.4.47 kernel from Congatec, but I also tried a (patched) 5.10.72 version from NXP. But in both kernels I can't get it running.
In the 5.10 kernel I can see - when using an oscilloscope - the correct chip select lines going low when I try to send some data to a slave. But I cannot see any clock signal or signals on the MISO an MOSI lines. In the 5.4 kernel I cannot see anything happening at all.
We have two microchip ksz8895 switches connected to the spi bus. I added the first in the device tree, and the second as a spidev device for further testing.
I used the following device tree entries:
pinctrl_ecspi1: ecspi1grp {
fsl,pins = <
MX8MM_IOMUXC_ECSPI1_SCLK_ECSPI1_SCLK 0x150
MX8MM_IOMUXC_ECSPI1_MOSI_ECSPI1_MOSI 0x150
MX8MM_IOMUXC_ECSPI1_SS0_ECSPI1_SS0 0x150
MX8MM_IOMUXC_ECSPI1_MISO_ECSPI1_MISO 0x150
>;
};
&ecspi1 {
status = "okay";
pinctrl-names = "default";
pinctrl-0 = <&pinctrl_ecspi1>;
cs-gpios = <&gpio4 10 GPIO_ACTIVE_LOW>, <&gpio4 20 GPIO_ACTIVE_LOW>;
num-cs = <2>;
id = <1>;
spi-cpha;
spi-cpol;
ksz8795a: ksz8795@0 {
status = "okay";
compatible = "microchip,ksz8795";
reg = <0>;
dsa,member = <0 0>;
spi-max-frequency = <12500000>;
spi-cpha;
spi-cpol;
ports {
#address-cells = <1>;
#size-cells = <0>;
port@0 {
reg = <0>;
label = "lan01";
};
port@1 {
reg = <1>;
label = "lan02";
};
port@2 {
reg = <2>;
label = "lan03";
};
port@3 {
reg = <3>;
label = "lan04";
};
port@4 {
reg = <4>;
label = "lan05";
};
port@5 {
reg = <5>;
label = "lan9500";
//ethernet = <ð1>;
fixed-link {
speed = <100>;
full-duplex;
};
};
};
};
switch1: spidev@1 {
compatible = "spidev";
spi-max-frequency = <12500000>;
reg = <1>;
status = "okay";
};
};
The pinctrl-handles seem to be ok (30820000 = ecspi1):
cat /sys/kernel/debug/pinctrl/pinctrl-handles
device: 30820000.spi current state: default
state: default
type: MUX_GROUP controller 30330000.pinctrl group: ecspi1grp (21) function: pinctrl (0)
type: CONFIGS_PIN controller 30330000.pinctrl pin MX8MM_IOMUXC_ECSPI1_SCLK (125)config 00000150
type: CONFIGS_PIN controller 30330000.pinctrl pin MX8MM_IOMUXC_ECSPI1_MOSI (126)config 00000150
type: CONFIGS_PIN controller 30330000.pinctrl pin MX8MM_IOMUXC_ECSPI1_SS0 (128)config 00000150
type: CONFIGS_PIN controller 30330000.pinctrl pin MX8MM_IOMUXC_ECSPI1_MISO (127)config 00000150
gpioinfo gives me the following:
gpioinfo
gpiochip3 - 32 lines:
line 10: unnamed "spi0 CS0" output active-low [used]
line 20: unnamed "spi0 CS1" output active-low [used]
But when trying to send some data I'll get an IO Error. When monitoring with an oscilloscope I can only see the chip select line going down. No clock, miso or mosi.
./spidev_test -D /dev/spidev0.1 -s 12500000 -v
output in kernel log:
[ 2161.215336] spidev spi0.1: spi_imx_setup: mode 4, 8 bpw, 12500000 hz
[ 2161.215366] spidev spi0.1: setup mode 0, cs_high, 8 bits/w, 12500000 Hz max --> 0
[ 2161.215374] spidev spi0.1: spi mode 4
[ 2161.215384] spidev spi0.1: spi_imx_setup: mode 4, 8 bpw, 12500000 hz
[ 2161.215393] spidev spi0.1: setup mode 0, cs_high, 8 bits/w, 12500000 Hz max --> 0
[ 2161.215401] spidev spi0.1: 8 bits per word
[ 2161.215408] spidev spi0.1: spi_imx_setup: mode 4, 8 bpw, 12500000 hz
[ 2161.215418] spidev spi0.1: setup mode 0, cs_high, 8 bits/w, 12500000 Hz max --> 0
[ 2161.215426] spidev spi0.1: 12500000 Hz (max)
[ 2161.215596] spi_imx 30820000.spi: mx51_ecspi_clkdiv: fin: 50000000, fspi: 12500000, post: 0, pre: 3
[ 2163.230524] spidev spi0.1: I/O Error in PIO
[ 2163.230542] spidev spi0.1: SPI transfer failed: -110
[ 2163.230566] spi_master spi0: failed to transfer one message from queue
Loading the ksz8795-spi drivers, gives me the same error.
Does anybody has an idea what I missed or where to look for?