32 #define DMA_REG_CFG_OFS 0x00000398UL 33 #define DMA_REG_CH_EN_OFS 0x000003A0UL 35 #define DMA_REG_INTR_RAW_TFR 0x000002C0UL 36 #define DMA_REG_INTR_RAW_BLOCK 0x000002C8UL 37 #define DMA_REG_INTR_RAW_SRC 0x000002D0UL 38 #define DMA_REG_INTR_RAW_DST 0x000002D8UL 39 #define DMA_REG_INTR_RAW_ERR 0x000002E0UL 41 #define DMA_REG_INTR_STAT_TFR 0x000002E8UL 42 #define DMA_REG_INTR_STAT_BLOCK 0x000002F0UL 43 #define DMA_REG_INTR_STAT_SRC 0x000002F8UL 44 #define DMA_REG_INTR_STAT_DST 0x00000300UL 45 #define DMA_REG_INTR_STAT_ERR 0x00000308UL 47 #define DMA_REG_INTR_MASK_TFR 0x00000310UL 48 #define DMA_REG_INTR_MASK_BLOCK 0x00000318UL 49 #define DMA_REG_INTR_MASK_SRC 0x00000320UL 50 #define DMA_REG_INTR_MASK_DST 0x00000328UL 51 #define DMA_REG_INTR_MASK_ERR 0x00000330UL 53 #define DMA_REG_INTR_CLR_TFR 0x00000338UL 54 #define DMA_REG_INTR_CLR_BLOCK 0x00000340UL 55 #define DMA_REG_INTR_CLR_SRC 0x00000348UL 56 #define DMA_REG_INTR_CLR_DST 0x00000350UL 57 #define DMA_REG_INTR_CLR_ERR 0x00000358UL 59 #define DMA_REG_INTR_STAT 0x00000360UL 61 #define DMA_REG_SRC_SW_REQ 0x00000368UL 62 #define DMA_REG_DST_SW_REQ 0x00000370UL 63 #define DMA_REG_SRC_SW_SGLREQ 0x00000378UL 64 #define DMA_REG_DST_SW_SGLREQ 0x00000380UL 65 #define DMA_REG_LST_SRC_SW_REQ 0x00000388UL 66 #define DMA_REG_LST_DST_SW_REQ 0x00000390UL 68 #define DMA_CH_REG_SAR_OFS 0x00000000UL 69 #define DMA_CH_REG_DAR_OFS 0x00000008UL 70 #define DMA_CH_REG_LLP_OFS 0x00000010UL 71 #define DMA_CH_REG_CTL_OFS 0x00000018UL 72 #define DMA_CH_REG_SSTAT_OFS 0x00000020UL 73 #define DMA_CH_REG_DSTAT_OFS 0x00000028UL 74 #define DMA_CH_REG_SSTATAR_OFS 0x00000030UL 75 #define DMA_CH_REG_DSTATAR_OFS 0x00000038UL 76 #define DMA_CH_REG_CFG_OFS 0x00000040UL 77 #define DMA_CH_REG_SGR_OFS 0x00000048UL 78 #define DMA_CH_REG_DSR_OFS 0x00000050UL 80 #define DMA_CH_REG_GAP 0x58 81 #define DMA_MAX_CTL_NB 2 82 #define DMA_MAX_CH_NB 4 84 #define DMA_IT_STATUS_TFR 0x00000001UL 85 #define DMA_IT_STATUS_BLOCK 0x00000002UL 86 #define DMA_IT_STATUS_SRCT 0x00000004UL 87 #define DMA_IT_STATUS_DSTT 0x00000008UL 88 #define DMA_IT_STATUS_ERR 0x00000010UL 89 #define DMA_IT_STATUS_ALL 0x0000001FUL 91 #define DMA_CH_CTL_INT_EN 0x00000001UL 92 #define DMA_CH_CTL_DST_TR_WIDTH 0x0000000EUL 93 #define DMA_CH_CTL_SRC_TR_WIDTH 0x00000070UL 94 #define DMA_CH_CTL_DINC 0x00000180UL 95 #define DMA_CH_CTL_SINC 0x00000600UL 96 #define DMA_CH_CTL_DEST_MSIZE 0x00003800UL 97 #define DMA_CH_CTL_SRC_MSIZE 0x0001C000UL 98 #define DMA_CH_CTL_TT_FC 0x00700000UL 99 #define DMA_CH_CTL_DMS 0x01800000UL 100 #define DMA_CH_CTL_SMS 0x06000000UL 101 #define DMA_CH_CTL_LLP_DST_EN 0x08000000UL 102 #define DMA_CH_CTL_LLP_SRC_EN 0x10000000UL 103 #define DMA_CH_CTL_BLOCK_TS 0x0000FFFFUL 105 #define DMA_CH_CFG_PRIOR 0x000000E0UL 106 #define DMA_CH_CFG_SUSP 0x00000100UL 107 #define DMA_CH_CFG_FIFO_EMPTY 0x00000200UL 108 #define DMA_CH_CFG_HS_SEL_DST 0x00000400UL 109 #define DMA_CH_CFG_HS_SEL_SRC 0x00000800UL 110 #define DMA_CH_CFG_LOCK_CH_L 0x00003000UL 111 #define DMA_CH_CFG_LOCK_B_L 0x0000C000UL 112 #define DMA_CH_CFG_LOCK_CH 0x00010000UL 113 #define DMA_CH_CFG_LOCK_B 0x00020000UL 114 #define DMA_CH_CFG_DST_HS_POL 0x00040000UL 115 #define DMA_CH_CFG_SRC_HS_POL 0x00080000UL 116 #define DMA_CH_CFG_RELOAD_SRC 0x40000000UL 117 #define DMA_CH_CFG_RELOAD_DST 0x80000000UL 118 #define DMA_CH_CFG_FCMODE 0x00000001UL 119 #define DMA_CH_CFG_FIFO_MODE 0x00000002UL 120 #define DMA_CH_CFG_DS_UPD_EN 0x00000020UL 121 #define DMA_CH_CFG_SS_UPD_EN 0x00000040UL 122 #define DMA_CH_CFG_SRC_PER 0x00000780UL 123 #define DMA_CH_CFG_DEST_PER 0x00007800UL 135 enum dma_error_code {
137 DMA_ERR_BAD_STATE = -1,
138 DMA_ERR_INVALID_PARA = -2,
143 enum dma0_periph_id {
148 DMA_ID_I2S_MASTER_TX,
157 enum dma1_periph_id {
162 DMA_ID_I2S_MASTER_RX,
172 DMA_CTL_TR_WIDTH_8BITS = 0,
173 DMA_CTL_TR_WIDTH_16BITS,
174 DMA_CTL_TR_WIDTH_32BITS,
175 DMA_CTL_TR_WIDTH_64BITS,
176 DMA_CTL_TR_WIDTH_128BITS,
177 DMA_CTL_TR_WIDTH_256BITS,
181 DMA_CTL_TR_MSIZE_1 = 0,
196 DMA_TT_MEM_TO_MEM_FC_DMAC = 0,
197 DMA_TT_MEM_TO_PERF_FC_DMAC,
198 DMA_TT_PERF_TO_MEM_FC_DMAC,
199 DMA_TT_PERF_TO_PERF_FC_DMAC,
200 DMA_TT_PERF_TO_MEM_FC_PERF,
201 DMA_TT_PERF_TO_PERF_FC_SRC_FC_PERF,
202 DMA_TT_MEM_TO_PERF_FC_PERF,
203 DMA_TT_PERF_TO_PERF_FC_DST_PERF,
206 enum dma_ahb_master {
208 DMA_AHB_MASTER_PERIPH,
211 enum dma_pcm_error_code {
214 DMA_PCM_ERR_INVALID_PARA,
215 DMA_PCM_ERR_DMA_BUSY,
216 DMA_PCM_ERR_DMA_TRAN,
232 uint32_t dst_tr_width:3;
233 uint32_t src_tr_width:3;
236 uint32_t dest_mszie:3;
237 uint32_t src_mszie:3;
238 uint32_t src_gather_en:1;
239 uint32_t dst_scatter_en:1;
244 uint32_t llp_dst_en:1;
245 uint32_t llp_src_en:1;
259 static __inline
void dma_enable(uint32_t base)
261 WR_WORD((base + DMA_REG_CFG_OFS), 1);
264 static __inline
void dma_disable(uint32_t base)
266 WR_WORD((base + DMA_REG_CFG_OFS), 0);
269 static __inline uint32_t dma_get_ch_enable(uint32_t base)
271 return RD_WORD(base + DMA_REG_CH_EN_OFS);
274 static __inline
void dma_ch_enable(uint32_t base,
int chn)
278 reg = (1<<chn) | (1<<(chn+8));
280 WR_WORD((base + DMA_REG_CH_EN_OFS), reg);
283 static __inline
void dma_ch_disable(uint32_t base, uint32_t ch_base,
int chn)
285 uint32_t reg = RD_WORD(base + DMA_REG_CH_EN_OFS);
287 if ((reg >> chn) & 1) {
288 uint32_t cfg_reg = RD_WORD(ch_base + DMA_CH_REG_CFG_OFS);
289 if (!(cfg_reg & DMA_CH_CFG_FIFO_EMPTY)) {
290 cfg_reg |= DMA_CH_CFG_SUSP;
291 WR_WORD(ch_base + DMA_CH_REG_CFG_OFS, cfg_reg);
292 while (!(RD_WORD(ch_base + DMA_CH_REG_CFG_OFS) & DMA_CH_CFG_FIFO_EMPTY));
295 WR_WORD((base + DMA_REG_CH_EN_OFS), reg);
299 static __inline uint32_t dma_intr_raw_tfr_status(uint32_t base)
301 return RD_WORD(base + DMA_REG_INTR_RAW_TFR);
304 static __inline uint32_t dma_intr_tfr_status(uint32_t base)
306 return RD_WORD(base + DMA_REG_INTR_STAT_TFR);
309 static __inline
void dma_intr_tfr_clear(uint32_t base)
311 WR_WORD((base + DMA_REG_INTR_CLR_TFR), 0xFF);
314 static __inline
int dma_intr_ch_raw_tfr_status(uint32_t base,
int chn)
316 return ((RD_WORD(base + DMA_REG_INTR_RAW_TFR) >> chn) & 1);
319 static __inline
int dma_intr_ch_tfr_status(uint32_t base,
int chn)
321 return ((RD_WORD(base + DMA_REG_INTR_STAT_TFR) >> chn) & 1);
324 static __inline
void dma_intr_ch_tfr_clear(uint32_t base,
int chn)
326 WR_WORD((base + DMA_REG_INTR_CLR_TFR), (1 << chn));
329 static __inline uint32_t dma_intr_raw_block_status(uint32_t base)
331 return RD_WORD(base + DMA_REG_INTR_RAW_BLOCK);
334 static __inline uint32_t dma_intr_block_status(uint32_t base)
336 return RD_WORD(base + DMA_REG_INTR_STAT_BLOCK);
339 static __inline
void dma_intr_block_clear(uint32_t base)
341 WR_WORD((base + DMA_REG_INTR_CLR_BLOCK), 0xFF);
344 static __inline
int dma_intr_ch_raw_block_status(uint32_t base,
int chn)
346 return ((RD_WORD(base + DMA_REG_INTR_RAW_BLOCK) >> chn) & 1);
349 static __inline
int dma_intr_ch_block_status(uint32_t base,
int chn)
351 return ((RD_WORD(base + DMA_REG_INTR_STAT_BLOCK) >> chn) & 1);
354 static __inline
void dma_intr_ch_block_clear(uint32_t base,
int chn)
356 WR_WORD((base + DMA_REG_INTR_CLR_BLOCK), (1 << chn));
360 static __inline uint32_t dma_intr_raw_src_status(uint32_t base)
362 return RD_WORD(base + DMA_REG_INTR_RAW_SRC);
365 static __inline uint32_t dma_intr_src_status(uint32_t base)
367 return RD_WORD(base + DMA_REG_INTR_STAT_SRC);
370 static __inline
void dma_intr_src_clear(uint32_t base)
372 WR_WORD((base + DMA_REG_INTR_CLR_SRC), 0xFF);
375 static __inline
int dma_intr_ch_raw_src_status(uint32_t base,
int chn)
377 return ((RD_WORD(base + DMA_REG_INTR_RAW_SRC) >> chn) & 1);
380 static __inline
int dma_intr_ch_src_status(uint32_t base,
int chn)
382 return ((RD_WORD(base + DMA_REG_INTR_STAT_SRC) >> chn) & 1);
385 static __inline
void dma_intr_ch_src_clear(uint32_t base,
int chn)
387 WR_WORD((base + DMA_REG_INTR_CLR_SRC), (1 << chn));
390 static __inline uint32_t dma_intr_raw_dst_status(uint32_t base)
392 return RD_WORD(base + DMA_REG_INTR_RAW_DST);
395 static __inline uint32_t dma_intr_dst_status(uint32_t base)
397 return RD_WORD(base + DMA_REG_INTR_STAT_DST);
400 static __inline
void dma_intr_dst_clear(uint32_t base)
402 WR_WORD((base + DMA_REG_INTR_CLR_DST), 0xFF);
405 static __inline
int dma_intr_ch_raw_dst_status(uint32_t base,
int chn)
407 return ((RD_WORD(base + DMA_REG_INTR_RAW_DST) >> chn) & 1);
410 static __inline
int dma_intr_ch_dst_status(uint32_t base,
int chn)
412 return ((RD_WORD(base + DMA_REG_INTR_STAT_DST) >> chn) & 1);
415 static __inline
void dma_intr_ch_dst_clear(uint32_t base,
int chn)
417 WR_WORD((base + DMA_REG_INTR_CLR_DST), (1 << chn));
420 static __inline uint32_t dma_intr_raw_err_status(uint32_t base)
422 return RD_WORD(base + DMA_REG_INTR_RAW_ERR);
425 static __inline uint32_t dma_intr_err_status(uint32_t base)
427 return RD_WORD(base + DMA_REG_INTR_STAT_ERR);
430 static __inline
void dma_intr_err_clear(uint32_t base)
432 WR_WORD((base + DMA_REG_INTR_CLR_ERR), 0xFF);
435 static __inline
int dma_intr_ch_raw_err_status(uint32_t base,
int chn)
437 return ((RD_WORD(base + DMA_REG_INTR_RAW_ERR) >> chn) & 1);
440 static __inline
int dma_intr_ch_err_status(uint32_t base,
int chn)
442 return ((RD_WORD(base + DMA_REG_INTR_STAT_ERR) >> chn) & 1);
445 static __inline
void dma_intr_ch_err_clear(uint32_t base,
int chn)
447 WR_WORD((base + DMA_REG_INTR_CLR_ERR), (1 << chn));
450 static __inline
void dma_intr_raw_clear_all(uint32_t base)
452 WR_WORD(base + DMA_REG_INTR_CLR_TFR, 0xFF);
453 WR_WORD(base + DMA_REG_INTR_CLR_BLOCK, 0xFF);
454 WR_WORD(base + DMA_REG_INTR_CLR_SRC, 0xFF);
455 WR_WORD(base + DMA_REG_INTR_CLR_DST, 0xFF);
456 WR_WORD(base + DMA_REG_INTR_CLR_ERR, 0xFF);
461 static __inline
void dma_intr_clr(uint32_t base,
int chn, uint32_t status)
463 if (status & DMA_IT_STATUS_TFR) {
464 WR_WORD((base + DMA_REG_INTR_CLR_TFR), (1 << chn));
467 if (status & DMA_IT_STATUS_BLOCK) {
468 WR_WORD((base + DMA_REG_INTR_CLR_BLOCK), (1 << chn));
471 if (status & DMA_IT_STATUS_SRCT) {
472 WR_WORD((base + DMA_REG_INTR_CLR_SRC), (1 << chn));
475 if (status & DMA_IT_STATUS_DSTT) {
476 WR_WORD((base + DMA_REG_INTR_CLR_DST), (1 << chn));
479 if (status & DMA_IT_STATUS_ERR) {
480 WR_WORD((base + DMA_REG_INTR_CLR_ERR), (1 << chn));
484 static __inline
void dma_intr_mask(uint32_t base,
int chn, uint32_t mask)
487 if (mask & DMA_IT_STATUS_TFR) {
488 WR_WORD((base + DMA_REG_INTR_MASK_TFR), (1<<(chn+8)));
491 if (mask & DMA_IT_STATUS_BLOCK) {
492 WR_WORD((base + DMA_REG_INTR_MASK_BLOCK), (1<<(chn+8)));
495 if (mask & DMA_IT_STATUS_SRCT) {
496 WR_WORD((base + DMA_REG_INTR_MASK_SRC), (1<<(chn+8)));
499 if (mask & DMA_IT_STATUS_DSTT) {
500 WR_WORD((base + DMA_REG_INTR_MASK_DST), (1<<(chn+8)));
503 if (mask & DMA_IT_STATUS_ERR) {
504 WR_WORD((base + DMA_REG_INTR_MASK_ERR), (1<<(chn+8)));
508 static __inline
void dma_intr_unmask(uint32_t base,
int chn, uint32_t mask)
511 if (mask & DMA_IT_STATUS_TFR) {
512 WR_WORD((base + DMA_REG_INTR_MASK_TFR), ((1<<chn) | (1<<(chn+8))));
515 if (mask & DMA_IT_STATUS_BLOCK) {
516 WR_WORD((base + DMA_REG_INTR_MASK_BLOCK), ((1<<chn) | (1<<(chn+8))));
519 if (mask & DMA_IT_STATUS_SRCT) {
520 WR_WORD((base + DMA_REG_INTR_MASK_SRC), ((1<<chn) | (1<<(chn+8))));
523 if (mask & DMA_IT_STATUS_DSTT) {
524 WR_WORD((base + DMA_REG_INTR_MASK_DST), ((1<<chn) | (1<<(chn+8))));
527 if (mask & DMA_IT_STATUS_ERR) {
528 WR_WORD((base + DMA_REG_INTR_MASK_ERR), ((1<<chn) | (1<<(chn+8))));
532 static __inline
void dma_sw_src_req(uint32_t base,
int chn)
534 WR_WORD((base + DMA_REG_SRC_SW_REQ), ((1<<chn)|(1<<(8+chn))));
537 static __inline
void dma_sw_dst_req(uint32_t base,
int chn)
539 WR_WORD((base + DMA_REG_DST_SW_REQ), ((1<<chn)|(1<<(8+chn))));
542 static __inline
void dma_sw_src_sreq(uint32_t base,
int chn)
544 WR_WORD((base + DMA_REG_SRC_SW_SGLREQ), ((1<<chn)|(1<<(8+chn))));
547 static __inline
void dma_sw_dst_sreq(uint32_t base,
int chn)
549 WR_WORD((base + DMA_REG_DST_SW_SGLREQ), ((1<<chn)|(1<<(8+chn))));
552 static __inline
void dma_sw_src_lreq(uint32_t base,
int chn)
554 WR_WORD((base + DMA_REG_LST_SRC_SW_REQ), ((1<<chn)|(1<<(8+chn))));
557 static __inline
void dma_sw_dst_lreq(uint32_t base,
int chn)
559 WR_WORD((base + DMA_REG_LST_DST_SW_REQ), ((1<<chn)|(1<<(8+chn))));
562 static __inline
void dma_ch_set_sar(uint32_t ch_base, uint32_t addr)
564 WR_WORD(ch_base + DMA_CH_REG_SAR_OFS, addr);
567 static __inline
void dma_ch_set_dar(uint32_t ch_base, uint32_t addr)
569 WR_WORD(ch_base + DMA_CH_REG_DAR_OFS, addr);
572 static __inline
void dma_ch_intr_enable(uint32_t ch_base)
574 uint32_t reg = RD_WORD(ch_base + DMA_CH_REG_CTL_OFS);
575 reg |= DMA_CH_CTL_INT_EN;
577 WR_WORD(ch_base + DMA_CH_REG_CTL_OFS, reg);
580 static __inline
void dma_ch_intr_disable(uint32_t ch_base)
582 uint32_t reg = RD_WORD(ch_base + DMA_CH_REG_CTL_OFS);
583 reg &= ~DMA_CH_CTL_INT_EN;
584 WR_WORD(ch_base + DMA_CH_REG_CTL_OFS, reg);
587 static __inline
void dma_ch_dst_width(uint32_t ch_base,
int data_width)
589 uint32_t reg = RD_WORD(ch_base + DMA_CH_REG_CTL_OFS);
590 reg &= ~DMA_CH_CTL_DST_TR_WIDTH;
591 reg |= (data_width & 0x7) << 1;
592 WR_WORD(ch_base + DMA_CH_REG_CTL_OFS, reg);
595 static __inline
void dma_ch_src_width(uint32_t ch_base,
int data_width)
597 uint32_t reg = RD_WORD(ch_base + DMA_CH_REG_CTL_OFS);
598 reg &= ~DMA_CH_CTL_SRC_TR_WIDTH;
599 reg |= (data_width & 0x7) << 4;
600 WR_WORD(ch_base + DMA_CH_REG_CTL_OFS, reg);
603 static __inline
void dma_ch_dst_inc(uint32_t ch_base,
int dinc)
605 uint32_t reg = RD_WORD(ch_base + DMA_CH_REG_CTL_OFS);
606 reg &= ~DMA_CH_CTL_DINC;
607 reg |= (dinc & 0x3) << 7;
608 WR_WORD(ch_base + DMA_CH_REG_CTL_OFS, reg);
611 static __inline
void dma_ch_src_inc(uint32_t ch_base,
int sinc)
613 uint32_t reg = RD_WORD(ch_base + DMA_CH_REG_CTL_OFS);
614 reg &= ~DMA_CH_CTL_SINC;
615 reg |= (sinc & 0x3) << 9;
616 WR_WORD(ch_base + DMA_CH_REG_CTL_OFS, reg);
619 static __inline
void dma_ch_dst_msize(uint32_t ch_base,
int msize)
621 uint32_t reg = RD_WORD(ch_base + DMA_CH_REG_CTL_OFS);
622 reg &= ~DMA_CH_CTL_DEST_MSIZE;
623 reg |= (msize & 0x7) << 11;
624 WR_WORD(ch_base + DMA_CH_REG_CTL_OFS, reg);
627 static __inline
void dma_ch_src_msize(uint32_t ch_base,
int msize)
629 uint32_t reg = RD_WORD(ch_base + DMA_CH_REG_CTL_OFS);
630 reg &= ~DMA_CH_CTL_SRC_MSIZE;
631 reg |= (msize & 0x7) << 14;
632 WR_WORD(ch_base + DMA_CH_REG_CTL_OFS, reg);
635 static __inline
void dma_ch_tran_type_fc(uint32_t ch_base,
int tt_fc)
637 uint32_t reg = RD_WORD(ch_base + DMA_CH_REG_CTL_OFS);
638 reg &= ~DMA_CH_CTL_TT_FC;
639 reg |= (tt_fc & 0x7) << 20;
640 WR_WORD(ch_base + DMA_CH_REG_CTL_OFS, reg);
643 static __inline
void dma_ch_dst_ahb_master(uint32_t ch_base,
int dms)
645 uint32_t reg = RD_WORD(ch_base + DMA_CH_REG_CTL_OFS);
646 reg &= ~DMA_CH_CTL_DMS;
647 reg |= (dms & 0x3) << 23;
648 WR_WORD(ch_base + DMA_CH_REG_CTL_OFS, reg);
651 static __inline
void dma_ch_src_ahb_master(uint32_t ch_base,
int sms)
653 uint32_t reg = RD_WORD(ch_base + DMA_CH_REG_CTL_OFS);
654 reg &= ~DMA_CH_CTL_SMS;
655 reg |= (sms & 0x3) << 25;
656 WR_WORD(ch_base + DMA_CH_REG_CTL_OFS, reg);
659 static __inline
void dma_ch_llp_dst_en(uint32_t ch_base,
int en)
661 uint32_t reg = RD_WORD(ch_base + DMA_CH_REG_CTL_OFS);
663 reg |= DMA_CH_CTL_LLP_DST_EN;
665 reg &= ~DMA_CH_CTL_LLP_DST_EN;
667 WR_WORD(ch_base + DMA_CH_REG_CTL_OFS, reg);
670 static __inline
void dma_ch_llp_src_en(uint32_t ch_base,
int en)
672 uint32_t reg = RD_WORD(ch_base + DMA_CH_REG_CTL_OFS);
674 reg |= DMA_CH_CTL_LLP_SRC_EN;
676 reg &= ~DMA_CH_CTL_LLP_SRC_EN;
678 WR_WORD(ch_base + DMA_CH_REG_CTL_OFS, reg);
681 static __inline
void dma_ch_tran_block_size(uint32_t ch_base,
int block_ts)
683 uint32_t reg = RD_WORD(ch_base + DMA_CH_REG_CTL_OFS + 4);
684 reg &= ~DMA_CH_CTL_BLOCK_TS;
686 WR_WORD(ch_base + DMA_CH_REG_CTL_OFS + 4, reg);
689 static __inline uint32_t dma_ch_get_tran_block_size(uint32_t ch_base)
691 uint32_t reg = RD_WORD(ch_base + DMA_CH_REG_CTL_OFS + 4);
692 reg &= DMA_CH_CTL_BLOCK_TS;
696 static __inline
void dma_ch_set_prio(uint32_t ch_base,
int priority)
698 uint32_t reg = RD_WORD(ch_base + DMA_CH_REG_CFG_OFS);
699 reg &= ~DMA_CH_CFG_PRIOR;
700 reg |= (priority & 0x7) << 5;
701 WR_WORD(ch_base + DMA_CH_REG_CFG_OFS, reg);
704 static __inline
int dma_ch_get_prio(uint32_t ch_base)
706 uint32_t reg = RD_WORD(ch_base + DMA_CH_REG_CFG_OFS);
713 static __inline
int dma_ch_fifo_empty(uint32_t ch_base)
715 return (((RD_WORD(ch_base + DMA_CH_REG_CFG_OFS) & DMA_CH_CFG_FIFO_EMPTY) ? 1 : 0));
718 static __inline
void dma_ch_suspend(uint32_t ch_base)
720 uint32_t reg = RD_WORD(ch_base + DMA_CH_REG_CFG_OFS);
722 reg |= DMA_CH_CFG_SUSP;
724 WR_WORD(ch_base + DMA_CH_REG_CFG_OFS, reg);
726 while (!dma_ch_fifo_empty(ch_base));
729 static __inline
void dma_ch_hs_dest(uint32_t ch_base,
int hw)
731 uint32_t reg = RD_WORD(ch_base + DMA_CH_REG_CFG_OFS);
734 reg &= ~DMA_CH_CFG_HS_SEL_DST;
736 reg |= DMA_CH_CFG_HS_SEL_DST;
739 WR_WORD(ch_base + DMA_CH_REG_CFG_OFS, reg);
742 static __inline
void dma_ch_hs_src(uint32_t ch_base,
int hw)
744 uint32_t reg = RD_WORD(ch_base + DMA_CH_REG_CFG_OFS);
747 reg &= ~DMA_CH_CFG_HS_SEL_SRC;
749 reg |= DMA_CH_CFG_HS_SEL_SRC;
752 WR_WORD(ch_base + DMA_CH_REG_CFG_OFS, reg);
755 static __inline
void dma_ch_hs_pol_dest(uint32_t ch_base,
int active_high)
757 uint32_t reg = RD_WORD(ch_base + DMA_CH_REG_CFG_OFS);
760 reg &= ~DMA_CH_CFG_DST_HS_POL;
762 reg |= DMA_CH_CFG_DST_HS_POL;
765 WR_WORD(ch_base + DMA_CH_REG_CFG_OFS, reg);
768 static __inline
void dma_ch_hs_pol_src(uint32_t ch_base,
int active_high)
770 uint32_t reg = RD_WORD(ch_base + DMA_CH_REG_CFG_OFS);
773 reg &= ~DMA_CH_CFG_SRC_HS_POL;
775 reg |= DMA_CH_CFG_SRC_HS_POL;
778 WR_WORD(ch_base + DMA_CH_REG_CFG_OFS, reg);
781 static __inline
void dma_ch_sar_reload(uint32_t ch_base,
int reload)
783 uint32_t reg = RD_WORD(ch_base + DMA_CH_REG_CFG_OFS);
786 reg |= DMA_CH_CFG_RELOAD_SRC;
788 reg &= ~DMA_CH_CFG_RELOAD_SRC;
791 WR_WORD(ch_base + DMA_CH_REG_CFG_OFS, reg);
794 static __inline
void dma_ch_dest_reload(uint32_t ch_base,
int reload)
796 uint32_t reg = RD_WORD(ch_base + DMA_CH_REG_CFG_OFS);
799 reg |= DMA_CH_CFG_RELOAD_DST;
801 reg &= ~DMA_CH_CFG_RELOAD_DST;
804 WR_WORD(ch_base + DMA_CH_REG_CFG_OFS, reg);
807 static __inline
void dma_ch_fc(uint32_t ch_base,
int pre_fetch)
809 uint32_t reg = RD_WORD(ch_base + DMA_CH_REG_CFG_OFS + 4);
812 reg &= ~DMA_CH_CFG_FCMODE;
814 reg |= DMA_CH_CFG_FCMODE;
817 WR_WORD(ch_base + DMA_CH_REG_CFG_OFS + 4, reg);
820 static __inline
void dma_ch_fifo(uint32_t ch_base,
int single)
822 uint32_t reg = RD_WORD(ch_base + DMA_CH_REG_CFG_OFS + 4);
825 reg &= ~DMA_CH_CFG_FIFO_MODE;
827 reg |=~DMA_CH_CFG_FIFO_MODE;
830 WR_WORD(ch_base + DMA_CH_REG_CFG_OFS + 4, reg);
833 static __inline
void dma_ch_src_periph_id(uint32_t ch_base,
int id)
835 uint32_t reg = RD_WORD(ch_base + DMA_CH_REG_CFG_OFS + 4);
837 reg &= ~DMA_CH_CFG_SRC_PER;
839 WR_WORD(ch_base + DMA_CH_REG_CFG_OFS + 4, reg);
842 static __inline
void dma_ch_dest_periph_id(uint32_t ch_base,
int id)
844 uint32_t reg = RD_WORD(ch_base + DMA_CH_REG_CFG_OFS + 4);
846 reg &= ~DMA_CH_CFG_DEST_PER;
848 WR_WORD(ch_base + DMA_CH_REG_CFG_OFS + 4, reg);
851 static __inline
void dma_ch_llp(uint32_t ch_base, uint32_t addr)
853 WR_WORD(ch_base + DMA_CH_REG_LLP_OFS, addr);
856 static __inline uint32_t dma_ch_get_llp(uint32_t ch_base)
858 return (RD_WORD(ch_base + DMA_CH_REG_LLP_OFS) & 0xFFFFFFFC);
890 void *
hal_dma_open(
int id,
int periph_id, uint32_t sar, uint32_t dar,
int size,
int sdw,
int ddw,
int sai,
int dai,
int sbz,
int dbz,
int sahb,
int dahb,
int ttype);
913 void *
hal_dma_soft_open(
int id, uint32_t sar, uint32_t dar,
int size,
int sdw,
int ddw,
int sai,
int dai,
int sbz,
int dbz,
int sahb,
int dahb,
int ttype);
939 int hal_dma_ch_enable(
void *hdl,
void *arg,
void (*callback)(
int id,
void *arg, uint32_t status));
940 int hal_dma_soft_ch_enable(
void *hdl,
void *arg,
void (*callback)(
int id,
void *arg, uint32_t status));
987 int hal_dma_dst_req(
void *hdl);
1024 int hal_dma_add_mb_item(uint32_t ba, uint32_t next_ba, uint32_t dar, uint32_t sar,
int dtw,
int stw,
int dai,
int sai,
int dbz,
int sbz,
int dms,
int sms,
int tt_fc,
int size);
1039 void *
hal_dma_mb_open(
int id, uint32_t bd_addr,
int bda_nb,
int src_periph_id,
int dst_periph_id);
1053 int hal_dma_mb_ch_enable(
void *hdl,
void *arg,
void (*callback)(
int id,
void *arg, uint32_t status));
1054 int hal_dma_mb_ch_enable_no_int(
void *hdl);
1068 int hal_dma_mb_ch_disable_no_int(
void *hdl);
1086 int hal_dma_pcm_en(
void *buffer0,
void *buffer1, uint16_t buffer_len,
void *arg,
void (*callback)(
void * arg,
int id, uint32_t status));
1087 int hal_dma_pcm_dis(
void);
1089 int hal_dma_set_sar(
void *hdl, uint32_t sar);
1090 int hal_dma_set_dar(
void *hdl, uint32_t dar);
1091 int hal_dma_set_tran_block_size(
void *hdl, uint32_t size);
1093 int hal_dma_ch_enable_no_int(
void *hdl);
1094 int hal_dma_ch_disable_no_int(
void *hdl);
1095 int hal_dma_poll_tran_done(
void *hdl,
int max_poll_nb);
int hal_dma_switch_buffer(void *hdl, int sa_da, uint32_t buffer_addr)
DMA change source or destination buffer address : This function is provided to quickly switch buffer ...
int hal_dma_mb_ch_disable(void *hdl, uint32_t baddr)
DMA link list driver open.
int hal_dma_ch_disable(void *hdl)
DMA channel disable.
void * hal_dma_mb_open(int id, uint32_t bd_addr, int bda_nb, int src_periph_id, int dst_periph_id)
DMA block chaining open.
uint32_t hal_dma_get_tran_len(void *hdl)
Get DMA transfer length.
DMA block descriptor structure.
Definition: hal_dma.h:225
void * hal_dma_open(int id, int periph_id, uint32_t sar, uint32_t dar, int size, int sdw, int ddw, int sai, int dai, int sbz, int dbz, int sahb, int dahb, int ttype)
Open the DMA driver.
int hal_dma_add_mb_item(uint32_t ba, uint32_t next_ba, uint32_t dar, uint32_t sar, int dtw, int stw, int dai, int sai, int dbz, int sbz, int dms, int sms, int tt_fc, int size)
Add DMA each block descriptor for block chaining : Call this function before start DMA block chaining...
void * hal_dma_soft_open(int id, uint32_t sar, uint32_t dar, int size, int sdw, int ddw, int sai, int dai, int sbz, int dbz, int sahb, int dahb, int ttype)
Open a Software Control DMA driver.
int hal_dma_mb_ch_enable(void *hdl, void *arg, void(*callback)(int id, void *arg, uint32_t status))
DMA link list driver open.
int hal_dma_ch_enable(void *hdl, void *arg, void(*callback)(int id, void *arg, uint32_t status))
(Software Control) DMA channel enable
char hal_dma_ch_is_enabled(void *hdl)
DMA channel is enabled.
void hal_dma_close(void *hdl)
Close the DMA driver.
int hal_dma_pcm_en(void *buffer0, void *buffer1, uint16_t buffer_len, void *arg, void(*callback)(void *arg, int id, uint32_t status))
DMA Audio block's PCM data to memory : This function is not responsible for setting up Audio Block's ...
int hal_dma_src_req(void *hdl)
DMA controlled by software to transfer data from or to peripheral.