blob: 0922fe9bb109c8c357b9e1f58e7228e6ec0f51f3 [file] [log] [blame]
Tom Rini83d290c2018-05-06 17:58:06 -04001// SPDX-License-Identifier: GPL-2.0+
Dirk Eibachb46226b2014-07-03 09:28:18 +02002/*
3 * (C) Copyright 2013
Mario Sixd38826a2018-03-06 08:04:58 +01004 * Dirk Eibach, Guntermann & Drunck GmbH, dirk.eibach@gdsys.cc
Dirk Eibachb46226b2014-07-03 09:28:18 +02005 */
6
7#include <common.h>
8#include <i2c.h>
Mario Six92164212018-01-15 11:08:11 +01009#ifdef CONFIG_DM_I2C
10#include <dm.h>
11#include <fpgamap.h>
12#include "../misc/gdsys_soc.h"
13#else
Dirk Eibachb46226b2014-07-03 09:28:18 +020014#include <gdsys_fpga.h>
Mario Six92164212018-01-15 11:08:11 +010015#endif
Mario Six64ef0942018-01-15 11:08:10 +010016#include <asm/unaligned.h>
Dirk Eibachb46226b2014-07-03 09:28:18 +020017
Mario Six92164212018-01-15 11:08:11 +010018#ifdef CONFIG_DM_I2C
19struct ihs_i2c_priv {
20 uint speed;
21 phys_addr_t addr;
22};
23
24enum {
25 REG_INTERRUPT_STATUS = 0x00,
26 REG_INTERRUPT_ENABLE_CONTROL = 0x02,
27 REG_WRITE_MAILBOX_EXT = 0x04,
28 REG_WRITE_MAILBOX = 0x06,
29 REG_READ_MAILBOX_EXT = 0x08,
30 REG_READ_MAILBOX = 0x0A,
31};
32
33#else /* !CONFIG_DM_I2C */
Dirk Eibachb46226b2014-07-03 09:28:18 +020034DECLARE_GLOBAL_DATA_PTR;
35
Dirk Eibach071be892015-10-28 11:46:22 +010036#ifdef CONFIG_SYS_I2C_IHS_DUAL
Mario Six92164212018-01-15 11:08:11 +010037
Dirk Eibach071be892015-10-28 11:46:22 +010038#define I2C_SET_REG(fld, val) \
Dirk Eibach3af0cdb2015-10-28 11:46:23 +010039 do { \
40 if (I2C_ADAP_HWNR & 0x10) \
41 FPGA_SET_REG(I2C_ADAP_HWNR & 0xf, i2c1.fld, val); \
42 else \
43 FPGA_SET_REG(I2C_ADAP_HWNR, i2c0.fld, val); \
44 } while (0)
Dirk Eibach071be892015-10-28 11:46:22 +010045#else
46#define I2C_SET_REG(fld, val) \
Dirk Eibach3af0cdb2015-10-28 11:46:23 +010047 FPGA_SET_REG(I2C_ADAP_HWNR, i2c0.fld, val)
Dirk Eibach071be892015-10-28 11:46:22 +010048#endif
49
50#ifdef CONFIG_SYS_I2C_IHS_DUAL
51#define I2C_GET_REG(fld, val) \
Dirk Eibach3af0cdb2015-10-28 11:46:23 +010052 do { \
53 if (I2C_ADAP_HWNR & 0x10) \
54 FPGA_GET_REG(I2C_ADAP_HWNR & 0xf, i2c1.fld, val); \
55 else \
56 FPGA_GET_REG(I2C_ADAP_HWNR, i2c0.fld, val); \
57 } while (0)
Dirk Eibach071be892015-10-28 11:46:22 +010058#else
59#define I2C_GET_REG(fld, val) \
Dirk Eibach3af0cdb2015-10-28 11:46:23 +010060 FPGA_GET_REG(I2C_ADAP_HWNR, i2c0.fld, val)
Dirk Eibach071be892015-10-28 11:46:22 +010061#endif
Mario Six92164212018-01-15 11:08:11 +010062#endif /* CONFIG_DM_I2C */
Dirk Eibach071be892015-10-28 11:46:22 +010063
Dirk Eibachb46226b2014-07-03 09:28:18 +020064enum {
Mario Six64ef0942018-01-15 11:08:10 +010065 I2CINT_ERROR_EV = BIT(13),
66 I2CINT_TRANSMIT_EV = BIT(14),
67 I2CINT_RECEIVE_EV = BIT(15),
Dirk Eibachb46226b2014-07-03 09:28:18 +020068};
69
70enum {
Mario Six64ef0942018-01-15 11:08:10 +010071 I2CMB_READ = 0 << 10,
Dirk Eibachb46226b2014-07-03 09:28:18 +020072 I2CMB_WRITE = 1 << 10,
Mario Six64ef0942018-01-15 11:08:10 +010073 I2CMB_1BYTE = 0 << 11,
Dirk Eibachb46226b2014-07-03 09:28:18 +020074 I2CMB_2BYTE = 1 << 11,
Mario Six64ef0942018-01-15 11:08:10 +010075 I2CMB_DONT_HOLD_BUS = 0 << 13,
Dirk Eibachb46226b2014-07-03 09:28:18 +020076 I2CMB_HOLD_BUS = 1 << 13,
77 I2CMB_NATIVE = 2 << 14,
78};
79
Mario Six64ef0942018-01-15 11:08:10 +010080enum {
81 I2COP_WRITE = 0,
82 I2COP_READ = 1,
83};
84
Mario Six92164212018-01-15 11:08:11 +010085#ifdef CONFIG_DM_I2C
86static int wait_for_int(struct udevice *dev, int read)
87#else
Dirk Eibachb46226b2014-07-03 09:28:18 +020088static int wait_for_int(bool read)
Mario Six92164212018-01-15 11:08:11 +010089#endif
Dirk Eibachb46226b2014-07-03 09:28:18 +020090{
91 u16 val;
Mario Six64ef0942018-01-15 11:08:10 +010092 uint ctr = 0;
Mario Six92164212018-01-15 11:08:11 +010093#ifdef CONFIG_DM_I2C
94 struct ihs_i2c_priv *priv = dev_get_priv(dev);
95 struct udevice *fpga;
Dirk Eibachb46226b2014-07-03 09:28:18 +020096
Mario Six92164212018-01-15 11:08:11 +010097 gdsys_soc_get_fpga(dev, &fpga);
98#endif
99
100#ifdef CONFIG_DM_I2C
Mario Six2df71d62018-03-28 14:37:42 +0200101 fpgamap_read(fpga, priv->addr + REG_INTERRUPT_STATUS, &val,
102 FPGAMAP_SIZE_16);
Mario Six92164212018-01-15 11:08:11 +0100103#else
Dirk Eibach071be892015-10-28 11:46:22 +0100104 I2C_GET_REG(interrupt_status, &val);
Mario Six92164212018-01-15 11:08:11 +0100105#endif
Mario Six64ef0942018-01-15 11:08:10 +0100106 /* Wait until error or receive/transmit interrupt was raised */
Dirk Eibachb46226b2014-07-03 09:28:18 +0200107 while (!(val & (I2CINT_ERROR_EV
108 | (read ? I2CINT_RECEIVE_EV : I2CINT_TRANSMIT_EV)))) {
109 udelay(10);
Mario Six64ef0942018-01-15 11:08:10 +0100110 if (ctr++ > 5000)
Dirk Eibachb46226b2014-07-03 09:28:18 +0200111 return 1;
Mario Six92164212018-01-15 11:08:11 +0100112#ifdef CONFIG_DM_I2C
Mario Six2df71d62018-03-28 14:37:42 +0200113 fpgamap_read(fpga, priv->addr + REG_INTERRUPT_STATUS, &val,
114 FPGAMAP_SIZE_16);
Mario Six92164212018-01-15 11:08:11 +0100115#else
Dirk Eibach071be892015-10-28 11:46:22 +0100116 I2C_GET_REG(interrupt_status, &val);
Mario Six92164212018-01-15 11:08:11 +0100117#endif
Dirk Eibachb46226b2014-07-03 09:28:18 +0200118 }
119
120 return (val & I2CINT_ERROR_EV) ? 1 : 0;
121}
122
Mario Six92164212018-01-15 11:08:11 +0100123#ifdef CONFIG_DM_I2C
124static int ihs_i2c_transfer(struct udevice *dev, uchar chip,
125 uchar *buffer, int len, int read, bool is_last)
126#else
Dirk Eibachb46226b2014-07-03 09:28:18 +0200127static int ihs_i2c_transfer(uchar chip, uchar *buffer, int len, bool read,
128 bool is_last)
Mario Six92164212018-01-15 11:08:11 +0100129#endif
Dirk Eibachb46226b2014-07-03 09:28:18 +0200130{
131 u16 val;
Mario Six2df71d62018-03-28 14:37:42 +0200132 u16 data;
Mario Six92164212018-01-15 11:08:11 +0100133#ifdef CONFIG_DM_I2C
134 struct ihs_i2c_priv *priv = dev_get_priv(dev);
135 struct udevice *fpga;
136
137 gdsys_soc_get_fpga(dev, &fpga);
138#endif
Dirk Eibachb46226b2014-07-03 09:28:18 +0200139
Mario Six64ef0942018-01-15 11:08:10 +0100140 /* Clear interrupt status */
Mario Six2df71d62018-03-28 14:37:42 +0200141 data = I2CINT_ERROR_EV | I2CINT_RECEIVE_EV | I2CINT_TRANSMIT_EV;
Mario Six92164212018-01-15 11:08:11 +0100142#ifdef CONFIG_DM_I2C
Mario Six2df71d62018-03-28 14:37:42 +0200143 fpgamap_write(fpga, priv->addr + REG_INTERRUPT_STATUS, &data,
144 FPGAMAP_SIZE_16);
145 fpgamap_read(fpga, priv->addr + REG_INTERRUPT_STATUS, &val,
146 FPGAMAP_SIZE_16);
Mario Six92164212018-01-15 11:08:11 +0100147#else
Mario Six2df71d62018-03-28 14:37:42 +0200148 I2C_SET_REG(interrupt_status, data);
Dirk Eibach071be892015-10-28 11:46:22 +0100149 I2C_GET_REG(interrupt_status, &val);
Mario Six92164212018-01-15 11:08:11 +0100150#endif
Dirk Eibachb46226b2014-07-03 09:28:18 +0200151
Mario Six64ef0942018-01-15 11:08:10 +0100152 /* If we want to write and have data, write the bytes to the mailbox */
Dirk Eibachb46226b2014-07-03 09:28:18 +0200153 if (!read && len) {
154 val = buffer[0];
155
156 if (len > 1)
157 val |= buffer[1] << 8;
Mario Six92164212018-01-15 11:08:11 +0100158#ifdef CONFIG_DM_I2C
Mario Six2df71d62018-03-28 14:37:42 +0200159 fpgamap_write(fpga, priv->addr + REG_WRITE_MAILBOX_EXT, &val,
160 FPGAMAP_SIZE_16);
Mario Six92164212018-01-15 11:08:11 +0100161#else
Dirk Eibach071be892015-10-28 11:46:22 +0100162 I2C_SET_REG(write_mailbox_ext, val);
Mario Six92164212018-01-15 11:08:11 +0100163#endif
Dirk Eibachb46226b2014-07-03 09:28:18 +0200164 }
165
Mario Six2df71d62018-03-28 14:37:42 +0200166 data = I2CMB_NATIVE
167 | (read ? 0 : I2CMB_WRITE)
168 | (chip << 1)
169 | ((len > 1) ? I2CMB_2BYTE : 0)
170 | (is_last ? 0 : I2CMB_HOLD_BUS);
171
Mario Six92164212018-01-15 11:08:11 +0100172#ifdef CONFIG_DM_I2C
Mario Six2df71d62018-03-28 14:37:42 +0200173 fpgamap_write(fpga, priv->addr + REG_WRITE_MAILBOX, &data,
174 FPGAMAP_SIZE_16);
Mario Six92164212018-01-15 11:08:11 +0100175#else
Mario Six2df71d62018-03-28 14:37:42 +0200176 I2C_SET_REG(write_mailbox, data);
Mario Six92164212018-01-15 11:08:11 +0100177#endif
Dirk Eibachb46226b2014-07-03 09:28:18 +0200178
Mario Six92164212018-01-15 11:08:11 +0100179#ifdef CONFIG_DM_I2C
180 if (wait_for_int(dev, read))
181#else
Dirk Eibachb46226b2014-07-03 09:28:18 +0200182 if (wait_for_int(read))
Mario Six92164212018-01-15 11:08:11 +0100183#endif
Dirk Eibachb46226b2014-07-03 09:28:18 +0200184 return 1;
185
Mario Six64ef0942018-01-15 11:08:10 +0100186 /* If we want to read, get the bytes from the mailbox */
Dirk Eibachb46226b2014-07-03 09:28:18 +0200187 if (read) {
Mario Six92164212018-01-15 11:08:11 +0100188#ifdef CONFIG_DM_I2C
Mario Six2df71d62018-03-28 14:37:42 +0200189 fpgamap_read(fpga, priv->addr + REG_READ_MAILBOX_EXT, &val,
190 FPGAMAP_SIZE_16);
Mario Six92164212018-01-15 11:08:11 +0100191#else
Dirk Eibach071be892015-10-28 11:46:22 +0100192 I2C_GET_REG(read_mailbox_ext, &val);
Mario Six92164212018-01-15 11:08:11 +0100193#endif
Dirk Eibachb46226b2014-07-03 09:28:18 +0200194 buffer[0] = val & 0xff;
195 if (len > 1)
196 buffer[1] = val >> 8;
197 }
198
199 return 0;
200}
201
Mario Six92164212018-01-15 11:08:11 +0100202#ifdef CONFIG_DM_I2C
Mario Six9cef9832018-01-15 11:08:12 +0100203static int ihs_i2c_send_buffer(struct udevice *dev, uchar chip, u8 *data, int len, bool hold_bus, int read)
204#else
205static int ihs_i2c_send_buffer(uchar chip, u8 *data, int len, bool hold_bus,
206 int read)
207#endif
208{
209 while (len) {
210 int transfer = min(len, 2);
211 bool is_last = len <= transfer;
212
213#ifdef CONFIG_DM_I2C
214 if (ihs_i2c_transfer(dev, chip, data, transfer, read,
215 hold_bus ? false : is_last))
216 return 1;
217#else
218 if (ihs_i2c_transfer(chip, data, transfer, read,
219 hold_bus ? false : is_last))
220 return 1;
221#endif
222
223 data += transfer;
224 len -= transfer;
225 }
226
227 return 0;
228}
229
230#ifdef CONFIG_DM_I2C
231static int ihs_i2c_address(struct udevice *dev, uchar chip, u8 *addr, int alen,
232 bool hold_bus)
Mario Six92164212018-01-15 11:08:11 +0100233#else
Mario Six64ef0942018-01-15 11:08:10 +0100234static int ihs_i2c_address(uchar chip, u8 *addr, int alen, bool hold_bus)
Mario Six92164212018-01-15 11:08:11 +0100235#endif
Dirk Eibachb46226b2014-07-03 09:28:18 +0200236{
Mario Six92164212018-01-15 11:08:11 +0100237#ifdef CONFIG_DM_I2C
Mario Six9cef9832018-01-15 11:08:12 +0100238 return ihs_i2c_send_buffer(dev, chip, addr, alen, hold_bus, I2COP_WRITE);
Mario Six92164212018-01-15 11:08:11 +0100239#else
Mario Six9cef9832018-01-15 11:08:12 +0100240 return ihs_i2c_send_buffer(chip, addr, alen, hold_bus, I2COP_WRITE);
Mario Six92164212018-01-15 11:08:11 +0100241#endif
Dirk Eibachb46226b2014-07-03 09:28:18 +0200242}
243
Mario Six92164212018-01-15 11:08:11 +0100244#ifdef CONFIG_DM_I2C
245static int ihs_i2c_access(struct udevice *dev, uchar chip, u8 *addr,
246 int alen, uchar *buffer, int len, int read)
247#else
Mario Six64ef0942018-01-15 11:08:10 +0100248static int ihs_i2c_access(struct i2c_adapter *adap, uchar chip, u8 *addr,
249 int alen, uchar *buffer, int len, int read)
Mario Six92164212018-01-15 11:08:11 +0100250#endif
Dirk Eibachb46226b2014-07-03 09:28:18 +0200251{
Mario Six64ef0942018-01-15 11:08:10 +0100252 /* Don't hold the bus if length of data to send/receive is zero */
Mario Six92164212018-01-15 11:08:11 +0100253#ifdef CONFIG_DM_I2C
254 if (len <= 0 || ihs_i2c_address(dev, chip, addr, alen, len))
255 return 1;
256#else
Mario Six64ef0942018-01-15 11:08:10 +0100257 if (len <= 0 || ihs_i2c_address(chip, addr, alen, len))
Dirk Eibachb46226b2014-07-03 09:28:18 +0200258 return 1;
Mario Six92164212018-01-15 11:08:11 +0100259#endif
Dirk Eibachb46226b2014-07-03 09:28:18 +0200260
Mario Six92164212018-01-15 11:08:11 +0100261#ifdef CONFIG_DM_I2C
Mario Six9cef9832018-01-15 11:08:12 +0100262 return ihs_i2c_send_buffer(dev, chip, buffer, len, false, read);
Mario Six92164212018-01-15 11:08:11 +0100263#else
Mario Six9cef9832018-01-15 11:08:12 +0100264 return ihs_i2c_send_buffer(chip, buffer, len, false, read);
Mario Six92164212018-01-15 11:08:11 +0100265#endif
Dirk Eibachb46226b2014-07-03 09:28:18 +0200266}
267
Mario Six92164212018-01-15 11:08:11 +0100268#ifdef CONFIG_DM_I2C
269
270int ihs_i2c_probe(struct udevice *bus)
271{
272 struct ihs_i2c_priv *priv = dev_get_priv(bus);
273 int addr;
274
275 addr = dev_read_u32_default(bus, "reg", -1);
276
277 priv->addr = addr;
278
279 return 0;
280}
281
282static int ihs_i2c_set_bus_speed(struct udevice *bus, uint speed)
283{
284 struct ihs_i2c_priv *priv = dev_get_priv(bus);
285
286 if (speed != priv->speed && priv->speed != 0)
287 return 1;
288
289 priv->speed = speed;
290
291 return 0;
292}
293
294static int ihs_i2c_xfer(struct udevice *bus, struct i2c_msg *msg, int nmsgs)
295{
296 struct i2c_msg *dmsg, *omsg, dummy;
297
298 memset(&dummy, 0, sizeof(struct i2c_msg));
299
300 /* We expect either two messages (one with an offset and one with the
301 * actucal data) or one message (just data)
302 */
303 if (nmsgs > 2 || nmsgs == 0) {
304 debug("%s: Only one or two messages are supported.", __func__);
305 return -1;
306 }
307
308 omsg = nmsgs == 1 ? &dummy : msg;
309 dmsg = nmsgs == 1 ? msg : msg + 1;
310
311 if (dmsg->flags & I2C_M_RD)
312 return ihs_i2c_access(bus, dmsg->addr, omsg->buf,
313 omsg->len, dmsg->buf, dmsg->len,
314 I2COP_READ);
315 else
316 return ihs_i2c_access(bus, dmsg->addr, omsg->buf,
317 omsg->len, dmsg->buf, dmsg->len,
318 I2COP_WRITE);
319}
320
321static int ihs_i2c_probe_chip(struct udevice *bus, u32 chip_addr,
322 u32 chip_flags)
323{
324 uchar buffer[2];
325
326 if (ihs_i2c_transfer(bus, chip_addr, buffer, 0, I2COP_READ, true))
327 return 1;
328
329 return 0;
330}
331
332static const struct dm_i2c_ops ihs_i2c_ops = {
333 .xfer = ihs_i2c_xfer,
334 .probe_chip = ihs_i2c_probe_chip,
335 .set_bus_speed = ihs_i2c_set_bus_speed,
336};
337
338static const struct udevice_id ihs_i2c_ids[] = {
339 { .compatible = "gdsys,ihs_i2cmaster", },
340 { /* sentinel */ }
341};
342
343U_BOOT_DRIVER(i2c_ihs) = {
344 .name = "i2c_ihs",
345 .id = UCLASS_I2C,
346 .of_match = ihs_i2c_ids,
347 .probe = ihs_i2c_probe,
348 .priv_auto_alloc_size = sizeof(struct ihs_i2c_priv),
349 .ops = &ihs_i2c_ops,
350};
351
352#else /* CONFIG_DM_I2C */
353
Dirk Eibachb46226b2014-07-03 09:28:18 +0200354static void ihs_i2c_init(struct i2c_adapter *adap, int speed, int slaveaddr)
355{
356#ifdef CONFIG_SYS_I2C_INIT_BOARD
357 /*
358 * Call board specific i2c bus reset routine before accessing the
359 * environment, which might be in a chip on that bus. For details
360 * about this problem see doc/I2C_Edge_Conditions.
361 */
362 i2c_init_board();
363#endif
364}
365
366static int ihs_i2c_probe(struct i2c_adapter *adap, uchar chip)
367{
368 uchar buffer[2];
369
Mario Six64ef0942018-01-15 11:08:10 +0100370 if (ihs_i2c_transfer(chip, buffer, 0, I2COP_READ, true))
Dirk Eibachb46226b2014-07-03 09:28:18 +0200371 return 1;
372
373 return 0;
374}
375
376static int ihs_i2c_read(struct i2c_adapter *adap, uchar chip, uint addr,
377 int alen, uchar *buffer, int len)
378{
Mario Six64ef0942018-01-15 11:08:10 +0100379 u8 addr_bytes[4];
380
381 put_unaligned_le32(addr, addr_bytes);
382
383 return ihs_i2c_access(adap, chip, addr_bytes, alen, buffer, len,
384 I2COP_READ);
Dirk Eibachb46226b2014-07-03 09:28:18 +0200385}
386
387static int ihs_i2c_write(struct i2c_adapter *adap, uchar chip, uint addr,
388 int alen, uchar *buffer, int len)
389{
Mario Six64ef0942018-01-15 11:08:10 +0100390 u8 addr_bytes[4];
391
392 put_unaligned_le32(addr, addr_bytes);
393
394 return ihs_i2c_access(adap, chip, addr_bytes, alen, buffer, len,
395 I2COP_WRITE);
Dirk Eibachb46226b2014-07-03 09:28:18 +0200396}
397
398static unsigned int ihs_i2c_set_bus_speed(struct i2c_adapter *adap,
Dirk Eibach071be892015-10-28 11:46:22 +0100399 unsigned int speed)
Dirk Eibachb46226b2014-07-03 09:28:18 +0200400{
401 if (speed != adap->speed)
402 return 1;
403 return speed;
404}
405
406/*
407 * Register IHS i2c adapters
408 */
409#ifdef CONFIG_SYS_I2C_IHS_CH0
410U_BOOT_I2C_ADAP_COMPLETE(ihs0, ihs_i2c_init, ihs_i2c_probe,
411 ihs_i2c_read, ihs_i2c_write,
412 ihs_i2c_set_bus_speed,
413 CONFIG_SYS_I2C_IHS_SPEED_0,
414 CONFIG_SYS_I2C_IHS_SLAVE_0, 0)
Dirk Eibach071be892015-10-28 11:46:22 +0100415#ifdef CONFIG_SYS_I2C_IHS_DUAL
416U_BOOT_I2C_ADAP_COMPLETE(ihs0_1, ihs_i2c_init, ihs_i2c_probe,
417 ihs_i2c_read, ihs_i2c_write,
418 ihs_i2c_set_bus_speed,
419 CONFIG_SYS_I2C_IHS_SPEED_0_1,
420 CONFIG_SYS_I2C_IHS_SLAVE_0_1, 16)
421#endif
Dirk Eibachb46226b2014-07-03 09:28:18 +0200422#endif
423#ifdef CONFIG_SYS_I2C_IHS_CH1
424U_BOOT_I2C_ADAP_COMPLETE(ihs1, ihs_i2c_init, ihs_i2c_probe,
425 ihs_i2c_read, ihs_i2c_write,
426 ihs_i2c_set_bus_speed,
427 CONFIG_SYS_I2C_IHS_SPEED_1,
428 CONFIG_SYS_I2C_IHS_SLAVE_1, 1)
Dirk Eibach071be892015-10-28 11:46:22 +0100429#ifdef CONFIG_SYS_I2C_IHS_DUAL
430U_BOOT_I2C_ADAP_COMPLETE(ihs1_1, ihs_i2c_init, ihs_i2c_probe,
431 ihs_i2c_read, ihs_i2c_write,
432 ihs_i2c_set_bus_speed,
433 CONFIG_SYS_I2C_IHS_SPEED_1_1,
434 CONFIG_SYS_I2C_IHS_SLAVE_1_1, 17)
435#endif
Dirk Eibachb46226b2014-07-03 09:28:18 +0200436#endif
437#ifdef CONFIG_SYS_I2C_IHS_CH2
438U_BOOT_I2C_ADAP_COMPLETE(ihs2, ihs_i2c_init, ihs_i2c_probe,
439 ihs_i2c_read, ihs_i2c_write,
440 ihs_i2c_set_bus_speed,
441 CONFIG_SYS_I2C_IHS_SPEED_2,
442 CONFIG_SYS_I2C_IHS_SLAVE_2, 2)
Dirk Eibach071be892015-10-28 11:46:22 +0100443#ifdef CONFIG_SYS_I2C_IHS_DUAL
444U_BOOT_I2C_ADAP_COMPLETE(ihs2_1, ihs_i2c_init, ihs_i2c_probe,
445 ihs_i2c_read, ihs_i2c_write,
446 ihs_i2c_set_bus_speed,
447 CONFIG_SYS_I2C_IHS_SPEED_2_1,
448 CONFIG_SYS_I2C_IHS_SLAVE_2_1, 18)
449#endif
Dirk Eibachb46226b2014-07-03 09:28:18 +0200450#endif
451#ifdef CONFIG_SYS_I2C_IHS_CH3
452U_BOOT_I2C_ADAP_COMPLETE(ihs3, ihs_i2c_init, ihs_i2c_probe,
453 ihs_i2c_read, ihs_i2c_write,
454 ihs_i2c_set_bus_speed,
455 CONFIG_SYS_I2C_IHS_SPEED_3,
456 CONFIG_SYS_I2C_IHS_SLAVE_3, 3)
Dirk Eibach071be892015-10-28 11:46:22 +0100457#ifdef CONFIG_SYS_I2C_IHS_DUAL
458U_BOOT_I2C_ADAP_COMPLETE(ihs3_1, ihs_i2c_init, ihs_i2c_probe,
459 ihs_i2c_read, ihs_i2c_write,
460 ihs_i2c_set_bus_speed,
461 CONFIG_SYS_I2C_IHS_SPEED_3_1,
462 CONFIG_SYS_I2C_IHS_SLAVE_3_1, 19)
463#endif
Dirk Eibachb46226b2014-07-03 09:28:18 +0200464#endif
Mario Six92164212018-01-15 11:08:11 +0100465#endif /* CONFIG_DM_I2C */