xref: /netbsd-src/sys/dev/i2c/gttwsivar.h (revision 92b1a40bcb4311ef82accebc963331d1c4e241d0)
1 /*	$NetBSD: gttwsivar.h,v 1.6 2020/01/12 17:48:42 thorpej Exp $	*/
2 /*
3  * Copyright (c) 2008 Eiji Kawauchi.
4  * All rights reserved.
5  *
6  * Redistribution and use in source and binary forms, with or without
7  * modification, are permitted provided that the following conditions
8  * are met:
9  * 1. Redistributions of source code must retain the above copyright
10  *    notice, this list of conditions and the following disclaimer.
11  * 2. Redistributions in binary form must reproduce the above copyright
12  *    notice, this list of conditions and the following disclaimer in the
13  *    documentation and/or other materials provided with the distribution.
14  * 3. All advertising materials mentioning features or use of this software
15  *    must display the following acknowledgement:
16  *      This product includes software developed for the NetBSD Project by
17  *      Eiji Kawauchi.
18  * 4. The name of the author may not be used to endorse or promote products
19  *    derived from this software without specific prior written permission
20  *
21  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
22  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
23  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
24  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
25  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
26  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
30  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31  */
32 /*
33  * Copyright (c) 2005 Brocade Communcations, inc.
34  * All rights reserved.
35  *
36  * Written by Matt Thomas for Brocade Communcations, Inc.
37  *
38  * Redistribution and use in source and binary forms, with or without
39  * modification, are permitted provided that the following conditions
40  * are met:
41  * 1. Redistributions of source code must retain the above copyright
42  *    notice, this list of conditions and the following disclaimer.
43  * 2. Redistributions in binary form must reproduce the above copyright
44  *    notice, this list of conditions and the following disclaimer in the
45  *    documentation and/or other materials provided with the distribution.
46  * 3. The name of Brocade Communications, Inc. may not be used to endorse
47  *    or promote products derived from this software without specific prior
48  *    written permission.
49  *
50  * THIS SOFTWARE IS PROVIDED BY BROCADE COMMUNICATIONS, INC. ``AS IS'' AND
51  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
52  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
53  * ARE DISCLAIMED.  IN NO EVENT SHALL EITHER BROCADE COMMUNICATIONS, INC. BE
54  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
55  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
56  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
57  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
58  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
59  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
60  * OF THE POSSIBILITY OF SUCH DAMAGE.
61  */
62 
63 #ifndef _DEV_MARVELL_GTTWSIVAR_H_
64 #define _DEV_MARVELL_GTTWSIVAR_H_
65 
66 /*
67  * Marvell Two-Wire Serial Interface (aka I2C) master driver
68  */
69 
70 #include <sys/param.h>
71 #include <sys/bus.h>
72 #include <sys/condvar.h>
73 #include <sys/device.h>
74 #include <sys/errno.h>
75 #include <sys/kernel.h>
76 #include <sys/mutex.h>
77 #include <sys/systm.h>
78 
79 #include <dev/i2c/i2cvar.h>
80 
81 struct gttwsi_softc {
82 	device_t sc_dev;
83 	bus_space_tag_t sc_bust;
84 	bus_space_handle_t sc_bush;
85 	bool sc_started;
86 	struct i2c_controller sc_i2c;
87 	kmutex_t sc_buslock;
88 	kmutex_t sc_mtx;
89 	kcondvar_t sc_cv;
90 
91 	const bus_size_t *sc_regmap;	/* GTTWSI_NREGS entries */
92 
93 	bool sc_iflg_rwc;
94 };
95 
96 void	gttwsi_attach_subr(device_t, bus_space_tag_t, bus_space_handle_t,
97 			   const bus_size_t *);
98 void	gttwsi_config_children(device_t);
99 
100 uint32_t gttwsi_read_4(struct gttwsi_softc *, uint32_t);
101 void	gttwsi_write_4(struct gttwsi_softc *, uint32_t, uint32_t);
102 
103 int	gttwsi_intr(void *);
104 
105 #endif /* _DEV_MARVELL_GTTSWI_VAR_H_ */
106