xref: /illumos-gate/usr/src/uts/sun4u/sys/i2c/clients/ssc100_impl.h (revision 69a119caa6570c7077699161b7c28b6ee9f8b0f4)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License, Version 1.0 only
6  * (the "License").  You may not use this file except in compliance
7  * with the License.
8  *
9  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10  * or http://www.opensolaris.org/os/licensing.
11  * See the License for the specific language governing permissions
12  * and limitations under the License.
13  *
14  * When distributing Covered Code, include this CDDL HEADER in each
15  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16  * If applicable, add the following below this CDDL HEADER, with the
17  * fields enclosed by brackets "[]" replaced with your own identifying
18  * information: Portions Copyright [yyyy] [name of copyright owner]
19  *
20  * CDDL HEADER END
21  */
22 /*
23  * Copyright (c) 2000 by Sun Microsystems, Inc.
24  * All rights reserved.
25  */
26 
27 #ifndef	_SSC100_IMPL_H
28 #define	_SSC100_IMPL_H
29 
30 #pragma ident	"%Z%%M%	%I%	%E% SMI"
31 
32 #ifdef	__cplusplus
33 extern "C" {
34 #endif
35 
36 #include <sys/i2c/clients/i2c_client.h>
37 
38 /*
39  * SSC100_BIT_READ_MASK takes in a byte from the device and the bit that
40  * the user wants to read.  I shifts the byte over so that the bit that we
41  * want is in the 1's bit and masks out the rest of the byte.
42  */
43 #define	SSC100_BIT_READ_MASK(byte, bit)	((byte >> bit) & 0x01)
44 
45 /*
46  * SSC100_BIT_WRITE_MASK takes in a byte from the device, the bit that the
47  * user wants to read write, and the value that the user wants put into that
48  * bit. It zero's out the bit that we are writing to in the byte and then or's
49  * the value(which was shifted to the bit location we wanted) to fill in only
50  * that bit in the byte
51  */
52 #define	SSC100_BIT_WRITE_MASK(byte, bit, value)\
53 				((value << bit) | (byte & (~(0x01 << bit))))
54 
55 #define	SSC100_SIZE		8192
56 #define	SSC100_PAGESIZE		32
57 #define	SSC100_PAGEMASK		(SSC100_PAGESIZE - 1)
58 
59 struct ssc100_unit {
60 	kmutex_t		ssc100_mutex;
61 	uint8_t			ssc100_flags;
62 	int			ssc100_oflag;
63 	int			ssc100_size;
64 	i2c_client_hdl_t	ssc100_hdl;
65 	char			ssc100_name[24];
66 };
67 
68 #ifdef DEBUG
69 
70 static int ssc100debug = 0;
71 #define	D1CMN_ERR(ARGS) if (ssc100debug & 0x1) cmn_err ARGS;
72 #define	D2CMN_ERR(ARGS) if (ssc100debug & 0x2) cmn_err ARGS;
73 
74 #else
75 
76 #define	D1CMN_ERR(ARGS)
77 #define	D2CMN_ERR(ARGS)
78 
79 #endif
80 
81 #ifdef	__cplusplus
82 }
83 #endif
84 
85 #endif	/* _SSC100_IMPL_H */
86