xref: /dragonfly/sys/bus/smbus/smbconf.h (revision c9f721c2)
1 /*-
2  * Copyright (c) 1998 Nicolas Souchu
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  * 1. Redistributions of source code must retain the above copyright
9  *    notice, this list of conditions and the following disclaimer.
10  * 2. Redistributions in binary form must reproduce the above copyright
11  *    notice, this list of conditions and the following disclaimer in the
12  *    documentation and/or other materials provided with the distribution.
13  *
14  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
18  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24  * SUCH DAMAGE.
25  *
26  * $FreeBSD: src/sys/dev/smbus/smbconf.h,v 1.7 2002/03/23 15:47:28 nsouch Exp $
27  * $DragonFly: src/sys/bus/smbus/smbconf.h,v 1.4 2003/11/14 21:46:18 daver Exp $
28  */
29 #ifndef __SMBONF_H
30 #define __SMBONF_H
31 
32 #include <sys/queue.h>
33 
34 #define n(flags) (~(flags) & (flags))
35 
36 /*
37  * How tsleep() is called in smb_request_bus().
38  */
39 #define SMB_DONTWAIT	0
40 #define SMB_NOINTR	0
41 #define SMB_WAIT	0x1
42 #define SMB_INTR	0x2
43 
44 /*
45  * callback index
46  */
47 #define SMB_REQUEST_BUS	0x1
48 #define SMB_RELEASE_BUS	0x2
49 
50 /*
51  * SMB bus errors
52  */
53 #define SMB_ENOERR	0x0
54 #define SMB_EBUSERR	0x1
55 #define SMB_ENOTSUPP	0x2
56 #define SMB_ENOACK	0x4
57 #define SMB_ECOLLI	0x8
58 #define SMB_EABORT	0x10
59 #define SMB_ETIMEOUT	0x20
60 #define SMB_EBUSY	0x40
61 
62 /*
63  * How Quick command is executed
64  */
65 #define SMB_QWRITE	0x0
66 #define SMB_QREAD	0x1
67 
68 /*
69  * ivars codes
70  */
71 #define SMBUS_IVAR_ADDR	0x1	/* I2C address of the device */
72 
73 extern int smbus_request_bus(device_t, device_t, int);
74 extern int smbus_release_bus(device_t, device_t);
75 extern device_t smbus_alloc_bus(device_t);
76 extern int smbus_error(int error);
77 
78 extern void smbus_intr(device_t, u_char, char low, char high, int error);
79 
80 extern u_char smbus_get_addr(device_t);
81 
82 #define smbus_quick(bus,slave,how) \
83 	(SMBUS_QUICK(device_get_parent(bus), slave, how))
84 #define smbus_sendb(bus,slave,byte) \
85 	(SMBUS_SENDB(device_get_parent(bus), slave, byte))
86 #define smbus_recvb(bus,slave,byte) \
87 	(SMBUS_RECVB(device_get_parent(bus), slave, byte))
88 #define smbus_writeb(bus,slave,cmd,byte) \
89 	(SMBUS_WRITEB(device_get_parent(bus), slave, cmd, byte))
90 #define smbus_writew(bus,slave,cmd,word) \
91 	(SMBUS_WRITEW(device_get_parent(bus), slave, cmd, word))
92 #define smbus_readb(bus,slave,cmd,byte) \
93 	(SMBUS_READB(device_get_parent(bus), slave, cmd, byte))
94 #define smbus_readw(bus,slave,cmd,word) \
95 	(SMBUS_READW(device_get_parent(bus), slave, cmd, word))
96 #define smbus_pcall(bus,slave,cmd,sdata,rdata) \
97 	(SMBUS_PCALL(device_get_parent(bus), slave, cmd, sdata, rdata))
98 #define smbus_bwrite(bus,slave,cmd,count,buf) \
99 	(SMBUS_BWRITE(device_get_parent(bus), slave, cmd, count, buf))
100 #define smbus_bread(bus,slave,cmd,count,buf) \
101 	(SMBUS_BREAD(device_get_parent(bus), slave, cmd, count, buf))
102 
103 #define SMBUS_MODVER   1
104 #define SMBUS_MINVER   1
105 #define SMBUS_MAXVER   1
106 #define SMBUS_PREFVER  SMBUS_MODVER
107 
108 #endif
109