designware_i2c.c 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626
  1. // SPDX-License-Identifier: GPL-2.0+
  2. /*
  3. * (C) Copyright 2009
  4. * Vipin Kumar, ST Micoelectronics, vipin.kumar@st.com.
  5. */
  6. #include <common.h>
  7. #include <dm.h>
  8. #include <i2c.h>
  9. #include <pci.h>
  10. #include <reset.h>
  11. #include <asm/io.h>
  12. #include "designware_i2c.h"
  13. struct dw_scl_sda_cfg {
  14. u32 ss_hcnt;
  15. u32 fs_hcnt;
  16. u32 ss_lcnt;
  17. u32 fs_lcnt;
  18. u32 sda_hold;
  19. };
  20. #ifdef CONFIG_X86
  21. /* BayTrail HCNT/LCNT/SDA hold time */
  22. static struct dw_scl_sda_cfg byt_config = {
  23. .ss_hcnt = 0x200,
  24. .fs_hcnt = 0x55,
  25. .ss_lcnt = 0x200,
  26. .fs_lcnt = 0x99,
  27. .sda_hold = 0x6,
  28. };
  29. #endif
  30. struct dw_i2c {
  31. struct i2c_regs *regs;
  32. struct dw_scl_sda_cfg *scl_sda_cfg;
  33. struct reset_ctl reset_ctl;
  34. };
  35. #ifdef CONFIG_SYS_I2C_DW_ENABLE_STATUS_UNSUPPORTED
  36. static void dw_i2c_enable(struct i2c_regs *i2c_base, bool enable)
  37. {
  38. u32 ena = enable ? IC_ENABLE_0B : 0;
  39. writel(ena, &i2c_base->ic_enable);
  40. }
  41. #else
  42. static void dw_i2c_enable(struct i2c_regs *i2c_base, bool enable)
  43. {
  44. u32 ena = enable ? IC_ENABLE_0B : 0;
  45. int timeout = 100;
  46. do {
  47. writel(ena, &i2c_base->ic_enable);
  48. if ((readl(&i2c_base->ic_enable_status) & IC_ENABLE_0B) == ena)
  49. return;
  50. /*
  51. * Wait 10 times the signaling period of the highest I2C
  52. * transfer supported by the driver (for 400KHz this is
  53. * 25us) as described in the DesignWare I2C databook.
  54. */
  55. udelay(25);
  56. } while (timeout--);
  57. printf("timeout in %sabling I2C adapter\n", enable ? "en" : "dis");
  58. }
  59. #endif
  60. /*
  61. * i2c_set_bus_speed - Set the i2c speed
  62. * @speed: required i2c speed
  63. *
  64. * Set the i2c speed.
  65. */
  66. static unsigned int __dw_i2c_set_bus_speed(struct i2c_regs *i2c_base,
  67. struct dw_scl_sda_cfg *scl_sda_cfg,
  68. unsigned int speed)
  69. {
  70. unsigned int cntl;
  71. unsigned int hcnt, lcnt;
  72. int i2c_spd;
  73. if (speed >= I2C_MAX_SPEED)
  74. i2c_spd = IC_SPEED_MODE_MAX;
  75. else if (speed >= I2C_FAST_SPEED)
  76. i2c_spd = IC_SPEED_MODE_FAST;
  77. else
  78. i2c_spd = IC_SPEED_MODE_STANDARD;
  79. /* to set speed cltr must be disabled */
  80. dw_i2c_enable(i2c_base, false);
  81. cntl = (readl(&i2c_base->ic_con) & (~IC_CON_SPD_MSK));
  82. switch (i2c_spd) {
  83. #ifndef CONFIG_X86 /* No High-speed for BayTrail yet */
  84. case IC_SPEED_MODE_MAX:
  85. cntl |= IC_CON_SPD_SS;
  86. if (scl_sda_cfg) {
  87. hcnt = scl_sda_cfg->fs_hcnt;
  88. lcnt = scl_sda_cfg->fs_lcnt;
  89. } else {
  90. hcnt = (IC_CLK * MIN_HS_SCL_HIGHTIME) / NANO_TO_MICRO;
  91. lcnt = (IC_CLK * MIN_HS_SCL_LOWTIME) / NANO_TO_MICRO;
  92. }
  93. writel(hcnt, &i2c_base->ic_hs_scl_hcnt);
  94. writel(lcnt, &i2c_base->ic_hs_scl_lcnt);
  95. break;
  96. #endif
  97. case IC_SPEED_MODE_STANDARD:
  98. cntl |= IC_CON_SPD_SS;
  99. if (scl_sda_cfg) {
  100. hcnt = scl_sda_cfg->ss_hcnt;
  101. lcnt = scl_sda_cfg->ss_lcnt;
  102. } else {
  103. hcnt = (IC_CLK * MIN_SS_SCL_HIGHTIME) / NANO_TO_MICRO;
  104. lcnt = (IC_CLK * MIN_SS_SCL_LOWTIME) / NANO_TO_MICRO;
  105. }
  106. writel(hcnt, &i2c_base->ic_ss_scl_hcnt);
  107. writel(lcnt, &i2c_base->ic_ss_scl_lcnt);
  108. break;
  109. case IC_SPEED_MODE_FAST:
  110. default:
  111. cntl |= IC_CON_SPD_FS;
  112. if (scl_sda_cfg) {
  113. hcnt = scl_sda_cfg->fs_hcnt;
  114. lcnt = scl_sda_cfg->fs_lcnt;
  115. } else {
  116. hcnt = (IC_CLK * MIN_FS_SCL_HIGHTIME) / NANO_TO_MICRO;
  117. lcnt = (IC_CLK * MIN_FS_SCL_LOWTIME) / NANO_TO_MICRO;
  118. }
  119. writel(hcnt, &i2c_base->ic_fs_scl_hcnt);
  120. writel(lcnt, &i2c_base->ic_fs_scl_lcnt);
  121. break;
  122. }
  123. writel(cntl, &i2c_base->ic_con);
  124. /* Configure SDA Hold Time if required */
  125. if (scl_sda_cfg)
  126. writel(scl_sda_cfg->sda_hold, &i2c_base->ic_sda_hold);
  127. /* Enable back i2c now speed set */
  128. dw_i2c_enable(i2c_base, true);
  129. return 0;
  130. }
  131. /*
  132. * i2c_setaddress - Sets the target slave address
  133. * @i2c_addr: target i2c address
  134. *
  135. * Sets the target slave address.
  136. */
  137. static void i2c_setaddress(struct i2c_regs *i2c_base, unsigned int i2c_addr)
  138. {
  139. /* Disable i2c */
  140. dw_i2c_enable(i2c_base, false);
  141. writel(i2c_addr, &i2c_base->ic_tar);
  142. /* Enable i2c */
  143. dw_i2c_enable(i2c_base, true);
  144. }
  145. /*
  146. * i2c_flush_rxfifo - Flushes the i2c RX FIFO
  147. *
  148. * Flushes the i2c RX FIFO
  149. */
  150. static void i2c_flush_rxfifo(struct i2c_regs *i2c_base)
  151. {
  152. while (readl(&i2c_base->ic_status) & IC_STATUS_RFNE)
  153. readl(&i2c_base->ic_cmd_data);
  154. }
  155. /*
  156. * i2c_wait_for_bb - Waits for bus busy
  157. *
  158. * Waits for bus busy
  159. */
  160. static int i2c_wait_for_bb(struct i2c_regs *i2c_base)
  161. {
  162. unsigned long start_time_bb = get_timer(0);
  163. while ((readl(&i2c_base->ic_status) & IC_STATUS_MA) ||
  164. !(readl(&i2c_base->ic_status) & IC_STATUS_TFE)) {
  165. /* Evaluate timeout */
  166. if (get_timer(start_time_bb) > (unsigned long)(I2C_BYTE_TO_BB))
  167. return 1;
  168. }
  169. return 0;
  170. }
  171. static int i2c_xfer_init(struct i2c_regs *i2c_base, uchar chip, uint addr,
  172. int alen)
  173. {
  174. if (i2c_wait_for_bb(i2c_base))
  175. return 1;
  176. i2c_setaddress(i2c_base, chip);
  177. while (alen) {
  178. alen--;
  179. /* high byte address going out first */
  180. writel((addr >> (alen * 8)) & 0xff,
  181. &i2c_base->ic_cmd_data);
  182. }
  183. return 0;
  184. }
  185. static int i2c_xfer_finish(struct i2c_regs *i2c_base)
  186. {
  187. ulong start_stop_det = get_timer(0);
  188. while (1) {
  189. if ((readl(&i2c_base->ic_raw_intr_stat) & IC_STOP_DET)) {
  190. readl(&i2c_base->ic_clr_stop_det);
  191. break;
  192. } else if (get_timer(start_stop_det) > I2C_STOPDET_TO) {
  193. break;
  194. }
  195. }
  196. if (i2c_wait_for_bb(i2c_base)) {
  197. printf("Timed out waiting for bus\n");
  198. return 1;
  199. }
  200. i2c_flush_rxfifo(i2c_base);
  201. return 0;
  202. }
  203. /*
  204. * i2c_read - Read from i2c memory
  205. * @chip: target i2c address
  206. * @addr: address to read from
  207. * @alen:
  208. * @buffer: buffer for read data
  209. * @len: no of bytes to be read
  210. *
  211. * Read from i2c memory.
  212. */
  213. static int __dw_i2c_read(struct i2c_regs *i2c_base, u8 dev, uint addr,
  214. int alen, u8 *buffer, int len)
  215. {
  216. unsigned long start_time_rx;
  217. unsigned int active = 0;
  218. #ifdef CONFIG_SYS_I2C_EEPROM_ADDR_OVERFLOW
  219. /*
  220. * EEPROM chips that implement "address overflow" are ones
  221. * like Catalyst 24WC04/08/16 which has 9/10/11 bits of
  222. * address and the extra bits end up in the "chip address"
  223. * bit slots. This makes a 24WC08 (1Kbyte) chip look like
  224. * four 256 byte chips.
  225. *
  226. * Note that we consider the length of the address field to
  227. * still be one byte because the extra address bits are
  228. * hidden in the chip address.
  229. */
  230. dev |= ((addr >> (alen * 8)) & CONFIG_SYS_I2C_EEPROM_ADDR_OVERFLOW);
  231. addr &= ~(CONFIG_SYS_I2C_EEPROM_ADDR_OVERFLOW << (alen * 8));
  232. debug("%s: fix addr_overflow: dev %02x addr %02x\n", __func__, dev,
  233. addr);
  234. #endif
  235. if (i2c_xfer_init(i2c_base, dev, addr, alen))
  236. return 1;
  237. start_time_rx = get_timer(0);
  238. while (len) {
  239. if (!active) {
  240. /*
  241. * Avoid writing to ic_cmd_data multiple times
  242. * in case this loop spins too quickly and the
  243. * ic_status RFNE bit isn't set after the first
  244. * write. Subsequent writes to ic_cmd_data can
  245. * trigger spurious i2c transfer.
  246. */
  247. if (len == 1)
  248. writel(IC_CMD | IC_STOP, &i2c_base->ic_cmd_data);
  249. else
  250. writel(IC_CMD, &i2c_base->ic_cmd_data);
  251. active = 1;
  252. }
  253. if (readl(&i2c_base->ic_status) & IC_STATUS_RFNE) {
  254. *buffer++ = (uchar)readl(&i2c_base->ic_cmd_data);
  255. len--;
  256. start_time_rx = get_timer(0);
  257. active = 0;
  258. } else if (get_timer(start_time_rx) > I2C_BYTE_TO) {
  259. return 1;
  260. }
  261. }
  262. return i2c_xfer_finish(i2c_base);
  263. }
  264. /*
  265. * i2c_write - Write to i2c memory
  266. * @chip: target i2c address
  267. * @addr: address to read from
  268. * @alen:
  269. * @buffer: buffer for read data
  270. * @len: no of bytes to be read
  271. *
  272. * Write to i2c memory.
  273. */
  274. static int __dw_i2c_write(struct i2c_regs *i2c_base, u8 dev, uint addr,
  275. int alen, u8 *buffer, int len)
  276. {
  277. int nb = len;
  278. unsigned long start_time_tx;
  279. #ifdef CONFIG_SYS_I2C_EEPROM_ADDR_OVERFLOW
  280. /*
  281. * EEPROM chips that implement "address overflow" are ones
  282. * like Catalyst 24WC04/08/16 which has 9/10/11 bits of
  283. * address and the extra bits end up in the "chip address"
  284. * bit slots. This makes a 24WC08 (1Kbyte) chip look like
  285. * four 256 byte chips.
  286. *
  287. * Note that we consider the length of the address field to
  288. * still be one byte because the extra address bits are
  289. * hidden in the chip address.
  290. */
  291. dev |= ((addr >> (alen * 8)) & CONFIG_SYS_I2C_EEPROM_ADDR_OVERFLOW);
  292. addr &= ~(CONFIG_SYS_I2C_EEPROM_ADDR_OVERFLOW << (alen * 8));
  293. debug("%s: fix addr_overflow: dev %02x addr %02x\n", __func__, dev,
  294. addr);
  295. #endif
  296. if (i2c_xfer_init(i2c_base, dev, addr, alen))
  297. return 1;
  298. start_time_tx = get_timer(0);
  299. while (len) {
  300. if (readl(&i2c_base->ic_status) & IC_STATUS_TFNF) {
  301. if (--len == 0) {
  302. writel(*buffer | IC_STOP,
  303. &i2c_base->ic_cmd_data);
  304. } else {
  305. writel(*buffer, &i2c_base->ic_cmd_data);
  306. }
  307. buffer++;
  308. start_time_tx = get_timer(0);
  309. } else if (get_timer(start_time_tx) > (nb * I2C_BYTE_TO)) {
  310. printf("Timed out. i2c write Failed\n");
  311. return 1;
  312. }
  313. }
  314. return i2c_xfer_finish(i2c_base);
  315. }
  316. /*
  317. * __dw_i2c_init - Init function
  318. * @speed: required i2c speed
  319. * @slaveaddr: slave address for the device
  320. *
  321. * Initialization function.
  322. */
  323. static void __dw_i2c_init(struct i2c_regs *i2c_base, int speed, int slaveaddr)
  324. {
  325. /* Disable i2c */
  326. dw_i2c_enable(i2c_base, false);
  327. writel(IC_CON_SD | IC_CON_RE | IC_CON_SPD_FS | IC_CON_MM,
  328. &i2c_base->ic_con);
  329. writel(IC_RX_TL, &i2c_base->ic_rx_tl);
  330. writel(IC_TX_TL, &i2c_base->ic_tx_tl);
  331. writel(IC_STOP_DET, &i2c_base->ic_intr_mask);
  332. #ifndef CONFIG_DM_I2C
  333. __dw_i2c_set_bus_speed(i2c_base, NULL, speed);
  334. writel(slaveaddr, &i2c_base->ic_sar);
  335. #endif
  336. /* Enable i2c */
  337. dw_i2c_enable(i2c_base, true);
  338. }
  339. #ifndef CONFIG_DM_I2C
  340. /*
  341. * The legacy I2C functions. These need to get removed once
  342. * all users of this driver are converted to DM.
  343. */
  344. static struct i2c_regs *i2c_get_base(struct i2c_adapter *adap)
  345. {
  346. switch (adap->hwadapnr) {
  347. #if CONFIG_SYS_I2C_BUS_MAX >= 4
  348. case 3:
  349. return (struct i2c_regs *)CONFIG_SYS_I2C_BASE3;
  350. #endif
  351. #if CONFIG_SYS_I2C_BUS_MAX >= 3
  352. case 2:
  353. return (struct i2c_regs *)CONFIG_SYS_I2C_BASE2;
  354. #endif
  355. #if CONFIG_SYS_I2C_BUS_MAX >= 2
  356. case 1:
  357. return (struct i2c_regs *)CONFIG_SYS_I2C_BASE1;
  358. #endif
  359. case 0:
  360. return (struct i2c_regs *)CONFIG_SYS_I2C_BASE;
  361. default:
  362. printf("Wrong I2C-adapter number %d\n", adap->hwadapnr);
  363. }
  364. return NULL;
  365. }
  366. static unsigned int dw_i2c_set_bus_speed(struct i2c_adapter *adap,
  367. unsigned int speed)
  368. {
  369. adap->speed = speed;
  370. return __dw_i2c_set_bus_speed(i2c_get_base(adap), NULL, speed);
  371. }
  372. static void dw_i2c_init(struct i2c_adapter *adap, int speed, int slaveaddr)
  373. {
  374. __dw_i2c_init(i2c_get_base(adap), speed, slaveaddr);
  375. }
  376. static int dw_i2c_read(struct i2c_adapter *adap, u8 dev, uint addr,
  377. int alen, u8 *buffer, int len)
  378. {
  379. return __dw_i2c_read(i2c_get_base(adap), dev, addr, alen, buffer, len);
  380. }
  381. static int dw_i2c_write(struct i2c_adapter *adap, u8 dev, uint addr,
  382. int alen, u8 *buffer, int len)
  383. {
  384. return __dw_i2c_write(i2c_get_base(adap), dev, addr, alen, buffer, len);
  385. }
  386. /* dw_i2c_probe - Probe the i2c chip */
  387. static int dw_i2c_probe(struct i2c_adapter *adap, u8 dev)
  388. {
  389. struct i2c_regs *i2c_base = i2c_get_base(adap);
  390. u32 tmp;
  391. int ret;
  392. /*
  393. * Try to read the first location of the chip.
  394. */
  395. ret = __dw_i2c_read(i2c_base, dev, 0, 1, (uchar *)&tmp, 1);
  396. if (ret)
  397. dw_i2c_init(adap, adap->speed, adap->slaveaddr);
  398. return ret;
  399. }
  400. U_BOOT_I2C_ADAP_COMPLETE(dw_0, dw_i2c_init, dw_i2c_probe, dw_i2c_read,
  401. dw_i2c_write, dw_i2c_set_bus_speed,
  402. CONFIG_SYS_I2C_SPEED, CONFIG_SYS_I2C_SLAVE, 0)
  403. #if CONFIG_SYS_I2C_BUS_MAX >= 2
  404. U_BOOT_I2C_ADAP_COMPLETE(dw_1, dw_i2c_init, dw_i2c_probe, dw_i2c_read,
  405. dw_i2c_write, dw_i2c_set_bus_speed,
  406. CONFIG_SYS_I2C_SPEED1, CONFIG_SYS_I2C_SLAVE1, 1)
  407. #endif
  408. #if CONFIG_SYS_I2C_BUS_MAX >= 3
  409. U_BOOT_I2C_ADAP_COMPLETE(dw_2, dw_i2c_init, dw_i2c_probe, dw_i2c_read,
  410. dw_i2c_write, dw_i2c_set_bus_speed,
  411. CONFIG_SYS_I2C_SPEED2, CONFIG_SYS_I2C_SLAVE2, 2)
  412. #endif
  413. #if CONFIG_SYS_I2C_BUS_MAX >= 4
  414. U_BOOT_I2C_ADAP_COMPLETE(dw_3, dw_i2c_init, dw_i2c_probe, dw_i2c_read,
  415. dw_i2c_write, dw_i2c_set_bus_speed,
  416. CONFIG_SYS_I2C_SPEED3, CONFIG_SYS_I2C_SLAVE3, 3)
  417. #endif
  418. #else /* CONFIG_DM_I2C */
  419. /* The DM I2C functions */
  420. static int designware_i2c_xfer(struct udevice *bus, struct i2c_msg *msg,
  421. int nmsgs)
  422. {
  423. struct dw_i2c *i2c = dev_get_priv(bus);
  424. int ret;
  425. debug("i2c_xfer: %d messages\n", nmsgs);
  426. for (; nmsgs > 0; nmsgs--, msg++) {
  427. debug("i2c_xfer: chip=0x%x, len=0x%x\n", msg->addr, msg->len);
  428. if (msg->flags & I2C_M_RD) {
  429. ret = __dw_i2c_read(i2c->regs, msg->addr, 0, 0,
  430. msg->buf, msg->len);
  431. } else {
  432. ret = __dw_i2c_write(i2c->regs, msg->addr, 0, 0,
  433. msg->buf, msg->len);
  434. }
  435. if (ret) {
  436. debug("i2c_write: error sending\n");
  437. return -EREMOTEIO;
  438. }
  439. }
  440. return 0;
  441. }
  442. static int designware_i2c_set_bus_speed(struct udevice *bus, unsigned int speed)
  443. {
  444. struct dw_i2c *i2c = dev_get_priv(bus);
  445. return __dw_i2c_set_bus_speed(i2c->regs, i2c->scl_sda_cfg, speed);
  446. }
  447. static int designware_i2c_probe_chip(struct udevice *bus, uint chip_addr,
  448. uint chip_flags)
  449. {
  450. struct dw_i2c *i2c = dev_get_priv(bus);
  451. struct i2c_regs *i2c_base = i2c->regs;
  452. u32 tmp;
  453. int ret;
  454. /* Try to read the first location of the chip */
  455. ret = __dw_i2c_read(i2c_base, chip_addr, 0, 1, (uchar *)&tmp, 1);
  456. if (ret)
  457. __dw_i2c_init(i2c_base, 0, 0);
  458. return ret;
  459. }
  460. static int designware_i2c_probe(struct udevice *bus)
  461. {
  462. struct dw_i2c *priv = dev_get_priv(bus);
  463. int ret;
  464. if (device_is_on_pci_bus(bus)) {
  465. #ifdef CONFIG_DM_PCI
  466. /* Save base address from PCI BAR */
  467. priv->regs = (struct i2c_regs *)
  468. dm_pci_map_bar(bus, PCI_BASE_ADDRESS_0, PCI_REGION_MEM);
  469. #ifdef CONFIG_X86
  470. /* Use BayTrail specific timing values */
  471. priv->scl_sda_cfg = &byt_config;
  472. #endif
  473. #endif
  474. } else {
  475. priv->regs = (struct i2c_regs *)devfdt_get_addr_ptr(bus);
  476. }
  477. ret = reset_get_by_name(bus, "i2c", &priv->reset_ctl);
  478. if (ret)
  479. pr_info("reset_get_by_name() failed: %d\n", ret);
  480. if (&priv->reset_ctl)
  481. reset_deassert(&priv->reset_ctl);
  482. __dw_i2c_init(priv->regs, 0, 0);
  483. return 0;
  484. }
  485. static int designware_i2c_bind(struct udevice *dev)
  486. {
  487. static int num_cards;
  488. char name[20];
  489. /* Create a unique device name for PCI type devices */
  490. if (device_is_on_pci_bus(dev)) {
  491. /*
  492. * ToDo:
  493. * Setting req_seq in the driver is probably not recommended.
  494. * But without a DT alias the number is not configured. And
  495. * using this driver is impossible for PCIe I2C devices.
  496. * This can be removed, once a better (correct) way for this
  497. * is found and implemented.
  498. */
  499. dev->req_seq = num_cards;
  500. sprintf(name, "i2c_designware#%u", num_cards++);
  501. device_set_name(dev, name);
  502. }
  503. return 0;
  504. }
  505. static const struct dm_i2c_ops designware_i2c_ops = {
  506. .xfer = designware_i2c_xfer,
  507. .probe_chip = designware_i2c_probe_chip,
  508. .set_bus_speed = designware_i2c_set_bus_speed,
  509. };
  510. static const struct udevice_id designware_i2c_ids[] = {
  511. { .compatible = "snps,designware-i2c" },
  512. { }
  513. };
  514. U_BOOT_DRIVER(i2c_designware) = {
  515. .name = "i2c_designware",
  516. .id = UCLASS_I2C,
  517. .of_match = designware_i2c_ids,
  518. .bind = designware_i2c_bind,
  519. .probe = designware_i2c_probe,
  520. .priv_auto_alloc_size = sizeof(struct dw_i2c),
  521. .ops = &designware_i2c_ops,
  522. };
  523. #ifdef CONFIG_X86
  524. static struct pci_device_id designware_pci_supported[] = {
  525. /* Intel BayTrail has 7 I2C controller located on the PCI bus */
  526. { PCI_VDEVICE(INTEL, 0x0f41) },
  527. { PCI_VDEVICE(INTEL, 0x0f42) },
  528. { PCI_VDEVICE(INTEL, 0x0f43) },
  529. { PCI_VDEVICE(INTEL, 0x0f44) },
  530. { PCI_VDEVICE(INTEL, 0x0f45) },
  531. { PCI_VDEVICE(INTEL, 0x0f46) },
  532. { PCI_VDEVICE(INTEL, 0x0f47) },
  533. {},
  534. };
  535. U_BOOT_PCI_DEVICE(i2c_designware, designware_pci_supported);
  536. #endif
  537. #endif /* CONFIG_DM_I2C */