diff options
author | nsouch <nsouch@FreeBSD.org> | 2002-09-21 21:43:49 +0000 |
---|---|---|
committer | nsouch <nsouch@FreeBSD.org> | 2002-09-21 21:43:49 +0000 |
commit | b57c1147d22981983ef63f8b1324742d4664408c (patch) | |
tree | 76984e1b4af600a91a5383cc0ad2c37e60b0d5b7 /sys | |
parent | 7d834f54d05040e389b2b233f50099ba6de76210 (diff) | |
download | FreeBSD-src-b57c1147d22981983ef63f8b1324742d4664408c.zip FreeBSD-src-b57c1147d22981983ef63f8b1324742d4664408c.tar.gz |
Cleanup of amdpm(4).
Add of NVIDIA nForce (nfpm) smbus support.
Obtained from: Thomas D. Dean <tomdean@speakeasy.org>
Diffstat (limited to 'sys')
-rw-r--r-- | sys/conf/NOTES | 3 | ||||
-rw-r--r-- | sys/conf/files | 1 | ||||
-rw-r--r-- | sys/dev/smbus/smbus.c | 1 | ||||
-rw-r--r-- | sys/pci/amdpm.c | 315 |
4 files changed, 183 insertions, 137 deletions
diff --git a/sys/conf/NOTES b/sys/conf/NOTES index 85b2343..a0ccf86 100644 --- a/sys/conf/NOTES +++ b/sys/conf/NOTES @@ -1965,6 +1965,7 @@ device card 1 # ichsmb Intel ICH SMBus controller chips (82801AA, 82801AB, 82801BA) # viapm VIA VT82C586B/596B/686A and VT8233 Power Management Unit # amdpm AMD 756 Power Management Unit +# nfpm NVIDIA nForce Power Management Unit # device smbus # Bus support, required for smb below. @@ -1972,6 +1973,8 @@ device intpm device alpm device ichsmb device viapm +device amdpm +device nfpm device smb diff --git a/sys/conf/files b/sys/conf/files index faee80d..b0942e9 100644 --- a/sys/conf/files +++ b/sys/conf/files @@ -1353,6 +1353,7 @@ pci/agp_i810.c optional agp pci/alpm.c optional alpm pci/amd.c optional amd pci/amdpm.c optional amdpm +pci/amdpm.c optional nfpm pci/if_dc.c optional dc pci/if_de.c optional de pci/if_en_pci.c optional en pci diff --git a/sys/dev/smbus/smbus.c b/sys/dev/smbus/smbus.c index 99b7ca3..c55399d 100644 --- a/sys/dev/smbus/smbus.c +++ b/sys/dev/smbus/smbus.c @@ -114,4 +114,5 @@ DRIVER_MODULE(smbus, alpm, smbus_driver, smbus_devclass, 0, 0); DRIVER_MODULE(smbus, ichsmb, smbus_driver, smbus_devclass, 0, 0); DRIVER_MODULE(smbus, amdpm, smbus_driver, smbus_devclass, 0, 0); DRIVER_MODULE(smbus, viapropm, smbus_driver, smbus_devclass, 0, 0); +DRIVER_MODULE(smbus, nfpm, smbus_driver, smbus_devclass, 0, 0); MODULE_VERSION(smbus, SMBUS_MODVER); diff --git a/sys/pci/amdpm.c b/sys/pci/amdpm.c index 9664ce2..c04b57a 100644 --- a/sys/pci/amdpm.c +++ b/sys/pci/amdpm.c @@ -67,8 +67,13 @@ static int amdpm_debug = 0; #define AMDPM_VENDORID_AMD 0x1022 #define AMDPM_DEVICEID_AMD756PM 0x740b +/* nVidia nForce chipset */ +#define AMDPM_VENDORID_NVIDIA 0x10de +#define AMDPM_DEVICEID_NF_SMB 0x01b4 + /* PCI Configuration space registers */ #define AMDPCI_PMBASE 0x58 +#define NFPCI_PMBASE 0x14 #define AMDPCI_GEN_CONFIG_PM 0x41 #define AMDPCI_PMIOEN (1<<7) @@ -82,7 +87,10 @@ static int amdpm_debug = 0; * I/O registers. * Base address programmed via AMDPCI_PMBASE. */ -#define AMDSMB_GLOBAL_STATUS 0xE0 + +static u_int32_t pm_reg_offset = 0xE0; + +#define AMDSMB_GLOBAL_STATUS (0x00 + pm_reg_offset) #define AMDSMB_GS_TO_STS (1<<5) #define AMDSMB_GS_HCYC_STS (1<<4) #define AMDSMB_GS_HST_STS (1<<3) @@ -91,7 +99,7 @@ static int amdpm_debug = 0; #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 0xE2 +#define AMDSMB_GLOBAL_ENABLE (0x02 + pm_reg_offset) #define AMDSMB_GE_ABORT (1<<5) #define AMDSMB_GE_HCYC_EN (1<<4) #define AMDSMB_GE_HOST_STC (1<<3) @@ -102,54 +110,33 @@ static int amdpm_debug = 0; #define AMDSMB_GE_CYC_PROCCALL 4 #define AMDSMB_GE_CYC_BLOCK 5 -#define AMDSMB_HSTADDR 0xE4 -#define AMDSMB_HSTDATA 0xE6 -#define AMDSMB_HSTCMD 0xE8 -#define AMDSMB_HSTDFIFO 0xE9 -#define AMDSMB_HSLVDATA 0xEA -#define AMDSMB_HSLVDA 0xEC -#define AMDSMB_HSLVDDR 0xEE -#define AMDSMB_SNPADDR 0xEF +#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) struct amdpm_softc { int base; int rid; struct resource *res; - bus_space_tag_t smbst; - bus_space_handle_t smbsh; -}; + bus_space_tag_t smbst; + bus_space_handle_t smbsh; -struct amdsmb_softc { - int base; device_t smbus; - struct amdpm_softc *amdpm; }; -#define AMDPM_SMBINB(amdsmb,register) \ - (bus_space_read_1(amdsmb->amdpm->smbst, amdsmb->amdpm->smbsh, register)) -#define AMDPM_SMBOUTB(amdsmb,register,value) \ - (bus_space_write_1(amdsmb->amdpm->smbst, amdsmb->amdpm->smbsh, register, value)) -#define AMDPM_SMBINW(amdsmb,register) \ - (bus_space_read_2(amdsmb->amdpm->smbst, amdsmb->amdpm->smbsh, register)) -#define AMDPM_SMBOUTW(amdsmb,register,value) \ - (bus_space_write_2(amdsmb->amdpm->smbst, amdsmb->amdpm->smbsh, register, value)) - -static int amdsmb_probe(device_t); -static int amdsmb_attach(device_t); -static int amdsmb_smb_callback(device_t, int, caddr_t *); -static int amdsmb_smb_quick(device_t dev, u_char slave, int how); -static int amdsmb_smb_sendb(device_t dev, u_char slave, char byte); -static int amdsmb_smb_recvb(device_t dev, u_char slave, char *byte); -static int amdsmb_smb_writeb(device_t dev, u_char slave, char cmd, char byte); -static int amdsmb_smb_readb(device_t dev, u_char slave, char cmd, char *byte); -static int amdsmb_smb_writew(device_t dev, u_char slave, char cmd, short word); -static int amdsmb_smb_readw(device_t dev, u_char slave, char cmd, short *word); -static int amdsmb_smb_bwrite(device_t dev, u_char slave, char cmd, u_char count, char *buf); -static int amdsmb_smb_bread(device_t dev, u_char slave, char cmd, u_char count, char *byte); - -static int amdpm_probe(device_t); -static int amdpm_attach(device_t); - +#define AMDPM_SMBINB(amdpm,register) \ + (bus_space_read_1(amdpm->smbst, amdpm->smbsh, register)) +#define AMDPM_SMBOUTB(amdpm,register,value) \ + (bus_space_write_1(amdpm->smbst, amdpm->smbsh, register, value)) +#define AMDPM_SMBINW(amdpm,register) \ + (bus_space_read_2(amdpm->smbst, amdpm->smbsh, register)) +#define AMDPM_SMBOUTW(amdpm,register,value) \ + (bus_space_write_2(amdpm->smbst, amdpm->smbsh, register, value)) static int amdpm_probe(device_t dev) @@ -177,8 +164,6 @@ amdpm_attach(device_t dev) { struct amdpm_softc *amdpm_sc = device_get_softc(dev); u_char val_b; - int unit = device_get_unit(dev); - device_t smbinterface; /* Enable I/O block access */ val_b = pci_read_config(dev, AMDPCI_GEN_CONFIG_PM, 1); @@ -195,49 +180,92 @@ amdpm_attach(device_t dev) amdpm_sc->smbst = rman_get_bustag(amdpm_sc->res); amdpm_sc->smbsh = rman_get_bushandle(amdpm_sc->res); - - smbinterface = device_add_child(dev, "amdsmb", unit); - if (!smbinterface) - device_printf(dev, "could not add SMBus device\n"); - else - device_probe_and_attach(smbinterface); + + /* 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 -amdsmb_probe(device_t dev) +amdpm_detach(device_t dev) { - struct amdsmb_softc *amdsmb_sc = (struct amdsmb_softc *)device_get_softc(dev); - - device_set_desc(dev, "AMD 756 SMBus interface"); - device_printf(dev, "AMD 756 SMBus interface\n"); + struct amdpm_softc *amdpm_sc = device_get_softc(dev); - /* Allocate a new smbus device */ - amdsmb_sc->smbus = device_add_child(dev, "smbus", -1); - if (!amdsmb_sc->smbus) - return (EINVAL); + if (amdpm_sc->smbus) { + device_delete_child(dev, amdpm_sc->smbus); + amdpm_sc->smbus = NULL; + } - bus_generic_attach(dev); + if (amdpm_sc->res) + bus_release_resource(dev, SYS_RES_IOPORT, amdpm_sc->rid, + amdpm_sc->res); return (0); } static int -amdsmb_attach(device_t dev) +nfpm_probe(device_t dev) { - struct amdsmb_softc *amdsmb_sc = (struct amdsmb_softc *)device_get_softc(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; +} - amdsmb_sc->amdpm = device_get_softc(device_get_parent(dev)); +static int +nfpm_attach(device_t dev) +{ + struct amdpm_softc *amdpm_sc = device_get_softc(dev); + u_char val_b; - /* Probe and attach the smbus */ - device_probe_and_attach(amdsmb_sc->smbus); + /* 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 -amdsmb_smb_callback(device_t dev, int index, caddr_t *data) +amdpm_callback(device_t dev, int index, caddr_t *data) { int error = 0; @@ -253,7 +281,7 @@ amdsmb_smb_callback(device_t dev, int index, caddr_t *data) } static int -amdsmb_clear(struct amdsmb_softc *sc) +amdpm_clear(struct amdpm_softc *sc) { AMDPM_SMBOUTW(sc, AMDSMB_GLOBAL_STATUS, AMDSMB_GS_CLEAR_STS); DELAY(10); @@ -263,7 +291,7 @@ amdsmb_clear(struct amdsmb_softc *sc) #if 0 static int -amdsmb_abort(struct amdsmb_softc *sc) +amdpm_abort(struct amdpm_softc *sc) { u_short l; @@ -275,7 +303,7 @@ amdsmb_abort(struct amdsmb_softc *sc) #endif static int -amdsmb_idle(struct amdsmb_softc *sc) +amdpm_idle(struct amdpm_softc *sc) { u_short sts; @@ -290,7 +318,7 @@ amdsmb_idle(struct amdsmb_softc *sc) * Poll the SMBus controller */ static int -amdsmb_wait(struct amdsmb_softc *sc) +amdpm_wait(struct amdpm_softc *sc) { int count = 10000; u_short sts = 0; @@ -321,20 +349,20 @@ amdsmb_wait(struct amdsmb_softc *sc) error |= SMB_EBUSERR; if (error != SMB_ENOERR) - amdsmb_clear(sc); + amdpm_clear(sc); return (error); } static int -amdsmb_smb_quick(device_t dev, u_char slave, int how) +amdpm_quick(device_t dev, u_char slave, int how) { - struct amdsmb_softc *sc = (struct amdsmb_softc *)device_get_softc(dev); + struct amdpm_softc *sc = (struct amdpm_softc *)device_get_softc(dev); int error; u_short l; - amdsmb_clear(sc); - if (!amdsmb_idle(sc)) + amdpm_clear(sc); + if (!amdpm_idle(sc)) return (EBUSY); switch (how) { @@ -352,7 +380,7 @@ amdsmb_smb_quick(device_t dev, u_char slave, int how) l = AMDPM_SMBINW(sc, AMDSMB_GLOBAL_ENABLE); AMDPM_SMBOUTW(sc, AMDSMB_GLOBAL_ENABLE, (l & 0xfff8) | AMDSMB_GE_CYC_QUICK | AMDSMB_GE_HOST_STC); - error = amdsmb_wait(sc); + error = amdpm_wait(sc); AMDPM_DEBUG(printf(", error=0x%x\n", error)); @@ -360,14 +388,14 @@ amdsmb_smb_quick(device_t dev, u_char slave, int how) } static int -amdsmb_smb_sendb(device_t dev, u_char slave, char byte) +amdpm_sendb(device_t dev, u_char slave, char byte) { - struct amdsmb_softc *sc = (struct amdsmb_softc *)device_get_softc(dev); + struct amdpm_softc *sc = (struct amdpm_softc *)device_get_softc(dev); int error; u_short l; - amdsmb_clear(sc); - if (!amdsmb_idle(sc)) + amdpm_clear(sc); + if (!amdpm_idle(sc)) return (SMB_EBUSY); AMDPM_SMBOUTW(sc, AMDSMB_HSTADDR, slave & ~LSB); @@ -375,7 +403,7 @@ amdsmb_smb_sendb(device_t dev, u_char slave, char byte) l = AMDPM_SMBINW(sc, AMDSMB_GLOBAL_ENABLE); AMDPM_SMBOUTW(sc, AMDSMB_GLOBAL_ENABLE, (l & 0xfff8) | AMDSMB_GE_CYC_BYTE | AMDSMB_GE_HOST_STC); - error = amdsmb_wait(sc); + error = amdpm_wait(sc); AMDPM_DEBUG(printf("amdpm: SENDB to 0x%x, byte=0x%x, error=0x%x\n", slave, byte, error)); @@ -383,21 +411,21 @@ amdsmb_smb_sendb(device_t dev, u_char slave, char byte) } static int -amdsmb_smb_recvb(device_t dev, u_char slave, char *byte) +amdpm_recvb(device_t dev, u_char slave, char *byte) { - struct amdsmb_softc *sc = (struct amdsmb_softc *)device_get_softc(dev); + struct amdpm_softc *sc = (struct amdpm_softc *)device_get_softc(dev); int error; u_short l; - amdsmb_clear(sc); - if (!amdsmb_idle(sc)) + amdpm_clear(sc); + if (!amdpm_idle(sc)) return (SMB_EBUSY); AMDPM_SMBOUTW(sc, AMDSMB_HSTADDR, slave | LSB); l = AMDPM_SMBINW(sc, AMDSMB_GLOBAL_ENABLE); AMDPM_SMBOUTW(sc, AMDSMB_GLOBAL_ENABLE, (l & 0xfff8) | AMDSMB_GE_CYC_BYTE | AMDSMB_GE_HOST_STC); - if ((error = amdsmb_wait(sc)) == SMB_ENOERR) + if ((error = amdpm_wait(sc)) == SMB_ENOERR) *byte = AMDPM_SMBINW(sc, AMDSMB_HSTDATA); AMDPM_DEBUG(printf("amdpm: RECVB from 0x%x, byte=0x%x, error=0x%x\n", slave, *byte, error)); @@ -406,14 +434,14 @@ amdsmb_smb_recvb(device_t dev, u_char slave, char *byte) } static int -amdsmb_smb_writeb(device_t dev, u_char slave, char cmd, char byte) +amdpm_writeb(device_t dev, u_char slave, char cmd, char byte) { - struct amdsmb_softc *sc = (struct amdsmb_softc *)device_get_softc(dev); + struct amdpm_softc *sc = (struct amdpm_softc *)device_get_softc(dev); int error; u_short l; - amdsmb_clear(sc); - if (!amdsmb_idle(sc)) + amdpm_clear(sc); + if (!amdpm_idle(sc)) return (SMB_EBUSY); AMDPM_SMBOUTW(sc, AMDSMB_HSTADDR, slave & ~LSB); @@ -422,7 +450,7 @@ amdsmb_smb_writeb(device_t dev, u_char slave, char cmd, char byte) l = AMDPM_SMBINW(sc, AMDSMB_GLOBAL_ENABLE); AMDPM_SMBOUTW(sc, AMDSMB_GLOBAL_ENABLE, (l & 0xfff8) | AMDSMB_GE_CYC_BDATA | AMDSMB_GE_HOST_STC); - error = amdsmb_wait(sc); + error = amdpm_wait(sc); AMDPM_DEBUG(printf("amdpm: WRITEB to 0x%x, cmd=0x%x, byte=0x%x, error=0x%x\n", slave, cmd, byte, error)); @@ -430,14 +458,14 @@ amdsmb_smb_writeb(device_t dev, u_char slave, char cmd, char byte) } static int -amdsmb_smb_readb(device_t dev, u_char slave, char cmd, char *byte) +amdpm_readb(device_t dev, u_char slave, char cmd, char *byte) { - struct amdsmb_softc *sc = (struct amdsmb_softc *)device_get_softc(dev); + struct amdpm_softc *sc = (struct amdpm_softc *)device_get_softc(dev); int error; u_short l; - amdsmb_clear(sc); - if (!amdsmb_idle(sc)) + amdpm_clear(sc); + if (!amdpm_idle(sc)) return (SMB_EBUSY); AMDPM_SMBOUTW(sc, AMDSMB_HSTADDR, slave | LSB); @@ -445,7 +473,7 @@ amdsmb_smb_readb(device_t dev, u_char slave, char cmd, char *byte) l = AMDPM_SMBINW(sc, AMDSMB_GLOBAL_ENABLE); AMDPM_SMBOUTW(sc, AMDSMB_GLOBAL_ENABLE, (l & 0xfff8) | AMDSMB_GE_CYC_BDATA | AMDSMB_GE_HOST_STC); - if ((error = amdsmb_wait(sc)) == SMB_ENOERR) + if ((error = amdpm_wait(sc)) == SMB_ENOERR) *byte = AMDPM_SMBINW(sc, AMDSMB_HSTDATA); AMDPM_DEBUG(printf("amdpm: READB from 0x%x, cmd=0x%x, byte=0x%x, error=0x%x\n", slave, cmd, *byte, error)); @@ -454,14 +482,14 @@ amdsmb_smb_readb(device_t dev, u_char slave, char cmd, char *byte) } static int -amdsmb_smb_writew(device_t dev, u_char slave, char cmd, short word) +amdpm_writew(device_t dev, u_char slave, char cmd, short word) { - struct amdsmb_softc *sc = (struct amdsmb_softc *)device_get_softc(dev); + struct amdpm_softc *sc = (struct amdpm_softc *)device_get_softc(dev); int error; u_short l; - amdsmb_clear(sc); - if (!amdsmb_idle(sc)) + amdpm_clear(sc); + if (!amdpm_idle(sc)) return (SMB_EBUSY); AMDPM_SMBOUTW(sc, AMDSMB_HSTADDR, slave & ~LSB); @@ -470,7 +498,7 @@ amdsmb_smb_writew(device_t dev, u_char slave, char cmd, short word) l = AMDPM_SMBINW(sc, AMDSMB_GLOBAL_ENABLE); AMDPM_SMBOUTW(sc, AMDSMB_GLOBAL_ENABLE, (l & 0xfff8) | AMDSMB_GE_CYC_WDATA | AMDSMB_GE_HOST_STC); - error = amdsmb_wait(sc); + error = amdpm_wait(sc); AMDPM_DEBUG(printf("amdpm: WRITEW to 0x%x, cmd=0x%x, word=0x%x, error=0x%x\n", slave, cmd, word, error)); @@ -478,14 +506,14 @@ amdsmb_smb_writew(device_t dev, u_char slave, char cmd, short word) } static int -amdsmb_smb_readw(device_t dev, u_char slave, char cmd, short *word) +amdpm_readw(device_t dev, u_char slave, char cmd, short *word) { - struct amdsmb_softc *sc = (struct amdsmb_softc *)device_get_softc(dev); + struct amdpm_softc *sc = (struct amdpm_softc *)device_get_softc(dev); int error; u_short l; - amdsmb_clear(sc); - if (!amdsmb_idle(sc)) + amdpm_clear(sc); + if (!amdpm_idle(sc)) return (SMB_EBUSY); AMDPM_SMBOUTW(sc, AMDSMB_HSTADDR, slave | LSB); @@ -493,7 +521,7 @@ amdsmb_smb_readw(device_t dev, u_char slave, char cmd, short *word) l = AMDPM_SMBINW(sc, AMDSMB_GLOBAL_ENABLE); AMDPM_SMBOUTW(sc, AMDSMB_GLOBAL_ENABLE, (l & 0xfff8) | AMDSMB_GE_CYC_WDATA | AMDSMB_GE_HOST_STC); - if ((error = amdsmb_wait(sc)) == SMB_ENOERR) + if ((error = amdpm_wait(sc)) == SMB_ENOERR) *word = AMDPM_SMBINW(sc, AMDSMB_HSTDATA); AMDPM_DEBUG(printf("amdpm: READW from 0x%x, cmd=0x%x, word=0x%x, error=0x%x\n", slave, cmd, *word, error)); @@ -502,15 +530,15 @@ amdsmb_smb_readw(device_t dev, u_char slave, char cmd, short *word) } static int -amdsmb_smb_bwrite(device_t dev, u_char slave, char cmd, u_char count, char *buf) +amdpm_bwrite(device_t dev, u_char slave, char cmd, u_char count, char *buf) { - struct amdsmb_softc *sc = (struct amdsmb_softc *)device_get_softc(dev); + struct amdpm_softc *sc = (struct amdpm_softc *)device_get_softc(dev); u_char remain, len, i; int error = SMB_ENOERR; u_short l; - amdsmb_clear(sc); - if(!amdsmb_idle(sc)) + amdpm_clear(sc); + if(!amdpm_idle(sc)) return (SMB_EBUSY); remain = count; @@ -535,7 +563,7 @@ amdsmb_smb_bwrite(device_t dev, u_char slave, char cmd, u_char count, char *buf) l = AMDPM_SMBINW(sc, AMDSMB_GLOBAL_ENABLE); AMDPM_SMBOUTW(sc, AMDSMB_GLOBAL_ENABLE, (l & 0xfff8) | AMDSMB_GE_CYC_BLOCK | AMDSMB_GE_HOST_STC); - if ((error = amdsmb_wait(sc)) != SMB_ENOERR) + if ((error = amdpm_wait(sc)) != SMB_ENOERR) goto error; remain -= len; @@ -548,15 +576,15 @@ error: } static int -amdsmb_smb_bread(device_t dev, u_char slave, char cmd, u_char count, char *buf) +amdpm_bread(device_t dev, u_char slave, char cmd, u_char count, char *buf) { - struct amdsmb_softc *sc = (struct amdsmb_softc *)device_get_softc(dev); + struct amdpm_softc *sc = (struct amdpm_softc *)device_get_softc(dev); u_char remain, len, i; int error = SMB_ENOERR; u_short l; - amdsmb_clear(sc); - if (!amdsmb_idle(sc)) + amdpm_clear(sc); + if (!amdpm_idle(sc)) return (SMB_EBUSY); remain = count; @@ -568,7 +596,7 @@ amdsmb_smb_bread(device_t dev, u_char slave, char cmd, u_char count, char *buf) l = AMDPM_SMBINW(sc, AMDSMB_GLOBAL_ENABLE); AMDPM_SMBOUTW(sc, AMDSMB_GLOBAL_ENABLE, (l & 0xfff8) | AMDSMB_GE_CYC_BLOCK | AMDSMB_GE_HOST_STC); - if ((error = amdsmb_wait(sc)) != SMB_ENOERR) + if ((error = amdpm_wait(sc)) != SMB_ENOERR) goto error; len = AMDPM_SMBINW(sc, AMDSMB_HSTDATA); @@ -593,6 +621,19 @@ static device_method_t amdpm_methods[] = { /* Device interface */ DEVMETHOD(device_probe, amdpm_probe), DEVMETHOD(device_attach, amdpm_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 } }; @@ -603,38 +644,38 @@ static driver_t amdpm_driver = { sizeof(struct amdpm_softc), }; -static devclass_t amdsmb_devclass; +static devclass_t nfpm_devclass; -static device_method_t amdsmb_methods[] = { +static device_method_t nfpm_methods[] = { /* Device interface */ - DEVMETHOD(device_probe, amdsmb_probe), - DEVMETHOD(device_attach, amdsmb_attach), - - /* Bus interface */ - DEVMETHOD(bus_print_child, bus_generic_print_child), + DEVMETHOD(device_probe, nfpm_probe), + DEVMETHOD(device_attach, nfpm_attach), + DEVMETHOD(device_detach, amdpm_detach), /* SMBus interface */ - DEVMETHOD(smbus_callback, amdsmb_smb_callback), - DEVMETHOD(smbus_quick, amdsmb_smb_quick), - DEVMETHOD(smbus_sendb, amdsmb_smb_sendb), - DEVMETHOD(smbus_recvb, amdsmb_smb_recvb), - DEVMETHOD(smbus_writeb, amdsmb_smb_writeb), - DEVMETHOD(smbus_readb, amdsmb_smb_readb), - DEVMETHOD(smbus_writew, amdsmb_smb_writew), - DEVMETHOD(smbus_readw, amdsmb_smb_readw), - DEVMETHOD(smbus_bwrite, amdsmb_smb_bwrite), - DEVMETHOD(smbus_bread, amdsmb_smb_bread), + 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 amdsmb_driver = { - "amdsmb", - amdsmb_methods, - sizeof(struct amdsmb_softc), +static driver_t nfpm_driver = { + "nfpm", + nfpm_methods, + sizeof(struct amdpm_softc), }; DRIVER_MODULE(amdpm, pci, amdpm_driver, amdpm_devclass, 0, 0); -DRIVER_MODULE(amdsmb, amdpm, amdsmb_driver, amdsmb_devclass, 0, 0); +DRIVER_MODULE(nfpm, pci, nfpm_driver, nfpm_devclass, 0, 0); + MODULE_DEPEND(amdpm, smbus, SMBUS_MINVER, SMBUS_PREFVER, SMBUS_MAXVER); MODULE_VERSION(amdpm, 1); + |