blob: c388dc002460a159a33681af91c7f9f564827644 [file] [log] [blame]
Sergey Kubushyne8f39122007-08-10 20:26:18 +02001/*
2 * (C) Copyright 2004
3 * Texas Instruments, <www.ti.com>
4 *
5 * Some changes copyright (C) 2007 Sergey Kubushyn <ksi@koi8.net>
6 *
Wolfgang Denkd79de1d2013-07-08 09:37:19 +02007 * SPDX-License-Identifier: GPL-2.0+
Sergey Kubushyne8f39122007-08-10 20:26:18 +02008 */
9#ifndef _DAVINCI_I2C_H_
10#define _DAVINCI_I2C_H_
11
12#define I2C_WRITE 0
13#define I2C_READ 1
14
Nick Thompson4c1e5092009-11-12 11:06:08 -050015#ifndef CONFIG_SOC_DA8XX
Sergey Kubushyne8f39122007-08-10 20:26:18 +020016#define I2C_BASE 0x01c21000
Nick Thompson4c1e5092009-11-12 11:06:08 -050017#else
18#define I2C_BASE 0x01c22000
19#endif
Sergey Kubushyne8f39122007-08-10 20:26:18 +020020
21#define I2C_OA (I2C_BASE + 0x00)
22#define I2C_IE (I2C_BASE + 0x04)
23#define I2C_STAT (I2C_BASE + 0x08)
24#define I2C_SCLL (I2C_BASE + 0x0c)
25#define I2C_SCLH (I2C_BASE + 0x10)
26#define I2C_CNT (I2C_BASE + 0x14)
27#define I2C_DRR (I2C_BASE + 0x18)
28#define I2C_SA (I2C_BASE + 0x1c)
29#define I2C_DXR (I2C_BASE + 0x20)
30#define I2C_CON (I2C_BASE + 0x24)
31#define I2C_IV (I2C_BASE + 0x28)
32#define I2C_PSC (I2C_BASE + 0x30)
33
34/* I2C masks */
35
36/* I2C Interrupt Enable Register (I2C_IE): */
37#define I2C_IE_SCD_IE (1 << 5) /* Stop condition detect interrupt enable */
38#define I2C_IE_XRDY_IE (1 << 4) /* Transmit data ready interrupt enable */
39#define I2C_IE_RRDY_IE (1 << 3) /* Receive data ready interrupt enable */
40#define I2C_IE_ARDY_IE (1 << 2) /* Register access ready interrupt enable */
41#define I2C_IE_NACK_IE (1 << 1) /* No acknowledgment interrupt enable */
42#define I2C_IE_AL_IE (1 << 0) /* Arbitration lost interrupt enable */
43
44/* I2C Status Register (I2C_STAT): */
45
46#define I2C_STAT_BB (1 << 12) /* Bus busy */
47#define I2C_STAT_ROVR (1 << 11) /* Receive overrun */
48#define I2C_STAT_XUDF (1 << 10) /* Transmit underflow */
49#define I2C_STAT_AAS (1 << 9) /* Address as slave */
50#define I2C_STAT_SCD (1 << 5) /* Stop condition detect */
51#define I2C_STAT_XRDY (1 << 4) /* Transmit data ready */
52#define I2C_STAT_RRDY (1 << 3) /* Receive data ready */
53#define I2C_STAT_ARDY (1 << 2) /* Register access ready */
54#define I2C_STAT_NACK (1 << 1) /* No acknowledgment interrupt enable */
55#define I2C_STAT_AL (1 << 0) /* Arbitration lost interrupt enable */
56
57
58/* I2C Interrupt Code Register (I2C_INTCODE): */
59
60#define I2C_INTCODE_MASK 7
61#define I2C_INTCODE_NONE 0
62#define I2C_INTCODE_AL 1 /* Arbitration lost */
63#define I2C_INTCODE_NAK 2 /* No acknowledgement/general call */
64#define I2C_INTCODE_ARDY 3 /* Register access ready */
65#define I2C_INTCODE_RRDY 4 /* Rcv data ready */
66#define I2C_INTCODE_XRDY 5 /* Xmit data ready */
67#define I2C_INTCODE_SCD 6 /* Stop condition detect */
68
69
70/* I2C Configuration Register (I2C_CON): */
71
72#define I2C_CON_EN (1 << 5) /* I2C module enable */
73#define I2C_CON_STB (1 << 4) /* Start byte mode (master mode only) */
74#define I2C_CON_MST (1 << 10) /* Master/slave mode */
75#define I2C_CON_TRX (1 << 9) /* Transmitter/receiver mode (master mode only) */
76#define I2C_CON_XA (1 << 8) /* Expand address */
77#define I2C_CON_STP (1 << 11) /* Stop condition (master mode only) */
78#define I2C_CON_STT (1 << 13) /* Start condition (master mode only) */
Nick Thompson4c1e5092009-11-12 11:06:08 -050079#define I2C_CON_FREE (1 << 14) /* Free run on emulation */
Sergey Kubushyne8f39122007-08-10 20:26:18 +020080
81#define I2C_TIMEOUT 0xffff0000 /* Timeout mask for poll_i2c_irq() */
82
83#endif