ki2cvar.h revision 1.2.18.2 1 1.2.18.2 yamt /* $NetBSD: ki2cvar.h,v 1.2.18.2 2006/06/21 14:53:13 yamt Exp $ */
2 1.2.18.2 yamt /* Id: ki2c.c,v 1.7 2002/10/05 09:56:05 tsubai Exp */
3 1.2.18.2 yamt
4 1.2.18.2 yamt /*-
5 1.2.18.2 yamt * Copyright (c) 2001 Tsubai Masanari. All rights reserved.
6 1.2.18.2 yamt *
7 1.2.18.2 yamt * Redistribution and use in source and binary forms, with or without
8 1.2.18.2 yamt * modification, are permitted provided that the following conditions
9 1.2.18.2 yamt * are met:
10 1.2.18.2 yamt * 1. Redistributions of source code must retain the above copyright
11 1.2.18.2 yamt * notice, this list of conditions and the following disclaimer.
12 1.2.18.2 yamt * 2. Redistributions in binary form must reproduce the above copyright
13 1.2.18.2 yamt * notice, this list of conditions and the following disclaimer in the
14 1.2.18.2 yamt * documentation and/or other materials provided with the distribution.
15 1.2.18.2 yamt * 3. The name of the author may not be used to endorse or promote products
16 1.2.18.2 yamt * derived from this software without specific prior written permission.
17 1.2.18.2 yamt *
18 1.2.18.2 yamt * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
19 1.2.18.2 yamt * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
20 1.2.18.2 yamt * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
21 1.2.18.2 yamt * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
22 1.2.18.2 yamt * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
23 1.2.18.2 yamt * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24 1.2.18.2 yamt * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25 1.2.18.2 yamt * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26 1.2.18.2 yamt * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
27 1.2.18.2 yamt * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 1.2.18.2 yamt */
29 1.2.18.2 yamt
30 1.2.18.2 yamt #ifndef KI2CVAR_H
31 1.2.18.2 yamt #define KI2CVAR_H
32 1.2.18.2 yamt
33 1.2.18.2 yamt #include <sys/param.h>
34 1.2.18.2 yamt #include <sys/device.h>
35 1.2.18.2 yamt #include <sys/systm.h>
36 1.2.18.2 yamt
37 1.2.18.2 yamt #include <dev/i2c/i2cvar.h>
38 1.2.18.2 yamt
39 1.2.18.2 yamt /* Keywest I2C Register offsets */
40 1.2.18.2 yamt #define MODE 0
41 1.2.18.2 yamt #define CONTROL 1
42 1.2.18.2 yamt #define STATUS 2
43 1.2.18.2 yamt #define ISR 3
44 1.2.18.2 yamt #define IER 4
45 1.2.18.2 yamt #define ADDR 5
46 1.2.18.2 yamt #define SUBADDR 6
47 1.2.18.2 yamt #define DATA 7
48 1.2.18.2 yamt
49 1.2.18.2 yamt /* MODE */
50 1.2.18.2 yamt #define I2C_SPEED 0x03 /* Speed mask */
51 1.2.18.2 yamt #define I2C_100kHz 0x00
52 1.2.18.2 yamt #define I2C_50kHz 0x01
53 1.2.18.2 yamt #define I2C_25kHz 0x02
54 1.2.18.2 yamt #define I2C_MODE 0x0c /* Mode mask */
55 1.2.18.2 yamt #define I2C_DUMBMODE 0x00 /* Dumb mode */
56 1.2.18.2 yamt #define I2C_STDMODE 0x04 /* Standard mode */
57 1.2.18.2 yamt #define I2C_STDSUBMODE 0x08 /* Standard mode + sub address */
58 1.2.18.2 yamt #define I2C_COMBMODE 0x0c /* Combined mode */
59 1.2.18.2 yamt #define I2C_PORT 0xf0 /* Port mask */
60 1.2.18.2 yamt
61 1.2.18.2 yamt /* CONTROL */
62 1.2.18.2 yamt #define I2C_CT_AAK 0x01 /* Send AAK */
63 1.2.18.2 yamt #define I2C_CT_ADDR 0x02 /* Send address(es) */
64 1.2.18.2 yamt #define I2C_CT_STOP 0x04 /* Send STOP */
65 1.2.18.2 yamt #define I2C_CT_START 0x08 /* Send START */
66 1.2.18.2 yamt
67 1.2.18.2 yamt /* STATUS */
68 1.2.18.2 yamt #define I2C_ST_BUSY 0x01 /* Busy */
69 1.2.18.2 yamt #define I2C_ST_LASTAAK 0x02 /* Last AAK */
70 1.2.18.2 yamt #define I2C_ST_LASTRW 0x04 /* Last R/W */
71 1.2.18.2 yamt #define I2C_ST_SDA 0x08 /* SDA */
72 1.2.18.2 yamt #define I2C_ST_SCL 0x10 /* SCL */
73 1.2.18.2 yamt
74 1.2.18.2 yamt /* ISR/IER */
75 1.2.18.2 yamt #define I2C_INT_DATA 0x01 /* Data byte sent/received */
76 1.2.18.2 yamt #define I2C_INT_ADDR 0x02 /* Address sent */
77 1.2.18.2 yamt #define I2C_INT_STOP 0x04 /* STOP condition sent */
78 1.2.18.2 yamt #define I2C_INT_START 0x08 /* START condition sent */
79 1.2.18.2 yamt
80 1.2.18.2 yamt /* I2C flags */
81 1.2.18.2 yamt #define I2C_BUSY 0x01
82 1.2.18.2 yamt #define I2C_READING 0x02
83 1.2.18.2 yamt #define I2C_ERROR 0x04
84 1.2.18.2 yamt
85 1.2.18.2 yamt struct ki2c_softc {
86 1.2.18.2 yamt struct device sc_dev;
87 1.2.18.2 yamt u_char *sc_reg;
88 1.2.18.2 yamt int sc_regstep;
89 1.2.18.2 yamt
90 1.2.18.2 yamt struct i2c_controller sc_i2c;
91 1.2.18.2 yamt struct lock sc_buslock;
92 1.2.18.2 yamt
93 1.2.18.2 yamt int sc_flags;
94 1.2.18.2 yamt u_char *sc_data;
95 1.2.18.2 yamt int sc_resid;
96 1.2.18.2 yamt };
97 1.2.18.2 yamt
98 1.2.18.2 yamt struct ki2c_confargs {
99 1.2.18.2 yamt char *ka_name; /* device name */
100 1.2.18.2 yamt int ka_node;
101 1.2.18.2 yamt i2c_tag_t ka_tag; /* our controller */
102 1.2.18.2 yamt i2c_addr_t ka_addr; /* address of device */
103 1.2.18.2 yamt };
104 1.2.18.2 yamt
105 1.2.18.2 yamt #endif
106