blob: f7b59d36f983a8290cef2393ca847f597701f8a5 [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>
Mario Six98e42492019-01-28 09:45:57 +010011#include <regmap.h>
Mario Six92164212018-01-15 11:08:11 +010012#else
Dirk Eibachb46226b2014-07-03 09:28:18 +020013#include <gdsys_fpga.h>
Mario Six92164212018-01-15 11:08:11 +010014#endif
Mario Six64ef0942018-01-15 11:08:10 +010015#include <asm/unaligned.h>
Dirk Eibachb46226b2014-07-03 09:28:18 +020016
Mario Six92164212018-01-15 11:08:11 +010017#ifdef CONFIG_DM_I2C
18struct ihs_i2c_priv {
19 uint speed;
Mario Six98e42492019-01-28 09:45:57 +010020 struct regmap *map;
Mario Six92164212018-01-15 11:08:11 +010021};
22
Mario Six98e42492019-01-28 09:45:57 +010023struct ihs_i2c_regs {
24 u16 interrupt_status;
25 u16 interrupt_enable_control;
26 u16 write_mailbox_ext;
27 u16 write_mailbox;
28 u16 read_mailbox_ext;
29 u16 read_mailbox;
Mario Six92164212018-01-15 11:08:11 +010030};
31
Mario Six98e42492019-01-28 09:45:57 +010032#define ihs_i2c_set(map, member, val) \
33 regmap_set(map, struct ihs_i2c_regs, member, val)
34
35#define ihs_i2c_get(map, member, valp) \
36 regmap_get(map, struct ihs_i2c_regs, member, valp)
37
Mario Six92164212018-01-15 11:08:11 +010038#else /* !CONFIG_DM_I2C */
Dirk Eibachb46226b2014-07-03 09:28:18 +020039DECLARE_GLOBAL_DATA_PTR;
40
Dirk Eibach071be892015-10-28 11:46:22 +010041#ifdef CONFIG_SYS_I2C_IHS_DUAL
Mario Six92164212018-01-15 11:08:11 +010042
Dirk Eibach071be892015-10-28 11:46:22 +010043#define I2C_SET_REG(fld, val) \
Dirk Eibach3af0cdb2015-10-28 11:46:23 +010044 do { \
45 if (I2C_ADAP_HWNR & 0x10) \
46 FPGA_SET_REG(I2C_ADAP_HWNR & 0xf, i2c1.fld, val); \
47 else \
48 FPGA_SET_REG(I2C_ADAP_HWNR, i2c0.fld, val); \
49 } while (0)
Dirk Eibach071be892015-10-28 11:46:22 +010050#else
51#define I2C_SET_REG(fld, val) \
Dirk Eibach3af0cdb2015-10-28 11:46:23 +010052 FPGA_SET_REG(I2C_ADAP_HWNR, i2c0.fld, val)
Dirk Eibach071be892015-10-28 11:46:22 +010053#endif
54
55#ifdef CONFIG_SYS_I2C_IHS_DUAL
56#define I2C_GET_REG(fld, val) \
Dirk Eibach3af0cdb2015-10-28 11:46:23 +010057 do { \
58 if (I2C_ADAP_HWNR & 0x10) \
59 FPGA_GET_REG(I2C_ADAP_HWNR & 0xf, i2c1.fld, val); \
60 else \
61 FPGA_GET_REG(I2C_ADAP_HWNR, i2c0.fld, val); \
62 } while (0)
Dirk Eibach071be892015-10-28 11:46:22 +010063#else
64#define I2C_GET_REG(fld, val) \
Dirk Eibach3af0cdb2015-10-28 11:46:23 +010065 FPGA_GET_REG(I2C_ADAP_HWNR, i2c0.fld, val)
Dirk Eibach071be892015-10-28 11:46:22 +010066#endif
Mario Six92164212018-01-15 11:08:11 +010067#endif /* CONFIG_DM_I2C */
Dirk Eibach071be892015-10-28 11:46:22 +010068
Dirk Eibachb46226b2014-07-03 09:28:18 +020069enum {
Mario Six64ef0942018-01-15 11:08:10 +010070 I2CINT_ERROR_EV = BIT(13),
71 I2CINT_TRANSMIT_EV = BIT(14),
72 I2CINT_RECEIVE_EV = BIT(15),
Dirk Eibachb46226b2014-07-03 09:28:18 +020073};
74
75enum {
Mario Six64ef0942018-01-15 11:08:10 +010076 I2CMB_READ = 0 << 10,
Dirk Eibachb46226b2014-07-03 09:28:18 +020077 I2CMB_WRITE = 1 << 10,
Mario Six64ef0942018-01-15 11:08:10 +010078 I2CMB_1BYTE = 0 << 11,
Dirk Eibachb46226b2014-07-03 09:28:18 +020079 I2CMB_2BYTE = 1 << 11,
Mario Six64ef0942018-01-15 11:08:10 +010080 I2CMB_DONT_HOLD_BUS = 0 << 13,
Dirk Eibachb46226b2014-07-03 09:28:18 +020081 I2CMB_HOLD_BUS = 1 << 13,
82 I2CMB_NATIVE = 2 << 14,
83};
84
Mario Six64ef0942018-01-15 11:08:10 +010085enum {
86 I2COP_WRITE = 0,
87 I2COP_READ = 1,
88};
89
Mario Six92164212018-01-15 11:08:11 +010090#ifdef CONFIG_DM_I2C
91static int wait_for_int(struct udevice *dev, int read)
92#else
Dirk Eibachb46226b2014-07-03 09:28:18 +020093static int wait_for_int(bool read)
Mario Six92164212018-01-15 11:08:11 +010094#endif
Dirk Eibachb46226b2014-07-03 09:28:18 +020095{
96 u16 val;
Mario Six64ef0942018-01-15 11:08:10 +010097 uint ctr = 0;
Mario Six92164212018-01-15 11:08:11 +010098#ifdef CONFIG_DM_I2C
99 struct ihs_i2c_priv *priv = dev_get_priv(dev);
Mario Six92164212018-01-15 11:08:11 +0100100#endif
101
102#ifdef CONFIG_DM_I2C
Mario Six98e42492019-01-28 09:45:57 +0100103 ihs_i2c_get(priv->map, interrupt_status, &val);
Mario Six92164212018-01-15 11:08:11 +0100104#else
Dirk Eibach071be892015-10-28 11:46:22 +0100105 I2C_GET_REG(interrupt_status, &val);
Mario Six92164212018-01-15 11:08:11 +0100106#endif
Mario Six64ef0942018-01-15 11:08:10 +0100107 /* Wait until error or receive/transmit interrupt was raised */
Dirk Eibachb46226b2014-07-03 09:28:18 +0200108 while (!(val & (I2CINT_ERROR_EV
109 | (read ? I2CINT_RECEIVE_EV : I2CINT_TRANSMIT_EV)))) {
110 udelay(10);
Mario Six482c76e2019-01-28 09:45:58 +0100111 if (ctr++ > 5000) {
112 debug("%s: timed out\n", __func__);
113 return -ETIMEDOUT;
114 }
Mario Six92164212018-01-15 11:08:11 +0100115#ifdef CONFIG_DM_I2C
Mario Six98e42492019-01-28 09:45:57 +0100116 ihs_i2c_get(priv->map, interrupt_status, &val);
Mario Six92164212018-01-15 11:08:11 +0100117#else
Dirk Eibach071be892015-10-28 11:46:22 +0100118 I2C_GET_REG(interrupt_status, &val);
Mario Six92164212018-01-15 11:08:11 +0100119#endif
Dirk Eibachb46226b2014-07-03 09:28:18 +0200120 }
121
Mario Six482c76e2019-01-28 09:45:58 +0100122 return (val & I2CINT_ERROR_EV) ? -EIO : 0;
Dirk Eibachb46226b2014-07-03 09:28:18 +0200123}
124
Mario Six92164212018-01-15 11:08:11 +0100125#ifdef CONFIG_DM_I2C
126static int ihs_i2c_transfer(struct udevice *dev, uchar chip,
127 uchar *buffer, int len, int read, bool is_last)
128#else
Dirk Eibachb46226b2014-07-03 09:28:18 +0200129static int ihs_i2c_transfer(uchar chip, uchar *buffer, int len, bool read,
130 bool is_last)
Mario Six92164212018-01-15 11:08:11 +0100131#endif
Dirk Eibachb46226b2014-07-03 09:28:18 +0200132{
133 u16 val;
Mario Six2df71d62018-03-28 14:37:42 +0200134 u16 data;
Mario Six482c76e2019-01-28 09:45:58 +0100135 int res;
Mario Six92164212018-01-15 11:08:11 +0100136#ifdef CONFIG_DM_I2C
137 struct ihs_i2c_priv *priv = dev_get_priv(dev);
Mario Six92164212018-01-15 11:08:11 +0100138#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 Six98e42492019-01-28 09:45:57 +0100143 ihs_i2c_set(priv->map, interrupt_status, data);
144 ihs_i2c_get(priv->map, interrupt_status, &val);
Mario Six92164212018-01-15 11:08:11 +0100145#else
Mario Six2df71d62018-03-28 14:37:42 +0200146 I2C_SET_REG(interrupt_status, data);
Dirk Eibach071be892015-10-28 11:46:22 +0100147 I2C_GET_REG(interrupt_status, &val);
Mario Six92164212018-01-15 11:08:11 +0100148#endif
Dirk Eibachb46226b2014-07-03 09:28:18 +0200149
Mario Six64ef0942018-01-15 11:08:10 +0100150 /* If we want to write and have data, write the bytes to the mailbox */
Dirk Eibachb46226b2014-07-03 09:28:18 +0200151 if (!read && len) {
152 val = buffer[0];
153
154 if (len > 1)
155 val |= buffer[1] << 8;
Mario Six92164212018-01-15 11:08:11 +0100156#ifdef CONFIG_DM_I2C
Mario Six98e42492019-01-28 09:45:57 +0100157 ihs_i2c_set(priv->map, write_mailbox_ext, val);
Mario Six92164212018-01-15 11:08:11 +0100158#else
Dirk Eibach071be892015-10-28 11:46:22 +0100159 I2C_SET_REG(write_mailbox_ext, val);
Mario Six92164212018-01-15 11:08:11 +0100160#endif
Dirk Eibachb46226b2014-07-03 09:28:18 +0200161 }
162
Mario Six2df71d62018-03-28 14:37:42 +0200163 data = I2CMB_NATIVE
164 | (read ? 0 : I2CMB_WRITE)
165 | (chip << 1)
166 | ((len > 1) ? I2CMB_2BYTE : 0)
167 | (is_last ? 0 : I2CMB_HOLD_BUS);
168
Mario Six92164212018-01-15 11:08:11 +0100169#ifdef CONFIG_DM_I2C
Mario Six98e42492019-01-28 09:45:57 +0100170 ihs_i2c_set(priv->map, write_mailbox, data);
Mario Six92164212018-01-15 11:08:11 +0100171#else
Mario Six2df71d62018-03-28 14:37:42 +0200172 I2C_SET_REG(write_mailbox, data);
Mario Six92164212018-01-15 11:08:11 +0100173#endif
Dirk Eibachb46226b2014-07-03 09:28:18 +0200174
Mario Six92164212018-01-15 11:08:11 +0100175#ifdef CONFIG_DM_I2C
Mario Six482c76e2019-01-28 09:45:58 +0100176 res = wait_for_int(dev, read);
Mario Six92164212018-01-15 11:08:11 +0100177#else
Mario Six482c76e2019-01-28 09:45:58 +0100178 res = wait_for_int(read);
Mario Six92164212018-01-15 11:08:11 +0100179#endif
Mario Six482c76e2019-01-28 09:45:58 +0100180 if (res) {
181 if (res == -ETIMEDOUT)
182 debug("%s: time out while waiting for event\n", __func__);
183
184 return res;
185 }
Dirk Eibachb46226b2014-07-03 09:28:18 +0200186
Mario Six64ef0942018-01-15 11:08:10 +0100187 /* If we want to read, get the bytes from the mailbox */
Dirk Eibachb46226b2014-07-03 09:28:18 +0200188 if (read) {
Mario Six92164212018-01-15 11:08:11 +0100189#ifdef CONFIG_DM_I2C
Mario Six98e42492019-01-28 09:45:57 +0100190 ihs_i2c_get(priv->map, read_mailbox_ext, &val);
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{
Mario Six482c76e2019-01-28 09:45:58 +0100209 int res;
210
Mario Six9cef9832018-01-15 11:08:12 +0100211 while (len) {
212 int transfer = min(len, 2);
213 bool is_last = len <= transfer;
214
215#ifdef CONFIG_DM_I2C
Mario Six482c76e2019-01-28 09:45:58 +0100216 res = ihs_i2c_transfer(dev, chip, data, transfer, read,
217 hold_bus ? false : is_last);
Mario Six9cef9832018-01-15 11:08:12 +0100218#else
Mario Six482c76e2019-01-28 09:45:58 +0100219 res = ihs_i2c_transfer(chip, data, transfer, read,
220 hold_bus ? false : is_last);
Mario Six9cef9832018-01-15 11:08:12 +0100221#endif
Mario Six482c76e2019-01-28 09:45:58 +0100222 if (res)
223 return res;
Mario Six9cef9832018-01-15 11:08:12 +0100224
225 data += transfer;
226 len -= transfer;
227 }
228
229 return 0;
230}
231
232#ifdef CONFIG_DM_I2C
233static int ihs_i2c_address(struct udevice *dev, uchar chip, u8 *addr, int alen,
234 bool hold_bus)
Mario Six92164212018-01-15 11:08:11 +0100235#else
Mario Six64ef0942018-01-15 11:08:10 +0100236static int ihs_i2c_address(uchar chip, u8 *addr, int alen, bool hold_bus)
Mario Six92164212018-01-15 11:08:11 +0100237#endif
Dirk Eibachb46226b2014-07-03 09:28:18 +0200238{
Mario Six92164212018-01-15 11:08:11 +0100239#ifdef CONFIG_DM_I2C
Mario Six9cef9832018-01-15 11:08:12 +0100240 return ihs_i2c_send_buffer(dev, chip, addr, alen, hold_bus, I2COP_WRITE);
Mario Six92164212018-01-15 11:08:11 +0100241#else
Mario Six9cef9832018-01-15 11:08:12 +0100242 return ihs_i2c_send_buffer(chip, addr, alen, hold_bus, I2COP_WRITE);
Mario Six92164212018-01-15 11:08:11 +0100243#endif
Dirk Eibachb46226b2014-07-03 09:28:18 +0200244}
245
Mario Six92164212018-01-15 11:08:11 +0100246#ifdef CONFIG_DM_I2C
247static int ihs_i2c_access(struct udevice *dev, uchar chip, u8 *addr,
248 int alen, uchar *buffer, int len, int read)
249#else
Mario Six64ef0942018-01-15 11:08:10 +0100250static int ihs_i2c_access(struct i2c_adapter *adap, uchar chip, u8 *addr,
251 int alen, uchar *buffer, int len, int read)
Mario Six92164212018-01-15 11:08:11 +0100252#endif
Dirk Eibachb46226b2014-07-03 09:28:18 +0200253{
Mario Six482c76e2019-01-28 09:45:58 +0100254 int res;
255
Mario Six64ef0942018-01-15 11:08:10 +0100256 /* Don't hold the bus if length of data to send/receive is zero */
Mario Six482c76e2019-01-28 09:45:58 +0100257 if (len <= 0)
258 return -EINVAL;
259
Mario Six92164212018-01-15 11:08:11 +0100260#ifdef CONFIG_DM_I2C
Mario Six482c76e2019-01-28 09:45:58 +0100261 res = ihs_i2c_address(dev, chip, addr, alen, len);
Mario Six92164212018-01-15 11:08:11 +0100262#else
Mario Six482c76e2019-01-28 09:45:58 +0100263 res = ihs_i2c_address(chip, addr, alen, len);
Mario Six92164212018-01-15 11:08:11 +0100264#endif
Mario Six482c76e2019-01-28 09:45:58 +0100265 if (res)
266 return res;
Dirk Eibachb46226b2014-07-03 09:28:18 +0200267
Mario Six92164212018-01-15 11:08:11 +0100268#ifdef CONFIG_DM_I2C
Mario Six9cef9832018-01-15 11:08:12 +0100269 return ihs_i2c_send_buffer(dev, chip, buffer, len, false, read);
Mario Six92164212018-01-15 11:08:11 +0100270#else
Mario Six9cef9832018-01-15 11:08:12 +0100271 return ihs_i2c_send_buffer(chip, buffer, len, false, read);
Mario Six92164212018-01-15 11:08:11 +0100272#endif
Dirk Eibachb46226b2014-07-03 09:28:18 +0200273}
274
Mario Six92164212018-01-15 11:08:11 +0100275#ifdef CONFIG_DM_I2C
276
277int ihs_i2c_probe(struct udevice *bus)
278{
279 struct ihs_i2c_priv *priv = dev_get_priv(bus);
Mario Six92164212018-01-15 11:08:11 +0100280
Mario Six98e42492019-01-28 09:45:57 +0100281 regmap_init_mem(dev_ofnode(bus), &priv->map);
Mario Six92164212018-01-15 11:08:11 +0100282
283 return 0;
284}
285
286static int ihs_i2c_set_bus_speed(struct udevice *bus, uint speed)
287{
288 struct ihs_i2c_priv *priv = dev_get_priv(bus);
289
290 if (speed != priv->speed && priv->speed != 0)
Mario Six482c76e2019-01-28 09:45:58 +0100291 return -EINVAL;
Mario Six92164212018-01-15 11:08:11 +0100292
293 priv->speed = speed;
294
295 return 0;
296}
297
298static int ihs_i2c_xfer(struct udevice *bus, struct i2c_msg *msg, int nmsgs)
299{
300 struct i2c_msg *dmsg, *omsg, dummy;
301
302 memset(&dummy, 0, sizeof(struct i2c_msg));
303
304 /* We expect either two messages (one with an offset and one with the
305 * actucal data) or one message (just data)
306 */
307 if (nmsgs > 2 || nmsgs == 0) {
Mario Six482c76e2019-01-28 09:45:58 +0100308 debug("%s: Only one or two messages are supported\n", __func__);
309 return -ENOTSUPP;
Mario Six92164212018-01-15 11:08:11 +0100310 }
311
312 omsg = nmsgs == 1 ? &dummy : msg;
313 dmsg = nmsgs == 1 ? msg : msg + 1;
314
315 if (dmsg->flags & I2C_M_RD)
316 return ihs_i2c_access(bus, dmsg->addr, omsg->buf,
317 omsg->len, dmsg->buf, dmsg->len,
318 I2COP_READ);
319 else
320 return ihs_i2c_access(bus, dmsg->addr, omsg->buf,
321 omsg->len, dmsg->buf, dmsg->len,
322 I2COP_WRITE);
323}
324
325static int ihs_i2c_probe_chip(struct udevice *bus, u32 chip_addr,
326 u32 chip_flags)
327{
328 uchar buffer[2];
Mario Six482c76e2019-01-28 09:45:58 +0100329 int res;
Mario Six92164212018-01-15 11:08:11 +0100330
Mario Six482c76e2019-01-28 09:45:58 +0100331 res = ihs_i2c_transfer(bus, chip_addr, buffer, 0, I2COP_READ, true);
332 if (res)
333 return res;
Mario Six92164212018-01-15 11:08:11 +0100334
335 return 0;
336}
337
338static const struct dm_i2c_ops ihs_i2c_ops = {
339 .xfer = ihs_i2c_xfer,
340 .probe_chip = ihs_i2c_probe_chip,
341 .set_bus_speed = ihs_i2c_set_bus_speed,
342};
343
344static const struct udevice_id ihs_i2c_ids[] = {
345 { .compatible = "gdsys,ihs_i2cmaster", },
346 { /* sentinel */ }
347};
348
349U_BOOT_DRIVER(i2c_ihs) = {
350 .name = "i2c_ihs",
351 .id = UCLASS_I2C,
352 .of_match = ihs_i2c_ids,
353 .probe = ihs_i2c_probe,
354 .priv_auto_alloc_size = sizeof(struct ihs_i2c_priv),
355 .ops = &ihs_i2c_ops,
356};
357
358#else /* CONFIG_DM_I2C */
359
Dirk Eibachb46226b2014-07-03 09:28:18 +0200360static void ihs_i2c_init(struct i2c_adapter *adap, int speed, int slaveaddr)
361{
362#ifdef CONFIG_SYS_I2C_INIT_BOARD
363 /*
364 * Call board specific i2c bus reset routine before accessing the
365 * environment, which might be in a chip on that bus. For details
366 * about this problem see doc/I2C_Edge_Conditions.
367 */
368 i2c_init_board();
369#endif
370}
371
372static int ihs_i2c_probe(struct i2c_adapter *adap, uchar chip)
373{
374 uchar buffer[2];
Mario Six482c76e2019-01-28 09:45:58 +0100375 int res;
Dirk Eibachb46226b2014-07-03 09:28:18 +0200376
Mario Six482c76e2019-01-28 09:45:58 +0100377 res = ihs_i2c_transfer(chip, buffer, 0, I2COP_READ, true);
378 if (res)
379 return res;
Dirk Eibachb46226b2014-07-03 09:28:18 +0200380
381 return 0;
382}
383
384static int ihs_i2c_read(struct i2c_adapter *adap, uchar chip, uint addr,
385 int alen, uchar *buffer, int len)
386{
Mario Six64ef0942018-01-15 11:08:10 +0100387 u8 addr_bytes[4];
388
389 put_unaligned_le32(addr, addr_bytes);
390
391 return ihs_i2c_access(adap, chip, addr_bytes, alen, buffer, len,
392 I2COP_READ);
Dirk Eibachb46226b2014-07-03 09:28:18 +0200393}
394
395static int ihs_i2c_write(struct i2c_adapter *adap, uchar chip, uint addr,
396 int alen, uchar *buffer, int len)
397{
Mario Six64ef0942018-01-15 11:08:10 +0100398 u8 addr_bytes[4];
399
400 put_unaligned_le32(addr, addr_bytes);
401
402 return ihs_i2c_access(adap, chip, addr_bytes, alen, buffer, len,
403 I2COP_WRITE);
Dirk Eibachb46226b2014-07-03 09:28:18 +0200404}
405
406static unsigned int ihs_i2c_set_bus_speed(struct i2c_adapter *adap,
Dirk Eibach071be892015-10-28 11:46:22 +0100407 unsigned int speed)
Dirk Eibachb46226b2014-07-03 09:28:18 +0200408{
409 if (speed != adap->speed)
Mario Six482c76e2019-01-28 09:45:58 +0100410 return -EINVAL;
Dirk Eibachb46226b2014-07-03 09:28:18 +0200411 return speed;
412}
413
414/*
415 * Register IHS i2c adapters
416 */
417#ifdef CONFIG_SYS_I2C_IHS_CH0
418U_BOOT_I2C_ADAP_COMPLETE(ihs0, ihs_i2c_init, ihs_i2c_probe,
419 ihs_i2c_read, ihs_i2c_write,
420 ihs_i2c_set_bus_speed,
421 CONFIG_SYS_I2C_IHS_SPEED_0,
422 CONFIG_SYS_I2C_IHS_SLAVE_0, 0)
Dirk Eibach071be892015-10-28 11:46:22 +0100423#ifdef CONFIG_SYS_I2C_IHS_DUAL
424U_BOOT_I2C_ADAP_COMPLETE(ihs0_1, 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_0_1,
428 CONFIG_SYS_I2C_IHS_SLAVE_0_1, 16)
429#endif
Dirk Eibachb46226b2014-07-03 09:28:18 +0200430#endif
431#ifdef CONFIG_SYS_I2C_IHS_CH1
432U_BOOT_I2C_ADAP_COMPLETE(ihs1, ihs_i2c_init, ihs_i2c_probe,
433 ihs_i2c_read, ihs_i2c_write,
434 ihs_i2c_set_bus_speed,
435 CONFIG_SYS_I2C_IHS_SPEED_1,
436 CONFIG_SYS_I2C_IHS_SLAVE_1, 1)
Dirk Eibach071be892015-10-28 11:46:22 +0100437#ifdef CONFIG_SYS_I2C_IHS_DUAL
438U_BOOT_I2C_ADAP_COMPLETE(ihs1_1, 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_1_1,
442 CONFIG_SYS_I2C_IHS_SLAVE_1_1, 17)
443#endif
Dirk Eibachb46226b2014-07-03 09:28:18 +0200444#endif
445#ifdef CONFIG_SYS_I2C_IHS_CH2
446U_BOOT_I2C_ADAP_COMPLETE(ihs2, ihs_i2c_init, ihs_i2c_probe,
447 ihs_i2c_read, ihs_i2c_write,
448 ihs_i2c_set_bus_speed,
449 CONFIG_SYS_I2C_IHS_SPEED_2,
450 CONFIG_SYS_I2C_IHS_SLAVE_2, 2)
Dirk Eibach071be892015-10-28 11:46:22 +0100451#ifdef CONFIG_SYS_I2C_IHS_DUAL
452U_BOOT_I2C_ADAP_COMPLETE(ihs2_1, 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_2_1,
456 CONFIG_SYS_I2C_IHS_SLAVE_2_1, 18)
457#endif
Dirk Eibachb46226b2014-07-03 09:28:18 +0200458#endif
459#ifdef CONFIG_SYS_I2C_IHS_CH3
460U_BOOT_I2C_ADAP_COMPLETE(ihs3, ihs_i2c_init, ihs_i2c_probe,
461 ihs_i2c_read, ihs_i2c_write,
462 ihs_i2c_set_bus_speed,
463 CONFIG_SYS_I2C_IHS_SPEED_3,
464 CONFIG_SYS_I2C_IHS_SLAVE_3, 3)
Dirk Eibach071be892015-10-28 11:46:22 +0100465#ifdef CONFIG_SYS_I2C_IHS_DUAL
466U_BOOT_I2C_ADAP_COMPLETE(ihs3_1, ihs_i2c_init, ihs_i2c_probe,
467 ihs_i2c_read, ihs_i2c_write,
468 ihs_i2c_set_bus_speed,
469 CONFIG_SYS_I2C_IHS_SPEED_3_1,
470 CONFIG_SYS_I2C_IHS_SLAVE_3_1, 19)
471#endif
Dirk Eibachb46226b2014-07-03 09:28:18 +0200472#endif
Mario Six92164212018-01-15 11:08:11 +0100473#endif /* CONFIG_DM_I2C */