Lines Matching +full:slave +full:- +full:dev
1 /*-
39 #include <dev/pci/pcivar.h>
40 #include <dev/pci/pcireg.h>
42 #include <dev/smbus/smbconf.h>
100 #define SMB_STS_PEC 0x1F /* PEC (CRC-8) Error */
121 #define NFSMB_LOCK(nfsmb) mtx_lock(&(nfsmb)->lock)
122 #define NFSMB_UNLOCK(nfsmb) mtx_unlock(&(nfsmb)->lock)
123 #define NFSMB_LOCK_ASSERT(nfsmb) mtx_assert(&(nfsmb)->lock, MA_OWNED)
126 (bus_read_1(nfsmb->res, register))
128 (bus_write_1(nfsmb->res, register, value))
130 static int nfsmb_detach(device_t dev);
131 static int nfsmbsub_detach(device_t dev);
134 nfsmbsub_probe(device_t dev) in nfsmbsub_probe() argument
137 device_set_desc(dev, "nForce2/3/4 MCP SMBus Controller"); in nfsmbsub_probe()
142 nfsmb_probe(device_t dev) in nfsmb_probe() argument
147 vid = pci_get_vendor(dev); in nfsmb_probe()
148 did = pci_get_device(dev); in nfsmb_probe()
166 device_set_desc(dev, "nForce2/3/4 MCP SMBus Controller"); in nfsmb_probe()
175 nfsmbsub_attach(device_t dev) in nfsmbsub_attach() argument
178 struct nfsmb_softc *nfsmbsub_sc = device_get_softc(dev); in nfsmbsub_attach()
180 parent = device_get_parent(dev); in nfsmbsub_attach()
182 nfsmbsub_sc->rid = NF2PCI_SMBASE_2; in nfsmbsub_attach()
184 nfsmbsub_sc->res = bus_alloc_resource_any(parent, SYS_RES_IOPORT, in nfsmbsub_attach()
185 &nfsmbsub_sc->rid, RF_ACTIVE); in nfsmbsub_attach()
186 if (nfsmbsub_sc->res == NULL) { in nfsmbsub_attach()
187 /* Older incarnations of the device used non-standard BARs. */ in nfsmbsub_attach()
188 nfsmbsub_sc->rid = 0x54; in nfsmbsub_attach()
189 nfsmbsub_sc->res = bus_alloc_resource_any(parent, in nfsmbsub_attach()
190 SYS_RES_IOPORT, &nfsmbsub_sc->rid, RF_ACTIVE); in nfsmbsub_attach()
191 if (nfsmbsub_sc->res == NULL) { in nfsmbsub_attach()
192 device_printf(dev, "could not map i/o space\n"); in nfsmbsub_attach()
196 mtx_init(&nfsmbsub_sc->lock, device_get_nameunit(dev), "nfsmb", in nfsmbsub_attach()
199 nfsmbsub_sc->smbus = device_add_child(dev, "smbus", DEVICE_UNIT_ANY); in nfsmbsub_attach()
200 if (nfsmbsub_sc->smbus == NULL) { in nfsmbsub_attach()
201 nfsmbsub_detach(dev); in nfsmbsub_attach()
205 bus_attach_children(dev); in nfsmbsub_attach()
211 nfsmb_attach(device_t dev) in nfsmb_attach() argument
213 struct nfsmb_softc *nfsmb_sc = device_get_softc(dev); in nfsmb_attach()
216 nfsmb_sc->rid = NF2PCI_SMBASE_1; in nfsmb_attach()
218 nfsmb_sc->res = bus_alloc_resource_any(dev, SYS_RES_IOPORT, in nfsmb_attach()
219 &nfsmb_sc->rid, RF_ACTIVE); in nfsmb_attach()
221 if (nfsmb_sc->res == NULL) { in nfsmb_attach()
222 /* Older incarnations of the device used non-standard BARs. */ in nfsmb_attach()
223 nfsmb_sc->rid = 0x50; in nfsmb_attach()
224 nfsmb_sc->res = bus_alloc_resource_any(dev, in nfsmb_attach()
225 SYS_RES_IOPORT, &nfsmb_sc->rid, RF_ACTIVE); in nfsmb_attach()
226 if (nfsmb_sc->res == NULL) { in nfsmb_attach()
227 device_printf(dev, "could not map i/o space\n"); in nfsmb_attach()
232 mtx_init(&nfsmb_sc->lock, device_get_nameunit(dev), "nfsmb", MTX_DEF); in nfsmb_attach()
235 nfsmb_sc->smbus = device_add_child(dev, "smbus", DEVICE_UNIT_ANY); in nfsmb_attach()
236 if (!nfsmb_sc->smbus) { in nfsmb_attach()
237 nfsmb_detach(dev); in nfsmb_attach()
241 nfsmb_sc->subdev = NULL; in nfsmb_attach()
242 switch (pci_get_device(dev)) { in nfsmb_attach()
257 /* Trying to add secondary device as slave */ in nfsmb_attach()
258 nfsmb_sc->subdev = device_add_child(dev, "nfsmb", DEVICE_UNIT_ANY); in nfsmb_attach()
259 if (!nfsmb_sc->subdev) { in nfsmb_attach()
260 nfsmb_detach(dev); in nfsmb_attach()
268 bus_attach_children(dev); in nfsmb_attach()
274 nfsmbsub_detach(device_t dev) in nfsmbsub_detach() argument
277 struct nfsmb_softc *nfsmbsub_sc = device_get_softc(dev); in nfsmbsub_detach()
280 parent = device_get_parent(dev); in nfsmbsub_detach()
282 error = bus_generic_detach(dev); in nfsmbsub_detach()
285 mtx_destroy(&nfsmbsub_sc->lock); in nfsmbsub_detach()
286 if (nfsmbsub_sc->res) { in nfsmbsub_detach()
287 bus_release_resource(parent, SYS_RES_IOPORT, nfsmbsub_sc->rid, in nfsmbsub_detach()
288 nfsmbsub_sc->res); in nfsmbsub_detach()
289 nfsmbsub_sc->res = NULL; in nfsmbsub_detach()
295 nfsmb_detach(device_t dev) in nfsmb_detach() argument
297 struct nfsmb_softc *nfsmb_sc = device_get_softc(dev); in nfsmb_detach()
300 error = bus_generic_detach(dev); in nfsmb_detach()
304 mtx_destroy(&nfsmb_sc->lock); in nfsmb_detach()
305 if (nfsmb_sc->res) { in nfsmb_detach()
306 bus_release_resource(dev, SYS_RES_IOPORT, nfsmb_sc->rid, in nfsmb_detach()
307 nfsmb_sc->res); in nfsmb_detach()
308 nfsmb_sc->res = NULL; in nfsmb_detach()
315 nfsmb_callback(device_t dev, int index, void *data) in nfsmb_callback() argument
342 } while (NFSMB_SMBINB(sc, SMB_PRTCL) != 0 && count--); in nfsmb_wait()
377 nfsmb_quick(device_t dev, u_char slave, int how) in nfsmb_quick() argument
379 struct nfsmb_softc *sc = (struct nfsmb_softc *)device_get_softc(dev); in nfsmb_quick()
388 NFSMB_DEBUG(printf("nfsmb: QWRITE to 0x%x", slave)); in nfsmb_quick()
392 NFSMB_DEBUG(printf("nfsmb: QREAD to 0x%x", slave)); in nfsmb_quick()
399 NFSMB_SMBOUTB(sc, SMB_ADDR, slave); in nfsmb_quick()
411 nfsmb_sendb(device_t dev, u_char slave, char byte) in nfsmb_sendb() argument
413 struct nfsmb_softc *sc = (struct nfsmb_softc *)device_get_softc(dev); in nfsmb_sendb()
418 NFSMB_SMBOUTB(sc, SMB_ADDR, slave); in nfsmb_sendb()
423 NFSMB_DEBUG(printf("nfsmb: SENDB to 0x%x, byte=0x%x, error=0x%x\n", slave, byte, error)); in nfsmb_sendb()
430 nfsmb_recvb(device_t dev, u_char slave, char *byte) in nfsmb_recvb() argument
432 struct nfsmb_softc *sc = (struct nfsmb_softc *)device_get_softc(dev); in nfsmb_recvb()
436 NFSMB_SMBOUTB(sc, SMB_ADDR, slave); in nfsmb_recvb()
442 NFSMB_DEBUG(printf("nfsmb: RECVB from 0x%x, byte=0x%x, error=0x%x\n", slave, *byte, error)); in nfsmb_recvb()
449 nfsmb_writeb(device_t dev, u_char slave, char cmd, char byte) in nfsmb_writeb() argument
451 struct nfsmb_softc *sc = (struct nfsmb_softc *)device_get_softc(dev); in nfsmb_writeb()
457 NFSMB_SMBOUTB(sc, SMB_ADDR, slave); in nfsmb_writeb()
462 …NFSMB_DEBUG(printf("nfsmb: WRITEB to 0x%x, cmd=0x%x, byte=0x%x, error=0x%x\n", slave, cmd, byte, e… in nfsmb_writeb()
469 nfsmb_readb(device_t dev, u_char slave, char cmd, char *byte) in nfsmb_readb() argument
471 struct nfsmb_softc *sc = (struct nfsmb_softc *)device_get_softc(dev); in nfsmb_readb()
476 NFSMB_SMBOUTB(sc, SMB_ADDR, slave); in nfsmb_readb()
482 …NFSMB_DEBUG(printf("nfsmb: READB from 0x%x, cmd=0x%x, byte=0x%x, error=0x%x\n", slave, cmd, (unsig… in nfsmb_readb()
489 nfsmb_writew(device_t dev, u_char slave, char cmd, short word) in nfsmb_writew() argument
491 struct nfsmb_softc *sc = (struct nfsmb_softc *)device_get_softc(dev); in nfsmb_writew()
498 NFSMB_SMBOUTB(sc, SMB_ADDR, slave); in nfsmb_writew()
503 …NFSMB_DEBUG(printf("nfsmb: WRITEW to 0x%x, cmd=0x%x, word=0x%x, error=0x%x\n", slave, cmd, word, e… in nfsmb_writew()
510 nfsmb_readw(device_t dev, u_char slave, char cmd, short *word) in nfsmb_readw() argument
512 struct nfsmb_softc *sc = (struct nfsmb_softc *)device_get_softc(dev); in nfsmb_readw()
517 NFSMB_SMBOUTB(sc, SMB_ADDR, slave); in nfsmb_readw()
524 …NFSMB_DEBUG(printf("nfsmb: READW from 0x%x, cmd=0x%x, word=0x%x, error=0x%x\n", slave, cmd, (unsig… in nfsmb_readw()
531 nfsmb_bwrite(device_t dev, u_char slave, char cmd, u_char count, char *buf) in nfsmb_bwrite() argument
533 struct nfsmb_softc *sc = (struct nfsmb_softc *)device_get_softc(dev); in nfsmb_bwrite()
545 NFSMB_SMBOUTB(sc, SMB_ADDR, slave); in nfsmb_bwrite()
550 …NFSMB_DEBUG(printf("nfsmb: WRITEBLK to 0x%x, count=0x%x, cmd=0x%x, error=0x%x", slave, count, cmd,… in nfsmb_bwrite()
557 nfsmb_bread(device_t dev, u_char slave, char cmd, u_char *count, char *buf) in nfsmb_bread() argument
559 struct nfsmb_softc *sc = (struct nfsmb_softc *)device_get_softc(dev); in nfsmb_bread()
568 NFSMB_SMBOUTB(sc, SMB_ADDR, slave); in nfsmb_bread()
581 …NFSMB_DEBUG(printf("nfsmb: READBLK to 0x%x, count=0x%x, cmd=0x%x, error=0x%x", slave, *count, cmd,… in nfsmb_bread()