Subject: Re: Drivers that access other devices (clcs(4), SMBus, and kern/12843)
To: Jared D. McNeill <jmcneill@invisible.ca>
From: Manuel Bouyer <bouyer@antioche.eu.org>
List: tech-kern
Date: 09/08/2003 23:49:45
On Sun, Sep 07, 2003 at 08:27:12PM -0300, Jared D. McNeill wrote:
> Hey folks --
> 
> The resolution to kern/12843 requires that clcs(4) enable/disable CLKRUN# at 
> certain points during its operation. Unfortunately, without documentation on 
> the CS4280 (and nothing in cs4280reg.h or cs428xreg.h that appears to do what 
> I need), the only way I can toggle CLKRUN# is through the SMBus.
> 
> The patch for kern/12843 does a pci_find_device looking for the PIIX4 SMBus 
> controller, querys the power management base address from it, then accesses 
> the PM controller to toggle CLKRUN#.
> 
> I realize that this isn't a very clean approach, so I ask: is there a better 
> way to accomplish this? Or should I just commit the fix and document the 
> hack?

pciide.c already does access to other's devices registers.
For example, the cypress has a helper "driver" to serialise access to his
special registers (which can be accedded by pciide or the alpha sio)
Other pciide drivers call pci_find_device(), but only to get ID/REV of other
functions of the bridge.

As long as nothing else access the PIIX4 SMBus, it is safe to do it the
way you propose. If something else wants to talk to it, we'll probably
need a helper driver to avoid conflicts between accesses.

-- 
Manuel Bouyer <bouyer@antioche.eu.org>
     NetBSD: 24 ans d'experience feront toujours la difference
--