MCPcopy Create free account
hub / github.com/F-Stack/f-stack / ti_sdma_activate_channel

Function ti_sdma_activate_channel

freebsd/arm/ti/ti_sdma.c:315–387  ·  view source on GitHub ↗

* ti_sdma_activate_channel - activates a DMA channel * @ch: upon return contains the channel allocated * @callback: a callback function to associate with the channel * @data: optional data supplied when the callback is called * * Simply activates a channel be enabling and writing default values to the * channel's register set. It doesn't start a transaction, just populates the * internal d

Source from the content-addressed store, hash-verified

313 * 0 on success, otherwise an error code
314 */
315int
316ti_sdma_activate_channel(unsigned int *ch,
317 void (*callback)(unsigned int ch, uint32_t status, void *data),
318 void *data)
319{
320 struct ti_sdma_softc *sc = ti_sdma_sc;
321 struct ti_sdma_channel *channel = NULL;
322 uint32_t addr;
323 unsigned int i;
324
325 /* Sanity check */
326 if (sc == NULL)
327 return (ENOMEM);
328
329 if (ch == NULL)
330 return (EINVAL);
331
332 TI_SDMA_LOCK(sc);
333
334 /* Check to see if all channels are in use */
335 if (sc->sc_active_channels == 0xffffffff) {
336 TI_SDMA_UNLOCK(sc);
337 return (ENOMEM);
338 }
339
340 /* Find the first non-active channel */
341 for (i = 0; i < NUM_DMA_CHANNELS; i++) {
342 if (!(sc->sc_active_channels & (0x1 << i))) {
343 sc->sc_active_channels |= (0x1 << i);
344 *ch = i;
345 break;
346 }
347 }
348
349 /* Get the channel struct and populate the fields */
350 channel = &sc->sc_channel[*ch];
351
352 channel->callback = callback;
353 channel->callback_data = data;
354
355 channel->need_reg_write = 1;
356
357 /* Set the default configuration for the DMA channel */
358 channel->reg_csdp = DMA4_CSDP_DATA_TYPE(0x2)
359 | DMA4_CSDP_SRC_BURST_MODE(0)
360 | DMA4_CSDP_DST_BURST_MODE(0)
361 | DMA4_CSDP_SRC_ENDIANISM(0)
362 | DMA4_CSDP_DST_ENDIANISM(0)
363 | DMA4_CSDP_WRITE_MODE(0)
364 | DMA4_CSDP_SRC_PACKED(0)
365 | DMA4_CSDP_DST_PACKED(0);
366
367 channel->reg_ccr = DMA4_CCR_DST_ADDRESS_MODE(1)
368 | DMA4_CCR_SRC_ADDRESS_MODE(1)
369 | DMA4_CCR_READ_PRIORITY(0)
370 | DMA4_CCR_WRITE_PRIORITY(0)
371 | DMA4_CCR_SYNC_TRIGGER(0)
372 | DMA4_CCR_FRAME_SYNC(0)

Callers

nothing calls this directly

Calls 1

ti_sdma_write_4Function · 0.85

Tested by

no test coverage detected