Index: stable/11/share/man/man4/smb.4 =================================================================== --- stable/11/share/man/man4/smb.4 (revision 310519) +++ stable/11/share/man/man4/smb.4 (revision 310520) @@ -1,228 +1,201 @@ .\" Copyright (c) 1998, Nicolas Souchu .\" Copyright (c) 2004, Joerg Wunsch .\" Copyright (c) 2015, Michael Gmelin .\" All rights reserved. .\" .\" Redistribution and use in source and binary forms, with or without .\" modification, are permitted provided that the following conditions .\" are met: .\" 1. Redistributions of source code must retain the above copyright .\" notice, this list of conditions and the following disclaimer. .\" 2. Redistributions in binary form must reproduce the above copyright .\" notice, this list of conditions and the following disclaimer in the .\" documentation and/or other materials provided with the distribution. .\" .\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE .\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" .\" $FreeBSD$ .\" .Dd April 25, 2015 .Dt SMB 4 .Os .Sh NAME .Nm smb .Nd SMB generic I/O device driver .Sh SYNOPSIS .Cd "device smb" .Sh DESCRIPTION The .Em smb character device driver provides generic I/O to any .Xr smbus 4 instance. To control SMB devices, use .Pa /dev/smb? with the ioctls described below. Any of these ioctl commands takes a pointer to .Vt struct smbcmd as its argument. .Bd -literal #include struct smbcmd { u_char cmd; u_char reserved; u_short op; union { char byte; char buf[2]; short word; } wdata; union { char byte; char buf[2]; short word; } rdata; int slave; char *wbuf; /* use wdata if NULL */ int wcount; char *rbuf; /* use rdata if NULL */ int rcount; }; .Ed .Pp The .Fa slave field is always used, and provides the address of the SMBus slave device. The slave address is specified in the seven most significant bits .Pq i.e., Dq "left-justified" . The least significant bit of the slave address must be zero. .Pp .Bl -column ".Dv SMB_QUICK_WRITE" -compact .It Em Ioctl Ta Em Description .Pp .It Dv SMB_QUICK_WRITE Ta .Em QuickWrite does not transfer any data. It just issues the device address with write intent to the bus. .It Dv SMB_QUICK_READ Ta .Em QuickRead does not transfer any data. It just issues the device address with read intent to the bus. .It Dv SMB_SENDB Ta .Em SendByte sends the byte provided in .Fa cmd to the device. .It Dv SMB_RECVB Ta .Em ReceiveByte reads a single byte from the device which is returned in .Fa cmd . .It Dv SMB_WRITEB Ta .Em WriteByte first sends the byte from .Fa cmd to the device, followed by the byte given in .Fa wdata.byte . .It Dv SMB_WRITEW Ta .Em WriteWord first sends the byte from .Fa cmd to the device, followed by the word given in .Fa wdata.word . Note that the SMBus byte-order is little-endian by definition. .It Dv SMB_READB Ta .Em ReadByte first sends the byte from .Fa cmd to the device, then reads one byte of data from the device. Returned data is stored in .Fa rdata.byte . .It Dv SMB_READW Ta .Em ReadWord first sends the byte from .Fa cmd to the device, then reads one word of data from the device. Returned data is stored in .Fa rdata.word . .It Dv SMB_PCALL Ta .Em ProcedureCall first sends the byte from .Fa cmd to the device, followed by the word provided in .Fa wdata.word . It then reads one word of data from the device and returns it in .Fa rdata.word . .It Dv SMB_BWRITE Ta .Em BlockWrite first sends the byte from .Fa cmd to the device, followed by .Fa wcount bytes of data that are taken from the buffer pointed to by .Fa wbuf . The SMBus specification mandates that no more than 32 bytes of data can be transferred in a single block read or write command, but since .Xr smbus 4 is also used to access I2C devices, the limit has been increased to 1024. This value can be read from the constant .Dv SMB_MAXBLOCKSIZE . .It Dv SMB_BREAD Ta .Em BlockRead first sends the byte from .Fa cmd to the device, then reads .Fa rcount bytes of data that from the device. This data is returned in the buffer pointed to by .Fa rbuf . -.It Dv SMB_TRANS Ta -.Em Trans -sends an SMB roll-up transaction with flags that also allow it to -be used for (mostly) I2C pass-through and with 10-bit addresses. -This function can be utilized to roll up all of the above functions. -It first sends the byte from -.Fa cmd -to the device, followed by -.Fa wcount -bytes of data that are taken from the buffer pointed to by -.Fa wbuf , -then reads -.Fa rcount -bytes of data that from the device. -This data is returned in the buffer pointed to by -.Fa rbuf . -.Pp -The following flags are allowed in -.Fa op : -.Pp -.Bd -literal -compact -SMB_TRANS_NOSTOP Do not send STOP at end -SMB_TRANS_NOCMD Ignore cmd field (do not tx) -SMB_TRANS_NOCNT Do not tx or rx count field -SMB_TRANS_7BIT Change address mode to 7-bit -SMB_TRANS_10BIT Change address mode to 10-bit -.Ed .El .Pp The .Xr read 2 and .Xr write 2 system calls are not implemented by this driver. .Sh ERRORS The .Xr ioctl 2 commands can cause the following driver-specific errors: .Bl -tag -width Er .It Bq Er ENXIO Device did not respond to selection. .It Bq Er EBUSY Device still in use. .It Bq Er ENODEV Operation not supported by device (not supposed to happen). .It Bq Er EINVAL General argument error. .It Bq Er EWOULDBLOCK SMBus transaction timed out. .El .Sh SEE ALSO .Xr ioctl 2 , .Xr smbus 4 .Sh HISTORY The .Nm manual page first appeared in .Fx 3.0 . .Sh AUTHORS This manual page was written by .An Nicolas Souchu and extended by .An Michael Gmelin Aq freebsd@grem.de . Index: stable/11/sys/dev/smbus/smb.c =================================================================== --- stable/11/sys/dev/smbus/smb.c (revision 310519) +++ stable/11/sys/dev/smbus/smb.c (revision 310520) @@ -1,333 +1,315 @@ /*- * Copyright (c) 1998, 2001 Nicolas Souchu * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * $FreeBSD$ */ #include #include #include #include #include #include #include #include #include #include #include #include "smbus_if.h" #define SMB_OLD_READB _IOW('i', 7, struct smbcmd) #define SMB_OLD_READW _IOW('i', 8, struct smbcmd) #define SMB_OLD_PCALL _IOW('i', 9, struct smbcmd) struct smb_softc { device_t sc_dev; int sc_count; /* >0 if device opened */ struct cdev *sc_devnode; struct mtx sc_lock; }; static void smb_identify(driver_t *driver, device_t parent); static int smb_probe(device_t); static int smb_attach(device_t); static int smb_detach(device_t); static devclass_t smb_devclass; static device_method_t smb_methods[] = { /* device interface */ DEVMETHOD(device_identify, smb_identify), DEVMETHOD(device_probe, smb_probe), DEVMETHOD(device_attach, smb_attach), DEVMETHOD(device_detach, smb_detach), /* smbus interface */ DEVMETHOD(smbus_intr, smbus_generic_intr), { 0, 0 } }; static driver_t smb_driver = { "smb", smb_methods, sizeof(struct smb_softc), }; static d_open_t smbopen; static d_close_t smbclose; static d_ioctl_t smbioctl; static struct cdevsw smb_cdevsw = { .d_version = D_VERSION, .d_flags = D_TRACKCLOSE, .d_open = smbopen, .d_close = smbclose, .d_ioctl = smbioctl, .d_name = "smb", }; static void smb_identify(driver_t *driver, device_t parent) { if (device_find_child(parent, "smb", -1) == NULL) BUS_ADD_CHILD(parent, 0, "smb", -1); } static int smb_probe(device_t dev) { if (smbus_get_addr(dev) != -1) return (ENXIO); device_set_desc(dev, "SMBus generic I/O"); return (BUS_PROBE_NOWILDCARD); } static int smb_attach(device_t dev) { struct smb_softc *sc = device_get_softc(dev); int unit; unit = device_get_unit(dev); sc->sc_dev = dev; sc->sc_devnode = make_dev(&smb_cdevsw, unit, UID_ROOT, GID_WHEEL, 0600, "smb%d", unit); sc->sc_devnode->si_drv1 = sc; mtx_init(&sc->sc_lock, device_get_nameunit(dev), NULL, MTX_DEF); return (0); } static int smb_detach(device_t dev) { struct smb_softc *sc = (struct smb_softc *)device_get_softc(dev); if (sc->sc_devnode) destroy_dev(sc->sc_devnode); mtx_destroy(&sc->sc_lock); return (0); } static int smbopen(struct cdev *dev, int flags, int fmt, struct thread *td) { struct smb_softc *sc = dev->si_drv1; mtx_lock(&sc->sc_lock); if (sc->sc_count != 0) { mtx_unlock(&sc->sc_lock); return (EBUSY); } sc->sc_count++; mtx_unlock(&sc->sc_lock); return (0); } static int smbclose(struct cdev *dev, int flags, int fmt, struct thread *td) { struct smb_softc *sc = dev->si_drv1; mtx_lock(&sc->sc_lock); KASSERT(sc->sc_count == 1, ("device not busy")); sc->sc_count--; mtx_unlock(&sc->sc_lock); return (0); } static int smbioctl(struct cdev *dev, u_long cmd, caddr_t data, int flags, struct thread *td) { char buf[SMB_MAXBLOCKSIZE]; device_t parent; struct smbcmd *s = (struct smbcmd *)data; struct smb_softc *sc = dev->si_drv1; device_t smbdev = sc->sc_dev; int error; int unit; u_char bcount; /* * If a specific slave device is being used, override any passed-in * slave. */ unit = dev2unit(dev); if (unit & 0x0400) s->slave = unit & 0x03ff; parent = device_get_parent(smbdev); /* Make sure that LSB bit is cleared. */ if (s->slave & 0x1) return (EINVAL); /* Allocate the bus. */ if ((error = smbus_request_bus(parent, smbdev, (flags & O_NONBLOCK) ? SMB_DONTWAIT : (SMB_WAIT | SMB_INTR)))) return (error); switch (cmd) { case SMB_QUICK_WRITE: error = smbus_error(smbus_quick(parent, s->slave, SMB_QWRITE)); break; case SMB_QUICK_READ: error = smbus_error(smbus_quick(parent, s->slave, SMB_QREAD)); break; case SMB_SENDB: error = smbus_error(smbus_sendb(parent, s->slave, s->cmd)); break; case SMB_RECVB: error = smbus_error(smbus_recvb(parent, s->slave, &s->cmd)); break; case SMB_WRITEB: error = smbus_error(smbus_writeb(parent, s->slave, s->cmd, s->wdata.byte)); break; case SMB_WRITEW: error = smbus_error(smbus_writew(parent, s->slave, s->cmd, s->wdata.word)); break; case SMB_OLD_READB: case SMB_READB: /* NB: for SMB_OLD_READB the read data goes to rbuf only. */ error = smbus_error(smbus_readb(parent, s->slave, s->cmd, &s->rdata.byte)); if (error) break; if (s->rbuf && s->rcount >= 1) { error = copyout(&s->rdata.byte, s->rbuf, 1); s->rcount = 1; } break; case SMB_OLD_READW: case SMB_READW: /* NB: for SMB_OLD_READW the read data goes to rbuf only. */ error = smbus_error(smbus_readw(parent, s->slave, s->cmd, &s->rdata.word)); if (error) break; if (s->rbuf && s->rcount >= 2) { buf[0] = (u_char)s->rdata.word; buf[1] = (u_char)(s->rdata.word >> 8); error = copyout(buf, s->rbuf, 2); s->rcount = 2; } break; case SMB_OLD_PCALL: case SMB_PCALL: /* NB: for SMB_OLD_PCALL the read data goes to rbuf only. */ error = smbus_error(smbus_pcall(parent, s->slave, s->cmd, s->wdata.word, &s->rdata.word)); if (error) break; if (s->rbuf && s->rcount >= 2) { buf[0] = (u_char)s->rdata.word; buf[1] = (u_char)(s->rdata.word >> 8); error = copyout(buf, s->rbuf, 2); s->rcount = 2; } break; case SMB_BWRITE: if (s->wcount < 0) { error = EINVAL; break; } if (s->wcount > SMB_MAXBLOCKSIZE) s->wcount = SMB_MAXBLOCKSIZE; if (s->wcount) error = copyin(s->wbuf, buf, s->wcount); if (error) break; error = smbus_error(smbus_bwrite(parent, s->slave, s->cmd, s->wcount, buf)); break; case SMB_BREAD: if (s->rcount < 0) { error = EINVAL; break; } if (s->rcount > SMB_MAXBLOCKSIZE) s->rcount = SMB_MAXBLOCKSIZE; error = smbus_error(smbus_bread(parent, s->slave, s->cmd, &bcount, buf)); if (error) break; if (s->rcount > bcount) s->rcount = bcount; error = copyout(buf, s->rbuf, s->rcount); break; - case SMB_TRANS: - if (s->rcount < 0 || s->wcount < 0) { - error = EINVAL; - break; - } - if (s->rcount > SMB_MAXBLOCKSIZE) - s->rcount = SMB_MAXBLOCKSIZE; - if (s->wcount > SMB_MAXBLOCKSIZE) - s->wcount = SMB_MAXBLOCKSIZE; - if (s->wcount) - error = copyin(s->wbuf, buf, s->wcount); - if (error) - break; - error = smbus_error(smbus_trans(parent, s->slave, s->cmd, - s->op, buf, s->wcount, buf, s->rcount, &s->rcount)); - if (error == 0) - error = copyout(buf, s->rbuf, s->rcount); - break; default: error = ENOTTY; } smbus_release_bus(parent, smbdev); return (error); } DRIVER_MODULE(smb, smbus, smb_driver, smb_devclass, 0, 0); MODULE_DEPEND(smb, smbus, SMBUS_MINVER, SMBUS_PREFVER, SMBUS_MAXVER); MODULE_VERSION(smb, 1); Index: stable/11/sys/dev/smbus/smb.h =================================================================== --- stable/11/sys/dev/smbus/smb.h (revision 310519) +++ stable/11/sys/dev/smbus/smb.h (revision 310520) @@ -1,76 +1,73 @@ /*- * Copyright (c) 1998 Nicolas Souchu * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * $FreeBSD$ * */ #ifndef __SMB_H #define __SMB_H #include struct smbcmd { u_char cmd; u_char reserved; u_short op; union { char byte; char buf[2]; short word; } wdata; union { char byte; char buf[2]; short word; } rdata; int slave; char *wbuf; /* use wdata if NULL */ int wcount; char *rbuf; /* use rdata if NULL */ int rcount; }; /* * SMBus spec 2.0 says block transfers may be at most 32 bytes. - * We use SMBus for i2c as well, make the size limit something more - * reasonable. Keep in mind that a char buf array is declared on the - * kernel stack. */ -#define SMB_MAXBLOCKSIZE 1024 +#define SMB_MAXBLOCKSIZE 32 #define SMB_QUICK_WRITE _IOW('i', 1, struct smbcmd) #define SMB_QUICK_READ _IOW('i', 2, struct smbcmd) #define SMB_SENDB _IOW('i', 3, struct smbcmd) #define SMB_RECVB _IOWR('i', 4, struct smbcmd) #define SMB_WRITEB _IOW('i', 5, struct smbcmd) #define SMB_WRITEW _IOW('i', 6, struct smbcmd) #define SMB_READB _IOWR('i', 7, struct smbcmd) #define SMB_READW _IOWR('i', 8, struct smbcmd) #define SMB_PCALL _IOWR('i', 9, struct smbcmd) #define SMB_BWRITE _IOW('i', 10, struct smbcmd) #define SMB_BREAD _IOWR('i', 11, struct smbcmd) -#define SMB_TRANS _IOWR('i', 12, struct smbcmd) +#define SMB_OLD_TRANS _IOWR('i', 12, struct smbcmd) #endif Index: stable/11/sys/dev/smbus/smbconf.h =================================================================== --- stable/11/sys/dev/smbus/smbconf.h (revision 310519) +++ stable/11/sys/dev/smbus/smbconf.h (revision 310520) @@ -1,146 +1,127 @@ /*- * Copyright (c) 1998 Nicolas Souchu * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * $FreeBSD$ */ #ifndef __SMBONF_H #define __SMBONF_H #include #define SMBPRI (PZERO+8) /* XXX sleep/wakeup queue priority */ #define n(flags) (~(flags) & (flags)) /* Order constants for smbus children. */ #define SMBUS_ORDER_HINTED 20 #define SMBUS_ORDER_PNP 40 /* * How tsleep() is called in smb_request_bus(). */ #define SMB_DONTWAIT 0 #define SMB_NOINTR 0 #define SMB_WAIT 0x1 #define SMB_INTR 0x2 /* * callback index */ #define SMB_REQUEST_BUS 0x1 #define SMB_RELEASE_BUS 0x2 /* * SMB bus errors */ #define SMB_ENOERR 0x0 #define SMB_EBUSERR 0x1 #define SMB_ENOTSUPP 0x2 #define SMB_ENOACK 0x4 #define SMB_ECOLLI 0x8 #define SMB_EABORT 0x10 #define SMB_ETIMEOUT 0x20 #define SMB_EBUSY 0x40 #define SMB_EINVAL 0x100 /* * How Quick command is executed */ #define SMB_QWRITE 0x0 #define SMB_QREAD 0x1 /* - * smbus transction op with pass-thru capabilities - * - * This smbus function is capable of doing a smbus command transaction - * (read or write), and can be flagged to not issue the 'cmd' and/or - * issue or expect a count field as well as flagged for chaining (no STOP), - * which gives it an i2c pass-through capability. - * - * NOSTOP- Caller chaining transactions, do not issue STOP - * NOCMD- Do not transmit the command field - * NOCNT- Do not transmit (wr) or expect (rd) the count field - */ -#define SMB_TRANS_NOSTOP 0x0001 /* do not send STOP at end */ -#define SMB_TRANS_NOCMD 0x0002 /* ignore cmd field (do not tx) */ -#define SMB_TRANS_NOCNT 0x0004 /* do not tx or rx count field */ -#define SMB_TRANS_7BIT 0x0008 /* change address mode to 7-bit */ -#define SMB_TRANS_10BIT 0x0010 /* change address mode to 10-bit */ -#define SMB_TRANS_NOREPORT 0x0020 /* do not report errors */ - -/* * ivars codes */ enum smbus_ivars { SMBUS_IVAR_ADDR, /* slave address of the device */ }; int smbus_request_bus(device_t, device_t, int); int smbus_release_bus(device_t, device_t); device_t smbus_alloc_bus(device_t); int smbus_error(int error); void smbus_intr(device_t, u_char, char low, char high, int error); #define SMBUS_ACCESSOR(var, ivar, type) \ __BUS_ACCESSOR(smbus, var, SMBUS, ivar, type) SMBUS_ACCESSOR(addr, ADDR, int) #undef SMBUS_ACCESSOR extern driver_t smbus_driver; extern devclass_t smbus_devclass; #define smbus_quick(bus,slave,how) \ (SMBUS_QUICK(device_get_parent(bus), slave, how)) #define smbus_sendb(bus,slave,byte) \ (SMBUS_SENDB(device_get_parent(bus), slave, byte)) #define smbus_recvb(bus,slave,byte) \ (SMBUS_RECVB(device_get_parent(bus), slave, byte)) #define smbus_writeb(bus,slave,cmd,byte) \ (SMBUS_WRITEB(device_get_parent(bus), slave, cmd, byte)) #define smbus_writew(bus,slave,cmd,word) \ (SMBUS_WRITEW(device_get_parent(bus), slave, cmd, word)) #define smbus_readb(bus,slave,cmd,byte) \ (SMBUS_READB(device_get_parent(bus), slave, cmd, byte)) #define smbus_readw(bus,slave,cmd,word) \ (SMBUS_READW(device_get_parent(bus), slave, cmd, word)) #define smbus_pcall(bus,slave,cmd,sdata,rdata) \ (SMBUS_PCALL(device_get_parent(bus), slave, cmd, sdata, rdata)) #define smbus_bwrite(bus,slave,cmd,count,buf) \ (SMBUS_BWRITE(device_get_parent(bus), slave, cmd, count, buf)) #define smbus_bread(bus,slave,cmd,count,buf) \ (SMBUS_BREAD(device_get_parent(bus), slave, cmd, count, buf)) #define smbus_trans(bus,slave,cmd,op,wbuf,wcount,rbuf,rcount,actualp) \ (SMBUS_TRANS(device_get_parent(bus), slave, cmd, op, \ wbuf, wcount, rbuf, rcount, actualp)) #define SMBUS_MODVER 1 #define SMBUS_MINVER 1 #define SMBUS_MAXVER 1 #define SMBUS_PREFVER SMBUS_MODVER #endif Index: stable/11/sys/dev/smbus/smbus_if.m =================================================================== --- stable/11/sys/dev/smbus/smbus_if.m (revision 310519) +++ stable/11/sys/dev/smbus/smbus_if.m (revision 310520) @@ -1,168 +1,151 @@ #- # Copyright (c) 1998 Nicolas Souchu # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # 1. Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # 2. Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. # # THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE # ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF # SUCH DAMAGE. # # $FreeBSD$ # #include INTERFACE smbus; # # Interpret interrupt # METHOD void intr { device_t dev; u_char devaddr; char low; char high; int error; }; # # smbus callback # METHOD int callback { device_t dev; int index; void *data; }; # # Quick command # METHOD int quick { device_t dev; u_char slave; int how; }; # # Send Byte command # METHOD int sendb { device_t dev; u_char slave; char byte; }; # # Receive Byte command # METHOD int recvb { device_t dev; u_char slave; char *byte; }; # # Write Byte command # METHOD int writeb { device_t dev; u_char slave; char cmd; char byte; }; # # Write Word command # METHOD int writew { device_t dev; u_char slave; char cmd; short word; }; # # Read Byte command # METHOD int readb { device_t dev; u_char slave; char cmd; char *byte; }; # # Read Word command # METHOD int readw { device_t dev; u_char slave; char cmd; short *word; }; # # Process Call command # METHOD int pcall { device_t dev; u_char slave; char cmd; short sdata; short *rdata; }; # # Block Write command # METHOD int bwrite { device_t dev; u_char slave; char cmd; u_char count; char *buf; }; # # Block Read command # METHOD int bread { device_t dev; u_char slave; char cmd; u_char *count; char *buf; }; - -# -# SMB roll-up transaction with flags that also allow it to be -# used for (mostly) i2c pass-through and with 10-bit addresses. -# This function can be used to roll-up all of the above functions. -# -METHOD int trans { - device_t dev; - int slave; - char cmd; - int op; - char *wbuf; - int wcount; - char *rbuf; - int rcount; - int *actualp; -}; Index: stable/11 =================================================================== --- stable/11 (revision 310519) +++ stable/11 (revision 310520) Property changes on: stable/11 ___________________________________________________________________ Modified: svn:mergeinfo ## -0,0 +0,1 ## Merged /head:r308242