google / periph

Older version of periph, see new version at https://github.com/periph
https://periph.io
Apache License 2.0
1.75k stars 166 forks source link

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

Closed maruel closed 1 year ago

maruel commented 6 years ago

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.

svenschwermer commented 6 years ago

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

maruel commented 6 years ago

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 commented 1 year ago

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