xref: /linux/arch/mips/include/asm/mach-rc32434/dma_v.h (revision 498495dba268b20e8eadd7fe93c140c68b6cc9d2)
1*b2441318SGreg Kroah-Hartman /* SPDX-License-Identifier: GPL-2.0 */
2384740dcSRalf Baechle /*
3384740dcSRalf Baechle  * Copyright 2002 Integrated Device Technology, Inc.
4384740dcSRalf Baechle  *		All rights reserved.
5384740dcSRalf Baechle  *
6384740dcSRalf Baechle  * DMA register definition.
7384740dcSRalf Baechle  *
8384740dcSRalf Baechle  * Author : ryan.holmQVist@idt.com
9384740dcSRalf Baechle  * Date	  : 20011005
10384740dcSRalf Baechle  */
11384740dcSRalf Baechle 
12384740dcSRalf Baechle #ifndef _ASM_RC32434_DMA_V_H_
13384740dcSRalf Baechle #define _ASM_RC32434_DMA_V_H_
14384740dcSRalf Baechle 
15384740dcSRalf Baechle #include  <asm/mach-rc32434/dma.h>
16384740dcSRalf Baechle #include  <asm/mach-rc32434/rc32434.h>
17384740dcSRalf Baechle 
18384740dcSRalf Baechle #define DMA_CHAN_OFFSET		0x14
19384740dcSRalf Baechle #define IS_DMA_USED(X)		(((X) & \
20384740dcSRalf Baechle 				(DMA_DESC_FINI | DMA_DESC_DONE | DMA_DESC_TERM)) \
21384740dcSRalf Baechle 				!= 0)
22384740dcSRalf Baechle #define DMA_COUNT(count)	((count) & DMA_DESC_COUNT_MSK)
23384740dcSRalf Baechle 
24384740dcSRalf Baechle #define DMA_HALT_TIMEOUT	500
25384740dcSRalf Baechle 
rc32434_halt_dma(struct dma_reg * ch)26384740dcSRalf Baechle static inline int rc32434_halt_dma(struct dma_reg *ch)
27384740dcSRalf Baechle {
28384740dcSRalf Baechle 	int timeout = 1;
29384740dcSRalf Baechle 	if (__raw_readl(&ch->dmac) & DMA_CHAN_RUN_BIT) {
30384740dcSRalf Baechle 		__raw_writel(0, &ch->dmac);
31384740dcSRalf Baechle 		for (timeout = DMA_HALT_TIMEOUT; timeout > 0; timeout--) {
32384740dcSRalf Baechle 			if (__raw_readl(&ch->dmas) & DMA_STAT_HALT) {
33384740dcSRalf Baechle 				__raw_writel(0, &ch->dmas);
34384740dcSRalf Baechle 				break;
35384740dcSRalf Baechle 			}
36384740dcSRalf Baechle 		}
37384740dcSRalf Baechle 	}
38384740dcSRalf Baechle 
39384740dcSRalf Baechle 	return timeout ? 0 : 1;
40384740dcSRalf Baechle }
41384740dcSRalf Baechle 
rc32434_start_dma(struct dma_reg * ch,u32 dma_addr)42384740dcSRalf Baechle static inline void rc32434_start_dma(struct dma_reg *ch, u32 dma_addr)
43384740dcSRalf Baechle {
44384740dcSRalf Baechle 	__raw_writel(0, &ch->dmandptr);
45384740dcSRalf Baechle 	__raw_writel(dma_addr, &ch->dmadptr);
46384740dcSRalf Baechle }
47384740dcSRalf Baechle 
rc32434_chain_dma(struct dma_reg * ch,u32 dma_addr)48384740dcSRalf Baechle static inline void rc32434_chain_dma(struct dma_reg *ch, u32 dma_addr)
49384740dcSRalf Baechle {
50384740dcSRalf Baechle 	__raw_writel(dma_addr, &ch->dmandptr);
51384740dcSRalf Baechle }
52384740dcSRalf Baechle 
53384740dcSRalf Baechle #endif	/* _ASM_RC32434_DMA_V_H_ */
54