gttwsireg.h revision 1.3.28.1 1 1.3.28.1 ad /* $NetBSD: gttwsireg.h,v 1.3.28.1 2020/01/17 21:47:31 ad Exp $ */
2 1.1 matt
3 1.1 matt /*
4 1.1 matt * Copyright (c) 2008 Eiji Kawauchi.
5 1.1 matt * All rights reserved.
6 1.1 matt *
7 1.1 matt * Redistribution and use in source and binary forms, with or without
8 1.1 matt * modification, are permitted provided that the following conditions
9 1.1 matt * are met:
10 1.1 matt * 1. Redistributions of source code must retain the above copyright
11 1.1 matt * notice, this list of conditions and the following disclaimer.
12 1.1 matt * 2. Redistributions in binary form must reproduce the above copyright
13 1.1 matt * notice, this list of conditions and the following disclaimer in the
14 1.1 matt * documentation and/or other materials provided with the distribution.
15 1.1 matt *
16 1.1 matt * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
17 1.1 matt * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
18 1.1 matt * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
19 1.1 matt * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
20 1.1 matt * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
21 1.1 matt * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
22 1.1 matt * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
23 1.1 matt * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 1.1 matt * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
25 1.1 matt * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 1.1 matt */
27 1.1 matt #ifndef _GTTWSIREG_H_
28 1.1 matt #define _GTTWSIREG_H_
29 1.1 matt
30 1.1 matt #define GTTWSI_SIZE 0x100
31 1.3.28.1 ad #define GTTWSI_NREGS 7
32 1.1 matt
33 1.3.28.1 ad /* reg map indices */
34 1.3.28.1 ad #define TWSI_SLAVEADDR 0
35 1.3.28.1 ad #define TWSI_EXTEND_SLAVEADDR 1
36 1.3.28.1 ad #define TWSI_DATA 2
37 1.3.28.1 ad #define TWSI_CONTROL 3
38 1.3.28.1 ad #define TWSI_STATUS 4
39 1.3.28.1 ad #define TWSI_BAUDRATE 5
40 1.3.28.1 ad #define TWSI_SOFTRESET 6
41 1.3.28.1 ad
42 1.3.28.1 ad /* register offsets for Allwinner implementations */
43 1.3.28.1 ad #define TWSI_ALLWINNER_SLAVEADDR 0x00
44 1.3.28.1 ad #define TWSI_ALLWINNER_EXTEND_SLAVEADDR 0x04
45 1.3.28.1 ad #define TWSI_ALLWINNER_DATA 0x08
46 1.3.28.1 ad #define TWSI_ALLWINNER_CONTROL 0x0c
47 1.3.28.1 ad #define TWSI_ALLWINNER_STATUS 0x10
48 1.3.28.1 ad #define TWSI_ALLWINNER_BAUDRATE 0x14
49 1.3.28.1 ad #define TWSI_ALLWINNER_SOFTRESET 0x18
50 1.3.28.1 ad #define TWSI_ALLWINNER_ENH_FEAT 0x1c
51 1.3.28.1 ad #define TWSI_ALLWINNER_LINE_CTRL 0x20
52 1.3.28.1 ad
53 1.3.28.1 ad /* register offsets for Marvell implementations */
54 1.3.28.1 ad #define TWSI_MARVELL_SLAVEADDR 0x00
55 1.3.28.1 ad #define TWSI_MARVELL_EXTEND_SLAVEADDR 0x10
56 1.3.28.1 ad #define TWSI_MARVELL_DATA 0x04
57 1.3.28.1 ad #define TWSI_MARVELL_CONTROL 0x08
58 1.3.28.1 ad #define TWSI_MARVELL_STATUS 0x0c /* for read */
59 1.3.28.1 ad #define TWSI_MARVELL_BAUDRATE 0x0c /* for write */
60 1.3.28.1 ad #define TWSI_MARVELL_SOFTRESET 0x1c
61 1.1 matt
62 1.1 matt #define SLAVEADDR_GCE_MASK 0x01
63 1.1 matt #define SLAVEADDR_SADDR_MASK 0xfe
64 1.1 matt
65 1.1 matt #define EXTEND_SLAVEADDR_MASK 0xff
66 1.1 matt
67 1.1 matt #define DATA_MASK 0xff
68 1.1 matt
69 1.1 matt #define CONTROL_ACK (1<<2)
70 1.1 matt #define CONTROL_IFLG (1<<3)
71 1.1 matt #define CONTROL_STOP (1<<4)
72 1.1 matt #define CONTROL_START (1<<5)
73 1.1 matt #define CONTROL_TWSIEN (1<<6)
74 1.1 matt #define CONTROL_INTEN (1<<7)
75 1.1 matt
76 1.1 matt #define STAT_BE 0x00 /* Bus Error */
77 1.1 matt #define STAT_SCT 0x08 /* Start condition transmitted */
78 1.1 matt #define STAT_RSCT 0x10 /* Repeated start condition transmitted */
79 1.1 matt #define STAT_AWBT_AR 0x18 /* Address + write bit transd, ack recvd */
80 1.1 matt #define STAT_AWBT_ANR 0x20 /* Address + write bit transd, ack not recvd */
81 1.1 matt #define STAT_MTDB_AR 0x28 /* Master transd data byte, ack recvd */
82 1.1 matt #define STAT_MTDB_ANR 0x30 /* Master transd data byte, ack not recvd */
83 1.1 matt #define STAT_MLADADT 0x38 /* Master lost arbitr during addr or data tx */
84 1.1 matt #define STAT_ARBT_AR 0x40 /* Address + read bit transd, ack recvd */
85 1.1 matt #define STAT_ARBT_ANR 0x48 /* Address + read bit transd, ack not recvd */
86 1.1 matt #define STAT_MRRD_AT 0x50 /* Master received read data, ack transd */
87 1.1 matt #define STAT_MRRD_ANT 0x58 /* Master received read data, ack not transd */
88 1.1 matt #define STAT_SAWBT_AR 0xd0 /* Second addr + write bit transd, ack recvd */
89 1.1 matt #define STAT_SAWBT_ANR 0xd8 /* S addr + write bit transd, ack not recvd */
90 1.1 matt #define STAT_SARBT_AR 0xe0 /* Second addr + read bit transd, ack recvd */
91 1.1 matt #define STAT_SARBT_ANR 0xe8 /* S addr + read bit transd, ack not recvd */
92 1.1 matt #define STAT_NRS 0xf8 /* No relevant status */
93 1.1 matt
94 1.1 matt #define SOFTRESET_VAL 0 /* reset value */
95 1.1 matt
96 1.1 matt #define TWSI_RETRY_COUNT 1000 /* retry loop count */
97 1.1 matt #define TWSI_RETRY_DELAY 1 /* retry delay */
98 1.1 matt #define TWSI_STAT_DELAY 1 /* poll status delay */
99 1.1 matt #define TWSI_READ_DELAY 2 /* read delay */
100 1.1 matt #define TWSI_WRITE_DELAY 2 /* write delay */
101 1.1 matt
102 1.1 matt #endif /* _GTTWSIREG_H_ */
103