i2c-s3c2410.c (0b28330e39bbe0ffee4c56b09fc415fcec595ea3) | i2c-s3c2410.c (1bc2962e530527de829bf4b1eb99f24dc25d1828) |
---|---|
1/* linux/drivers/i2c/busses/i2c-s3c2410.c 2 * 3 * Copyright (C) 2004,2005,2009 Simtec Electronics 4 * Ben Dooks <ben@simtec.co.uk> 5 * 6 * S3C2410 I2C Controller 7 * 8 * This program is free software; you can redistribute it and/or modify --- 468 unchanged lines hidden (view full) --- 477/* s3c24xx_i2c_doxfer 478 * 479 * this starts an i2c transfer 480*/ 481 482static int s3c24xx_i2c_doxfer(struct s3c24xx_i2c *i2c, 483 struct i2c_msg *msgs, int num) 484{ | 1/* linux/drivers/i2c/busses/i2c-s3c2410.c 2 * 3 * Copyright (C) 2004,2005,2009 Simtec Electronics 4 * Ben Dooks <ben@simtec.co.uk> 5 * 6 * S3C2410 I2C Controller 7 * 8 * This program is free software; you can redistribute it and/or modify --- 468 unchanged lines hidden (view full) --- 477/* s3c24xx_i2c_doxfer 478 * 479 * this starts an i2c transfer 480*/ 481 482static int s3c24xx_i2c_doxfer(struct s3c24xx_i2c *i2c, 483 struct i2c_msg *msgs, int num) 484{ |
485 unsigned long timeout; | 485 unsigned long iicstat, timeout; 486 int spins = 20; |
486 int ret; 487 488 if (i2c->suspended) 489 return -EIO; 490 491 ret = s3c24xx_i2c_set_master(i2c); 492 if (ret != 0) { 493 dev_err(i2c->dev, "cannot get bus (error %d)\n", ret); --- 22 unchanged lines hidden (view full) --- 516 517 if (timeout == 0) 518 dev_dbg(i2c->dev, "timeout\n"); 519 else if (ret != num) 520 dev_dbg(i2c->dev, "incomplete xfer (%d)\n", ret); 521 522 /* ensure the stop has been through the bus */ 523 | 487 int ret; 488 489 if (i2c->suspended) 490 return -EIO; 491 492 ret = s3c24xx_i2c_set_master(i2c); 493 if (ret != 0) { 494 dev_err(i2c->dev, "cannot get bus (error %d)\n", ret); --- 22 unchanged lines hidden (view full) --- 517 518 if (timeout == 0) 519 dev_dbg(i2c->dev, "timeout\n"); 520 else if (ret != num) 521 dev_dbg(i2c->dev, "incomplete xfer (%d)\n", ret); 522 523 /* ensure the stop has been through the bus */ 524 |
524 msleep(1); | 525 dev_dbg(i2c->dev, "waiting for bus idle\n"); |
525 | 526 |
527 /* first, try busy waiting briefly */ 528 do { 529 iicstat = readl(i2c->regs + S3C2410_IICSTAT); 530 } while ((iicstat & S3C2410_IICSTAT_START) && --spins); 531 532 /* if that timed out sleep */ 533 if (!spins) { 534 msleep(1); 535 iicstat = readl(i2c->regs + S3C2410_IICSTAT); 536 } 537 538 if (iicstat & S3C2410_IICSTAT_START) 539 dev_warn(i2c->dev, "timeout waiting for bus idle\n"); 540 |
|
526 out: 527 return ret; 528} 529 530/* s3c24xx_i2c_xfer 531 * 532 * first port of call from the i2c bus code when an message needs 533 * transferring across the i2c bus. --- 486 unchanged lines hidden --- | 541 out: 542 return ret; 543} 544 545/* s3c24xx_i2c_xfer 546 * 547 * first port of call from the i2c bus code when an message needs 548 * transferring across the i2c bus. --- 486 unchanged lines hidden --- |