Subject: Sharing MII and I2C code in ethernet drivers
To: None <tech-kern@NetBSD.ORG>
From: Manuel BOUYER <bouyer@antioche.lip6.fr>
List: tech-kern
Date: 09/18/1997 16:01:24
Hi,
So I've started a driver for the integrated network adapter found on
the Compaq professional systems. This adapter is build with 3 components:
 - A thunderland controller chip, which makes the interface between the
   PCI bus and the 2 other components (handle DMA, interrupts, ...)
 - a serial eeprom chip (microchip 24c01A), connected to the thunderland via
   an  I2C compatible bus
 - An ethernet physical controller (NS DP83840A) connected to the
   thunderland via an MII bus.

These 3 elements have a standart interface, so they may be present in other
board as well. The DP83840A is present in some (all ?) dec tulip based
ethernet board. So I think it is worth definning an software interface
for the MII and I2C busses, and writing "controller independant" drivers
for the DP83840A and 24c01A.

For the EEPROM, the driver need to export 2 functions: read a byte at an
adress, and write a bit at an adress. The controller chip driver need to
export the functions for controlling and reading the bus lines (set/clear/read
for 3 control lines, so 9 functions). The protocol for reading and writing
a byte may change from an EEPROM to antother.
The driver for the microchip 24c01A could stand in a new sys/dev/i2c directory.

For the DP83840A, the functionalities provided by the controller chip driver
need to be the same (this is also a serial line). A generic MII interface
would allow reading/writing registers, using the controller's driver functions.
Then a MII chip specific driver would provide common services, mostly about
medias: available_medias, select_media, autoselect_media, ...
These drivers would be in sys/dev/mii.
MII could be handled as other bus are, by creating an miibus in autoconfig,
and then having something like:
de* at pci? dev? function ?
miibus* at de?
tl* at pci? dev? function ?
miibus* at tl?
DP83840A* at miibus?
[ possibly others MII drivers ]
This would finer grain tuning when we'll have several mii drivers.
The problem here is that we can't easily say that a MII driver can attach to a
controller but not to another (the internal MII device of the thunderland will
never attach to a de). So I'd prefer:
de* at pci? dev? function ?
DP83840A* at de?
[ possibly others MII drivers ]
tl* at pci? dev? function ?
miitl* at tl?
DP83840A* at tl?

Any ideas about all this ?

--
Manuel Bouyer, LIP6, Universite Paris VI.           Manuel.Bouyer@lip6.fr
--