/* @threshold = 0..3. FIFO threshold: 0 means 1/4 full FIFO; 1 means 1/2 full FIFO; 2 means 3/4 full FIFO; 3 means full FIFO.  */
int stm32_dma_ch_init_fifo(int ch, enum stm32_dma_mode burst, enum stm32_dma_threshold threshold)
/* @threshold = 0..3. FIFO threshold: 0 means 1/4 full FIFO; 1 means 1/2 full FIFO; 2 means 3/4 full FIFO; 3 means full FIFO.  */
int stm32_dma_ch_init_fifo(int ch, enum stm32_dma_mode burst, enum stm32_dma_threshold threshold)
{
	volatile struct stm32_dma_ch_regs *ch_regs;
	DMAAPI_LOCKED_BEGIN
	if (burst > 1 || threshold > 3) {
		rv = -EINVAL;
		goto unlock;
	}
	ch_regs = dma_ch_regs(ch);
	if (ch_regs->cr & STM32_DMA_CR_EN) {
		rv = -EBUSY;
		goto unlock;
	}
	ch_regs->fcr =
		(ch_regs->fcr & ~(STM32_DMA_FCR_DMDIS_MSK |
			STM32_DMA_FCR_FTH_MSK)) |
		((u32)burst << STM32_DMA_FCR_DMDIS_BIT) |
		((u32)threshold << STM32_DMA_FCR_FTH_BITS);
	DMAAPI_LOCKED_END
}