mxc_i2c.c 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565
  1. /*
  2. * i2c driver for Freescale i.MX series
  3. *
  4. * (c) 2007 Pengutronix, Sascha Hauer <s.hauer@pengutronix.de>
  5. * (c) 2011 Marek Vasut <marek.vasut@gmail.com>
  6. *
  7. * Based on i2c-imx.c from linux kernel:
  8. * Copyright (C) 2005 Torsten Koschorrek <koschorrek at synertronixx.de>
  9. * Copyright (C) 2005 Matthias Blaschke <blaschke at synertronixx.de>
  10. * Copyright (C) 2007 RightHand Technologies, Inc.
  11. * Copyright (C) 2008 Darius Augulis <darius.augulis at teltonika.lt>
  12. *
  13. *
  14. * SPDX-License-Identifier: GPL-2.0+
  15. */
  16. #include <common.h>
  17. #include <asm/arch/clock.h>
  18. #include <asm/arch/imx-regs.h>
  19. #include <asm/errno.h>
  20. #include <asm/io.h>
  21. #include <i2c.h>
  22. #include <watchdog.h>
  23. DECLARE_GLOBAL_DATA_PTR;
  24. #ifdef I2C_QUIRK_REG
  25. struct mxc_i2c_regs {
  26. uint8_t iadr;
  27. uint8_t ifdr;
  28. uint8_t i2cr;
  29. uint8_t i2sr;
  30. uint8_t i2dr;
  31. };
  32. #else
  33. struct mxc_i2c_regs {
  34. uint32_t iadr;
  35. uint32_t ifdr;
  36. uint32_t i2cr;
  37. uint32_t i2sr;
  38. uint32_t i2dr;
  39. };
  40. #endif
  41. #define I2CR_IIEN (1 << 6)
  42. #define I2CR_MSTA (1 << 5)
  43. #define I2CR_MTX (1 << 4)
  44. #define I2CR_TX_NO_AK (1 << 3)
  45. #define I2CR_RSTA (1 << 2)
  46. #define I2SR_ICF (1 << 7)
  47. #define I2SR_IBB (1 << 5)
  48. #define I2SR_IAL (1 << 4)
  49. #define I2SR_IIF (1 << 1)
  50. #define I2SR_RX_NO_AK (1 << 0)
  51. #ifdef I2C_QUIRK_REG
  52. #define I2CR_IEN (0 << 7)
  53. #define I2CR_IDIS (1 << 7)
  54. #define I2SR_IIF_CLEAR (1 << 1)
  55. #else
  56. #define I2CR_IEN (1 << 7)
  57. #define I2CR_IDIS (0 << 7)
  58. #define I2SR_IIF_CLEAR (0 << 1)
  59. #endif
  60. #if defined(CONFIG_HARD_I2C) && !defined(CONFIG_SYS_I2C_BASE)
  61. #error "define CONFIG_SYS_I2C_BASE to use the mxc_i2c driver"
  62. #endif
  63. #ifdef I2C_QUIRK_REG
  64. static u16 i2c_clk_div[60][2] = {
  65. { 20, 0x00 }, { 22, 0x01 }, { 24, 0x02 }, { 26, 0x03 },
  66. { 28, 0x04 }, { 30, 0x05 }, { 32, 0x09 }, { 34, 0x06 },
  67. { 36, 0x0A }, { 40, 0x07 }, { 44, 0x0C }, { 48, 0x0D },
  68. { 52, 0x43 }, { 56, 0x0E }, { 60, 0x45 }, { 64, 0x12 },
  69. { 68, 0x0F }, { 72, 0x13 }, { 80, 0x14 }, { 88, 0x15 },
  70. { 96, 0x19 }, { 104, 0x16 }, { 112, 0x1A }, { 128, 0x17 },
  71. { 136, 0x4F }, { 144, 0x1C }, { 160, 0x1D }, { 176, 0x55 },
  72. { 192, 0x1E }, { 208, 0x56 }, { 224, 0x22 }, { 228, 0x24 },
  73. { 240, 0x1F }, { 256, 0x23 }, { 288, 0x5C }, { 320, 0x25 },
  74. { 384, 0x26 }, { 448, 0x2A }, { 480, 0x27 }, { 512, 0x2B },
  75. { 576, 0x2C }, { 640, 0x2D }, { 768, 0x31 }, { 896, 0x32 },
  76. { 960, 0x2F }, { 1024, 0x33 }, { 1152, 0x34 }, { 1280, 0x35 },
  77. { 1536, 0x36 }, { 1792, 0x3A }, { 1920, 0x37 }, { 2048, 0x3B },
  78. { 2304, 0x3C }, { 2560, 0x3D }, { 3072, 0x3E }, { 3584, 0x7A },
  79. { 3840, 0x3F }, { 4096, 0x7B }, { 5120, 0x7D }, { 6144, 0x7E },
  80. };
  81. #else
  82. static u16 i2c_clk_div[50][2] = {
  83. { 22, 0x20 }, { 24, 0x21 }, { 26, 0x22 }, { 28, 0x23 },
  84. { 30, 0x00 }, { 32, 0x24 }, { 36, 0x25 }, { 40, 0x26 },
  85. { 42, 0x03 }, { 44, 0x27 }, { 48, 0x28 }, { 52, 0x05 },
  86. { 56, 0x29 }, { 60, 0x06 }, { 64, 0x2A }, { 72, 0x2B },
  87. { 80, 0x2C }, { 88, 0x09 }, { 96, 0x2D }, { 104, 0x0A },
  88. { 112, 0x2E }, { 128, 0x2F }, { 144, 0x0C }, { 160, 0x30 },
  89. { 192, 0x31 }, { 224, 0x32 }, { 240, 0x0F }, { 256, 0x33 },
  90. { 288, 0x10 }, { 320, 0x34 }, { 384, 0x35 }, { 448, 0x36 },
  91. { 480, 0x13 }, { 512, 0x37 }, { 576, 0x14 }, { 640, 0x38 },
  92. { 768, 0x39 }, { 896, 0x3A }, { 960, 0x17 }, { 1024, 0x3B },
  93. { 1152, 0x18 }, { 1280, 0x3C }, { 1536, 0x3D }, { 1792, 0x3E },
  94. { 1920, 0x1B }, { 2048, 0x3F }, { 2304, 0x1C }, { 2560, 0x1D },
  95. { 3072, 0x1E }, { 3840, 0x1F }
  96. };
  97. #endif
  98. #ifndef CONFIG_SYS_MXC_I2C1_SPEED
  99. #define CONFIG_SYS_MXC_I2C1_SPEED 100000
  100. #endif
  101. #ifndef CONFIG_SYS_MXC_I2C2_SPEED
  102. #define CONFIG_SYS_MXC_I2C2_SPEED 100000
  103. #endif
  104. #ifndef CONFIG_SYS_MXC_I2C3_SPEED
  105. #define CONFIG_SYS_MXC_I2C3_SPEED 100000
  106. #endif
  107. #ifndef CONFIG_SYS_MXC_I2C4_SPEED
  108. #define CONFIG_SYS_MXC_I2C4_SPEED 100000
  109. #endif
  110. #ifndef CONFIG_SYS_MXC_I2C1_SLAVE
  111. #define CONFIG_SYS_MXC_I2C1_SLAVE 0
  112. #endif
  113. #ifndef CONFIG_SYS_MXC_I2C2_SLAVE
  114. #define CONFIG_SYS_MXC_I2C2_SLAVE 0
  115. #endif
  116. #ifndef CONFIG_SYS_MXC_I2C3_SLAVE
  117. #define CONFIG_SYS_MXC_I2C3_SLAVE 0
  118. #endif
  119. #ifndef CONFIG_SYS_MXC_I2C4_SLAVE
  120. #define CONFIG_SYS_MXC_I2C4_SLAVE 0
  121. #endif
  122. /*
  123. * Calculate and set proper clock divider
  124. */
  125. static uint8_t i2c_imx_get_clk(unsigned int rate)
  126. {
  127. unsigned int i2c_clk_rate;
  128. unsigned int div;
  129. u8 clk_div;
  130. #if defined(CONFIG_MX31)
  131. struct clock_control_regs *sc_regs =
  132. (struct clock_control_regs *)CCM_BASE;
  133. /* start the required I2C clock */
  134. writel(readl(&sc_regs->cgr0) | (3 << CONFIG_SYS_I2C_CLK_OFFSET),
  135. &sc_regs->cgr0);
  136. #endif
  137. /* Divider value calculation */
  138. i2c_clk_rate = mxc_get_clock(MXC_I2C_CLK);
  139. div = (i2c_clk_rate + rate - 1) / rate;
  140. if (div < i2c_clk_div[0][0])
  141. clk_div = 0;
  142. else if (div > i2c_clk_div[ARRAY_SIZE(i2c_clk_div) - 1][0])
  143. clk_div = ARRAY_SIZE(i2c_clk_div) - 1;
  144. else
  145. for (clk_div = 0; i2c_clk_div[clk_div][0] < div; clk_div++)
  146. ;
  147. /* Store divider value */
  148. return clk_div;
  149. }
  150. /*
  151. * Set I2C Bus speed
  152. */
  153. static int bus_i2c_set_bus_speed(void *base, int speed)
  154. {
  155. struct mxc_i2c_regs *i2c_regs = (struct mxc_i2c_regs *)base;
  156. u8 clk_idx = i2c_imx_get_clk(speed);
  157. u8 idx = i2c_clk_div[clk_idx][1];
  158. /* Store divider value */
  159. writeb(idx, &i2c_regs->ifdr);
  160. /* Reset module */
  161. writeb(I2CR_IDIS, &i2c_regs->i2cr);
  162. writeb(0, &i2c_regs->i2sr);
  163. return 0;
  164. }
  165. #define ST_BUS_IDLE (0 | (I2SR_IBB << 8))
  166. #define ST_BUS_BUSY (I2SR_IBB | (I2SR_IBB << 8))
  167. #define ST_IIF (I2SR_IIF | (I2SR_IIF << 8))
  168. static int wait_for_sr_state(struct mxc_i2c_regs *i2c_regs, unsigned state)
  169. {
  170. unsigned sr;
  171. ulong elapsed;
  172. ulong start_time = get_timer(0);
  173. for (;;) {
  174. sr = readb(&i2c_regs->i2sr);
  175. if (sr & I2SR_IAL) {
  176. #ifdef I2C_QUIRK_REG
  177. writeb(sr | I2SR_IAL, &i2c_regs->i2sr);
  178. #else
  179. writeb(sr & ~I2SR_IAL, &i2c_regs->i2sr);
  180. #endif
  181. printf("%s: Arbitration lost sr=%x cr=%x state=%x\n",
  182. __func__, sr, readb(&i2c_regs->i2cr), state);
  183. return -ERESTART;
  184. }
  185. if ((sr & (state >> 8)) == (unsigned char)state)
  186. return sr;
  187. WATCHDOG_RESET();
  188. elapsed = get_timer(start_time);
  189. if (elapsed > (CONFIG_SYS_HZ / 10)) /* .1 seconds */
  190. break;
  191. }
  192. printf("%s: failed sr=%x cr=%x state=%x\n", __func__,
  193. sr, readb(&i2c_regs->i2cr), state);
  194. return -ETIMEDOUT;
  195. }
  196. static int tx_byte(struct mxc_i2c_regs *i2c_regs, u8 byte)
  197. {
  198. int ret;
  199. writeb(I2SR_IIF_CLEAR, &i2c_regs->i2sr);
  200. writeb(byte, &i2c_regs->i2dr);
  201. ret = wait_for_sr_state(i2c_regs, ST_IIF);
  202. if (ret < 0)
  203. return ret;
  204. if (ret & I2SR_RX_NO_AK)
  205. return -ENODEV;
  206. return 0;
  207. }
  208. /*
  209. * Stop I2C transaction
  210. */
  211. static void i2c_imx_stop(struct mxc_i2c_regs *i2c_regs)
  212. {
  213. int ret;
  214. unsigned int temp = readb(&i2c_regs->i2cr);
  215. temp &= ~(I2CR_MSTA | I2CR_MTX);
  216. writeb(temp, &i2c_regs->i2cr);
  217. ret = wait_for_sr_state(i2c_regs, ST_BUS_IDLE);
  218. if (ret < 0)
  219. printf("%s:trigger stop failed\n", __func__);
  220. }
  221. /*
  222. * Send start signal, chip address and
  223. * write register address
  224. */
  225. static int i2c_init_transfer_(struct mxc_i2c_regs *i2c_regs,
  226. uchar chip, uint addr, int alen)
  227. {
  228. unsigned int temp;
  229. int ret;
  230. /* Enable I2C controller */
  231. #ifdef I2C_QUIRK_REG
  232. if (readb(&i2c_regs->i2cr) & I2CR_IDIS) {
  233. #else
  234. if (!(readb(&i2c_regs->i2cr) & I2CR_IEN)) {
  235. #endif
  236. writeb(I2CR_IEN, &i2c_regs->i2cr);
  237. /* Wait for controller to be stable */
  238. udelay(50);
  239. }
  240. if (readb(&i2c_regs->iadr) == (chip << 1))
  241. writeb((chip << 1) ^ 2, &i2c_regs->iadr);
  242. writeb(I2SR_IIF_CLEAR, &i2c_regs->i2sr);
  243. ret = wait_for_sr_state(i2c_regs, ST_BUS_IDLE);
  244. if (ret < 0)
  245. return ret;
  246. /* Start I2C transaction */
  247. temp = readb(&i2c_regs->i2cr);
  248. temp |= I2CR_MSTA;
  249. writeb(temp, &i2c_regs->i2cr);
  250. ret = wait_for_sr_state(i2c_regs, ST_BUS_BUSY);
  251. if (ret < 0)
  252. return ret;
  253. temp |= I2CR_MTX | I2CR_TX_NO_AK;
  254. writeb(temp, &i2c_regs->i2cr);
  255. /* write slave address */
  256. ret = tx_byte(i2c_regs, chip << 1);
  257. if (ret < 0)
  258. return ret;
  259. while (alen--) {
  260. ret = tx_byte(i2c_regs, (addr >> (alen * 8)) & 0xff);
  261. if (ret < 0)
  262. return ret;
  263. }
  264. return 0;
  265. }
  266. static int i2c_idle_bus(void *base);
  267. static int i2c_init_transfer(struct mxc_i2c_regs *i2c_regs,
  268. uchar chip, uint addr, int alen)
  269. {
  270. int retry;
  271. int ret;
  272. for (retry = 0; retry < 3; retry++) {
  273. ret = i2c_init_transfer_(i2c_regs, chip, addr, alen);
  274. if (ret >= 0)
  275. return 0;
  276. i2c_imx_stop(i2c_regs);
  277. if (ret == -ENODEV)
  278. return ret;
  279. printf("%s: failed for chip 0x%x retry=%d\n", __func__, chip,
  280. retry);
  281. if (ret != -ERESTART)
  282. /* Disable controller */
  283. writeb(I2CR_IDIS, &i2c_regs->i2cr);
  284. udelay(100);
  285. if (i2c_idle_bus(i2c_regs) < 0)
  286. break;
  287. }
  288. printf("%s: give up i2c_regs=%p\n", __func__, i2c_regs);
  289. return ret;
  290. }
  291. /*
  292. * Read data from I2C device
  293. */
  294. int bus_i2c_read(void *base, uchar chip, uint addr, int alen, uchar *buf,
  295. int len)
  296. {
  297. int ret;
  298. unsigned int temp;
  299. int i;
  300. struct mxc_i2c_regs *i2c_regs = (struct mxc_i2c_regs *)base;
  301. ret = i2c_init_transfer(i2c_regs, chip, addr, alen);
  302. if (ret < 0)
  303. return ret;
  304. temp = readb(&i2c_regs->i2cr);
  305. temp |= I2CR_RSTA;
  306. writeb(temp, &i2c_regs->i2cr);
  307. ret = tx_byte(i2c_regs, (chip << 1) | 1);
  308. if (ret < 0) {
  309. i2c_imx_stop(i2c_regs);
  310. return ret;
  311. }
  312. /* setup bus to read data */
  313. temp = readb(&i2c_regs->i2cr);
  314. temp &= ~(I2CR_MTX | I2CR_TX_NO_AK);
  315. if (len == 1)
  316. temp |= I2CR_TX_NO_AK;
  317. writeb(temp, &i2c_regs->i2cr);
  318. writeb(I2SR_IIF_CLEAR, &i2c_regs->i2sr);
  319. readb(&i2c_regs->i2dr); /* dummy read to clear ICF */
  320. /* read data */
  321. for (i = 0; i < len; i++) {
  322. ret = wait_for_sr_state(i2c_regs, ST_IIF);
  323. if (ret < 0) {
  324. i2c_imx_stop(i2c_regs);
  325. return ret;
  326. }
  327. /*
  328. * It must generate STOP before read I2DR to prevent
  329. * controller from generating another clock cycle
  330. */
  331. if (i == (len - 1)) {
  332. i2c_imx_stop(i2c_regs);
  333. } else if (i == (len - 2)) {
  334. temp = readb(&i2c_regs->i2cr);
  335. temp |= I2CR_TX_NO_AK;
  336. writeb(temp, &i2c_regs->i2cr);
  337. }
  338. writeb(I2SR_IIF_CLEAR, &i2c_regs->i2sr);
  339. buf[i] = readb(&i2c_regs->i2dr);
  340. }
  341. i2c_imx_stop(i2c_regs);
  342. return 0;
  343. }
  344. /*
  345. * Write data to I2C device
  346. */
  347. int bus_i2c_write(void *base, uchar chip, uint addr, int alen,
  348. const uchar *buf, int len)
  349. {
  350. int ret;
  351. int i;
  352. struct mxc_i2c_regs *i2c_regs = (struct mxc_i2c_regs *)base;
  353. ret = i2c_init_transfer(i2c_regs, chip, addr, alen);
  354. if (ret < 0)
  355. return ret;
  356. for (i = 0; i < len; i++) {
  357. ret = tx_byte(i2c_regs, buf[i]);
  358. if (ret < 0)
  359. break;
  360. }
  361. i2c_imx_stop(i2c_regs);
  362. return ret;
  363. }
  364. static void * const i2c_bases[] = {
  365. #if defined(CONFIG_MX25)
  366. (void *)IMX_I2C_BASE,
  367. (void *)IMX_I2C2_BASE,
  368. (void *)IMX_I2C3_BASE
  369. #elif defined(CONFIG_MX27)
  370. (void *)IMX_I2C1_BASE,
  371. (void *)IMX_I2C2_BASE
  372. #elif defined(CONFIG_MX31) || defined(CONFIG_MX35) || \
  373. defined(CONFIG_MX51) || defined(CONFIG_MX53) || \
  374. defined(CONFIG_MX6) || defined(CONFIG_LS102XA)
  375. (void *)I2C1_BASE_ADDR,
  376. (void *)I2C2_BASE_ADDR,
  377. (void *)I2C3_BASE_ADDR
  378. #elif defined(CONFIG_VF610)
  379. (void *)I2C0_BASE_ADDR
  380. #elif defined(CONFIG_FSL_LSCH3)
  381. (void *)I2C1_BASE_ADDR,
  382. (void *)I2C2_BASE_ADDR,
  383. (void *)I2C3_BASE_ADDR,
  384. (void *)I2C4_BASE_ADDR
  385. #else
  386. #error "architecture not supported"
  387. #endif
  388. };
  389. struct i2c_parms {
  390. void *base;
  391. void *idle_bus_data;
  392. int (*idle_bus_fn)(void *p);
  393. };
  394. struct sram_data {
  395. unsigned curr_i2c_bus;
  396. struct i2c_parms i2c_data[ARRAY_SIZE(i2c_bases)];
  397. };
  398. void *i2c_get_base(struct i2c_adapter *adap)
  399. {
  400. return i2c_bases[adap->hwadapnr];
  401. }
  402. static struct i2c_parms *i2c_get_parms(void *base)
  403. {
  404. struct sram_data *srdata = (void *)gd->srdata;
  405. int i = 0;
  406. struct i2c_parms *p = srdata->i2c_data;
  407. while (i < ARRAY_SIZE(srdata->i2c_data)) {
  408. if (p->base == base)
  409. return p;
  410. p++;
  411. i++;
  412. }
  413. printf("Invalid I2C base: %p\n", base);
  414. return NULL;
  415. }
  416. static int i2c_idle_bus(void *base)
  417. {
  418. struct i2c_parms *p = i2c_get_parms(base);
  419. if (p && p->idle_bus_fn)
  420. return p->idle_bus_fn(p->idle_bus_data);
  421. return 0;
  422. }
  423. static int mxc_i2c_read(struct i2c_adapter *adap, uint8_t chip,
  424. uint addr, int alen, uint8_t *buffer,
  425. int len)
  426. {
  427. return bus_i2c_read(i2c_get_base(adap), chip, addr, alen, buffer, len);
  428. }
  429. static int mxc_i2c_write(struct i2c_adapter *adap, uint8_t chip,
  430. uint addr, int alen, uint8_t *buffer,
  431. int len)
  432. {
  433. return bus_i2c_write(i2c_get_base(adap), chip, addr, alen, buffer, len);
  434. }
  435. /*
  436. * Test if a chip at a given address responds (probe the chip)
  437. */
  438. static int mxc_i2c_probe(struct i2c_adapter *adap, uint8_t chip)
  439. {
  440. return bus_i2c_write(i2c_get_base(adap), chip, 0, 0, NULL, 0);
  441. }
  442. void bus_i2c_init(void *base, int speed, int unused,
  443. int (*idle_bus_fn)(void *p), void *idle_bus_data)
  444. {
  445. struct sram_data *srdata = (void *)gd->srdata;
  446. int i = 0;
  447. struct i2c_parms *p = srdata->i2c_data;
  448. if (!base)
  449. return;
  450. for (;;) {
  451. if (!p->base || (p->base == base)) {
  452. p->base = base;
  453. if (idle_bus_fn) {
  454. p->idle_bus_fn = idle_bus_fn;
  455. p->idle_bus_data = idle_bus_data;
  456. }
  457. break;
  458. }
  459. p++;
  460. i++;
  461. if (i >= ARRAY_SIZE(srdata->i2c_data))
  462. return;
  463. }
  464. bus_i2c_set_bus_speed(base, speed);
  465. }
  466. /*
  467. * Init I2C Bus
  468. */
  469. static void mxc_i2c_init(struct i2c_adapter *adap, int speed, int slaveaddr)
  470. {
  471. bus_i2c_init(i2c_get_base(adap), speed, slaveaddr, NULL, NULL);
  472. }
  473. /*
  474. * Set I2C Speed
  475. */
  476. static uint mxc_i2c_set_bus_speed(struct i2c_adapter *adap, uint speed)
  477. {
  478. return bus_i2c_set_bus_speed(i2c_get_base(adap), speed);
  479. }
  480. /*
  481. * Register mxc i2c adapters
  482. */
  483. U_BOOT_I2C_ADAP_COMPLETE(mxc0, mxc_i2c_init, mxc_i2c_probe,
  484. mxc_i2c_read, mxc_i2c_write,
  485. mxc_i2c_set_bus_speed,
  486. CONFIG_SYS_MXC_I2C1_SPEED,
  487. CONFIG_SYS_MXC_I2C1_SLAVE, 0)
  488. U_BOOT_I2C_ADAP_COMPLETE(mxc1, mxc_i2c_init, mxc_i2c_probe,
  489. mxc_i2c_read, mxc_i2c_write,
  490. mxc_i2c_set_bus_speed,
  491. CONFIG_SYS_MXC_I2C2_SPEED,
  492. CONFIG_SYS_MXC_I2C2_SLAVE, 1)
  493. #ifdef CONFIG_SYS_I2C_MXC_I2C3
  494. U_BOOT_I2C_ADAP_COMPLETE(mxc2, mxc_i2c_init, mxc_i2c_probe,
  495. mxc_i2c_read, mxc_i2c_write,
  496. mxc_i2c_set_bus_speed,
  497. CONFIG_SYS_MXC_I2C3_SPEED,
  498. CONFIG_SYS_MXC_I2C3_SLAVE, 2)
  499. #endif
  500. #ifdef CONFIG_SYS_I2C_MXC_I2C4
  501. U_BOOT_I2C_ADAP_COMPLETE(mxc3, mxc_i2c_init, mxc_i2c_probe,
  502. mxc_i2c_read, mxc_i2c_write,
  503. mxc_i2c_set_bus_speed,
  504. CONFIG_SYS_MXC_I2C4_SPEED,
  505. CONFIG_SYS_MXC_I2C4_SLAVE, 3)
  506. #endif