omap24xx_i2c.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639
  1. /*
  2. * Basic I2C functions
  3. *
  4. * Copyright (c) 2004 Texas Instruments
  5. *
  6. * This package is free software; you can redistribute it and/or
  7. * modify it under the terms of the license found in the file
  8. * named COPYING that should have accompanied this file.
  9. *
  10. * THIS PACKAGE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
  11. * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
  12. * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  13. *
  14. * Author: Jian Zhang jzhang@ti.com, Texas Instruments
  15. *
  16. * Copyright (c) 2003 Wolfgang Denk, wd@denx.de
  17. * Rewritten to fit into the current U-Boot framework
  18. *
  19. * Adapted for OMAP2420 I2C, r-woodruff2@ti.com
  20. *
  21. * Copyright (c) 2013 Lubomir Popov <lpopov@mm-sol.com>, MM Solutions
  22. * New i2c_read, i2c_write and i2c_probe functions, tested on OMAP4
  23. * (4430/60/70), OMAP5 (5430) and AM335X (3359); should work on older
  24. * OMAPs and derivatives as well. The only anticipated exception would
  25. * be the OMAP2420, which shall require driver modification.
  26. * - Rewritten i2c_read to operate correctly with all types of chips
  27. * (old function could not read consistent data from some I2C slaves).
  28. * - Optimized i2c_write.
  29. * - New i2c_probe, performs write access vs read. The old probe could
  30. * hang the system under certain conditions (e.g. unconfigured pads).
  31. * - The read/write/probe functions try to identify unconfigured bus.
  32. * - Status functions now read irqstatus_raw as per TRM guidelines
  33. * (except for OMAP243X and OMAP34XX).
  34. * - Driver now supports up to I2C5 (OMAP5).
  35. */
  36. #include <common.h>
  37. #include <i2c.h>
  38. #include <asm/arch/i2c.h>
  39. #include <asm/io.h>
  40. #include "omap24xx_i2c.h"
  41. DECLARE_GLOBAL_DATA_PTR;
  42. #define I2C_TIMEOUT 1000
  43. /* Absolutely safe for status update at 100 kHz I2C: */
  44. #define I2C_WAIT 200
  45. static int wait_for_bb(struct i2c_adapter *adap);
  46. static struct i2c *omap24_get_base(struct i2c_adapter *adap);
  47. static u16 wait_for_event(struct i2c_adapter *adap);
  48. static void flush_fifo(struct i2c_adapter *adap);
  49. static void omap24_i2c_init(struct i2c_adapter *adap, int speed, int slaveadd)
  50. {
  51. struct i2c *i2c_base = omap24_get_base(adap);
  52. int psc, fsscll, fssclh;
  53. int hsscll = 0, hssclh = 0;
  54. u32 scll, sclh;
  55. int timeout = I2C_TIMEOUT;
  56. /* Only handle standard, fast and high speeds */
  57. if ((speed != OMAP_I2C_STANDARD) &&
  58. (speed != OMAP_I2C_FAST_MODE) &&
  59. (speed != OMAP_I2C_HIGH_SPEED)) {
  60. printf("Error : I2C unsupported speed %d\n", speed);
  61. return;
  62. }
  63. psc = I2C_IP_CLK / I2C_INTERNAL_SAMPLING_CLK;
  64. psc -= 1;
  65. if (psc < I2C_PSC_MIN) {
  66. printf("Error : I2C unsupported prescalar %d\n", psc);
  67. return;
  68. }
  69. if (speed == OMAP_I2C_HIGH_SPEED) {
  70. /* High speed */
  71. /* For first phase of HS mode */
  72. fsscll = fssclh = I2C_INTERNAL_SAMPLING_CLK /
  73. (2 * OMAP_I2C_FAST_MODE);
  74. fsscll -= I2C_HIGHSPEED_PHASE_ONE_SCLL_TRIM;
  75. fssclh -= I2C_HIGHSPEED_PHASE_ONE_SCLH_TRIM;
  76. if (((fsscll < 0) || (fssclh < 0)) ||
  77. ((fsscll > 255) || (fssclh > 255))) {
  78. puts("Error : I2C initializing first phase clock\n");
  79. return;
  80. }
  81. /* For second phase of HS mode */
  82. hsscll = hssclh = I2C_INTERNAL_SAMPLING_CLK / (2 * speed);
  83. hsscll -= I2C_HIGHSPEED_PHASE_TWO_SCLL_TRIM;
  84. hssclh -= I2C_HIGHSPEED_PHASE_TWO_SCLH_TRIM;
  85. if (((fsscll < 0) || (fssclh < 0)) ||
  86. ((fsscll > 255) || (fssclh > 255))) {
  87. puts("Error : I2C initializing second phase clock\n");
  88. return;
  89. }
  90. scll = (unsigned int)hsscll << 8 | (unsigned int)fsscll;
  91. sclh = (unsigned int)hssclh << 8 | (unsigned int)fssclh;
  92. } else {
  93. /* Standard and fast speed */
  94. fsscll = fssclh = I2C_INTERNAL_SAMPLING_CLK / (2 * speed);
  95. fsscll -= I2C_FASTSPEED_SCLL_TRIM;
  96. fssclh -= I2C_FASTSPEED_SCLH_TRIM;
  97. if (((fsscll < 0) || (fssclh < 0)) ||
  98. ((fsscll > 255) || (fssclh > 255))) {
  99. puts("Error : I2C initializing clock\n");
  100. return;
  101. }
  102. scll = (unsigned int)fsscll;
  103. sclh = (unsigned int)fssclh;
  104. }
  105. if (readw(&i2c_base->con) & I2C_CON_EN) {
  106. writew(0, &i2c_base->con);
  107. udelay(50000);
  108. }
  109. writew(0x2, &i2c_base->sysc); /* for ES2 after soft reset */
  110. udelay(1000);
  111. writew(I2C_CON_EN, &i2c_base->con);
  112. while (!(readw(&i2c_base->syss) & I2C_SYSS_RDONE) && timeout--) {
  113. if (timeout <= 0) {
  114. puts("ERROR: Timeout in soft-reset\n");
  115. return;
  116. }
  117. udelay(1000);
  118. }
  119. writew(0, &i2c_base->con);
  120. writew(psc, &i2c_base->psc);
  121. writew(scll, &i2c_base->scll);
  122. writew(sclh, &i2c_base->sclh);
  123. /* own address */
  124. writew(slaveadd, &i2c_base->oa);
  125. writew(I2C_CON_EN, &i2c_base->con);
  126. #if defined(CONFIG_OMAP243X) || defined(CONFIG_OMAP34XX)
  127. /*
  128. * Have to enable interrupts for OMAP2/3, these IPs don't have
  129. * an 'irqstatus_raw' register and we shall have to poll 'stat'
  130. */
  131. writew(I2C_IE_XRDY_IE | I2C_IE_RRDY_IE | I2C_IE_ARDY_IE |
  132. I2C_IE_NACK_IE | I2C_IE_AL_IE, &i2c_base->ie);
  133. #endif
  134. udelay(1000);
  135. flush_fifo(adap);
  136. writew(0xFFFF, &i2c_base->stat);
  137. writew(0, &i2c_base->cnt);
  138. }
  139. static void flush_fifo(struct i2c_adapter *adap)
  140. {
  141. struct i2c *i2c_base = omap24_get_base(adap);
  142. u16 stat;
  143. /* note: if you try and read data when its not there or ready
  144. * you get a bus error
  145. */
  146. while (1) {
  147. stat = readw(&i2c_base->stat);
  148. if (stat == I2C_STAT_RRDY) {
  149. readb(&i2c_base->data);
  150. writew(I2C_STAT_RRDY, &i2c_base->stat);
  151. udelay(1000);
  152. } else
  153. break;
  154. }
  155. }
  156. /*
  157. * i2c_probe: Use write access. Allows to identify addresses that are
  158. * write-only (like the config register of dual-port EEPROMs)
  159. */
  160. static int omap24_i2c_probe(struct i2c_adapter *adap, uchar chip)
  161. {
  162. struct i2c *i2c_base = omap24_get_base(adap);
  163. u16 status;
  164. int res = 1; /* default = fail */
  165. if (chip == readw(&i2c_base->oa))
  166. return res;
  167. /* Wait until bus is free */
  168. if (wait_for_bb(adap))
  169. return res;
  170. /* No data transfer, slave addr only */
  171. writew(0, &i2c_base->cnt);
  172. /* Set slave address */
  173. writew(chip, &i2c_base->sa);
  174. /* Stop bit needed here */
  175. writew(I2C_CON_EN | I2C_CON_MST | I2C_CON_STT | I2C_CON_TRX |
  176. I2C_CON_STP, &i2c_base->con);
  177. status = wait_for_event(adap);
  178. if ((status & ~I2C_STAT_XRDY) == 0 || (status & I2C_STAT_AL)) {
  179. /*
  180. * With current high-level command implementation, notifying
  181. * the user shall flood the console with 127 messages. If
  182. * silent exit is desired upon unconfigured bus, remove the
  183. * following 'if' section:
  184. */
  185. if (status == I2C_STAT_XRDY)
  186. printf("i2c_probe: pads on bus %d probably not configured (status=0x%x)\n",
  187. adap->hwadapnr, status);
  188. goto pr_exit;
  189. }
  190. /* Check for ACK (!NAK) */
  191. if (!(status & I2C_STAT_NACK)) {
  192. res = 0; /* Device found */
  193. udelay(I2C_WAIT); /* Required by AM335X in SPL */
  194. /* Abort transfer (force idle state) */
  195. writew(I2C_CON_MST | I2C_CON_TRX, &i2c_base->con); /* Reset */
  196. udelay(1000);
  197. writew(I2C_CON_EN | I2C_CON_MST | I2C_CON_TRX |
  198. I2C_CON_STP, &i2c_base->con); /* STP */
  199. }
  200. pr_exit:
  201. flush_fifo(adap);
  202. writew(0xFFFF, &i2c_base->stat);
  203. writew(0, &i2c_base->cnt);
  204. return res;
  205. }
  206. /*
  207. * i2c_read: Function now uses a single I2C read transaction with bulk transfer
  208. * of the requested number of bytes (note that the 'i2c md' command
  209. * limits this to 16 bytes anyway). If CONFIG_I2C_REPEATED_START is
  210. * defined in the board config header, this transaction shall be with
  211. * Repeated Start (Sr) between the address and data phases; otherwise
  212. * Stop-Start (P-S) shall be used (some I2C chips do require a P-S).
  213. * The address (reg offset) may be 0, 1 or 2 bytes long.
  214. * Function now reads correctly from chips that return more than one
  215. * byte of data per addressed register (like TI temperature sensors),
  216. * or that do not need a register address at all (such as some clock
  217. * distributors).
  218. */
  219. static int omap24_i2c_read(struct i2c_adapter *adap, uchar chip, uint addr,
  220. int alen, uchar *buffer, int len)
  221. {
  222. struct i2c *i2c_base = omap24_get_base(adap);
  223. int i2c_error = 0;
  224. u16 status;
  225. if (alen < 0) {
  226. puts("I2C read: addr len < 0\n");
  227. return 1;
  228. }
  229. if (len < 0) {
  230. puts("I2C read: data len < 0\n");
  231. return 1;
  232. }
  233. if (buffer == NULL) {
  234. puts("I2C read: NULL pointer passed\n");
  235. return 1;
  236. }
  237. if (alen > 2) {
  238. printf("I2C read: addr len %d not supported\n", alen);
  239. return 1;
  240. }
  241. if (addr + len > (1 << 16)) {
  242. puts("I2C read: address out of range\n");
  243. return 1;
  244. }
  245. /* Wait until bus not busy */
  246. if (wait_for_bb(adap))
  247. return 1;
  248. /* Zero, one or two bytes reg address (offset) */
  249. writew(alen, &i2c_base->cnt);
  250. /* Set slave address */
  251. writew(chip, &i2c_base->sa);
  252. if (alen) {
  253. /* Must write reg offset first */
  254. #ifdef CONFIG_I2C_REPEATED_START
  255. /* No stop bit, use Repeated Start (Sr) */
  256. writew(I2C_CON_EN | I2C_CON_MST | I2C_CON_STT |
  257. I2C_CON_TRX, &i2c_base->con);
  258. #else
  259. /* Stop - Start (P-S) */
  260. writew(I2C_CON_EN | I2C_CON_MST | I2C_CON_STT | I2C_CON_STP |
  261. I2C_CON_TRX, &i2c_base->con);
  262. #endif
  263. /* Send register offset */
  264. while (1) {
  265. status = wait_for_event(adap);
  266. /* Try to identify bus that is not padconf'd for I2C */
  267. if (status == I2C_STAT_XRDY) {
  268. i2c_error = 2;
  269. printf("i2c_read (addr phase): pads on bus %d probably not configured (status=0x%x)\n",
  270. adap->hwadapnr, status);
  271. goto rd_exit;
  272. }
  273. if (status == 0 || status & I2C_STAT_NACK) {
  274. i2c_error = 1;
  275. printf("i2c_read: error waiting for addr ACK (status=0x%x)\n",
  276. status);
  277. goto rd_exit;
  278. }
  279. if (alen) {
  280. if (status & I2C_STAT_XRDY) {
  281. alen--;
  282. /* Do we have to use byte access? */
  283. writeb((addr >> (8 * alen)) & 0xff,
  284. &i2c_base->data);
  285. writew(I2C_STAT_XRDY, &i2c_base->stat);
  286. }
  287. }
  288. if (status & I2C_STAT_ARDY) {
  289. writew(I2C_STAT_ARDY, &i2c_base->stat);
  290. break;
  291. }
  292. }
  293. }
  294. /* Set slave address */
  295. writew(chip, &i2c_base->sa);
  296. /* Read len bytes from slave */
  297. writew(len, &i2c_base->cnt);
  298. /* Need stop bit here */
  299. writew(I2C_CON_EN | I2C_CON_MST |
  300. I2C_CON_STT | I2C_CON_STP,
  301. &i2c_base->con);
  302. /* Receive data */
  303. while (1) {
  304. status = wait_for_event(adap);
  305. /*
  306. * Try to identify bus that is not padconf'd for I2C. This
  307. * state could be left over from previous transactions if
  308. * the address phase is skipped due to alen=0.
  309. */
  310. if (status == I2C_STAT_XRDY) {
  311. i2c_error = 2;
  312. printf("i2c_read (data phase): pads on bus %d probably not configured (status=0x%x)\n",
  313. adap->hwadapnr, status);
  314. goto rd_exit;
  315. }
  316. if (status == 0 || status & I2C_STAT_NACK) {
  317. i2c_error = 1;
  318. goto rd_exit;
  319. }
  320. if (status & I2C_STAT_RRDY) {
  321. *buffer++ = readb(&i2c_base->data);
  322. writew(I2C_STAT_RRDY, &i2c_base->stat);
  323. }
  324. if (status & I2C_STAT_ARDY) {
  325. writew(I2C_STAT_ARDY, &i2c_base->stat);
  326. break;
  327. }
  328. }
  329. rd_exit:
  330. flush_fifo(adap);
  331. writew(0xFFFF, &i2c_base->stat);
  332. writew(0, &i2c_base->cnt);
  333. return i2c_error;
  334. }
  335. /* i2c_write: Address (reg offset) may be 0, 1 or 2 bytes long. */
  336. static int omap24_i2c_write(struct i2c_adapter *adap, uchar chip, uint addr,
  337. int alen, uchar *buffer, int len)
  338. {
  339. struct i2c *i2c_base = omap24_get_base(adap);
  340. int i;
  341. u16 status;
  342. int i2c_error = 0;
  343. if (alen < 0) {
  344. puts("I2C write: addr len < 0\n");
  345. return 1;
  346. }
  347. if (len < 0) {
  348. puts("I2C write: data len < 0\n");
  349. return 1;
  350. }
  351. if (buffer == NULL) {
  352. puts("I2C write: NULL pointer passed\n");
  353. return 1;
  354. }
  355. if (alen > 2) {
  356. printf("I2C write: addr len %d not supported\n", alen);
  357. return 1;
  358. }
  359. if (addr + len > (1 << 16)) {
  360. printf("I2C write: address 0x%x + 0x%x out of range\n",
  361. addr, len);
  362. return 1;
  363. }
  364. /* Wait until bus not busy */
  365. if (wait_for_bb(adap))
  366. return 1;
  367. /* Start address phase - will write regoffset + len bytes data */
  368. writew(alen + len, &i2c_base->cnt);
  369. /* Set slave address */
  370. writew(chip, &i2c_base->sa);
  371. /* Stop bit needed here */
  372. writew(I2C_CON_EN | I2C_CON_MST | I2C_CON_STT | I2C_CON_TRX |
  373. I2C_CON_STP, &i2c_base->con);
  374. while (alen) {
  375. /* Must write reg offset (one or two bytes) */
  376. status = wait_for_event(adap);
  377. /* Try to identify bus that is not padconf'd for I2C */
  378. if (status == I2C_STAT_XRDY) {
  379. i2c_error = 2;
  380. printf("i2c_write: pads on bus %d probably not configured (status=0x%x)\n",
  381. adap->hwadapnr, status);
  382. goto wr_exit;
  383. }
  384. if (status == 0 || status & I2C_STAT_NACK) {
  385. i2c_error = 1;
  386. printf("i2c_write: error waiting for addr ACK (status=0x%x)\n",
  387. status);
  388. goto wr_exit;
  389. }
  390. if (status & I2C_STAT_XRDY) {
  391. alen--;
  392. writeb((addr >> (8 * alen)) & 0xff, &i2c_base->data);
  393. writew(I2C_STAT_XRDY, &i2c_base->stat);
  394. } else {
  395. i2c_error = 1;
  396. printf("i2c_write: bus not ready for addr Tx (status=0x%x)\n",
  397. status);
  398. goto wr_exit;
  399. }
  400. }
  401. /* Address phase is over, now write data */
  402. for (i = 0; i < len; i++) {
  403. status = wait_for_event(adap);
  404. if (status == 0 || status & I2C_STAT_NACK) {
  405. i2c_error = 1;
  406. printf("i2c_write: error waiting for data ACK (status=0x%x)\n",
  407. status);
  408. goto wr_exit;
  409. }
  410. if (status & I2C_STAT_XRDY) {
  411. writeb(buffer[i], &i2c_base->data);
  412. writew(I2C_STAT_XRDY, &i2c_base->stat);
  413. } else {
  414. i2c_error = 1;
  415. printf("i2c_write: bus not ready for data Tx (i=%d)\n",
  416. i);
  417. goto wr_exit;
  418. }
  419. }
  420. wr_exit:
  421. flush_fifo(adap);
  422. writew(0xFFFF, &i2c_base->stat);
  423. writew(0, &i2c_base->cnt);
  424. return i2c_error;
  425. }
  426. /*
  427. * Wait for the bus to be free by checking the Bus Busy (BB)
  428. * bit to become clear
  429. */
  430. static int wait_for_bb(struct i2c_adapter *adap)
  431. {
  432. struct i2c *i2c_base = omap24_get_base(adap);
  433. int timeout = I2C_TIMEOUT;
  434. u16 stat;
  435. writew(0xFFFF, &i2c_base->stat); /* clear current interrupts...*/
  436. #if defined(CONFIG_OMAP243X) || defined(CONFIG_OMAP34XX)
  437. while ((stat = readw(&i2c_base->stat) & I2C_STAT_BB) && timeout--) {
  438. #else
  439. /* Read RAW status */
  440. while ((stat = readw(&i2c_base->irqstatus_raw) &
  441. I2C_STAT_BB) && timeout--) {
  442. #endif
  443. writew(stat, &i2c_base->stat);
  444. udelay(I2C_WAIT);
  445. }
  446. if (timeout <= 0) {
  447. printf("Timed out in wait_for_bb: status=%04x\n",
  448. stat);
  449. return 1;
  450. }
  451. writew(0xFFFF, &i2c_base->stat); /* clear delayed stuff*/
  452. return 0;
  453. }
  454. /*
  455. * Wait for the I2C controller to complete current action
  456. * and update status
  457. */
  458. static u16 wait_for_event(struct i2c_adapter *adap)
  459. {
  460. struct i2c *i2c_base = omap24_get_base(adap);
  461. u16 status;
  462. int timeout = I2C_TIMEOUT;
  463. do {
  464. udelay(I2C_WAIT);
  465. #if defined(CONFIG_OMAP243X) || defined(CONFIG_OMAP34XX)
  466. status = readw(&i2c_base->stat);
  467. #else
  468. /* Read RAW status */
  469. status = readw(&i2c_base->irqstatus_raw);
  470. #endif
  471. } while (!(status &
  472. (I2C_STAT_ROVR | I2C_STAT_XUDF | I2C_STAT_XRDY |
  473. I2C_STAT_RRDY | I2C_STAT_ARDY | I2C_STAT_NACK |
  474. I2C_STAT_AL)) && timeout--);
  475. if (timeout <= 0) {
  476. printf("Timed out in wait_for_event: status=%04x\n",
  477. status);
  478. /*
  479. * If status is still 0 here, probably the bus pads have
  480. * not been configured for I2C, and/or pull-ups are missing.
  481. */
  482. printf("Check if pads/pull-ups of bus %d are properly configured\n",
  483. adap->hwadapnr);
  484. writew(0xFFFF, &i2c_base->stat);
  485. status = 0;
  486. }
  487. return status;
  488. }
  489. static struct i2c *omap24_get_base(struct i2c_adapter *adap)
  490. {
  491. switch (adap->hwadapnr) {
  492. case 0:
  493. return (struct i2c *)I2C_BASE1;
  494. break;
  495. case 1:
  496. return (struct i2c *)I2C_BASE2;
  497. break;
  498. #if (I2C_BUS_MAX > 2)
  499. case 2:
  500. return (struct i2c *)I2C_BASE3;
  501. break;
  502. #if (I2C_BUS_MAX > 3)
  503. case 3:
  504. return (struct i2c *)I2C_BASE4;
  505. break;
  506. #if (I2C_BUS_MAX > 4)
  507. case 4:
  508. return (struct i2c *)I2C_BASE5;
  509. break;
  510. #endif
  511. #endif
  512. #endif
  513. default:
  514. printf("wrong hwadapnr: %d\n", adap->hwadapnr);
  515. break;
  516. }
  517. return NULL;
  518. }
  519. #if !defined(CONFIG_SYS_OMAP24_I2C_SPEED1)
  520. #define CONFIG_SYS_OMAP24_I2C_SPEED1 CONFIG_SYS_OMAP24_I2C_SPEED
  521. #endif
  522. #if !defined(CONFIG_SYS_OMAP24_I2C_SLAVE1)
  523. #define CONFIG_SYS_OMAP24_I2C_SLAVE1 CONFIG_SYS_OMAP24_I2C_SLAVE
  524. #endif
  525. U_BOOT_I2C_ADAP_COMPLETE(omap24_0, omap24_i2c_init, omap24_i2c_probe,
  526. omap24_i2c_read, omap24_i2c_write, NULL,
  527. CONFIG_SYS_OMAP24_I2C_SPEED,
  528. CONFIG_SYS_OMAP24_I2C_SLAVE,
  529. 0)
  530. U_BOOT_I2C_ADAP_COMPLETE(omap24_1, omap24_i2c_init, omap24_i2c_probe,
  531. omap24_i2c_read, omap24_i2c_write, NULL,
  532. CONFIG_SYS_OMAP24_I2C_SPEED1,
  533. CONFIG_SYS_OMAP24_I2C_SLAVE1,
  534. 1)
  535. #if (I2C_BUS_MAX > 2)
  536. #if !defined(CONFIG_SYS_OMAP24_I2C_SPEED2)
  537. #define CONFIG_SYS_OMAP24_I2C_SPEED2 CONFIG_SYS_OMAP24_I2C_SPEED
  538. #endif
  539. #if !defined(CONFIG_SYS_OMAP24_I2C_SLAVE2)
  540. #define CONFIG_SYS_OMAP24_I2C_SLAVE2 CONFIG_SYS_OMAP24_I2C_SLAVE
  541. #endif
  542. U_BOOT_I2C_ADAP_COMPLETE(omap24_2, omap24_i2c_init, omap24_i2c_probe,
  543. omap24_i2c_read, omap24_i2c_write, NULL,
  544. CONFIG_SYS_OMAP24_I2C_SPEED2,
  545. CONFIG_SYS_OMAP24_I2C_SLAVE2,
  546. 2)
  547. #if (I2C_BUS_MAX > 3)
  548. #if !defined(CONFIG_SYS_OMAP24_I2C_SPEED3)
  549. #define CONFIG_SYS_OMAP24_I2C_SPEED3 CONFIG_SYS_OMAP24_I2C_SPEED
  550. #endif
  551. #if !defined(CONFIG_SYS_OMAP24_I2C_SLAVE3)
  552. #define CONFIG_SYS_OMAP24_I2C_SLAVE3 CONFIG_SYS_OMAP24_I2C_SLAVE
  553. #endif
  554. U_BOOT_I2C_ADAP_COMPLETE(omap24_3, omap24_i2c_init, omap24_i2c_probe,
  555. omap24_i2c_read, omap24_i2c_write, NULL,
  556. CONFIG_SYS_OMAP24_I2C_SPEED3,
  557. CONFIG_SYS_OMAP24_I2C_SLAVE3,
  558. 3)
  559. #if (I2C_BUS_MAX > 4)
  560. #if !defined(CONFIG_SYS_OMAP24_I2C_SPEED4)
  561. #define CONFIG_SYS_OMAP24_I2C_SPEED4 CONFIG_SYS_OMAP24_I2C_SPEED
  562. #endif
  563. #if !defined(CONFIG_SYS_OMAP24_I2C_SLAVE4)
  564. #define CONFIG_SYS_OMAP24_I2C_SLAVE4 CONFIG_SYS_OMAP24_I2C_SLAVE
  565. #endif
  566. U_BOOT_I2C_ADAP_COMPLETE(omap24_4, omap24_i2c_init, omap24_i2c_probe,
  567. omap24_i2c_read, omap24_i2c_write, NULL,
  568. CONFIG_SYS_OMAP24_I2C_SPEED4,
  569. CONFIG_SYS_OMAP24_I2C_SLAVE4,
  570. 4)
  571. #endif
  572. #endif
  573. #endif