blob: a6bce26171e9d5f9e7a904ab8039d98ca08fa2f4 [file] [log] [blame]
Sergey Kubushyne8f39122007-08-10 20:26:18 +02001/*
2 * TI DaVinci (TMS320DM644x) I2C driver.
3 *
Vitaly Andrianovbc9cd952014-04-04 13:16:52 -04004 * (C) Copyright 2012-2014
5 * Texas Instruments Incorporated, <www.ti.com>
6 * (C) Copyright 2007 Sergey Kubushyn <ksi@koi8.net>
Sergey Kubushyne8f39122007-08-10 20:26:18 +02007 * --------------------------------------------------------
8 *
Wolfgang Denkd79de1d2013-07-08 09:37:19 +02009 * SPDX-License-Identifier: GPL-2.0+
Simon Glasscb052ff2016-11-23 06:34:44 -070010 *
11 * NOTE: This driver should be converted to driver model before June 2017.
12 * Please see doc/driver-model/i2c-howto.txt for instructions.
Sergey Kubushyne8f39122007-08-10 20:26:18 +020013 */
14
15#include <common.h>
Sergey Kubushyne8f39122007-08-10 20:26:18 +020016#include <i2c.h>
17#include <asm/arch/hardware.h>
18#include <asm/arch/i2c_defs.h>
Vitaly Andrianovbc9cd952014-04-04 13:16:52 -040019#include <asm/io.h>
Karicheri, Muralidharanf89c87f2014-04-04 13:16:51 -040020#include "davinci_i2c.h"
Sergey Kubushyne8f39122007-08-10 20:26:18 +020021
22#define CHECK_NACK() \
23 do {\
24 if (tmp & (I2C_TIMEOUT | I2C_STAT_NACK)) {\
Vitaly Andrianovbc9cd952014-04-04 13:16:52 -040025 REG(&(i2c_base->i2c_con)) = 0;\
26 return 1;\
27 } \
Sergey Kubushyne8f39122007-08-10 20:26:18 +020028 } while (0)
29
Vitaly Andrianovbc9cd952014-04-04 13:16:52 -040030static struct i2c_regs *davinci_get_base(struct i2c_adapter *adap);
Sergey Kubushyne8f39122007-08-10 20:26:18 +020031
Cooper Jr., Frankline1f7f6d2017-04-20 10:25:42 -050032static int _wait_for_bus(struct i2c_regs *i2c_base)
Sergey Kubushyne8f39122007-08-10 20:26:18 +020033{
34 int stat, timeout;
35
Vitaly Andrianovbc9cd952014-04-04 13:16:52 -040036 REG(&(i2c_base->i2c_stat)) = 0xffff;
Sergey Kubushyne8f39122007-08-10 20:26:18 +020037
38 for (timeout = 0; timeout < 10; timeout++) {
Vitaly Andrianovbc9cd952014-04-04 13:16:52 -040039 stat = REG(&(i2c_base->i2c_stat));
40 if (!((stat) & I2C_STAT_BB)) {
41 REG(&(i2c_base->i2c_stat)) = 0xffff;
42 return 0;
Sergey Kubushyne8f39122007-08-10 20:26:18 +020043 }
44
Vitaly Andrianovbc9cd952014-04-04 13:16:52 -040045 REG(&(i2c_base->i2c_stat)) = stat;
Sergey Kubushyne8f39122007-08-10 20:26:18 +020046 udelay(50000);
47 }
48
Vitaly Andrianovbc9cd952014-04-04 13:16:52 -040049 REG(&(i2c_base->i2c_stat)) = 0xffff;
50 return 1;
Sergey Kubushyne8f39122007-08-10 20:26:18 +020051}
52
Cooper Jr., Frankline1f7f6d2017-04-20 10:25:42 -050053static int _poll_i2c_irq(struct i2c_regs *i2c_base, int mask)
Sergey Kubushyne8f39122007-08-10 20:26:18 +020054{
55 int stat, timeout;
56
57 for (timeout = 0; timeout < 10; timeout++) {
58 udelay(1000);
Vitaly Andrianovbc9cd952014-04-04 13:16:52 -040059 stat = REG(&(i2c_base->i2c_stat));
60 if (stat & mask)
61 return stat;
Sergey Kubushyne8f39122007-08-10 20:26:18 +020062 }
63
Vitaly Andrianovbc9cd952014-04-04 13:16:52 -040064 REG(&(i2c_base->i2c_stat)) = 0xffff;
65 return stat | I2C_TIMEOUT;
Sergey Kubushyne8f39122007-08-10 20:26:18 +020066}
67
Cooper Jr., Frankline1f7f6d2017-04-20 10:25:42 -050068static void _flush_rx(struct i2c_regs *i2c_base)
Sergey Kubushyne8f39122007-08-10 20:26:18 +020069{
Sergey Kubushyne8f39122007-08-10 20:26:18 +020070 while (1) {
Vitaly Andrianovbc9cd952014-04-04 13:16:52 -040071 if (!(REG(&(i2c_base->i2c_stat)) & I2C_STAT_RRDY))
Sergey Kubushyne8f39122007-08-10 20:26:18 +020072 break;
73
Vitaly Andrianovbc9cd952014-04-04 13:16:52 -040074 REG(&(i2c_base->i2c_drr));
75 REG(&(i2c_base->i2c_stat)) = I2C_STAT_RRDY;
Sergey Kubushyne8f39122007-08-10 20:26:18 +020076 udelay(1000);
77 }
78}
79
Cooper Jr., Frankline1f7f6d2017-04-20 10:25:42 -050080static uint _davinci_i2c_setspeed(struct i2c_regs *i2c_base,
81 uint speed)
Vitaly Andrianovbc9cd952014-04-04 13:16:52 -040082{
Vitaly Andrianovbc9cd952014-04-04 13:16:52 -040083 uint32_t div, psc;
Sergey Kubushyne8f39122007-08-10 20:26:18 +020084
Vitaly Andrianovbc9cd952014-04-04 13:16:52 -040085 psc = 2;
86 /* SCLL + SCLH */
87 div = (CONFIG_SYS_HZ_CLOCK / ((psc + 1) * speed)) - 10;
88 REG(&(i2c_base->i2c_psc)) = psc; /* 27MHz / (2 + 1) = 9MHz */
89 REG(&(i2c_base->i2c_scll)) = (div * 50) / 100; /* 50% Duty */
90 REG(&(i2c_base->i2c_sclh)) = div - REG(&(i2c_base->i2c_scll));
91
Vitaly Andrianovbc9cd952014-04-04 13:16:52 -040092 return 0;
93}
94
Cooper Jr., Frankline1f7f6d2017-04-20 10:25:42 -050095static void _davinci_i2c_init(struct i2c_regs *i2c_base,
96 uint speed, int slaveadd)
Sergey Kubushyne8f39122007-08-10 20:26:18 +020097{
Vitaly Andrianovbc9cd952014-04-04 13:16:52 -040098 if (REG(&(i2c_base->i2c_con)) & I2C_CON_EN) {
99 REG(&(i2c_base->i2c_con)) = 0;
100 udelay(50000);
Sergey Kubushyne8f39122007-08-10 20:26:18 +0200101 }
102
Cooper Jr., Frankline1f7f6d2017-04-20 10:25:42 -0500103 _davinci_i2c_setspeed(i2c_base, speed);
Sergey Kubushyne8f39122007-08-10 20:26:18 +0200104
Vitaly Andrianovbc9cd952014-04-04 13:16:52 -0400105 REG(&(i2c_base->i2c_oa)) = slaveadd;
106 REG(&(i2c_base->i2c_cnt)) = 0;
Sergey Kubushyne8f39122007-08-10 20:26:18 +0200107
108 /* Interrupts must be enabled or I2C module won't work */
Vitaly Andrianovbc9cd952014-04-04 13:16:52 -0400109 REG(&(i2c_base->i2c_ie)) = I2C_IE_SCD_IE | I2C_IE_XRDY_IE |
Sergey Kubushyne8f39122007-08-10 20:26:18 +0200110 I2C_IE_RRDY_IE | I2C_IE_ARDY_IE | I2C_IE_NACK_IE;
111
112 /* Now enable I2C controller (get it out of reset) */
Vitaly Andrianovbc9cd952014-04-04 13:16:52 -0400113 REG(&(i2c_base->i2c_con)) = I2C_CON_EN;
Sergey Kubushyne8f39122007-08-10 20:26:18 +0200114
115 udelay(1000);
116}
117
Cooper Jr., Frankline1f7f6d2017-04-20 10:25:42 -0500118static int _davinci_i2c_read(struct i2c_regs *i2c_base, uint8_t chip,
119 uint32_t addr, int alen, uint8_t *buf, int len)
Sergey Kubushyne8f39122007-08-10 20:26:18 +0200120{
Vitaly Andrianovbc9cd952014-04-04 13:16:52 -0400121 uint32_t tmp;
Sergey Kubushyne8f39122007-08-10 20:26:18 +0200122 int i;
123
124 if ((alen < 0) || (alen > 2)) {
Vitaly Andrianovbc9cd952014-04-04 13:16:52 -0400125 printf("%s(): bogus address length %x\n", __func__, alen);
126 return 1;
Sergey Kubushyne8f39122007-08-10 20:26:18 +0200127 }
128
Cooper Jr., Frankline1f7f6d2017-04-20 10:25:42 -0500129 if (_wait_for_bus(i2c_base))
Vitaly Andrianovbc9cd952014-04-04 13:16:52 -0400130 return 1;
Sergey Kubushyne8f39122007-08-10 20:26:18 +0200131
132 if (alen != 0) {
133 /* Start address phase */
134 tmp = I2C_CON_EN | I2C_CON_MST | I2C_CON_STT | I2C_CON_TRX;
Vitaly Andrianovbc9cd952014-04-04 13:16:52 -0400135 REG(&(i2c_base->i2c_cnt)) = alen;
136 REG(&(i2c_base->i2c_sa)) = chip;
137 REG(&(i2c_base->i2c_con)) = tmp;
Sergey Kubushyne8f39122007-08-10 20:26:18 +0200138
Cooper Jr., Frankline1f7f6d2017-04-20 10:25:42 -0500139 tmp = _poll_i2c_irq(i2c_base, I2C_STAT_XRDY | I2C_STAT_NACK);
Sergey Kubushyne8f39122007-08-10 20:26:18 +0200140
141 CHECK_NACK();
142
143 switch (alen) {
Vitaly Andrianovbc9cd952014-04-04 13:16:52 -0400144 case 2:
145 /* Send address MSByte */
146 if (tmp & I2C_STAT_XRDY) {
147 REG(&(i2c_base->i2c_dxr)) = (addr >> 8) & 0xff;
148 } else {
149 REG(&(i2c_base->i2c_con)) = 0;
150 return 1;
151 }
Sergey Kubushyne8f39122007-08-10 20:26:18 +0200152
Cooper Jr., Frankline1f7f6d2017-04-20 10:25:42 -0500153 tmp = _poll_i2c_irq(i2c_base,
154 I2C_STAT_XRDY | I2C_STAT_NACK);
Sergey Kubushyne8f39122007-08-10 20:26:18 +0200155
Vitaly Andrianovbc9cd952014-04-04 13:16:52 -0400156 CHECK_NACK();
157 /* No break, fall through */
158 case 1:
159 /* Send address LSByte */
160 if (tmp & I2C_STAT_XRDY) {
161 REG(&(i2c_base->i2c_dxr)) = addr & 0xff;
162 } else {
163 REG(&(i2c_base->i2c_con)) = 0;
164 return 1;
165 }
Sergey Kubushyne8f39122007-08-10 20:26:18 +0200166
Cooper Jr., Frankline1f7f6d2017-04-20 10:25:42 -0500167 tmp = _poll_i2c_irq(i2c_base, I2C_STAT_XRDY |
168 I2C_STAT_NACK | I2C_STAT_ARDY);
Sergey Kubushyne8f39122007-08-10 20:26:18 +0200169
Vitaly Andrianovbc9cd952014-04-04 13:16:52 -0400170 CHECK_NACK();
Sergey Kubushyne8f39122007-08-10 20:26:18 +0200171
Vitaly Andrianovbc9cd952014-04-04 13:16:52 -0400172 if (!(tmp & I2C_STAT_ARDY)) {
173 REG(&(i2c_base->i2c_con)) = 0;
174 return 1;
175 }
Sergey Kubushyne8f39122007-08-10 20:26:18 +0200176 }
177 }
178
179 /* Address phase is over, now read 'len' bytes and stop */
180 tmp = I2C_CON_EN | I2C_CON_MST | I2C_CON_STT | I2C_CON_STP;
Vitaly Andrianovbc9cd952014-04-04 13:16:52 -0400181 REG(&(i2c_base->i2c_cnt)) = len & 0xffff;
182 REG(&(i2c_base->i2c_sa)) = chip;
183 REG(&(i2c_base->i2c_con)) = tmp;
Sergey Kubushyne8f39122007-08-10 20:26:18 +0200184
185 for (i = 0; i < len; i++) {
Cooper Jr., Frankline1f7f6d2017-04-20 10:25:42 -0500186 tmp = _poll_i2c_irq(i2c_base, I2C_STAT_RRDY | I2C_STAT_NACK |
Vitaly Andrianovbc9cd952014-04-04 13:16:52 -0400187 I2C_STAT_ROVR);
Sergey Kubushyne8f39122007-08-10 20:26:18 +0200188
189 CHECK_NACK();
190
191 if (tmp & I2C_STAT_RRDY) {
Vitaly Andrianovbc9cd952014-04-04 13:16:52 -0400192 buf[i] = REG(&(i2c_base->i2c_drr));
Sergey Kubushyne8f39122007-08-10 20:26:18 +0200193 } else {
Vitaly Andrianovbc9cd952014-04-04 13:16:52 -0400194 REG(&(i2c_base->i2c_con)) = 0;
195 return 1;
Sergey Kubushyne8f39122007-08-10 20:26:18 +0200196 }
197 }
198
Cooper Jr., Frankline1f7f6d2017-04-20 10:25:42 -0500199 tmp = _poll_i2c_irq(i2c_base, I2C_STAT_SCD | I2C_STAT_NACK);
Sergey Kubushyne8f39122007-08-10 20:26:18 +0200200
201 CHECK_NACK();
202
203 if (!(tmp & I2C_STAT_SCD)) {
Vitaly Andrianovbc9cd952014-04-04 13:16:52 -0400204 REG(&(i2c_base->i2c_con)) = 0;
205 return 1;
Sergey Kubushyne8f39122007-08-10 20:26:18 +0200206 }
207
Cooper Jr., Frankline1f7f6d2017-04-20 10:25:42 -0500208 _flush_rx(i2c_base);
Vitaly Andrianovbc9cd952014-04-04 13:16:52 -0400209 REG(&(i2c_base->i2c_stat)) = 0xffff;
210 REG(&(i2c_base->i2c_cnt)) = 0;
211 REG(&(i2c_base->i2c_con)) = 0;
Sergey Kubushyne8f39122007-08-10 20:26:18 +0200212
Vitaly Andrianovbc9cd952014-04-04 13:16:52 -0400213 return 0;
Sergey Kubushyne8f39122007-08-10 20:26:18 +0200214}
215
Cooper Jr., Frankline1f7f6d2017-04-20 10:25:42 -0500216static int _davinci_i2c_write(struct i2c_regs *i2c_base, uint8_t chip,
217 uint32_t addr, int alen, uint8_t *buf, int len)
Sergey Kubushyne8f39122007-08-10 20:26:18 +0200218{
Vitaly Andrianovbc9cd952014-04-04 13:16:52 -0400219 uint32_t tmp;
Sergey Kubushyne8f39122007-08-10 20:26:18 +0200220 int i;
221
222 if ((alen < 0) || (alen > 2)) {
Vitaly Andrianovbc9cd952014-04-04 13:16:52 -0400223 printf("%s(): bogus address length %x\n", __func__, alen);
224 return 1;
Sergey Kubushyne8f39122007-08-10 20:26:18 +0200225 }
226 if (len < 0) {
Vitaly Andrianovbc9cd952014-04-04 13:16:52 -0400227 printf("%s(): bogus length %x\n", __func__, len);
228 return 1;
Sergey Kubushyne8f39122007-08-10 20:26:18 +0200229 }
230
Cooper Jr., Frankline1f7f6d2017-04-20 10:25:42 -0500231 if (_wait_for_bus(i2c_base))
Vitaly Andrianovbc9cd952014-04-04 13:16:52 -0400232 return 1;
Sergey Kubushyne8f39122007-08-10 20:26:18 +0200233
234 /* Start address phase */
Vitaly Andrianovbc9cd952014-04-04 13:16:52 -0400235 tmp = I2C_CON_EN | I2C_CON_MST | I2C_CON_STT |
236 I2C_CON_TRX | I2C_CON_STP;
237 REG(&(i2c_base->i2c_cnt)) = (alen == 0) ?
238 len & 0xffff : (len & 0xffff) + alen;
239 REG(&(i2c_base->i2c_sa)) = chip;
240 REG(&(i2c_base->i2c_con)) = tmp;
Sergey Kubushyne8f39122007-08-10 20:26:18 +0200241
242 switch (alen) {
Vitaly Andrianovbc9cd952014-04-04 13:16:52 -0400243 case 2:
244 /* Send address MSByte */
Cooper Jr., Frankline1f7f6d2017-04-20 10:25:42 -0500245 tmp = _poll_i2c_irq(i2c_base, I2C_STAT_XRDY | I2C_STAT_NACK);
Sergey Kubushyne8f39122007-08-10 20:26:18 +0200246
Vitaly Andrianovbc9cd952014-04-04 13:16:52 -0400247 CHECK_NACK();
Sergey Kubushyne8f39122007-08-10 20:26:18 +0200248
Vitaly Andrianovbc9cd952014-04-04 13:16:52 -0400249 if (tmp & I2C_STAT_XRDY) {
250 REG(&(i2c_base->i2c_dxr)) = (addr >> 8) & 0xff;
251 } else {
252 REG(&(i2c_base->i2c_con)) = 0;
253 return 1;
254 }
255 /* No break, fall through */
256 case 1:
257 /* Send address LSByte */
Cooper Jr., Frankline1f7f6d2017-04-20 10:25:42 -0500258 tmp = _poll_i2c_irq(i2c_base, I2C_STAT_XRDY | I2C_STAT_NACK);
Sergey Kubushyne8f39122007-08-10 20:26:18 +0200259
Vitaly Andrianovbc9cd952014-04-04 13:16:52 -0400260 CHECK_NACK();
Sergey Kubushyne8f39122007-08-10 20:26:18 +0200261
Vitaly Andrianovbc9cd952014-04-04 13:16:52 -0400262 if (tmp & I2C_STAT_XRDY) {
263 REG(&(i2c_base->i2c_dxr)) = addr & 0xff;
264 } else {
265 REG(&(i2c_base->i2c_con)) = 0;
266 return 1;
267 }
Sergey Kubushyne8f39122007-08-10 20:26:18 +0200268 }
269
270 for (i = 0; i < len; i++) {
Cooper Jr., Frankline1f7f6d2017-04-20 10:25:42 -0500271 tmp = _poll_i2c_irq(i2c_base, I2C_STAT_XRDY | I2C_STAT_NACK);
Sergey Kubushyne8f39122007-08-10 20:26:18 +0200272
273 CHECK_NACK();
274
Vitaly Andrianovbc9cd952014-04-04 13:16:52 -0400275 if (tmp & I2C_STAT_XRDY)
276 REG(&(i2c_base->i2c_dxr)) = buf[i];
277 else
278 return 1;
Sergey Kubushyne8f39122007-08-10 20:26:18 +0200279 }
280
Cooper Jr., Frankline1f7f6d2017-04-20 10:25:42 -0500281 tmp = _poll_i2c_irq(i2c_base, I2C_STAT_SCD | I2C_STAT_NACK);
Sergey Kubushyne8f39122007-08-10 20:26:18 +0200282
283 CHECK_NACK();
284
285 if (!(tmp & I2C_STAT_SCD)) {
Vitaly Andrianovbc9cd952014-04-04 13:16:52 -0400286 REG(&(i2c_base->i2c_con)) = 0;
287 return 1;
Sergey Kubushyne8f39122007-08-10 20:26:18 +0200288 }
289
Cooper Jr., Frankline1f7f6d2017-04-20 10:25:42 -0500290 _flush_rx(i2c_base);
Vitaly Andrianovbc9cd952014-04-04 13:16:52 -0400291 REG(&(i2c_base->i2c_stat)) = 0xffff;
292 REG(&(i2c_base->i2c_cnt)) = 0;
293 REG(&(i2c_base->i2c_con)) = 0;
Sergey Kubushyne8f39122007-08-10 20:26:18 +0200294
Vitaly Andrianovbc9cd952014-04-04 13:16:52 -0400295 return 0;
Sergey Kubushyne8f39122007-08-10 20:26:18 +0200296}
Vitaly Andrianovbc9cd952014-04-04 13:16:52 -0400297
Cooper Jr., Frankline1f7f6d2017-04-20 10:25:42 -0500298static int _davinci_i2c_probe_chip(struct i2c_regs *i2c_base, uint8_t chip)
299{
300 int rc = 1;
301
302 if (chip == REG(&(i2c_base->i2c_oa)))
303 return rc;
304
305 REG(&(i2c_base->i2c_con)) = 0;
306 if (_wait_for_bus(i2c_base))
307 return 1;
308
309 /* try to read one byte from current (or only) address */
310 REG(&(i2c_base->i2c_cnt)) = 1;
311 REG(&(i2c_base->i2c_sa)) = chip;
312 REG(&(i2c_base->i2c_con)) = (I2C_CON_EN | I2C_CON_MST | I2C_CON_STT |
313 I2C_CON_STP);
314 udelay(50000);
315
316 if (!(REG(&(i2c_base->i2c_stat)) & I2C_STAT_NACK)) {
317 rc = 0;
318 _flush_rx(i2c_base);
319 REG(&(i2c_base->i2c_stat)) = 0xffff;
320 } else {
321 REG(&(i2c_base->i2c_stat)) = 0xffff;
322 REG(&(i2c_base->i2c_con)) |= I2C_CON_STP;
323 udelay(20000);
324 if (_wait_for_bus(i2c_base))
325 return 1;
326 }
327
328 _flush_rx(i2c_base);
329 REG(&(i2c_base->i2c_stat)) = 0xffff;
330 REG(&(i2c_base->i2c_cnt)) = 0;
331 return rc;
332}
333
Vitaly Andrianovbc9cd952014-04-04 13:16:52 -0400334static struct i2c_regs *davinci_get_base(struct i2c_adapter *adap)
335{
336 switch (adap->hwadapnr) {
337#if I2C_BUS_MAX >= 3
338 case 2:
339 return (struct i2c_regs *)I2C2_BASE;
340#endif
341#if I2C_BUS_MAX >= 2
342 case 1:
343 return (struct i2c_regs *)I2C1_BASE;
344#endif
345 case 0:
346 return (struct i2c_regs *)I2C_BASE;
347
348 default:
349 printf("wrong hwadapnr: %d\n", adap->hwadapnr);
350 }
351
352 return NULL;
353}
354
Cooper Jr., Frankline1f7f6d2017-04-20 10:25:42 -0500355static uint davinci_i2c_setspeed(struct i2c_adapter *adap, uint speed)
356{
357 struct i2c_regs *i2c_base = davinci_get_base(adap);
358 uint ret;
359
360 adap->speed = speed;
361 ret = _davinci_i2c_setspeed(i2c_base, speed);
362
363 return ret;
364}
365
366static void davinci_i2c_init(struct i2c_adapter *adap, int speed,
367 int slaveadd)
368{
369 struct i2c_regs *i2c_base = davinci_get_base(adap);
370
371 adap->speed = speed;
372 _davinci_i2c_init(i2c_base, speed, slaveadd);
373
374 return;
375}
376
377static int davinci_i2c_read(struct i2c_adapter *adap, uint8_t chip,
378 uint32_t addr, int alen, uint8_t *buf, int len)
379{
380 struct i2c_regs *i2c_base = davinci_get_base(adap);
381 return _davinci_i2c_read(i2c_base, chip, addr, alen, buf, len);
382}
383
384static int davinci_i2c_write(struct i2c_adapter *adap, uint8_t chip,
385 uint32_t addr, int alen, uint8_t *buf, int len)
386{
387 struct i2c_regs *i2c_base = davinci_get_base(adap);
388
389 return _davinci_i2c_write(i2c_base, chip, addr, alen, buf, len);
390}
391
392static int davinci_i2c_probe_chip(struct i2c_adapter *adap, uint8_t chip)
393{
394 struct i2c_regs *i2c_base = davinci_get_base(adap);
395
396 return _davinci_i2c_probe_chip(i2c_base, chip);
397}
398
399U_BOOT_I2C_ADAP_COMPLETE(davinci_0, davinci_i2c_init, davinci_i2c_probe_chip,
Vitaly Andrianovbc9cd952014-04-04 13:16:52 -0400400 davinci_i2c_read, davinci_i2c_write,
401 davinci_i2c_setspeed,
402 CONFIG_SYS_DAVINCI_I2C_SPEED,
403 CONFIG_SYS_DAVINCI_I2C_SLAVE,
404 0)
405
406#if I2C_BUS_MAX >= 2
Cooper Jr., Frankline1f7f6d2017-04-20 10:25:42 -0500407U_BOOT_I2C_ADAP_COMPLETE(davinci_1, davinci_i2c_init, davinci_i2c_probe_chip,
Vitaly Andrianovbc9cd952014-04-04 13:16:52 -0400408 davinci_i2c_read, davinci_i2c_write,
409 davinci_i2c_setspeed,
410 CONFIG_SYS_DAVINCI_I2C_SPEED1,
411 CONFIG_SYS_DAVINCI_I2C_SLAVE1,
412 1)
413#endif
414
415#if I2C_BUS_MAX >= 3
Cooper Jr., Frankline1f7f6d2017-04-20 10:25:42 -0500416U_BOOT_I2C_ADAP_COMPLETE(davinci_2, davinci_i2c_init, davinci_i2c_probe_chip,
Vitaly Andrianovbc9cd952014-04-04 13:16:52 -0400417 davinci_i2c_read, davinci_i2c_write,
418 davinci_i2c_setspeed,
419 CONFIG_SYS_DAVINCI_I2C_SPEED2,
420 CONFIG_SYS_DAVINCI_I2C_SLAVE2,
421 2)
422#endif