Daily Archives: 2019-10-27

VoCore2: develop SPI driver 4

Thanks for Leo, I find this new patch https://github.com/openwrt/openwrt/pull/1954.
This patch increases a lot of SPI speed. I have a quick check, looks like it speeds up because of morebuf mode.

...

	/*
	 * Select SPI device 7, enable "more buffer mode" and disable
	 * full-duplex (only half-duplex really works on this chip
	 * reliably)
	 */
	master = mt7621_spi_read(rs, MT7621_SPI_MASTER);
	master |= MASTER_RS_SLAVE_SEL | MASTER_MORE_BUFMODE;
	master &= ~MASTER_FULL_DUPLEX;
	mt7621_spi_write(rs, MT7621_SPI_MASTER, master);

...

static void mt7621_spi_read_half_duplex(struct mt7621_spi *rs,
					int rx_len, u8 *buf)
...
		mt7621_spi_write(rs, MT7621_SPI_MOREBUF, val);

That is nice. A good example about morebuf mode, this should be an important mode for dma. This code saves me a lot time, now I can directly try interrupt and dma.

Currently DMA source address can be fixed and max burst size is 16DWs, in morebuf + half duplex mode we use 8DWs. So DMA should work no problem. We will see later 🙂