xref: /dragonfly/sys/bus/smbus/smbus_if.m (revision ef2b2b9d)
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/smbus_if.m,v 1.7.2.1 2006/09/22 19:19:16 jhb Exp $
27# $DragonFly: src/sys/bus/smbus/smbus_if.m,v 1.3 2003/11/17 00:54:39 asmodai Exp $
28#
29
30#include <sys/bus.h>
31
32INTERFACE smbus;
33
34#
35# Interpret interrupt
36#
37METHOD void intr {
38	device_t dev;
39	u_char devaddr;
40	char low;
41	char high;
42	int error;
43};
44
45#
46# smbus callback
47#
48METHOD int callback {
49	device_t dev;
50	int index;
51	void *data;
52};
53
54#
55# Quick command
56#
57METHOD int quick {
58	device_t dev;
59	u_char slave;
60	int how;
61};
62
63#
64# Send Byte command
65#
66METHOD int sendb {
67	device_t dev;
68	u_char slave;
69	char byte;
70};
71
72#
73# Receive Byte command
74#
75METHOD int recvb {
76	device_t dev;
77	u_char slave;
78	char *byte;
79};
80
81#
82# Write Byte command
83#
84METHOD int writeb {
85	device_t dev;
86	u_char slave;
87	char cmd;
88	char byte;
89};
90
91#
92# Write Word command
93#
94METHOD int writew {
95	device_t dev;
96	u_char slave;
97	char cmd;
98	short word;
99};
100
101#
102# Read Byte command
103#
104METHOD int readb {
105	device_t dev;
106	u_char slave;
107	char cmd;
108	char *byte;
109};
110
111#
112# Read Word command
113#
114METHOD int readw {
115	device_t dev;
116	u_char slave;
117	char cmd;
118	short *word;
119};
120
121#
122# Process Call command
123#
124METHOD int pcall {
125	device_t dev;
126	u_char slave;
127	char cmd;
128	short sdata;
129	short *rdata;
130};
131
132#
133# Block Write command
134#
135METHOD int bwrite {
136	device_t dev;
137	u_char slave;
138	char cmd;
139	u_char count;
140	char *buf;
141};
142
143#
144# Block Read command
145#
146METHOD int bread {
147	device_t dev;
148	u_char slave;
149	char cmd;
150	u_char *count;
151	char *buf;
152};
153
154#
155# SMB roll-up transaction with flags that also allow it to be
156# used for (mostly) i2c pass-through and with 10-bit addresses.
157# This function can be used to roll-up all of the above functions.
158#
159METHOD int trans {
160	device_t dev;
161	int	slave;
162	char	cmd;
163	int	op;
164	char	*wbuf;
165	int	wcount;
166	char	*rbuf;
167	int	rcount;
168	int	*actualp;
169}
170