diff options
author | Ed Nash <ed.nash@timesys.com> | 2013-02-06 15:48:38 -0500 |
---|---|---|
committer | Ed Nash <ed.nash@timesys.com> | 2013-02-17 18:49:01 -0500 |
commit | 64d3336b3a83c44f9cab909c07a22d805aade63b (patch) | |
tree | 56867f3259105353047fbf478f417f39feb24d82 /drivers/i2c/busses/i2c-imx.c | |
parent | c3a8aceebb13cbc4d50bd8a3a781f4ec9ef14951 (diff) |
add semaphore protection with MQX of I2C bus
Diffstat (limited to 'drivers/i2c/busses/i2c-imx.c')
-rw-r--r-- | drivers/i2c/busses/i2c-imx.c | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/drivers/i2c/busses/i2c-imx.c b/drivers/i2c/busses/i2c-imx.c index 71b8cd4f8a3e..7741e8036997 100644 --- a/drivers/i2c/busses/i2c-imx.c +++ b/drivers/i2c/busses/i2c-imx.c @@ -52,6 +52,7 @@ #include <mach/irqs.h> #include <mach/hardware.h> #include <mach/i2c.h> +#include <linux/mvf_sema4.h> /** Defines ******************************************************************** *******************************************************************************/ @@ -122,6 +123,8 @@ static u16 __initdata i2c_clk_div[60][2] = { { 2304, 0x3C }, { 2560, 0x3D }, { 3072, 0x3E }, { 3584, 0x7A }, { 3840, 0x3F }, { 4096, 0x7B }, { 5120, 0x7D }, { 6144, 0x7E }, }; + +static MVF_SEMA4* sema4; #else static u16 __initdata i2c_clk_div[50][2] = { { 22, 0x20 }, { 24, 0x21 }, { 26, 0x22 }, { 28, 0x23 }, @@ -152,6 +155,7 @@ struct imx_i2c_struct { unsigned int ifdr; /* IMX_I2C_IFDR */ }; + /** Functions for IMX I2C adapter driver *************************************** *******************************************************************************/ @@ -434,6 +438,12 @@ static int i2c_imx_xfer(struct i2c_adapter *adapter, dev_dbg(&i2c_imx->adapter.dev, "<%s>\n", __func__); +#ifdef CONFIG_ARCH_MVF + result = mvf_sema4_lock(sema4, 1000000); + if(result) + return result; +#endif + /* Start I2C transfer */ result = i2c_imx_start(i2c_imx); if (result) @@ -482,6 +492,10 @@ fail0: /* Stop I2C transfer */ i2c_imx_stop(i2c_imx); +#ifdef CONFIG_ARCH_MVF + mvf_sema4_unlock(sema4); +#endif + dev_dbg(&i2c_imx->adapter.dev, "<%s> exit with: %s: %d\n", __func__, (result < 0) ? "error" : "success msg", (result < 0) ? result : num); @@ -605,6 +619,14 @@ static int __init i2c_imx_probe(struct platform_device *pdev) /* Set up platform driver data */ platform_set_drvdata(pdev, i2c_imx); +#ifdef CONFIG_ARCH_MVF + // make sure not in use by MQX + if(mvf_sema4_assign(3, true, &sema4)) { + dev_err(&pdev->dev, "could not grab MQX semaphore\n"); + goto fail5; + } +#endif + dev_dbg(&i2c_imx->adapter.dev, "claimed irq %d\n", i2c_imx->irq); dev_dbg(&i2c_imx->adapter.dev, "device resources from 0x%x to 0x%x\n", i2c_imx->res->start, i2c_imx->res->end); |