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>
94 #define SMB_STS_PEC 0x1f /* PEC (CRC-8) Error */
114 #define AMDSMB_LOCK(amdsmb) mtx_lock(&(amdsmb)->lock)
115 #define AMDSMB_UNLOCK(amdsmb) mtx_unlock(&(amdsmb)->lock)
116 #define AMDSMB_LOCK_ASSERT(amdsmb) mtx_assert(&(amdsmb)->lock, MA_OWNED)
119 (bus_read_1(amdsmb->res, register))
121 (bus_write_1(amdsmb->res, register, value))
123 static int amdsmb_detach(device_t dev);
127 PCI_DESCR("AMD-8111 SMBus 2.0 Controller") }
131 amdsmb_probe(device_t dev)
135 tbl = PCI_MATCH(dev, amdsmb_devs);
138 device_set_desc(dev, tbl->descr);
144 amdsmb_attach(device_t dev)
146 struct amdsmb_softc *amdsmb_sc = device_get_softc(dev);
149 amdsmb_sc->rid = PCIR_BAR(0);
151 amdsmb_sc->res = bus_alloc_resource_any(dev, SYS_RES_IOPORT,
152 &amdsmb_sc->rid, RF_ACTIVE);
154 if (amdsmb_sc->res == NULL) {
155 device_printf(dev, "could not map i/o space\n");
159 mtx_init(&amdsmb_sc->lock, device_get_nameunit(dev), "amdsmb", MTX_DEF);
162 amdsmb_sc->smbus = device_add_child(dev, "smbus", DEVICE_UNIT_ANY);
163 if (!amdsmb_sc->smbus) {
164 amdsmb_detach(dev);
168 bus_generic_attach(dev);
174 amdsmb_detach(device_t dev)
176 struct amdsmb_softc *amdsmb_sc = device_get_softc(dev);
178 if (amdsmb_sc->smbus) {
179 device_delete_child(dev, amdsmb_sc->smbus);
180 amdsmb_sc->smbus = NULL;
183 mtx_destroy(&amdsmb_sc->lock);
184 if (amdsmb_sc->res)
185 bus_release_resource(dev, SYS_RES_IOPORT, amdsmb_sc->rid,
186 amdsmb_sc->res);
192 amdsmb_callback(device_t dev, int index, void *data)
212 while (timeout-- && AMDSMB_ECINB(sc, EC_SC) & EC_SC_IBF)
215 device_printf(sc->smbus, "timeout waiting for IBF to clear\n");
226 while (timeout-- && ~AMDSMB_ECINB(sc, EC_SC) & EC_SC_OBF)
229 device_printf(sc->smbus, "timeout waiting for OBF to set\n");
289 } while (temp != 0 && count--);
325 amdsmb_quick(device_t dev, u_char slave, int how)
327 struct amdsmb_softc *sc = (struct amdsmb_softc *)device_get_softc(dev);
336 AMDSMB_DEBUG(printf("amdsmb: QWRITE to 0x%x", slave));
340 AMDSMB_DEBUG(printf("amdsmb: QREAD to 0x%x", slave));
347 amdsmb_ec_write(sc, SMB_ADDR, slave);
359 amdsmb_sendb(device_t dev, u_char slave, char byte)
361 struct amdsmb_softc *sc = (struct amdsmb_softc *)device_get_softc(dev);
366 amdsmb_ec_write(sc, SMB_ADDR, slave);
372 slave, byte, error));
379 amdsmb_recvb(device_t dev, u_char slave, char *byte)
381 struct amdsmb_softc *sc = (struct amdsmb_softc *)device_get_softc(dev);
385 amdsmb_ec_write(sc, SMB_ADDR, slave);
392 slave, *byte, error));
399 amdsmb_writeb(device_t dev, u_char slave, char cmd, char byte)
401 struct amdsmb_softc *sc = (struct amdsmb_softc *)device_get_softc(dev);
407 amdsmb_ec_write(sc, SMB_ADDR, slave);
413 "error=0x%x\n", slave, cmd, byte, error));
420 amdsmb_readb(device_t dev, u_char slave, char cmd, char *byte)
422 struct amdsmb_softc *sc = (struct amdsmb_softc *)device_get_softc(dev);
427 amdsmb_ec_write(sc, SMB_ADDR, slave);
434 "error=0x%x\n", slave, cmd, (unsigned char)*byte, error));
441 amdsmb_writew(device_t dev, u_char slave, char cmd, short word)
443 struct amdsmb_softc *sc = (struct amdsmb_softc *)device_get_softc(dev);
450 amdsmb_ec_write(sc, SMB_ADDR, slave);
456 "error=0x%x\n", slave, cmd, word, error));
463 amdsmb_readw(device_t dev, u_char slave, char cmd, short *word)
465 struct amdsmb_softc *sc = (struct amdsmb_softc *)device_get_softc(dev);
471 amdsmb_ec_write(sc, SMB_ADDR, slave);
481 "error=0x%x\n", slave, cmd, (unsigned short)*word, error));
488 amdsmb_bwrite(device_t dev, u_char slave, char cmd, u_char count, char *buf)
490 struct amdsmb_softc *sc = (struct amdsmb_softc *)device_get_softc(dev);
502 amdsmb_ec_write(sc, SMB_ADDR, slave);
508 "error=0x%x", slave, count, cmd, error));
515 amdsmb_bread(device_t dev, u_char slave, char cmd, u_char *count, char *buf)
517 struct amdsmb_softc *sc = (struct amdsmb_softc *)device_get_softc(dev);
526 amdsmb_ec_write(sc, SMB_ADDR, slave);
540 "error=0x%x", slave, *count, cmd, error));