Date: Thu, 16 Mar 2006 14:10:26 +0100 From: Milan Obuch <hackers@dino.sk> To: freebsd-hackers@freebsd.org Subject: Re: newbus questions Message-ID: <200603161410.28225.hackers@dino.sk> In-Reply-To: <1142510785.36931.43.camel@timon> References: <1142506792.36931.25.camel@timon> <200603161235.24124.hackers@dino.sk> <1142510785.36931.43.camel@timon>
next in thread | previous in thread | raw e-mail | index | archive | help
On Thursday 16 March 2006 13:06, Artem 'ZaZooBred' Ignatiev wrote: ... > > > 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. > > > > There is some basis for i2c, look in /usr/src/sys/dev/iicbus directory. > > There are two kinds of i2c controllers - bit banged and full hardware > > controlled. The former is easily usable, you need just set and query > > methods implementation (look into iicbb_if.m), even if this has not the > > full i2c potential, the latter is (at least for me) somewhat hard to > > understand. I tried to implement such driver with Geode's Access.BUS > > controller, but so far no luck. And no description, google does not help > > me either. > > If SAA7146 uses bit banging interface or can be forced into such mode, > > you can do it in small amount of time. > > I had looked at both iicbb_if.m and iicbus_if.m. > SAA has internal logic to handle IIC, so iicbb was of no interest to me. > As to iicbus_if.m, it way closer to what I want. i2c subsystem in FreeBSD is somewhat SMBus oriented. Look at iicsmb, smbus and smb manpages. iicbus class implements just basic primitives. > It looks like linux is one layer of abstraction higher, so they have > "send N i2c messages" kind of functions, and in case of these cards, > logic is like that: > get array of messages, pack them into dwords, transfer that dwords using > DMA to card, read that dwords back and decode them into response. All > START/STOP conditions are handled by SAA chip itself, and I hoped that > there was something similar in other drivers, so there's no need to > reinvent the wheel for me. There is substantial difference - FreeBSD is modularised, linux (and NetBSD and OpenBSD as well, if I looked there at rught places) somehow makes i2c drivers monolithic, with code duplicated over all drivers. FreeBSD lacks this 'top-level' i2c-exec function. > > > 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? > > > > This is not that easy to understand at first, but bus 'ivars' are > > intended for this purpose. man device_get_ivars would be first step as it > > was for me to understand this. > > Yeah, that told me to look into BUS_READ_IVAR(9), and it looks like > something I can use, so now my question is reformed to ``how can I from > child driver get the bus device_t''. > Look into bus_if.m - child devices are added using device_add_child. And there is device_get_parent... Oh, and maybe pcf device is similar to SAA7146 and may give you an idea on i2c driver implementation... Regards, Milan -- Please reply only to mailing list. This address is filtered.
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200603161410.28225.hackers>