xref: /freebsd/sys/dev/smbus/smb.h (revision 202379af847e82a654964f69aaa3435212732eff)
1b2dc47b4SNicolas Souchu /*-
2b2dc47b4SNicolas Souchu  * Copyright (c) 1998 Nicolas Souchu
3b2dc47b4SNicolas Souchu  * All rights reserved.
4b2dc47b4SNicolas Souchu  *
5b2dc47b4SNicolas Souchu  * Redistribution and use in source and binary forms, with or without
6b2dc47b4SNicolas Souchu  * modification, are permitted provided that the following conditions
7b2dc47b4SNicolas Souchu  * are met:
8b2dc47b4SNicolas Souchu  * 1. Redistributions of source code must retain the above copyright
9b2dc47b4SNicolas Souchu  *    notice, this list of conditions and the following disclaimer.
10b2dc47b4SNicolas Souchu  * 2. Redistributions in binary form must reproduce the above copyright
11b2dc47b4SNicolas Souchu  *    notice, this list of conditions and the following disclaimer in the
12b2dc47b4SNicolas Souchu  *    documentation and/or other materials provided with the distribution.
13b2dc47b4SNicolas Souchu  *
14b2dc47b4SNicolas Souchu  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15b2dc47b4SNicolas Souchu  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16b2dc47b4SNicolas Souchu  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17b2dc47b4SNicolas Souchu  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
18b2dc47b4SNicolas Souchu  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19b2dc47b4SNicolas Souchu  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20b2dc47b4SNicolas Souchu  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21b2dc47b4SNicolas Souchu  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22b2dc47b4SNicolas Souchu  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23b2dc47b4SNicolas Souchu  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24b2dc47b4SNicolas Souchu  * SUCH DAMAGE.
25b2dc47b4SNicolas Souchu  *
26c3aac50fSPeter Wemm  * $FreeBSD$
27b2dc47b4SNicolas Souchu  *
28b2dc47b4SNicolas Souchu  */
29b2dc47b4SNicolas Souchu #ifndef __SMB_H
30b2dc47b4SNicolas Souchu #define __SMB_H
31b2dc47b4SNicolas Souchu 
32b2dc47b4SNicolas Souchu #include <sys/ioccom.h>
33b2dc47b4SNicolas Souchu 
34b2dc47b4SNicolas Souchu struct smbcmd {
35*202379afSMichael Gmelin 	u_char cmd;
36*202379afSMichael Gmelin 	u_char reserved;
37*202379afSMichael Gmelin 	u_short op;
38b2dc47b4SNicolas Souchu 	union {
39b2dc47b4SNicolas Souchu 		char	byte;
40*202379afSMichael Gmelin 		char	buf[2];
41b2dc47b4SNicolas Souchu 		short	word;
42*202379afSMichael Gmelin 	} wdata;
43*202379afSMichael Gmelin 	union {
44*202379afSMichael Gmelin 		char	byte;
45*202379afSMichael Gmelin 		char	buf[2];
46*202379afSMichael Gmelin 		short	word;
47*202379afSMichael Gmelin 	} rdata;
48*202379afSMichael Gmelin 	int  slave;
49*202379afSMichael Gmelin 	char *wbuf;	/* use wdata if NULL */
50*202379afSMichael Gmelin 	int  wcount;
51*202379afSMichael Gmelin 	char *rbuf;	/* use rdata if NULL */
52*202379afSMichael Gmelin 	int  rcount;
53b2dc47b4SNicolas Souchu };
54b2dc47b4SNicolas Souchu 
55add37e1eSJoerg Wunsch /*
56add37e1eSJoerg Wunsch  * SMBus spec 2.0 says block transfers may be at most 32 bytes.
57*202379afSMichael Gmelin  * We use SMBus for i2c as well, make the size limit something more
58*202379afSMichael Gmelin  * reasonable.  Keep in mind that a char buf array is declared on the
59*202379afSMichael Gmelin  * kernel stack.
60add37e1eSJoerg Wunsch  */
61*202379afSMichael Gmelin #define SMB_MAXBLOCKSIZE	1024
62add37e1eSJoerg Wunsch 
63bf896bd0SNicolas Souchu #define SMB_QUICK_WRITE	_IOW('i', 1, struct smbcmd)
64bf896bd0SNicolas Souchu #define SMB_QUICK_READ	_IOW('i', 2, struct smbcmd)
65b2dc47b4SNicolas Souchu #define SMB_SENDB	_IOW('i', 3, struct smbcmd)
66add37e1eSJoerg Wunsch #define SMB_RECVB	_IOWR('i', 4, struct smbcmd)
67b2dc47b4SNicolas Souchu #define SMB_WRITEB	_IOW('i', 5, struct smbcmd)
68b2dc47b4SNicolas Souchu #define SMB_WRITEW	_IOW('i', 6, struct smbcmd)
69b2dc47b4SNicolas Souchu #define SMB_READB	_IOW('i', 7, struct smbcmd)
70b2dc47b4SNicolas Souchu #define SMB_READW	_IOW('i', 8, struct smbcmd)
71b2dc47b4SNicolas Souchu #define SMB_PCALL	_IOW('i', 9, struct smbcmd)
72b2dc47b4SNicolas Souchu #define SMB_BWRITE	_IOW('i', 10, struct smbcmd)
737048a99cSJohn Baldwin #define SMB_OLD_BREAD	_IOW('i', 11, struct smbcmd)
747048a99cSJohn Baldwin #define SMB_BREAD	_IOWR('i', 11, struct smbcmd)
75*202379afSMichael Gmelin #define SMB_TRANS	_IOWR('i', 12, struct smbcmd)
76b2dc47b4SNicolas Souchu 
77b2dc47b4SNicolas Souchu #endif
78