Lines Matching +full:cpu +full:- +full:map

1 // SPDX-License-Identifier: GPL-2.0
73 unsigned int cpu; member
79 struct cv1800_dmamux_map *map = route_data; in cv1800_dmamux_free() local
81 guard(spinlock_irqsave)(&dmamux->lock); in cv1800_dmamux_free()
83 regmap_update_bits(dmamux->regmap, in cv1800_dmamux_free()
84 DMAMUX_CH_REG(map->channel), in cv1800_dmamux_free()
85 DMAMUX_CH_MASK(map->channel), in cv1800_dmamux_free()
88 regmap_update_bits(dmamux->regmap, REG_DMA_INT_MUX, in cv1800_dmamux_free()
89 DMAMUX_INT_CH_MASK(map->channel, map->cpu), in cv1800_dmamux_free()
90 DMAMUX_INTEN_BIT(map->cpu)); in cv1800_dmamux_free()
92 dev_dbg(dev, "free channel %u for req %u (cpu %u)\n", in cv1800_dmamux_free()
93 map->channel, map->peripheral, map->cpu); in cv1800_dmamux_free()
99 struct platform_device *pdev = of_find_device_by_node(ofdma->of_node); in cv1800_dmamux_route_allocate()
101 struct cv1800_dmamux_map *map; in cv1800_dmamux_route_allocate() local
107 if (dma_spec->args_count != DMAMUX_NCELLS) { in cv1800_dmamux_route_allocate()
108 dev_err(&pdev->dev, "invalid number of dma mux args\n"); in cv1800_dmamux_route_allocate()
109 return ERR_PTR(-EINVAL); in cv1800_dmamux_route_allocate()
112 devid = dma_spec->args[0]; in cv1800_dmamux_route_allocate()
113 cpuid = dma_spec->args[1]; in cv1800_dmamux_route_allocate()
114 dma_spec->args_count = 1; in cv1800_dmamux_route_allocate()
117 dev_err(&pdev->dev, "invalid device id: %u\n", devid); in cv1800_dmamux_route_allocate()
118 return ERR_PTR(-EINVAL); in cv1800_dmamux_route_allocate()
122 dev_err(&pdev->dev, "invalid cpu id: %u\n", cpuid); in cv1800_dmamux_route_allocate()
123 return ERR_PTR(-EINVAL); in cv1800_dmamux_route_allocate()
126 dma_spec->np = of_parse_phandle(ofdma->of_node, "dma-masters", 0); in cv1800_dmamux_route_allocate()
127 if (!dma_spec->np) { in cv1800_dmamux_route_allocate()
128 dev_err(&pdev->dev, "can't get dma master\n"); in cv1800_dmamux_route_allocate()
129 return ERR_PTR(-EINVAL); in cv1800_dmamux_route_allocate()
132 spin_lock_irqsave(&dmamux->lock, flags); in cv1800_dmamux_route_allocate()
134 if (test_bit(devid, dmamux->mapped_peripherals)) { in cv1800_dmamux_route_allocate()
135 llist_for_each_entry(map, dmamux->reserve_maps.first, node) { in cv1800_dmamux_route_allocate()
136 if (map->peripheral == devid && map->cpu == cpuid) in cv1800_dmamux_route_allocate()
140 ret = -EINVAL; in cv1800_dmamux_route_allocate()
143 node = llist_del_first(&dmamux->free_maps); in cv1800_dmamux_route_allocate()
145 ret = -ENODEV; in cv1800_dmamux_route_allocate()
149 map = llist_entry(node, struct cv1800_dmamux_map, node); in cv1800_dmamux_route_allocate()
150 llist_add(&map->node, &dmamux->reserve_maps); in cv1800_dmamux_route_allocate()
151 set_bit(devid, dmamux->mapped_peripherals); in cv1800_dmamux_route_allocate()
155 chid = map->channel; in cv1800_dmamux_route_allocate()
156 map->peripheral = devid; in cv1800_dmamux_route_allocate()
157 map->cpu = cpuid; in cv1800_dmamux_route_allocate()
159 regmap_set_bits(dmamux->regmap, in cv1800_dmamux_route_allocate()
163 regmap_update_bits(dmamux->regmap, REG_DMA_INT_MUX, in cv1800_dmamux_route_allocate()
167 spin_unlock_irqrestore(&dmamux->lock, flags); in cv1800_dmamux_route_allocate()
169 dma_spec->args[0] = chid; in cv1800_dmamux_route_allocate()
171 dev_dbg(&pdev->dev, "register channel %u for req %u (cpu %u)\n", in cv1800_dmamux_route_allocate()
174 return map; in cv1800_dmamux_route_allocate()
177 spin_unlock_irqrestore(&dmamux->lock, flags); in cv1800_dmamux_route_allocate()
178 of_node_put(dma_spec->np); in cv1800_dmamux_route_allocate()
179 dev_err(&pdev->dev, "errno %d\n", ret); in cv1800_dmamux_route_allocate()
185 struct device *dev = &pdev->dev; in cv1800_dmamux_probe()
186 struct device_node *mux_node = dev->of_node; in cv1800_dmamux_probe()
189 struct device *parent = dev->parent; in cv1800_dmamux_probe()
194 return -ENODEV; in cv1800_dmamux_probe()
196 regmap = device_node_to_regmap(parent->of_node); in cv1800_dmamux_probe()
202 return -ENOMEM; in cv1800_dmamux_probe()
204 spin_lock_init(&data->lock); in cv1800_dmamux_probe()
205 init_llist_head(&data->free_maps); in cv1800_dmamux_probe()
206 init_llist_head(&data->reserve_maps); in cv1800_dmamux_probe()
216 init_llist_node(&tmp->node); in cv1800_dmamux_probe()
217 tmp->channel = i; in cv1800_dmamux_probe()
218 llist_add(&tmp->node, &data->free_maps); in cv1800_dmamux_probe()
222 if (llist_empty(&data->free_maps)) in cv1800_dmamux_probe()
223 return -ENOMEM; in cv1800_dmamux_probe()
225 data->regmap = regmap; in cv1800_dmamux_probe()
226 data->dmarouter.dev = dev; in cv1800_dmamux_probe()
227 data->dmarouter.route_free = cv1800_dmamux_free; in cv1800_dmamux_probe()
233 &data->dmarouter); in cv1800_dmamux_probe()
238 of_dma_controller_free(pdev->dev.of_node); in cv1800_dmamux_remove()
242 { .compatible = "sophgo,cv1800b-dmamux", },
251 .name = "cv1800-dmamux",