i2c-algo-bit.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666
  1. /* -------------------------------------------------------------------------
  2. * i2c-algo-bit.c i2c driver algorithms for bit-shift adapters
  3. * -------------------------------------------------------------------------
  4. * Copyright (C) 1995-2000 Simon G. Vogl
  5. This program is free software; you can redistribute it and/or modify
  6. it under the terms of the GNU General Public License as published by
  7. the Free Software Foundation; either version 2 of the License, or
  8. (at your option) any later version.
  9. This program is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. GNU General Public License for more details.
  13. * ------------------------------------------------------------------------- */
  14. /* With some changes from Frodo Looijaard <frodol@dds.nl>, Kyösti Mälkki
  15. <kmalkki@cc.hut.fi> and Jean Delvare <jdelvare@suse.de> */
  16. #include <linux/kernel.h>
  17. #include <linux/module.h>
  18. #include <linux/delay.h>
  19. #include <linux/errno.h>
  20. #include <linux/sched.h>
  21. #include <linux/i2c.h>
  22. #include <linux/i2c-algo-bit.h>
  23. /* ----- global defines ----------------------------------------------- */
  24. #ifdef DEBUG
  25. #define bit_dbg(level, dev, format, args...) \
  26. do { \
  27. if (i2c_debug >= level) \
  28. dev_dbg(dev, format, ##args); \
  29. } while (0)
  30. #else
  31. #define bit_dbg(level, dev, format, args...) \
  32. do {} while (0)
  33. #endif /* DEBUG */
  34. /* ----- global variables --------------------------------------------- */
  35. static int bit_test; /* see if the line-setting functions work */
  36. module_param(bit_test, int, S_IRUGO);
  37. MODULE_PARM_DESC(bit_test, "lines testing - 0 off; 1 report; 2 fail if stuck");
  38. #ifdef DEBUG
  39. static int i2c_debug = 1;
  40. module_param(i2c_debug, int, S_IRUGO | S_IWUSR);
  41. MODULE_PARM_DESC(i2c_debug,
  42. "debug level - 0 off; 1 normal; 2 verbose; 3 very verbose");
  43. #endif
  44. /* --- setting states on the bus with the right timing: --------------- */
  45. #define setsda(adap, val) adap->setsda(adap->data, val)
  46. #define setscl(adap, val) adap->setscl(adap->data, val)
  47. #define getsda(adap) adap->getsda(adap->data)
  48. #define getscl(adap) adap->getscl(adap->data)
  49. static inline void sdalo(struct i2c_algo_bit_data *adap)
  50. {
  51. setsda(adap, 0);
  52. udelay((adap->udelay + 1) / 2);
  53. }
  54. static inline void sdahi(struct i2c_algo_bit_data *adap)
  55. {
  56. setsda(adap, 1);
  57. udelay((adap->udelay + 1) / 2);
  58. }
  59. static inline void scllo(struct i2c_algo_bit_data *adap)
  60. {
  61. setscl(adap, 0);
  62. udelay(adap->udelay / 2);
  63. }
  64. /*
  65. * Raise scl line, and do checking for delays. This is necessary for slower
  66. * devices.
  67. */
  68. static int sclhi(struct i2c_algo_bit_data *adap)
  69. {
  70. unsigned long start;
  71. setscl(adap, 1);
  72. /* Not all adapters have scl sense line... */
  73. if (!adap->getscl)
  74. goto done;
  75. start = jiffies;
  76. while (!getscl(adap)) {
  77. /* This hw knows how to read the clock line, so we wait
  78. * until it actually gets high. This is safer as some
  79. * chips may hold it low ("clock stretching") while they
  80. * are processing data internally.
  81. */
  82. if (time_after(jiffies, start + adap->timeout)) {
  83. /* Test one last time, as we may have been preempted
  84. * between last check and timeout test.
  85. */
  86. if (getscl(adap))
  87. break;
  88. return -ETIMEDOUT;
  89. }
  90. cpu_relax();
  91. }
  92. #ifdef DEBUG
  93. if (jiffies != start && i2c_debug >= 3)
  94. pr_debug("i2c-algo-bit: needed %ld jiffies for SCL to go "
  95. "high\n", jiffies - start);
  96. #endif
  97. done:
  98. udelay(adap->udelay);
  99. return 0;
  100. }
  101. /* --- other auxiliary functions -------------------------------------- */
  102. static void i2c_start(struct i2c_algo_bit_data *adap)
  103. {
  104. /* assert: scl, sda are high */
  105. setsda(adap, 0);
  106. udelay(adap->udelay);
  107. scllo(adap);
  108. }
  109. static void i2c_repstart(struct i2c_algo_bit_data *adap)
  110. {
  111. /* assert: scl is low */
  112. sdahi(adap);
  113. sclhi(adap);
  114. setsda(adap, 0);
  115. udelay(adap->udelay);
  116. scllo(adap);
  117. }
  118. static void i2c_stop(struct i2c_algo_bit_data *adap)
  119. {
  120. /* assert: scl is low */
  121. sdalo(adap);
  122. sclhi(adap);
  123. setsda(adap, 1);
  124. udelay(adap->udelay);
  125. }
  126. /* send a byte without start cond., look for arbitration,
  127. check ackn. from slave */
  128. /* returns:
  129. * 1 if the device acknowledged
  130. * 0 if the device did not ack
  131. * -ETIMEDOUT if an error occurred (while raising the scl line)
  132. */
  133. static int i2c_outb(struct i2c_adapter *i2c_adap, unsigned char c)
  134. {
  135. int i;
  136. int sb;
  137. int ack;
  138. struct i2c_algo_bit_data *adap = i2c_adap->algo_data;
  139. /* assert: scl is low */
  140. for (i = 7; i >= 0; i--) {
  141. sb = (c >> i) & 1;
  142. setsda(adap, sb);
  143. udelay((adap->udelay + 1) / 2);
  144. if (sclhi(adap) < 0) { /* timed out */
  145. bit_dbg(1, &i2c_adap->dev, "i2c_outb: 0x%02x, "
  146. "timeout at bit #%d\n", (int)c, i);
  147. return -ETIMEDOUT;
  148. }
  149. /* FIXME do arbitration here:
  150. * if (sb && !getsda(adap)) -> ouch! Get out of here.
  151. *
  152. * Report a unique code, so higher level code can retry
  153. * the whole (combined) message and *NOT* issue STOP.
  154. */
  155. scllo(adap);
  156. }
  157. sdahi(adap);
  158. if (sclhi(adap) < 0) { /* timeout */
  159. bit_dbg(1, &i2c_adap->dev, "i2c_outb: 0x%02x, "
  160. "timeout at ack\n", (int)c);
  161. return -ETIMEDOUT;
  162. }
  163. /* read ack: SDA should be pulled down by slave, or it may
  164. * NAK (usually to report problems with the data we wrote).
  165. */
  166. ack = !getsda(adap); /* ack: sda is pulled low -> success */
  167. bit_dbg(2, &i2c_adap->dev, "i2c_outb: 0x%02x %s\n", (int)c,
  168. ack ? "A" : "NA");
  169. scllo(adap);
  170. return ack;
  171. /* assert: scl is low (sda undef) */
  172. }
  173. static int i2c_inb(struct i2c_adapter *i2c_adap)
  174. {
  175. /* read byte via i2c port, without start/stop sequence */
  176. /* acknowledge is sent in i2c_read. */
  177. int i;
  178. unsigned char indata = 0;
  179. struct i2c_algo_bit_data *adap = i2c_adap->algo_data;
  180. /* assert: scl is low */
  181. sdahi(adap);
  182. for (i = 0; i < 8; i++) {
  183. if (sclhi(adap) < 0) { /* timeout */
  184. bit_dbg(1, &i2c_adap->dev, "i2c_inb: timeout at bit "
  185. "#%d\n", 7 - i);
  186. return -ETIMEDOUT;
  187. }
  188. indata *= 2;
  189. if (getsda(adap))
  190. indata |= 0x01;
  191. setscl(adap, 0);
  192. udelay(i == 7 ? adap->udelay / 2 : adap->udelay);
  193. }
  194. /* assert: scl is low */
  195. return indata;
  196. }
  197. /*
  198. * Sanity check for the adapter hardware - check the reaction of
  199. * the bus lines only if it seems to be idle.
  200. */
  201. static int test_bus(struct i2c_adapter *i2c_adap)
  202. {
  203. struct i2c_algo_bit_data *adap = i2c_adap->algo_data;
  204. const char *name = i2c_adap->name;
  205. int scl, sda, ret;
  206. if (adap->pre_xfer) {
  207. ret = adap->pre_xfer(i2c_adap);
  208. if (ret < 0)
  209. return -ENODEV;
  210. }
  211. if (adap->getscl == NULL)
  212. pr_info("%s: Testing SDA only, SCL is not readable\n", name);
  213. sda = getsda(adap);
  214. scl = (adap->getscl == NULL) ? 1 : getscl(adap);
  215. if (!scl || !sda) {
  216. printk(KERN_WARNING
  217. "%s: bus seems to be busy (scl=%d, sda=%d)\n",
  218. name, scl, sda);
  219. goto bailout;
  220. }
  221. sdalo(adap);
  222. sda = getsda(adap);
  223. scl = (adap->getscl == NULL) ? 1 : getscl(adap);
  224. if (sda) {
  225. printk(KERN_WARNING "%s: SDA stuck high!\n", name);
  226. goto bailout;
  227. }
  228. if (!scl) {
  229. printk(KERN_WARNING "%s: SCL unexpected low "
  230. "while pulling SDA low!\n", name);
  231. goto bailout;
  232. }
  233. sdahi(adap);
  234. sda = getsda(adap);
  235. scl = (adap->getscl == NULL) ? 1 : getscl(adap);
  236. if (!sda) {
  237. printk(KERN_WARNING "%s: SDA stuck low!\n", name);
  238. goto bailout;
  239. }
  240. if (!scl) {
  241. printk(KERN_WARNING "%s: SCL unexpected low "
  242. "while pulling SDA high!\n", name);
  243. goto bailout;
  244. }
  245. scllo(adap);
  246. sda = getsda(adap);
  247. scl = (adap->getscl == NULL) ? 0 : getscl(adap);
  248. if (scl) {
  249. printk(KERN_WARNING "%s: SCL stuck high!\n", name);
  250. goto bailout;
  251. }
  252. if (!sda) {
  253. printk(KERN_WARNING "%s: SDA unexpected low "
  254. "while pulling SCL low!\n", name);
  255. goto bailout;
  256. }
  257. sclhi(adap);
  258. sda = getsda(adap);
  259. scl = (adap->getscl == NULL) ? 1 : getscl(adap);
  260. if (!scl) {
  261. printk(KERN_WARNING "%s: SCL stuck low!\n", name);
  262. goto bailout;
  263. }
  264. if (!sda) {
  265. printk(KERN_WARNING "%s: SDA unexpected low "
  266. "while pulling SCL high!\n", name);
  267. goto bailout;
  268. }
  269. if (adap->post_xfer)
  270. adap->post_xfer(i2c_adap);
  271. pr_info("%s: Test OK\n", name);
  272. return 0;
  273. bailout:
  274. sdahi(adap);
  275. sclhi(adap);
  276. if (adap->post_xfer)
  277. adap->post_xfer(i2c_adap);
  278. return -ENODEV;
  279. }
  280. /* ----- Utility functions
  281. */
  282. /* try_address tries to contact a chip for a number of
  283. * times before it gives up.
  284. * return values:
  285. * 1 chip answered
  286. * 0 chip did not answer
  287. * -x transmission error
  288. */
  289. static int try_address(struct i2c_adapter *i2c_adap,
  290. unsigned char addr, int retries)
  291. {
  292. struct i2c_algo_bit_data *adap = i2c_adap->algo_data;
  293. int i, ret = 0;
  294. for (i = 0; i <= retries; i++) {
  295. ret = i2c_outb(i2c_adap, addr);
  296. if (ret == 1 || i == retries)
  297. break;
  298. bit_dbg(3, &i2c_adap->dev, "emitting stop condition\n");
  299. i2c_stop(adap);
  300. udelay(adap->udelay);
  301. yield();
  302. bit_dbg(3, &i2c_adap->dev, "emitting start condition\n");
  303. i2c_start(adap);
  304. }
  305. if (i && ret)
  306. bit_dbg(1, &i2c_adap->dev, "Used %d tries to %s client at "
  307. "0x%02x: %s\n", i + 1,
  308. addr & 1 ? "read from" : "write to", addr >> 1,
  309. ret == 1 ? "success" : "failed, timeout?");
  310. return ret;
  311. }
  312. static int sendbytes(struct i2c_adapter *i2c_adap, struct i2c_msg *msg)
  313. {
  314. const unsigned char *temp = msg->buf;
  315. int count = msg->len;
  316. unsigned short nak_ok = msg->flags & I2C_M_IGNORE_NAK;
  317. int retval;
  318. int wrcount = 0;
  319. while (count > 0) {
  320. retval = i2c_outb(i2c_adap, *temp);
  321. /* OK/ACK; or ignored NAK */
  322. if ((retval > 0) || (nak_ok && (retval == 0))) {
  323. count--;
  324. temp++;
  325. wrcount++;
  326. /* A slave NAKing the master means the slave didn't like
  327. * something about the data it saw. For example, maybe
  328. * the SMBus PEC was wrong.
  329. */
  330. } else if (retval == 0) {
  331. dev_err(&i2c_adap->dev, "sendbytes: NAK bailout.\n");
  332. return -EIO;
  333. /* Timeout; or (someday) lost arbitration
  334. *
  335. * FIXME Lost ARB implies retrying the transaction from
  336. * the first message, after the "winning" master issues
  337. * its STOP. As a rule, upper layer code has no reason
  338. * to know or care about this ... it is *NOT* an error.
  339. */
  340. } else {
  341. dev_err(&i2c_adap->dev, "sendbytes: error %d\n",
  342. retval);
  343. return retval;
  344. }
  345. }
  346. return wrcount;
  347. }
  348. static int acknak(struct i2c_adapter *i2c_adap, int is_ack)
  349. {
  350. struct i2c_algo_bit_data *adap = i2c_adap->algo_data;
  351. /* assert: sda is high */
  352. if (is_ack) /* send ack */
  353. setsda(adap, 0);
  354. udelay((adap->udelay + 1) / 2);
  355. if (sclhi(adap) < 0) { /* timeout */
  356. dev_err(&i2c_adap->dev, "readbytes: ack/nak timeout\n");
  357. return -ETIMEDOUT;
  358. }
  359. scllo(adap);
  360. return 0;
  361. }
  362. static int readbytes(struct i2c_adapter *i2c_adap, struct i2c_msg *msg)
  363. {
  364. int inval;
  365. int rdcount = 0; /* counts bytes read */
  366. unsigned char *temp = msg->buf;
  367. int count = msg->len;
  368. const unsigned flags = msg->flags;
  369. while (count > 0) {
  370. inval = i2c_inb(i2c_adap);
  371. if (inval >= 0) {
  372. *temp = inval;
  373. rdcount++;
  374. } else { /* read timed out */
  375. break;
  376. }
  377. temp++;
  378. count--;
  379. /* Some SMBus transactions require that we receive the
  380. transaction length as the first read byte. */
  381. if (rdcount == 1 && (flags & I2C_M_RECV_LEN)) {
  382. if (inval <= 0 || inval > I2C_SMBUS_BLOCK_MAX) {
  383. if (!(flags & I2C_M_NO_RD_ACK))
  384. acknak(i2c_adap, 0);
  385. dev_err(&i2c_adap->dev, "readbytes: invalid "
  386. "block length (%d)\n", inval);
  387. return -EPROTO;
  388. }
  389. /* The original count value accounts for the extra
  390. bytes, that is, either 1 for a regular transaction,
  391. or 2 for a PEC transaction. */
  392. count += inval;
  393. msg->len += inval;
  394. }
  395. bit_dbg(2, &i2c_adap->dev, "readbytes: 0x%02x %s\n",
  396. inval,
  397. (flags & I2C_M_NO_RD_ACK)
  398. ? "(no ack/nak)"
  399. : (count ? "A" : "NA"));
  400. if (!(flags & I2C_M_NO_RD_ACK)) {
  401. inval = acknak(i2c_adap, count);
  402. if (inval < 0)
  403. return inval;
  404. }
  405. }
  406. return rdcount;
  407. }
  408. /* doAddress initiates the transfer by generating the start condition (in
  409. * try_address) and transmits the address in the necessary format to handle
  410. * reads, writes as well as 10bit-addresses.
  411. * returns:
  412. * 0 everything went okay, the chip ack'ed, or IGNORE_NAK flag was set
  413. * -x an error occurred (like: -ENXIO if the device did not answer, or
  414. * -ETIMEDOUT, for example if the lines are stuck...)
  415. */
  416. static int bit_doAddress(struct i2c_adapter *i2c_adap, struct i2c_msg *msg)
  417. {
  418. unsigned short flags = msg->flags;
  419. unsigned short nak_ok = msg->flags & I2C_M_IGNORE_NAK;
  420. struct i2c_algo_bit_data *adap = i2c_adap->algo_data;
  421. unsigned char addr;
  422. int ret, retries;
  423. retries = nak_ok ? 0 : i2c_adap->retries;
  424. if (flags & I2C_M_TEN) {
  425. /* a ten bit address */
  426. addr = 0xf0 | ((msg->addr >> 7) & 0x06);
  427. bit_dbg(2, &i2c_adap->dev, "addr0: %d\n", addr);
  428. /* try extended address code...*/
  429. ret = try_address(i2c_adap, addr, retries);
  430. if ((ret != 1) && !nak_ok) {
  431. dev_err(&i2c_adap->dev,
  432. "died at extended address code\n");
  433. return -ENXIO;
  434. }
  435. /* the remaining 8 bit address */
  436. ret = i2c_outb(i2c_adap, msg->addr & 0xff);
  437. if ((ret != 1) && !nak_ok) {
  438. /* the chip did not ack / xmission error occurred */
  439. dev_err(&i2c_adap->dev, "died at 2nd address code\n");
  440. return -ENXIO;
  441. }
  442. if (flags & I2C_M_RD) {
  443. bit_dbg(3, &i2c_adap->dev, "emitting repeated "
  444. "start condition\n");
  445. i2c_repstart(adap);
  446. /* okay, now switch into reading mode */
  447. addr |= 0x01;
  448. ret = try_address(i2c_adap, addr, retries);
  449. if ((ret != 1) && !nak_ok) {
  450. dev_err(&i2c_adap->dev,
  451. "died at repeated address code\n");
  452. return -EIO;
  453. }
  454. }
  455. } else { /* normal 7bit address */
  456. addr = msg->addr << 1;
  457. if (flags & I2C_M_RD)
  458. addr |= 1;
  459. if (flags & I2C_M_REV_DIR_ADDR)
  460. addr ^= 1;
  461. ret = try_address(i2c_adap, addr, retries);
  462. if ((ret != 1) && !nak_ok)
  463. return -ENXIO;
  464. }
  465. return 0;
  466. }
  467. static int bit_xfer(struct i2c_adapter *i2c_adap,
  468. struct i2c_msg msgs[], int num)
  469. {
  470. struct i2c_msg *pmsg;
  471. struct i2c_algo_bit_data *adap = i2c_adap->algo_data;
  472. int i, ret;
  473. unsigned short nak_ok;
  474. if (adap->pre_xfer) {
  475. ret = adap->pre_xfer(i2c_adap);
  476. if (ret < 0)
  477. return ret;
  478. }
  479. bit_dbg(3, &i2c_adap->dev, "emitting start condition\n");
  480. i2c_start(adap);
  481. for (i = 0; i < num; i++) {
  482. pmsg = &msgs[i];
  483. nak_ok = pmsg->flags & I2C_M_IGNORE_NAK;
  484. if (!(pmsg->flags & I2C_M_NOSTART)) {
  485. if (i) {
  486. bit_dbg(3, &i2c_adap->dev, "emitting "
  487. "repeated start condition\n");
  488. i2c_repstart(adap);
  489. }
  490. ret = bit_doAddress(i2c_adap, pmsg);
  491. if ((ret != 0) && !nak_ok) {
  492. bit_dbg(1, &i2c_adap->dev, "NAK from "
  493. "device addr 0x%02x msg #%d\n",
  494. msgs[i].addr, i);
  495. goto bailout;
  496. }
  497. }
  498. if (pmsg->flags & I2C_M_RD) {
  499. /* read bytes into buffer*/
  500. ret = readbytes(i2c_adap, pmsg);
  501. if (ret >= 1)
  502. bit_dbg(2, &i2c_adap->dev, "read %d byte%s\n",
  503. ret, ret == 1 ? "" : "s");
  504. if (ret < pmsg->len) {
  505. if (ret >= 0)
  506. ret = -EIO;
  507. goto bailout;
  508. }
  509. } else {
  510. /* write bytes from buffer */
  511. ret = sendbytes(i2c_adap, pmsg);
  512. if (ret >= 1)
  513. bit_dbg(2, &i2c_adap->dev, "wrote %d byte%s\n",
  514. ret, ret == 1 ? "" : "s");
  515. if (ret < pmsg->len) {
  516. if (ret >= 0)
  517. ret = -EIO;
  518. goto bailout;
  519. }
  520. }
  521. }
  522. ret = i;
  523. bailout:
  524. bit_dbg(3, &i2c_adap->dev, "emitting stop condition\n");
  525. i2c_stop(adap);
  526. if (adap->post_xfer)
  527. adap->post_xfer(i2c_adap);
  528. return ret;
  529. }
  530. static u32 bit_func(struct i2c_adapter *adap)
  531. {
  532. return I2C_FUNC_I2C | I2C_FUNC_NOSTART | I2C_FUNC_SMBUS_EMUL |
  533. I2C_FUNC_SMBUS_READ_BLOCK_DATA |
  534. I2C_FUNC_SMBUS_BLOCK_PROC_CALL |
  535. I2C_FUNC_10BIT_ADDR | I2C_FUNC_PROTOCOL_MANGLING;
  536. }
  537. /* -----exported algorithm data: ------------------------------------- */
  538. const struct i2c_algorithm i2c_bit_algo = {
  539. .master_xfer = bit_xfer,
  540. .functionality = bit_func,
  541. };
  542. EXPORT_SYMBOL(i2c_bit_algo);
  543. /*
  544. * registering functions to load algorithms at runtime
  545. */
  546. static int __i2c_bit_add_bus(struct i2c_adapter *adap,
  547. int (*add_adapter)(struct i2c_adapter *))
  548. {
  549. struct i2c_algo_bit_data *bit_adap = adap->algo_data;
  550. int ret;
  551. if (bit_test) {
  552. ret = test_bus(adap);
  553. if (bit_test >= 2 && ret < 0)
  554. return -ENODEV;
  555. }
  556. /* register new adapter to i2c module... */
  557. adap->algo = &i2c_bit_algo;
  558. adap->retries = 3;
  559. ret = add_adapter(adap);
  560. if (ret < 0)
  561. return ret;
  562. /* Complain if SCL can't be read */
  563. if (bit_adap->getscl == NULL) {
  564. dev_warn(&adap->dev, "Not I2C compliant: can't read SCL\n");
  565. dev_warn(&adap->dev, "Bus may be unreliable\n");
  566. }
  567. return 0;
  568. }
  569. int i2c_bit_add_bus(struct i2c_adapter *adap)
  570. {
  571. return __i2c_bit_add_bus(adap, i2c_add_adapter);
  572. }
  573. EXPORT_SYMBOL(i2c_bit_add_bus);
  574. int i2c_bit_add_numbered_bus(struct i2c_adapter *adap)
  575. {
  576. return __i2c_bit_add_bus(adap, i2c_add_numbered_adapter);
  577. }
  578. EXPORT_SYMBOL(i2c_bit_add_numbered_bus);
  579. MODULE_AUTHOR("Simon G. Vogl <simon@tk.uni-linz.ac.at>");
  580. MODULE_DESCRIPTION("I2C-Bus bit-banging algorithm");
  581. MODULE_LICENSE("GPL");