Subject: Re: Using same com.c driver for two devices that access serial port differently?
To: Bruce Martin <brucem@cat.co.za>
From: Ian Zagorskih <ianzag@megasignal.com>
List: tech-kern
Date: 06/25/2003 22:55:29
On Wednesday 25 June 2003 15:05, Bruce Martin wrote:
> Hi all
>
> We have recently developed a serial port card that plugs onto another o=
ne
> of our cards as a daughter card. What I have done, using the puc.c driv=
er
> as a reference, is written the hooks so that serial ports can attach th=
e
> the isa bus (for the 2 motherboard serial ports) or to our already exit=
ing
> custom device (for the 4 serial ports on the daughtercard). So the kern=
el
> registers the following: com0 at isa0 port ...
> com1 at isa0 port ...
> com2 at pciio0 port...
> com3 at pciio0 port...
> com4 at pciio0 port...
> com5 at pciio0 port...
>
> So all looks awell and good - the daughter card has an NS16550 compatib=
le
> chipset, so it should work with the com.c driver as is - the
> machine-dependent code has hooked up to com.c so that the bus_space rea=
ds
> and writes should access the registers.
>
> Here's the catch: for reasons outside of our control, the serial card
> device on the pciio device has to be accessed via addresses multiplied =
by
> 4. So, if we want to access the NS16550 register at 0x13, we actually h=
ave
> to attempt an access to 0x4C, and if we were looking for the contents o=
f
> the 16550 register at 0x1, we would need to read the offset 0x04.
>
> So, what I need to know is: is there any way to do this kind of
> mapping/translation in the hooking up of the machine dependent code. Th=
e
> aim would be for the following line in com.c:
> bus_space_read_1(iot,ioh,0x03)
>
> to access the register at address 0x03 for the isa com's, and to access=
the
> register at address 0x0C for the pciio com's.
>
AFAIU from dev/ic/com.c source code you cannot do this so simple. All=20
bus_space_read_1()/write_1() calls use absolute register offset values=20
defined at dev/ic/ns16550reg.h like below:
------
#define=09com_data=09=090=09/* data register (R/W) */
#define=09com_ier=09=091=09/* interrupt enable (W) */
#define=09com_iir=09=092=09/* interrupt identification (R) */
------
and used for all com-like devices. So you have to re-define this offsets=20
depending on exact com device context i.e. value 1 for com_ier used for I=
SA=20
bus and 4 for PCI bus.
One sollution is to re-define bus_space_read/write specially for/in com.c=
=20
which would fix register value depending on bus space tag and handle.
But 1) doing it just looking at "PCI or ISA" bus space type obviously wil=
l=20
break suitability of com.c for other PCI UART cards 2) you should to it f=
or=20
all <arch>/bus.h :)
For me seems like com.c isn't suitable for your device course of differen=
t=20
hardware registers mapping.
--=20
JSC Novosibirsk Geophysical Equipment Development Center.
WEB=09http://www.megasignal.com