First, sorry this is a bit long; I probably should have split it up, but
when I get going... Y'Know...
I've done some work on a driver for the SMBus functions of the AMD 756
chip found on K7-based motherboards, based on alpm.c from -CURRENT. This
works nicely on my system (Gigabyte GA7IXE-4 with Athlon 700MHz), but is
currently using old-style PCI shims. Since this is my first go at doing
anything in the FreeBSD kernel, I didn't realise that this was not a Good
Thing, so I've been trying to get it to work with Newbus; please see
below.
Anyway, for anyone who'd like to try the old-style compatability version,
please feel free to pull the diffs from:
http://www.3d-med.cse.dmu.ac.uk/~mcf/amdpm_oldpci.tar.gz
My newbus efforts are not going too well; specifically I'm having a hard
time with bus_alloc_resource, which refuses to allocate any I/O space for
me. I've tried all sorts of things, but it just won't work. If anyone can
spot anything idiotic I've done, please let me know; you may just save my
hair!
Here goes (BTW AMDPCI_PMBASE is a long which contains the base of I/O
space for the power management function of the AMD 756):
static int
amdpm_attach(device_t dev)
{
struct amdpm_softc *amdpm_sc = device_get_softc(dev);
u_long l;
int unit = device_get_unit(dev);
if (unit >= NAMDPM) {
printf("amdpm%d: attach: only %d units configured.\n",
unit, NAMDPM);
return (0);
}
amdpm_sc = &amdpmsoftc[unit];
/* Enable I/O. We must always do this with the AMD 756 for it to
allow
* us access.
*/
l = pci_read_config(dev, AMDPCI_GEN_CONFIG_PM, 2);
pci_write_config(dev, AMDPCI_GEN_CONFIG_PM, l | AMDPCI_PMIOEN, 2);
amdpm_sc->rid = AMDPCI_PMBASE;
amdpm_sc->pio = bus_alloc_resource(dev, SYS_RES_IOPORT,
&amdpm_sc->rid,
0, ~0, 1, RF_ACTIVE);
if (!(amdpm_sc->pio)) {
device_printf(dev, "could not map i/o ports\n");
return (ENXIO);
}
amdpm_sc->smbst = rman_get_bustag(amdpm_sc->pio);
amdpm_sc->smbsh = rman_get_bushandle(amdpm_sc->pio);
/* XXX add the I2C interface to the root_bus until pcibus is ready
*/
device_add_child(root_bus, "amdsmb", unit);
return (0);
}
---
Matt
-
Dr. Matthew C. Forman
3D & Medical Imaging Group,
De Montfort University, Leicester, UK.
To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-hackers" in the body of the message