Lines Matching +full:stm32 +full:- +full:timers
1 // SPDX-License-Identifier: GPL-2.0
8 #include <linux/mfd/stm32-timers.h>
32 status = dmaengine_tx_status(dma->chan, dma->chan->cookie, &state); in stm32_timers_dma_done()
34 complete(&dma->completion); in stm32_timers_dma_done()
38 * stm32_timers_dma_burst_read - Read from timers registers using DMA.
40 * Read from STM32 timers registers using DMA on a single event.
56 struct regmap *regmap = ddata->regmap; in stm32_timers_dma_burst_read()
57 struct stm32_timers_dma *dma = &ddata->dma; in stm32_timers_dma_burst_read()
69 return -EINVAL; in stm32_timers_dma_burst_read()
73 return -EINVAL; in stm32_timers_dma_burst_read()
75 if (!dma->chans[id]) in stm32_timers_dma_burst_read()
76 return -ENODEV; in stm32_timers_dma_burst_read()
77 mutex_lock(&dma->lock); in stm32_timers_dma_burst_read()
80 dma->chan = dma->chans[id]; in stm32_timers_dma_burst_read()
83 ret = -ENOMEM; in stm32_timers_dma_burst_read()
89 config.src_addr = (dma_addr_t)dma->phys_base + TIM_DMAR; in stm32_timers_dma_burst_read()
91 ret = dmaengine_slave_config(dma->chan, &config); in stm32_timers_dma_burst_read()
95 desc = dmaengine_prep_slave_single(dma->chan, dma_buf, len, in stm32_timers_dma_burst_read()
98 ret = -EBUSY; in stm32_timers_dma_burst_read()
102 desc->callback = stm32_timers_dma_done; in stm32_timers_dma_burst_read()
103 desc->callback_param = dma; in stm32_timers_dma_burst_read()
109 reinit_completion(&dma->completion); in stm32_timers_dma_burst_read()
110 dma_async_issue_pending(dma->chan); in stm32_timers_dma_burst_read()
113 dbl = FIELD_PREP(TIM_DCR_DBL, bursts - 1); in stm32_timers_dma_burst_read()
129 err = wait_for_completion_interruptible_timeout(&dma->completion, in stm32_timers_dma_burst_read()
132 ret = -ETIMEDOUT; in stm32_timers_dma_burst_read()
141 dmaengine_terminate_all(dma->chan); in stm32_timers_dma_burst_read()
145 dma->chan = NULL; in stm32_timers_dma_burst_read()
146 mutex_unlock(&dma->lock); in stm32_timers_dma_burst_read()
165 regmap_write(ddata->regmap, TIM_ARR, ~0L); in stm32_timers_get_arr_size()
166 regmap_read(ddata->regmap, TIM_ARR, &ddata->max_arr); in stm32_timers_get_arr_size()
167 regmap_write(ddata->regmap, TIM_ARR, 0x0); in stm32_timers_get_arr_size()
177 init_completion(&ddata->dma.completion); in stm32_timers_dma_probe()
178 mutex_init(&ddata->dma.lock); in stm32_timers_dma_probe()
183 ddata->dma.chans[i] = dma_request_chan(dev, name); in stm32_timers_dma_probe()
185 ddata->dma.chans[STM32_TIMERS_DMA_UP] = dma_request_chan(dev, "up"); in stm32_timers_dma_probe()
186 ddata->dma.chans[STM32_TIMERS_DMA_TRIG] = dma_request_chan(dev, "trig"); in stm32_timers_dma_probe()
187 ddata->dma.chans[STM32_TIMERS_DMA_COM] = dma_request_chan(dev, "com"); in stm32_timers_dma_probe()
190 if (IS_ERR(ddata->dma.chans[i])) { in stm32_timers_dma_probe()
192 if (PTR_ERR(ddata->dma.chans[i]) != -ENODEV && !ret) in stm32_timers_dma_probe()
193 ret = PTR_ERR(ddata->dma.chans[i]); in stm32_timers_dma_probe()
195 ddata->dma.chans[i] = NULL; in stm32_timers_dma_probe()
208 if (ddata->dma.chans[i]) in stm32_timers_dma_remove()
209 dma_release_channel(ddata->dma.chans[i]); in stm32_timers_dma_remove()
214 struct device *dev = &pdev->dev; in stm32_timers_probe()
222 return -ENOMEM; in stm32_timers_probe()
230 ddata->dma.phys_base = res->start; in stm32_timers_probe()
232 ddata->regmap = devm_regmap_init_mmio_clk(dev, "int", mmio, in stm32_timers_probe()
234 if (IS_ERR(ddata->regmap)) in stm32_timers_probe()
235 return PTR_ERR(ddata->regmap); in stm32_timers_probe()
237 ddata->clk = devm_clk_get(dev, NULL); in stm32_timers_probe()
238 if (IS_ERR(ddata->clk)) in stm32_timers_probe()
239 return PTR_ERR(ddata->clk); in stm32_timers_probe()
251 ret = of_platform_populate(pdev->dev.of_node, NULL, NULL, &pdev->dev); in stm32_timers_probe()
266 of_platform_depopulate(&pdev->dev); in stm32_timers_remove()
267 stm32_timers_dma_remove(&pdev->dev, ddata); in stm32_timers_remove()
273 { .compatible = "st,stm32-timers", },
282 .name = "stm32-timers",
288 MODULE_DESCRIPTION("STMicroelectronics STM32 Timers");