i2c-algo-bit.c 17 KB

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