i2c-algo-bit.c 16 KB

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