dma_v.h 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. /*
  3. * Copyright 2002 Integrated Device Technology, Inc.
  4. * All rights reserved.
  5. *
  6. * DMA register definition.
  7. *
  8. * Author : ryan.holmQVist@idt.com
  9. * Date : 20011005
  10. */
  11. #ifndef _ASM_RC32434_DMA_V_H_
  12. #define _ASM_RC32434_DMA_V_H_
  13. #include <asm/mach-rc32434/dma.h>
  14. #include <asm/mach-rc32434/rc32434.h>
  15. #define DMA_CHAN_OFFSET 0x14
  16. #define IS_DMA_USED(X) (((X) & \
  17. (DMA_DESC_FINI | DMA_DESC_DONE | DMA_DESC_TERM)) \
  18. != 0)
  19. #define DMA_COUNT(count) ((count) & DMA_DESC_COUNT_MSK)
  20. #define DMA_HALT_TIMEOUT 500
  21. static inline int rc32434_halt_dma(struct dma_reg *ch)
  22. {
  23. int timeout = 1;
  24. if (__raw_readl(&ch->dmac) & DMA_CHAN_RUN_BIT) {
  25. __raw_writel(0, &ch->dmac);
  26. for (timeout = DMA_HALT_TIMEOUT; timeout > 0; timeout--) {
  27. if (__raw_readl(&ch->dmas) & DMA_STAT_HALT) {
  28. __raw_writel(0, &ch->dmas);
  29. break;
  30. }
  31. }
  32. }
  33. return timeout ? 0 : 1;
  34. }
  35. static inline void rc32434_start_dma(struct dma_reg *ch, u32 dma_addr)
  36. {
  37. __raw_writel(0, &ch->dmandptr);
  38. __raw_writel(dma_addr, &ch->dmadptr);
  39. }
  40. static inline void rc32434_chain_dma(struct dma_reg *ch, u32 dma_addr)
  41. {
  42. __raw_writel(dma_addr, &ch->dmandptr);
  43. }
  44. #endif /* _ASM_RC32434_DMA_V_H_ */