xref: /freebsd/sys/dev/iicbus/iicbb_if.m (revision 031beb4e239bfce798af17f5fe8dba8bcaf13d99)
1098ca2bdSWarner Losh#-
204f89a63SNicolas Souchu# Copyright (c) 1998 Nicolas Souchu
304f89a63SNicolas Souchu# All rights reserved.
404f89a63SNicolas Souchu#
504f89a63SNicolas Souchu# Redistribution and use in source and binary forms, with or without
604f89a63SNicolas Souchu# modification, are permitted provided that the following conditions
704f89a63SNicolas Souchu# are met:
804f89a63SNicolas Souchu# 1. Redistributions of source code must retain the above copyright
904f89a63SNicolas Souchu#    notice, this list of conditions and the following disclaimer.
1004f89a63SNicolas Souchu# 2. Redistributions in binary form must reproduce the above copyright
1104f89a63SNicolas Souchu#    notice, this list of conditions and the following disclaimer in the
1204f89a63SNicolas Souchu#    documentation and/or other materials provided with the distribution.
1304f89a63SNicolas Souchu#
1404f89a63SNicolas Souchu# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
1504f89a63SNicolas Souchu# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
1604f89a63SNicolas Souchu# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
1704f89a63SNicolas Souchu# ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
1804f89a63SNicolas Souchu# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
1904f89a63SNicolas Souchu# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
2004f89a63SNicolas Souchu# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
2104f89a63SNicolas Souchu# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
2204f89a63SNicolas Souchu# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2304f89a63SNicolas Souchu# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2404f89a63SNicolas Souchu# SUCH DAMAGE.
2504f89a63SNicolas Souchu#
2604f89a63SNicolas Souchu#
2704f89a63SNicolas Souchu
28f7b77691SDoug Rabson#include <sys/bus.h>
29f7b77691SDoug Rabson
307a8ecb9eSNicolas SouchuINTERFACE iicbb;
3104f89a63SNicolas Souchu
3204f89a63SNicolas Souchu#
33*d4280a0fSAlexander Kabaev# Default implementation of optional methods
34*d4280a0fSAlexander Kabaev#
35*d4280a0fSAlexander KabaevCODE {
36*d4280a0fSAlexander Kabaev	static int
37*d4280a0fSAlexander Kabaev	null_pre_xfer(device_t dev)
38*d4280a0fSAlexander Kabaev	{
39*d4280a0fSAlexander Kabaev		return 0;
40*d4280a0fSAlexander Kabaev	}
41*d4280a0fSAlexander Kabaev
42*d4280a0fSAlexander Kabaev	static void
43*d4280a0fSAlexander Kabaev	null_post_xfer(device_t dev)
44*d4280a0fSAlexander Kabaev	{
45*d4280a0fSAlexander Kabaev	}
46*d4280a0fSAlexander Kabaev
47*d4280a0fSAlexander Kabaev	static int
48*d4280a0fSAlexander Kabaev	null_callback(device_t dev, int index, caddr_t data)
49*d4280a0fSAlexander Kabaev	{
50*d4280a0fSAlexander Kabaev		return 0;
51*d4280a0fSAlexander Kabaev	}
52*d4280a0fSAlexander Kabaev};
53*d4280a0fSAlexander Kabaev
54*d4280a0fSAlexander Kabaev#
5504f89a63SNicolas Souchu# iicbus callback
5604f89a63SNicolas Souchu#
5704f89a63SNicolas SouchuMETHOD int callback {
5804f89a63SNicolas Souchu	device_t dev;
5904f89a63SNicolas Souchu	int index;
6004f89a63SNicolas Souchu	caddr_t data;
61*d4280a0fSAlexander Kabaev} DEFAULT null_callback;
62*d4280a0fSAlexander Kabaev
63*d4280a0fSAlexander Kabaev#
64*d4280a0fSAlexander Kabaev# Prepare device for I2C transfer
65*d4280a0fSAlexander Kabaev#
66*d4280a0fSAlexander KabaevMETHOD int pre_xfer {
67*d4280a0fSAlexander Kabaev	device_t dev;
68*d4280a0fSAlexander Kabaev} DEFAULT null_pre_xfer;
69*d4280a0fSAlexander Kabaev
70*d4280a0fSAlexander Kabaev#
71*d4280a0fSAlexander Kabaev# Cleanup device after I2C transfer
72*d4280a0fSAlexander Kabaev#
73*d4280a0fSAlexander KabaevMETHOD void post_xfer {
74*d4280a0fSAlexander Kabaev	device_t dev;
75*d4280a0fSAlexander Kabaev} DEFAULT null_post_xfer;
7604f89a63SNicolas Souchu
7704f89a63SNicolas Souchu#
78c17d4340SNicolas Souchu# Set I2C bus data line
7904f89a63SNicolas Souchu#
80c17d4340SNicolas SouchuMETHOD void setsda {
8104f89a63SNicolas Souchu	device_t dev;
82c17d4340SNicolas Souchu	int val;
8304f89a63SNicolas Souchu};
8404f89a63SNicolas Souchu
8504f89a63SNicolas Souchu#
86c17d4340SNicolas Souchu# Set I2C bus clock line
87c17d4340SNicolas Souchu#
88c17d4340SNicolas SouchuMETHOD void setscl {
89c17d4340SNicolas Souchu	device_t dev;
90c17d4340SNicolas Souchu	int val;
91c17d4340SNicolas Souchu};
92c17d4340SNicolas Souchu
93c17d4340SNicolas Souchu#
94c17d4340SNicolas Souchu# Get I2C bus data line
9504f89a63SNicolas Souchu#
9604f89a63SNicolas Souchu#
97c17d4340SNicolas SouchuMETHOD int getsda {
98c17d4340SNicolas Souchu	device_t dev;
99c17d4340SNicolas Souchu};
100c17d4340SNicolas Souchu
101c17d4340SNicolas Souchu#
102c17d4340SNicolas Souchu# Get I2C bus clock line
103c17d4340SNicolas Souchu#
104c17d4340SNicolas Souchu#
105c17d4340SNicolas SouchuMETHOD int getscl {
10604f89a63SNicolas Souchu	device_t dev;
10704f89a63SNicolas Souchu};
10804f89a63SNicolas Souchu
10904f89a63SNicolas Souchu#
11004f89a63SNicolas Souchu# Reset interface
11104f89a63SNicolas Souchu#
11204f89a63SNicolas SouchuMETHOD int reset {
11304f89a63SNicolas Souchu	device_t dev;
11404f89a63SNicolas Souchu	u_char speed;
11504f89a63SNicolas Souchu	u_char addr;
11604f89a63SNicolas Souchu	u_char *oldaddr;
11704f89a63SNicolas Souchu};
118