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