WRTnode add spi slave

From WRTnode Wiki Site
Jump to: navigation, search
This page contains changes which are not marked for translation.

Other languages:
English 100% • ‎中文(中国大陆)‎ 100%

一:Modify spi controller driver to achieve the support of the spi cs1

We assume that $(TOPDIR) for OpenWrt of compiler directory.
open spi-rt2880.c

vim $(TOPDIR)/build_dir/target-mipsel_24kec+dsp_uClibc-0.9.33.2/linux-ramips_mt7620n/linux-3.10.49/drivers/spi/spi-rt2880.c

find struct rt2880_spi_ops then set spi_ops[0].num_cs = 2

static struct rt2880_spi_ops spi_ops[] = {
    {
        .init_hw = rt2880_spi_reset,
        .set_cs = rt2880_spi_set_cs,
        .baudrate_set = rt2880_spi_baudrate_set,
        .write_read = rt2880_spi_write_read,
        .num_cs = 1,  // .num_cs = 2
    }, {
        .init_hw = rt5350_spi_reset,
        .set_cs = rt2880_spi_set_cs,
        .baudrate_set = rt2880_spi_baudrate_set,
        .write_read = rt2880_spi_write_read,
        .num_cs = 2,
    }, {
        .init_hw = mt7621_spi_reset,
        .set_cs = mt7621_spi_set_cs,
        .baudrate_set = mt7621_spi_baudrate_set,
        .write_read = mt7621_spi_write_read,
        .num_cs = 1,
    },
};

二:Complete the registration of spi slave device where the dts

cd $(TOPDIR)/
wget --no-check-certificate https://raw.githubusercontent.com/WRTnode/openwrt-patches/master/R39786/wrtnode_spidev_dts.patch
patch  -p1 < wrtnode_spidev_dts.patch

Spi2.png

三:spi configuration

make menuconfig
Kernel modules  --->    SPI Support  --->    <*> kmod-spi-dev

四:Compile

make

五:flash Firmware
The new firmware re-programmed into the WRTnode, perform the following operations on WRTnode:

ls /dev

Spi6.png

Provide a demo for spidev