UART on an SPI bus?

I have a system running FreeBSD (currently at 12.3, 13.1 upgrade under development) that has a SPI bus, which is working with the FreeBSD spibus driver, to which is connected an ns8250-compatible DUART. There are, in fact, 6 DUARTs on the bus, with chip selects operated by gpio pins. We have written a "spimux" driver which manages these pins. It attaches as a child to the spibus, then creates a second spibus as it's own child. The devices on the second spibus are configured as kernel hints. This all works, and we can access the DUARTs correctly using a test driver that simply copies SPI messages formatted in user space down to the device. This could be improved, but that is not my concern now.

I am attempting to write uart_bus_spi.c to allow attaching the FreeBSD uart driver as a child of the spibus driver. I've figured out how to get it to probe, and uart core gets as far as calling bus_alloc_resource_any(). I've added DEVMETHODs for alloc_resource and release_resource to spibus, and I can see the alloc getting passed up the device chain to the nexus. At that point rman_reserve_resource() returns NULL, which gets returned down the device tree to uart_probe, which then fails.

I'm not sure where to go at this point. I suspect I need to map the UART control registers (which are accessed through SPI messages) to memory somehow, but I have no idea how to go about that. I suspect that needs to happen in my uart_bus_spi code, and it needs to register that mapping with rman, but I'm really just guessing at this point.

I am a longtime embedded engineer, but I have done very little FreeBSD kernel or driver development. Any hints or pointers to instructions or sample code would be deeply appreciated.
Of course, functioning code is always welcome :)

-Steve
 
I have. I didn't find it very helpful for the purpose of attaching a uart driver to the bus. We are proceeding with a custom driver instead (I am not part of that project) and it's working, so I moved on to other things..
 
Back
Top