Commit c850ecfc authored by Marek Szyprowski's avatar Marek Szyprowski Committed by Wolfram Sang

i2c: brcmstb: Add support for atomic transfers

Add support for atomic transfers using polling mode with interrupts
intentionally disabled to get rid of the warning introduced by commit
63b96983 ("i2c: core: introduce callbacks for atomic transfers")
during system reboot and power-off.
Signed-off-by: default avatarMarek Szyprowski <m.szyprowski@samsung.com>
Reviewed-by: default avatarFlorian Fainelli <florian.fainelli@broadcom.com>
Reviewed-by: default avatarAndi Shyti <andi.shyti@kernel.org>
Signed-off-by: default avatarWolfram Sang <wsa@kernel.org>
parent 8c56f9ef
...@@ -160,6 +160,7 @@ struct brcmstb_i2c_dev { ...@@ -160,6 +160,7 @@ struct brcmstb_i2c_dev {
struct completion done; struct completion done;
u32 clk_freq_hz; u32 clk_freq_hz;
int data_regsz; int data_regsz;
bool atomic;
}; };
/* register accessors for both be and le cpu arch */ /* register accessors for both be and le cpu arch */
...@@ -240,7 +241,7 @@ static int brcmstb_i2c_wait_for_completion(struct brcmstb_i2c_dev *dev) ...@@ -240,7 +241,7 @@ static int brcmstb_i2c_wait_for_completion(struct brcmstb_i2c_dev *dev)
int ret = 0; int ret = 0;
unsigned long timeout = msecs_to_jiffies(I2C_TIMEOUT); unsigned long timeout = msecs_to_jiffies(I2C_TIMEOUT);
if (dev->irq >= 0) { if (dev->irq >= 0 && !dev->atomic) {
if (!wait_for_completion_timeout(&dev->done, timeout)) if (!wait_for_completion_timeout(&dev->done, timeout))
ret = -ETIMEDOUT; ret = -ETIMEDOUT;
} else { } else {
...@@ -287,7 +288,7 @@ static int brcmstb_send_i2c_cmd(struct brcmstb_i2c_dev *dev, ...@@ -287,7 +288,7 @@ static int brcmstb_send_i2c_cmd(struct brcmstb_i2c_dev *dev,
return rc; return rc;
/* only if we are in interrupt mode */ /* only if we are in interrupt mode */
if (dev->irq >= 0) if (dev->irq >= 0 && !dev->atomic)
reinit_completion(&dev->done); reinit_completion(&dev->done);
/* enable BSC CTL interrupt line */ /* enable BSC CTL interrupt line */
...@@ -520,6 +521,23 @@ static int brcmstb_i2c_xfer(struct i2c_adapter *adapter, ...@@ -520,6 +521,23 @@ static int brcmstb_i2c_xfer(struct i2c_adapter *adapter,
} }
static int brcmstb_i2c_xfer_atomic(struct i2c_adapter *adapter,
struct i2c_msg msgs[], int num)
{
struct brcmstb_i2c_dev *dev = i2c_get_adapdata(adapter);
int ret;
if (dev->irq >= 0)
disable_irq(dev->irq);
dev->atomic = true;
ret = brcmstb_i2c_xfer(adapter, msgs, num);
dev->atomic = false;
if (dev->irq >= 0)
enable_irq(dev->irq);
return ret;
}
static u32 brcmstb_i2c_functionality(struct i2c_adapter *adap) static u32 brcmstb_i2c_functionality(struct i2c_adapter *adap)
{ {
return I2C_FUNC_I2C | I2C_FUNC_SMBUS_EMUL | I2C_FUNC_10BIT_ADDR return I2C_FUNC_I2C | I2C_FUNC_SMBUS_EMUL | I2C_FUNC_10BIT_ADDR
...@@ -528,6 +546,7 @@ static u32 brcmstb_i2c_functionality(struct i2c_adapter *adap) ...@@ -528,6 +546,7 @@ static u32 brcmstb_i2c_functionality(struct i2c_adapter *adap)
static const struct i2c_algorithm brcmstb_i2c_algo = { static const struct i2c_algorithm brcmstb_i2c_algo = {
.master_xfer = brcmstb_i2c_xfer, .master_xfer = brcmstb_i2c_xfer,
.master_xfer_atomic = brcmstb_i2c_xfer_atomic,
.functionality = brcmstb_i2c_functionality, .functionality = brcmstb_i2c_functionality,
}; };
......
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