Subject: lkm serial com driver
To: None <tech-kern@netbsd.org>
From: Daniel Brewer <danielb@cat.co.za>
List: tech-kern
Date: 04/06/2006 10:46:52
Hi
I'm having trouble writing an lkm com driver for a serial port add-on board
that we produce.
The situation is as follows:
We manufacture a pci board that has numerous output relays and input sensors
(called pciio).
We also manufacture a piggy-back add-on board that connects to the pciio and
has 4 ns16550 serial port devices on it (we call it the psp - no relation to
Sony ;) ).
We communicate with the pciio 32bit registers through a
pci_mapreg_map(*,PCI_MAPREG_TYPE_MEM,.....).
There are sets of registers that map directly through to the psp com
registers on the ns16550 devices. The lowest 8-bits of the 32-bit registers
map directly through.
In netbsd 1.5 & 1.6, we've built our pciio driver directly into the kernel
and modified the com driver to be able to attach to our pciio0. We've also
modified the com driver to use bus_space_write_4 and bus_space_read_4 for
our psp com ports and use the standard bus_space_write_1 & bus_space_read_1
for the normal serial ports.
When the pciio driver attaches, we do a bus_space_subregion(...) and a
config_found_sm(...) for each serial port on the psp.
This all works great and we can access our extra com-ports through tty2-5 as
normal.
Now, in netbsd 2, we've moved our drivers into lkms, to allow us to keep a
fair amount of independence from the kernel itself. I've had no major
trouble making an lkm of the pciio card driver, but I'm having trouble with
the psp.
I've taken the com.c comvar.h and comreg.h and copied them and modified to
make a pspcom lkm driver. I've changed the bus_space_writes & reads to be
32-bit and got it to attach to the pciio. I've managed to get this attaching
seemingly correctly and it identifies the ns16550a device correctly. The
problem I'm having, is that I can't open up tty2-5 to open the serial ports.
It seems like the tty isn't initializing.
Is there something I'm missing?
Thanks
-Daniel