periph icon indicating copy to clipboard operation
periph copied to clipboard

sysfs-spi: graceful fallback on unidirectional I/O on buggy driver

Open maruel opened this issue 7 years ago • 2 comments

I want the sysfs-spi driver to not allocate memory unless explicitly needed.

Based on https://github.com/google/periph/pull/264#issuecomment-411192356, the SPI kernel driver for MediaTek MT7688AN CPU is buggy and won't work if no read buffer is provided.

For write-only SPI devices like apa102, there's no read buffer provided when doing the SPI transaction.

That causes a problem, as this means that right now trying to use APA102 on a MT7688AN probably doesn't work. A dummy read buffer should be provided to work around the buggy driver.

The optimal case would be to allocate a dummy buffer, but only when this situation is detected.

Paging @svenschwermer.

maruel avatar Aug 08 '18 13:08 maruel

For reference, this is the driver I tested with: https://github.com/openwrt/openwrt/blob/v18.06.0-rc1/target/linux/ramips/patches-4.14/0043-spi-add-mt7621-support.patch

svenschwermer avatar Aug 08 '18 13:08 svenschwermer

Ah dang, it never occurred to me that the speed flag could only take effect on a condition, in this case if it were lower than the default speed.

This line implies support for write-only tx.

maruel avatar Aug 08 '18 13:08 maruel

Ported to https://github.com/periph/host/issues/42.

maruel avatar Sep 20 '23 17:09 maruel