We plan to send HDMI related patches to mainline late this month and will add MIPI support if we have time to do that.
If you want to use spi0: spi@1100a000 you should enable it, add the correct pinmux setting and add a device which is connected to spi0.
There are many examples in /arch/arm//boot/dts/* (for more details please grep ‘spi’ ).
Thanks
Hi Ryder. I have editted mt7623.dtsi following;
spi0: spi@1100a000 {
compatible = "mediatek,mt7623-spi",
"mediatek,mt2701-spi";
#address-cells = <1>;
#size-cells = <0>;
reg = <0 0x1100a000 0 0x100>;
interrupts = <GIC_SPI 78 IRQ_TYPE_LEVEL_LOW>;
clocks = <&topckgen CLK_TOP_SYSPLL3_D2>,
<&topckgen CLK_TOP_SPI0_SEL>,
<&pericfg CLK_PERI_SPI0>;
clock-names = "parent-clk", "sel-clk", "spi-clk";
status = "disabled";
};
Also, I added like this mt7623n_bpi_r2.dts file;
spi0_pins_a: spi0@0 {
pins_spi {
pinmux = <MT7623_PIN_53_SPI0_CSN_FUNC_SPI0_CS>,
<MT7623_PIN_54_SPI0_CK_FUNC_SPI0_CK>,
<MT7623_PIN_55_SPI0_MI_FUNC_SPI0_MI>,
<MT7623_PIN_56_SPI0_MO_FUNC_SPI0_MO>;
bias-disable;
};
};
I have checked gpio of spi are correct. But, I couldn’t see /dev/spidev.0.0 after rebuilding kernel.
Did you enable it : "status = “okay”?
Please type this command: find /sys/bus | grep spi
Yes I have also added to mt7623n_bpi_r2.dts following;
&spi0 {
pinctrl-names = "default";
pinctrl-0 = <&spi0_pins_a>;
status = "okay";
};
Actually, Driver is seen, but There is no /dev/spidev
pi@bpi-iot-ros-ai:~$ find /sys/bus | grep spi
/sys/bus/spi
/sys/bus/spi/devices
/sys/bus/spi/drivers
/sys/bus/spi/drivers/spidev
/sys/bus/spi/drivers/spidev/bind
/sys/bus/spi/drivers/spidev/uevent
/sys/bus/spi/drivers/spidev/unbind
/sys/bus/spi/uevent
/sys/bus/spi/drivers_probe
/sys/bus/spi/drivers_autoprobe
/sys/bus/platform/devices/1100a000.spi
/sys/bus/platform/drivers/mtk-spi
/sys/bus/platform/drivers/mtk-spi/bind
/sys/bus/platform/drivers/mtk-spi/1100a000.spi
/sys/bus/platform/drivers/mtk-spi/uevent
/sys/bus/platform/drivers/mtk-spi/unbind
also I have enabled spi user interface from kernel build options.
Hi.
I I have looked the link and made some research. I tried to create devices and bind to driver with “mknod” command. But, I couldn’t solve the problem.
Have you any another idea?
Did you have the slave devices connected to host controller? Did you try to use mdev or udev to create /dev/* node?
Sorry. I didn’t try to create device node from udev and mdev. Because I didn’t find any Info how to create it.
Can you send or tell me how to create spidev from mdev and udev? I will be very glad for this.
enable CONFIG_SPI_SPIDEV and CONFIG_SPI_MT65XX.
Add spidev node to spi bus:
&spi {
pinctrl-names = "default";
pinctrl-0 = <&spi_pins_a>;
status = "okay";
spidev: spidev@0 {
compatible = "spidev";
spi-max-frequency = <1000000>;
reg = <0>;
};
};
build user space test code :Documentation/spi/spidev_test.c and copy to board.
./spidev_test -D /dev/spidevxxx
The below log indicates that spi bus loopback success.
spi mode: 0x0 bits per word:[ 1366.441051] <0>(O) max speed: 500000 Hz (500 KHz) FF FF FF FF FF FF 40 00 00 00 00 95 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF DE AD BE EF BA AD F0 0D
Nope… I can’t it. There is still no /dev/spidev and also device can’t opened at example program.
I can’t figure out what happened here. Try “mdev -s” to create /dev/* …
Btw. Sample-application seems to be here (not Documentation): https://github.com/torvalds/linux/blob/master/tools/spi/spidev_test.c
with the changes from @Ryder.Lee i got a kernel-crash when loading spidev:
root@bpi-r2:~# lsmod
Module Size Used by
bridge 151552 0
mt76x2e 61440 0
mt76 32768 1 mt76x2e
pwm_mediatek 16384 0
mtk_thermal 16384 0
spi_mt65xx 20480 0
thermal_sys 61440 1 mtk_thermal
mt6577_auxadc 16384 0
ip_tables 24576 0
x_tables 28672 1 ip_tables
ipv6 409600 23 bridge
root@bpi-r2:~# modprobe spidev
[ 100.293178] spidev spi0.0: buggy DT: spidev listed directly in DT
[ 100.299303] ------------[ cut here ]------------
[ 100.303914] WARNING: CPU: 0 PID: 699 at drivers/spi/spidev.c:730 spidev_prob]
[ 100.312840] Modules linked in: spidev(+) bridge mt76x2e mt76 pwm_mediatek mt]
[ 100.328025] CPU: 0 PID: 699 Comm: modprobe Tainted: G W 4.14.181
[ 100.336489] Hardware name: Mediatek Cortex-A7 (Device Tree)
[ 100.342043] [<c0113208>] (unwind_backtrace) from [<c010d6b0>] (show_stack+0x)
[ 100.349737] [<c010d6b0>] (show_stack) from [<c08b85e0>] (dump_stack+0x9c/0xb)
[ 100.356914] [<c08b85e0>] (dump_stack) from [<c0125478>] (__warn+0xf8/0x110)
[ 100.363832] [<c0125478>] (__warn) from [<c0125560>] (warn_slowpath_null+0x30)
[ 100.371362] [<c0125560>] (warn_slowpath_null) from [<bf131370>] (spidev_prob)
[ 100.380362] [<bf131370>] (spidev_probe [spidev]) from [<c05d9b44>] (spi_drv_)
[ 100.388747] [<c05d9b44>] (spi_drv_probe) from [<c0476994>] (driver_probe_dev)
[ 100.397137] [<c0476994>] (driver_probe_device) from [<c0476c88>] (__driver_a)
[ 100.405608] [<c0476c88>] (__driver_attach) from [<c04745b4>] (bus_for_each_d)
[ 100.413736] [<c04745b4>] (bus_for_each_dev) from [<c0476170>] (driver_attach)
[ 100.421690] [<c0476170>] (driver_attach) from [<c0475b1c>] (bus_add_driver+0)
[ 100.429645] [<c0475b1c>] (bus_add_driver) from [<c0477978>] (driver_register)
[ 100.437686] [<c0477978>] (driver_register) from [<c05d9a70>] (__spi_register)
[ 100.446249] [<c05d9a70>] (__spi_register_driver) from [<bf137098>] (spidev_i)
[ 100.455417] [<bf137098>] (spidev_init [spidev]) from [<c0101c38>] (do_one_in)
[ 100.463978] [<c0101c38>] (do_one_initcall) from [<c01b1110>] (do_init_module)
[ 100.472020] [<c01b1110>] (do_init_module) from [<c01afff0>] (load_module+0x1)
[ 100.479976] [<c01afff0>] (load_module) from [<c01b0a68>] (SyS_finit_module+0)
[ 100.487758] [<c01b0a68>] (SyS_finit_module) from [<c0108b80>] (ret_fast_sysc)
[ 100.495922] ---[ end trace c412506263de5bee ]---
mt7623.dtsi (33,6 KB) mt7623n-bananapi-bpi-r2.dts (17,7 KB)
it seems that something is wrong in devicetree (spidev spi0.0: buggy DT: spidev listed directly in DT)
root@bpi-r2:~# modprobe spidev
root@bpi-r2:~# lsmod
Module Size Used by
spidev 20480 0
bridge 151552 0
mt76x2e 61440 0
mt76 32768 1 mt76x2e
spi_mt65xx 20480 0
mtk_thermal 16384 0
mt6577_auxadc 16384 0
thermal_sys 61440 1 mtk_thermal
pwm_mediatek 16384 0
ip_tables 24576 0
x_tables 28672 1 ip_tables
ipv6 409600 23 bridge
root@bpi-r2:~# ls /dev/spi*
/dev/spidev0.0
i used the dts-way in the link…
&spi0 {
pinctrl-names = "default";
pinctrl-0 = <&spi0_pins_a>;
status = "okay";
spidev: spidev@0 {
compatible = "rohm,dh2228fv";
//compatible = "spidev";
spi-max-frequency = <1000000>;
reg = <0>;
};
};
but i have not figured out how to compile the test-binary…
arm-linux-gnueabihf-gcc spidev_test.c -Igithub/include/
my kernel-source is in github/…
spidev_test.log (4,8 KB)
tools/spi$ make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf-
seems to do this job…spidev_fdx (17,3 KB) spidev_test (29,0 KB)
root@bpi-r2:~# ./spidev_test -D /dev/spidev0.0
spi mode: 0x0
bits per word: 8
max speed: 500000 Hz (500 KHz)
Hi. Frank.
Thanks. I will try this way in monday.
You added the following
&spi0 {
pinctrl-names = "default";
pinctrl-0 = <&spi0_pins_a>;
status = "okay";
spidev: spidev@0 {
compatible = "rohm,dh2228fv";
//compatible = "spidev";
spi-max-frequency = <1000000>;
reg = <0>;
};
};
to mt7623n_bpi_r2.dts file? Right?
on 4.4 right (the 4.14 pendant)
Good Job Frank.
I tested and verified that “spidev32766.0” is creating at boot time. I can open the port.
Thanks for your efforts.
Hi. I am trying to use GPIO SPI communication on BPI-R2 board. Currently I am using your kernel 4.4.118. Still I need to recompile the kernel to enable SPI or your 4.4.118 kernel already enabled SPI?.
TIA.