Lines Matching full:dma

11 /* Functions for DMA support */
17 struct stm32_i2c_dma *dma; in stm32_i2c_dma_request() local
21 dma = devm_kzalloc(dev, sizeof(*dma), GFP_KERNEL); in stm32_i2c_dma_request()
22 if (!dma) in stm32_i2c_dma_request()
25 /* Request and configure I2C TX dma channel */ in stm32_i2c_dma_request()
26 dma->chan_tx = dma_request_chan(dev, "tx"); in stm32_i2c_dma_request()
27 if (IS_ERR(dma->chan_tx)) { in stm32_i2c_dma_request()
28 ret = PTR_ERR(dma->chan_tx); in stm32_i2c_dma_request()
31 "can't request DMA tx channel\n"); in stm32_i2c_dma_request()
40 ret = dmaengine_slave_config(dma->chan_tx, &dma_sconfig); in stm32_i2c_dma_request()
46 /* Request and configure I2C RX dma channel */ in stm32_i2c_dma_request()
47 dma->chan_rx = dma_request_chan(dev, "rx"); in stm32_i2c_dma_request()
48 if (IS_ERR(dma->chan_rx)) { in stm32_i2c_dma_request()
49 ret = PTR_ERR(dma->chan_rx); in stm32_i2c_dma_request()
52 "can't request DMA rx channel\n"); in stm32_i2c_dma_request()
62 ret = dmaengine_slave_config(dma->chan_rx, &dma_sconfig); in stm32_i2c_dma_request()
68 init_completion(&dma->dma_complete); in stm32_i2c_dma_request()
70 dev_info(dev, "using %s (tx) and %s (rx) for DMA transfers\n", in stm32_i2c_dma_request()
71 dma_chan_name(dma->chan_tx), dma_chan_name(dma->chan_rx)); in stm32_i2c_dma_request()
73 return dma; in stm32_i2c_dma_request()
76 dma_release_channel(dma->chan_rx); in stm32_i2c_dma_request()
78 dma_release_channel(dma->chan_tx); in stm32_i2c_dma_request()
80 devm_kfree(dev, dma); in stm32_i2c_dma_request()
85 void stm32_i2c_dma_free(struct stm32_i2c_dma *dma) in stm32_i2c_dma_free() argument
87 dma->dma_buf = 0; in stm32_i2c_dma_free()
88 dma->dma_len = 0; in stm32_i2c_dma_free()
90 dma_release_channel(dma->chan_tx); in stm32_i2c_dma_free()
91 dma->chan_tx = NULL; in stm32_i2c_dma_free()
93 dma_release_channel(dma->chan_rx); in stm32_i2c_dma_free()
94 dma->chan_rx = NULL; in stm32_i2c_dma_free()
96 dma->chan_using = NULL; in stm32_i2c_dma_free()
99 int stm32_i2c_prep_dma_xfer(struct device *dev, struct stm32_i2c_dma *dma, in stm32_i2c_prep_dma_xfer() argument
109 dma->chan_using = dma->chan_rx; in stm32_i2c_prep_dma_xfer()
110 dma->dma_transfer_dir = DMA_DEV_TO_MEM; in stm32_i2c_prep_dma_xfer()
111 dma->dma_data_dir = DMA_FROM_DEVICE; in stm32_i2c_prep_dma_xfer()
113 dma->chan_using = dma->chan_tx; in stm32_i2c_prep_dma_xfer()
114 dma->dma_transfer_dir = DMA_MEM_TO_DEV; in stm32_i2c_prep_dma_xfer()
115 dma->dma_data_dir = DMA_TO_DEVICE; in stm32_i2c_prep_dma_xfer()
118 dma->dma_len = len; in stm32_i2c_prep_dma_xfer()
119 chan_dev = dma->chan_using->device->dev; in stm32_i2c_prep_dma_xfer()
121 dma->dma_buf = dma_map_single(chan_dev, buf, dma->dma_len, in stm32_i2c_prep_dma_xfer()
122 dma->dma_data_dir); in stm32_i2c_prep_dma_xfer()
123 if (dma_mapping_error(chan_dev, dma->dma_buf)) { in stm32_i2c_prep_dma_xfer()
124 dev_err(dev, "DMA mapping failed\n"); in stm32_i2c_prep_dma_xfer()
128 txdesc = dmaengine_prep_slave_single(dma->chan_using, dma->dma_buf, in stm32_i2c_prep_dma_xfer()
129 dma->dma_len, in stm32_i2c_prep_dma_xfer()
130 dma->dma_transfer_dir, in stm32_i2c_prep_dma_xfer()
133 dev_err(dev, "Not able to get desc for DMA xfer\n"); in stm32_i2c_prep_dma_xfer()
138 reinit_completion(&dma->dma_complete); in stm32_i2c_prep_dma_xfer()
144 dev_err(dev, "DMA submit failed\n"); in stm32_i2c_prep_dma_xfer()
148 dma_async_issue_pending(dma->chan_using); in stm32_i2c_prep_dma_xfer()
153 dma_unmap_single(chan_dev, dma->dma_buf, dma->dma_len, in stm32_i2c_prep_dma_xfer()
154 dma->dma_data_dir); in stm32_i2c_prep_dma_xfer()