Help needed for SPI on mt7620

I am upgrading an old system to use openwrt 18.0.6. The old system had some spi data transfers that were accomplished using a custom character device driver.

All the device driver is doing is poking registers. I have recompiled the device against 18.0.6, but cannot get the spi transfers to work (a check on RT2880_SPI1_STAT_REG always indicates busy).

I suspect something in the mt7620a.dtsi is not setting up the pinctrl for SPI. Enabling spi and spi1 results in an error as described here:

Following the advice in that bug report to change the dtsi does eliminate the boot error, but I still do not see spi devices in /dev/ and still cannot get spi to work with the custom register writes.

Does anyone have any suggestions? I am out of ideas.

dmesg | grep -i spi

With the original dtsi this will say

rt2880-pinmux pinctrl: function 'spi_cs1' not supported
rt2880-pinmux pinctrl: invalid function 'spi_cs1' in map table

With the modified dtsi, there is nothing."\[OpenWrt\-Tickets\]+\[OpenWrt\]+%2322191\%3A+MT7620a+DTS+refers+to+invalid+pin+group\%2Ffunction+'spi_cs1'"&o=newest&f=1

Current workaround is to override with '''spi refclk''' in device DTS file
 (leads to same pin settings as for CS1):

 pinctrl {

 spi_cs1: spi1 {
 spi1 {
 ralink,group = "spi refclk";
 ralink,function = "spi refclk";


Yeah, that eliminates the error, but doesn't result in any spi devices, and as far as I can tell, is not putting the pincntrl into a good state for spi. Unless there is something else I have to do in order to be able to use spi directly from register poking.

226	                spi1: spi@b40 {
227	                        compatible = "ralink,rt2880-spi";
236	                        status = "disabled";
237	                        ^^^^^^^^^^^^^^^^^^^
240	                };

note: this seems ok on master / more recent source ( spi refclk is present )... did you mention what source version your using? your sure your selecting the right target?

I'm on the 18.0.6 branch, I am setting spi0 and spi1 status to "okay". I am not sure what you mean by right target, but I am using a custom DTS on top of mt7620a.dtsi, and have system that compiles, flashes and runs fine, just can't make spi work.

does little to help people to help you if you do not share it.

is not a source code version

DTS here:
Can I get an example of what you mean by source version? Appreciate the help.

1 Like


I see those as tags in the repo, but I just checked out openwrt-18.06 (not a tag). My kernel is v4.14.121.

Last time I merged in 18.06 was June 1.

1 Like

try status okay in your custom dts for

&gpio2 {
    status = "okay";

( b40 = ralink,gpio-base = <40> aka the underlying pinmux is disabled? )

under where you have;

&gpio1 {
    status = "okay"; /* needed for the softAP button above */

enabled gpio2, results in gpiochip1 in /dev, and

0.161810] pinctrl core: initialized pinctrl subsystem
[    0.172671] NET: Registered protocol family 16
[    0.443653] mt7620-pci 10140000.pcie: PCIE0 no card, disable it(RST&CLK)
[    0.456883] mt7620-pci: probe of 10140000.pcie failed with error -1
[    0.485712] rt2880_gpio 10000638.gpio: registering 16 gpios
[    0.496741] rt2880_gpio 10000638.gpio: registering 16 irq handlers
[    0.509345] rt2880_gpio 10000660.gpio: registering 32 gpios
[    0.520342] rt2880_gpio 10000660.gpio: registering 32 irq handlers

at boot. Custom spi binary still fails.

bugger... hopefully someone with that device can help.....

Thanks. I dont see why my code isn't able to initialize the spi mode. The only thing I could think of is a dts problem.

well there is still the generic option of going back to a vanilla build ( without the custom dts ) and seeing if that works.....

All the router builds have spi disabled, and due to the dtsi bug they could never work even if they were enabled.

The most aggravating part is that i dont need the spi char devices, i just need the board to be initialized so that I can use spi via direct register control, but I cant get either.

In the end my problem ended up being that spi0 was being configured differently on boot by the newer openwrt. I was unable to match it on boot via DTS edits, so added code to my binary to init it (in addition to the spi1 init that was already present). This solved my issue. The DTS "spi cs1" fix has made it into the 18.06 branch now. Thanks all.

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.