Re: [PATCH] spi: spidev: Add compatible for external SPI ports on Kontron boards

From: Frieder Schrempf
Date: Thu Jul 02 2020 - 12:04:12 EST


Hi Geert,

On 02.07.20 16:57, Geert Uytterhoeven wrote:
Hi Frieder,

On Thu, Jul 2, 2020 at 4:46 PM Frieder Schrempf
<frieder.schrempf@xxxxxxxxxx> wrote:
On 02.07.20 16:25, Mark Brown wrote:
On Thu, Jul 02, 2020 at 04:18:46PM +0200, Schrempf Frieder wrote:
From: Frieder Schrempf <frieder.schrempf@xxxxxxxxxx>

Allow external SPI ports on Kontron boards to use the spidev driver.

I'd have expected this to require loading a DT overlay for whatever's
attached?

My intention is to use the spidev driver in the default board DT for an
interface that is routed to an extension connector and has no dedicated
slave device attached onboard. So users can attach sensors, etc. with
userspace drivers without touching the kernel or DT.

See https://eur04.safelinks.protection.outlook.com/?url=https%3A%2F%2Fpatchwork.kernel.org%2Fpatch%2F11639075%2F&amp;data=02%7C01%7Cfrieder.schrempf%40kontron.de%7C5ca9f0ba0ccb4ab0329f08d81e983d4e%7C8c9d3c973fd941c8a2b1646f3942daf1%7C0%7C0%7C637292987071583819&amp;sdata=M8y9HYICQLocSgRmak6uYsx9Y%2FoukaqgmK2D0F%2FTV98%3D&amp;reserved=0 for the boards DT.

You can bind "kontron,user-spi" devices to spidev from userspace:
[PATCH v2 0/3] device tree spidev solution - driver_override for SPI
https://eur04.safelinks.protection.outlook.com/?url=https%3A%2F%2Fspinics.net%2Flists%2Flinux-spi%2Fmsg13951.html&amp;data=02%7C01%7Cfrieder.schrempf%40kontron.de%7C5ca9f0ba0ccb4ab0329f08d81e983d4e%7C8c9d3c973fd941c8a2b1646f3942daf1%7C0%7C0%7C637292987071583819&amp;sdata=D9pum1oTXWSt%2BY8Egb1J4DOgSa5KH3RwxsSmUl7LgUk%3D&amp;reserved=0

Thanks for pointing that out. I didn't know that this is possible.
I just tried like below it and it works like a charm:

> echo "spidev" > /sys/devices/platform/soc@0/30800000.bus/30840000.spi/spi_master/spi2/spi2.0/driver_override
> echo "spi2.0" > /sys/bus/spi/drivers/spidev/bind

Thanks,
Frieder