newbus questions

M. Warner Losh imp at bsdimp.com
Fri Mar 17 05:06:42 UTC 2006


In message: <1142506792.36931.25.camel at timon>
            "Artem 'ZaZooBred' Ignatiev" <zazubrik at mail.ru> writes:
: As far as I understand, all such cards have the same architecture: there
: is bridge chip (Philips SAA7146) which interfaces with PC (using PCI)
: and tuner on the card (using I2C), so in terms of newbus Properly
: Written (tm) driver must be split in two parts: driver for the SAA7146
: itself (which will be a ``bus-device'') and drivers for specific tuners
: (which will act as a child device on a SAA7146 "bus").
: 
: I had read arch-handbook and googled, but couldn't find an answer to
: some questions:
: 
: 1. How to create the bus itself, and properly describe its interfaces?
: skeletons of bus-driver and frontend-drivers would be a GREAT help.

Creating the bus is easy. The driver just adds the 'bus' device.  The
'bus' device enumerates the children and adds them.  Creating the bus
interface can require creating a a foo_if.m interface.  You'd wind up
with a tree that looks like:

	pci0 -- your-card-driver0 -- your-bus0 -- child0
						+ child1
						+ child2
						+ child3
						+ child4

: 2. SAA7146 uses I2C to communicate with tuners, and I know that there
: are some I2C-related peaces already in kernel. I would like to reuse
: that code, if possible, but can't figure out where to look and how to
: link it in. 

FreeBSD has a iicbus infrastructure, but I've never used it.

: 3. Card vendors use different PCI_SUBDEVICE on SAA7146 to indicate which
: tuner is (possibly) used. So, I suppose that "bus"-driver shall provide
: some way to tuner-driver to get this information. How that can be done?

It depends on where you want to put knowledge.  If you don't mind the
your-bus0 driver knowing, it can ask its parent what the subdevice ID
is and then use that to populate the children.

: 4. I would like to have driver, acting like "sound" -- loading one
: driver loads as dependencies all present sub-drivers for tuners, so
: after "bus"-driver identifies card it could try to probe sub-drivers for
: tuner searching for one to match. How is that done? (I suppose it can be
: something like no-op driver, that MODULE_DEPEND(9)s on modules it knows
: about)? 

This is much more complicated.  I'd wait until I got the basic driver
working before trying to tackle this.  I said this because during
driver development, you may change your mind on the interrelationships
between the different parts of your drivers.  It is easy to retrofit
functionality like this in later.

Warner


More information about the freebsd-hackers mailing list