tegra_i2c.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646
  1. /*
  2. * Copyright (c) 2012 The Chromium OS Authors. All rights reserved.
  3. * Copyright (c) 2010-2011 NVIDIA Corporation
  4. * NVIDIA Corporation <www.nvidia.com>
  5. *
  6. * SPDX-License-Identifier: GPL-2.0+
  7. */
  8. #include <common.h>
  9. #include <fdtdec.h>
  10. #include <i2c.h>
  11. #include <asm/io.h>
  12. #include <asm/arch/clock.h>
  13. #include <asm/arch/funcmux.h>
  14. #include <asm/arch/gpio.h>
  15. #include <asm/arch/pinmux.h>
  16. #include <asm/arch-tegra/clk_rst.h>
  17. #include <asm/arch-tegra/tegra_i2c.h>
  18. DECLARE_GLOBAL_DATA_PTR;
  19. /* Information about i2c controller */
  20. struct i2c_bus {
  21. int id;
  22. enum periph_id periph_id;
  23. int speed;
  24. int pinmux_config;
  25. struct i2c_control *control;
  26. struct i2c_ctlr *regs;
  27. int is_dvc; /* DVC type, rather than I2C */
  28. int is_scs; /* single clock source (T114+) */
  29. int inited; /* bus is inited */
  30. };
  31. static struct i2c_bus i2c_controllers[TEGRA_I2C_NUM_CONTROLLERS];
  32. static void set_packet_mode(struct i2c_bus *i2c_bus)
  33. {
  34. u32 config;
  35. config = I2C_CNFG_NEW_MASTER_FSM_MASK | I2C_CNFG_PACKET_MODE_MASK;
  36. if (i2c_bus->is_dvc) {
  37. struct dvc_ctlr *dvc = (struct dvc_ctlr *)i2c_bus->regs;
  38. writel(config, &dvc->cnfg);
  39. } else {
  40. writel(config, &i2c_bus->regs->cnfg);
  41. /*
  42. * program I2C_SL_CNFG.NEWSL to ENABLE. This fixes probe
  43. * issues, i.e., some slaves may be wrongly detected.
  44. */
  45. setbits_le32(&i2c_bus->regs->sl_cnfg, I2C_SL_CNFG_NEWSL_MASK);
  46. }
  47. }
  48. static void i2c_reset_controller(struct i2c_bus *i2c_bus)
  49. {
  50. /* Reset I2C controller. */
  51. reset_periph(i2c_bus->periph_id, 1);
  52. /* re-program config register to packet mode */
  53. set_packet_mode(i2c_bus);
  54. }
  55. static void i2c_init_controller(struct i2c_bus *i2c_bus)
  56. {
  57. /*
  58. * Use PLLP - DP-04508-001_v06 datasheet indicates a divisor of 8
  59. * here, in section 23.3.1, but in fact we seem to need a factor of
  60. * 16 to get the right frequency.
  61. */
  62. clock_start_periph_pll(i2c_bus->periph_id, CLOCK_ID_PERIPH,
  63. i2c_bus->speed * 2 * 8);
  64. if (i2c_bus->is_scs) {
  65. /*
  66. * T114 I2C went to a single clock source for standard/fast and
  67. * HS clock speeds. The new clock rate setting calculation is:
  68. * SCL = CLK_SOURCE.I2C /
  69. * (CLK_MULT_STD_FAST_MODE * (I2C_CLK_DIV_STD_FAST_MODE+1) *
  70. * I2C FREQUENCY DIVISOR) as per the T114 TRM (sec 30.3.1).
  71. *
  72. * NOTE: We do this here, after the initial clock/pll start,
  73. * because if we read the clk_div reg before the controller
  74. * is running, we hang, and we need it for the new calc.
  75. */
  76. int clk_div_stdfst_mode = readl(&i2c_bus->regs->clk_div) >> 16;
  77. debug("%s: CLK_DIV_STD_FAST_MODE setting = %d\n", __func__,
  78. clk_div_stdfst_mode);
  79. clock_start_periph_pll(i2c_bus->periph_id, CLOCK_ID_PERIPH,
  80. CLK_MULT_STD_FAST_MODE * (clk_div_stdfst_mode + 1) *
  81. i2c_bus->speed * 2);
  82. }
  83. /* Reset I2C controller. */
  84. i2c_reset_controller(i2c_bus);
  85. /* Configure I2C controller. */
  86. if (i2c_bus->is_dvc) { /* only for DVC I2C */
  87. struct dvc_ctlr *dvc = (struct dvc_ctlr *)i2c_bus->regs;
  88. setbits_le32(&dvc->ctrl3, DVC_CTRL_REG3_I2C_HW_SW_PROG_MASK);
  89. }
  90. funcmux_select(i2c_bus->periph_id, i2c_bus->pinmux_config);
  91. }
  92. static void send_packet_headers(
  93. struct i2c_bus *i2c_bus,
  94. struct i2c_trans_info *trans,
  95. u32 packet_id,
  96. bool end_with_repeated_start)
  97. {
  98. u32 data;
  99. /* prepare header1: Header size = 0 Protocol = I2C, pktType = 0 */
  100. data = PROTOCOL_TYPE_I2C << PKT_HDR1_PROTOCOL_SHIFT;
  101. data |= packet_id << PKT_HDR1_PKT_ID_SHIFT;
  102. data |= i2c_bus->id << PKT_HDR1_CTLR_ID_SHIFT;
  103. writel(data, &i2c_bus->control->tx_fifo);
  104. debug("pkt header 1 sent (0x%x)\n", data);
  105. /* prepare header2 */
  106. data = (trans->num_bytes - 1) << PKT_HDR2_PAYLOAD_SIZE_SHIFT;
  107. writel(data, &i2c_bus->control->tx_fifo);
  108. debug("pkt header 2 sent (0x%x)\n", data);
  109. /* prepare IO specific header: configure the slave address */
  110. data = trans->address << PKT_HDR3_SLAVE_ADDR_SHIFT;
  111. /* Enable Read if it is not a write transaction */
  112. if (!(trans->flags & I2C_IS_WRITE))
  113. data |= PKT_HDR3_READ_MODE_MASK;
  114. if (end_with_repeated_start)
  115. data |= PKT_HDR3_REPEAT_START_MASK;
  116. /* Write I2C specific header */
  117. writel(data, &i2c_bus->control->tx_fifo);
  118. debug("pkt header 3 sent (0x%x)\n", data);
  119. }
  120. static int wait_for_tx_fifo_empty(struct i2c_control *control)
  121. {
  122. u32 count;
  123. int timeout_us = I2C_TIMEOUT_USEC;
  124. while (timeout_us >= 0) {
  125. count = (readl(&control->fifo_status) & TX_FIFO_EMPTY_CNT_MASK)
  126. >> TX_FIFO_EMPTY_CNT_SHIFT;
  127. if (count == I2C_FIFO_DEPTH)
  128. return 1;
  129. udelay(10);
  130. timeout_us -= 10;
  131. }
  132. return 0;
  133. }
  134. static int wait_for_rx_fifo_notempty(struct i2c_control *control)
  135. {
  136. u32 count;
  137. int timeout_us = I2C_TIMEOUT_USEC;
  138. while (timeout_us >= 0) {
  139. count = (readl(&control->fifo_status) & TX_FIFO_FULL_CNT_MASK)
  140. >> TX_FIFO_FULL_CNT_SHIFT;
  141. if (count)
  142. return 1;
  143. udelay(10);
  144. timeout_us -= 10;
  145. }
  146. return 0;
  147. }
  148. static int wait_for_transfer_complete(struct i2c_control *control)
  149. {
  150. int int_status;
  151. int timeout_us = I2C_TIMEOUT_USEC;
  152. while (timeout_us >= 0) {
  153. int_status = readl(&control->int_status);
  154. if (int_status & I2C_INT_NO_ACK_MASK)
  155. return -int_status;
  156. if (int_status & I2C_INT_ARBITRATION_LOST_MASK)
  157. return -int_status;
  158. if (int_status & I2C_INT_XFER_COMPLETE_MASK)
  159. return 0;
  160. udelay(10);
  161. timeout_us -= 10;
  162. }
  163. return -1;
  164. }
  165. static int send_recv_packets(struct i2c_bus *i2c_bus,
  166. struct i2c_trans_info *trans)
  167. {
  168. struct i2c_control *control = i2c_bus->control;
  169. u32 int_status;
  170. u32 words;
  171. u8 *dptr;
  172. u32 local;
  173. uchar last_bytes;
  174. int error = 0;
  175. int is_write = trans->flags & I2C_IS_WRITE;
  176. /* clear status from previous transaction, XFER_COMPLETE, NOACK, etc. */
  177. int_status = readl(&control->int_status);
  178. writel(int_status, &control->int_status);
  179. send_packet_headers(i2c_bus, trans, 1,
  180. trans->flags & I2C_USE_REPEATED_START);
  181. words = DIV_ROUND_UP(trans->num_bytes, 4);
  182. last_bytes = trans->num_bytes & 3;
  183. dptr = trans->buf;
  184. while (words) {
  185. u32 *wptr = (u32 *)dptr;
  186. if (is_write) {
  187. /* deal with word alignment */
  188. if ((words == 1) && last_bytes) {
  189. local = 0;
  190. memcpy(&local, dptr, last_bytes);
  191. } else if ((unsigned)dptr & 3) {
  192. memcpy(&local, dptr, sizeof(u32));
  193. } else {
  194. local = *wptr;
  195. }
  196. writel(local, &control->tx_fifo);
  197. debug("pkt data sent (0x%x)\n", local);
  198. if (!wait_for_tx_fifo_empty(control)) {
  199. error = -1;
  200. goto exit;
  201. }
  202. } else {
  203. if (!wait_for_rx_fifo_notempty(control)) {
  204. error = -1;
  205. goto exit;
  206. }
  207. /*
  208. * for the last word, we read into our local buffer,
  209. * in case that caller did not provide enough buffer.
  210. */
  211. local = readl(&control->rx_fifo);
  212. if ((words == 1) && last_bytes)
  213. memcpy(dptr, (char *)&local, last_bytes);
  214. else if ((unsigned)dptr & 3)
  215. memcpy(dptr, &local, sizeof(u32));
  216. else
  217. *wptr = local;
  218. debug("pkt data received (0x%x)\n", local);
  219. }
  220. words--;
  221. dptr += sizeof(u32);
  222. }
  223. if (wait_for_transfer_complete(control)) {
  224. error = -1;
  225. goto exit;
  226. }
  227. return 0;
  228. exit:
  229. /* error, reset the controller. */
  230. i2c_reset_controller(i2c_bus);
  231. return error;
  232. }
  233. static int tegra_i2c_write_data(struct i2c_bus *bus, u32 addr, u8 *data,
  234. u32 len, bool end_with_repeated_start)
  235. {
  236. int error;
  237. struct i2c_trans_info trans_info;
  238. trans_info.address = addr;
  239. trans_info.buf = data;
  240. trans_info.flags = I2C_IS_WRITE;
  241. if (end_with_repeated_start)
  242. trans_info.flags |= I2C_USE_REPEATED_START;
  243. trans_info.num_bytes = len;
  244. trans_info.is_10bit_address = 0;
  245. error = send_recv_packets(bus, &trans_info);
  246. if (error)
  247. debug("tegra_i2c_write_data: Error (%d) !!!\n", error);
  248. return error;
  249. }
  250. static int tegra_i2c_read_data(struct i2c_bus *bus, u32 addr, u8 *data,
  251. u32 len)
  252. {
  253. int error;
  254. struct i2c_trans_info trans_info;
  255. trans_info.address = addr | 1;
  256. trans_info.buf = data;
  257. trans_info.flags = 0;
  258. trans_info.num_bytes = len;
  259. trans_info.is_10bit_address = 0;
  260. error = send_recv_packets(bus, &trans_info);
  261. if (error)
  262. debug("tegra_i2c_read_data: Error (%d) !!!\n", error);
  263. return error;
  264. }
  265. #ifndef CONFIG_OF_CONTROL
  266. #error "Please enable device tree support to use this driver"
  267. #endif
  268. /**
  269. * Check that a bus number is valid and return a pointer to it
  270. *
  271. * @param bus_num Bus number to check / return
  272. * @return pointer to bus, if valid, else NULL
  273. */
  274. static struct i2c_bus *tegra_i2c_get_bus(struct i2c_adapter *adap)
  275. {
  276. struct i2c_bus *bus;
  277. bus = &i2c_controllers[adap->hwadapnr];
  278. if (!bus->inited) {
  279. debug("%s: Bus %u not available\n", __func__, adap->hwadapnr);
  280. return NULL;
  281. }
  282. return bus;
  283. }
  284. static unsigned int tegra_i2c_set_bus_speed(struct i2c_adapter *adap,
  285. unsigned int speed)
  286. {
  287. struct i2c_bus *bus;
  288. bus = tegra_i2c_get_bus(adap);
  289. if (!bus)
  290. return 0;
  291. bus->speed = speed;
  292. i2c_init_controller(bus);
  293. return 0;
  294. }
  295. static int i2c_get_config(const void *blob, int node, struct i2c_bus *i2c_bus)
  296. {
  297. i2c_bus->regs = (struct i2c_ctlr *)fdtdec_get_addr(blob, node, "reg");
  298. /*
  299. * We don't have a binding for pinmux yet. Leave it out for now. So
  300. * far no one needs anything other than the default.
  301. */
  302. i2c_bus->pinmux_config = FUNCMUX_DEFAULT;
  303. i2c_bus->speed = fdtdec_get_int(blob, node, "clock-frequency", 0);
  304. i2c_bus->periph_id = clock_decode_periph_id(blob, node);
  305. /*
  306. * We can't specify the pinmux config in the fdt, so I2C2 will not
  307. * work on Seaboard. It normally has no devices on it anyway.
  308. * You could add in this little hack if you need to use it.
  309. * The correct solution is a pinmux binding in the fdt.
  310. *
  311. * if (i2c_bus->periph_id == PERIPH_ID_I2C2)
  312. * i2c_bus->pinmux_config = FUNCMUX_I2C2_PTA;
  313. */
  314. if (i2c_bus->periph_id == -1)
  315. return -FDT_ERR_NOTFOUND;
  316. return 0;
  317. }
  318. /*
  319. * Process a list of nodes, adding them to our list of I2C ports.
  320. *
  321. * @param blob fdt blob
  322. * @param node_list list of nodes to process (any <=0 are ignored)
  323. * @param count number of nodes to process
  324. * @param is_dvc 1 if these are DVC ports, 0 if standard I2C
  325. * @param is_scs 1 if this HW uses a single clock source (T114+)
  326. * @return 0 if ok, -1 on error
  327. */
  328. static int process_nodes(const void *blob, int node_list[], int count,
  329. int is_dvc, int is_scs)
  330. {
  331. struct i2c_bus *i2c_bus;
  332. int i;
  333. /* build the i2c_controllers[] for each controller */
  334. for (i = 0; i < count; i++) {
  335. int node = node_list[i];
  336. if (node <= 0)
  337. continue;
  338. i2c_bus = &i2c_controllers[i];
  339. i2c_bus->id = i;
  340. if (i2c_get_config(blob, node, i2c_bus)) {
  341. printf("i2c_init_board: failed to decode bus %d\n", i);
  342. return -1;
  343. }
  344. i2c_bus->is_scs = is_scs;
  345. i2c_bus->is_dvc = is_dvc;
  346. if (is_dvc) {
  347. i2c_bus->control =
  348. &((struct dvc_ctlr *)i2c_bus->regs)->control;
  349. } else {
  350. i2c_bus->control = &i2c_bus->regs->control;
  351. }
  352. debug("%s: controller bus %d at %p, periph_id %d, speed %d: ",
  353. is_dvc ? "dvc" : "i2c", i, i2c_bus->regs,
  354. i2c_bus->periph_id, i2c_bus->speed);
  355. i2c_init_controller(i2c_bus);
  356. debug("ok\n");
  357. i2c_bus->inited = 1;
  358. /* Mark position as used */
  359. node_list[i] = -1;
  360. }
  361. return 0;
  362. }
  363. /* Sadly there is no error return from this function */
  364. void i2c_init_board(void)
  365. {
  366. int node_list[TEGRA_I2C_NUM_CONTROLLERS];
  367. const void *blob = gd->fdt_blob;
  368. int count;
  369. /* First check for newer (T114+) I2C ports */
  370. count = fdtdec_find_aliases_for_id(blob, "i2c",
  371. COMPAT_NVIDIA_TEGRA114_I2C, node_list,
  372. TEGRA_I2C_NUM_CONTROLLERS);
  373. if (process_nodes(blob, node_list, count, 0, 1))
  374. return;
  375. /* Now get the older (T20/T30) normal I2C ports */
  376. count = fdtdec_find_aliases_for_id(blob, "i2c",
  377. COMPAT_NVIDIA_TEGRA20_I2C, node_list,
  378. TEGRA_I2C_NUM_CONTROLLERS);
  379. if (process_nodes(blob, node_list, count, 0, 0))
  380. return;
  381. /* Now look for dvc ports */
  382. count = fdtdec_add_aliases_for_id(blob, "i2c",
  383. COMPAT_NVIDIA_TEGRA20_DVC, node_list,
  384. TEGRA_I2C_NUM_CONTROLLERS);
  385. if (process_nodes(blob, node_list, count, 1, 0))
  386. return;
  387. }
  388. static void tegra_i2c_init(struct i2c_adapter *adap, int speed, int slaveaddr)
  389. {
  390. /* No i2c support prior to relocation */
  391. if (!(gd->flags & GD_FLG_RELOC))
  392. return;
  393. /* This will override the speed selected in the fdt for that port */
  394. debug("i2c_init(speed=%u, slaveaddr=0x%x)\n", speed, slaveaddr);
  395. i2c_set_bus_speed(speed);
  396. }
  397. /* i2c write version without the register address */
  398. int i2c_write_data(struct i2c_bus *bus, uchar chip, uchar *buffer, int len,
  399. bool end_with_repeated_start)
  400. {
  401. int rc;
  402. debug("i2c_write_data: chip=0x%x, len=0x%x\n", chip, len);
  403. debug("write_data: ");
  404. /* use rc for counter */
  405. for (rc = 0; rc < len; ++rc)
  406. debug(" 0x%02x", buffer[rc]);
  407. debug("\n");
  408. /* Shift 7-bit address over for lower-level i2c functions */
  409. rc = tegra_i2c_write_data(bus, chip << 1, buffer, len,
  410. end_with_repeated_start);
  411. if (rc)
  412. debug("i2c_write_data(): rc=%d\n", rc);
  413. return rc;
  414. }
  415. /* i2c read version without the register address */
  416. int i2c_read_data(struct i2c_bus *bus, uchar chip, uchar *buffer, int len)
  417. {
  418. int rc;
  419. debug("inside i2c_read_data():\n");
  420. /* Shift 7-bit address over for lower-level i2c functions */
  421. rc = tegra_i2c_read_data(bus, chip << 1, buffer, len);
  422. if (rc) {
  423. debug("i2c_read_data(): rc=%d\n", rc);
  424. return rc;
  425. }
  426. debug("i2c_read_data: ");
  427. /* reuse rc for counter*/
  428. for (rc = 0; rc < len; ++rc)
  429. debug(" 0x%02x", buffer[rc]);
  430. debug("\n");
  431. return 0;
  432. }
  433. /* Probe to see if a chip is present. */
  434. static int tegra_i2c_probe(struct i2c_adapter *adap, uchar chip)
  435. {
  436. struct i2c_bus *bus;
  437. int rc;
  438. uchar reg;
  439. debug("i2c_probe: addr=0x%x\n", chip);
  440. bus = tegra_i2c_get_bus(adap);
  441. if (!bus)
  442. return 1;
  443. reg = 0;
  444. rc = i2c_write_data(bus, chip, &reg, 1, false);
  445. if (rc) {
  446. debug("Error probing 0x%x.\n", chip);
  447. return 1;
  448. }
  449. return 0;
  450. }
  451. static int i2c_addr_ok(const uint addr, const int alen)
  452. {
  453. /* We support 7 or 10 bit addresses, so one or two bytes each */
  454. return alen == 1 || alen == 2;
  455. }
  456. /* Read bytes */
  457. static int tegra_i2c_read(struct i2c_adapter *adap, uchar chip, uint addr,
  458. int alen, uchar *buffer, int len)
  459. {
  460. struct i2c_bus *bus;
  461. uint offset;
  462. int i;
  463. debug("i2c_read: chip=0x%x, addr=0x%x, len=0x%x\n",
  464. chip, addr, len);
  465. bus = tegra_i2c_get_bus(adap);
  466. if (!bus)
  467. return 1;
  468. if (!i2c_addr_ok(addr, alen)) {
  469. debug("i2c_read: Bad address %x.%d.\n", addr, alen);
  470. return 1;
  471. }
  472. for (offset = 0; offset < len; offset++) {
  473. if (alen) {
  474. uchar data[alen];
  475. for (i = 0; i < alen; i++) {
  476. data[alen - i - 1] =
  477. (addr + offset) >> (8 * i);
  478. }
  479. if (i2c_write_data(bus, chip, data, alen, true)) {
  480. debug("i2c_read: error sending (0x%x)\n",
  481. addr);
  482. return 1;
  483. }
  484. }
  485. if (i2c_read_data(bus, chip, buffer + offset, 1)) {
  486. debug("i2c_read: error reading (0x%x)\n", addr);
  487. return 1;
  488. }
  489. }
  490. return 0;
  491. }
  492. /* Write bytes */
  493. static int tegra_i2c_write(struct i2c_adapter *adap, uchar chip, uint addr,
  494. int alen, uchar *buffer, int len)
  495. {
  496. struct i2c_bus *bus;
  497. uint offset;
  498. int i;
  499. debug("i2c_write: chip=0x%x, addr=0x%x, len=0x%x\n",
  500. chip, addr, len);
  501. bus = tegra_i2c_get_bus(adap);
  502. if (!bus)
  503. return 1;
  504. if (!i2c_addr_ok(addr, alen)) {
  505. debug("i2c_write: Bad address %x.%d.\n", addr, alen);
  506. return 1;
  507. }
  508. for (offset = 0; offset < len; offset++) {
  509. uchar data[alen + 1];
  510. for (i = 0; i < alen; i++)
  511. data[alen - i - 1] = (addr + offset) >> (8 * i);
  512. data[alen] = buffer[offset];
  513. if (i2c_write_data(bus, chip, data, alen + 1, false)) {
  514. debug("i2c_write: error sending (0x%x)\n", addr);
  515. return 1;
  516. }
  517. }
  518. return 0;
  519. }
  520. int tegra_i2c_get_dvc_bus_num(void)
  521. {
  522. int i;
  523. for (i = 0; i < TEGRA_I2C_NUM_CONTROLLERS; i++) {
  524. struct i2c_bus *bus = &i2c_controllers[i];
  525. if (bus->inited && bus->is_dvc)
  526. return i;
  527. }
  528. return -1;
  529. }
  530. /*
  531. * Register soft i2c adapters
  532. */
  533. U_BOOT_I2C_ADAP_COMPLETE(tegra0, tegra_i2c_init, tegra_i2c_probe,
  534. tegra_i2c_read, tegra_i2c_write,
  535. tegra_i2c_set_bus_speed, 100000, 0, 0)
  536. U_BOOT_I2C_ADAP_COMPLETE(tegra1, tegra_i2c_init, tegra_i2c_probe,
  537. tegra_i2c_read, tegra_i2c_write,
  538. tegra_i2c_set_bus_speed, 100000, 0, 1)
  539. U_BOOT_I2C_ADAP_COMPLETE(tegra2, tegra_i2c_init, tegra_i2c_probe,
  540. tegra_i2c_read, tegra_i2c_write,
  541. tegra_i2c_set_bus_speed, 100000, 0, 2)
  542. U_BOOT_I2C_ADAP_COMPLETE(tegra3, tegra_i2c_init, tegra_i2c_probe,
  543. tegra_i2c_read, tegra_i2c_write,
  544. tegra_i2c_set_bus_speed, 100000, 0, 3)
  545. #if TEGRA_I2C_NUM_CONTROLLERS > 4
  546. U_BOOT_I2C_ADAP_COMPLETE(tegra4, tegra_i2c_init, tegra_i2c_probe,
  547. tegra_i2c_read, tegra_i2c_write,
  548. tegra_i2c_set_bus_speed, 100000, 0, 4)
  549. #endif