xref: /freebsd/sys/dev/iicbus/iicbb_if.m (revision d4280a0fab59c98c474452cf9c3d7417bd098e68)
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#
26c3aac50fSPeter Wemm# $FreeBSD$
2704f89a63SNicolas Souchu#
2804f89a63SNicolas Souchu
29f7b77691SDoug Rabson#include <sys/bus.h>
30f7b77691SDoug Rabson
317a8ecb9eSNicolas SouchuINTERFACE iicbb;
3204f89a63SNicolas Souchu
3304f89a63SNicolas Souchu#
34*d4280a0fSAlexander Kabaev# Default implementation of optional methods
35*d4280a0fSAlexander Kabaev#
36*d4280a0fSAlexander KabaevCODE {
37*d4280a0fSAlexander Kabaev	static int
38*d4280a0fSAlexander Kabaev	null_pre_xfer(device_t dev)
39*d4280a0fSAlexander Kabaev	{
40*d4280a0fSAlexander Kabaev		return 0;
41*d4280a0fSAlexander Kabaev	}
42*d4280a0fSAlexander Kabaev
43*d4280a0fSAlexander Kabaev	static void
44*d4280a0fSAlexander Kabaev	null_post_xfer(device_t dev)
45*d4280a0fSAlexander Kabaev
46*d4280a0fSAlexander Kabaev	{
47*d4280a0fSAlexander Kabaev	}
48*d4280a0fSAlexander Kabaev
49*d4280a0fSAlexander Kabaev	static int
50*d4280a0fSAlexander Kabaev	null_callback(device_t dev, int index, caddr_t data)
51*d4280a0fSAlexander Kabaev	{
52*d4280a0fSAlexander Kabaev		return 0;
53*d4280a0fSAlexander Kabaev	}
54*d4280a0fSAlexander Kabaev};
55*d4280a0fSAlexander Kabaev
56*d4280a0fSAlexander Kabaev#
5704f89a63SNicolas Souchu# iicbus callback
5804f89a63SNicolas Souchu#
5904f89a63SNicolas SouchuMETHOD int callback {
6004f89a63SNicolas Souchu	device_t dev;
6104f89a63SNicolas Souchu	int index;
6204f89a63SNicolas Souchu	caddr_t data;
63*d4280a0fSAlexander Kabaev} DEFAULT null_callback;
64*d4280a0fSAlexander Kabaev
65*d4280a0fSAlexander Kabaev#
66*d4280a0fSAlexander Kabaev# Prepare device for I2C transfer
67*d4280a0fSAlexander Kabaev#
68*d4280a0fSAlexander KabaevMETHOD int pre_xfer {
69*d4280a0fSAlexander Kabaev	device_t dev;
70*d4280a0fSAlexander Kabaev} DEFAULT null_pre_xfer;
71*d4280a0fSAlexander Kabaev
72*d4280a0fSAlexander Kabaev#
73*d4280a0fSAlexander Kabaev# Cleanup device after I2C transfer
74*d4280a0fSAlexander Kabaev#
75*d4280a0fSAlexander KabaevMETHOD void post_xfer {
76*d4280a0fSAlexander Kabaev	device_t dev;
77*d4280a0fSAlexander Kabaev} DEFAULT null_post_xfer;
7804f89a63SNicolas Souchu
7904f89a63SNicolas Souchu#
80c17d4340SNicolas Souchu# Set I2C bus data line
8104f89a63SNicolas Souchu#
82c17d4340SNicolas SouchuMETHOD void setsda {
8304f89a63SNicolas Souchu	device_t dev;
84c17d4340SNicolas Souchu	int val;
8504f89a63SNicolas Souchu};
8604f89a63SNicolas Souchu
8704f89a63SNicolas Souchu#
88c17d4340SNicolas Souchu# Set I2C bus clock line
89c17d4340SNicolas Souchu#
90c17d4340SNicolas SouchuMETHOD void setscl {
91c17d4340SNicolas Souchu	device_t dev;
92c17d4340SNicolas Souchu	int val;
93c17d4340SNicolas Souchu};
94c17d4340SNicolas Souchu
95c17d4340SNicolas Souchu#
96c17d4340SNicolas Souchu# Get I2C bus data line
9704f89a63SNicolas Souchu#
9804f89a63SNicolas Souchu#
99c17d4340SNicolas SouchuMETHOD int getsda {
100c17d4340SNicolas Souchu	device_t dev;
101c17d4340SNicolas Souchu};
102c17d4340SNicolas Souchu
103c17d4340SNicolas Souchu#
104c17d4340SNicolas Souchu# Get I2C bus clock line
105c17d4340SNicolas Souchu#
106c17d4340SNicolas Souchu#
107c17d4340SNicolas SouchuMETHOD int getscl {
10804f89a63SNicolas Souchu	device_t dev;
10904f89a63SNicolas Souchu};
11004f89a63SNicolas Souchu
11104f89a63SNicolas Souchu#
11204f89a63SNicolas Souchu# Reset interface
11304f89a63SNicolas Souchu#
11404f89a63SNicolas SouchuMETHOD int reset {
11504f89a63SNicolas Souchu	device_t dev;
11604f89a63SNicolas Souchu	u_char speed;
11704f89a63SNicolas Souchu	u_char addr;
11804f89a63SNicolas Souchu	u_char *oldaddr;
11904f89a63SNicolas Souchu};
120