diff options
author | dfr <dfr@FreeBSD.org> | 2003-09-06 13:56:56 +0000 |
---|---|---|
committer | dfr <dfr@FreeBSD.org> | 2003-09-06 13:56:56 +0000 |
commit | e317aacd0ed29ae47b81929a05f12b1126fb610e (patch) | |
tree | 6510b4bf2b8369759b62789cca25090777e5737b | |
parent | 9d0084b76a807178be69cb153d0f5d8dd31e6c2f (diff) | |
download | FreeBSD-src-e317aacd0ed29ae47b81929a05f12b1126fb610e.zip FreeBSD-src-e317aacd0ed29ae47b81929a05f12b1126fb610e.tar.gz |
When recording resources for the amdpm driver, only describe the ports
we actually use. Originally, the code reserved 0x8000 to 0x80ff inclusive
which on my hardware conflicts with the acpi timer. This broke the amdpm
driver since it was actually given ports 0x800c to 0x810b (which should
not have happened, IMHO).
This also allows us to considerably simplify the handling of the nForce
smb driver, removing the need for a separate nfpm driver. With this, SMB
accesses appear to work on my Tyan Tiger MP board. Your mileage may vary.
In particular, the nForce changes have not been tested.
-rw-r--r-- | sys/pci/amdpm.c | 137 |
1 files changed, 36 insertions, 101 deletions
diff --git a/sys/pci/amdpm.c b/sys/pci/amdpm.c index c3868fe..d972a47 100644 --- a/sys/pci/amdpm.c +++ b/sys/pci/amdpm.c @@ -90,9 +90,7 @@ static int amdpm_debug = 0; * Base address programmed via AMDPCI_PMBASE. */ -static u_int32_t pm_reg_offset = 0xE0; - -#define AMDSMB_GLOBAL_STATUS (0x00 + pm_reg_offset) +#define AMDSMB_GLOBAL_STATUS (0x00) #define AMDSMB_GS_TO_STS (1<<5) #define AMDSMB_GS_HCYC_STS (1<<4) #define AMDSMB_GS_HST_STS (1<<3) @@ -101,7 +99,7 @@ static u_int32_t pm_reg_offset = 0xE0; #define AMDSMB_GS_ABRT_STS (1<<0) #define AMDSMB_GS_CLEAR_STS (AMDSMB_GS_TO_STS|AMDSMB_GS_HCYC_STS|AMDSMB_GS_PRERR_STS|AMDSMB_GS_COL_STS|AMDSMB_GS_ABRT_STS) -#define AMDSMB_GLOBAL_ENABLE (0x02 + pm_reg_offset) +#define AMDSMB_GLOBAL_ENABLE (0x02) #define AMDSMB_GE_ABORT (1<<5) #define AMDSMB_GE_HCYC_EN (1<<4) #define AMDSMB_GE_HOST_STC (1<<3) @@ -112,14 +110,14 @@ static u_int32_t pm_reg_offset = 0xE0; #define AMDSMB_GE_CYC_PROCCALL 4 #define AMDSMB_GE_CYC_BLOCK 5 -#define AMDSMB_HSTADDR (0x04 + pm_reg_offset) -#define AMDSMB_HSTDATA (0x06 + pm_reg_offset) -#define AMDSMB_HSTCMD (0x08 + pm_reg_offset) -#define AMDSMB_HSTDFIFO (0x09 + pm_reg_offset) -#define AMDSMB_HSLVDATA (0x0A + pm_reg_offset) -#define AMDSMB_HSLVDA (0x0C + pm_reg_offset) -#define AMDSMB_HSLVDDR (0x0E + pm_reg_offset) -#define AMDSMB_SNPADDR (0x0F + pm_reg_offset) +#define AMDSMB_HSTADDR (0x04) +#define AMDSMB_HSTDATA (0x06) +#define AMDSMB_HSTCMD (0x08) +#define AMDSMB_HSTDFIFO (0x09) +#define AMDSMB_HSLVDATA (0x0A) +#define AMDSMB_HSLVDA (0x0C) +#define AMDSMB_HSLVDDR (0x0E) +#define AMDSMB_SNPADDR (0x0F) struct amdpm_softc { int base; @@ -144,10 +142,12 @@ static int amdpm_probe(device_t dev) { u_long base; + u_int16_t vid; u_int16_t did; + vid = pci_get_vendor(dev); did = pci_get_device(dev); - if ((pci_get_vendor(dev) == AMDPM_VENDORID_AMD) && + if ((vid == AMDPM_VENDORID_AMD) && ((did == AMDPM_DEVICEID_AMD756PM) || (did == AMDPM_DEVICEID_AMD766PM) || (did == AMDPM_DEVICEID_AMD768PM))) { @@ -159,9 +159,27 @@ amdpm_probe(device_t dev) */ base = pci_read_config(dev, AMDPCI_PMBASE, 4); base &= 0xff00; - bus_set_resource(dev, SYS_RES_IOPORT, AMDPCI_PMBASE, base, 256); + bus_set_resource(dev, SYS_RES_IOPORT, AMDPCI_PMBASE, + base+0xe0, 32); return (0); } + + if ((vid == AMDPM_VENDORID_NVIDIA) && + (did == AMDPM_DEVICEID_NF_SMB)) { + device_set_desc(dev, "nForce SMBus Controller"); + + /* + * We have to do this, since the BIOS won't give us the + * resource info (not mine, anyway). + */ + base = pci_read_config(dev, NFPCI_PMBASE, 4); + base &= 0xff00; + bus_set_resource(dev, SYS_RES_IOPORT, NFPCI_PMBASE, + base, 32); + + return (0); + } + return ENXIO; } @@ -176,7 +194,10 @@ amdpm_attach(device_t dev) pci_write_config(dev, AMDPCI_GEN_CONFIG_PM, val_b | AMDPCI_PMIOEN, 1); /* Allocate I/O space */ - amdpm_sc->rid = AMDPCI_PMBASE; + if (pci_get_vendor(dev) == AMDPM_VENDORID_AMD) + amdpm_sc->rid = AMDPCI_PMBASE; + else + amdpm_sc->rid = NFPCI_PMBASE; amdpm_sc->res = bus_alloc_resource(dev, SYS_RES_IOPORT, &amdpm_sc->rid, 0, ~0, 1, RF_ACTIVE); if (amdpm_sc->res == NULL) { @@ -215,62 +236,6 @@ amdpm_detach(device_t dev) } static int -nfpm_probe(device_t dev) -{ - u_long base; - - if ((pci_get_vendor(dev) == AMDPM_VENDORID_NVIDIA) && - (pci_get_device(dev) == AMDPM_DEVICEID_NF_SMB)) { - device_set_desc(dev, "nForce SMBus Controller"); - - /* - * We have to do this, since the BIOS won't give us the - * resource info (not mine, anyway). - */ - base = pci_read_config(dev, NFPCI_PMBASE, 4); - base &= 0xff00; - bus_set_resource(dev, SYS_RES_IOPORT, NFPCI_PMBASE, base, 256); - - pm_reg_offset = 0x00; - - return (0); - } - return ENXIO; -} - -static int -nfpm_attach(device_t dev) -{ - struct amdpm_softc *amdpm_sc = device_get_softc(dev); - u_char val_b; - - /* Enable I/O block access */ - val_b = pci_read_config(dev, AMDPCI_GEN_CONFIG_PM, 1); - pci_write_config(dev, AMDPCI_GEN_CONFIG_PM, val_b | AMDPCI_PMIOEN, 1); - - /* Allocate I/O space */ - amdpm_sc->rid = NFPCI_PMBASE; - amdpm_sc->res = bus_alloc_resource(dev, SYS_RES_IOPORT, &amdpm_sc->rid, 0, ~0, 1, RF_ACTIVE); - - if (amdpm_sc->res == NULL) { - device_printf(dev, "could not map i/o space\n"); - return (ENXIO); - } - - amdpm_sc->smbst = rman_get_bustag(amdpm_sc->res); - amdpm_sc->smbsh = rman_get_bushandle(amdpm_sc->res); - - /* Allocate a new smbus device */ - amdpm_sc->smbus = device_add_child(dev, "smbus", -1); - if (!amdpm_sc->smbus) - return (EINVAL); - - bus_generic_attach(dev); - - return (0); -} - -static int amdpm_callback(device_t dev, int index, caddr_t *data) { int error = 0; @@ -650,37 +615,7 @@ static driver_t amdpm_driver = { sizeof(struct amdpm_softc), }; -static devclass_t nfpm_devclass; - -static device_method_t nfpm_methods[] = { - /* Device interface */ - DEVMETHOD(device_probe, nfpm_probe), - DEVMETHOD(device_attach, nfpm_attach), - DEVMETHOD(device_detach, amdpm_detach), - - /* SMBus interface */ - DEVMETHOD(smbus_callback, amdpm_callback), - DEVMETHOD(smbus_quick, amdpm_quick), - DEVMETHOD(smbus_sendb, amdpm_sendb), - DEVMETHOD(smbus_recvb, amdpm_recvb), - DEVMETHOD(smbus_writeb, amdpm_writeb), - DEVMETHOD(smbus_readb, amdpm_readb), - DEVMETHOD(smbus_writew, amdpm_writew), - DEVMETHOD(smbus_readw, amdpm_readw), - DEVMETHOD(smbus_bwrite, amdpm_bwrite), - DEVMETHOD(smbus_bread, amdpm_bread), - - { 0, 0 } -}; - -static driver_t nfpm_driver = { - "nfpm", - nfpm_methods, - sizeof(struct amdpm_softc), -}; - DRIVER_MODULE(amdpm, pci, amdpm_driver, amdpm_devclass, 0, 0); -DRIVER_MODULE(nfpm, pci, nfpm_driver, nfpm_devclass, 0, 0); MODULE_DEPEND(amdpm, pci, 1, 1, 1); MODULE_DEPEND(amdpm, smbus, SMBUS_MINVER, SMBUS_PREFVER, SMBUS_MAXVER); |