MCPcopy Create free account
hub / github.com/RT-Thread/rt-thread / ofw_device_dma_ops

Function ofw_device_dma_ops

components/drivers/dma/dma_pool.c:168–234  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

166};
167
168static const struct rt_dma_map_ops *ofw_device_dma_ops(struct rt_device *dev)
169{
170 rt_err_t err;
171 int region_nr = 0;
172 const fdt32_t *cell;
173 rt_phandle phandle;
174 rt_region_t region;
175 struct rt_ofw_prop *prop;
176 struct rt_dma_pool *dma_pool;
177 const struct rt_dma_map_ops *ops = RT_NULL;
178 struct rt_ofw_node *mem_np, *np = dev->ofw_node;
179
180 rt_ofw_foreach_prop_u32(np, "memory-region", prop, cell, phandle)
181 {
182 rt_uint64_t addr, size;
183
184 if (!(mem_np = rt_ofw_find_node_by_phandle(phandle)))
185 {
186 if (region_nr == 0)
187 {
188 return RT_NULL;
189 }
190
191 break;
192 }
193
194 if ((err = rt_ofw_get_address(mem_np, 0, &addr, &size)))
195 {
196 LOG_E("%s: Read '%s' error = %s", rt_ofw_node_full_name(mem_np),
197 "memory-region", rt_strerror(err));
198
199 rt_ofw_node_put(mem_np);
200 continue;
201 }
202
203 region.start = addr;
204 region.end = addr + size;
205 region.name = rt_dm_dev_get_name(dev);
206
207 rt_ofw_node_put(mem_np);
208
209 if (!(dma_pool = dma_pool_install(&region)))
210 {
211 return RT_NULL;
212 }
213
214 if (rt_ofw_prop_read_bool(mem_np, "no-map"))
215 {
216 dma_pool->flags |= RT_DMA_F_NOMAP;
217 }
218
219 if (!rt_dma_device_is_coherent(dev))
220 {
221 dma_pool->flags |= RT_DMA_F_NOCACHE;
222 }
223
224 dma_pool->dev = dev;
225 ++region_nr;

Callers 1

device_dma_opsFunction · 0.85

Calls 9

rt_ofw_get_addressFunction · 0.85
rt_ofw_node_full_nameFunction · 0.85
rt_strerrorFunction · 0.85
rt_ofw_node_putFunction · 0.85
rt_dm_dev_get_nameFunction · 0.85
dma_pool_installFunction · 0.85
rt_ofw_prop_read_boolFunction · 0.85

Tested by

no test coverage detected