Lines Matching +full:slave +full:- +full:if
1 /*-
23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
49 #define ALPM_DEBUG(x) if (alpm_debug) (x)
60 * I/O registers offsets - the base address is programmed via the
63 #define SMBSTS 0x0 /* SMBus host/slave status register */
64 #define SMBCMD 0x1 /* SMBus host/slave command register */
130 #define ALPM_LOCK(alpm) mtx_lock(&(alpm)->lock)
131 #define ALPM_UNLOCK(alpm) mtx_unlock(&(alpm)->lock)
132 #define ALPM_LOCK_ASSERT(alpm) mtx_assert(&(alpm)->lock, MA_OWNED)
135 (bus_space_read_1(alpm->smbst, alpm->smbsh, register))
137 (bus_space_write_1(alpm->smbst, alpm->smbsh, register, value))
145 if (pci_get_devid(dev) == ACER_M1543_PMU_ID) { in alpm_probe()
175 if (bootverbose || alpm_debug) { in alpm_attach()
179 (l & SMBHSI_SLAVE) ? "slave":"noslave"); in alpm_attach()
209 alpm->res = bus_alloc_resource_any(dev, SYS_RES_IOPORT, &rid, in alpm_attach()
212 if (alpm->res == NULL) { in alpm_attach()
216 alpm->smbst = rman_get_bustag(alpm->res); in alpm_attach()
217 alpm->smbsh = rman_get_bushandle(alpm->res); in alpm_attach()
218 mtx_init(&alpm->lock, device_get_nameunit(dev), "alpm", MTX_DEF); in alpm_attach()
221 alpm->smbus = device_add_child(dev, "smbus", DEVICE_UNIT_ANY); in alpm_attach()
222 if (alpm->smbus == NULL) { in alpm_attach()
238 if (error != 0) in alpm_detach()
241 mtx_destroy(&alpm->lock); in alpm_detach()
243 if (alpm->res) in alpm_detach()
244 bus_release_resource(dev, SYS_RES_IOPORT, SMBBA, alpm->res); in alpm_detach()
275 #if 0
308 while (count--) { in alpm_wait()
311 if (sts & SMI_I_STS) in alpm_wait()
319 if (!count) in alpm_wait()
322 if (sts & TERMINATE) in alpm_wait()
325 if (sts & BUS_COLLI) in alpm_wait()
328 if (sts & DEVICE_ERR) in alpm_wait()
331 if (error != SMB_ENOERR) in alpm_wait()
338 alpm_quick(device_t dev, u_char slave, int how) in alpm_quick() argument
345 if (!alpm_idle(sc)) { in alpm_quick()
352 ALPM_DEBUG(printf("alpm: QWRITE to 0x%x", slave)); in alpm_quick()
353 ALPM_SMBOUTB(sc, SMBHADDR, slave & ~LSB); in alpm_quick()
356 ALPM_DEBUG(printf("alpm: QREAD to 0x%x", slave)); in alpm_quick()
357 ALPM_SMBOUTB(sc, SMBHADDR, slave | LSB); in alpm_quick()
375 alpm_sendb(device_t dev, u_char slave, char byte) in alpm_sendb() argument
382 if (!alpm_idle(sc)) { in alpm_sendb()
387 ALPM_SMBOUTB(sc, SMBHADDR, slave & ~LSB); in alpm_sendb()
394 ALPM_DEBUG(printf("alpm: SENDB to 0x%x, byte=0x%x, error=0x%x\n", slave, byte, error)); in alpm_sendb()
401 alpm_recvb(device_t dev, u_char slave, char *byte) in alpm_recvb() argument
408 if (!alpm_idle(sc)) { in alpm_recvb()
413 ALPM_SMBOUTB(sc, SMBHADDR, slave | LSB); in alpm_recvb()
417 if ((error = alpm_wait(sc)) == SMB_ENOERR) in alpm_recvb()
420 ALPM_DEBUG(printf("alpm: RECVB from 0x%x, byte=0x%x, error=0x%x\n", slave, *byte, error)); in alpm_recvb()
427 alpm_writeb(device_t dev, u_char slave, char cmd, char byte) in alpm_writeb() argument
434 if (!alpm_idle(sc)) { in alpm_writeb()
439 ALPM_SMBOUTB(sc, SMBHADDR, slave & ~LSB); in alpm_writeb()
447 …ALPM_DEBUG(printf("alpm: WRITEB to 0x%x, cmd=0x%x, byte=0x%x, error=0x%x\n", slave, cmd, byte, err… in alpm_writeb()
454 alpm_readb(device_t dev, u_char slave, char cmd, char *byte) in alpm_readb() argument
461 if (!alpm_idle(sc)) { in alpm_readb()
466 ALPM_SMBOUTB(sc, SMBHADDR, slave | LSB); in alpm_readb()
471 if ((error = alpm_wait(sc)) == SMB_ENOERR) in alpm_readb()
474 …ALPM_DEBUG(printf("alpm: READB from 0x%x, cmd=0x%x, byte=0x%x, error=0x%x\n", slave, cmd, *byte, e… in alpm_readb()
481 alpm_writew(device_t dev, u_char slave, char cmd, short word) in alpm_writew() argument
488 if (!alpm_idle(sc)) { in alpm_writew()
493 ALPM_SMBOUTB(sc, SMBHADDR, slave & ~LSB); in alpm_writew()
502 …ALPM_DEBUG(printf("alpm: WRITEW to 0x%x, cmd=0x%x, word=0x%x, error=0x%x\n", slave, cmd, word, err… in alpm_writew()
509 alpm_readw(device_t dev, u_char slave, char cmd, short *word) in alpm_readw() argument
517 if (!alpm_idle(sc)) { in alpm_readw()
522 ALPM_SMBOUTB(sc, SMBHADDR, slave | LSB); in alpm_readw()
527 if ((error = alpm_wait(sc)) == SMB_ENOERR) { in alpm_readw()
534 …ALPM_DEBUG(printf("alpm: READW from 0x%x, cmd=0x%x, word=0x%x, error=0x%x\n", slave, cmd, *word, e… in alpm_readw()
541 alpm_bwrite(device_t dev, u_char slave, char cmd, u_char count, char *buf) in alpm_bwrite() argument
547 if (count < 1 || count > 32) in alpm_bwrite()
552 if(!alpm_idle(sc)) { in alpm_bwrite()
557 ALPM_SMBOUTB(sc, SMBHADDR, slave & ~LSB); in alpm_bwrite()
560 * 32-byte long internal buffer */ in alpm_bwrite()
565 /* fill the 32-byte internal buffer */ in alpm_bwrite()
575 …ALPM_DEBUG(printf("alpm: WRITEBLK to 0x%x, count=0x%x, cmd=0x%x, error=0x%x", slave, count, cmd, e… in alpm_bwrite()
582 alpm_bread(device_t dev, u_char slave, char cmd, u_char *count, char *buf) in alpm_bread() argument
588 if (*count < 1 || *count > 32) in alpm_bread()
593 if (!alpm_idle(sc)) { in alpm_bread()
598 ALPM_SMBOUTB(sc, SMBHADDR, slave | LSB); in alpm_bread()
601 * 32-byte long internal buffer */ in alpm_bread()
607 if ((error = alpm_wait(sc)) != SMB_ENOERR) in alpm_bread()
612 /* read the 32-byte internal buffer */ in alpm_bread()
615 if (i < *count) in alpm_bread()
622 …ALPM_DEBUG(printf("alpm: READBLK to 0x%x, count=0x%x, cmd=0x%x, error=0x%x", slave, *count, cmd, e… in alpm_bread()