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