xref: /dflybsd-src/sys/dev/smbus/smb/smb.h (revision 6e242d39072cb9931b728f51b29597d66f73edf1)
16ba12bf3SMatthew Dillon /*-
26ba12bf3SMatthew Dillon  * Copyright (c) 1998 Nicolas Souchu
36ba12bf3SMatthew Dillon  * All rights reserved.
46ba12bf3SMatthew Dillon  *
56ba12bf3SMatthew Dillon  * Redistribution and use in source and binary forms, with or without
66ba12bf3SMatthew Dillon  * modification, are permitted provided that the following conditions
76ba12bf3SMatthew Dillon  * are met:
86ba12bf3SMatthew Dillon  * 1. Redistributions of source code must retain the above copyright
96ba12bf3SMatthew Dillon  *    notice, this list of conditions and the following disclaimer.
106ba12bf3SMatthew Dillon  * 2. Redistributions in binary form must reproduce the above copyright
116ba12bf3SMatthew Dillon  *    notice, this list of conditions and the following disclaimer in the
126ba12bf3SMatthew Dillon  *    documentation and/or other materials provided with the distribution.
136ba12bf3SMatthew Dillon  *
146ba12bf3SMatthew Dillon  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
156ba12bf3SMatthew Dillon  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
166ba12bf3SMatthew Dillon  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
176ba12bf3SMatthew Dillon  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
186ba12bf3SMatthew Dillon  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
196ba12bf3SMatthew Dillon  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
206ba12bf3SMatthew Dillon  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
216ba12bf3SMatthew Dillon  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
226ba12bf3SMatthew Dillon  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
236ba12bf3SMatthew Dillon  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
246ba12bf3SMatthew Dillon  * SUCH DAMAGE.
256ba12bf3SMatthew Dillon  *
266ba12bf3SMatthew Dillon  * $FreeBSD: src/sys/dev/smbus/smb.h,v 1.4.8.1 2006/09/22 19:19:16 jhb Exp $
276ba12bf3SMatthew Dillon  * $DragonFly: src/sys/platform/pc32/include/smb.h,v 1.4 2006/05/20 02:42:06 dillon Exp $
286ba12bf3SMatthew Dillon  *
296ba12bf3SMatthew Dillon  */
306ba12bf3SMatthew Dillon #ifndef __SMB_H
316ba12bf3SMatthew Dillon #define __SMB_H
326ba12bf3SMatthew Dillon 
336ba12bf3SMatthew Dillon #include <sys/ioccom.h>
346ba12bf3SMatthew Dillon 
356ba12bf3SMatthew Dillon struct smbcmd {
366ba12bf3SMatthew Dillon 	u_char cmd;
376ba12bf3SMatthew Dillon 	u_char reserved;
386ba12bf3SMatthew Dillon 	u_short op;
396ba12bf3SMatthew Dillon 	union {
406ba12bf3SMatthew Dillon 		char	byte;
416ba12bf3SMatthew Dillon 		char	buf[2];
426ba12bf3SMatthew Dillon 		short	word;
436ba12bf3SMatthew Dillon 	} wdata;
446ba12bf3SMatthew Dillon 	union {
456ba12bf3SMatthew Dillon 		char	byte;
466ba12bf3SMatthew Dillon 		char	buf[2];
476ba12bf3SMatthew Dillon 		short	word;
486ba12bf3SMatthew Dillon 	} rdata;
496ba12bf3SMatthew Dillon 	int  slave;
506ba12bf3SMatthew Dillon 	char *wbuf;	/* use wdata if NULL */
516ba12bf3SMatthew Dillon 	int  wcount;	/* max 255 bytes */
526ba12bf3SMatthew Dillon 	char *rbuf;	/* use rdata if NULL */
536ba12bf3SMatthew Dillon 	int  rcount;	/* max 255 bytes */
546ba12bf3SMatthew Dillon };
556ba12bf3SMatthew Dillon 
566ba12bf3SMatthew Dillon /*
576ba12bf3SMatthew Dillon  * SMBus spec 2.0 says block transfers may be at most 32 bytes.
58*6e242d39SMatthew Dillon  * We usse SMBus for i2c as well, make the size limit something more
59*6e242d39SMatthew Dillon  * reasonable.  Keep in mind that a char buf array is declared on the
60*6e242d39SMatthew Dillon  * kernel stack.
616ba12bf3SMatthew Dillon  */
62*6e242d39SMatthew Dillon #define SMB_MAXBLOCKSIZE	1024
636ba12bf3SMatthew Dillon 
646ba12bf3SMatthew Dillon #define SMB_QUICK_WRITE	_IOW('i', 1, struct smbcmd)
656ba12bf3SMatthew Dillon #define SMB_QUICK_READ	_IOW('i', 2, struct smbcmd)
666ba12bf3SMatthew Dillon #define SMB_SENDB	_IOWR('i', 3, struct smbcmd)
676ba12bf3SMatthew Dillon #define SMB_RECVB	_IOWR('i', 4, struct smbcmd)
686ba12bf3SMatthew Dillon #define SMB_WRITEB	_IOWR('i', 5, struct smbcmd)
696ba12bf3SMatthew Dillon #define SMB_WRITEW	_IOWR('i', 6, struct smbcmd)
706ba12bf3SMatthew Dillon #define SMB_READB	_IOWR('i', 7, struct smbcmd)
716ba12bf3SMatthew Dillon #define SMB_READW	_IOWR('i', 8, struct smbcmd)
726ba12bf3SMatthew Dillon #define SMB_PCALL	_IOWR('i', 9, struct smbcmd)
736ba12bf3SMatthew Dillon #define SMB_BWRITE	_IOWR('i', 10, struct smbcmd)
746ba12bf3SMatthew Dillon #define SMB_BREAD	_IOWR('i', 11, struct smbcmd)
756ba12bf3SMatthew Dillon #define SMB_TRANS	_IOWR('i', 12, struct smbcmd)
766ba12bf3SMatthew Dillon 
776ba12bf3SMatthew Dillon #endif
78