Port-arm archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: SPI device connection woes



Dave Tyson <dtyson%anduin.org.uk@localhost> writes:

> On Sun, 2023-03-19 at 19:22 -0400, Brad Spencer wrote:

[snip]

> Hi Brad,
>
> Thanks for the fast response! I hadn't noticed I had to compile the SPI
> driver into a kernel rather than modloading it. With it added to the
> generic kernel I now see:
>
> [     1.000004] spi0 at sun4ispi0: SPI bus
> [     1.000004] bmx280thp0 at spi0 slave 0
> [     1.000004] sun4ispi0: ctl 0x140013, cctl 0x104a, CLK 150000000Hz,
> SCLK 1000000Hz
> [     1.000004] bmx280thp0: Bosch Sensortec BMP280, Chip ID: 0x58
>
> and the envstat command reports sensible values :-)

Yes, that looks correct to me.

> As an aside I did try driving this device a while ago using the
> SPI_IOCTL_CONFIGURE & SPI_IOCTL_TRANSFER in userland but didn't get
> very far so maybe a kernel driver is the way to go.

For the BMx280 it will be a pain to use it from userland.  That isn't
true of every device I have worked with, but I wouldn't want to do that
with this one.

> I do have a MAX31865 chip which allows temperatures to be read from a
> pt100 probe - this is a pure SPI device. I can probably knock up a
> kernel driver using your code as a guideline. Would this be a more
> sensible route rather than usermode application?

It depends entirely on how messy the chip is.  The Bosch chips are all
messy, at least the BMx280 and BME68x are, and I would not want to try
and use them from userland SPI.  When I was working on scmd(4) I allowed
it to use the scmd driver, which can attach with i2c or SPI, or userland
SPI or userland TTY (that device has a lot of way to talk to the world).
See the scmdctl(1) command for details on how this is done, if you are
interested.  However, this was really only possible because it was
pretty simple to interface to the device.  Nothing about it was very
messy as it modeled itself more or less as a linear set of registers, so
I just allowed the device to be opened, read, write and seek'ed to.  The
environment sensors I have worked with so far really would not lend
themselves to that sort of model, although some of them are simple
enough that a userland interface would be possible..  the SHT4x has a
pretty simple trigger register and a simple read back, for example (but
it is all I2C only).

Is there a data sheet for your device somewhere??

> Thanks again,
> Dave




-- 
Brad Spencer - brad%anduin.eldar.org@localhost - KC8VKS - http://anduin.eldar.org


Home | Main Index | Thread Index | Old Index