Commit 187432b8 authored by Marek Szyprowski's avatar Marek Szyprowski Committed by Wolfram Sang

i2c: s3c24xx: add support for atomic transfers

Add support for atomic transfers using polling mode with interrupts
intentionally disabled to get rid of the following warning introduced by
commit 63b96983 ("i2c: core: introduce callbacks for atomic
transfers") during system reboot and power-off:

------------[ cut here ]------------
WARNING: CPU: 0 PID: 1518 at drivers/i2c/i2c-core.h:40 i2c_transfer+0xe8/0xf4
No atomic I2C transfer handler for 'i2c-0'
...
---[ end trace 0000000000000000 ]---
Signed-off-by: default avatarMarek Szyprowski <m.szyprowski@samsung.com>
Reviewed-by: default avatarChanho Park <chanho61.park@samsung.com>
Reviewed-by: default avatarAndi Shyti <andi.shyti@kernel.org>
Signed-off-by: default avatarWolfram Sang <wsa@kernel.org>
parent 990489e1
...@@ -76,6 +76,7 @@ ...@@ -76,6 +76,7 @@
#define QUIRK_HDMIPHY (1 << 1) #define QUIRK_HDMIPHY (1 << 1)
#define QUIRK_NO_GPIO (1 << 2) #define QUIRK_NO_GPIO (1 << 2)
#define QUIRK_POLL (1 << 3) #define QUIRK_POLL (1 << 3)
#define QUIRK_ATOMIC (1 << 4)
/* Max time to wait for bus to become idle after a xfer (in us) */ /* Max time to wait for bus to become idle after a xfer (in us) */
#define S3C2410_IDLE_TIMEOUT 5000 #define S3C2410_IDLE_TIMEOUT 5000
...@@ -174,7 +175,7 @@ static inline void s3c24xx_i2c_master_complete(struct s3c24xx_i2c *i2c, int ret) ...@@ -174,7 +175,7 @@ static inline void s3c24xx_i2c_master_complete(struct s3c24xx_i2c *i2c, int ret)
if (ret) if (ret)
i2c->msg_idx = ret; i2c->msg_idx = ret;
if (!(i2c->quirks & QUIRK_POLL)) if (!(i2c->quirks & (QUIRK_POLL | QUIRK_ATOMIC)))
wake_up(&i2c->wait); wake_up(&i2c->wait);
} }
...@@ -703,7 +704,7 @@ static int s3c24xx_i2c_doxfer(struct s3c24xx_i2c *i2c, ...@@ -703,7 +704,7 @@ static int s3c24xx_i2c_doxfer(struct s3c24xx_i2c *i2c,
s3c24xx_i2c_enable_irq(i2c); s3c24xx_i2c_enable_irq(i2c);
s3c24xx_i2c_message_start(i2c, msgs); s3c24xx_i2c_message_start(i2c, msgs);
if (i2c->quirks & QUIRK_POLL) { if (i2c->quirks & (QUIRK_POLL | QUIRK_ATOMIC)) {
while ((i2c->msg_num != 0) && is_ack(i2c)) { while ((i2c->msg_num != 0) && is_ack(i2c)) {
unsigned long stat = readl(i2c->regs + S3C2410_IICSTAT); unsigned long stat = readl(i2c->regs + S3C2410_IICSTAT);
...@@ -775,6 +776,21 @@ static int s3c24xx_i2c_xfer(struct i2c_adapter *adap, ...@@ -775,6 +776,21 @@ static int s3c24xx_i2c_xfer(struct i2c_adapter *adap,
return -EREMOTEIO; return -EREMOTEIO;
} }
static int s3c24xx_i2c_xfer_atomic(struct i2c_adapter *adap,
struct i2c_msg *msgs, int num)
{
struct s3c24xx_i2c *i2c = (struct s3c24xx_i2c *)adap->algo_data;
int ret;
disable_irq(i2c->irq);
i2c->quirks |= QUIRK_ATOMIC;
ret = s3c24xx_i2c_xfer(adap, msgs, num);
i2c->quirks &= ~QUIRK_ATOMIC;
enable_irq(i2c->irq);
return ret;
}
/* declare our i2c functionality */ /* declare our i2c functionality */
static u32 s3c24xx_i2c_func(struct i2c_adapter *adap) static u32 s3c24xx_i2c_func(struct i2c_adapter *adap)
{ {
...@@ -785,6 +801,7 @@ static u32 s3c24xx_i2c_func(struct i2c_adapter *adap) ...@@ -785,6 +801,7 @@ static u32 s3c24xx_i2c_func(struct i2c_adapter *adap)
/* i2c bus registration info */ /* i2c bus registration info */
static const struct i2c_algorithm s3c24xx_i2c_algorithm = { static const struct i2c_algorithm s3c24xx_i2c_algorithm = {
.master_xfer = s3c24xx_i2c_xfer, .master_xfer = s3c24xx_i2c_xfer,
.master_xfer_atomic = s3c24xx_i2c_xfer_atomic,
.functionality = s3c24xx_i2c_func, .functionality = s3c24xx_i2c_func,
}; };
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment