3 * Vipin Kumar, ST Micoelectronics, vipin.kumar@st.com.
5 * SPDX-License-Identifier: GPL-2.0+
44 u32 ic_tx_abrt_source;
50 #define NANO_TO_MICRO 1000
52 /* High and low times in different speed modes (in ns) */
53 #define MIN_SS_SCL_HIGHTIME 4000
54 #define MIN_SS_SCL_LOWTIME 4700
55 #define MIN_FS_SCL_HIGHTIME 600
56 #define MIN_FS_SCL_LOWTIME 1300
57 #define MIN_HS_SCL_HIGHTIME 60
58 #define MIN_HS_SCL_LOWTIME 160
60 /* Worst case timeout for 1 byte is kept as 2ms */
61 #define I2C_BYTE_TO (CONFIG_SYS_HZ/500)
62 #define I2C_STOPDET_TO (CONFIG_SYS_HZ/500)
63 #define I2C_BYTE_TO_BB (I2C_BYTE_TO * 16)
65 /* i2c control register definitions */
66 #define IC_CON_SD 0x0040
67 #define IC_CON_RE 0x0020
68 #define IC_CON_10BITADDRMASTER 0x0010
69 #define IC_CON_10BITADDR_SLAVE 0x0008
70 #define IC_CON_SPD_MSK 0x0006
71 #define IC_CON_SPD_SS 0x0002
72 #define IC_CON_SPD_FS 0x0004
73 #define IC_CON_SPD_HS 0x0006
74 #define IC_CON_MM 0x0001
76 /* i2c target address register definitions */
77 #define TAR_ADDR 0x0050
79 /* i2c slave address register definitions */
80 #define IC_SLAVE_ADDR 0x0002
82 /* i2c data buffer and command register definitions */
84 #define IC_STOP 0x0200
86 /* i2c interrupt status register definitions */
87 #define IC_GEN_CALL 0x0800
88 #define IC_START_DET 0x0400
89 #define IC_STOP_DET 0x0200
90 #define IC_ACTIVITY 0x0100
91 #define IC_RX_DONE 0x0080
92 #define IC_TX_ABRT 0x0040
93 #define IC_RD_REQ 0x0020
94 #define IC_TX_EMPTY 0x0010
95 #define IC_TX_OVER 0x0008
96 #define IC_RX_FULL 0x0004
97 #define IC_RX_OVER 0x0002
98 #define IC_RX_UNDER 0x0001
100 /* fifo threshold register definitions */
109 #define IC_RX_TL IC_TL0
110 #define IC_TX_TL IC_TL0
112 /* i2c enable register definitions */
113 #define IC_ENABLE_0B 0x0001
115 /* i2c status register definitions */
116 #define IC_STATUS_SA 0x0040
117 #define IC_STATUS_MA 0x0020
118 #define IC_STATUS_RFF 0x0010
119 #define IC_STATUS_RFNE 0x0008
120 #define IC_STATUS_TFE 0x0004
121 #define IC_STATUS_TFNF 0x0002
122 #define IC_STATUS_ACT 0x0001
124 /* Speed Selection */
125 #define IC_SPEED_MODE_STANDARD 1
126 #define IC_SPEED_MODE_FAST 2
127 #define IC_SPEED_MODE_MAX 3
129 #define I2C_MAX_SPEED 3400000
130 #define I2C_FAST_SPEED 400000
131 #define I2C_STANDARD_SPEED 100000
133 #endif /* __DW_I2C_H_ */