Lines Matching +full:dma +full:- +full:requests

1 // SPDX-License-Identifier: GPL-2.0-only
3 * DMA Router driver for LPC18xx/43xx DMA MUX
7 * Based on TI DMA Crossbar driver by:
8 * Copyright (C) 2015 Texas Instruments Incorporated - http://www.ti.com
48 spin_lock_irqsave(&dmamux->lock, flags); in lpc18xx_dmamux_free()
49 mux->busy = false; in lpc18xx_dmamux_free()
50 spin_unlock_irqrestore(&dmamux->lock, flags); in lpc18xx_dmamux_free()
56 struct platform_device *pdev = of_find_device_by_node(ofdma->of_node); in lpc18xx_dmamux_reserve()
61 if (dma_spec->args_count != 3) { in lpc18xx_dmamux_reserve()
62 dev_err(&pdev->dev, "invalid number of dma mux args\n"); in lpc18xx_dmamux_reserve()
63 return ERR_PTR(-EINVAL); in lpc18xx_dmamux_reserve()
66 mux = dma_spec->args[0]; in lpc18xx_dmamux_reserve()
67 if (mux >= dmamux->dma_master_requests) { in lpc18xx_dmamux_reserve()
68 dev_err(&pdev->dev, "invalid mux number: %d\n", in lpc18xx_dmamux_reserve()
69 dma_spec->args[0]); in lpc18xx_dmamux_reserve()
70 return ERR_PTR(-EINVAL); in lpc18xx_dmamux_reserve()
73 if (dma_spec->args[1] > LPC18XX_DMAMUX_MAX_VAL) { in lpc18xx_dmamux_reserve()
74 dev_err(&pdev->dev, "invalid dma mux value: %d\n", in lpc18xx_dmamux_reserve()
75 dma_spec->args[1]); in lpc18xx_dmamux_reserve()
76 return ERR_PTR(-EINVAL); in lpc18xx_dmamux_reserve()
80 dma_spec->np = of_parse_phandle(ofdma->of_node, "dma-masters", 0); in lpc18xx_dmamux_reserve()
81 if (!dma_spec->np) { in lpc18xx_dmamux_reserve()
82 dev_err(&pdev->dev, "can't get dma master\n"); in lpc18xx_dmamux_reserve()
83 return ERR_PTR(-EINVAL); in lpc18xx_dmamux_reserve()
86 spin_lock_irqsave(&dmamux->lock, flags); in lpc18xx_dmamux_reserve()
87 if (dmamux->muxes[mux].busy) { in lpc18xx_dmamux_reserve()
88 spin_unlock_irqrestore(&dmamux->lock, flags); in lpc18xx_dmamux_reserve()
89 dev_err(&pdev->dev, "dma request %u busy with %u.%u\n", in lpc18xx_dmamux_reserve()
90 mux, mux, dmamux->muxes[mux].value); in lpc18xx_dmamux_reserve()
91 of_node_put(dma_spec->np); in lpc18xx_dmamux_reserve()
92 return ERR_PTR(-EBUSY); in lpc18xx_dmamux_reserve()
95 dmamux->muxes[mux].busy = true; in lpc18xx_dmamux_reserve()
96 dmamux->muxes[mux].value = dma_spec->args[1]; in lpc18xx_dmamux_reserve()
98 regmap_update_bits(dmamux->reg, LPC18XX_CREG_DMAMUX, in lpc18xx_dmamux_reserve()
100 LPC18XX_DMAMUX_VAL(dmamux->muxes[mux].value, mux)); in lpc18xx_dmamux_reserve()
101 spin_unlock_irqrestore(&dmamux->lock, flags); in lpc18xx_dmamux_reserve()
103 dma_spec->args[1] = dma_spec->args[2]; in lpc18xx_dmamux_reserve()
104 dma_spec->args_count = 2; in lpc18xx_dmamux_reserve()
106 dev_dbg(&pdev->dev, "mapping dmamux %u.%u to dma request %u\n", mux, in lpc18xx_dmamux_reserve()
107 dmamux->muxes[mux].value, mux); in lpc18xx_dmamux_reserve()
109 return &dmamux->muxes[mux]; in lpc18xx_dmamux_reserve()
114 struct device_node *dma_np, *np = pdev->dev.of_node; in lpc18xx_dmamux_probe()
118 dmamux = devm_kzalloc(&pdev->dev, sizeof(*dmamux), GFP_KERNEL); in lpc18xx_dmamux_probe()
120 return -ENOMEM; in lpc18xx_dmamux_probe()
122 dmamux->reg = syscon_regmap_lookup_by_compatible("nxp,lpc1850-creg"); in lpc18xx_dmamux_probe()
123 if (IS_ERR(dmamux->reg)) { in lpc18xx_dmamux_probe()
124 dev_err(&pdev->dev, "syscon lookup failed\n"); in lpc18xx_dmamux_probe()
125 return PTR_ERR(dmamux->reg); in lpc18xx_dmamux_probe()
128 ret = of_property_read_u32(np, "dma-requests", in lpc18xx_dmamux_probe()
129 &dmamux->dma_mux_requests); in lpc18xx_dmamux_probe()
131 dev_err(&pdev->dev, "missing dma-requests property\n"); in lpc18xx_dmamux_probe()
135 dma_np = of_parse_phandle(np, "dma-masters", 0); in lpc18xx_dmamux_probe()
137 dev_err(&pdev->dev, "can't get dma master\n"); in lpc18xx_dmamux_probe()
138 return -ENODEV; in lpc18xx_dmamux_probe()
141 ret = of_property_read_u32(dma_np, "dma-requests", in lpc18xx_dmamux_probe()
142 &dmamux->dma_master_requests); in lpc18xx_dmamux_probe()
145 dev_err(&pdev->dev, "missing master dma-requests property\n"); in lpc18xx_dmamux_probe()
149 dmamux->muxes = devm_kcalloc(&pdev->dev, dmamux->dma_master_requests, in lpc18xx_dmamux_probe()
152 if (!dmamux->muxes) in lpc18xx_dmamux_probe()
153 return -ENOMEM; in lpc18xx_dmamux_probe()
155 spin_lock_init(&dmamux->lock); in lpc18xx_dmamux_probe()
157 dmamux->dmarouter.dev = &pdev->dev; in lpc18xx_dmamux_probe()
158 dmamux->dmarouter.route_free = lpc18xx_dmamux_free; in lpc18xx_dmamux_probe()
161 &dmamux->dmarouter); in lpc18xx_dmamux_probe()
165 { .compatible = "nxp,lpc1850-dmamux" },
172 .name = "lpc18xx-dmamux",