aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/i2c/busses/i2c-imx.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/i2c/busses/i2c-imx.c')
-rw-r--r--drivers/i2c/busses/i2c-imx.c33
1 files changed, 17 insertions, 16 deletions
diff --git a/drivers/i2c/busses/i2c-imx.c b/drivers/i2c/busses/i2c-imx.c
index 7f3a9fe9bf4e..d7b26fc6f432 100644
--- a/drivers/i2c/busses/i2c-imx.c
+++ b/drivers/i2c/busses/i2c-imx.c
@@ -201,7 +201,7 @@ struct imx_i2c_struct {
201 void __iomem *base; 201 void __iomem *base;
202 wait_queue_head_t queue; 202 wait_queue_head_t queue;
203 unsigned long i2csr; 203 unsigned long i2csr;
204 unsigned int disable_delay; 204 unsigned int disable_delay;
205 int stopped; 205 int stopped;
206 unsigned int ifdr; /* IMX_I2C_IFDR */ 206 unsigned int ifdr; /* IMX_I2C_IFDR */
207 unsigned int cur_clk; 207 unsigned int cur_clk;
@@ -295,7 +295,6 @@ static void i2c_imx_dma_request(struct imx_i2c_struct *i2c_imx,
295 dma->chan_tx = dma_request_slave_channel(dev, "tx"); 295 dma->chan_tx = dma_request_slave_channel(dev, "tx");
296 if (!dma->chan_tx) { 296 if (!dma->chan_tx) {
297 dev_dbg(dev, "can't request DMA tx channel\n"); 297 dev_dbg(dev, "can't request DMA tx channel\n");
298 ret = -ENODEV;
299 goto fail_al; 298 goto fail_al;
300 } 299 }
301 300
@@ -313,7 +312,6 @@ static void i2c_imx_dma_request(struct imx_i2c_struct *i2c_imx,
313 dma->chan_rx = dma_request_slave_channel(dev, "rx"); 312 dma->chan_rx = dma_request_slave_channel(dev, "rx");
314 if (!dma->chan_rx) { 313 if (!dma->chan_rx) {
315 dev_dbg(dev, "can't request DMA rx channel\n"); 314 dev_dbg(dev, "can't request DMA rx channel\n");
316 ret = -ENODEV;
317 goto fail_tx; 315 goto fail_tx;
318 } 316 }
319 317
@@ -481,8 +479,8 @@ static void i2c_imx_set_clk(struct imx_i2c_struct *i2c_imx)
481 i2c_clk_rate = clk_get_rate(i2c_imx->clk); 479 i2c_clk_rate = clk_get_rate(i2c_imx->clk);
482 if (i2c_imx->cur_clk == i2c_clk_rate) 480 if (i2c_imx->cur_clk == i2c_clk_rate)
483 return; 481 return;
484 else 482
485 i2c_imx->cur_clk = i2c_clk_rate; 483 i2c_imx->cur_clk = i2c_clk_rate;
486 484
487 div = (i2c_clk_rate + i2c_imx->bitrate - 1) / i2c_imx->bitrate; 485 div = (i2c_clk_rate + i2c_imx->bitrate - 1) / i2c_imx->bitrate;
488 if (div < i2c_clk_div[0].div) 486 if (div < i2c_clk_div[0].div)
@@ -490,7 +488,8 @@ static void i2c_imx_set_clk(struct imx_i2c_struct *i2c_imx)
490 else if (div > i2c_clk_div[i2c_imx->hwdata->ndivs - 1].div) 488 else if (div > i2c_clk_div[i2c_imx->hwdata->ndivs - 1].div)
491 i = i2c_imx->hwdata->ndivs - 1; 489 i = i2c_imx->hwdata->ndivs - 1;
492 else 490 else
493 for (i = 0; i2c_clk_div[i].div < div; i++); 491 for (i = 0; i2c_clk_div[i].div < div; i++)
492 ;
494 493
495 /* Store divider value */ 494 /* Store divider value */
496 i2c_imx->ifdr = i2c_clk_div[i].val; 495 i2c_imx->ifdr = i2c_clk_div[i].val;
@@ -628,9 +627,9 @@ static int i2c_imx_dma_write(struct imx_i2c_struct *i2c_imx,
628 result = wait_for_completion_timeout( 627 result = wait_for_completion_timeout(
629 &i2c_imx->dma->cmd_complete, 628 &i2c_imx->dma->cmd_complete,
630 msecs_to_jiffies(DMA_TIMEOUT)); 629 msecs_to_jiffies(DMA_TIMEOUT));
631 if (result <= 0) { 630 if (result == 0) {
632 dmaengine_terminate_all(dma->chan_using); 631 dmaengine_terminate_all(dma->chan_using);
633 return result ?: -ETIMEDOUT; 632 return -ETIMEDOUT;
634 } 633 }
635 634
636 /* Waiting for transfer complete. */ 635 /* Waiting for transfer complete. */
@@ -686,9 +685,9 @@ static int i2c_imx_dma_read(struct imx_i2c_struct *i2c_imx,
686 result = wait_for_completion_timeout( 685 result = wait_for_completion_timeout(
687 &i2c_imx->dma->cmd_complete, 686 &i2c_imx->dma->cmd_complete,
688 msecs_to_jiffies(DMA_TIMEOUT)); 687 msecs_to_jiffies(DMA_TIMEOUT));
689 if (result <= 0) { 688 if (result == 0) {
690 dmaengine_terminate_all(dma->chan_using); 689 dmaengine_terminate_all(dma->chan_using);
691 return result ?: -ETIMEDOUT; 690 return -ETIMEDOUT;
692 } 691 }
693 692
694 /* waiting for transfer complete. */ 693 /* waiting for transfer complete. */
@@ -822,6 +821,7 @@ static int i2c_imx_read(struct imx_i2c_struct *i2c_imx, struct i2c_msg *msgs, bo
822 /* read data */ 821 /* read data */
823 for (i = 0; i < msgs->len; i++) { 822 for (i = 0; i < msgs->len; i++) {
824 u8 len = 0; 823 u8 len = 0;
824
825 result = i2c_imx_trx_complete(i2c_imx); 825 result = i2c_imx_trx_complete(i2c_imx);
826 if (result) 826 if (result)
827 return result; 827 return result;
@@ -917,15 +917,16 @@ static int i2c_imx_xfer(struct i2c_adapter *adapter,
917 /* write/read data */ 917 /* write/read data */
918#ifdef CONFIG_I2C_DEBUG_BUS 918#ifdef CONFIG_I2C_DEBUG_BUS
919 temp = imx_i2c_read_reg(i2c_imx, IMX_I2C_I2CR); 919 temp = imx_i2c_read_reg(i2c_imx, IMX_I2C_I2CR);
920 dev_dbg(&i2c_imx->adapter.dev, "<%s> CONTROL: IEN=%d, IIEN=%d, " 920 dev_dbg(&i2c_imx->adapter.dev,
921 "MSTA=%d, MTX=%d, TXAK=%d, RSTA=%d\n", __func__, 921 "<%s> CONTROL: IEN=%d, IIEN=%d, MSTA=%d, MTX=%d, TXAK=%d, RSTA=%d\n",
922 __func__,
922 (temp & I2CR_IEN ? 1 : 0), (temp & I2CR_IIEN ? 1 : 0), 923 (temp & I2CR_IEN ? 1 : 0), (temp & I2CR_IIEN ? 1 : 0),
923 (temp & I2CR_MSTA ? 1 : 0), (temp & I2CR_MTX ? 1 : 0), 924 (temp & I2CR_MSTA ? 1 : 0), (temp & I2CR_MTX ? 1 : 0),
924 (temp & I2CR_TXAK ? 1 : 0), (temp & I2CR_RSTA ? 1 : 0)); 925 (temp & I2CR_TXAK ? 1 : 0), (temp & I2CR_RSTA ? 1 : 0));
925 temp = imx_i2c_read_reg(i2c_imx, IMX_I2C_I2SR); 926 temp = imx_i2c_read_reg(i2c_imx, IMX_I2C_I2SR);
926 dev_dbg(&i2c_imx->adapter.dev, 927 dev_dbg(&i2c_imx->adapter.dev,
927 "<%s> STATUS: ICF=%d, IAAS=%d, IBB=%d, " 928 "<%s> STATUS: ICF=%d, IAAS=%d, IBB=%d, IAL=%d, SRW=%d, IIF=%d, RXAK=%d\n",
928 "IAL=%d, SRW=%d, IIF=%d, RXAK=%d\n", __func__, 929 __func__,
929 (temp & I2SR_ICF ? 1 : 0), (temp & I2SR_IAAS ? 1 : 0), 930 (temp & I2SR_ICF ? 1 : 0), (temp & I2SR_IAAS ? 1 : 0),
930 (temp & I2SR_IBB ? 1 : 0), (temp & I2SR_IAL ? 1 : 0), 931 (temp & I2SR_IBB ? 1 : 0), (temp & I2SR_IAL ? 1 : 0),
931 (temp & I2SR_SRW ? 1 : 0), (temp & I2SR_IIF ? 1 : 0), 932 (temp & I2SR_SRW ? 1 : 0), (temp & I2SR_IIF ? 1 : 0),
@@ -1004,7 +1005,7 @@ static int i2c_imx_probe(struct platform_device *pdev)
1004 i2c_imx->adapter.owner = THIS_MODULE; 1005 i2c_imx->adapter.owner = THIS_MODULE;
1005 i2c_imx->adapter.algo = &i2c_imx_algo; 1006 i2c_imx->adapter.algo = &i2c_imx_algo;
1006 i2c_imx->adapter.dev.parent = &pdev->dev; 1007 i2c_imx->adapter.dev.parent = &pdev->dev;
1007 i2c_imx->adapter.nr = pdev->id; 1008 i2c_imx->adapter.nr = pdev->id;
1008 i2c_imx->adapter.dev.of_node = pdev->dev.of_node; 1009 i2c_imx->adapter.dev.of_node = pdev->dev.of_node;
1009 i2c_imx->base = base; 1010 i2c_imx->base = base;
1010 1011
@@ -1063,7 +1064,7 @@ static int i2c_imx_probe(struct platform_device *pdev)
1063 i2c_imx->adapter.name); 1064 i2c_imx->adapter.name);
1064 dev_info(&i2c_imx->adapter.dev, "IMX I2C adapter registered\n"); 1065 dev_info(&i2c_imx->adapter.dev, "IMX I2C adapter registered\n");
1065 1066
1066 /* Init DMA config if support*/ 1067 /* Init DMA config if supported */
1067 i2c_imx_dma_request(i2c_imx, phy_addr); 1068 i2c_imx_dma_request(i2c_imx, phy_addr);
1068 1069
1069 return 0; /* Return OK */ 1070 return 0; /* Return OK */