Commit 727f9c2d authored by Ludovic Desroches's avatar Ludovic Desroches Committed by Wolfram Sang

i2c: at91: enable probe deferring on dma channel request

If dma controller is not probed, defer i2c probe.
Signed-off-by: default avatarLudovic Desroches <ludovic.desroches@atmel.com>
Reviewed-by: default avatarArnd Bergmann <arnd@arndb.de>
Signed-off-by: default avatarWolfram Sang <wsa@the-dreams.de>
parent dc6df6e9
...@@ -650,17 +650,17 @@ static int at91_twi_configure_dma(struct at91_twi_dev *dev, u32 phy_addr) ...@@ -650,17 +650,17 @@ static int at91_twi_configure_dma(struct at91_twi_dev *dev, u32 phy_addr)
slave_config.dst_maxburst = 1; slave_config.dst_maxburst = 1;
slave_config.device_fc = false; slave_config.device_fc = false;
dma->chan_tx = dma_request_slave_channel(dev->dev, "tx"); dma->chan_tx = dma_request_slave_channel_reason(dev->dev, "tx");
if (!dma->chan_tx) { if (IS_ERR(dma->chan_tx)) {
dev_err(dev->dev, "can't get a DMA channel for tx\n"); ret = PTR_ERR(dma->chan_tx);
ret = -EBUSY; dma->chan_tx = NULL;
goto error; goto error;
} }
dma->chan_rx = dma_request_slave_channel(dev->dev, "rx"); dma->chan_rx = dma_request_slave_channel_reason(dev->dev, "rx");
if (!dma->chan_rx) { if (IS_ERR(dma->chan_rx)) {
dev_err(dev->dev, "can't get a DMA channel for rx\n"); ret = PTR_ERR(dma->chan_rx);
ret = -EBUSY; dma->chan_rx = NULL;
goto error; goto error;
} }
...@@ -681,6 +681,7 @@ static int at91_twi_configure_dma(struct at91_twi_dev *dev, u32 phy_addr) ...@@ -681,6 +681,7 @@ static int at91_twi_configure_dma(struct at91_twi_dev *dev, u32 phy_addr)
sg_init_table(&dma->sg, 1); sg_init_table(&dma->sg, 1);
dma->buf_mapped = false; dma->buf_mapped = false;
dma->xfer_in_progress = false; dma->xfer_in_progress = false;
dev->use_dma = true;
dev_info(dev->dev, "using %s (tx) and %s (rx) for DMA transfers\n", dev_info(dev->dev, "using %s (tx) and %s (rx) for DMA transfers\n",
dma_chan_name(dma->chan_tx), dma_chan_name(dma->chan_rx)); 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,7 +689,8 @@ static int at91_twi_configure_dma(struct at91_twi_dev *dev, u32 phy_addr)
return ret; return ret;
error: error:
dev_info(dev->dev, "can't use DMA\n"); if (ret != -EPROBE_DEFER)
dev_info(dev->dev, "can't use DMA, error %d\n", ret);
if (dma->chan_rx) if (dma->chan_rx)
dma_release_channel(dma->chan_rx); dma_release_channel(dma->chan_rx);
if (dma->chan_tx) if (dma->chan_tx)
...@@ -757,8 +759,9 @@ static int at91_twi_probe(struct platform_device *pdev) ...@@ -757,8 +759,9 @@ static int at91_twi_probe(struct platform_device *pdev)
clk_prepare_enable(dev->clk); clk_prepare_enable(dev->clk);
if (dev->dev->of_node) { if (dev->dev->of_node) {
if (at91_twi_configure_dma(dev, phy_addr) == 0) rc = at91_twi_configure_dma(dev, phy_addr);
dev->use_dma = true; if (rc == -EPROBE_DEFER)
return rc;
} }
rc = of_property_read_u32(dev->dev->of_node, "clock-frequency", rc = of_property_read_u32(dev->dev->of_node, "clock-frequency",
......
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