xref: /dragonfly/sys/bus/iicbus/iicbus_if.m (revision 86d7f5d3)
1*86d7f5d3SJohn Marino#-
2*86d7f5d3SJohn Marino# Copyright (c) 1998 Nicolas Souchu
3*86d7f5d3SJohn Marino# All rights reserved.
4*86d7f5d3SJohn Marino#
5*86d7f5d3SJohn Marino# Redistribution and use in source and binary forms, with or without
6*86d7f5d3SJohn Marino# modification, are permitted provided that the following conditions
7*86d7f5d3SJohn Marino# are met:
8*86d7f5d3SJohn Marino# 1. Redistributions of source code must retain the above copyright
9*86d7f5d3SJohn Marino#    notice, this list of conditions and the following disclaimer.
10*86d7f5d3SJohn Marino# 2. Redistributions in binary form must reproduce the above copyright
11*86d7f5d3SJohn Marino#    notice, this list of conditions and the following disclaimer in the
12*86d7f5d3SJohn Marino#    documentation and/or other materials provided with the distribution.
13*86d7f5d3SJohn Marino#
14*86d7f5d3SJohn Marino# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15*86d7f5d3SJohn Marino# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16*86d7f5d3SJohn Marino# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17*86d7f5d3SJohn Marino# ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
18*86d7f5d3SJohn Marino# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19*86d7f5d3SJohn Marino# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20*86d7f5d3SJohn Marino# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21*86d7f5d3SJohn Marino# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22*86d7f5d3SJohn Marino# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23*86d7f5d3SJohn Marino# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24*86d7f5d3SJohn Marino# SUCH DAMAGE.
25*86d7f5d3SJohn Marino#
26*86d7f5d3SJohn Marino# $FreeBSD: src/sys/dev/iicbus/iicbus_if.m,v 1.8 2006/12/05 06:19:36 imp Exp $
27*86d7f5d3SJohn Marino# $DragonFly: src/sys/bus/iicbus/iicbus_if.m,v 1.3 2003/11/17 00:54:39 asmodai Exp $
28*86d7f5d3SJohn Marino#
29*86d7f5d3SJohn Marino
30*86d7f5d3SJohn Marino#include <sys/bus.h>
31*86d7f5d3SJohn Marino#include <bus/iicbus/iic.h>
32*86d7f5d3SJohn Marino
33*86d7f5d3SJohn MarinoINTERFACE iicbus;
34*86d7f5d3SJohn Marino
35*86d7f5d3SJohn Marino#
36*86d7f5d3SJohn Marino# Interpret interrupt
37*86d7f5d3SJohn Marino#
38*86d7f5d3SJohn MarinoMETHOD int intr {
39*86d7f5d3SJohn Marino	device_t dev;
40*86d7f5d3SJohn Marino	int event;
41*86d7f5d3SJohn Marino	char *buf;
42*86d7f5d3SJohn Marino};
43*86d7f5d3SJohn Marino
44*86d7f5d3SJohn Marino#
45*86d7f5d3SJohn Marino# iicbus callback
46*86d7f5d3SJohn Marino#
47*86d7f5d3SJohn MarinoMETHOD int callback {
48*86d7f5d3SJohn Marino	device_t dev;
49*86d7f5d3SJohn Marino	int index;
50*86d7f5d3SJohn Marino	caddr_t data;
51*86d7f5d3SJohn Marino};
52*86d7f5d3SJohn Marino
53*86d7f5d3SJohn Marino#
54*86d7f5d3SJohn Marino# Send REPEATED_START condition
55*86d7f5d3SJohn Marino#
56*86d7f5d3SJohn MarinoMETHOD int repeated_start {
57*86d7f5d3SJohn Marino	device_t dev;
58*86d7f5d3SJohn Marino	u_char slave;
59*86d7f5d3SJohn Marino	int timeout;
60*86d7f5d3SJohn Marino};
61*86d7f5d3SJohn Marino
62*86d7f5d3SJohn Marino#
63*86d7f5d3SJohn Marino# Send START condition
64*86d7f5d3SJohn Marino#
65*86d7f5d3SJohn MarinoMETHOD int start {
66*86d7f5d3SJohn Marino	device_t dev;
67*86d7f5d3SJohn Marino	u_char slave;
68*86d7f5d3SJohn Marino	int timeout;
69*86d7f5d3SJohn Marino};
70*86d7f5d3SJohn Marino
71*86d7f5d3SJohn Marino#
72*86d7f5d3SJohn Marino# Send STOP condition
73*86d7f5d3SJohn Marino#
74*86d7f5d3SJohn MarinoMETHOD int stop {
75*86d7f5d3SJohn Marino	device_t dev;
76*86d7f5d3SJohn Marino};
77*86d7f5d3SJohn Marino
78*86d7f5d3SJohn Marino#
79*86d7f5d3SJohn Marino# Read from I2C bus
80*86d7f5d3SJohn Marino#
81*86d7f5d3SJohn MarinoMETHOD int read {
82*86d7f5d3SJohn Marino	device_t dev;
83*86d7f5d3SJohn Marino	char *buf;
84*86d7f5d3SJohn Marino	int len;
85*86d7f5d3SJohn Marino	int *bytes;
86*86d7f5d3SJohn Marino	int last;
87*86d7f5d3SJohn Marino	int delay;
88*86d7f5d3SJohn Marino};
89*86d7f5d3SJohn Marino
90*86d7f5d3SJohn Marino#
91*86d7f5d3SJohn Marino# Write to the I2C bus
92*86d7f5d3SJohn Marino#
93*86d7f5d3SJohn MarinoMETHOD int write {
94*86d7f5d3SJohn Marino	device_t dev;
95*86d7f5d3SJohn Marino	const char *buf;
96*86d7f5d3SJohn Marino	int len;
97*86d7f5d3SJohn Marino	int *bytes;
98*86d7f5d3SJohn Marino	int timeout;
99*86d7f5d3SJohn Marino};
100*86d7f5d3SJohn Marino
101*86d7f5d3SJohn Marino#
102*86d7f5d3SJohn Marino# Reset I2C bus
103*86d7f5d3SJohn Marino#
104*86d7f5d3SJohn MarinoMETHOD int reset {
105*86d7f5d3SJohn Marino	device_t dev;
106*86d7f5d3SJohn Marino	u_char speed;
107*86d7f5d3SJohn Marino	u_char addr;
108*86d7f5d3SJohn Marino	u_char *oldaddr;
109*86d7f5d3SJohn Marino};
110*86d7f5d3SJohn Marino
111*86d7f5d3SJohn Marino#
112*86d7f5d3SJohn Marino# Generalized Read/Write interface
113*86d7f5d3SJohn Marino#
114*86d7f5d3SJohn MarinoMETHOD int transfer {
115*86d7f5d3SJohn Marino	device_t dev;
116*86d7f5d3SJohn Marino	struct iic_msg *msgs;
117*86d7f5d3SJohn Marino	uint32_t nmsgs;
118*86d7f5d3SJohn Marino};
119