Subject: Making the zs driver trully MI
To: None <tech-kern@netbsd.org>
From: Steve Woodford <steve@mctavish.co.uk>
List: tech-kern
Date: 09/16/2000 13:48:47
  This message is in MIME format.  The first part should be readable text,
  while the remaining parts are likely unreadable without MIME-aware tools.
  Send mail to mime@docserver.cac.washington.edu for more info.

--0-477159123-969108527=:16423
Content-Type: TEXT/PLAIN; charset=US-ASCII

Hi folks,

The current driver for the Zilog 8530 serial chip and its derivatives is
only partially machine independent, despite most of its guts being in
/sys/dev/ic/z8530*.

The problem is that it can only have one type of "parent" zsc device,
namely the native parent for each NetBSD platform which uses it. That
interface is currently defined in <machine/z8530var.h> and is very
specific to how the zs chip is wired up on each platform's hardware.

So, along comes a VMEbus board with a bunch of Z8530 chips whose registers
are directly mapped onto the bus. With the current state of the zs driver,
there's no way I can write MI VMEbus glue to make it work. Not to mention
the ports which can have a VMEbus attached, but don't have
<machine/z8530var.h> ...

My plan is to put a __BROKEN_ZS_DRIVER_ATTACHMENT define in the
<machine/types.h> file of each port which currently has a
<machine/z8530var.h>, and modify the zs driver to conditionally present
the original not-quite-MI attachment interface or a new proper-MI
interface depending on this #define. (Note: alpha and sgimips have a
<machine/z8530var.h> header file, but don't seem to use the driver!)

None of the original functionality will be lost with the new interface.
Specifically, there will be MI versions of zs_read_{reg,csr,data} and
zs_write_{reg,csr,data} which will insert the optional delay between
accesses. The only problem I could see with this was the mipsco port; it
seems to do a dummy read of another hardware register as well as a delay.
I'm not sure how to fix this one right now...

Other slightly oddball platforms are mac68k and macppc. These have CTS
wired up backwards and need to flip the status bit in the CSR to
compensate. I've added a flag to the MI code to take this into account.

I plan to make the mvme68k port use the new interface, leaving it up to
individual port-masters to update their code when they have time.

Since this driver seems to be used on at least 11 platforms, comments
would be appreciated before I break^W commit it. ;-)

The diffs for the stuff in sys/dev/ic/z8530* are attached since they're
not excessively big. The diffs for mvme68k's MD part are in:

	ftp://ftp.netbsd.org/pub/NetBSD/arch/mvme68k/md_zs_diffs

Cheers, Steve


--0-477159123-969108527=:16423
Content-Type: TEXT/PLAIN; charset=US-ASCII; name=mi_zs_diffs
Content-Transfer-Encoding: BASE64
Content-ID: <Pine.NEB.4.21.0009161348470.16423@oor-wullie.mctavish.co.uk>
Content-Description: 
Content-Disposition: attachment; filename=mi_zs_diffs

SW5kZXg6IHo4NTMwc2MuaA0KPT09PT09PT09PT09PT09PT09PT09PT09PT09
PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PQ0KUkNT
IGZpbGU6IC9jdnNyb290L3N5c3NyYy9zeXMvZGV2L2ljL3o4NTMwc2MuaCx2
DQpyZXRyaWV2aW5nIHJldmlzaW9uIDEuMTQNCmRpZmYgLWMgLXIxLjE0IHo4
NTMwc2MuaA0KKioqIHo4NTMwc2MuaAkyMDAwLzAzLzE5IDEyOjM5OjQ3CTEu
MTQNCi0tLSB6ODUzMHNjLmgJMjAwMC8wOS8xNiAxMjozNjozMA0KKioqKioq
KioqKioqKioqDQoqKiogNjgsNzcgKioqKg0KICAgKiBTb2Z0d2FyZSBzdGF0
ZSwgcGVyIHpzIGNoYW5uZWwuDQogICAqLw0KICBzdHJ1Y3QgenNfY2hhbnN0
YXRlIHsNCiEgDQogIAkvKiBQb2ludGVycyB0byB0aGUgZGV2aWNlIHJlZ2lz
dGVycy4gKi8NCiAgCXZvbGF0aWxlIHVfY2hhcgkqY3NfcmVnX2NzcjsgCS8q
IGN0cmwsIHN0YXR1cywgYW5kIHJlZy4gbnVtYmVyLiAqLw0KICAJdm9sYXRp
bGUgdV9jaGFyCSpjc19yZWdfZGF0YTsJLyogZGF0YSBvciBudW1iZXJlZCBy
ZWdpc3RlciAqLw0KICANCiAgCWludAljc19jaGFubmVsOwkJLyogc3ViLXVu
aXQgbnVtYmVyICovDQogIAl2b2lkICAgKmNzX3ByaXZhdGU7CQkvKiBzdWIt
ZHJpdmVyIGRhdGEgcG9pbnRlciAqLw0KLS0tIDY4LDg0IC0tLS0NCiAgICog
U29mdHdhcmUgc3RhdGUsI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