Lines Matching +full:slave +full:- +full:dev

1 /*-
43 #include <dev/pci/pcivar.h>
44 #include <dev/pci/pcireg.h>
46 #include <dev/smbus/smbconf.h>
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))
139 static int alpm_detach(device_t dev);
142 alpm_probe(device_t dev) in alpm_probe() argument
145 if (pci_get_devid(dev) == ACER_M1543_PMU_ID) { in alpm_probe()
146 device_set_desc(dev, "AcerLabs M15x3 Power Management Unit"); in alpm_probe()
155 alpm_attach(device_t dev) in alpm_attach() argument
161 alpm = device_get_softc(dev); in alpm_attach()
164 l = pci_read_config(dev, ATPC, 1); in alpm_attach()
165 pci_write_config(dev, ATPC, l & ~ATPC_SMBCTRL, 1); in alpm_attach()
169 l = pci_read_config(dev, SMBHCBC, 1); in alpm_attach()
172 pci_write_config(dev, SMBHCBC, l, 1); in alpm_attach()
176 l = pci_read_config(dev, SMBHSI, 1); in alpm_attach()
177 device_printf(dev, "%s/%s", in alpm_attach()
179 (l & SMBHSI_SLAVE) ? "slave":"noslave"); in alpm_attach()
181 l = pci_read_config(dev, SMBHCBC, 1); 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()
213 device_printf(dev,"Could not allocate Bus space\n"); 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()
223 alpm_detach(dev); in alpm_attach()
226 bus_attach_children(dev); in alpm_attach()
232 alpm_detach(device_t dev) in alpm_detach() argument
234 struct alpm_softc *alpm = device_get_softc(dev); in alpm_detach()
237 error = bus_generic_detach(dev); 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()
250 alpm_callback(device_t dev, int index, void *data) in alpm_callback() argument
308 while (count--) { in alpm_wait()
338 alpm_quick(device_t dev, u_char slave, int how) in alpm_quick() argument
340 struct alpm_softc *sc = (struct alpm_softc *)device_get_softc(dev); 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
377 struct alpm_softc *sc = (struct alpm_softc *)device_get_softc(dev); 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
403 struct alpm_softc *sc = (struct alpm_softc *)device_get_softc(dev); in alpm_recvb()
413 ALPM_SMBOUTB(sc, SMBHADDR, slave | LSB); 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
429 struct alpm_softc *sc = (struct alpm_softc *)device_get_softc(dev); 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
456 struct alpm_softc *sc = (struct alpm_softc *)device_get_softc(dev); in alpm_readb()
466 ALPM_SMBOUTB(sc, SMBHADDR, slave | LSB); 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
483 struct alpm_softc *sc = (struct alpm_softc *)device_get_softc(dev); 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
511 struct alpm_softc *sc = (struct alpm_softc *)device_get_softc(dev); in alpm_readw()
522 ALPM_SMBOUTB(sc, SMBHADDR, slave | LSB); 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
543 struct alpm_softc *sc = (struct alpm_softc *)device_get_softc(dev); 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
584 struct alpm_softc *sc = (struct alpm_softc *)device_get_softc(dev); in alpm_bread()
598 ALPM_SMBOUTB(sc, SMBHADDR, slave | LSB); in alpm_bread()
601 * 32-byte long internal buffer */ in alpm_bread()
612 /* read the 32-byte internal buffer */ 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()