aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLudovic Desroches <ludovic.desroches@atmel.com>2014-11-21 08:44:32 -0500
committerWolfram Sang <wsa@the-dreams.de>2014-11-23 11:27:29 -0500
commit727f9c2dad9dd3e9aff4f64e92df577f1409a768 (patch)
tree408e4801ba7fe270c9ad7efbaa11895d5514aace
parentdc6df6e90de9b1e0fb2e2329312b4431de60ad0f (diff)
i2c: at91: enable probe deferring on dma channel request
If dma controller is not probed, defer i2c probe. Signed-off-by: Ludovic Desroches <ludovic.desroches@atmel.com> Reviewed-by: Arnd Bergmann <arnd@arndb.de> Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
-rw-r--r--drivers/i2c/busses/i2c-at91.c25
1 files changed, 14 insertions, 11 deletions
diff --git a/drivers/i2c/busses/i2c-at91.c b/drivers/i2c/busses/i2c-at91.c
index 8790f2332458..87e2f142ae6c 100644
--- a/drivers/i2c/busses/i2c-at91.c
+++ b/drivers/i2c/busses/i2c-at91.c
@@ -650,17 +650,17 @@ static int at91_twi_configure_dma(struct at91_twi_dev *dev, u32 phy_addr)
650 slave_config.dst_maxburst = 1; 650 slave_config.dst_maxburst = 1;
651 slave_config.device_fc = false; 651 slave_config.device_fc = false;
652 652
653 dma->chan_tx = dma_request_slave_channel(dev->dev, "tx"); 653 dma->chan_tx = dma_request_slave_channel_reason(dev->dev, "tx");
654 if (!dma->chan_tx) { 654 if (IS_ERR(dma->chan_tx)) {
655 dev_err(dev->dev, "can't get a DMA channel for tx\n"); 655 ret = PTR_ERR(dma->chan_tx);
656 ret = -EBUSY; 656 dma->chan_tx = NULL;
657 goto error; 657 goto error;
658 } 658 }
659 659
660 dma->chan_rx = dma_request_slave_channel(dev->dev, "rx"); 660 dma->chan_rx = dma_request_slave_channel_reason(dev->dev, "rx");
661 if (!dma->chan_rx) { 661 if (IS_ERR(dma->chan_rx)) {
662 dev_err(dev->dev, "can't get a DMA channel for rx\n"); 662 ret = PTR_ERR(dma->chan_rx);
663 ret = -EBUSY; 663 dma->chan_rx = NULL;
664 goto error; 664 goto error;
665 } 665 }
666 666
@@ -681,6 +681,7 @@ static int at91_twi_configure_dma(struct at91_twi_dev *dev, u32 phy_addr)
681 sg_init_table(&dma->sg, 1); 681 sg_init_table(&dma->sg, 1);
682 dma->buf_mapped = false; 682 dma->buf_mapped = false;
683 dma->xfer_in_progress = false; 683 dma->xfer_in_progress = false;
684 dev->use_dma = true;
684 685
685 dev_info(dev->dev, "using %s (tx) and %s (rx) for DMA transfers\n", 686 dev_info(dev->dev, "using %s (tx) and %s (rx) for DMA transfers\n",
686 dma_chan_name(dma->chan_tx), dma_chan_name(dma->chan_rx)); 687 dma_chan_name(dma->chan_tx), dma_chan_name(dma->chan_rx));
@@ -688,7 +689,8 @@ static int at91_twi_configure_dma(struct at91_twi_dev *dev, u32 phy_addr)
688 return ret; 689 return ret;
689 690
690error: 691error:
691 dev_info(dev->dev, "can't use DMA\n"); 692 if (ret != -EPROBE_DEFER)
693 dev_info(dev->dev, "can't use DMA, error %d\n", ret);
692 if (dma->chan_rx) 694 if (dma->chan_rx)
693 dma_release_channel(dma->chan_rx); 695 dma_release_channel(dma->chan_rx);
694 if (dma->chan_tx) 696 if (dma->chan_tx)
@@ -757,8 +759,9 @@ static int at91_twi_probe(struct platform_device *pdev)
757 clk_prepare_enable(dev->clk); 759 clk_prepare_enable(dev->clk);
758 760
759 if (dev->dev->of_node) { 761 if (dev->dev->of_node) {
760 if (at91_twi_configure_dma(dev, phy_addr) == 0) 762 rc = at91_twi_configure_dma(dev, phy_addr);
761 dev->use_dma = true; 763 if (rc == -EPROBE_DEFER)
764 return rc;
762 } 765 }
763 766
764 rc = of_property_read_u32(dev->dev->of_node, "clock-frequency", 767 rc = of_property_read_u32(dev->dev->of_node, "clock-frequency",