1 From 9de3b340d84b75f93081f871b640a065cba4ded0 Mon Sep 17 00:00:00 2001
2 From: Peng Ma <peng.ma@nxp.com>
3 Date: Tue, 26 Nov 2019 16:02:00 +0800
4 Subject: [PATCH] LF-162: i2c: imx: Defer probing if EDMA not available
6 EDMA may be not available or defered due to dependencies on
7 other modules, If these scenarios is encountered, we should
10 Signed-off-by: Peng Ma <peng.ma@nxp.com>
12 drivers/i2c/busses/i2c-imx.c | 16 +++++++++++-----
13 1 file changed, 11 insertions(+), 5 deletions(-)
15 --- a/drivers/i2c/busses/i2c-imx.c
16 +++ b/drivers/i2c/busses/i2c-imx.c
17 @@ -369,8 +369,8 @@ static void i2c_imx_reset_regs(struct im
20 /* Functions for DMA support */
21 -static void i2c_imx_dma_request(struct imx_i2c_struct *i2c_imx,
22 - dma_addr_t phy_addr)
23 +static int i2c_imx_dma_request(struct imx_i2c_struct *i2c_imx,
24 + dma_addr_t phy_addr)
26 struct imx_i2c_dma *dma;
27 struct dma_slave_config dma_sconfig;
28 @@ -379,7 +379,7 @@ static void i2c_imx_dma_request(struct i
30 dma = devm_kzalloc(dev, sizeof(*dma), GFP_KERNEL);
35 dma->chan_tx = dma_request_chan(dev, "tx");
36 if (IS_ERR(dma->chan_tx)) {
37 @@ -424,7 +424,7 @@ static void i2c_imx_dma_request(struct i
38 dev_info(dev, "using %s (tx) and %s (rx) for DMA transfers\n",
39 dma_chan_name(dma->chan_tx), dma_chan_name(dma->chan_rx));
45 dma_release_channel(dma->chan_rx);
46 @@ -432,6 +432,8 @@ fail_tx:
47 dma_release_channel(dma->chan_tx);
54 static void i2c_imx_dma_callback(void *arg)
55 @@ -1602,10 +1604,14 @@ static int i2c_imx_probe(struct platform
56 dev_info(&i2c_imx->adapter.dev, "IMX I2C adapter registered\n");
58 /* Init DMA config if supported */
59 - i2c_imx_dma_request(i2c_imx, phy_addr);
60 + ret = i2c_imx_dma_request(i2c_imx, phy_addr);
61 + if (ret == -EPROBE_DEFER)
62 + goto i2c_adapter_remove;
64 return 0; /* Return OK */
67 + i2c_del_adapter(&i2c_imx->adapter);
68 clk_notifier_unregister:
69 clk_notifier_unregister(i2c_imx->clk, &i2c_imx->clk_change_nb);
70 free_irq(irq, i2c_imx);