blob: 9a0b126b387825c9f7d8d20f2dcacc79a07ab0b9 [file] [log] [blame]
Steve Sakoman10acc712010-06-12 06:42:57 -07001/*
2 * (C) Copyright 2004-2010
3 * Texas Instruments, <www.ti.com>
4 *
5 * See file CREDITS for list of people who contributed to this
6 * project.
7 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License as
10 * published by the Free Software Foundation; either version 2 of
11 * the License, or (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
21 * MA 02111-1307 USA
22 */
Nishanth Menond5002302010-08-18 19:39:07 -050023#ifndef _OMAP2PLUS_I2C_H_
24#define _OMAP2PLUS_I2C_H_
Steve Sakoman10acc712010-06-12 06:42:57 -070025
26/* I2C masks */
27
28/* I2C Interrupt Enable Register (I2C_IE): */
29#define I2C_IE_GC_IE (1 << 5)
30#define I2C_IE_XRDY_IE (1 << 4) /* Transmit data ready interrupt enable */
31#define I2C_IE_RRDY_IE (1 << 3) /* Receive data ready interrupt enable */
32#define I2C_IE_ARDY_IE (1 << 2) /* Register access ready interrupt enable */
33#define I2C_IE_NACK_IE (1 << 1) /* No acknowledgment interrupt enable */
34#define I2C_IE_AL_IE (1 << 0) /* Arbitration lost interrupt enable */
35
36/* I2C Status Register (I2C_STAT): */
37
38#define I2C_STAT_SBD (1 << 15) /* Single byte data */
39#define I2C_STAT_BB (1 << 12) /* Bus busy */
40#define I2C_STAT_ROVR (1 << 11) /* Receive overrun */
41#define I2C_STAT_XUDF (1 << 10) /* Transmit underflow */
42#define I2C_STAT_AAS (1 << 9) /* Address as slave */
43#define I2C_STAT_GC (1 << 5)
44#define I2C_STAT_XRDY (1 << 4) /* Transmit data ready */
45#define I2C_STAT_RRDY (1 << 3) /* Receive data ready */
46#define I2C_STAT_ARDY (1 << 2) /* Register access ready */
47#define I2C_STAT_NACK (1 << 1) /* No acknowledgment interrupt enable */
48#define I2C_STAT_AL (1 << 0) /* Arbitration lost interrupt enable */
49
50/* I2C Interrupt Code Register (I2C_INTCODE): */
51
52#define I2C_INTCODE_MASK 7
53#define I2C_INTCODE_NONE 0
54#define I2C_INTCODE_AL 1 /* Arbitration lost */
55#define I2C_INTCODE_NAK 2 /* No acknowledgement/general call */
56#define I2C_INTCODE_ARDY 3 /* Register access ready */
57#define I2C_INTCODE_RRDY 4 /* Rcv data ready */
58#define I2C_INTCODE_XRDY 5 /* Xmit data ready */
59
60/* I2C Buffer Configuration Register (I2C_BUF): */
61
62#define I2C_BUF_RDMA_EN (1 << 15) /* Receive DMA channel enable */
Patil, Rachnaa9e18c22012-01-22 23:44:12 +000063#define I2C_RXFIFO_CLEAR (1 << 14) /* RX FIFO Clear */
Steve Sakoman10acc712010-06-12 06:42:57 -070064#define I2C_BUF_XDMA_EN (1 << 7) /* Transmit DMA channel enable */
Patil, Rachnaa9e18c22012-01-22 23:44:12 +000065#define I2C_TXFIFO_CLEAR (1 << 6) /* TX FIFO clear */
Steve Sakoman10acc712010-06-12 06:42:57 -070066
67/* I2C Configuration Register (I2C_CON): */
68
69#define I2C_CON_EN (1 << 15) /* I2C module enable */
70#define I2C_CON_BE (1 << 14) /* Big endian mode */
71#define I2C_CON_STB (1 << 11) /* Start byte mode (master mode only) */
72#define I2C_CON_MST (1 << 10) /* Master/slave mode */
73#define I2C_CON_TRX (1 << 9) /* Transmitter/receiver mode */
74 /* (master mode only) */
75#define I2C_CON_XA (1 << 8) /* Expand address */
76#define I2C_CON_STP (1 << 1) /* Stop condition (master mode only) */
77#define I2C_CON_STT (1 << 0) /* Start condition (master mode only) */
78
79/* I2C System Test Register (I2C_SYSTEST): */
80
81#define I2C_SYSTEST_ST_EN (1 << 15) /* System test enable */
82#define I2C_SYSTEST_FREE (1 << 14) /* Free running mode, on brkpoint) */
83#define I2C_SYSTEST_TMODE_MASK (3 << 12) /* Test mode select */
84#define I2C_SYSTEST_TMODE_SHIFT (12) /* Test mode select */
85#define I2C_SYSTEST_SCL_I (1 << 3) /* SCL line sense input value */
86#define I2C_SYSTEST_SCL_O (1 << 2) /* SCL line drive output value */
87#define I2C_SYSTEST_SDA_I (1 << 1) /* SDA line sense input value */
88#define I2C_SYSTEST_SDA_O (1 << 0) /* SDA line drive output value */
89
Steve Sakomane2bdc132010-07-19 20:31:55 -070090/* I2C System Status Register (I2C_SYSS): */
91
92#define I2C_SYSS_RDONE (1 << 0) /* Internel reset monitoring */
93
Steve Sakoman10acc712010-06-12 06:42:57 -070094#define I2C_SCLL_SCLL 0
95#define I2C_SCLL_SCLL_M 0xFF
96#define I2C_SCLL_HSSCLL 8
97#define I2C_SCLH_HSSCLL_M 0xFF
98#define I2C_SCLH_SCLH 0
99#define I2C_SCLH_SCLH_M 0xFF
100#define I2C_SCLH_HSSCLH 8
101#define I2C_SCLH_HSSCLH_M 0xFF
102
103#define OMAP_I2C_STANDARD 100000
104#define OMAP_I2C_FAST_MODE 400000
105#define OMAP_I2C_HIGH_SPEED 3400000
106
107#define SYSTEM_CLOCK_12 12000000
108#define SYSTEM_CLOCK_13 13000000
109#define SYSTEM_CLOCK_192 19200000
110#define SYSTEM_CLOCK_96 96000000
111
112/* Use the reference value of 96MHz if not explicitly set by the board */
113#ifndef I2C_IP_CLK
114#define I2C_IP_CLK SYSTEM_CLOCK_96
115#endif
116
117/*
118 * The reference minimum clock for high speed is 19.2MHz.
119 * The linux 2.6.30 kernel uses this value.
120 * The reference minimum clock for fast mode is 9.6MHz
121 * The reference minimum clock for standard mode is 4MHz
122 * In TRM, the value of 12MHz is used.
123 */
124#ifndef I2C_INTERNAL_SAMPLING_CLK
125#define I2C_INTERNAL_SAMPLING_CLK 19200000
126#endif
127
128/*
129 * The equation for the low and high time is
130 * tlow = scll + scll_trim = (sampling clock * tlow_duty) / speed
131 * thigh = sclh + sclh_trim = (sampling clock * (1 - tlow_duty)) / speed
132 *
133 * If the duty cycle is 50%
134 *
135 * tlow = scll + scll_trim = sampling clock / (2 * speed)
136 * thigh = sclh + sclh_trim = sampling clock / (2 * speed)
137 *
138 * In TRM
139 * scll_trim = 7
140 * sclh_trim = 5
141 *
142 * The linux 2.6.30 kernel uses
143 * scll_trim = 6
144 * sclh_trim = 6
145 *
146 * These are the trim values for standard and fast speed
147 */
148#ifndef I2C_FASTSPEED_SCLL_TRIM
149#define I2C_FASTSPEED_SCLL_TRIM 6
150#endif
151#ifndef I2C_FASTSPEED_SCLH_TRIM
152#define I2C_FASTSPEED_SCLH_TRIM 6
153#endif
154
155/* These are the trim values for high speed */
156#ifndef I2C_HIGHSPEED_PHASE_ONE_SCLL_TRIM
157#define I2C_HIGHSPEED_PHASE_ONE_SCLL_TRIM I2C_FASTSPEED_SCLL_TRIM
158#endif
159#ifndef I2C_HIGHSPEED_PHASE_ONE_SCLH_TRIM
160#define I2C_HIGHSPEED_PHASE_ONE_SCLH_TRIM I2C_FASTSPEED_SCLH_TRIM
161#endif
162#ifndef I2C_HIGHSPEED_PHASE_TWO_SCLL_TRIM
163#define I2C_HIGHSPEED_PHASE_TWO_SCLL_TRIM I2C_FASTSPEED_SCLL_TRIM
164#endif
165#ifndef I2C_HIGHSPEED_PHASE_TWO_SCLH_TRIM
166#define I2C_HIGHSPEED_PHASE_TWO_SCLH_TRIM I2C_FASTSPEED_SCLH_TRIM
167#endif
168
169#define I2C_PSC_MAX 0x0f
170#define I2C_PSC_MIN 0x00
171
172#endif /* _OMAP24XX_I2C_H_ */